Changeset 4628


Ignore:
Timestamp:
08/16/04 14:59:34 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r4624 r4628  
    2121!   Author(s): Markus Gaug     04/2004 <mailto:markus@ifae.es>
    2222!   Author(s): Hendrik Bartko  08/2004 <mailto:hbartko@mppmu.mpg.de>
     23!   Author(s): Thomas Bretz    08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
    2324!
    2425!   Copyright: MAGIC Software Development, 2000-2004
     
    4748//   The calibration modes which exclude non-valid pixels are the following:
    4849//
    49 //   kFfactor:    calibrates using the F-Factor method
    50 //   kBlindpixel: calibrates using the BlindPixel method
    51 //   kBlindpixel: calibrates using the BlindPixel method
    52 //   kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected.
    53 //   kDummy:      calibrates with fixed conversion factors of 1 and errors of 0.
     50//     kFfactor:    calibrates using the F-Factor method
     51//     kBlindpixel: calibrates using the BlindPixel method
     52//     kBlindpixel: calibrates using the BlindPixel method
     53//     kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected.
     54//     kDummy:      calibrates with fixed conversion factors of 1 and errors of 0.
    5455//
    5556//   The calibration modes which include all pixels regardless of their validity is:
    5657//
    57 //   kNone:       calibrates with fixed conversion factors of 1 and errors of 0.
    58 //
    59 //   Use the kDummy and kNone methods ONLY FOR DEBUGGING!   
     58//     kNone:       calibrates with fixed conversion factors of 1 and errors of 0.
     59//
     60//   Use the kDummy and kNone methods ONLY FOR DEBUGGING!
     61//
     62//
     63//   This class can calibrate data and/or pedestals. To switch off calibration of data
     64//   set the Calibration Mode to kSkip. To switch on pedestal calibration call either
     65//     SetPedestalFlag(MCalibrateData::kRun)    (calibration is done once in ReInit)
     66//     SetPedestalFlag(MCalibrateData::kEvent)  (calibration is done for each event)
     67//
     68//   By calling SetNamePedADCContainer() and/or SetNamePedPhotContainer() you
     69//   can control the name of the MPedestalCam and/or MPedPhotCam container which is used.
     70//
     71//   Assume you want to calibrate "MPedestalCam" once and "MPedestalFromLoGain" [MPedestalCam]
     72//   event-by-event, so:
     73//     MCalibrateData cal1;
     74//     cal1.SetCalibrationMode(MCalibrateData::kSkip);
     75//     cal1.SetPedestalFlag(MCalibrateData::kRun);
     76//     MCalibrateData cal2;
     77//     cal2.SetCalibrationMode(MCalibrateData::kSkip);
     78//     cal2.SetNamePedADCContainer("MPedestalFromLoGain");
     79//     cal2.SetNamePedPhotContainer("MPedPhotFromLoGain")
     80//     cal2.SetPedestalFlag(MCalibrateData::kEvent);
     81//
    6082//
    6183//   Input Containers:
    62 //    MPedestalCam
    63 //    MExtractedSignalCam
    64 //    MCalibrationChargeCam
    65 //    MCalibrationQECam
     84//    [MPedestalCam]
     85//    [MExtractedSignalCam]
     86//    [MCalibrationChargeCam]
     87//    [MCalibrationQECam]
     88//    MBadPixelsCam
    6689//
    6790//   Output Containers:
    68 //    MPedPhotCam
    69 //    MCerPhotEvt
     91//    [MPedPhotCam]
     92//    [MCerPhotEvt]
    7093//
    7194// See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest
     
    123146//
    124147MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
    125     : fGeomCam(NULL), fPedestal(NULL),
     148    : fGeomCam(NULL),   fPedestal(NULL),
    126149      fBadPixels(NULL), fCalibrations(NULL), fQEs(NULL), fSignals(NULL),
    127       fPedPhot(NULL), fCerPhotEvt(NULL)
     150      fPedPhot(NULL),   fCerPhotEvt(NULL), fPedestalFlag(kNo)
    128151{
    129152
     
    132155 
    133156  SetCalibrationMode();
    134   SetPedestalFlag();
    135157
    136158  SetNamePedADCContainer();
    137159  SetNamePedPhotContainer();
    138 
    139160}
    140161
     
    160181    // input containers
    161182
    162     fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedADCContainer), "MPedestalCam");
    163     if (!fPedestal)
    164     {
    165         *fLog << err << AddSerialNumber(fNamePedADCContainer) << " [MPedestalCam] not found ... aborting" << endl;
    166         return kFALSE;
    167     }
    168 
    169     fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
    170     if (!fSignals)
    171     {
    172         *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
    173         return kFALSE;
    174     }
    175 
    176183    fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
    177184    if (!fBadPixels)
     
    181188    }
    182189
     190    fSignals    = 0;
     191    fCerPhotEvt = 0;
     192    if (fCalibrationMode>kSkip)
     193    {
     194        fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
     195        if (!fSignals)
     196        {
     197            *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
     198            return kFALSE;
     199        }
     200
     201        fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
     202        if (!fCerPhotEvt)
     203            return kFALSE;
     204    }
     205
     206    fCalibrations = 0;
     207    fQEs          = 0;
    183208    if (fCalibrationMode>kNone)
    184209    {
     
    198223    }
    199224
    200     // output containers
    201 
    202     fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam", AddSerialNumber(fNamePedPhotContainer));
    203     if (!fPedPhot)
    204         return kFALSE;
    205 
    206     fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
    207     if (!fCerPhotEvt)
    208         return kFALSE;
     225    fPedestal = 0;
     226    fPedPhot  = 0;
     227    if (fPedestalFlag)
     228    {
     229        fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedADCContainer), "MPedestalCam");
     230        if (!fPedestal)
     231        {
     232            *fLog << err << AddSerialNumber(fNamePedADCContainer) << " [MPedestalCam] not found ... aborting" << endl;
     233            return kFALSE;
     234        }
     235
     236        fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam", AddSerialNumber(fNamePedPhotContainer));
     237        if (!fPedPhot)
     238            return kFALSE;
     239    }
    209240
    210241    return kTRUE;
     
    225256Bool_t MCalibrateData::ReInit(MParList *pList)
    226257{
    227 
    228   fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
    229   if (!fGeomCam)
    230     {
    231       *fLog << err << "No MGeomCam found... aborting." << endl;
    232       return kFALSE;
    233     }
    234 
    235   if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
    236     {
    237       *fLog << warn << GetDescriptor()
    238             << ": Blind pixel calibration method not valid, switching to default F-factor method" << endl;
    239       fCalibrationMode = kFfactor;
    240     }
    241 
    242   if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
    243     {
    244       *fLog << warn << GetDescriptor()
    245             << ": PIN diode calibration method not valid, switching to default F-factor method" << endl;
    246       fCalibrationMode = kFfactor;
    247     }
    248 
    249   if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
    250     {
    251       *fLog << warn << GetDescriptor()
    252             << ": Combined calibration method not valid, switching to default F-factor method" << endl;
    253       fCalibrationMode = kFfactor;
    254     }
    255 
    256   //
    257   // output information or warnings:
    258   //
    259   switch(fCalibrationMode)
     258    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
     259    if (!fGeomCam)
     260    {
     261        *fLog << err << "No MGeomCam found... aborting." << endl;
     262        return kFALSE;
     263    }
     264
     265    if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
     266    {
     267        *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl;
     268        fCalibrationMode = kFfactor;
     269    }
     270
     271    if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
     272    {
     273        *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl;
     274        fCalibrationMode = kFfactor;
     275    }
     276
     277    if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
     278    {
     279        *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl;
     280        fCalibrationMode = kFfactor;
     281    }
     282
     283    //
     284    // output information or warnings:
     285    //
     286    switch(fCalibrationMode)
    260287    {
    261288    case kBlindPixel:
    262       break;
     289        break;
    263290    case kFfactor:
    264       break;
     291        break;
    265292    case kPinDiode:
    266       *fLog << err << GetDescriptor()
    267                     << ": PIN Diode Calibration mode not yet available " << endl;
    268       return kFALSE;
    269       break;
     293        *fLog << err << "PIN Diode Calibration mode not yet available!" << endl;
     294        return kFALSE;
     295        break;
    270296    case kCombined:
    271       *fLog << err << GetDescriptor()
    272                     << ": Combined Calibration mode not yet available " << endl;
    273       return kFALSE;
    274       break;
     297        *fLog << err << "Combined Calibration mode not yet available!" << endl;
     298        return kFALSE;
     299        break;
    275300    case kFlatCharge:
    276       *fLog << warn << GetDescriptor()
    277             << ": WARNING: Flat-fielding charges - only for muon calibration! " << endl;
    278       break;
     301        *fLog << warn << "WARNING - Flat-fielding charges - only for muon calibration!" << endl;
     302        break;
    279303    case kDummy:
    280       *fLog << warn << GetDescriptor()
    281             << ": WARNING: Dummy calibration, no calibration applied!!" << endl;
    282       break;
     304        *fLog << warn << "WARNING - Dummy calibration, no calibration applied!" << endl;
     305        break;
    283306    case kNone:
    284       *fLog << warn << GetDescriptor()
    285             << ": WARNING: No calibration applied!!" << endl;
    286       break;
     307        *fLog << warn << "WARNING - No calibration applied!" << endl;
     308        break;
    287309    default:
    288       *fLog << warn << GetDescriptor()
    289             << ": WARNING: Calibration mode value ("
    290             << fCalibrationMode << ") not known" << endl;
    291       return kFALSE;
    292     }
    293 
    294   if (TestPedestalFlag(kRun))
    295       if (!CalibratePedestal())
     310        *fLog << warn << "WARNING - Calibration mode value (" << fCalibrationMode << ") not known" << endl;
     311        return kFALSE;
     312    }
     313
     314    if (TestPedestalFlag(kRun))
     315        if (!CalibratePedestal())
    296316          return kFALSE;
    297317
    298   return kTRUE;
    299 }
    300 
    301 
     318    return kTRUE;
     319}
    302320
    303321// --------------------------------------------------------------------------
     
    316334    if ((Int_t)fPedestal->GetSize() != fSignals->GetSize())
    317335    {
    318         *fLog << err << "MCalibrateData::ReInit(); sizes of MPedestalCam and MCalibrationCam are different"
    319             << endl;
     336        *fLog << err << "Sizes of MPedestalCam and MCalibrationCam are different" << endl;
     337        return kFALSE;
    320338    }
    321339
     
    326344
    327345        // pedestals/(used FADC slices)   in [ADC] counts
    328         Float_t pedes  = ped.GetPedestal()    * slices;
    329         Float_t pedrms = ped.GetPedestalRms() * TMath::Sqrt(slices);
     346        const Float_t pedes  = ped.GetPedestal()    * slices;
     347        const Float_t pedrms = ped.GetPedestalRms() * TMath::Sqrt(slices);
    330348
    331349        //
     
    337355        Float_t calibConvVar;
    338356        Float_t calibFFactor;
    339 
    340         if ( !GetConversionFactor(pixid, hiloconv, hiloconverr,
    341                                   calibConv, calibConvVar, calibFFactor ))
     357        if (!GetConversionFactor(pixid, hiloconv, hiloconverr,
     358                                 calibConv, calibConvVar, calibFFactor))
    342359            continue;
    343360
     
    345362        // pedestals/(used FADC slices)   in [number of photons]
    346363        //
    347         Float_t pedphot    = pedes  * calibConv;
    348         Float_t pedphotrms = pedrms * calibConv;
     364        const Float_t pedphot    = pedes  * calibConv;
     365        const Float_t pedphotrms = pedrms * calibConv;
    349366
    350367        (*fPedPhot)[pixid].Set(pedphot, pedphotrms);
     
    492509    for (UInt_t pixidx=0; pixidx<npix; pixidx++)
    493510    {
    494         if ( !GetConversionFactor(pixidx, hiloconv, hiloconverr,
    495                                   calibrationConversionFactor, calibrationConversionFactorErr, calibFFactor) )
     511        if (!GetConversionFactor(pixidx, hiloconv, hiloconverr,
     512                                 calibrationConversionFactor, calibrationConversionFactorErr, calibFFactor))
    496513            continue;
    497514
    498         MExtractedSignalPix &sig =  (*fSignals)[pixidx];
     515        MExtractedSignalPix &sig = (*fSignals)[pixidx];
    499516
    500517        Float_t signal;
     
    520537        nphot    = signal*calibrationConversionFactor;
    521538        nphotErr = calibFFactor*TMath::Sqrt(TMath::Abs(nphot));
     539
    522540        //
    523541        // The following part is the commented first version of the error calculation
     
    580598void MCalibrateData::StreamPrimitive(ofstream &out) const
    581599{
    582 
    583   out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    584   out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
    585 
    586   if (TestPedestalFlag(kEvent))
    587     out << "   " << GetUniqueName() << ".EnablePedestalType(kEvent)" << endl;
    588   if (TestPedestalFlag(kRun))
    589     out << "   " << GetUniqueName() << ".EnablePedestalType(kRun)" << endl;
    590 
    591   if (fCalibrationMode != kDefault)
    592     out << "   " << GetUniqueName() << ".SetCalibrationMode(" << fCalibrationMode << ")" << endl;
    593 
    594   if (fNamePedADCContainer != fgNamePedADCContainer)
    595     {
    596       out << "   " << GetUniqueName() << ".SetNamePedADCContainer(";
    597       out << fNamePedADCContainer.Data() << ");" << endl;
    598     }
    599  
    600   if (fNamePedPhotContainer  != fgNamePedPhotContainer)
    601     {
    602       out << "   " << GetUniqueName() << ".SetNamePedPhotContainer(";
    603       out << fNamePedPhotContainer.Data() << ");" << endl;
    604     }
    605 }
     600    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
     601    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
     602
     603    if (TestPedestalFlag(kEvent))
     604        out << "   " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kEvent)" << endl;
     605    if (TestPedestalFlag(kRun))
     606        out << "   " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kRun)" << endl;
     607
     608    if (fCalibrationMode != kDefault)
     609    {
     610        out << "   " << GetUniqueName() << ".SetCalibrationMode(MCalibrateData::";
     611        switch (fCalibrationMode)
     612        {
     613        case kSkip:       out << "kSkip";               break;
     614        case kNone:       out << "kNone";               break;
     615        case kFlatCharge: out << "kFlatCharge";         break;
     616        case kBlindPixel: out << "kBlindPixel";         break;
     617        case kFfactor:    out << "kFfactor";            break;
     618        case kPinDiode:   out << "kPinDiode";           break;
     619        case kCombined:   out << "kCombined";           break;
     620        case kDummy:      out << "kDummy";              break;
     621        default:          out << (int)fCalibrationMode; break;
     622        }
     623        out << ")" << endl;
     624    }
     625
     626    if (fNamePedADCContainer != fgNamePedADCContainer)
     627    {
     628        out << "   " << GetUniqueName() << ".SetNamePedADCContainer(";
     629        out << fNamePedADCContainer.Data() << ");" << endl;
     630    }
     631
     632    if (fNamePedPhotContainer  != fgNamePedPhotContainer)
     633    {
     634        out << "   " << GetUniqueName() << ".SetNamePedPhotContainer(";
     635        out << fNamePedPhotContainer.Data() << ");" << endl;
     636    }
     637}
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r4624 r4628  
    3434{
    3535private:
    36 
    3736  static const TString fgNamePedADCContainer;    //! "MPedestalCam"
    3837  static const TString fgNamePedPhotContainer;   //! "MPedPhotCam"
     
    4544  MExtractedSignalCam   *fSignals;          //! Integrated charge in FADCs counts
    4645 
    47   MPedPhotCam           *fPedPhot;          // Pedestals/(used slices) [photons]
    48   MCerPhotEvt           *fCerPhotEvt;       // Cerenkov Photon Event used for calculation
     46  MPedPhotCam           *fPedPhot;          //! Pedestals/(used slices) [photons]
     47  MCerPhotEvt           *fCerPhotEvt;       //! Cerenkov Photon Event used for calculation
    4948 
    5049  UShort_t fCalibrationMode;                // Flag defining the calibration mode (CalibrationMode_t)
    5150  Byte_t   fPedestalFlag;                   // Flags defining to calibrate the pedestal each event or each run
    5251 
    53   TString  fNamePedADCContainer;         // name of fPedestal
    54   TString  fNamePedPhotContainer;        // name of fPedPhot
     52  TString  fNamePedADCContainer;            // name of fPedestal
     53  TString  fNamePedPhotContainer;           // name of fPedPhot
    5554
    5655  Bool_t CalibratePedestal();
     
    6968    enum CalibrationMode_t
    7069    {
    71         kNone       =  0,
    72         kFlatCharge =  1,
    73         kBlindPixel =  2,
    74         kFfactor    =  3,
    75         kPinDiode   =  4,
    76         kCombined   =  5,
    77         kDummy      =  6,
    78         kSkip       =  7
     70        kSkip       =  0,
     71        kNone      =  1,
     72        kFlatCharge =  2,
     73        kBlindPixel =  3,
     74        kFfactor    =  4,
     75        kPinDiode   =  5,
     76        kCombined   =  6,
     77        kDummy      =  7
    7978    };
    8079
Note: See TracChangeset for help on using the changeset viewer.