Ignore:
Timestamp:
08/11/04 14:32:49 (20 years ago)
Author:
hbartko
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
2 edited

Legend:

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

    r3807 r4579  
    2020!   Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
    2121!   Author(s): Markus Gaug     04/2004 <mailto:markus@ifae.es>
     22!   Author(s): Hendrik Bartko  08/2004 <mailto:hbartko@mppmu.mpg.de>
    2223!
    2324!   Copyright: MAGIC Software Development, 2000-2004
     
    8889MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
    8990    : fCam(NULL), fPedestal(NULL), fBadPixels(NULL), fCalibrations(NULL), fSignals(NULL),
    90       fPedPhot(NULL), fCerPhotEvt(NULL), fCalibrationMode(calmode)
     91      fPedPhot(NULL), fCerPhotEvt(NULL), fCalibrationMode(calmode), fFlags(kRun), fNamePedADCRunContainer("MPedestalCam"), fNamePedADCEventContainer("MPedestalCamFromData"), fNamePedPhotRunContainer("MPedPhotCam"), fNamePedPhotEventContainer("MPedPhotCamFromData")
    9192{
    9293    fName  = name  ? name  : "MCalibrateData";
     
    111112Int_t MCalibrateData::PreProcess(MParList *pList)
    112113{
    113     fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
     114
     115  // input containers
     116
     117
     118  if (TestFlag(kRun))
     119  {
     120    fPedestal = (MPedestalCam*)pList->FindObject(fNamePedADCRunContainer, AddSerialNumber("MPedestalCam"));
    114121    if (!fPedestal)
    115     {
    116       *fLog << err << AddSerialNumber("MPedestalCam") << " not found ... aborting" << endl;
    117         return kFALSE;
    118     }
     122    { 
     123      *fLog << err << "container 'MPedestalCam'"
     124            << " not found ... aborting" << endl;
     125      return kFALSE;
     126    }
     127  }
     128
     129
     130  if (TestFlag(kEvent))
     131  {
     132    fPedestalFromData = (MPedestalCam*)pList->FindObject(fNamePedADCEventContainer, AddSerialNumber("MPedestalCam"));
     133    if (!fPedestalFromData)
     134    {
     135      *fLog << err << "container 'MPedestalCamFromData'"
     136            << " not found ... aborting" << endl;
     137      return kFALSE;
     138    }
     139  }
    119140
    120141
     
    150171    }
    151172
    152     fPedPhot = (MPedPhotCam*)pList->FindCreateObj(AddSerialNumber("MPedPhotCam"));
    153     if (!fPedPhot)
    154         return kFALSE;
     173    // output containers
     174
     175    if (TestFlag(kRun))
     176    {
     177      fPedPhot = (MPedPhotCam*)pList->FindCreateObj(AddSerialNumber("MPedPhotCam"), fNamePedPhotRunContainer);
     178      if (!fPedPhot)
     179      {
     180        *fLog << err << "container 'MPedPhotCam'"
     181              << " not found ... aborting" << endl;
     182        return kFALSE;
     183      }
     184    }
     185
     186
     187    if (TestFlag(kEvent))
     188    { 
     189      fPedPhotFromData = (MPedPhotCam*)pList->FindCreateObj(AddSerialNumber("MPedPhotCam"), fNamePedPhotEventContainer);
     190      if (!fPedPhotFromData)
     191      {
     192        *fLog << err << "container 'MPedPhotCamFromData'"
     193              << " not found ... aborting" << endl;
     194        return kFALSE;
     195      }
     196    }
    155197
    156198    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
     
    185227    }
    186228
     229
     230  if (TestFlag(kRun))
     231  {
    187232  //---------------------------------------------
    188233  // fill MPedPhot container using the informations from
     
    240285
    241286  fPedPhot->SetReadyToSave();
     287  }
    242288
    243289  return kTRUE;
     
    376422  fCerPhotEvt->SetReadyToSave();
    377423 
     424
     425
     426  if(TestFlag(kEvent))
     427  {
     428
     429  //---------------------------------------------
     430  // fill MPedPhot(FromData) container using the informations from
     431  // MPedestalCam, MExtractedSignalCam and MCalibrationCam
     432
     433  fNumUsedHiGainFADCSlices = fSignals->GetNumUsedHiGainFADCSlices();
     434
     435  // is pixid equal to pixidx ?
     436  if (    (Int_t)(fPedestal->GetSize()) != fSignals->GetSize())
     437  {
     438    *fLog << err << "MCalibrateData::ReInit(); sizes of MPedestalCam and MCalibrationCam are different"
     439          << endl;
     440  }
     441
     442  /*
     443  *fLog << all << "MCalibrateData::ReInit(); fill MPedPhotCam container"
     444        << endl;
     445  *fLog << all << "     fNumUsedHiGainADCSlices = "
     446        <<  fNumUsedHiGainFADCSlices << endl;
     447  *fLog << all << "     pixid, calibrationConversionFactor, ped, pedRMS, pedphot, pedphotRMS :"
     448        << endl;
     449  */
     450  for (Int_t pixid=0; pixid<fPedestalFromData->GetSize(); pixid++)
     451  {
     452    const MPedestalPix    &ped = (*fPedestalFromData)[pixid];
     453
     454    // pedestals/(used FADC slices)   in [ADC] counts
     455    Float_t pedes  = ped.GetPedestal()    * fNumUsedHiGainFADCSlices;
     456    Float_t pedrms = ped.GetPedestalRms() * sqrt(fNumUsedHiGainFADCSlices);
     457
     458    //----------------------------------
     459    // get phe/ADC conversion factor
     460
     461    Float_t hiloconv;
     462    Float_t hiloconverr;
     463    Float_t calibConv;
     464    Float_t calibFFactor;
     465
     466    if ( !GetConversionFactor(pixid, hiloconv, hiloconverr,
     467                              calibConv, calibFFactor ))
     468      continue;
     469
     470    //----------------------------------
     471
     472    // pedestals/(used FADC slices)   in [number of photons]
     473    Float_t pedphot    = pedes  * calibConv;
     474    Float_t pedphotrms = pedrms * calibConv;
     475
     476    (*fPedPhotFromData)[pixid].Set(pedphot, pedphotrms);
     477
     478    //    *fLog << all << pixid << ",  " << calibConv << ",  "
     479    //      << ped.GetPedestal() << ",  " << ped.GetPedestalRms() << ",  "
     480    //       << pedphot << ",  " << pedphotrms << endl;
     481  }
     482
     483  //---------------------------------------------
     484
     485  fPedPhotFromData->SetReadyToSave();
     486
     487  }
     488
     489
    378490  return kTRUE;
    379491}
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r3687 r4579  
    3737    MGeomCam              *fCam;
    3838    MPedestalCam          *fPedestal;     // Pedestals/slice [ADC counts]
     39    MPedestalCam          *fPedestalFromData;  // Pedestals/slice [ADC counts]
    3940    MBadPixelsCam         *fBadPixels;    // Bad Pixels information
    4041    MCalibrationChargeCam *fCalibrations; // Calibration constants
     
    4344
    4445    MPedPhotCam           *fPedPhot;      // Pedestals/(used slices) [photons]
     46    MPedPhotCam           *fPedPhotFromData;// Pedestals/(used slices) [photons]
    4547    MCerPhotEvt           *fCerPhotEvt;   // Cerenkov Photon Event used for calculation
    4648
     
    5052    Float_t  fConversionHiLo;
    5153    UShort_t fCalibrationMode;
     54
     55    Int_t        fFlags;            // Flags defining to calibrate the pedestal each event or each run
     56 
     57    TString fNamePedADCRunContainer;           // name of the 'MPedestalCam' container
     58    TString fNamePedADCEventContainer;         // name of the 'MPedestalCam' container
     59    TString fNamePedPhotRunContainer;          // name of the 'MPedestalCam' container
     60    TString fNamePedPhotEventContainer;        // name of the 'MPedestalCam' container
     61
    5262
    5363    Bool_t GetConversionFactor(UInt_t,
     
    6373    static const CalibrationMode_t kDefault = kBlindPixel;
    6474
     75    enum PedestalType_t{
     76      kRun = BIT(0),
     77      kEvent = BIT(1)
     78    };
     79   
     80
     81
    6582    MCalibrateData(CalibrationMode_t calmode = kDefault,const char *name=NULL, const char *title=NULL);
    6683
    6784    void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; };
    6885    void SetCalibrationMode(CalibrationMode_t calmode=kDefault){ fCalibrationMode=calmode;};
     86
     87    void SetPedestalType(PedestalType_t i) { fFlags  =  i; } // Int_t f
     88    void EnablePedestalType(PedestalType_t i)   { fFlags |=  i; } // Int_t f
     89    void DisablePedestalType(PedestalType_t i)  { fFlags &= ~i; } // Int_t f
     90    Bool_t TestFlag(PedestalType_t i) const { return fFlags&i; }
     91
     92
     93    void SetNamePedADCRunContainer(const char *name)    { fNamePedADCRunContainer = name; }
     94    void SetNamePedADCEventContainer(const char *name)    { fNamePedADCEventContainer = name; }
     95
     96    void SetNamePedPhotRunContainer(const char *name)    { fNamePedPhotRunContainer = name; }
     97    void SetNamePedPhotEventContainer(const char *name)    { fNamePedPhotEventContainer = name; }
     98   
    6999   
    70100    ClassDef(MCalibrateData, 0)   // Task to calculate cerenkov photons using calibration constants
Note: See TracChangeset for help on using the changeset viewer.