Changeset 14732


Ignore:
Timestamp:
12/05/12 11:16:10 (12 years ago)
Author:
Jens Buss
Message:
added comments
File:
1 edited

Legend:

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

    r14730 r14732  
    129129//    mpSamples       = NULL;
    130130
    131 
    132131    return;
    133132}
     
    178177    mpRootFile = new TFile(mFileName, "READ");
    179178
     179    //check if root file could be opened
    180180    if (!mpRootFile->IsOpen())
    181181    {
     
    185185    }
    186186    mRootFileOpend = true;
    187 
    188187    return 1;
    189188}
    190189
     190
    191191void
    192192MonteCarlo::CloseRootFile()
    193193{
    194194    if (mVerbosityLvl > 0) cout << "...closing root file: " << mFileName << endl;
     195
     196    // close root file
     197    // If option == "R", all TProcessIDs referenced by this file are deleted.
    195198    mpRootFile->Close("R");
     199
    196200    mpRootFile=NULL;
    197201
     
    199203}
    200204
     205
    201206void
    202207MonteCarlo::LoadHeaderTree(TString treeName)
     
    206211    mpHeaderTree       = (TTree*)mpRootFile->Get(treeName);
    207212
     213    //check if mpHeaderTree exists
    208214    if (mpHeaderTree->IsZombie())
    209215    {
     
    280286}
    281287
     288
    282289void
    283290MonteCarlo::ReadRunHeader()
    284291{
     292    // Read Values from RunHeader-Tree
     293
    285294    if (mVerbosityLvl > 0)
    286295        cout << "...reading run header " << mpHeaderTree << endl;
    287296
    288     //Read Values from RunHeader-Tree
    289 
    290     mpHeaderTree->GetEntry();    //This causes problems
     297    //Get first and only entry
     298    mpHeaderTree->GetEntry();
    291299
    292300    // -----------------------------------------------------------------------
    293301
    294302    //Get values from "MGeomCam" Branch
     303    if ( mpGeomCam != NULL)
     304    {
    295305        //Getter functions from "MGeomCamFACT.h"
    296     if ( mpGeomCam != NULL)
    297     {
    298306        mCamDist                = mpGeomCam->GetCameraDist();
    299307        mNumberOfPixels         = mpGeomCam->GetNumPixels();
     
    319327    if ( mpMcRunHeader != NULL)
    320328    {
     329        //Getter functions from "MMcRunHeader.hxx"
    321330        mNumSimulatedShowers    = mpMcRunHeader->GetNumSimulatedShowers();
    322331    }
     
    342351    if ( mpRawRunHeader != NULL)
    343352    {
    344         mNumberOfEvents         = mpRawRunHeader->GetNumEvents(); // couses problems
     353        //Getter functions from "MRawRunHeader.h"
     354        mNumberOfEvents         = mpRawRunHeader->GetNumEvents();
    345355        mNumberOfEventsRead     = mpRawRunHeader->GetNumEventsRead();
    346356        mSamplingFrequency      = mpRawRunHeader->GetFreqSampling();
     
    360370    if ( mpCorsikaRunHeader != NULL)
    361371    {
     372        //Getter functions from "MCorsikaRunHeader.h"
    362373        mSlopeSpectrum          = mpCorsikaRunHeader->GetSlopeSpectrum();
    363374        mEnergyMin              = mpCorsikaRunHeader->GetEnergyMin();
     
    374385
    375386    // delete Pixel Array before you set refferences for a new one
     387    // in case it is existing
    376388    if (mpPixel != NULL)
    377389    {
     
    387399        if (mVerbosityLvl > 1) cout << "   ...reading pedestal offsets" << endl;
    388400
    389         // Read Pedestal Offset
     401        // Loop over all pixel: Read Pedestal Offset
    390402        for ( int i = 0; i < mNumberOfPixels; i++ )
    391403        {
     404            // check if array entry exists
    392405            if ( &(mpElectronicNoise[0][i]) != NULL)
     406            {
     407                //tricky stuff!!!
     408                // mpElectronicNoise is a MPedestalCam Array
     409                // individual pixel pedestals are stored in a MPedestalPix array
     410                // the [] operator is overloaded in MPedestalCam
     411                // and returning a MPedestalPix at position [i]
     412                // MPedestalPix hast a Getter called GetPedestal()
    393413                mpPixel[i].pedestal   = mpElectronicNoise[0][i].GetPedestal();
     414            }
    394415            else if (mVerbosityLvl > 2)
     416            {
    395417                cout << "   ...cannot read pedestal offset" << endl;
     418            }
    396419        }
    397420    }
     
    486509    if ( mpIncidentAngle != NULL)
    487510    {
     511        //Getter functions from "MGeomCamFACT.h"
    488512        mIncidentAngle          = mpIncidentAngle->GetVal();
    489513    }
     
    519543    if ( mpRawEventHeader != NULL)
    520544    {
     545        //Getter functions from "MRawEventHeader.h"
    521546        mEventNumber            = mpRawEventHeader->GetDAQEvtNumber();
    522547        mNumTriggerLvl1         = mpRawEventHeader->GetNumTrigLvl1();
     
    531556    if ( mpCorsikaEvtHeader != NULL)
    532557    {
     558        //Getter functions from "MCorsikaEvtHeader.h"
    533559        mFirstInteractionHeight = mpCorsikaEvtHeader->GetFirstInteractionHeight();
    534560        mEvtReuse               = mpCorsikaEvtHeader->GetNumReuse();
     
    560586
    561587    // delete Pixel Array before you set refferences for a new one
     588    // in case it is existing
    562589    if (mpPixel != NULL)
    563590    {
     
    574601    }
    575602
     603    // you have to set this before you can read information
     604    // from a magic binary file
    576605    mpRawEventData->InitRead(mpRawRunHeader);
    577606
     
    580609    // -----------------------------------------------------------------------
    581610
     611    //array to contain alle samples of all pixel of a event
    582612    unsigned short* all_raw_data    = NULL;
    583613
    584614    if ( mpRawEventData != NULL)
    585615    {
     616        // point raw data array to RawEventData Array in Event Tree
    586617        all_raw_data    = (unsigned short*) mpRawEventData->GetSamples();
     618        /*
    587619//  FADC samples (hi gain) of all pixels
    588620//  This is an array of Byte_t variables. The value of a FADC sample has a
     
    593625//  i-th FADC sample of the j-th pixel are stored in the n consecutive
    594626//  positions of this array, starting from fHiGainFadcSamples[j*n*m+i*n]
     627*/
    595628    }
    596629    else cout << "...cannot read event raw data" << endl;
     
    601634        cout << "...pixel progress: ";
    602635
     636    //Loop over all camera pixel and read eEvent raw data, pixel ID and pedestal offset
    603637    for ( int i = 0; i < mNumberOfPixels; i++ )
    604638    {
     
    610644        }
    611645
    612         // Read Pedestal Offset
     646        // Read Pedestal Offset and store it in classes pixel_t array
    613647        if ( mpElectronicNoise != NULL)
    614648        {
     
    617651        else cout << "...cannot read pedestal offset" << endl;
    618652
    619         // Read Pixel SoftId
     653        // Read Pixel SoftId and store it in classes pixel_t array
    620654        if ( mpRawEventData != NULL)
    621655        {
     
    626660        pix_first_sample        = i*mNumberOfSamples;
    627661
    628         // point beginning of pixel's rawdata array to address
    629         // of pixel's first sample's adress
     662        // point beginning of class' pixel_t array to the address
     663        // of pixel's first sample's adress in TTree
    630664        mpPixel[i].rawData      = &(all_raw_data[pix_first_sample]);
    631665
     
    650684    mpEventTree->GetEntry(Event);
    651685
     686    //Get Event header data from TTree
    652687    ReadEventMetaData();
     688
     689    //Get Event raw data from TTree
    653690    ReadEventRawData();
    654691
     
    707744    WriteEventDataInfo2Csv();
    708745
    709 //    for (int evt = 0; evt < mNumberOfEvents; evt++)
     746    // loop over all events from tree and write content to csv
     747    //    for (int evt = 0; evt < mNumberOfEvents; evt++)
    710748    for (int evt = 0; evt < mNumberOfEntries; evt++)
    711749    {
     
    884922    mCsv << "pixelID" << mSeparator;
    885923//     mCsv << "pixelPedestal" << mSeparator;
     924
     925    // Loop over number of all samples in pixel
    886926    for (int i = 0; i < mNumberOfSamples; i++)
    887927    {
     
    898938    if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
    899939
    900     // Loop over pixels and write pixeldata to csv
     940    // Loop over all pixels and write pixeldata to csv
    901941    for (int i = 0; i < mNumberOfPixels; i++)
    902942    {
     
    915955//    mCsv << mpPixel[pixelID].pedestal << mSeparator;
    916956
     957    // Loop over number of all samples in pixel and write samples content to csv
    917958    for (int i = 0; i < mNumberOfSamples; i++)
    918959    {
     
    938979    if (mVerbosityLvl > 3) cout << "...writing pedestal info to csv" << endl;
    939980
     981    // Loop over all pixels and write pixel pedestal to csv
    940982    for (int pixelID = 0; pixelID < mNumberOfPixels; pixelID++)
    941983    {
Note: See TracChangeset for help on using the changeset viewer.