Changeset 9330 for trunk


Ignore:
Timestamp:
02/12/09 21:04:43 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9329 r9330  
    8181     - consequently removed the kCT1Pulser bit
    8282
     83  * mpedestal/MMcPedestalCopy.[h,cc]:
     84    - fixed for MUX MCs (the pedestal has to be scaled)
     85    - added option to process ceres data
    8386
    8487
  • trunk/MagicSoft/Mars/mpedestal/MMcPedestalCopy.cc

    r8274 r9330  
    7373// --------------------------------------------------------------------------
    7474//
    75 // Check for the run type. Return kTRUE if it is a MC run or if there
    76 // is no MC run header (old camera files) kFALSE in case of a different
    77 // run type
    78 //
    79 Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
    80 {
    81     const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
    82     if (!run)
    83     {
    84       *fLog << warn << dbginf << "Warning - cannot check file type, "
    85             << AddSerialNumber("MRawRunHeader") << " not found." << endl;
    86         return kTRUE;
    87     }
    88 
    89     return run->IsMonteCarloRun();
    90 }
    91 
    92 // --------------------------------------------------------------------------
    93 //
    9475// Make sure that there is a MPedestalCam object in the parameter list.
    9576//
     
    10687Bool_t MMcPedestalCopy::ReInit(MParList *pList)
    10788{
     89    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
     90    if (!run)
     91    {
     92        *fLog << warn << dbginf << "Warning - cannot check file type, " << AddSerialNumber("MRawRunHeader") << " not found." << endl;
     93        return kTRUE;
     94    }
     95
    10896    //
    10997    // If it is no MC file skip this function...
    11098    //
    111     if (!CheckRunType(pList))
    112       {
    113         *fLog << inf << "This is no MC file... skipping." << endl;
     99    if (!run->IsMonteCarloRun())
     100    {
     101        *fLog << inf << "This is no MC file... skipping." << endl;
    114102        return kTRUE;
    115       }
     103    }
     104
     105    MPedestalCam *pedcam = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
     106    if (!pedcam)
     107    {
     108        *fLog << err << "MPedestalCam not found... aborting." << endl;
     109        return kFALSE;
     110    }
     111
     112    // Get MMcRunHeader to check camera version
     113    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject(AddSerialNumber("MMcRunHeader"));
     114
     115    // Check if it is a ceres file
     116    if (mcrun && mcrun->GetCamVersion()==UShort_t(-1))
     117    {
     118        *fLog << inf << "This is a ceres file... subtracting Baseline from ElectronicNoise [MPedestalCam]." << endl;
     119
     120        MPedestalCam *noise = (MPedestalCam*)pList->FindObject(AddSerialNumber("ElectronicNoise"), "MPedestalCam");
     121        if (!noise)
     122        {
     123            *fLog << err << "ElectronicNoise [MPedestalCam] not found... aborting." << endl;
     124            return kFALSE;
     125        }
     126
     127        const int num = pedcam->GetSize();
     128        for (int i=0; i<num; i++)
     129        {
     130            const MPedestalPix &n = (*noise)[i];
     131
     132            (*pedcam)[i].Set(n.GetPedestal()/run->GetScale(),
     133                             n.GetPedestalRms()/run->GetScale());
     134        }
     135
     136        pedcam->SetReadyToSave();
     137
     138        return kTRUE;
     139    }
    116140
    117141    //
     
    126150    }
    127151
    128     MPedestalCam *pedcam = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
    129     if (!pedcam)
    130     {
    131         *fLog << err << "MPedestalCam not found... aborting." << endl;
    132         return kFALSE;
    133     }
    134 
    135     MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject(AddSerialNumber("MMcRunHeader"));
    136152    if (!mcrun)
    137       *fLog << warn << dbginf << AddSerialNumber("MMcRunHeader")
    138             << " not found... assuming camera<0.7" << endl;
    139 
    140     const int num = pedcam->GetSize();
     153        *fLog << warn << dbginf << AddSerialNumber("MMcRunHeader") << " not found... assuming camera<0.7" << endl;
    141154
    142155    const Bool_t camver70 = mcrun && mcrun->GetCamVersion()>=70;
    143156
     157    const int num = pedcam->GetSize();
    144158    for (int i=0; i<num; i++)
    145159    {
    146         MPedestalPix &pix = (*pedcam)[i];
    147 
    148160        // Here one should compute the Pedestal taking into account how
    149161        // the MC makes the transformation analogic-digital for the FADC.
    150162        // This is done only once per file -> not time critical.
    151 
    152163        const Float_t pedest = fadc->GetPedestal(i);
    153164        const Float_t sigma  = camver70 ? fadc->GetPedestalRmsHigh(i) : fadc->GetElecNoise(i);
    154165
    155         pix.Set(pedest, sigma);
    156 
     166        (*pedcam)[i].Set(pedest/run->GetScale(), sigma/run->GetScale());
    157167    }
    158168
Note: See TracChangeset for help on using the changeset viewer.