Ignore:
Timestamp:
11/19/12 10:59:53 (12 years ago)
Author:
Jens Buss
Message:
put pedestal readout into file header
Location:
fact/tools/marsmacros/mc2csv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/marsmacros/mc2csv/MonteCarlo.C

    r14625 r14657  
    600600}
    601601
    602 
    603602void
    604603MonteCarlo::WriteMc2Csv(TString filename)
     
    616615    OpenCsvFile(mCsvFileName);
    617616
    618     WriteFileHeader2Csv();
    619     WriteRunHeaderNames2Csv();
     617    WriteFileInfo2Csv();
     618    WriteRunHeaderInfo2Csv();
    620619    WriteRunHeader2Csv();
    621     WriteEventHeaderNames2Csv();
    622     WriteEventDataNames2Csv();
     620
     621    WritePedestalInfo2Csv();
     622    WritePedestal2Csv();
     623
     624    WriteEventHeaderInfo2Csv();
     625    WriteEventDataInfo2Csv();
    623626
    624627//    for (int evt = 0; evt < mNumberOfEvents; evt++)
     
    636639}
    637640
    638 
    639 void
    640 MonteCarlo::WritePixelData2Csv(int pixelID)
    641 {
    642     if (mVerbosityLvl > 3) cout << "...writing pixel data to csv" << endl;
    643     mCsv << mEventNumber << mSeparator;
    644     mCsv << mpPixel[pixelID].SoftId << mSeparator;
    645     mCsv << mpPixel[pixelID].pedestal << mSeparator;
    646 
    647     for (int i = 0; i < mNumberOfSamples; i++)
    648     {
    649          mCsv << mpPixel[pixelID].rawData[i] << mSeparator;
    650     }
    651     mCsv << endl;
    652 
    653     return;
    654 }
    655 
    656 void
    657 MonteCarlo::WriteEventData2Csv()
    658 {
    659     if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
    660 
    661     for (int i = 0; i < mNumberOfPixels; i++)
    662     {
    663         WritePixelData2Csv(i);
    664     }
    665 
    666     return;
    667 }
    668 
    669 void
    670 MonteCarlo::WriteEventDataNames2Csv()
    671 {
    672     if (mVerbosityLvl > 0) cout << "...writing event categories to csv" << endl;
    673 
    674     mCsv << "### [RawData]" << endl;
    675     mCsv << "# mEventNumber" << mSeparator;
    676     mCsv << "pixelID" << mSeparator;
    677      mCsv << "pixelPedestal" << mSeparator;
    678     for (int i = 0; i < mNumberOfSamples; i++)
    679     {
    680         mCsv << "Raw_" << i << mSeparator;
    681     }
    682     mCsv << endl;
    683 
    684     return;
    685 }
    686 
    687 void
    688 MonteCarlo::WriteEventHeaderNames2Csv()
     641void
     642MonteCarlo::WriteFileInfo2Csv()
     643{
     644    if (mVerbosityLvl > 0) cout << "...writing file header to csv" << endl;
     645
     646    mCsv << "### ==========================================================="
     647            << endl;
     648    mCsv << "### =             FACT Monte Carlo                            ="
     649            << endl;
     650    mCsv << "### ==========================================================="
     651            << endl;
     652    mCsv << "### = FileInfo:                                               "
     653            << endl;
     654    mCsv << "### =                                                         "
     655            << endl;
     656    mCsv << "### = Source Name:       " << mSourceName << endl;
     657    mCsv << "### = Number of Entries: " << mNumberOfEntries << endl;
     658    mCsv << "### = Run Number:        " << mRunNumber << endl;
     659    mCsv << "### = Run Type  :        " << mRunType << endl;
     660    mCsv << "### = File Number:       " << mFileNumber << endl;
     661    mCsv << "### ==========================================================="
     662         << endl ;
     663    mCsv << "###"
     664         << endl ;
     665
     666    return;
     667}
     668
     669void
     670MonteCarlo::WriteRunHeaderInfo2Csv()
     671{
     672    if (mVerbosityLvl > 0) cout << "...writing run header names to csv" << endl;
     673
     674    mCsv << "### [RunHeader]" << endl;
     675
     676    mCsv << "# mNumberOfEntries" << mSeparator;
     677    mCsv << "mIntendedPulsePos" << mSeparator;
     678//    Csv << "mPedestalOffset" << mSeparator;
     679    mCsv << "mNumSimulatedShowers" << mSeparator;
     680    mCsv << "mNumberOfPixels" << mSeparator;
     681    mCsv << "mNumberOfSamples" << mSeparator;
     682//    mCsv << "mSampleSize" << mSeparator;
     683    mCsv << "mCamDist" << mSeparator;
     684    mCsv << "mSourceName" << mSeparator;
     685    mCsv << "mSlopeSpectrum" << mSeparator;
     686    mCsv << "mEnergyMin" << mSeparator;
     687    mCsv << "mEnergyMax" << mSeparator;
     688    mCsv << "mZdMin" << mSeparator;
     689    mCsv << "mZdMax" << mSeparator;
     690    mCsv << "mAzMin" << mSeparator;
     691    mCsv << "mAzMax" << mSeparator;
     692    mCsv << "mFileNumber" << mSeparator;
     693    mCsv << "mRunnumber" << mSeparator;
     694    mCsv << "mRunType" << endl;
     695
     696    return;
     697}
     698
     699void
     700MonteCarlo::WriteRunHeader2Csv()
     701{
     702    if (mVerbosityLvl > 0) cout << "...writing run header to csv" << endl;
     703
     704    mCsv << mNumberOfEntries << mSeparator;
     705    mCsv << mIntendedPulsePos << mSeparator;
     706//    mCsv << mPedestalOffset << mSeparator;
     707    mCsv << mNumSimulatedShowers << mSeparator;
     708    mCsv << mNumberOfPixels << mSeparator;
     709    mCsv << mNumberOfSamples << mSeparator;
     710//    mCsv << mSampleSize << mSeparator;
     711    mCsv << mCamDist << mSeparator;
     712    mCsv << mSourceName << mSeparator;
     713    mCsv << mSlopeSpectrum << mSeparator;
     714    mCsv << mEnergyMin << mSeparator;
     715    mCsv << mEnergyMax << mSeparator;
     716    mCsv << mZdMin << mSeparator;
     717    mCsv << mZdMax << mSeparator;
     718    mCsv << mAzMin << mSeparator;
     719    mCsv << mAzMax << mSeparator;
     720    mCsv << mFileNumber << mSeparator;
     721    mCsv << mRunNumber << mSeparator;
     722    mCsv << mRunType << endl;
     723
     724    return;
     725}
     726
     727void
     728MonteCarlo::WriteEventHeaderInfo2Csv()
    689729{
    690730    if (mVerbosityLvl > 0) cout << "...writing event header names to csv" << endl;
     
    720760}
    721761
    722 
    723762void
    724763MonteCarlo::WriteEventHeader2Csv()
     
    755794
    756795void
    757 MonteCarlo::WriteRunHeaderNames2Csv()
    758 {
    759     if (mVerbosityLvl > 0) cout << "...writing run header names to csv" << endl;
    760 
    761     mCsv << "### [RunHeader]" << endl;
    762 
    763     mCsv << "# mNumberOfEntries" << mSeparator;
    764     mCsv << "mIntendedPulsePos" << mSeparator;
    765 //    Csv << "mPedestalOffset" << mSeparator;
    766     mCsv << "mNumSimulatedShowers" << mSeparator;
    767     mCsv << "mNumberOfPixels" << mSeparator;
    768     mCsv << "mNumberOfSamples" << mSeparator;
    769 //    mCsv << "mSampleSize" << mSeparator;
    770     mCsv << "mCamDist" << mSeparator;
    771     mCsv << "mSourceName" << mSeparator;
    772     mCsv << "mSlopeSpectrum" << mSeparator;
    773     mCsv << "mEnergyMin" << mSeparator;
    774     mCsv << "mEnergyMax" << mSeparator;
    775     mCsv << "mZdMin" << mSeparator;
    776     mCsv << "mZdMax" << mSeparator;
    777     mCsv << "mAzMin" << mSeparator;
    778     mCsv << "mAzMax" << mSeparator;
    779     mCsv << "mFileNumber" << mSeparator;
    780     mCsv << "mRunnumber" << mSeparator;
    781     mCsv << "mRunType" << endl;
    782 
    783     return;
    784 }
    785 
    786 
    787 void
    788 MonteCarlo::WriteRunHeader2Csv()
    789 {
    790     if (mVerbosityLvl > 0) cout << "...writing run header to csv" << endl;
    791 
    792     mCsv << mNumberOfEntries << mSeparator;
    793     mCsv << mIntendedPulsePos << mSeparator;
    794 //    mCsv << mPedestalOffset << mSeparator;
    795     mCsv << mNumSimulatedShowers << mSeparator;
    796     mCsv << mNumberOfPixels << mSeparator;
    797     mCsv << mNumberOfSamples << mSeparator;
    798 //    mCsv << mSampleSize << mSeparator;
    799     mCsv << mCamDist << mSeparator;
    800     mCsv << mSourceName << mSeparator;
    801     mCsv << mSlopeSpectrum << mSeparator;
    802     mCsv << mEnergyMin << mSeparator;
    803     mCsv << mEnergyMax << mSeparator;
    804     mCsv << mZdMin << mSeparator;
    805     mCsv << mZdMax << mSeparator;
    806     mCsv << mAzMin << mSeparator;
    807     mCsv << mAzMax << mSeparator;
    808     mCsv << mFileNumber << mSeparator;
    809     mCsv << mRunNumber << mSeparator;
    810     mCsv << mRunType << endl;
    811 
    812     return;
    813 }
    814 
    815 void
    816 MonteCarlo::WriteFileHeader2Csv()
    817 {
    818     if (mVerbosityLvl > 0) cout << "...writing file header to csv" << endl;
    819 
    820     mCsv << "### ==========================================================="
    821             << endl;
    822     mCsv << "### =             FACT Monte Carlo                            ="
    823             << endl;
    824     mCsv << "### ==========================================================="
    825             << endl;
    826     mCsv << "### = FileInfo:                                               "
    827             << endl;
    828     mCsv << "### =                                                         "
    829             << endl;
    830     mCsv << "### = Source Name:       " << mSourceName << endl;
    831     mCsv << "### = Number of Entries: " << mNumberOfEntries << endl;
    832     mCsv << "### = Run Number:        " << mRunNumber << endl;
    833     mCsv << "### = Run Type  :        " << mRunType << endl;
    834     mCsv << "### = File Number:       " << mFileNumber << endl;
    835     mCsv << "### ==========================================================="
    836          << endl ;
    837     mCsv << "###"
    838          << endl ;
    839 
    840     return;
    841 }
    842 
     796MonteCarlo::WriteEventDataInfo2Csv()
     797{
     798    if (mVerbosityLvl > 0) cout << "...writing event categories to csv" << endl;
     799
     800    mCsv << "### [RawData]" << endl;
     801    mCsv << "# mEventNumber" << mSeparator;
     802    mCsv << "pixelID" << mSeparator;
     803//     mCsv << "pixelPedestal" << mSeparator;
     804    for (int i = 0; i < mNumberOfSamples; i++)
     805    {
     806        mCsv << "Raw_" << i << mSeparator;
     807    }
     808    mCsv << endl;
     809
     810    return;
     811}
     812
     813void
     814MonteCarlo::WriteEventData2Csv()
     815{
     816    if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
     817
     818    for (int i = 0; i < mNumberOfPixels; i++)
     819    {
     820        WritePixelData2Csv(i);
     821    }
     822
     823    return;
     824}
     825
     826void
     827MonteCarlo::WritePixelData2Csv(int pixelID)
     828{
     829    if (mVerbosityLvl > 3) cout << "...writing pixel data to csv" << endl;
     830    mCsv << mEventNumber << mSeparator;
     831    mCsv << mpPixel[pixelID].SoftId << mSeparator;
     832//    mCsv << mpPixel[pixelID].pedestal << mSeparator;
     833
     834    for (int i = 0; i < mNumberOfSamples; i++)
     835    {
     836         mCsv << mpPixel[pixelID].rawData[i] << mSeparator;
     837    }
     838    mCsv << endl;
     839
     840    return;
     841}
     842
     843void
     844MonteCarlo::WritePedestalInfo2Csv()
     845{
     846    mCsv << "### [Pedestal info]" << endl;
     847    mCsv << "# SoftID" ;
     848    mCsv << mSeparator ;
     849    mCsv << "Pedestal" << endl;
     850}
     851
     852void
     853MonteCarlo::WritePedestal2Csv()
     854{
     855    if (mVerbosityLvl > 3) cout << "...writing pedestal info to csv" << endl;
     856
     857    for (int pixelID = 0; pixelID < mNumberOfPixels; pixelID++)
     858    {
     859        mCsv << mpPixel[pixelID].SoftId;
     860        mCsv << mSeparator;
     861        mCsv << mpPixel[pixelID].pedestal;
     862        mCsv << endl;
     863    }
     864    mCsv << endl;
     865
     866    return;
     867}
    843868
    844869
     
    847872//
    848873//
    849 
    850 
    851874//  FADC samples (hi gain) of all pixels
    852875//  This is an array of Byte_t variables. The value of a FADC sample has a
     
    859882
    860883
    861 /*
    862 int extractMC()
    863 {
    864 
    865     TTree *tree = (TTree*)f.Get("Events");
    866 
    867 //    MArrayB *array = NULL;
    868 
    869     const float dconv = 2000/4096;
    870 
    871     unsigned short *short_array;
    872     TH1F histo("histo", "histo", 150, 0, 150);
    873 
    874     TCanvas *canvas = new TCanvas("canvas", "canvas", 0, 0, 400, 400 );
    875     canvas->cd();
    876     tree->SetBranchAddress("MRawEvtData.", &branch1);
    877 
    878     tree->GetEntry(22);
    879 
    880     cout << "Branch1 " << branch1 << endl;
    881 
    882     array = branch1->GetSamples();
    883 
    884 
    885     for(int i = 0; i < 150; i++){
    886         cout << "i_" << i << "\t 1. " << short_array[i] ;
    887         short_array[i] = le16toh(short_array[i]);
    888 
    889 //        uint16_t htobe16(uint16_t host_16bits);
    890 //        uint16_t htole16(uint16_t host_16bits);
    891 //        uint16_t be16toh(uint16_t big_endian_16bits);
    892 
    893 
    894         cout << "\t 2. " << short_array[i] ;
    895         cout << "\t arr. " << (int)array[2*i] << " " << (int)array[2*i+1] << endl;
    896 
    897         histo.SetBinContent(i, short_array[i]-1000);
    898     }
    899     histo.DrawCopy();
    900     canvas->Modified();
    901     canvas->Update();
    902 
    903 //    int m = branch1->GetNumHiGainSamples();
    904 //    int n = branch1->GetNumBytesPerSample();
    905 
    906     cout << "GetNumHiGainSamples " << branch1->GetNumHiGainSamples()
    907          << " GetNumBytesPerSample " << branch1->GetNumBytesPerSample() << endl;
    908 
    909 //    tree->GetEntry(2);
    910 
    911 //    array = branch1->GetSamples();
    912 
    913 //    cout << "Branch2 " << branch1 << endl;
    914 
    915 ////    for(int i = 1439; i < 1441; i++){
    916 ////        cout << "Pixel: " << i << endl;
    917 
    918 //        for(int j = 431950; j < 432020; j++){
    919 //            cout << "Sl: " << j << "\t" ;
    920 //            cout << (unsigned short) array[j] << "\t";
    921 //            if ( j%5 == 0 ) cout <<endl;
    922 
    923 //        }
    924 //        cout << endl;
    925 ////    }
    926 
    927 ////    tree->SetBranchAddress("MRawEvtData.fHiGainFadcSamples.fArray", array);
    928 
    929 }
    930 
    931 */
    932 
    933 
    934 
    935 
     884
     885
  • fact/tools/marsmacros/mc2csv/MonteCarlo.h

    r14625 r14657  
    113113    void WritePixelData2Csv(int pixelID);
    114114    void WriteEventData2Csv();
    115     void WriteEventDataNames2Csv();
    116     void WriteEventHeaderNames2Csv();
     115    void WriteEventDataInfo2Csv();
     116    void WriteEventHeaderInfo2Csv();
    117117    void WriteEventHeader2Csv();
    118     void WriteRunHeaderNames2Csv();
     118    void WriteRunHeaderInfo2Csv();
    119119    void WriteRunHeader2Csv();
    120     void WriteFileHeader2Csv();
     120    void WriteFileInfo2Csv();
     121    void WritePedestal2Csv();
     122    void WritePedestalInfo2Csv();
    121123
    122124
Note: See TracChangeset for help on using the changeset viewer.