Changeset 2945


Ignore:
Timestamp:
01/28/04 15:05:30 (21 years ago)
Author:
rico
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2944 r2945  
    44
    55                                                 -*-*- END OF LINE -*-*-
     6 2004/01/28: Javier Rico
     7
     8   * mcalib/MCalibrate.[h.cc]
     9     - include possibility to select the calibration method to be used
     10
     11
    612 2004/01/28: Markus Gaug
    713
  • trunk/MagicSoft/Mars/mcalib/MCalibrate.cc

    r2908 r2945  
    1717!
    1818!   Author(s): Javier Lopez 12/2003 <mailto:jlopez@ifae.es>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2001
     19!   Modified by: Javier Rico  01/2004 <mailto:jrico@ifae.es>
     20!
     21!   Copyright: MAGIC Software Development, 2000-2004
    2122!
    2223!
     
    2930//   This task takes the integrated charge from MExtractedSignal and apply
    3031//   the calibration constants from MCalibraitionCam to the charge. Then
    31 //   stores number of photons obtained in MCerPhotEvt.
     32//   stores number of photons obtained in MCerPhotEvt. Selection of different
     33//   calibration methods is allowed through SetCalibrationMode member function
    3234//
    3335//   Input Containers:
     
    6567// Default constructor.
    6668//
    67 MCalibrate::MCalibrate(const char *name, const char *title)
     69MCalibrate::MCalibrate(CalibrationMode_t calmode,const char *name, const char *title) : fCalibrationMode(calmode)
    6870{
    6971    fName  = name  ? name  : "MCalibrate";
     
    8587Int_t MCalibrate::PreProcess(MParList *pList)
    8688{
     89
    8790    fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
     91
    8892    if (!fSignals)
    8993    {
     
    9296    }
    9397
    94     fCalibrations = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
    95     if (!fCalibrations)
    96     {
    97       *fLog << err << AddSerialNumber("MCalibrationCam") << " not found ... aborting." << endl;
    98         return kFALSE;
    99     }
     98   if(fCalibrationMode>kNone)
     99      {
     100
     101        fCalibrations = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
     102        if (!fCalibrations)
     103          {
     104            *fLog << err << AddSerialNumber("MCalibrationCam") << " not found ... aborting." << endl;
     105            return kFALSE;
     106          }
     107
     108      }
    100109
    101110    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
     
    108117// --------------------------------------------------------------------------
    109118//
     119// Check for validity of the selected calibration method, switch to a
     120// different one in case of need
     121//
     122Int_t MCalibrate::ReInit()
     123{
     124  if(fCalibrationMode == kBlindPixel && !fCalibrations->IsBlindPixelMethodValid())
     125    {
     126      *fLog << warn << GetDescriptor() << "Warning: Blind pixel calibration method not valid, switching to F-factor method" << endl;
     127      fCalibrationMode = kFfactor;
     128    }
     129
     130  if(fCalibrationMode == kPinDiode && !fCalibrations->IsPINDiodeMethodValid())
     131    {
     132      *fLog << warn << GetDescriptor() << "Warning: PIN diode calibration method not valid, switching to F-factor method" << endl;
     133      fCalibrationMode = kFfactor;
     134    }
     135  return kTRUE;
     136}
     137// --------------------------------------------------------------------------
     138//
     139// Apply the calibration factors to the extracted signal according to the
     140// selected calibration method
    110141//
    111142Int_t MCalibrate::Process()
     
    123154  */
    124155
    125   UInt_t numpix = fSignals->GetSize();
    126 
    127   for (UInt_t pixid=0; pixid< numpix; pixid++)
    128     {
    129       const MCalibrationPix &pix = (*fCalibrations)[pixid];
    130      
    131       if (!pix.IsFitValid())
    132         continue;
    133 
    134       MExtractedSignalPix &sig =  (*fSignals)[pixid];
     156  UInt_t npix = fSignals->GetSize();
     157
     158  Float_t hiloconv   = 1.;
     159  Float_t hiloconverr= 0.;
     160  Float_t calibrationConversionFactor = 1.;
     161  Float_t calibrationConversionFactorError = 0.;
     162 
     163  for (UInt_t pixidx=0; pixidx<npix; pixidx++)
     164    {
     165      if(fCalibrationMode!=kNone)
     166        {
     167          const MCalibrationPix &pix = (*fCalibrations)[pixidx];       
     168         
     169          if (!pix.IsFitValid())
     170            continue;
     171         
     172          hiloconv   = pix.GetConversionHiLo();
     173          hiloconverr= pix.GetConversionHiLoError();
     174         
     175          switch(fCalibrationMode)
     176            {
     177            case kBlindPixel:
     178              calibrationConversionFactor      = pix.GetMeanConversionBlindPixelMethod();
     179              calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
     180              break;
     181            case kFfactor:
     182              calibrationConversionFactor      = pix.GetMeanConversionFFactorMethod();
     183              calibrationConversionFactorError = pix.GetErrorConversionFFactorMethod();
     184              break;
     185            default:
     186              *fLog << warn << "MCalibrate::Process Warning: Calibration mode value ("<<fCalibrationMode<<") not known" << endl;
     187              break;
     188            }
     189        }
     190     
     191      MExtractedSignalPix &sig =  (*fSignals)[pixidx];
    135192     
    136193      Float_t signal;
    137194      Float_t signalErr = 0.;
    138      
     195      Float_t nphot,nphotErr;
     196           
    139197      if (sig.IsLoGainUsed())
    140198        {
    141           signal    = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
    142           signalErr = signal*pix.GetConversionHiLoError();
     199          signal    = sig.GetExtractedSignalLoGain()*hiloconv;
     200          signalErr = signal*hiloconverr;
    143201        }
    144202      else
     
    152210            signal = sig.GetExtractedSignalHiGain();
    153211        }
    154 
    155       //      Float_t calibrationConversionFactor = pix.GetMeanConversionFFactorMethod();
    156       const Float_t calibrationConversionFactor      = pix.GetMeanConversionBlindPixelMethod();
    157       const Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
    158      
    159       const Float_t nphot = signal*calibrationConversionFactor;
    160 
    161       Float_t nphotErr    = signal*calibrationConversionFactorError
    162                            *signal*calibrationConversionFactorError;
    163 
    164       nphotErr += signalErr*calibrationConversionFactor
    165                  *signalErr*calibrationConversionFactor;
     212     
     213      nphot    = signal*calibrationConversionFactor;
     214      nphotErr = signal*calibrationConversionFactorError
     215        *signal*calibrationConversionFactorError
     216        +signalErr*calibrationConversionFactor
     217        *signalErr*calibrationConversionFactor;
    166218     
    167219      nphotErr  = TMath::Sqrt(nphotErr);
    168220     
    169       MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixid, nphot, nphotErr);
     221      MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
    170222
    171223      if (sig.GetNumLoGainSaturated() > 0)
    172           cpix->SetPixelSaturated();
     224        cpix->SetPixelSaturated();
    173225    }
    174226 
  • trunk/MagicSoft/Mars/mcalib/MCalibrate.h

    r2885 r2945  
    2727
    2828    Float_t fConversionHiLo;
     29    UShort_t fCalibrationMode;
    2930   
    3031    Int_t PreProcess(MParList *pList);
    3132    Int_t Process();
     33    Int_t ReInit();
    3234
    3335public:
    3436
    35     MCalibrate(const char *name=NULL, const char *title=NULL);
     37    enum CalibrationMode_t{kNone=0,kBlindPixel,kFfactor,kPinDiode,kCombined};
     38    static const CalibrationMode_t kDefault = kBlindPixel;
    3639
    37     void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; }
     40    MCalibrate(CalibrationMode_t calmode = kDefault,const char *name=NULL, const char *title=NULL);
     41
     42    void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; };
     43    void SetCalibrationMode(CalibrationMode_t calmode=kDefault){ fCalibrationMode=calmode;};
    3844   
    3945    ClassDef(MCalibrate, 0)   // Task to calculate cerenkov photons using calibration constants
Note: See TracChangeset for help on using the changeset viewer.