Changeset 3264 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/23/04 06:02:14 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3263 r3264  
    4141   * mcalib/MCalibrationChargeCalc.[h,cc]
    4242   * mcalib/MCalibrationChargeCam.[h,cc]
     43   * mcalib/MCalibrationChargePix.[h,cc]
    4344   * mcalib/MCalibrationChargePINDiode.[h,cc]
    4445   * mcalib/MCalibrationCalc.[h,cc]
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3247 r3264  
    1616!
    1717!
    18 !   Author(s): Markus Gaug  09/2003 <mailto:markus@ifae.es>
     18!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2001
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    3131//   MExtractedSignalCam. The pedestals by an MPedestalCam.
    3232//
    33 //   The output container MCalibrationCam holds one entry of type MCalibrationPix
     33//   The output container MCalibrationCam holds one entry of type MCalibrationChargePix
    3434//   for every pixel. It is filled in the following way:
    3535//
     
    3939//               
    4040//   ReInit:     MCalibrationCam::InitSize(NumPixels) is called which allocates
    41 //               memory in a TClonesArray of type MCalibrationPix
     41//               memory in a TClonesArray of type MCalibrationChargePix
    4242//               Initialize number of used FADC slices
    4343//               Optionally exclude pixels from calibration               
    4444//
    45 //   Process:    Every MCalibrationPix holds a histogram class,
     45//   Process:    Every MCalibrationChargePix holds a histogram class,
    4646//               MHCalibrationPixel which itself hold histograms of type:
    4747//               HCharge(npix) (distribution of summed FADC time slice
     
    9797#include "MCalibrationChargeCam.h"
    9898#include "MCalibrationChargePINDiode.h"
    99 #include "MCalibrationPix.h"
     99#include "MCalibrationChargePix.h"
    100100
    101101#include "MExtractedSignalCam.h"
     
    142142    SETBIT(fFlags, kUseQualityChecks);
    143143    SETBIT(fFlags, kHiLoGainCalibration);
    144 
    145     CLRBIT(fFlags, kHiGainOverFlow);
    146     CLRBIT(fFlags, kLoGainOverFlow);
    147144
    148145    fNumBlindPixelSinglePhe = 0;
     
    270267      {
    271268       
    272         MCalibrationPix &pix = (*fCam)[i];
     269        MCalibrationChargePix &pix = (*fCam)[i];
    273270        pix.DefinePixId(i);
    274271
     
    278275                                    fSignals->GetLastUsedSliceLoGain());
    279276       
    280         if (!TESTBIT(fFlags,kUseQualityChecks))
    281           pix.SetExcludeQualityCheck();
    282277
    283278        // Exclude the blind pixel and the PIN Diode from normal pixel calibration:
     
    330325                // Exclude pixel
    331326                //
    332                 MCalibrationPix &pix = (*fCam)[pixel];
     327                MCalibrationChargePix &pix = (*fCam)[pixel];
    333328                pix.SetExcluded();
    334329               
     
    412407    hist->Fill(i,*ptr++);
    413408
    414   pixel.Reset();
    415  
    416   while (pixel.Next())
    417     {
    418      
    419       const UInt_t pixid = pixel.GetPixelId();
    420      
    421       MCalibrationPix            &pix   =  (*fCam)[pixid];
    422       MExtractedSignalPix        &sig   =  (*fSignals)     [pixid];
    423      
    424       const Float_t sumhi  = sig.GetExtractedSignalHiGain();
    425       const Float_t sumlo  = sig.GetExtractedSignalLoGain();
    426 
    427       Float_t abstime = 0.;
    428 
    429       if (sig.IsLoGainUsed())
    430         abstime = (Float_t)pixel.GetIdxMaxLoGainSample();
    431       else
    432         abstime = (Float_t)pixel.GetIdxMaxHiGainSample();
    433 
    434       if (pix.IsExcluded())
    435         continue;
    436      
    437       pix.FillGraphs(sumhi,sumlo);
    438 
    439       if (sig.IsLoGainUsed())
    440         {
    441          
    442           if (!pix.FillChargeLoGain(sumlo))
    443             *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
    444                   << " signal = " << sumlo << endl;
    445          
    446           if (!pix.FillAbsTimeLoGain(abstime))
    447             *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: "
    448                   << pixid << " time = " << abstime << endl;
    449         }
    450       else
    451         {
    452           if (!pix.FillChargeHiGain(sumhi))
    453             *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
    454                   << " signal = " << sumhi << endl;
    455          
    456           if (!pix.FillAbsTimeHiGain(abstime))
    457             *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: "
    458                   << pixid << " time = " << abstime << endl;
    459         }
    460      
    461     } /* while (pixel.Next()) */
    462 
    463409  return kTRUE;
    464410}
     
    467413{
    468414  *fLog << inf << GetDescriptor() << ": Cut Histogram Edges" << endl;
    469 
    470   //
    471   // Cut edges to make fits and viewing of the hists easier 
    472   //
    473   fCam->CutEdges();
    474415
    475416  //
     
    550491    {
    551492
    552       MCalibrationPix &pix = (*fCam)[pixid];
     493      MCalibrationChargePix &pix = (*fCam)[pixid];
    553494
    554495      //
     
    563504      const Float_t ped    = (*fPedestals)[pixid].GetPedestal();
    564505      const Float_t prms   = (*fPedestals)[pixid].GetPedestalRms();
     506      const Int_t   num    = fPedestals->GetTotalEntries();
    565507
    566508      //
    567509      // set them in the calibration camera
    568510      //
    569       pix.SetPedestal(ped,prms,(Float_t)fNumHiGainSamples,(Float_t)fNumLoGainSamples);
    570 
    571       //
    572       // perform the Gauss fits to the charges
    573       //
    574       pix.FitCharge();
    575 
    576       //
    577       // check also for oscillations
    578       //
    579       pix.CheckOscillations();
    580 
    581       //
    582       // calculate the F-Factor method
    583       //
     511      if (pix.IsHiGainSaturation())
     512      {
     513          pix.SetPedestal(ped  * (Float_t)fNumLoGainSamples,
     514                          prms * TMath::Sqrt((Float_t)fNumLoGainSamples),
     515                          prms * (Float_t)fNumLoGainSamples / num);
     516          pix.SetNumLoGainSamples((Float_t)fNumLoGainSamples);
     517          pix.ApplyLoGainConversion();
     518      }
     519      else
     520      {
     521          pix.SetPedestal(ped  * (Float_t)fNumHiGainSamples,
     522                          prms * TMath::Sqrt((Float_t)fNumHiGainSamples),
     523                          prms * (Float_t)fNumHiGainSamples / num);
     524      }
     525
     526      if (!pix.CheckChargeValidity() || !pix.CheckTimeValidity())
     527          continue;
     528
     529      if (!pix.CalcReducedSigma())
     530          continue;
     531
    584532      pix.CalcFFactorMethod();
     533
    585534    }
    586535
     
    597546    *fLog << inf << GetDescriptor() << ": Skipping Blind Pixel Calibration! " << endl;
    598547
    599   if (!fPINDiode->CalcFluxOutsidePlexiglass())
     548  if (!fPINDiode->CheckChargeFitValidity() || !fPINDiode->CheckTimeFitValidity())
    600549  {
    601       *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, will skip PIN Diode Calibration " << endl;
     550      *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, charge fit not valid " << endl;
    602551      fCam->SetPINDiodeMethodValid(kFALSE);
    603552  }
    604553  else
    605   {
    606       fCam->SetPINDiodeMethodValid(kTRUE);
     554  {
     555      if (!fPINDiode->CalcFluxOutsidePlexiglass())
     556      {
     557          *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, will skip PIN Diode Calibration " << endl;
     558          fCam->SetPINDiodeMethodValid(kFALSE);
     559      }
     560      else
     561      {
     562          fCam->SetPINDiodeMethodValid(kTRUE);
     563      }
    607564  }
    608 
    609565  fCam->SetReadyToSave();
    610566 
     
    613569
    614570
     571
     572
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r3247 r3264  
    6767  enum  { kUseBlindPixelFit,
    6868          kUseQualityChecks,
    69           kHiLoGainCalibration,
    70           kHiGainOverFlow,
    71           kLoGainOverFlow  };
     69          kHiLoGainCalibration };
    7270 
     71  Int_t  PreProcess(MParList *pList);
    7372  Bool_t ReInit(MParList *pList);
    74   Int_t PreProcess(MParList *pList);
    75   Int_t Process();
    76   Int_t PostProcess();
     73  Int_t  Process();
     74  Int_t  PostProcess();
    7775 
    7876public:
     
    9189
    9290  // Setters
    93   void SetConversionHiLo         ( const Float_t       conv )       { fConversionHiLo = conv;  }
    9491  void SetBlindPixelSinglePheCut ( const Int_t         cut=fgBlindPixelSinglePheCut)   
    9592                                                                    { fBlindPixelSinglePheCut = cut; }
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r3247 r3264  
    126126#include "MGeomPix.h"
    127127
    128 #include "MCalibrationPix.h"
     128#include "MCalibrationChargePix.h"
    129129#include "MCalibrationBlindPix.h"
    130130#include "MCalibrationChargePINDiode.h"
    131131
    132 #include "MHCalibrationPixel.h"
    133132
    134133ClassImp(MCalibrationChargeCam);
     
    174173    fTitle = title ? title : "Storage container for the Calibration Information in the camera";
    175174
    176     fPixels     = new TClonesArray("MCalibrationPix",1);
     175    fPixels     = new TClonesArray("MCalibrationChargePix",1);
    177176    fBlindPixel = new MCalibrationBlindPix();
    178177
     
    252251// Get i-th pixel (pixel number)
    253252//
    254 MCalibrationPix &MCalibrationChargeCam::operator[](UInt_t i)
    255 {
    256   return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
     253MCalibrationChargePix &MCalibrationChargeCam::operator[](UInt_t i)
     254{
     255  return *static_cast<MCalibrationChargePix*>(fPixels->UncheckedAt(i));
    257256}
    258257
     
    261260// Get i-th pixel (pixel number)
    262261//
    263 const MCalibrationPix &MCalibrationChargeCam::operator[](UInt_t i) const
    264 {
    265   return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
     262const MCalibrationChargePix &MCalibrationChargeCam::operator[](UInt_t i) const
     263{
     264  return *static_cast<MCalibrationChargePix*>(fPixels->UncheckedAt(i));
    266265}
    267266
     
    329328
    330329  TIter Next(fPixels);
    331   MCalibrationPix *pix;
    332   while ((pix=(MCalibrationPix*)Next()))
     330  MCalibrationChargePix *pix;
     331  while ((pix=(MCalibrationChargePix*)Next()))
    333332    {
    334333     
    335       if (pix->IsChargeValid() && !pix->IsExcluded() && !pix->IsOscillating() && pix->IsFitted())
     334      if (pix->IsChargeValid() && !pix->IsExcluded() && !pix->IsOscillating())
    336335        {
    337336
    338337          *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
    339                 << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
     338                << pix->GetPedRms() << " Reduced Charge: " << pix->GetMeanCharge() << " +- "
    340339                << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge()
    341340                << " Nr Phe's: " << pix->GetPheFFactorMethod() << endl;
     
    352351 
    353352  TIter Next2(fPixels);
    354     while ((pix=(MCalibrationPix*)Next2()))
     353    while ((pix=(MCalibrationChargePix*)Next2()))
    355354      {
    356355       
    357         if (!pix->IsChargeValid() && !pix->IsExcluded() && !pix->IsFitted())
     356        if (!pix->IsExcluded() && !pix->IsChargeValid())
    358357          {
    359358
    360359            *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
    361                   << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
     360                  << pix->GetPedRms() << " Reduced Charge: " <<  pix->GetMeanCharge() << " +- "
    362361                  << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge() << endl;
    363362            id++;
     
    373372
    374373  TIter Next3(fPixels);
    375   while ((pix=(MCalibrationPix*)Next3()))
     374  while ((pix=(MCalibrationChargePix*)Next3()))
    376375    {
    377      
    378       if (pix->IsOscillating() && !pix->IsExcluded())
     376
     377      if ( pix->IsOscillating() && !pix->IsExcluded())
    379378        {
    380379         
    381380          *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
    382                 << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
     381                << pix->GetPedRms() << " Reduced Charge: " << pix->GetMeanCharge() << " +- "
    383382                << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge() << endl;
    384383          id++;
     
    392391  *fLog << all << endl;
    393392 
     393  id = 0;
     394
    394395  TIter Next4(fPixels);
    395   while ((pix=(MCalibrationPix*)Next4()))
    396     if (pix->IsExcluded())
    397         *fLog << all << pix->GetPixId() << endl;
    398 
    399   *fLog << all << fNumExcludedPixels << " excluded pixels " << endl;
    400 }
    401 
    402 // --------------------------------------------------------------------------
    403 //
    404 // Return true if pixel is inside bounds of the TClonesArray fPixels
    405 //
    406 Bool_t MCalibrationChargeCam::IsPixelUsed(Int_t idx) const
    407 {
    408   if (!CheckBounds(idx))
    409     return kFALSE;
    410 
    411   return kTRUE;
    412 }
    413 
    414 // --------------------------------------------------------------------------
    415 //
    416 // Return true if pixel has already been fitted once (independent of the result)
    417 //
    418 Bool_t MCalibrationChargeCam::IsPixelFitted(Int_t idx) const
    419 {
    420 
    421   if (!CheckBounds(idx))
    422     return kFALSE;
    423 
    424   return (*this)[idx].IsFitted();
    425 }
     396  while ((pix=(MCalibrationChargePix*)Next4()))
     397  {
     398      if (pix->IsExcluded())
     399      {
     400          *fLog << all << pix->GetPixId() << endl;
     401          id++;
     402      }
     403  }
     404  *fLog << all << id << " Excluded pixels " << endl;
     405}
     406
    426407
    427408// --------------------------------------------------------------------------
     
    435416
    436417  fBlindPixel->GetHist()->CutAllEdges();
    437 
    438   TIter Next(fPixels);
    439   MCalibrationPix *pix;
    440   while ((pix=(MCalibrationPix*)Next()))
    441     {
    442       pix->GetHist()->CutAllEdges();
    443     }
    444418
    445419  return;
     
    495469// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
    496470// 29: Pixels with succeeded fit, but apparently wrong results
    497 // 30: Pixels with un-expected behavior in the fourier spectrum (e.g. oscillations)
     471// 30: Pixels with un-expected behavior in the Hi Gain fourier spectrum (e.g. oscillations)
     472// 31: Pixels with un-expected behavior in the Lo Gain fourier spectrum (e.g. oscillations)a
     473// 32: Number of probable pickup events in the Hi Gain
     474// 33: Number of probable pickup events in the Lo Gain
    498475//
    499476// Other classifications of pixels:
    500477// ================================
    501478//
    502 // 31: Pixels with saturated Hi-Gain
     479// 34: Pixels with saturated Hi-Gain
    503480//
    504481// Classification of validity of the calibrations:
    505482// ===============================================
    506483//
    507 // 32: Pixels with valid calibration by the F-Factor-Method
    508 // 33: Pixels with valid calibration by the Blind Pixel-Method
    509 // 34: Pixels with valid calibration by the PIN Diode-Method
     484// 35: Pixels with valid calibration by the F-Factor-Method
     485// 36: Pixels with valid calibration by the Blind Pixel-Method
     486// 37: Pixels with valid calibration by the PIN Diode-Method
    510487//
    511488// Used Pedestals:
    512489// ===============
    513490//
    514 // 35: Mean Pedestal over the entire range of signal extraction
    515 // 36: Error on the Mean Pedestal over the entire range of signal extraction
    516 // 37: Pedestal RMS over the entire range of signal extraction
    517 // 38: Error on the Pedestal RMS over the entire range of signal extraction
     491// 38: Mean Pedestal over the entire range of signal extraction
     492// 39: Error on the Mean Pedestal over the entire range of signal extraction
     493// 40: Pedestal RMS over the entire range of signal extraction
     494// 41: Error on the Pedestal RMS over the entire range of signal extraction
    518495//
    519496// Calculated absolute arrival times (very low precision!):
    520497// ========================================================
    521498//
    522 // 39: Absolute Arrival time of the signal
    523 // 40: Error on the Absolute Arrival time of the signal
    524 // 41: RMS of the Absolute Arrival time of the signal
    525 // 42: Error on the RMS of the Absolute Arrival time of the signal
     499// 42: Absolute Arrival time of the signal
     500// 43: RMS of the Absolute Arrival time of the signal
    526501//
    527502Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
     
    541516      if ((*this)[idx].IsExcluded())
    542517        return kFALSE;
    543       val = (*this)[idx].GetCharge();
     518      val = (*this)[idx].GetMeanCharge();
    544519      break;
    545520    case 1:
    546521      if ((*this)[idx].IsExcluded())
    547522        return kFALSE;
    548       val = (*this)[idx].GetChargeErr();
     523      val = (*this)[idx].GetMeanChargeErr();
    549524      break;
    550525    case 2:
     
    576551      if ((*this)[idx].IsExcluded())
    577552        return kFALSE;
    578       val = (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetCharge();
     553      val = (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetMeanCharge();
    579554      break;
    580555    case 8:
     
    585560            / ((*this)[idx].GetRSigmaCharge()   * (*this)[idx].GetRSigmaCharge()   );
    586561      // relative error Charge square
    587       val +=   (*this)[idx].GetChargeErr() * (*this)[idx].GetChargeErr()
    588             / ((*this)[idx].GetCharge()    * (*this)[idx].GetCharge()   );
     562      val +=   (*this)[idx].GetMeanChargeErr() * (*this)[idx].GetMeanChargeErr()
     563            / ((*this)[idx].GetMeanCharge()    * (*this)[idx].GetMeanCharge()   );
    589564      // calculate relative error out of squares
    590565      val  =   TMath::Sqrt(val) ;
    591566      // multiply with value to get absolute error
    592       val  *=  (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetCharge();
     567      val  *=  (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetMeanCharge();
    593568      break;
    594569    case 9:
     
    709684      if ((*this)[idx].IsExcluded())
    710685        return kFALSE;
    711       if ((*this)[idx].IsOscillating())
     686      if ((*this)[idx].IsHiGainOscillating())
    712687        val = 1;
    713688      else
     
    715690      break;
    716691    case 31:
     692      if ((*this)[idx].IsExcluded())
     693        return kFALSE;
     694      if ((*this)[idx].IsLoGainOscillating())
     695        val = 1;
     696      else
     697        return kFALSE;
     698      break;
     699    case 32:
     700      if ((*this)[idx].IsExcluded())
     701        return kFALSE;
     702      val = (*this)[idx].GetHiGainNumPickup();
     703      break;
     704    case 33:
     705      if ((*this)[idx].IsExcluded())
     706        return kFALSE;
     707      val = (*this)[idx].GetLoGainNumPickup();
     708      break;
     709    case 34:
    717710      if ((*this)[idx].IsExcluded())
    718711        return kFALSE;
     
    722715        return kFALSE;
    723716      break;
    724     case 32:
     717    case 35:
    725718      if ((*this)[idx].IsExcluded())
    726719        return kFALSE;
     
    730723        return kFALSE;
    731724      break;
    732     case 33:
     725    case 36:
    733726      if ((*this)[idx].IsExcluded())
    734727        return kFALSE;
     
    738731        return kFALSE;
    739732      break;
    740     case 34:
     733    case 37:
    741734      if ((*this)[idx].IsExcluded())
    742735        return kFALSE;
     
    746739        return kFALSE;
    747740      break;
    748     case 35:
     741    case 38:
    749742      if ((*this)[idx].IsExcluded())
    750743        return kFALSE;
    751744      val = (*this)[idx].GetPed();
    752745      break;
    753     case 36:
    754       if ((*this)[idx].IsExcluded())
    755         return kFALSE;
    756       val = 1.;
    757       //      val = (*this)[idx].GetPedError();
    758       break;
    759     case 37:
     746    case 39:
     747      if ((*this)[idx].IsExcluded())
     748        return kFALSE;
     749      val = (*this)[idx].GetPedErr();
     750      break;
     751    case 40:
    760752      if ((*this)[idx].IsExcluded())
    761753        return kFALSE;
    762754      val = (*this)[idx].GetPedRms();
    763755      break;
    764     case 38:
    765       if ((*this)[idx].IsExcluded())
    766         return kFALSE;
    767       val = 1.;
    768       //      val = (*this)[idx].GetPedRmsError();
    769       break;
    770     case 39:
     756    case 41:
     757      if ((*this)[idx].IsExcluded())
     758        return kFALSE;
     759      val = (*this)[idx].GetPedErr()/2.;
     760      break;
     761    case 42:
    771762      if ((*this)[idx].IsExcluded())
    772763        return kFALSE;
    773764      val = (*this)[idx].GetAbsTimeMean();
    774765      break;
    775     case 40:
    776       if ((*this)[idx].IsExcluded())
    777         return kFALSE;
    778       val = (*this)[idx].GetAbsTimeMeanErr();
    779       break;
    780     case 41:
     766    case 43:
    781767      if ((*this)[idx].IsExcluded())
    782768        return kFALSE;
    783769      val = (*this)[idx].GetAbsTimeRms();
    784       break;
    785     case 42:
    786       if ((*this)[idx].IsExcluded())
    787         return kFALSE;
    788       val = (*this)[idx].GetAbsTimeMeanErr()/TMath::Sqrt(2.);
    789770      break;
    790771    default:
     
    893874
    894875  TIter Next(fPixels);
    895   MCalibrationPix *pix;
    896   while ((pix=(MCalibrationPix*)Next()))
     876  MCalibrationChargePix *pix;
     877  while ((pix=(MCalibrationChargePix*)Next()))
    897878    {
    898879
     
    902883          const Int_t idx = pix->GetPixId();
    903884
    904           const Float_t charge    = pix->GetCharge();
     885          const Float_t charge    = pix->GetMeanCharge();
    905886          const Float_t area      = (*fGeomCam)[idx].GetA();
    906           const Float_t chargeerr = pix->GetChargeErr();         
     887          const Float_t chargeerr = pix->GetMeanChargeErr();         
    907888
    908889          const Float_t nphot      = fMeanFluxInsidePlexiglass*area;
     
    937918
    938919  TIter Next(fPixels);
    939   MCalibrationPix *pix;
    940   while ((pix=(MCalibrationPix*)Next()))
     920  MCalibrationChargePix *pix;
     921  while ((pix=(MCalibrationChargePix*)Next()))
    941922    {
    942923
     
    946927          const Int_t idx = pix->GetPixId();
    947928
    948           const Float_t charge    = pix->GetCharge();
     929          const Float_t charge    = pix->GetMeanCharge();
    949930          const Float_t area      = (*fGeomCam)[idx].GetA();
    950           const Float_t chargeerr = pix->GetChargeErr();         
     931          const Float_t chargeerr = pix->GetMeanChargeErr();         
    951932
    952933          const Float_t nphot      = flux    * area;
     
    980961{
    981962 
    982   if (ipx < 0 || !IsPixelFitted(ipx))
    983     return kFALSE;
    984963
    985964  if (!IsFluxInsidePlexiglassAvailable())
     
    997976Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    998977{
    999  
    1000   if (ipx < 0 || !IsPixelFitted(ipx))
    1001     return kFALSE;
    1002978
    1003979  Float_t conv = (*this)[ipx].GetMeanConversionFFactorMethod();
     
    10241000Bool_t MCalibrationChargeCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    10251001{
    1026 
    1027   if (ipx < 0 || !IsPixelFitted(ipx))
    1028     return kFALSE;
    10291002
    10301003  mean  = (*this)[ipx].GetMeanConversionPINDiodeMethod();
     
    10481021Bool_t MCalibrationChargeCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    10491022{
    1050 
    1051   if (ipx < 0 || !IsPixelFitted(ipx))
    1052     return kFALSE;
    1053 
    10541023  return kFALSE;
    10551024
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h

    r3247 r3264  
    1313class TClonesArray;
    1414
    15 class MCalibrationPix;
    1615class MCalibrationBlindPix;
    1716class MCalibrationChargePINDiode;
     17class MCalibrationChargePix;
    1818class MCalibrationChargeCam : public MParContainer, public MCamEvent
    1919{
     
    103103  Bool_t GetConversionFactorCombined(   Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
    104104
    105   Bool_t IsPixelUsed(Int_t idx)      const;
    106   Bool_t IsPixelFitted(Int_t idx)    const;
    107 
    108105  Bool_t IsBlindPixelMethodValid()   const;
    109106  Bool_t IsPINDiodeMethodValid()     const; 
     
    112109
    113110  // Others
    114   MCalibrationPix &operator[](UInt_t i);
    115   const MCalibrationPix &operator[](UInt_t i) const;
     111  MCalibrationChargePix &operator[](UInt_t i);
     112  const MCalibrationChargePix &operator[](UInt_t i) const;
    116113 
    117114  void CutEdges();
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h

    r3247 r3264  
    8080          kFluxOutsidePlexiglassAvailable  };   
    8181
    82   Bool_t CheckChargeFitValidity();
    83   Bool_t CheckTimeFitValidity();
    84  
    8582public:
    8683
     
    9188 
    9289  // Setters
    93   void SetColor(   const PulserColor_t color )    {  fColor = color;         }
     90  void SetColor(   const PulserColor_t color )  {  fColor = color;         }
    9491
    9592  void SetMeanCharge     (   const Float_t f )    { fMeanCharge        = f;  }
     
    146143  Bool_t  IsMeanTimeInLastBin()  const;
    147144
     145  Bool_t  CheckChargeFitValidity();
     146  Bool_t  CheckTimeFitValidity();
    148147  Bool_t  CalcFluxOutsidePlexiglass();
    149148
     
    153152#endif   /* MARS_MCalibrationChargePINDiode */
    154153
     154
     155
     156
     157
     158
     159
     160
     161
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeHiGainPix.cc

    r3257 r3264  
    4949using namespace std;
    5050
    51 const Int_t   MHCalibrationChargeHiGainPix::fgChargeNbins     = 200;
     51const Int_t   MHCalibrationChargeHiGainPix::fgChargeNbins     = 2000;
    5252const Axis_t  MHCalibrationChargeHiGainPix::fgChargeFirst     = -0.5;
    53 const Axis_t  MHCalibrationChargeHiGainPix::fgChargeLast      = 199.5;
    54 const Int_t   MHCalibrationChargeHiGainPix::fgAbsTimeNbins    = 30;
     53const Axis_t  MHCalibrationChargeHiGainPix::fgChargeLast      = 1999.5;
     54const Int_t   MHCalibrationChargeHiGainPix::fgAbsTimeNbins    = 20;
    5555const Axis_t  MHCalibrationChargeHiGainPix::fgAbsTimeFirst    = -0.5;
    56 const Axis_t  MHCalibrationChargeHiGainPix::fgAbsTimeLast     = 29.5;
     56const Axis_t  MHCalibrationChargeHiGainPix::fgAbsTimeLast     = 19.5;
    5757// --------------------------------------------------------------------------
    5858//
     
    6060//
    6161MHCalibrationChargeHiGainPix::MHCalibrationChargeHiGainPix(const char *name, const char *title)
    62     : fPix(NULL)
    6362{
    6463
    6564  fName  = name  ? name  : "MHCalibrationChargeHiGainPix";
    66   fTitle = title ? title : "Fill the FADC sums of the HiGainPix events and perform the fits";
     65  fTitle = title ? title : "Fill the FADC sums of the HiGainPix events and perform the fits Pixel ";
    6766 
    6867  SetChargeNbins();
     
    7372  SetAbsTimeFirst();
    7473  SetAbsTimeLast();
    75 
    7674}
    7775
     
    9795
    9896
     97void MHCalibrationChargeHiGainPix::ChangeHistId(Int_t id)
     98{
     99
     100  fPixId = id;
     101
     102  fHGausHist.SetName(Form("%s%d", fHGausHist.GetName(), id));
     103  fHGausHist.SetTitle(Form("%s%d", fHGausHist.GetTitle(), id));
     104
     105  fHAbsTime.SetName(Form("%s%d", fHAbsTime.GetName(), id));
     106  fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
     107
     108  fName  = Form("%s%d", fName.Data(), id);
     109  fTitle = Form("%s%d", fTitle.Data(), id);
     110}
     111
     112
     113void MHCalibrationChargeHiGainPix::Draw(const Option_t *opt)
     114{
     115
     116  TString option(opt);
     117  option.ToLower();
     118 
     119  Int_t win = 1;
     120
     121  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
     122
     123  pad->SetTicks();
     124  pad->SetBorderMode(0);
     125   
     126
     127  pad->Divide(1,win);
     128  pad->cd(1);
     129
     130  if (!IsEmpty())
     131    pad->SetLogy();
     132
     133  MHGausEvents::Draw(opt);
     134
     135}
    99136
    100137
    101138
    102 
    103 
    104 
    105 
    106 
    107 
    108 
    109 
    110 
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeHiGainPix.h

    r3257 r3264  
    77#endif
    88
    9 class MCalibrationChargePix;
     9class TH1F;
    1010class MHCalibrationChargeHiGainPix : public MHCalibrationChargePix
    1111{
    1212private:
    13 
    14   MCalibrationChargePix *fPix;            //! Storage container of the results
    1513
    1614  static const Int_t   fgChargeNbins;
     
    3836  void SetAbsTimeLast (const Axis_t last =fgAbsTimeLast)         { fAbsTimeLast  = last;    }
    3937
    40   void SetPix         (MCalibrationChargePix *pix )              { fPix          = pix;     }               
     38  void ChangeHistId(Int_t i);
     39
     40  // Draw
     41  void Draw(Option_t *opt="");
    4142
    4243  ClassDef(MHCalibrationChargeHiGainPix, 1)  // Histogram class for a Calibration Pixel with extracted Hi Gain
     
    4748
    4849
     50
     51
     52
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeLoGainPix.cc

    r3257 r3264  
    5252const Axis_t  MHCalibrationChargeLoGainPix::fgChargeFirst     = -0.5;
    5353const Axis_t  MHCalibrationChargeLoGainPix::fgChargeLast      = 199.5;
    54 const Int_t   MHCalibrationChargeLoGainPix::fgAbsTimeNbins    = 30;
     54const Int_t   MHCalibrationChargeLoGainPix::fgAbsTimeNbins    = 15;
    5555const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeFirst    = -0.5;
    56 const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeLast     = 29.5;
     56const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeLast     = 14.5;
    5757// --------------------------------------------------------------------------
    5858//
     
    6060//
    6161MHCalibrationChargeLoGainPix::MHCalibrationChargeLoGainPix(const char *name, const char *title)
    62     : fPix(NULL)
    6362{
    64 
    6563  fName  = name  ? name  : "MHCalibrationChargeLoGainPix";
    66   fTitle = title ? title : "Fill the FADC sums of the Low Gain events and perform the fits";
     64  fTitle = title ? title : "Fill the FADC sums of the Low Gain events and perform the fits Pixel ";
    6765 
    6866  SetChargeNbins();
     
    7371  SetAbsTimeFirst();
    7472  SetAbsTimeLast();
    75 
    7673}
    7774
     
    9895
    9996
     97void MHCalibrationChargeLoGainPix::ChangeHistId(Int_t id)
     98{
     99
     100  fPixId = id;
     101
     102  fHGausHist.SetName(Form("%s%d", fHGausHist.GetName(), id));
     103  fHGausHist.SetTitle(Form("%s%d", fHGausHist.GetTitle(), id));
     104
     105  fHAbsTime.SetName(Form("%s%d", fHAbsTime.GetName(), id));
     106  fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
     107
     108  fName  = Form("%s%d", fName.Data(), id);
     109  fTitle = Form("%s%d", fTitle.Data(), id);
     110}
    100111
    101112
     113
     114
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeLoGainPix.h

    r3257 r3264  
    77#endif
    88
    9 class MCalibrationChargePix;
    109class MHCalibrationChargeLoGainPix : public MHCalibrationChargePix
    1110{
    1211private:
    13 
    14   MCalibrationChargePix *fPix;            //! Storage container of the results
    1512
    1613  static const Int_t   fgChargeNbins;
     
    3835  void SetAbsTimeLast (const Axis_t last =fgAbsTimeLast)         { fAbsTimeLast  = last;    }
    3936
    40   void SetPix         (MCalibrationChargePix *pix )              { fPix          = pix;     }               
     37  void ChangeHistId(Int_t i);
    4138
    4239  ClassDef(MHCalibrationChargeLoGainPix, 1)  // Histogram class for a Calibration Pixel with extracted Low Gain
     
    4744
    4845
     46
     47
     48
     49
     50
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc

    r3256 r3264  
    2222!
    2323\* ======================================================================== */
    24 
    2524//////////////////////////////////////////////////////////////////////////////
    2625//
     
    5857const Axis_t  MHCalibrationChargePix::fgAbsTimeLast     = 14.5;
    5958
     59const Float_t MHCalibrationChargePix::fgPickupLimit     = 5.;
    6060const Int_t   MHCalibrationChargePix::fgPulserFrequency = 200;
    6161// --------------------------------------------------------------------------
     
    7777  SetAbsTimeFirst();
    7878  SetAbsTimeLast();
     79
     80  SetPickupLimit();
    7981
    8082  fHAbsTime.UseCurrentStyle();
     
    104106}
    105107
    106    
    107108
    108109void MHCalibrationChargePix::Clear(Option_t *o)
    109110{
    110111
    111   fPixId = -1;
     112  fPixId     = -1;
     113  fSaturated = 0;
     114  fPickup    = 0.;
    112115 
    113116  MHGausEvents::Clear();
     
    174177   
    175178  if (option.Contains("time"))
    176     win++;
     179  {
     180      option.ReplaceAll("events","");
     181      win++;
     182  }
    177183
    178184  pad->SetTicks();
     
    193199}
    194200
     201Bool_t MHCalibrationChargePix::RepeatFit(const Option_t *option)
     202{
     203
     204  //
     205  // Get new fitting ranges
     206  //
     207  Axis_t rmin = GetMean() - fPickupLimit * GetSigma();
     208  Axis_t rmax = GetMean() + fPickupLimit * GetSigma();
     209
     210  GetFGausFit()->SetRange(rmin,rmax);
     211
     212  GetHGausHist()->Fit(GetFGausFit(),option);
     213
     214  SetMean     ( GetFGausFit()->GetParameter(1) );
     215  SetMeanErr  ( GetFGausFit()->GetParameter(2) );
     216  SetSigma    ( GetFGausFit()->GetParError(1)  );
     217  SetSigmaErr ( GetFGausFit()->GetParError(2)  );
     218  SetProb     ( GetFGausFit()->GetProb()       );     
     219
     220  //
     221  // The fit result is accepted under condition:
     222  // 1) The results are not nan's
     223  // 2) The NDF is not smaller than fNDFLimit (5)
     224  // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
     225  //
     226  if (   TMath::IsNaN ( GetMean()     )
     227      || TMath::IsNaN ( GetMeanErr()  )
     228      || TMath::IsNaN ( GetProb()     )   
     229      || TMath::IsNaN ( GetSigma()    )
     230      || TMath::IsNaN ( GetSigmaErr() )
     231      || GetFGausFit()->GetNDF() < fNDFLimit
     232      || GetProb() < fProbLimit )
     233    return kFALSE;
     234 
     235  SetGausFitOK(kTRUE);
     236  return kTRUE;
     237
     238}
     239
    195240void MHCalibrationChargePix::BypassFit()
    196241{
     
    200245  // with the fit, we take the histogram values
    201246  //
    202   SetMean(fHGausHist.GetMean());
    203   SetMeanErr(fHGausHist.GetRMS()/fHGausHist.GetEntries());
    204   SetSigma(fHGausHist.GetRMS());
    205   SetSigmaErr(fHGausHist.GetRMS()/fHGausHist.GetEntries()/2.);
    206 }
    207 
     247  SetMean     ( fHGausHist.GetMean() );
     248  SetMeanErr  ( fHGausHist.GetRMS() / fHGausHist.GetEntries() );
     249  SetSigma    ( fHGausHist.GetRMS() );
     250  SetSigmaErr ( fHGausHist.GetRMS() / fHGausHist.GetEntries() / 2. );
     251}
     252
     253void MHCalibrationChargePix::CountPickup()
     254{
     255    fPickup  = GetHGausHist()->Integral(GetHGausHist()->GetXaxis()->FindBin(GetMean()+fPickupLimit*GetSigma()),
     256                                        GetHGausHist()->GetXaxis()->GetLast(),
     257                                        "width");
     258}
     259
     260
     261
     262
     263
     264
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h

    r3260 r3264  
    2020  static const Axis_t  fgAbsTimeLast;
    2121
     22  static const Float_t fgPickupLimit;
     23
    2224protected:
    2325
     
    3638  Axis_t   fAbsTimeLast;
    3739
    38   Bool_t   fSaturated;
     40  Float_t  fPickupLimit;      // The limit in number of sigmas from the fitted mean above which events are considered as pickup
     41
     42  Int_t    fSaturated;
     43  Float_t  fPickup;
    3944
    4045public:
     
    4651  virtual void Reset(); 
    4752  virtual void Init();
     53  virtual void ChangeHistId(Int_t i);
    4854 
    4955  // Setters
     
    5662  virtual void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)     { fAbsTimeLast  = last; }
    5763
     64  virtual void SetPickupLimit( const Float_t lim =fgPickupLimit)     { fPickupLimit  = lim; }
     65
    5866  void SetPulserFrequency(Float_t f=fgPulserFrequency);
    5967
    60   void    SetSaturated( const Bool_t b) { fSaturated = b; }
     68  void SetSaturated      (const Int_t i) { fSaturated += i; }
    6169
    6270  // Getters
     
    6977  const Float_t  GetAbsTimeRms()      const;
    7078
    71   const Bool_t   IsSaturated()        const { return fSaturated;   }
     79  const Int_t    GetSaturated()       const { return fSaturated;   }
     80  const Float_t  GetPickup()          const { return fPickup;      }
    7281
    73   void ChangeHistId(Int_t i);
    74  
    7582  // Fill histos
    7683  Bool_t FillAbsTime(const Float_t t);
    7784
    7885  // Fits
    79   void BypassFit();
     86  void   BypassFit();
     87  Bool_t RepeatFit(const Option_t *option="RQ0");
    8088 
    8189  // Draws
    8290  virtual void Draw(Option_t *opt="");
    83  
     91
     92  // Miscelleaneous
     93  void CountPickup();
     94
    8495  ClassDef(MHCalibrationChargePix, 1)     // Base class for charge calibrated pixel
    8596};
  • trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc

    r3198 r3264  
    9191using namespace std;
    9292
    93 const Float_t  MHGausEvents::fgProbLimit            = 0.01;
     93const Float_t  MHGausEvents::fgProbLimit            = 0.005;
    9494const Int_t    MHGausEvents::fgNDFLimit             = 2;
    95 const Int_t    MHGausEvents::fgPowerProbabilityBins = 25;
    96 const Int_t    MHGausEvents::fgBinsAfterStripping   = 25;
     95const Int_t    MHGausEvents::fgPowerProbabilityBins = 20;
     96const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
    9797// --------------------------------------------------------------------------
    9898//
     
    423423  const Stat_t   entries     = fHGausHist.Integral("width");
    424424  const Double_t mu_guess    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
    425   const Double_t sigma_guess = (rmax-rmin)/2.;
     425  const Double_t sigma_guess = fHGausHist.GetRMS();
    426426  const Double_t area_guess  = entries/TMath::Sqrt(TMath::TwoPi())/sigma_guess;
    427427
     
    436436  fFGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    437437  fFGausFit->SetParNames("Area","#mu","#sigma");
    438   fFGausFit->SetParLimits(0,0.,entries);
     438  fFGausFit->SetParLimits(0,0.,area_guess*1.5);
    439439  fFGausFit->SetParLimits(1,rmin,rmax);
    440440  fFGausFit->SetParLimits(2,0.,rmax-rmin);
     
    442442
    443443  fHGausHist.Fit(fFGausFit,option);
    444  
     444
     445
    445446  fMean     = fFGausFit->GetParameter(1);
    446447  fSigma    = fFGausFit->GetParameter(2);
    447448  fMeanErr  = fFGausFit->GetParError(1);
    448449  fSigmaErr = fFGausFit->GetParError(2);
    449 
    450450  fProb     = fFGausFit->GetProb();
    451451  //
     
    455455  // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
    456456  //
    457   if (    TMath::IsNaN(fMean)
     457  if (   TMath::IsNaN(fMean)
    458458      || TMath::IsNaN(fMeanErr)
    459459      || TMath::IsNaN(fProb)   
     
    578578
    579579  if (!IsEmpty())
    580     pad->SetLogy();
     580    gPad->SetLogy();
    581581
    582582  fHGausHist.Draw(opt);
     
    587587      fFGausFit->Draw("same");
    588588    }
    589  
    590589  switch (win)
    591590    {
  • trunk/MagicSoft/Mars/mcalib/MHGausEvents.h

    r3263 r3264  
    2525  const static Int_t    fgBinsAfterStripping;   // Default number of bins for the Gauss Histogram after stripping off the zeros at both end
    2626
    27   Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK
    28   Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
    2927  Int_t    fPowerProbabilityBins;      // number of bins for the projected power spectrum
    3028  Int_t    fBinsAfterStripping;        // number of bins for the Gauss Histogram after stripping off the zeros at both end
     
    5957  TArrayF fEvents;                     // Array which holds the entries of GausHist
    6058
     59  Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK
     60  Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
     61
    6162  // Setters
    62   void  SetPowerProbabilityBins(const Int_t nbins=fgPowerProbabilityBins) { fPowerProbabilityBins = nbins;  }
    63   void  SetBinsAfterStripping(const Int_t nbins=fgBinsAfterStripping)     { fBinsAfterStripping = nbins;  }
     63  void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins = nbins;  }
     64  void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping  = nbins;  }
    6465
    6566  void DrawEvents();                                  // Draw a graph of the array fEvents
     
    7778  void  SetEventFrequency(const Float_t f=0)  {  fEventFrequency = f; }
    7879
    79   void  SetMean(    const Double_t d )   { fMean     = d;   }
    80   void  SetMeanErr( const Double_t d )   { fMeanErr  = d;   }
    81   void  SetSigma(    const Double_t d )   { fSigma    = d;   }
     80  void  SetMean    ( const Double_t d )   { fMean     = d;   }
     81  void  SetMeanErr ( const Double_t d )   { fMeanErr  = d;   }
     82  void  SetSigma   ( const Double_t d )   { fSigma    = d;   }
    8283  void  SetSigmaErr( const Double_t d )   { fSigmaErr = d;   }
     84  void  SetProb    ( const Double_t d )   { fProb     = d;   }
    8385 
    8486  void  SetProbLimit( const Float_t lim=fgProbLimit ) {  fProbLimit = lim; }
Note: See TracChangeset for help on using the changeset viewer.