Changeset 3626


Ignore:
Timestamp:
04/01/04 20:59:25 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3625 r3626  
    3333     - moved BypassFit() function to MHGausEvents
    3434
     35   * mcalib/MHCalibrationChargeCam.[h,cc]
     36     - updated and enlarged documentation
    3537
    3638 2004/03/31: Markus Gaug
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3624 r3626  
    717717  fCam->SetReadyToSave();
    718718 
    719   *fLog << err << "Sectors: " << fGeom->GetNumSectors() << endl;
    720 
    721719  *fLog << inf << endl;
    722720  *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r3602 r3626  
    9393  Float_t fLoGainNumPickup;
    9494
    95   enum  { kHiGainSaturation, kLoGainSaturation,
    96           kExcluded,
     95  enum  { kHiGainSaturation, kExcluded,
    9796          kBlindPixelMethodValid, kFFactorMethodValid,
    9897          kPINDiodeMethodValid, kCombinedMethodValid };
     
    156155  // Bit Setters
    157156  void SetHiGainSaturation    (  const Bool_t b = kTRUE );
    158   void SetLoGainSaturation    (  const Bool_t b = kTRUE );
    159157  void SetExcluded            (  const Bool_t b = kTRUE );
    160158  void SetBlindPixelMethodValid( const Bool_t b = kTRUE );
     
    235233  Bool_t IsExcluded()                          const;
    236234  Bool_t IsHiGainSaturation()                  const;
    237   Bool_t IsLoGainSaturation()                  const;
    238235  Bool_t IsBlindPixelMethodValid()             const;
    239236  Bool_t IsPINDiodeMethodValid()               const;
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc

    r3625 r3626  
    2222!
    2323\* ======================================================================== */
    24 
    2524/////////////////////////////////////////////////////////////////////////////
    2625//                                                               
    2726// MHCalibrationChargeCam                                               
    2827//
    29 // Fills the extracted signals of MExtractedSignalCam into the MH-classes:
    30 //
    31 // MHCalibrationChargeHiGainPix, MHCalibrationChargeLoGainPix for each pixel
    32 // and additionally for an average of the inner and the outer pixels, respectively.
     28// Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
     29// MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
     30//
     31// - pixel, stored in the TObjArray's fHiGainArray and fLoGainArray
     32//
     33// - average pixel per area index (e.g. inner and outer for the MAGIC camera),
     34//   stored in the TObjArray's fAverageHiGainAreas and fAverageLoGainAreas
     35//
     36// - average pixel per camera sector (e.g. sectors 1-6 for the MAGIC camera),
     37//   stored in the TObjArray's fAverageHiGainSectors and fAverageLoGainSectors
    3338//
    34 // By default, subsequently the hi-gain classes are treated unless
    35 // more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
    36 // slices show saturation. In that case, the low-gain classes are treated.
     39// Every signal is filled into a Charge histogram and an array, in order to perform
     40// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
     41// event-by-event basis and written into the TObjArray's fAverageHiGainAreas,
     42// fAverageLoGainAreas, fAverageHiGainSectors and fAverageLoGainSectors.
     43//
     44// Additionally, the (FADC slice) position of the maximum is stored in an Absolute
     45// Arrival Time histogram. This histogram serves for a rough cross-check if the
     46// signal does not lie at or outside the edges of the extraction window.
     47//
     48// The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
     49// and the fit probability are extracted. If none of these values are NaN's and
     50// if the probability is bigger than fProbLimit (default: 0.5%), the fit is valid.
     51// Otherwise, the fit is repeated within ranges of the previous mean +- 5 sigma.
     52// In case this does not make the fit valid, the histogram means and RMS's are
     53// taken directly and the following flags are set:
     54// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or 
     55// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
     56// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   )
     57//
     58// Outliers of more than MHCalibrationChargePix::fPickupLimit (default: 5) sigmas
     59// from the mean are counted as PickUp events (stored in MHCalibrationChargePix::fPickup)
     60//
     61// Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
     62// slices show saturation, the following flag is set:
     63// - MCalibrationChargePix::SetHiGainSaturation();
     64// In that case, the calibration constants are derived from the low-gain results.
     65//
    3766// If more than fNumLoGainSaturationLimit (default: 1%) of the overall
    38 // low-gain FADC slices saturate, the pixel is declared not valid and no further
    39 // treatment is pursued.
     67// low-gain FADC slices saturate, the following flags are set:
     68// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
     69// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    )
    4070//
    41 // The filled histograms are fitted to a Gaussian and the mean and sigma with
    42 // its errors and the fit probability are extracted. If none of these values are
    43 // NaN's and if the probability is bigger than fProbLimit (default: 0.5%), the fit
    44 // is declared valid. Otherwise, the fit is repeated within ranges of the previous mean
    45 // +- 5 sigma. In case that this does not help, the histogram means and RMS's are taken directly,
    46 // but the flag kFitValid is set to FALSE. Outliers of more than fPickUpLimit (default: 5) sigmas
    47 // from the mean are counted as PickUp events.
    48 //
    49 // Additionally, the slice number with the highest value is stored and a corresponding
    50 // histogram is filled. This histogram serves only for a rough cross-check if the
    51 // signal does not lie at the edges of chose extraction window.
    52 //
    5371// The class also fills arrays with the signal vs. event number, creates a fourier
    54 // spectrum out of it and investigates if the projected frequencies follow an exponential
     72// spectrum and investigates if the projected fourier components follow an exponential
    5573// distribution. In case that the probability of the exponential fit is less than
    56 // fProbLimit, the pixel is declared HiGainOscillating or LoGainOscillating, respectively.
     74// fProbLimit (default: 0.5%), the following flags are set:
     75// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
     76// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
     77// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
    5778//
    58 // The results are written into MCalibrationChargeCam.
    59 //                                                               
     79// This same procedure is performed for the average pixels.
     80//
     81// The following results are written into MCalibrationChargeCam:
     82//
     83// - MCalibrationChargePix::SetHiGainSaturation(Bool_t b)
     84// - MCalibrationChargePix::SetHiGainMeanCharge()
     85// - MCalibrationChargePix::SetHiGainMeanChargeErr()
     86// - MCalibrationChargePix::SetHiGainSigmaCharge()
     87// - MCalibrationChargePix::SetHiGainSigmaChargeErr()
     88// - MCalibrationChargePix::SetHiGainChargeProb()
     89// - MCalibrationChargePix::SetHiGainNumPickup()
     90//
     91// - MCalibrationChargePix::SetLoGainMeanCharge()
     92// - MCalibrationChargePix::SetLoGainMeanChargeErr()
     93// - MCalibrationChargePix::SetLoGainSigmaCharge()
     94// - MCalibrationChargePix::SetLoGainSigmaChargeErr()
     95// - MCalibrationChargePix::SetLoGainChargeProb()
     96// - MCalibrationChargePix::SetLoGainNumPickup()
     97//
     98// - MCalibrationChargePix::SetAbsTimeMean()
     99// - MCalibrationChargePix::SetAbsTimeRms()
     100//
     101// The last two items are filled with the Hi-Gain or Lo-Gain result, depending on
     102// the saturation status.
     103//
     104// For all averaged areas, the fitted sigma is multiplied with the square root of
     105// the number involved pixels in order to be able to compare it to the average of
     106// sigmas in the camera.
     107//
    60108/////////////////////////////////////////////////////////////////////////////
    61109#include "MHCalibrationChargeCam.h"
     
    95143using namespace std;
    96144
     145const Int_t   MHCalibrationChargeCam::fgAverageNbins             = 4000;
    97146const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
    98147const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
    99148const Int_t   MHCalibrationChargeCam::fgPulserFrequency          = 500;
    100 //
     149// --------------------------------------------------------------------------
     150//
     151// Default Constructor.
     152//
     153// Sets:
     154// - all pointers to NULL
     155//
     156// Initializes and sets owner of:
     157// - fHiGainArray, fLoGainArray
     158// - fAverageHiGainAreas, fAverageLoGainAreas
     159// - fAverageHiGainSectors, fAverageLoGainSectors
     160//
     161// Initializes:
     162// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
     163// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
     164// - fPulserFrequency to fgPulserFrequency
    101165//
    102166MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
    103     : fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
     167    : fCam(NULL), fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
    104168{
    105169    fName  = name  ? name  : "MHCalibrationChargeCam";
     
    131195// --------------------------------------------------------------------------
    132196//
    133 // Delete the TClonesArray of MHCalibrationChargePix containers
    134 // Delete the average pixels
     197// Deletes the TClonesArray of:
     198// - fHiGainArray, fLoGainArray
     199// - fAverageHiGainAreas, fAverageLoGainAreas
     200// - fAverageHiGainSectors, fAverageLoGainSectors
    135201//
    136202MHCalibrationChargeCam::~MHCalibrationChargeCam()
     
    148214// --------------------------------------------------------------------------
    149215//
    150 // Get i-th pixel (pixel number)
     216// Get i-th High Gain pixel (pixel number)
    151217//
    152218MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
     
    157223// --------------------------------------------------------------------------
    158224//
    159 // Get i-th pixel (pixel number)
     225// Get i-th High Gain pixel (pixel number)
    160226//
    161227const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
     
    166232// --------------------------------------------------------------------------
    167233//
    168 // Get i-th pixel (pixel number)
     234// Get i-th Low Gain pixel (pixel number)
    169235//
    170236MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
     
    175241// --------------------------------------------------------------------------
    176242//
    177 // Get i-th pixel (pixel number)
     243// Get i-th Low Gain pixel (pixel number)
    178244//
    179245const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
     
    184250// --------------------------------------------------------------------------
    185251//
    186 // Get i-th pixel (pixel number)
     252// Get i-th High Gain pixel Area (area number)
    187253//
    188254MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainArea(UInt_t i)
     
    193259// --------------------------------------------------------------------------
    194260//
    195 // Get i-th pixel (pixel number)
     261// Get i-th High Gain pixel Area (area number)
    196262//
    197263const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainArea(UInt_t i) const
     
    202268// --------------------------------------------------------------------------
    203269//
    204 // Get i-th pixel (pixel number)
     270// Get i-th Low Gain pixel Area (area number)
    205271//
    206272MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainArea(UInt_t i)
     
    211277// --------------------------------------------------------------------------
    212278//
    213 // Get i-th pixel (pixel number)
     279// Get i-th Low Gain pixel Area (area number)
    214280//
    215281const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainArea(UInt_t i) const
     
    220286// --------------------------------------------------------------------------
    221287//
    222 // Get i-th pixel (pixel number)
     288// Get i-th High Gain Sector (sector number)
    223289//
    224290MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainSector(UInt_t i)
     
    229295// --------------------------------------------------------------------------
    230296//
    231 // Get i-th pixel (pixel number)
     297// Get i-th High Gain Sector (sector number)
    232298//
    233299const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::GetAverageHiGainSector(UInt_t i) const
     
    238304// --------------------------------------------------------------------------
    239305//
    240 // Get i-th pixel (pixel number)
     306// Get i-th Low Gain Sector (sector number)
    241307//
    242308MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainSector(UInt_t i)
     
    247313// --------------------------------------------------------------------------
    248314//
    249 // Get i-th pixel (pixel number)
     315// Get i-th Low Gain Sector (sector number)
    250316//
    251317const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::GetAverageLoGainSector(UInt_t i) const
     
    257323//
    258324// Our own clone function is necessary since root 3.01/06 or Mars 0.4
    259 // I don't know the reason
     325// I don't know the reason.
     326//
     327// Creates new MHCalibrationChargeCam
     328// Deletes the TObjArray's and Clones them individually
     329// Copies the TArray's
    260330//
    261331TObject *MHCalibrationChargeCam::Clone(const char *) const
     
    312382    }
    313383
    314   cam->fAverageAreaSat         = fAverageAreaSat;           
     384  cam->fAverageAreaNum         = fAverageAreaNum;
     385  cam->fAverageAreaSat         = fAverageAreaSat;
    315386  cam->fAverageAreaSigma       = fAverageAreaSigma;     
    316387  cam->fAverageAreaSigmaErr    = fAverageAreaSigmaErr;   
    317388  cam->fAverageAreaRelSigma    = fAverageAreaRelSigma;
    318389  cam->fAverageAreaRelSigmaErr = fAverageAreaRelSigmaErr;   
     390  cam->fAverageSectorNum       = fAverageSectorNum;     
    319391
    320392  return cam;
     
    323395// --------------------------------------------------------------------------
    324396//
    325 // To setup the object we get the number of pixels from a MGeomCam object
    326 // in the Parameter list.
     397// Gets the pointers to:
     398// - MRawEvtData
     399// - MGeomCam
     400//
     401// Calls Delete-Function of:
     402// - fHiGainArray, fLoGainArray
     403// - fAverageHiGainAreas, fAverageLoGainAreas
     404// - fAverageHiGainSectors, fAverageLoGainSectors
    327405//
    328406Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
     
    355433}
    356434
     435// --------------------------------------------------------------------------
     436//
     437// Gets or creates the pointers to:
     438// - MBadPixelsCam
     439// - MCalibrationChargeCam
     440//
     441// Searches pointer to:
     442// - MExtractedSignalCam
     443//
     444// Initializes, if empty to MExtractedSignalCam::GetSize() for:
     445// - fHiGainArray, fLoGainArray
     446//
     447// Initializes, if empty to MGeomCam::GetNumAreas() for:
     448// - fAverageHiGainAreas, fAverageLoGainAreas
     449//
     450// Initializes, if empty to MGeomCam::GetNumSectors() for:
     451// - fAverageHiGainSectors, fAverageLoGainSectors
     452//
     453// Initializes TArrays to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively
     454// Fills with number of valid pixels (if !MBadPixelsPix::IsBad()):
     455// - fAverageAreaNum[area index]
     456// - fAverageSectorNum[area index]
     457//
     458// Calls InitializeHiGainHists() and InitializeLoGainHists() for every entry in:
     459// - fHiGainArray, fLoGainArray
     460// - fAverageHiGainAreas, fAverageLoGainAreas
     461// - fAverageHiGainSectors, fAverageLoGainSectors
     462//
     463// Sets Titles and Names for the Charge Histograms and
     464// Sets number of bins to fAverageNbins for:
     465// - fAverageHiGainAreas, fAverageLoGainAreas
     466// - fAverageHiGainSectors, fAverageLoGainSectors
     467//
    357468Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
    358469{
     
    374485  }
    375486
    376   const Int_t n = signal->GetSize();
    377 
    378   if (fHiGainArray->GetEntries()==0)
    379   {
    380       fHiGainArray->Expand(n);
    381  
    382       for (Int_t i=0; i<n; i++)
    383       {
    384           //
    385           // Oscillating pixels
    386           //
    387           (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
    388           MHCalibrationChargeHiGainPix &hist = (*this)[i];
    389 
    390           if ((*fBadPixels)[i].IsBad())
    391           {
    392             *fLog << warn << "Excluded pixel: " << i << " from calibration " << endl;
    393             hist.SetExcluded();
    394           }
    395           hist.Init();
    396           hist.ChangeHistId(i);
    397           hist.SetEventFrequency(fPulserFrequency);
    398       }
    399   }
    400 
    401  
    402   if (fLoGainArray->GetEntries()==0)
    403   {
    404       fLoGainArray->Expand(n);
    405      
    406       for (Int_t i=0; i<n; i++)
    407       {
    408           (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
    409           MHCalibrationChargeLoGainPix &hist = (*this)(i);
    410           //
    411           // Pixels with non-valid behavior
    412           //
    413           if ((*fBadPixels)[i].IsBad())
    414             hist.SetExcluded();
    415 
    416           hist.Init();
    417           hist.ChangeHistId(i);
    418           hist.SetEventFrequency(fPulserFrequency);
    419       }
    420      
    421   }
    422 
    423   const Int_t nareas = fGeom->GetNumAreas();
    424 
    425   if (fAverageHiGainAreas->GetEntries()==0)
    426   {
    427       fAverageHiGainAreas->Expand(nareas);
    428 
    429       for (Int_t j=0; j<nareas; j++)
    430       {
    431           //
    432           // Oscillating pixels
    433           //
    434           (*fAverageHiGainAreas)[j] =
    435             new MHCalibrationChargeHiGainPix("AverageHiGainArea",
    436                                              "Average HiGain FADC sums of pixel area idx ");
    437           MHCalibrationChargeHiGainPix &hist = GetAverageHiGainArea(j);
    438 
    439           hist.GetHGausHist()->SetTitle("Summed FADC slices average Hi Gain pixels Area Idx ");
    440           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Hi Gain pixels Area Idx ");
    441           hist.SetChargeFirst(-1000.);
    442           hist.SetChargeLast(4000.);
    443           hist.SetChargeNbins(4000);
    444           hist.Init();
    445           hist.ChangeHistId(j);
    446           hist.SetEventFrequency(fPulserFrequency);
    447       }
    448   }
    449 
    450   if (fAverageLoGainAreas->GetEntries()==0)
    451   {
    452       fAverageLoGainAreas->Expand(nareas);
    453  
    454       for (Int_t j=0; j<nareas; j++)
    455       {
    456           //
    457           // Oscillating pixels
    458           //
    459           (*fAverageLoGainAreas)[j] =
    460             new MHCalibrationChargeLoGainPix("AverageLoGainArea",
    461                                              "Average LoGain FADC sums of pixel area idx ");
    462           MHCalibrationChargeLoGainPix &hist = GetAverageLoGainArea(j);
    463 
    464           hist.GetHGausHist()->SetTitle("Summed FADC slices average Lo Gain pixels Area Idx ");
    465           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Lo Gain pixels Area Idx ");
    466           hist.SetChargeFirst(-1000.);
    467           hist.SetChargeLast(4000.);
    468           hist.SetChargeNbins(4000);
    469           hist.Init();
    470           hist.ChangeHistId(j);
    471           hist.SetEventFrequency(fPulserFrequency);
    472       }
    473   }
    474 
     487  const Int_t n        = signal->GetSize();
     488  const Int_t nsectors = fGeom->GetNumSectors();
     489  const Int_t nareas   = fGeom->GetNumAreas();
     490
     491  //
     492  // The function TArrayF::Set() already sets all entries to 0.
     493  //
    475494  fAverageAreaNum.        Set(nareas);
    476495  fAverageAreaSat.        Set(nareas);           
     
    479498  fAverageAreaRelSigma.   Set(nareas);   
    480499  fAverageAreaRelSigmaErr.Set(nareas);
     500  fAverageSectorNum.      Set(nsectors);
     501
     502  for (Int_t i=0; i<n; i++)
     503    {
     504      if ((*fBadPixels)[i].IsBad())
     505        continue;
     506      fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
     507      fAverageSectorNum[(*fGeom)[i].GetSector()]++;
     508    }
     509
     510  if (fHiGainArray->GetEntries()==0)
     511  {
     512      fHiGainArray->Expand(n);
     513      for (Int_t i=0; i<n; i++)
     514      {
     515          (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
     516          InitializeHiGainHists((*this)[i],(*fBadPixels)[i],i);
     517      }
     518  }
     519
     520 
     521  if (fLoGainArray->GetEntries()==0)
     522  {
     523      fLoGainArray->Expand(n);
     524     
     525      for (Int_t i=0; i<n; i++)
     526      {
     527          (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
     528          InitializeLoGainHists((*this)(i),(*fBadPixels)[i],i);
     529      }
     530     
     531  }
     532
     533  if (fAverageHiGainAreas->GetEntries()==0)
     534  {
     535    fAverageHiGainAreas->Expand(nareas);
    481536   
    482   for (Int_t i=0; i<n; i++)
    483     {
    484       if ((*this)[i].IsExcluded())
    485         continue;
    486 
    487       const Int_t aidx  = (*fGeom)[i].GetAidx();
    488       fAverageAreaNum[aidx]++;
    489     }
    490 
    491 
    492   const Int_t nsectors = fGeom->GetNumSectors();
    493 
     537    for (Int_t j=0; j<nareas; j++)
     538      {
     539        (*fAverageHiGainAreas)[j] =
     540          new MHCalibrationChargeHiGainPix("AverageHiGainArea",
     541                                           "Average HiGain FADC sums area idx ");
     542        InitializeHiGainHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);       
     543        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
     544        GetAverageHiGainArea(j).GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
     545        GetAverageHiGainArea(j).SetChargeNbins(fAverageNbins);
     546      }
     547  }
     548
     549  if (fAverageLoGainAreas->GetEntries()==0)
     550    {
     551      fAverageLoGainAreas->Expand(nareas);
     552     
     553      for (Int_t j=0; j<nareas; j++)
     554        {
     555          (*fAverageLoGainAreas)[j] =
     556            new MHCalibrationChargeLoGainPix("AverageLoGainArea",
     557                                             "Average LoGain FADC sums of pixel area idx ");
     558          InitializeLoGainHists(GetAverageLoGainArea(j),fCam->GetAverageBadArea(j),j);       
     559          GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
     560          GetAverageLoGainArea(j).GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
     561          GetAverageLoGainArea(j).SetChargeNbins(fAverageNbins);
     562        }
     563    }
     564 
    494565  if (fAverageHiGainSectors->GetEntries()==0)
    495566  {
     
    498569      for (Int_t j=0; j<nsectors; j++)
    499570      {
    500           //
    501           // Oscillating pixels
    502           //
    503571          (*fAverageHiGainSectors)[j] =
    504572            new MHCalibrationChargeHiGainPix("AverageHiGainSector",
    505573                                             "Average HiGain FADC sums of pixel sector ");
    506           MHCalibrationChargeHiGainPix &hist = GetAverageHiGainSector(j);
    507 
    508           hist.GetHGausHist()->SetTitle("Summed FADC slices average Hi Gain pixels Sector ");
    509           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Hi Gain pixels Sector ");
    510           hist.SetChargeFirst(-1000.);
    511           hist.SetChargeLast(4000.);
    512           hist.SetChargeNbins(4000);
    513           hist.Init();
    514           hist.ChangeHistId(j);
    515           hist.SetEventFrequency(fPulserFrequency);
     574          InitializeHiGainHists(GetAverageHiGainSector(j),fCam->GetAverageBadSector(j),j);       
     575          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
     576          GetAverageHiGainSector(j).GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
     577          GetAverageHiGainSector(j).SetChargeNbins(fAverageNbins);
    516578      }
    517579  }
     
    523585      for (Int_t j=0; j<nsectors; j++)
    524586      {
    525           //
    526           // Oscillating pixels
    527           //
    528587          (*fAverageLoGainSectors)[j] =
    529588            new MHCalibrationChargeLoGainPix("AverageLoGainSector",
    530589                                             "Average LoGain FADC sums of pixel sector ");
    531           MHCalibrationChargeLoGainPix &hist = GetAverageLoGainSector(j);
    532 
    533           hist.GetHGausHist()->SetTitle("Summed FADC slices average Lo Gain pixels Sector ");
    534           hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average Lo Gain pixels Sector ");
    535           hist.SetChargeFirst(-1000.);
    536           hist.SetChargeLast(4000.);
    537           hist.SetChargeNbins(4000);
    538           hist.Init();
    539           hist.ChangeHistId(j);
    540           hist.SetEventFrequency(fPulserFrequency);
     590          InitializeLoGainHists(GetAverageLoGainSector(j),fCam->GetAverageBadSector(j),j);
     591          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
     592          GetAverageLoGainSector(j).GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
     593          GetAverageLoGainSector(j).SetChargeNbins(fAverageNbins);
    541594      }
    542595  }
    543596
    544   fAverageSectorNum.        Set(nsectors);
    545 
    546   for (Int_t i=0; i<n; i++)
    547     {
    548       if ((*this)[i].IsExcluded())
    549         continue;
    550 
    551       const Int_t sector  = (*fGeom)[i].GetSector();
    552       fAverageSectorNum[sector]++;
    553     }
    554 
    555  
    556597  return kTRUE;
    557598}
    558  
    559 
    560 // --------------------------------------------------------------------------
     599
     600// -------------------------------------------------------------
     601//
     602// If MBadPixelsPix::IsBad():
     603// - calls MHCalibrationChargeHiGainPix::SetExcluded()
     604//
     605// Calls:
     606// - MHCalibrationChargePix::Init()
     607// - MHCalibrationChargePix::ChangeHistId(i)
     608// - MHGausEvents::SetEventFrequency(fPulserFrequency)
     609//
     610void MHCalibrationChargeCam::InitializeHiGainHists(MHCalibrationChargeHiGainPix &hist,MBadPixelsPix &bad, const Int_t i)
     611{
     612 
     613  if (bad.IsBad())
     614    {
     615      *fLog << warn << "Excluded pixel: " << i << " from calibration " << endl;
     616      hist.SetExcluded();
     617    }
     618 
     619  hist.Init();
     620  hist.ChangeHistId(i);
     621  hist.SetEventFrequency(fPulserFrequency);
     622         
     623}
     624
     625// -------------------------------------------------------------
     626//
     627// If MBadPixelsPix::IsBad():
     628// - calls MHCalibrationChargeLoGainPix::SetExcluded()
     629//
     630// Calls:
     631// - MHCalibrationChargePix::Init()
     632// - MHCalibrationChargePix::ChangeHistId(i)
     633// - MHGausEvents::SetEventFrequency(fPulserFrequency)
     634//
     635void MHCalibrationChargeCam::InitializeLoGainHists(MHCalibrationChargeLoGainPix &hist,MBadPixelsPix &bad, const Int_t i)
     636{
     637
     638  if (bad.IsBad())
     639    hist.SetExcluded();
     640 
     641  hist.Init();
     642  hist.ChangeHistId(i);
     643  hist.SetEventFrequency(fPulserFrequency);
     644}
     645
     646 
     647// --------------------------------------------------------------------------
     648//
     649// Retrieves from MExtractedSignalCam:
     650// - number of pixels
     651// - first used LoGain FADC slice
     652//
     653// Retrieves from MGeomCam:
     654// - number of pixel areas
     655// - number of sectors
     656//
     657// For all TObjArray's (including the averaged ones), the following steps are performed:
     658//
     659// 1) Test size and return kFALSE if not matching
     660//
     661// 2) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
     662// - MExtractedSignalPix::GetExtractedSignalHiGain();
     663// - MExtractedSignalPix::GetExtractedSignalLoGain();
     664//
     665// 3) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
     666// - MExtractedSignalPix::GetNumHiGainSaturated();
     667// - MExtractedSignalPix::GetNumLoGainSaturated();
     668//
     669// 4) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
     670// - MRawEvtPixelIter::GetIdxMaxHiGainSample();       
     671// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
     672//
    561673Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
    562674{
     
    725837// --------------------------------------------------------------------------
    726838//
    727 // 1) Return if the charge distribution is already succesfully fitted 
    728 //    or if the histogram is empty
    729 // 2) Fit the histograms with a Gaussian
    730 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
    731 // 4) Check for pickup noise
    732 // 5) Check the fourier spectrum
    733 // 5) Retrieve the results and store them in this class
     839// For all TObjArray's (including the averaged ones), the following steps are performed:
     840//
     841// 1) Return if the pixel is excluded
     842//
     843// 2) Call to FinalizeHiGainHists() and FinalizeLoGainHists()
     844//
     845// For all averaged areas, the fitted sigma is multiplied with the square root of
     846// the number involved pixels
    734847//
    735848Bool_t MHCalibrationChargeCam::Finalize()
     
    832945}
    833946
     947// ---------------------------------------------------------------------------
     948//
     949// Returns if the histogram is empty and sets the following flag:
     950// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
     951//
     952// Returns if the number of saturated slices (MHCalibrationChargePix::GetSaturated()) is
     953// higher than the allowed limit (fNumHiGainSaturationLimit*histogram-entries), creates
     954// the fourier spectrum and sets the following flags:
     955// - MCalibrationChargePix::SetHiGainSaturation()
     956//
     957// Fits the histograms with a Gaussian, in case of failure
     958// calls MHCalibrationChargePix::RepeatFit(), in case of repeated failure
     959// calls MHGausEvents::BypassFit() and sets the following flags:
     960// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
     961// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   )
     962//
     963// Counts the number of pickup events
     964//
     965// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
     966// In case no, sets the following flags:
     967// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
     968// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
     969//
     970// Retrieves the results and store them in MCalibrationChargePix
     971//
    834972void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
    835973                                                 MCalibrationChargePix &pix,
     
    851989      return;
    852990    }
    853    
     991
    854992    //
    855993    // 2) Fit the Hi Gain histograms with a Gaussian
     
    8771015    hist.CreateFourierSpectrum();
    8781016   
    879     //
    880     // 6) Retrieve the results and store them in this class
    881     //
    882     pix.SetHiGainMeanCharge(     hist.GetMean()     );
    883     pix.SetHiGainMeanChargeErr(  hist.GetMeanErr()  );
    884     pix.SetHiGainSigmaCharge(    hist.GetSigma()    );
    885     pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
    886     pix.SetHiGainChargeProb    ( hist.GetProb()     );
    887    
    888     pix.SetAbsTimeMean         ( hist.GetAbsTimeMean());
    889     pix.SetAbsTimeRms          ( hist.GetAbsTimeRms() );
    890    
    891     pix.SetHiGainNumPickup     (  hist.GetPickup()           );
    892    
    8931017    if (!hist.IsFourierSpectrumOK())
    8941018      {
     
    8971021        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun     );
    8981022      }
    899 }
    900 
    901 
     1023
     1024    //
     1025    // 6) Retrieve the results and store them in this class
     1026    //
     1027    pix.SetHiGainMeanCharge(     hist.GetMean()      );
     1028    pix.SetHiGainMeanChargeErr(  hist.GetMeanErr()   );
     1029    pix.SetHiGainSigmaCharge(    hist.GetSigma()     );
     1030    pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr()  );
     1031    pix.SetHiGainChargeProb    ( hist.GetProb()      );
     1032   
     1033    pix.SetAbsTimeMean         ( hist.GetAbsTimeMean());
     1034    pix.SetAbsTimeRms          ( hist.GetAbsTimeRms() );
     1035   
     1036    pix.SetHiGainNumPickup     ( hist.GetPickup()     );
     1037   
     1038}
     1039
     1040// ---------------------------------------------------------------------------
     1041//
     1042// Returns if the histogram is empty. If yes and the flag MCalibrationChargePix::IsHiGainSaturation()
     1043// is set, sets the following flag:
     1044// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
     1045//
     1046// Returns if the number of saturated slices (MHCalibrationChargePix::GetSaturated()) is
     1047// higher than the allowed limit (fNumLoGainSaturationLimit*histogram-entries), creates
     1048// the fourier spectrum and sets the following flags:
     1049// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
     1050// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1051//
     1052// Fits the histograms with a Gaussian, in case of failure calls MHCalibrationChargePix::RepeatFit(),
     1053// in case of repeated failure calls MHGausEvents::BypassFit() and sets the following flags:
     1054// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
     1055//   If the flag MCalibrationChargePix::IsHiGainSaturation() is set, sets additionally:
     1056// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   )
     1057//
     1058// Counts the number of pickup events
     1059//
     1060// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
     1061// In case no, sets the following flags:
     1062// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
     1063//   If the flag MCalibrationChargePix::IsHiGainSaturation() is set, sets additionally:
     1064// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
     1065//
     1066// Retrieves the results and store them in MCalibrationChargePix
     1067//
    9021068void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
    9031069                                                 MCalibrationChargePix &pix,
     
    9151081    {
    9161082      *fLog << warn << "Saturated Lo Gain histogram in pixel: " << pix.GetPixId() << endl;
    917       pix.SetLoGainSaturation();
    9181083      bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
    9191084      bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     
    9471112    hist.CreateFourierSpectrum();
    9481113   
     1114    if (!hist.IsFourierSpectrumOK())
     1115      {
     1116        bad.SetUncalibrated( MBadPixelsPix::kLoGainOscillating );
     1117        if (pix.IsHiGainSaturation())
     1118          bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     1119      }
    9491120    //
    9501121    // 6) Retrieve the results and store them in this class
     
    9641135    pix.SetLoGainNumPickup     (  hist.GetPickup()    );
    9651136
    966     if (!hist.IsFourierSpectrumOK())
    967       {
    968         bad.SetUncalibrated( MBadPixelsPix::kLoGainOscillating );
    969         if (pix.IsHiGainSaturation())
    970           bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
    971       }
    9721137}   
    9731138
    974 
    975 
     1139// --------------------------------------------------------------------------
     1140//
     1141// Dummy, needed by MCamEvent
     1142//
    9761143Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    9771144{
     
    9881155}
    9891156
    990 
     1157// -----------------------------------------------------------------------------
     1158//
     1159// Default draw:
     1160//
     1161// Displays the averaged areas, both High Gain and Low Gain
     1162//
     1163// The following options can be chosen:
     1164//
     1165// "": displays the fHGausHist and the fHAbsTime
     1166// "all": executes additionally MHGausEvents::Draw(), with options
     1167//
    9911168void MHCalibrationChargeCam::Draw(const Option_t *opt)
    9921169{
     
    10211198}
    10221199
     1200// -----------------------------------------------------------------------------
     1201//
     1202// Default draw:
     1203//
     1204// Displays a TPaveText with the re-normalized sigmas of the average area
     1205//
    10231206void MHCalibrationChargeCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
    10241207                                              Float_t sigma, Float_t sigmaerr,
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h

    r3624 r3626  
    3636private:
    3737
     38  static const Int_t   fgAverageNbins;               // The default for fAverageNbins
    3839  static const Float_t fgNumHiGainSaturationLimit;   // The default for fNumHiGainSaturationLimit
    3940  static const Float_t fgNumLoGainSaturationLimit;   // The default for fNumLoGainSaturationLimit
    4041  static const Int_t   fgPulserFrequency;            // The default for fPulserFrequency
    4142 
     43  Int_t   fAverageNbins;              // Number of bins for the average histograms
    4244  Float_t fNumHiGainSaturationLimit;  // Rel. amount sat. higain FADC slices until pixel is called saturated
    4345  Float_t fNumLoGainSaturationLimit;  // Rel. amount sat. logain FADC slices until pixel is called saturated
    44 
    4546  Int_t   fPulserFrequency;           // Light pulser frequency
    4647 
     
    6667  TArrayI fAverageSectorNum;          // Number of pixels in average pixels per sector
    6768
     69  void InitializeHiGainHists(MHCalibrationChargeHiGainPix &hist, MBadPixelsPix &bad, const Int_t i);
     70  void InitializeLoGainHists(MHCalibrationChargeLoGainPix &hist, MBadPixelsPix &bad, const Int_t i); 
     71 
    6872  void FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
    6973  void FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
     
    7781  ~MHCalibrationChargeCam();
    7882
     83  void SetAverageNbins(    const Int_t bins=fgAverageNbins  )          { fAverageNbins = bins; }
     84  void SetNumLoGainSaturationLimit( const Float_t lim=fgNumLoGainSaturationLimit) { fNumLoGainSaturationLimit = lim; }
    7985  void SetNumHiGainSaturationLimit( const Float_t lim=fgNumHiGainSaturationLimit) { fNumHiGainSaturationLimit = lim; }
    80   void SetNumLoGainSaturationLimit( const Float_t lim=fgNumLoGainSaturationLimit) { fNumLoGainSaturationLimit = lim; }
    8186  void SetPulserFrequency        ( const Int_t   f=fgPulserFrequency)          { fPulserFrequency = f;            }
    8287 
Note: See TracChangeset for help on using the changeset viewer.