Changeset 3622 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
03/31/04 22:18:32 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3621 r3622  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21
     22 2004/03/31: Markus Gaug
     23
     24   * mcalib/MHCalibrationChargeCam.[h,cc]
     25   * mcalib/MCalibrationChargeCam.[h,cc]
     26   * mcalib/MCalibrationChargeCalc.cc
     27   * manalysis/MGeomApply.cc
     28     - make the average pixel independent on camera geometry, i.e.
     29       one average pixel per MGeomPix::Aidx
    2030
    2131
  • trunk/MagicSoft/Mars/manalysis/MGeomApply.cc

    r3552 r3622  
    136136    MCalibrationChargeCam *cal = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
    137137    if (cal)
     138      {
    138139        cal->InitSize(cam->GetNumPixels());
     140        cal->InitAverageSize(cam->GetNumAreas());
     141      }
     142   
    139143
    140144    MCalibrationQECam *qe = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3602 r3622  
    639639  }
    640640
    641   FinalizeAvPedestals(*fCam->GetAverageInnerPix(), avinnerped, avinnerprms,avinnernum);
    642   FinalizeAvPedestals(*fCam->GetAverageOuterPix(), avouterped, avouterprms,avouternum); 
    643 
    644   FinalizeCharges(*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
    645   FinalizeCharges(*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix()); 
    646 
     641  for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
     642    {
     643
     644      FinalizeAvPedestals(fCam->GetAveragePix(aidx), avinnerped, avinnerprms,avinnernum);
     645      FinalizeCharges(fCam->GetAveragePix(aidx),fCam->GetAverageBadPix(aidx));
     646    }
     647 
    647648  //
    648649  // F-Factor calibration
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r3603 r3622  
    129129using namespace std;
    130130
    131 const Float_t MCalibrationChargeCam::gkAverageQE                = 0.18;     
    132 const Float_t MCalibrationChargeCam::gkAverageQEErr             = 0.02; 
     131const Float_t MCalibrationChargeCam::fgAverageQE                = 0.18;     
     132const Float_t MCalibrationChargeCam::fgAverageQEErr             = 0.02; 
    133133const Float_t MCalibrationChargeCam::fgConvFFactorRelErrLimit   = 0.35;
    134134const Float_t MCalibrationChargeCam::fgPheFFactorRelErrLimit    = 5.;
     
    150150    fTitle = title ? title : "Storage container for the Calibration Information in the camera";
    151151
    152     fPixels          = new TClonesArray("MCalibrationChargePix",1);
    153     fAverageInnerPix = new MCalibrationChargePix("AverageInnerPix","Container of the fit results of the camera average inner pixels");
    154     fAverageOuterPix = new MCalibrationChargePix("AverageOuterPix","Container of the fit results of the camera average outer pixels");
    155     fAverageInnerBadPix = new MBadPixelsPix("AverageInnerBadPix","Bad Pixel Container of the camera average inner pixels");
    156     fAverageOuterBadPix = new MBadPixelsPix("AverageOuterBadPix","Bad Pixel Container of the camera average outer pixels");
     152    fPixels           = new TClonesArray("MCalibrationChargePix",1);
     153    fAveragePixels    = new TClonesArray("MCalibrationChargePix",1);
     154    fAverageBadPixels = new TClonesArray("MBadPixelsPix",1);
    157155
    158156    Clear();
     
    177175  //
    178176  delete fPixels;
    179   delete fAverageInnerPix;
    180   delete fAverageOuterPix;
    181  
    182   delete fAverageInnerBadPix;
    183   delete fAverageOuterBadPix;
     177  delete fAveragePixels;
     178  delete fAverageBadPixels;
    184179 
    185180  if (fOffsets)
     
    202197void MCalibrationChargeCam::InitSize(const UInt_t i)
    203198{
    204  
    205199  fPixels->ExpandCreate(i);
    206 
    207 }
     200}
     201
     202void MCalibrationChargeCam::InitAverageSize(const UInt_t i)
     203{
     204  fAveragePixels->ExpandCreate(i);
     205  fAverageBadPixels->ExpandCreate(i);
     206}
     207
     208
    208209
    209210// --------------------------------------------------------------------------
     
    219220}
    220221
     222Int_t MCalibrationChargeCam::GetAverageSize() const
     223{
     224  return fAveragePixels->GetEntriesFast();
     225}
     226
    221227
    222228// --------------------------------------------------------------------------
     
    238244}
    239245
     246// --------------------------------------------------------------------------
     247//
     248// Get i-th average pixel (area number)
     249//
     250MCalibrationChargePix &MCalibrationChargeCam::GetAveragePix(UInt_t i)
     251{
     252  return *static_cast<MCalibrationChargePix*>(fAveragePixels->UncheckedAt(i));
     253}
     254
     255// --------------------------------------------------------------------------
     256//
     257// Get i-th average pixel (area number)
     258//
     259const MCalibrationChargePix &MCalibrationChargeCam::GetAveragePix(UInt_t i) const
     260{
     261  return *static_cast<MCalibrationChargePix*>(fAveragePixels->UncheckedAt(i));
     262}
     263
     264// --------------------------------------------------------------------------
     265//
     266// Get i-th average pixel (area number)
     267//
     268MBadPixelsPix &MCalibrationChargeCam::GetAverageBadPix(UInt_t i)
     269{
     270  return *static_cast<MBadPixelsPix*>(fAverageBadPixels->UncheckedAt(i));
     271}
     272
     273// --------------------------------------------------------------------------
     274//
     275// Get i-th average pixel (area number)
     276//
     277const MBadPixelsPix &MCalibrationChargeCam::GetAverageBadPix(UInt_t i) const
     278{
     279  return *static_cast<MBadPixelsPix*>(fAverageBadPixels->UncheckedAt(i));
     280}
     281
    240282
    241283// --------------------------------------
     
    245287
    246288  fPixels->ForEach(TObject, Clear)();
    247   fAverageInnerPix->Clear();
    248   fAverageOuterPix->Clear();
    249 
    250   fAverageInnerBadPix->Clear();
    251   fAverageOuterBadPix->Clear();
    252 
    253   fNumExcludedPixels            = 0;
     289
     290  //
     291  // another ForEach does not compile, thus have to do the loop ourselves:
     292  //
     293  for (Int_t i=0;i<GetAverageSize();i++)
     294    {
     295      fAveragePixels[i].Clear();
     296      fAverageBadPixels[i].Clear();
     297    }
     298 
    254299  fMeanFluxPhesInnerPixel       = 0.;
    255300  fMeanFluxPhesInnerPixelVar    = 0.;
     
    373418  *fLog << endl;
    374419
    375   *fLog << all << "Average Inner Pix:"
    376                 << "   Ped.  Rms: "            << fAverageInnerPix->GetPedRms()        << " +- " << fAverageInnerPix->GetPedRmsErr()
    377                 << "   Mean signal: "          << fAverageInnerPix->GetMeanCharge()    << " +- " << fAverageInnerPix->GetMeanChargeErr()
    378                 << "   Sigma signal: "         << fAverageInnerPix->GetSigmaCharge()    << " +- "<< fAverageInnerPix->GetSigmaChargeErr()
    379                 << "   Reduced Sigma: "        << fAverageInnerPix->GetRSigmaCharge()
    380                 << "   Nr Phe's: "             << fAverageInnerPix->GetPheFFactorMethod()
    381                 << endl;
    382   *fLog << all << "Average Outer Pix:"
    383                 << "   Ped.  Rms: "            << fAverageOuterPix->GetPedRms()        << " +- " << fAverageOuterPix->GetPedRmsErr()
    384                 << "   Mean signal: "          << fAverageOuterPix->GetMeanCharge()    << " +- " << fAverageOuterPix->GetMeanChargeErr()
    385                 << "   Sigma signal: "         << fAverageOuterPix->GetSigmaCharge()    << " +- "<< fAverageOuterPix->GetSigmaChargeErr()
    386                 << "   Reduced Sigma: "        << fAverageOuterPix->GetRSigmaCharge()
    387                 << "   Nr Phe's: "             << fAverageOuterPix->GetPheFFactorMethod()
    388                 << endl;
    389 
     420  TIter Next5(fAveragePixels);
     421  while ((pix=(MCalibrationChargePix*)Next5()))
     422  {
     423    *fLog << all << "Average Pix:"
     424          << "   Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr()
     425          << "   Mean signal: "          << pix->GetMeanCharge()    << " +- " << pix->GetMeanChargeErr()
     426          << "   Sigma signal: "         << pix->GetSigmaCharge()    << " +- "<< pix->GetSigmaChargeErr()
     427          << "   Reduced Sigma: "        << pix->GetRSigmaCharge()
     428          << "   Nr Phe's: "             << pix->GetPheFFactorMethod()
     429          << endl;
     430  }
    390431}
    391432
     
    710751void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
    711752{
    712     if (idx == -1)
    713         fAverageInnerPix->DrawClone();
    714     if (idx == -2)
    715         fAverageOuterPix->DrawClone();
    716 
    717753    (*this)[idx].DrawClone();
    718754}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h

    r3511 r3622  
    2222private:
    2323 
    24   static const Float_t gkAverageQE;          // The average quantum efficieny agreed on for the first analysis
    25   static const Float_t gkAverageQEErr;       // The error of average quantum efficieny
    26  
    27   static const Float_t fgConvFFactorRelErrLimit; // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
    28   static const Float_t fgPheFFactorRelErrLimit;  // The rel. limit for acceptance of a calculated number of phe's w.r.t the mean number (in sigma of the error)
     24  static const Float_t fgAverageQE;              // The default for fAverageQE    (now set to: 0.18)
     25  static const Float_t fgAverageQEErr;           // The default for fAverageQEErr (now set to: 0.02)
     26  static const Float_t fgConvFFactorRelErrLimit; // The default for fConvFFactorRelErrLimit (now set to: 0.35)
     27  static const Float_t fgPheFFactorRelErrLimit;  // The default for fPheFFactorRelErrLimit  (now set to: 5.)
    2928 
    3029  Float_t fAverageQE;                // The average quantum efficieny (see Class description)
    3130  Float_t fAverageQEVar;             // The error of the average quantum efficieny (see Class description)
     31  Float_t fConvFFactorRelVarLimit;   // Acceptance limit for rel. error of conversion factor (FFactor method)
     32  Float_t fPheFFactorRelVarLimit;    // Acceptance limit for number of phe's w.r.t mean number (in variances)
    3233 
    33   Float_t fConvFFactorRelVarLimit;   // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
    34   Float_t fPheFFactorRelVarLimit;    // The rel. limit for acceptance of a calculated number of phe's w.r.t the mean number (in variances of the error).
     34  TClonesArray *fPixels;             //-> Array of MCalibrationChargePix, one per pixel
     35  TClonesArray *fAveragePixels;      //-> Array of MCalibrationChargePix, one per pixel area
     36  TClonesArray *fAverageBadPixels;   //-> Array of MBadPixelsPix, one per pixel area
    3537 
    36   Int_t fNumPixels;
    37   TClonesArray *fPixels;                         //-> Array of MCalibrationPix with fit results
    38 
    39   MCalibrationChargePix *fAverageInnerPix;       //-> Average Pixel of all events
    40   MCalibrationChargePix *fAverageOuterPix;       //-> Average Pixel of all events
     38  TH1D* fOffsets;                    //!
     39  TH1D* fSlopes;                     //!
    4140 
    42   MBadPixelsPix         *fAverageInnerBadPix;    //-> Average Pixel of all events
    43   MBadPixelsPix         *fAverageOuterBadPix;    //-> Average Pixel of all events
    44  
    45   TH1D* fOffsets;                                //!
    46   TH1D* fSlopes;                                 //!
    47  
    48   TH2D* fOffvsSlope;                             //!
    49 
    50   UInt_t  fNumExcludedPixels;
     41  TH2D* fOffvsSlope;                 //!
    5142
    5243  Byte_t  fFlags;
     
    7162  void Clear(    Option_t *o="" );
    7263  void InitSize( const UInt_t i );
     64  void InitAverageSize( const UInt_t i );
    7365
    7466  // Setters   
    75   void SetAverageQE(          const Float_t qe= gkAverageQE,
    76                               const Float_t err=gkAverageQEErr)         { fAverageQE    = qe;           
     67  void SetAverageQE(          const Float_t qe= fgAverageQE,
     68                              const Float_t err=fgAverageQEErr)         { fAverageQE    = qe;           
    7769                                                                          fAverageQEVar = err*err; }
    78   void SetNumPixelsExcluded(  const UInt_t n )            {  fNumExcludedPixels = n; }
    7970  void SetConvFFactorRelErrLimit( const Float_t f=fgConvFFactorRelErrLimit ) { fConvFFactorRelVarLimit = f*f; }
    8071  void SetPheFFactorRelErrLimit (  const Float_t f=fgPheFFactorRelErrLimit )     { fPheFFactorRelVarLimit = f*f;    } 
     
    8677  // Getters
    8778  Int_t   GetSize()               const;
    88   UInt_t  GetNumPixels()          const { return fNumPixels; }
     79  Int_t   GetAverageSize()        const; 
    8980
    9081  Bool_t  GetConversionFactorFFactor(    Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
     
    110101  const MCalibrationChargePix &operator[](UInt_t i) const;
    111102
    112   MCalibrationChargePix *GetAverageInnerPix()              { return fAverageInnerPix; }
    113   const MCalibrationChargePix *GetAverageInnerPix() const  { return fAverageInnerPix; }
     103  MCalibrationChargePix &GetAveragePix(UInt_t i);
     104  const MCalibrationChargePix &GetAveragePix(UInt_t i) const;
    114105
    115   MCalibrationChargePix *GetAverageOuterPix()              { return fAverageOuterPix; }
    116   const MCalibrationChargePix *GetAverageOuterPix() const  { return fAverageOuterPix; }
    117 
    118   MBadPixelsPix *GetAverageInnerBadPix()              { return fAverageInnerBadPix; }
    119   const MBadPixelsPix *GetAverageInnerBadPix() const  { return fAverageInnerBadPix; }
    120 
    121   MBadPixelsPix *GetAverageOuterBadPix()              { return fAverageOuterBadPix; }
    122   const MBadPixelsPix *GetAverageOuterBadPix() const  { return fAverageOuterBadPix; }
     106  MBadPixelsPix &GetAverageBadPix(UInt_t i);
     107  const MBadPixelsPix &GetAverageBadPix(UInt_t i) const;
    123108
    124109  // Prints
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc

    r3618 r3622  
    311311// - MCalibrationChargeBlindPix
    312312//
    313 // Resizes:
     313Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
     314{
     315
     316  fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
     317  if (!fBlindPix)
     318      return kFALSE;
     319
     320  return kTRUE;
     321}
     322
     323// --------------------------------------------------------------------------
     324//
     325// Retrieves from MExtractedSignalBlindPixel:
     326// - number of FADC samples
     327// - extracted signal
     328// - blind Pixel ID
     329//
     330// Resizes (if necessary):
    314331// - fASinglePheFADCSlices to sum of HiGain and LoGain samples
    315332// - fAPedestalFADCSlices to sum of HiGain and LoGain samples
    316333//
    317 Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
    318 {
    319 
    320   fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
    321   if (!fBlindPix)
    322       return kFALSE;
    323 
    324   Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()+(Int_t)fRawEvt->GetNumLoGainSamples();
     334// Fills the following histograms:
     335// - MHGausEvents::FillHistAndArray(signal)
     336//
     337// Creates MRawEvtPixelIter, jumps to blind pixel ID,
     338// fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
     339// with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
     340//
     341Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
     342{
     343
     344  const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()+(Int_t)fRawEvt->GetNumLoGainSamples();
    325345
    326346  if (fASinglePheFADCSlices.GetNrows() != samples)
     
    329349      fAPedestalFADCSlices.ResizeTo(samples);
    330350    }
    331  
    332 
    333   return kTRUE;
    334 }
    335 
    336 // --------------------------------------------------------------------------
    337 //
    338 // Retrieves from MExtractedSignalBlindPixel:
    339 // - number of FADC samples
    340 // - extracted signal
    341 // - blind Pixel ID
    342 //
    343 // Fills the following histograms:
    344 // - MHGausEvents::FillHistAndArray(signal)
    345 //
    346 // Creates MRawEvtPixelIter, jumps to blind pixel ID,
    347 // fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
    348 // with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
    349 //
    350 Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
    351 {
    352351
    353352  Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc

    r3615 r3622  
    1313! * in supporting documentation. It is provided "as is" without express
    1414! * or implied warranty.
    15 
    1615! *
    1716!
     
    113112    fLoGainArray->SetOwner();
    114113
    115     fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix",
    116                                                               "Average HiGain FADC sums of inner pixels");
    117     fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix",
    118                                                               "Average LoGain FADC sums of inner pixels");
    119     fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix",
    120                                                               "Average HiGain FADC sums of outer pixels");
    121     fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix",
    122                                                               "Average LoGain FADC sums of outer pixels");
    123 
    124     fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
    125     fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
    126     fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
    127     fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
    128 
    129     fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
    130     fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
    131     fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
    132     fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
    133 
    134     fAverageHiGainInnerPix->SetChargeFirst(-1000.);
    135     fAverageHiGainOuterPix->SetChargeFirst(-1000.);
    136 
    137     fAverageHiGainInnerPix->SetChargeLast(4000.);
    138     fAverageLoGainInnerPix->SetChargeLast(4000.);
    139     fAverageHiGainOuterPix->SetChargeLast(4000.);
    140     fAverageLoGainOuterPix->SetChargeLast(4000.);
    141 
    142     fAverageHiGainInnerPix->SetChargeNbins(4000);
    143     fAverageLoGainInnerPix->SetChargeNbins(4000);
    144     fAverageHiGainOuterPix->SetChargeNbins(4000);
    145     fAverageLoGainOuterPix->SetChargeNbins(4000);
     114    fAverageHiGainArray = new TObjArray;
     115    fAverageHiGainArray->SetOwner();
     116
     117    fAverageLoGainArray = new TObjArray;
     118    fAverageLoGainArray->SetOwner();
    146119
    147120    SetNumHiGainSaturationLimit();
    148121    SetNumLoGainSaturationLimit();
    149122    SetPulserFrequency();
    150 
    151     fNumInnerPixels = 0;
    152     fNumOuterPixels = 0;
    153     fNumExcluded    = 0;
    154 
    155     fAverageInnerSat            = 0;
    156     fAverageOuterSat            = 0; 
    157     fAverageInnerPixSigma       = 0.;
    158     fAverageOuterPixSigma       = 0.; 
    159     fAverageInnerPixSigmaErr    = 0.;
    160     fAverageOuterPixSigmaErr    = 0.; 
    161     fAverageInnerPixRelSigma    = 0.;
    162     fAverageOuterPixRelSigma    = 0.; 
    163     fAverageInnerPixRelSigmaErr = 0.;
    164     fAverageOuterPixRelSigmaErr = 0.; 
    165 
    166123}
    167124
     
    176133  delete fLoGainArray;
    177134
    178   delete fAverageHiGainInnerPix;
    179   delete fAverageLoGainInnerPix;
    180   delete fAverageHiGainOuterPix;
    181   delete fAverageLoGainOuterPix;
    182 
     135  delete fAverageHiGainArray;
     136  delete fAverageLoGainArray;
    183137}
    184138
     
    219173}
    220174
    221 
    222 #if 0
     175// --------------------------------------------------------------------------
     176//
     177// Get i-th pixel (pixel number)
     178//
     179MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainPix(UInt_t i)
     180{
     181  return *static_cast<MHCalibrationChargeHiGainPix*>(fAverageHiGainArray->UncheckedAt(i));
     182}
     183
     184// --------------------------------------------------------------------------
     185//
     186// Get i-th pixel (pixel number)
     187//
     188const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainPix(UInt_t i) const
     189{
     190  return *static_cast<MHCalibrationChargeHiGainPix*>(fAverageHiGainArray->UncheckedAt(i));
     191}
     192
     193// --------------------------------------------------------------------------
     194//
     195// Get i-th pixel (pixel number)
     196//
     197MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainPix(UInt_t i)
     198{
     199  return *static_cast<MHCalibrationChargeLoGainPix*>(fAverageLoGainArray->UncheckedAt(i));
     200}
     201
     202// --------------------------------------------------------------------------
     203//
     204// Get i-th pixel (pixel number)
     205//
     206const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainPix(UInt_t i) const
     207{
     208  return *static_cast<MHCalibrationChargeLoGainPix*>(fAverageLoGainArray->UncheckedAt(i));
     209}
     210
    223211// --------------------------------------------------------------------------
    224212//
     
    229217{
    230218
    231     const Int_t nhi = fHiGainArray->GetSize();
    232     const Int_t nlo = fLoGainArray->GetSize();
    233     //
    234     // FIXME, this might be done faster and more elegant, by direct copy.
    235     //
    236     MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
    237 //    MHCalibrationChargeCam cam;
    238 //    Copy(*cam);
    239 
    240 /*
    241     cam->fHiGainArray->Delete();
    242     cam->fLoGainArray->Delete();
    243 
    244     cam->fHiGainArray->Expand(nhi);
    245     cam->fLoGainArray->Expand(nlo);
    246 
    247     for (int i=0; i<nhi; i++)
    248     {
    249         delete (*cam->fHiGainArray)[i];
    250         (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
    251     }
    252     for (int i=0; i<nlo; i++)
    253     {
    254         delete (*cam->fLoGainArray)[i];
    255         (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
    256     }
    257 */
    258 
    259 /*
    260     delete cam->fAverageHiGainInnerPix;
    261     delete cam->fAverageLoGainInnerPix;
    262     delete cam->fAverageHiGainOuterPix;
    263     delete cam->fAverageLoGainOuterPix;
    264 
    265     cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
    266     cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
    267 
    268     cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
    269     cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
    270 
    271     fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
    272     fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
    273     fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
    274     fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
    275 */
    276 
    277     return cam;
    278 }
    279 #endif
     219  const Int_t nhi   = fHiGainArray->GetEntries();
     220  const Int_t nlo   = fLoGainArray->GetEntries();
     221  const Int_t navhi = fAverageHiGainArray->GetEntries();
     222  const Int_t navlo = fAverageLoGainArray->GetEntries();
     223 
     224  *fLog << err << nhi << "  " << nlo << "  " << navhi << "  " << navlo << endl;
     225
     226  //
     227  // FIXME, this might be done faster and more elegant, by direct copy.
     228  //
     229  MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
     230
     231  cam->fHiGainArray->Expand(nhi);
     232  cam->fLoGainArray->Expand(nlo);
     233  cam->fAverageHiGainArray->Expand(navhi);
     234  cam->fAverageLoGainArray->Expand(navlo);
     235
     236  for (int i=0; i<nhi; i++)
     237    {
     238      delete (*cam->fHiGainArray)[i];
     239      (*cam->fHiGainArray)[i] = (MHCalibrationChargeHiGainPix*)(*fHiGainArray)[i]->Clone();
     240    }
     241  for (int i=0; i<nlo; i++)
     242    {
     243      delete (*cam->fLoGainArray)[i];
     244      (*cam->fLoGainArray)[i] = (MHCalibrationChargeLoGainPix*)(*fLoGainArray)[i]->Clone();
     245    }
     246  for (int i=0; i<navhi; i++)
     247    {
     248      delete (*cam->fAverageHiGainArray)[i];
     249      (*cam->fAverageHiGainArray)[i] = (MHCalibrationChargeHiGainPix*)(*fAverageHiGainArray)[i]->Clone();
     250    }
     251  for (int i=0; i<navlo; i++)
     252    {
     253      delete (*cam->fAverageLoGainArray)[i];
     254      (*cam->fAverageLoGainArray)[i] = (MHCalibrationChargeLoGainPix*)(*fAverageLoGainArray)[i]->Clone();
     255    }
     256
     257  cam->fAverageNum            = fAverageNum;           
     258  cam->fAverageSat            = fAverageSat;           
     259  cam->fAveragePixSigma       = fAveragePixSigma;     
     260  cam->fAveragePixSigmaErr    = fAveragePixSigmaErr;   
     261  cam->fAveragePixRelSigma    = fAveragePixRelSigma;
     262  cam->fAveragePixRelSigmaErr = fAveragePixRelSigmaErr;   
     263
     264  return cam;
     265}
     266
    280267// --------------------------------------------------------------------------
    281268//
     
    303290  fLoGainArray->Delete();
    304291
    305   fAverageHiGainInnerPix->Init();
    306   fAverageLoGainInnerPix->Init(); 
    307   fAverageHiGainOuterPix->Init();
    308   fAverageLoGainOuterPix->Init(); 
     292  fAverageHiGainArray->Delete();
     293  fAverageLoGainArray->Delete();
    309294
    310295  return kTRUE;
     
    342327          //
    343328          (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
     329          MHCalibrationChargeHiGainPix &hist = (*this)[i];
    344330
    345331          if ((*fBadPixels)[i].IsBad())
    346332          {
    347333            *fLog << warn << "Excluded pixel: " << i << " from calibration " << endl;
    348             fNumExcluded++;
    349             (*this)[i].SetExcluded();
     334            hist.SetExcluded();
    350335          }
    351           (*this)[i].Init();
    352           (*this)[i].ChangeHistId(i);
    353           (*this)[i].SetEventFrequency(fPulserFrequency);
     336          hist.Init();
     337          hist.ChangeHistId(i);
     338          hist.SetEventFrequency(fPulserFrequency);
    354339      }
    355340  }
     
    363348      {
    364349          (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
     350          MHCalibrationChargeLoGainPix &hist = (*this)(i);
    365351          //
    366352          // Pixels with non-valid behavior
    367353          //
    368354          if ((*fBadPixels)[i].IsBad())
    369             (*this)(i).SetExcluded();
    370 
    371           (*this)(i).Init();
    372           (*this)(i).ChangeHistId(i);
    373           (*this)(i).SetEventFrequency(fPulserFrequency);
     355            hist.SetExcluded();
     356
     357          hist.Init();
     358          hist.ChangeHistId(i);
     359          hist.SetEventFrequency(fPulserFrequency);
    374360      }
    375361     
    376362  }
    377363
    378   fAverageHiGainInnerPix->SetEventFrequency(fPulserFrequency);
    379   fAverageLoGainInnerPix->SetEventFrequency(fPulserFrequency);
    380   fAverageHiGainOuterPix->SetEventFrequency(fPulserFrequency);
    381   fAverageLoGainOuterPix->SetEventFrequency(fPulserFrequency);
    382 
    383 
    384   *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
     364  const Int_t nareas = fGeom->GetNumAreas();
     365
     366  if (fAverageHiGainArray->GetEntries()==0)
     367  {
     368      fAverageHiGainArray->Expand(nareas);
     369
     370      for (Int_t j=0; j<nareas; j++)
     371      {
     372          //
     373          // Oscillating pixels
     374          //
     375          (*fAverageHiGainArray)[j] =
     376            new MHCalibrationChargeHiGainPix("AverageHiGainPix",
     377                                             "Average HiGain FADC sums of pixel area idx ");
     378          MHCalibrationChargeHiGainPix &hist = GetAverageHiGainPix(j);
     379
     380          hist.GetHGausHist()->SetTitle("Summed FADC slices average Hi Gain pixels Area Idx ");
     381          hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Hi Gain pixels Area Idx ");
     382          hist.SetChargeFirst(-1000.);
     383          hist.SetChargeLast(4000.);
     384          hist.SetChargeNbins(4000);
     385          hist.Init();
     386          hist.ChangeHistId(j);
     387          hist.SetEventFrequency(fPulserFrequency);
     388      }
     389  }
     390
     391  if (fAverageLoGainArray->GetEntries()==0)
     392  {
     393      fAverageLoGainArray->Expand(nareas);
     394 
     395      for (Int_t j=0; j<nareas; j++)
     396      {
     397          //
     398          // Oscillating pixels
     399          //
     400          (*fAverageLoGainArray)[j] =
     401            new MHCalibrationChargeLoGainPix("AverageLoGainPix",
     402                                             "Average LoGain FADC sums of pixel area idx ");
     403          MHCalibrationChargeLoGainPix &hist = GetAverageLoGainPix(j);
     404
     405          hist.GetHGausHist()->SetTitle("Summed FADC slices average Lo Gain pixels Area Idx ");
     406          hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Lo Gain pixels Area Idx ");
     407          hist.SetChargeFirst(-1000.);
     408          hist.SetChargeLast(4000.);
     409          hist.SetChargeNbins(4000);
     410          hist.Init();
     411          hist.ChangeHistId(j);
     412          hist.SetEventFrequency(fPulserFrequency);
     413      }
     414  }
     415
     416  fAverageNum.           Set(nareas);
     417  fAverageSat.           Set(nareas);           
     418  fAveragePixSigma.      Set(nareas);     
     419  fAveragePixSigmaErr.   Set(nareas);   
     420  fAveragePixRelSigma.   Set(nareas);   
     421  fAveragePixRelSigmaErr.Set(nareas);
     422   
     423  for (Int_t i=0; i<n; i++)
     424    {
     425      if ((*this)[i].IsExcluded())
     426        continue;
     427
     428      const Int_t aidx  = (*fGeom)[i].GetAidx();
     429      fAverageNum[aidx]++;
     430    }
     431 
    385432  return kTRUE;
    386433}
     
    398445    }
    399446 
    400   Int_t n       = signal->GetSize();
    401   Int_t lofirst = signal->GetFirstUsedSliceLoGain();
    402 
    403   if (fHiGainArray->GetEntries() != n)
    404     {
    405       *fLog << err << "ERROR - Size mismatch... abort." << endl;
    406       return kFALSE;
    407     }
    408 
    409   if (fLoGainArray->GetEntries() != n)
    410     {
    411       *fLog << err << "ERROR - Size mismatch... abort." << endl;
    412       return kFALSE;
    413     }
     447  const Int_t npixels = signal->GetSize();
     448  const Int_t lofirst = signal->GetFirstUsedSliceLoGain();
     449  const Int_t nareas  = fGeom->GetNumAreas();
     450
     451  if (fHiGainArray->GetEntries() != npixels)
     452    {
     453      *fLog << err << "ERROR - Size mismatch in number of pixels ... abort." << endl;
     454      return kFALSE;
     455    }
     456
     457  if (fLoGainArray->GetEntries() != npixels)
     458    {
     459      *fLog << err << "ERROR - Size mismatch in number of pixels ... abort." << endl;
     460      return kFALSE;
     461    }
     462
     463  if (fAverageHiGainArray->GetEntries() != nareas)
     464    {
     465      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
     466      return kFALSE;
     467    }
     468
     469  if (fAverageLoGainArray->GetEntries() != nareas)
     470    {
     471      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
     472      return kFALSE;
     473    }
     474
    414475
    415476  //
    416477  // First the extracted signal
    417478  //
    418   Float_t sumhiinnertot = 0.;
    419   Float_t sumloinnertot = 0.;
    420   Float_t sumhioutertot = 0.;
    421   Float_t sumlooutertot = 0.;
    422   Int_t   sumhiinnersat = 0;
    423   Int_t   sumloinnersat = 0;
    424   Int_t   sumhioutersat = 0;
    425   Int_t   sumlooutersat = 0;
    426 
    427   fNumInnerPixels = fNumOuterPixels = 0;
    428 
    429   for (int i=0; i<n; i++)
     479  Float_t sumhitot [nareas];
     480  Float_t sumlotot [nareas];
     481  Int_t   sumhisat [nareas];
     482  Int_t   sumlosat [nareas];
     483  Float_t timehitot[nareas];
     484  Float_t timelotot[nareas];
     485
     486  for (UInt_t j=0; j<nareas; j++)
     487    {
     488
     489      sumhitot[j]  =  sumlotot[j]  = 0.;
     490      sumhisat[j]  =  sumlosat[j]  = 0;
     491      timehitot[j] =  timelotot[j] = 0.;     
     492    }
     493 
     494  for (Int_t i=0; i<npixels; i++)
    430495    {
    431496
     
    447512      (*this)(i).SetSaturated(satlo);
    448513
    449       if (fGeom->GetPixRatio(i) == 1.)
    450       {
    451           sumhiinnertot += sumhi;
    452           sumloinnertot += sumlo;
    453           sumhiinnersat += sathi;
    454           sumloinnersat += satlo;
    455           fNumInnerPixels++;
    456       }
    457       else
    458       {
    459           sumhioutertot += sumhi;
    460           sumlooutertot += sumlo;
    461           sumhioutersat += sathi;
    462           sumlooutersat += satlo;
    463           fNumOuterPixels++;
    464       }
    465 
    466     }
    467 
    468   fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
    469   fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
    470   fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
    471   fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
    472 
    473   fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
    474   fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
    475   fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
    476   fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
    477 
    478   //
    479   // Now the times
    480   //
    481   sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
    482   fNumInnerPixels = fNumOuterPixels = 0;
     514      const Int_t aidx  = (*fGeom)[i].GetAidx();
     515
     516      sumhitot[aidx]  += sumhi;
     517      sumlotot[aidx]  += sumlo;
     518      sumhisat[aidx]  += sathi;
     519      sumlosat[aidx]  += satlo;
     520    }
    483521
    484522  MRawEvtPixelIter pixel(fRawEvt);
     
    487525     
    488526      const UInt_t pixid = pixel.GetPixelId();
    489 
    490       if ((*this)[pixid].IsExcluded())
    491         continue;
     527       if ((*this)[pixid].IsExcluded())
     528         continue;
    492529
    493530      const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
     
    497534      (*this)(pixid).FillAbsTime(timelo);
    498535
    499       if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
    500       {
    501           sumhiinnertot += timehi;
    502           sumloinnertot += timelo;
    503           fNumInnerPixels++;
    504       }
    505       else
    506       {
    507           sumhioutertot += timehi;
    508           sumlooutertot += timelo;
    509           fNumOuterPixels++;
    510       }
    511     }
    512 
    513   fAverageHiGainInnerPix->FillAbsTime(sumhiinnertot/fNumInnerPixels);
    514   fAverageLoGainInnerPix->FillAbsTime(sumloinnertot/fNumInnerPixels);
    515   fAverageHiGainOuterPix->FillAbsTime(sumhioutertot/fNumOuterPixels);
    516   fAverageLoGainOuterPix->FillAbsTime(sumlooutertot/fNumOuterPixels);
     536      const Int_t aidx  = (*fGeom)[pixid].GetAidx();
     537
     538      timehitot[aidx] += timehi;
     539      timelotot[aidx] += timelo;
     540    }
     541 
     542
     543  for (UInt_t j=0; j<nareas; j++)
     544    {
     545
     546      const Int_t npix = fAverageNum[j];
     547
     548      MHCalibrationChargeHiGainPix &hipix = GetAverageHiGainPix(j);
     549      MHCalibrationChargeLoGainPix &lopix = GetAverageLoGainPix(j);
     550
     551      hipix.FillHistAndArray(sumhitot[j]/npix);
     552      lopix.FillHistAndArray(sumlotot[j]/npix);
     553
     554      hipix.SetSaturated((Float_t)sumhisat[j]/npix);
     555      lopix.SetSaturated((Float_t)sumlosat[j]/npix);
     556
     557      hipix.FillAbsTime(timehitot[j]/npix);
     558      lopix.FillAbsTime(timelotot[j]/npix);
     559
     560    }
    517561
    518562  return kTRUE;
     
    531575Bool_t MHCalibrationChargeCam::Finalize()
    532576{
    533    
    534     for (int i=0; i<fHiGainArray->GetSize(); i++)
    535     {
    536      
    537         MCalibrationChargePix        &pix    = (*fCam)[i];
    538         MHCalibrationChargeHiGainPix &histhi = (*this)[i];
    539         MBadPixelsPix                &bad    = (*fBadPixels)[i];
    540 
    541         FinalizeHiGainHists(histhi,pix,bad);
    542 
    543     }
    544 
    545     for (int i=0; i<fLoGainArray->GetSize(); i++)
    546     {
    547      
    548         if ((*this)(i).IsExcluded())
    549            continue;
    550 
    551         MHCalibrationChargeLoGainPix &histlo = (*this)(i);
    552         MCalibrationChargePix        &pix    = (*fCam)[i];
    553         MBadPixelsPix                &bad    = (*fBadPixels)[i];
    554 
    555         FinalizeLoGainHists(histlo,pix,bad);
    556 
    557     }
    558 
    559     FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
    560     FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
    561     FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
    562     FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
    563 
    564     FinalizeAveragePix(*fCam->GetAverageInnerPix(),fNumInnerPixels,
    565                        fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
    566                        fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr,
    567                        fAverageInnerSat);
    568     FinalizeAveragePix(*fCam->GetAverageOuterPix(),fNumOuterPixels,
    569                        fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
    570                        fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr,
    571                        fAverageOuterSat);
    572 
    573     return kTRUE;
     577
     578  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
     579    {
     580     
     581      if ((*this)[i].IsExcluded())
     582        continue;
     583     
     584      MHCalibrationChargeHiGainPix &histhi = (*this)[i];
     585      MCalibrationChargePix        &pix    = (*fCam)[i];
     586      MBadPixelsPix                &bad    = (*fBadPixels)[i];
     587     
     588      FinalizeHiGainHists(histhi,pix,bad);
     589     
     590    }
     591 
     592  for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
     593    {
     594     
     595      if ((*this)(i).IsExcluded())
     596        continue;
     597     
     598      MHCalibrationChargeLoGainPix &histlo = (*this)(i);
     599      MCalibrationChargePix        &pix    = (*fCam)[i];
     600      MBadPixelsPix                &bad    = (*fBadPixels)[i];
     601     
     602      FinalizeLoGainHists(histlo,pix,bad);
     603     
     604    }
     605 
     606  for (Int_t j=0; j<fAverageHiGainArray->GetSize(); j++)
     607    {
     608     
     609      MHCalibrationChargeHiGainPix &histhi = GetAverageHiGainPix(j);     
     610      MCalibrationChargePix        &pix    = fCam->GetAveragePix(j);
     611      MBadPixelsPix                &bad    = fCam->GetAverageBadPix(j);       
     612     
     613      FinalizeHiGainHists(histhi,pix,bad);
     614    }
     615 
     616  for (Int_t j=0; j<fAverageLoGainArray->GetSize(); j++)
     617    {
     618     
     619      MHCalibrationChargeLoGainPix &histlo = GetAverageLoGainPix(j);     
     620      MCalibrationChargePix        &pix    = fCam->GetAveragePix(j);
     621      MBadPixelsPix                &bad    = fCam->GetAverageBadPix(j);       
     622     
     623      FinalizeLoGainHists(histlo,pix,bad);
     624    }
     625 
     626  for (Int_t j=0; j<fGeom->GetNumAreas();j++)
     627    {
     628     
     629      MCalibrationChargePix &pix = fCam->GetAveragePix(j);
     630
     631      if (pix.IsHiGainSaturation())
     632        fAverageSat[j]++;
     633
     634      fAveragePixSigma[j]    = pix.GetSigmaCharge    () * TMath::Sqrt((Float_t)fAverageNum[j]);
     635      fAveragePixSigmaErr[j] = pix.GetSigmaChargeErr () * TMath::Sqrt((Float_t)fAverageNum[j]);
     636
     637      pix.SetSigmaCharge   (fAveragePixSigma[j]);
     638      pix.SetSigmaChargeErr(fAveragePixSigmaErr[j]);
     639
     640      fAveragePixRelSigma[j]   = fAveragePixSigma[j] / pix.GetMeanCharge();
     641     
     642      Float_t relsigmaerr      =  fAveragePixSigmaErr[j]*fAveragePixSigmaErr[j]
     643                               / (fAveragePixSigma[j]   *fAveragePixSigma[j]   );
     644      relsigmaerr              += pix.GetMeanChargeErr()*pix.GetMeanChargeErr()
     645                               / (pix.GetMeanCharge()   *pix.GetMeanCharge()   );
     646      relsigmaerr              *= fAveragePixRelSigma[j];
     647      fAveragePixRelSigmaErr[j] = TMath::Sqrt(relsigmaerr);
     648
     649    }
     650
     651  return kTRUE;
    574652}
    575653
     
    588666    if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
    589667    {
    590         pix.SetHiGainSaturation();
    591         return;
     668      *fLog << warn << "Saturated Hi Gain histogram in pixel: " << pix.GetPixId() << endl;
     669      pix.SetHiGainSaturation();
     670      return;
    592671    }
    593672   
     
    654733    if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
    655734    {
    656         pix.SetLoGainSaturation();
    657         bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
    658         bad.SetUnsuitable(    MBadPixelsPix::kUnsuitableRun    );
    659         return;
     735      *fLog << warn << "Saturated Lo Gain histogram in pixel: " << pix.GetPixId() << endl;
     736      pix.SetLoGainSaturation();
     737      bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
     738      bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     739      return;
    660740    }
    661741
     
    710790}   
    711791
    712 void MHCalibrationChargeCam::FinalizeAveragePix(MCalibrationChargePix &pix, Int_t npix,
    713                                                 Float_t &sigma, Float_t &sigmaerr,
    714                                                 Float_t &relsigma, Float_t &relsigmaerr,
    715                                                 Bool_t &b)
    716 {
    717 
    718   if (pix.IsHiGainSaturation())
    719     b = kTRUE;
    720 
    721   sigma    = pix.GetSigmaCharge    () * TMath::Sqrt((Float_t)npix);
    722   sigmaerr = pix.GetSigmaChargeErr () * TMath::Sqrt((Float_t)npix);
    723 
    724   relsigma     = sigma / pix.GetMeanCharge();
    725 
    726   relsigmaerr  = sigmaerr*sigmaerr / sigma / sigma;
    727   relsigmaerr += pix.GetMeanChargeErr()*pix.GetMeanChargeErr() / pix.GetMeanCharge() / pix.GetMeanCharge();
    728 
    729   relsigmaerr *= relsigma;
    730   relsigmaerr  = TMath::Sqrt(relsigmaerr);
    731 
    732   pix.SetSigmaCharge   (sigma);
    733   pix.SetSigmaChargeErr(sigmaerr);
    734 
    735 }
    736792
    737793
     
    747803void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
    748804{
    749 
    750     if (idx == -1)
    751         fAverageHiGainInnerPix->DrawClone();
    752     if (idx == -2)
    753         fAverageHiGainOuterPix->DrawClone();
    754     if (idx == -3)
    755         fAverageLoGainInnerPix->DrawClone();
    756     if (idx == -4)
    757         fAverageLoGainOuterPix->DrawClone();
    758     (*this)[idx].DrawClone();
    759 
     805  (*this)[idx].DrawClone();
    760806}
    761807
     
    763809void MHCalibrationChargeCam::Draw(const Option_t *opt)
    764810{
     811
     812  const Int_t nareas = fAverageHiGainArray->GetEntries();
     813  if (nareas == 0)
     814    return;
    765815
    766816  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this); 
    767817  pad->SetBorderMode(0);
    768818
    769   pad->Divide(2,2);
    770 
    771   pad->cd(1);
    772 
    773   fAverageHiGainInnerPix->Draw(opt);
    774  
    775   if (!fAverageInnerSat)
    776     DrawAverageSigma(fAverageInnerSat, 1,
    777                      fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
    778                      fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
    779 
    780   pad->cd(2);
    781 
    782   fAverageLoGainInnerPix->Draw(opt);
    783 
    784   if (fAverageInnerSat)
    785     DrawAverageSigma(fAverageInnerSat, 1,
    786                      fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
    787                      fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
    788 
    789   pad->cd(3);
    790 
    791   fAverageHiGainOuterPix->Draw(opt);
    792 
    793   if (!fAverageOuterSat)
    794     DrawAverageSigma(fAverageOuterSat, 0,
    795                      fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
    796                      fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
    797 
    798   pad->cd(4);
    799 
    800   fAverageLoGainOuterPix->Draw(opt);
    801 
    802   if (fAverageOuterSat)
    803     DrawAverageSigma(fAverageOuterSat, 0,
    804                      fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
    805                      fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
     819  pad->Divide(2,nareas);
     820
     821  for (Int_t i=0; i<nareas;i++)
     822    {
     823      pad->cd(2*(i+1)-1);
     824      GetAverageHiGainPix(i).Draw(opt);
     825
     826      if (!fAverageSat[i])
     827        DrawAverageSigma(fAverageSat[i], i,
     828                         fAveragePixSigma[i],    fAveragePixSigmaErr[i],
     829                         fAveragePixRelSigma[i], fAveragePixRelSigmaErr[i]);
     830
     831      pad->cd(2*(i+1));
     832      GetAverageLoGainPix(i).Draw(opt);
     833     
     834      if (fAverageSat[i])
     835        DrawAverageSigma(fAverageSat[i], i,
     836                         fAveragePixSigma[i], fAveragePixSigmaErr[i],
     837                         fAveragePixRelSigma[i], fAveragePixRelSigmaErr[i]);
     838    }
    806839}
    807840
     
    821854      TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
    822855      text->SetTextSize(0.07);
    823       const TString line1 = Form("%s%s%s",inner ? "Inner" : "Outer",
     856      const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
    824857                                 " Pixels ", sat ? "Low Gain" : "High Gain");
    825858      TText *txt1 = text->AddText(line1.Data());
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h

    r3609 r3622  
    44#ifndef ROOT_TObjArray
    55#include <TObjArray.h>
     6#endif
     7
     8#ifndef ROOT_TArrayI
     9#include <TArrayI.h>
     10#endif
     11
     12#ifndef ROOT_TArrayF
     13#include <TArrayF.h>
    614#endif
    715
     
    1422
    1523class TText;
     24class TArrayI;
     25class TArrayF;
    1626class MRawEvtData;
    1727class MGeomCam;
     
    2636private:
    2737
    28   static const Float_t fgNumHiGainSaturationLimit;   // The default number of fNumHiGainSaturationLimit
    29   static const Float_t fgNumLoGainSaturationLimit;   // The default number of fNumLoGainSaturationLimit
    30   static const Int_t   fgPulserFrequency;            // The default pulser frequency
     38  static const Float_t fgNumHiGainSaturationLimit;   // The default for fNumHiGainSaturationLimit
     39  static const Float_t fgNumLoGainSaturationLimit;   // The default for fNumLoGainSaturationLimit
     40  static const Int_t   fgPulserFrequency;            // The default for fPulserFrequency
    3141 
    32   Float_t fNumHiGainSaturationLimit;  // Rel. number sat. higain FADC slices upon which the pixel is called saturated
    33   Float_t fNumLoGainSaturationLimit;  // Rel. number sat. logain FADC slices upon which the pixel is called saturated
    34   Int_t   fPulserFrequency;           // The pulser frequency
     42  Float_t fNumHiGainSaturationLimit;  // Rel. amount sat. higain FADC slices until pixel is called saturated
     43  Float_t fNumLoGainSaturationLimit;  // Rel. amount sat. logain FADC slices until pixel is called saturated
     44
     45  Int_t   fPulserFrequency;           // Light pulser frequency
    3546 
    36   TObjArray *fHiGainArray;                              //-> Array of MHCalibrationChargePix with hists
    37   TObjArray *fLoGainArray;                              //-> Array of MHCalibrationChargePix with hists
    38   MHCalibrationChargeHiGainPix *fAverageHiGainInnerPix; //-> HiGain Average of all inner pixels
    39   MHCalibrationChargeLoGainPix *fAverageLoGainInnerPix; //-> LoGain Average of all inner pixels
    40   MHCalibrationChargeHiGainPix *fAverageHiGainOuterPix; //-> HiGain Average of all outer pixels
    41   MHCalibrationChargeLoGainPix *fAverageLoGainOuterPix; //-> LoGain Average of all outer pixels
     47  TObjArray *fHiGainArray;            //-> Array of MHCalibrationChargeHiGainPix, one per pixel
     48  TObjArray *fLoGainArray;            //-> Array of MHCalibrationChargeLoGainPix, one per pixel
     49  TObjArray *fAverageHiGainArray;     //-> Array of MHCalibrationChargeHiGainPix, one per pixel area
     50  TObjArray *fAverageLoGainArray;     //-> Array of MHCalibrationChargeLoGainPix, one per pixel area
     51 
     52  MCalibrationChargeCam  *fCam;       //!  Calibration Cam with the results
     53  MRawEvtData            *fRawEvt;    //!  Raw event data
     54  MGeomCam               *fGeom;      //!  Camera geometry
     55  MBadPixelsCam          *fBadPixels; //!  Bad Pixels storage container
    4256
    43   MCalibrationChargeCam  *fCam;                         //!  Cam holding the results
    44   MRawEvtData            *fRawEvt;                      //!  Raw event data (time slices)
    45   MGeomCam               *fGeom;                        //!  MAGIC geometry
    46   MBadPixelsCam          *fBadPixels;                   //!  Bad Pixels
    47 
    48   Int_t fNumInnerPixels;
    49   Int_t fNumOuterPixels;
    50   Int_t fNumExcluded;
    51 
    52   Bool_t  fAverageInnerSat;
    53   Bool_t  fAverageOuterSat; 
    54  
    55   Float_t fAverageInnerPixSigma;
    56   Float_t fAverageOuterPixSigma; 
    57  
    58   Float_t fAverageInnerPixSigmaErr;
    59   Float_t fAverageOuterPixSigmaErr; 
    60 
    61   Float_t fAverageInnerPixRelSigma;
    62   Float_t fAverageOuterPixRelSigma; 
    63  
    64   Float_t fAverageInnerPixRelSigmaErr;
    65   Float_t fAverageOuterPixRelSigmaErr; 
     57  TArrayI fAverageNum;                // Number of pixels in average pixels
     58  TArrayI fAverageSat;                // Number of saturated slices in average pixels
     59  TArrayF fAveragePixSigma;           // Re-normalized sigmas in average pixels
     60  TArrayF fAveragePixSigmaErr;        // Errors of Re-normalized sigmas in average pixels
     61  TArrayF fAveragePixRelSigma;        // Re-normalized relative sigmas in average pixels
     62  TArrayF fAveragePixRelSigmaErr;     // Errors of Re-normalized relative sigmas in average pixels
    6663
    6764  void FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
    6865  void FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
    69   void FinalizeAveragePix (MCalibrationChargePix &pix, Int_t npix,
    70                            Float_t &sigma, Float_t &sigmaerr,
    71                            Float_t &relsigma, Float_t &relsigmaerr,
    72                            Bool_t &b);
    7366  void DrawAverageSigma(Bool_t sat, Bool_t inner,
    7467                        Float_t sigma, Float_t sigmaerr,
     
    9386  const MHCalibrationChargeLoGainPix &operator()(UInt_t i)    const;
    9487
    95         MHCalibrationChargeHiGainPix  &GetAverageHiGainInnerPix()        { return *fAverageHiGainInnerPix; }
    96   const MHCalibrationChargeHiGainPix  &GetAverageHiGainInnerPix()  const { return *fAverageHiGainInnerPix; }
     88        MHCalibrationChargeHiGainPix  &GetAverageHiGainPix(UInt_t i);
     89  const MHCalibrationChargeHiGainPix  &GetAverageHiGainPix(UInt_t i)  const;
    9790
    98         MHCalibrationChargeLoGainPix  &GetAverageLoGainInnerPix()        { return *fAverageLoGainInnerPix; }
    99   const MHCalibrationChargeLoGainPix  &GetAverageLoGainInnerPix()  const { return *fAverageLoGainInnerPix; }
    100 
    101         MHCalibrationChargeHiGainPix  &GetAverageHiGainOuterPix()        { return *fAverageHiGainOuterPix; }
    102   const MHCalibrationChargeHiGainPix  &GetAverageHiGainOuterPix()  const { return *fAverageHiGainOuterPix; }
    103 
    104         MHCalibrationChargeLoGainPix  &GetAverageLoGainOuterPix()        { return *fAverageLoGainOuterPix; }
    105   const MHCalibrationChargeLoGainPix  &GetAverageLoGainOuterPix()  const { return *fAverageLoGainOuterPix; }
     91        MHCalibrationChargeLoGainPix  &GetAverageLoGainPix(UInt_t i);
     92  const MHCalibrationChargeLoGainPix  &GetAverageLoGainPix(UInt_t i)  const;
    10693
    10794  Bool_t SetupFill(const MParList *pList);
     
    10996  Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
    11097  Bool_t Finalize ( );
     98
     99  // Clone
     100  TObject *Clone(const char *) const;
    111101 
    112102  // Draw
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc

    r3612 r3622  
    2828//  Histogram class for charge calibration analysis. Holds the histogrammed
    2929//  summed FADC slices and some rough absolute timing. Calculates the mean
    30 //  sum of FADC slices and its sigma
     30//  sum of FADC slices and its sigma and perform a Fourier analysis.
    3131//
    3232//////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.