Ignore:
Timestamp:
09/14/04 00:11:10 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhcalib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc

    r4964 r4986  
    4040#include "MLogManip.h"
    4141
    42 #include "MCalibrationChargeBlindPix.h"
    43 #include "MCalibrationChargeBlindCam.h"
     42#include "MRawEvtData.h"
     43#include "MRawEvtPixelIter.h"
    4444
    4545#include "MExtractedSignalBlindPixel.h"
    4646
     47#include "MCalibrationBlindPix.h"
     48#include "MCalibrationIntensityBlindCam.h"
     49
    4750#include "MParList.h"
    4851
     
    5255
    5356using namespace std;
    54 
     57const Int_t     MHCalibrationChargeBlindCam::fgNbins    =  128;
     58const Axis_t    MHCalibrationChargeBlindCam::fgFirst    = -0.5;
     59const Axis_t    MHCalibrationChargeBlindCam::fgLast     =  511.5;
     60const Axis_t    MHCalibrationChargeBlindCam::fgSPheCut  =  20.;
     61const TString   MHCalibrationChargeBlindCam::gsHistName   = "ChargeBlind";
     62const TString   MHCalibrationChargeBlindCam::gsHistTitle  = "Signals Blind ";
     63const TString   MHCalibrationChargeBlindCam::gsHistXTitle = "Signal [FADC counts]";
     64const TString   MHCalibrationChargeBlindCam::gsHistYTitle = "Nr. events";
    5565// --------------------------------------------------------------------------
    5666//
     
    6070// - all pointers to NULL
    6171//
    62 // Initializes and sets owner of:
    63 // - fBlindPixelsArray
     72// - fFitFunc to kEPoisson4
     73// - fNbins   to fgNbins
     74// - fFirst   to fgFirst
     75// - fLast    to fgLast
     76// - fSPheCut to fgSPheCut
    6477//
    65 // Sets fFitFunc to kEPoisson4
     78// - fHistName   to gsHistName 
     79// - fHistTitle  to gsHistTitle
     80// - fHistXTitle to gsHistXTitle
     81// - fHistYTitle to gsHistYTitle
     82//
     83// - SetAverageing  (kFALSE);
     84// - SetLoGain      (kFALSE);
     85// - SetOscillations(kFALSE);
     86// - SetSizeCheck   (kFALSE);
    6687//
    6788MHCalibrationChargeBlindCam::MHCalibrationChargeBlindCam(const char *name, const char *title)
    68     :  fCam(NULL), fRunHeader(NULL)
     89    : fRawEvt(NULL)
    6990{
    7091
     
    7293  fTitle = title ? title : "Class to fille the blind pixel histograms";
    7394
    74   fBlindPixelsArray = new TObjArray;
    75   fBlindPixelsArray->SetOwner();
    76 
    77   fFitFunc = MHCalibrationChargeBlindPix::kEPoisson4;
    78 
    79 }
    80 
    81 // --------------------------------------------------------------------------
    82 //
    83 // Deletes the TClonesArray of:
    84 // - fBlindPixelsArray
    85 //
    86 MHCalibrationChargeBlindCam::~MHCalibrationChargeBlindCam()
    87 {
    88   delete fBlindPixelsArray;
    89 }
    90 
    91 // --------------------------------------------------------------------------
    92 //
    93 // Get i-th High Gain pixel (pixel number)
    94 //
    95 MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i)
    96 {
    97   return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
    98 }
    99 
    100 // --------------------------------------------------------------------------
    101 //
    102 // Get i-th High Gain pixel (pixel number)
    103 //
    104 const MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i) const
    105 {
    106   return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
    107 }
     95  SetFitFunc();
     96  SetSPheCut();
     97
     98  SetNbins(fgNbins);
     99  SetFirst(fgFirst);
     100  SetLast (fgLast );
     101
     102  SetHistName  (gsHistName  .Data());
     103  SetHistTitle (gsHistTitle .Data());
     104  SetHistXTitle(gsHistXTitle.Data());
     105  SetHistYTitle(gsHistYTitle.Data());
     106
     107  SetAverageing  (kFALSE);
     108  SetLoGain      (kFALSE);
     109  SetOscillations(kFALSE);
     110  SetSizeCheck   (kFALSE);
     111}
     112
     113// --------------------------------------------------------------------------
     114//
     115// Gets the pointers to:
     116// - MRawEvtData
     117//
     118Bool_t MHCalibrationChargeBlindCam::SetupHists(const MParList *pList)
     119{
     120
     121  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
     122  if (!fRawEvt)
     123  {
     124      *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
     125      return kFALSE;
     126  }
     127
     128  return kTRUE;
     129}
     130
     131// --------------------------------------------------------------------------
     132//
     133// Gets or creates the pointers to:
     134// - MExtractedSignalBlindPixel
     135// - MCalibrationChargeCam or MCalibrationIntensityBlindCam
     136//
     137// Initializes the number of used FADC slices from MExtractedSignalCam
     138// into MCalibrationChargeCam and test for changes in that variable
     139//
     140// Retrieve:
     141// - fRunHeader->GetNumSamplesHiGain();
     142//
     143// Initializes the High Gain Arrays:
     144//
     145// - Expand fHiGainArrays to nblindpixels
     146//
     147// - For every entry in the expanded arrays:
     148//   * Initialize an MHCalibrationPix
     149//   * Set Binning from  fNbins, fFirst and fLast
     150//   * Set Histgram names and titles from fHistName and fHistTitle
     151//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
     152//   * Call InitHists
     153//
     154Bool_t MHCalibrationChargeBlindCam::ReInitHists(MParList *pList)
     155{
     156
     157  MExtractedSignalBlindPixel *signal =
     158    (MExtractedSignalBlindPixel*)pList->FindObject(AddSerialNumber("MExtractedSignalBlindPixel"));
     159  if (!signal)
     160  {
     161      *fLog << err << "MExtractedSignalBlindPixel not found... abort." << endl;
     162      return kFALSE;
     163  }
     164
     165  fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityBlindCam"));
     166  if (fIntensCam)
     167    *fLog << inf << "Found MCalibrationIntensityBlindCam ... " << endl;
     168  else
     169    {
     170      fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationBlindCam"));
     171      if (!fCam)
     172        {
     173          fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationBlindCam"));
     174          if (!fCam)
     175            {
     176              *fLog << err << "Cannot find nor create MCalibrationBlindCam ... abort." << endl;
     177              return kFALSE;
     178            }
     179        }
     180    }
     181
     182  const Int_t nblindpixels = signal->GetNumBlindPixels();
     183  const Int_t samples      = signal->GetNumFADCSamples();
     184  const Int_t integ        = signal->IsExtractionType( MExtractBlindPixel::kIntegral );
     185 
     186  TH1F *h;
     187
     188  if (fHiGainArray->GetEntries()==0)
     189  {
     190      fHiGainArray->Expand(nblindpixels);
     191      for (Int_t i=0; i<nblindpixels; i++)
     192      {
     193        (*fHiGainArray)[i] = new MHCalibrationChargeBlindPix(Form("%s%s",fHistName.Data(),"Pix"),
     194                                                  Form("%s%s",fHistTitle.Data()," Pixel "));
     195
     196        MHCalibrationChargeBlindPix &pix = (MHCalibrationChargeBlindPix&)(*this)[i];
     197
     198        pix.SetNbins        ( fNbins );
     199        pix.SetFirst        ( fFirst );
     200        pix.SetLast         ( integ ? ((fLast+0.5)*samples)-0.5 : fLast    );
     201        pix.SetSinglePheCut ( integ ? fSPheCut * samples        : fSPheCut );
     202        pix.SetFitFunc      ( integ ? kEPoisson5                : fFitFunc );
     203
     204        h = pix.GetHGausHist();
     205
     206        h->SetName (Form("%s%s%s","H",fHistName.Data(),"Pix"));
     207        h->SetTitle(Form("%s%s",fHistTitle.Data()," Pixel ")); 
     208        h->SetXTitle(fHistXTitle.Data());
     209        h->SetYTitle(fHistYTitle.Data());
     210
     211        pix.ChangeHistId(i);
     212        pix.InitBins();
     213
     214        h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
     215      }
     216  }
     217  return kTRUE;
     218}
     219
     220// --------------------------------------------------------------------------
     221//
     222// Retrieves from MExtractedSignalBlindPixel:
     223// - number of blind pixels
     224//
     225// Retrieves from MExtractedSignalBlindPixel:
     226// - number of FADC samples
     227// - extracted signal
     228// - blind Pixel ID
     229//
     230// Resizes (if necessary):
     231// - fASinglePheFADCSlices to sum of HiGain and LoGain samples
     232// - fAPedestalFADCSlices to sum of HiGain and LoGain samples
     233//
     234// Fills the following histograms:
     235// - MHGausEvents::FillHistAndArray(signal)
     236//
     237// Creates MRawEvtPixelIter, jumps to blind pixel ID,
     238// fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
     239// with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
     240//
     241Bool_t MHCalibrationChargeBlindCam::FillHists(const MParContainer *par, const Stat_t w)
     242{
     243
     244  MExtractedSignalBlindPixel *signal = (MExtractedSignalBlindPixel*)par;
     245  if (!signal)
     246    {
     247      *fLog << err << "No argument in MExtractedSignalBlindCam::Fill... abort." << endl;
     248      return kFALSE;
     249    }
     250 
     251  const Int_t nblindpixels  = signal->GetNumBlindPixels();
     252 
     253  if (GetSize() != nblindpixels)
     254    {
     255      gLog << err << "ERROR - Size mismatch... abort." << endl;
     256      return kFALSE;
     257    }
     258
     259  Float_t slices = (Float_t)signal->GetNumFADCSamples();
     260 
     261  if (slices == 0.)
     262    {
     263      *fLog << err << dbginf
     264            << "Number of used signal slices in MExtractedSignalBlindPix "
     265            << "is zero  ... abort."
     266            << endl;
     267      return kFALSE;
     268    }
     269 
     270  for (Int_t i=0; i<nblindpixels; i++)
     271    {
     272
     273      //
     274      // Signal extraction and histogram filling
     275      // If filter has been applied, sig has been set to -1.
     276      //
     277      const Float_t sig = signal->GetExtractedSignal(i);
     278     
     279      if (sig < -0.5)
     280        continue;
     281
     282      MHCalibrationChargeBlindPix &hist = (MHCalibrationChargeBlindPix&)(*this)[i];
     283
     284      hist.FillHist(sig);
     285      //
     286      // In order to study the single-phe posistion, we extract the slices
     287      //
     288      const Int_t blindpixIdx = signal->GetBlindPixelIdx(i);
     289     
     290      MRawEvtPixelIter pixel(fRawEvt);
     291      pixel.Jump(blindpixIdx);
     292     
     293      if (sig > fSPheCut)
     294        hist.FillSinglePheFADCSlices(pixel);
     295      else
     296        hist.FillPedestalFADCSlices(pixel);
     297
     298    }
     299
     300  return kTRUE;
     301}
     302
     303// --------------------------------------------------------------------------
     304//
     305// For all TObjArray's (including the averaged ones), the following steps are performed:
     306//
     307// 1) Returns if the pixel is excluded.
     308// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
     309//    or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
     310// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
     311//    MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
     312//    otherwise the Hi-Gain ones.
     313// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
     314//    with the flags:
     315//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
     316//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
     317//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
     318//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
     319//
     320Bool_t MHCalibrationChargeBlindCam::FinalizeHists()
     321{
     322
     323  *fLog << endl;
     324
     325  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
     326    {
     327     
     328      MHCalibrationChargeBlindPix &hist = (MHCalibrationChargeBlindPix&)(*this)[i];
     329     
     330      TH1F *h = hist.GetHGausHist();
     331
     332      Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
     333      if (overflow > 0.1)
     334        {
     335          *fLog << warn << GetDescriptor()
     336                << ": Histogram Overflow occurred " << overflow
     337                << " times in blind pixel: " << i << endl;
     338        }
     339
     340      overflow = h->GetBinContent(0);
     341      if (overflow > 0.1)
     342        {
     343          *fLog << warn << GetDescriptor()
     344                << ": Histogram Underflow occurred " << overflow
     345                << " times in blind pixel: " << i << endl;
     346        }
     347
     348      MCalibrationBlindPix  &pix    = fIntensCam
     349        ? (MCalibrationBlindPix&)(*fIntensCam)[i]
     350        : (MCalibrationBlindPix&)(*fCam)[i];
     351
     352      FitBlindPixel(hist,pix);
     353    }
     354
     355  return kTRUE;
     356}
     357
     358
     359// --------------------------------------------------------------------------
     360//
     361// Returns kFALSE, if empty
     362//
     363// - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
     364// - Retrieves the pedestals from MExtractedSignalBlindPixel
     365// - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
     366// - Executes FitPedestal()
     367// - Executes FitSinglePhe()
     368// - Retrieves fit results and stores them in MCalibrationBlindPix
     369//
     370void MHCalibrationChargeBlindCam::FitBlindPixel(MHCalibrationChargeBlindPix &hist, MCalibrationBlindPix &pix)
     371{
     372
     373  if (hist.IsEmpty())
     374  {
     375    *fLog << err << GetDescriptor() << " ID: " << hist.GetPixId()
     376          << " My histogram has not been filled !! " << endl;
     377      return;
     378  }
     379
     380  hist.FinalizeSinglePheSpectrum();
     381 
     382  hist.FitPedestal();
     383
     384  pix.SetValid(kTRUE);
     385
     386  if (hist.FitSinglePhe())
     387    pix.SetSinglePheFitOK();
     388  else
     389    pix.SetValid(hist.IsPedestalFitOK());
     390
     391  pix.SetLambda      ( hist.GetLambda   () );
     392  pix.SetLambdaVar   ( hist.GetLambdaErr()*hist.GetLambdaErr() );
     393  pix.SetMu0         ( hist.GetMu0      () );
     394  pix.SetMu0Err      ( hist.GetMu0Err   () );
     395  pix.SetMu1         ( hist.GetMu1      () );
     396  pix.SetMu1Err      ( hist.GetMu1Err   () );
     397  pix.SetSigma0      ( hist.GetSigma0   () );
     398  pix.SetSigma0Err   ( hist.GetSigma0Err() );
     399  pix.SetSigma1      ( hist.GetSigma1   () );
     400  pix.SetSigma1Err   ( hist.GetSigma1Err() );
     401  pix.SetProb        ( hist.GetProb     () );
     402
     403  pix.SetLambdaCheck    ( hist.GetLambdaCheck()    );
     404  pix.SetLambdaCheckErr ( hist.GetLambdaCheckErr() );
     405}
     406
    108407
    109408// --------------------------------------------------------------------------
     
    118417{
    119418
    120   const Int_t nhi   = fBlindPixelsArray->GetEntries();
    121  
    122419  //
    123420  // FIXME, this might be done faster and more elegant, by direct copy.
     
    125422  MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
    126423
    127   cam->fBlindPixelsArray->Expand(nhi);
     424  //
     425  // Copy the data members
     426  //
     427  cam->fRunNumbers             = fRunNumbers;
     428  cam->fPulserFrequency        = fPulserFrequency;
     429  cam->fFlags                  = fFlags;
     430  cam->fNbins                  = fNbins;
     431  cam->fFirst                  = fFirst;
     432  cam->fLast                   = fLast;
     433  cam->fFitFunc                = fFitFunc;
     434
     435  const Int_t nhi = fHiGainArray->GetEntries();
     436 
     437  cam->fHiGainArray->Expand(nhi);
    128438
    129439  for (int i=0; i<nhi; i++)
    130     (*cam->fBlindPixelsArray)[i] = (*fBlindPixelsArray)[i]->Clone();
     440    (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
    131441
    132442  return cam;
    133443}
    134 
    135 // --------------------------------------------------------------------------
    136 //
    137 // Gets the pointers to:
    138 // - MRunHeader
    139 // - MExtractedSignalBlindPix
    140 //
    141 // Calls Delete-Function of:
    142 // - MHCalibrationChargeBlindCam::fBlindPixelsArray
    143 //
    144 Bool_t MHCalibrationChargeBlindCam::SetupFill(const MParList *pList)
    145 {
    146  
    147   fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
    148   if (!fRunHeader)
    149   {
    150     *fLog << warn << GetDescriptor()
    151           << ": MRawRunHeader not found... will not store run numbers." << endl;
    152     return kFALSE;
    153   }
    154 
    155   fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
    156   if (!fSignal)
    157     {
    158       *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
    159       return kFALSE;
    160     }
    161 
    162   return kTRUE;
    163 }
    164 
    165 
    166 // --------------------------------------------------------------------------
    167 //
    168 // Initializes, if empty to MExtractedSignalCam::GetSize() for:
    169 // - MHCalibrationChargeBlindCam::fBlindPixelsArray
    170 //
    171 // Calls InitializeHists() for every entry in:
    172 // - MHCalibrationChargeBlindCam::fBlindPixelsArray
    173 //
    174 // Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
    175 //
    176 Bool_t MHCalibrationChargeBlindCam::ReInit(MParList *pList)
    177 {
    178 
    179   const UInt_t nblindpixels  = fSignal->GetNumBlindPixels();
    180 
    181   Int_t runnr = 0;
    182 
    183   if (fRunHeader)
    184     runnr = fRunHeader->GetRunNumber();
    185 
    186   fCam = (MCalibrationChargeBlindCam*)pList->FindCreateObj("MCalibrationChargeBlindCam");
    187   if (!fCam)
    188     {
    189       *fLog << err << "Cannot find nor create MCalibrationChargeBlindCam ... abort." << endl;
    190       return kFALSE;
    191     }
    192 
    193   if (fCam->GetNumBlindPixels() != nblindpixels)
    194     {
    195         *fLog << err;
    196         *fLog << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl;
    197         *fLog << "  Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels() << endl;
    198         *fLog << "  Size of MExtractedSignalBlindPixel: " << nblindpixels << endl;
    199       return kFALSE;
    200     }
    201  
    202 
    203   const Int_t samples = fSignal->GetNumFADCSamples();
    204   const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
    205 
    206   if (fBlindPixelsArray->GetEntries()==0)
    207   {
    208 
    209       fBlindPixelsArray->Expand(nblindpixels);
    210 
    211       for (UInt_t i=0; i<nblindpixels; i++)
    212         {
    213           (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
    214           (*this)[i].ChangeHistId(i);
    215           if (integ)
    216             {
    217               (*this)[i].SetLast( samples * integ *
    218                                   ((*this)[i].GetLast()+0.5) - 0.5 );
    219               (*this)[i].SetSinglePheCut( samples * integ *
    220                                           (*this)[i].GetSinglePheCut() );
    221             }
    222           (*this)[i].InitBins();
    223           TH1F *h = (*this)[i].GetHGausHist();
    224           h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
    225           (*this)[i].ChangeFitFunc(fFitFunc);
    226           (*this)[i].SetupFill(pList);
    227           (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
    228       }
    229   }
    230 
    231   for (UInt_t i=0; i<nblindpixels; i++)
    232     {
    233       TH1F *h = (*this)[i].GetHGausHist();
    234       h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
    235     }
    236 
    237   return kTRUE;
    238 }
    239 
    240 
    241 //--------------------------------------------------------------------------------
    242 //
    243 // Retrieves from MExtractedSignalBlindPixel:
    244 // - number of blind pixels
    245 //
    246 // For all TObjArray's, the following steps are performed:
    247 //
    248 // 1) Test size and return kFALSE if not matching
    249 // 2)
    250 //
    251 Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
    252 {
    253 
    254   const Int_t nblindpixels  = fSignal->GetNumBlindPixels();
    255  
    256   if (GetSize() != nblindpixels)
    257     {
    258       gLog << err << "ERROR - Size mismatch... abort." << endl;
    259       return kFALSE;
    260     }
    261  
    262   for (Int_t i=0; i<nblindpixels; i++)
    263     (*this)[i].Fill(par,w);
    264 
    265   return kTRUE;
    266 }
    267 
    268 // --------------------------------------------------------------------------
    269 //
    270 // Calls the Finalize() function of the blind pixels
    271 //
    272 Bool_t MHCalibrationChargeBlindCam::Finalize()
    273 {
    274 
    275   for (Int_t i=0; i<GetSize(); i++)
    276     if (!(*this)[i].Finalize())
    277       return kFALSE;
    278 
    279   return kTRUE;
    280 }
    281 
    282 
    283444
    284445// -----------------------------------------------------------------------------
     
    293454{
    294455
    295   const Int_t size = fBlindPixelsArray->GetEntries();
     456  const Int_t size = fHiGainArray->GetEntries();
    296457
    297458  if (size == 0)
     
    330491
    331492}
     493
     494Int_t MHCalibrationChargeBlindCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     495{
     496
     497  Bool_t rc = kFALSE;
     498
     499  if (MHCalibrationCam::ReadEnv(env,prefix,print))
     500    rc = kTRUE;
     501 
     502  if (IsEnvDefined(env, prefix, "SPheCut", print))
     503    {
     504      SetSPheCut(GetEnvValue(env, prefix, "SPheCut", fSPheCut));
     505      rc = kTRUE;
     506    }
     507 
     508  // FIXME: GetEnvValue does not work with enums yet
     509  /*
     510  if (IsEnvDefined(env, prefix, "FitFunc", print))
     511    {
     512      SetFitFunc((Int_t)GetEnvValue(env, prefix, "FitFunc", fFitFunc));
     513      rc = kTRUE;
     514  }
     515  */
     516  return rc;
     517}
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.h

    r4970 r4986  
    22#define MARS_MHCalibrationChargeBlindCam
    33
    4 #ifndef MARS_MH
    5 #include "MH.h"
    6 #endif
    7 #ifndef MARS_MHCalibrationChargeBlindPix
    8 #include "MHCalibrationChargeBlindPix.h"
     4#ifndef MARS_MHCalibrationCam
     5#include "MHCalibrationCam.h"
    96#endif
    107
    11 class TObjArray;
    12 class MRawRunHeader;
    13 class MExtractedSignalBlindPixel;
    14 class MCalibrationChargeBlindCam;
     8class MRawEvtData;
     9class MCalibrationBlindPix;
    1510class MHCalibrationChargeBlindPix;
    16 class MHCalibrationChargeBlindCam : public MH
     11class MHCalibrationChargeBlindCam : public MHCalibrationCam
    1712{
    1813private:
    1914
    20   MExtractedSignalBlindPixel *fSignal;     //!  Extracted Signal class
    21   MCalibrationChargeBlindCam *fCam;        //!  Calibration Cam with the results
    22   MRawRunHeader              *fRunHeader;  //!  Run Header
     15  static const Int_t   fgNbins;        //! Default for fNBins new style blind pixel (now set to:  128   )
     16  static const Axis_t  fgFirst;        //! Default for fFirst new style blind pixel (now set to: - 0.5 )
     17  static const Axis_t  fgLast;         //! Default for fLast  new style blind pixel (now set to: 511.5 )
     18
     19  static const Axis_t  fgSPheCut;      //! Default for fSinglePheCut new style blind pixel (now set to: 20)
    2320 
    24   TObjArray *fBlindPixelsArray;            // Array of calibration pixels, one per pixel
     21  static const TString gsHistName;     //! Default Histogram names
     22  static const TString gsHistTitle;    //! Default Histogram titles
     23  static const TString gsHistXTitle;   //! Default Histogram x-axis titles
     24  static const TString gsHistYTitle;   //! Default Histogram y-axis titles
     25 
     26  Axis_t fSPheCut;                    // Signal value upon which event considered as single-phe
     27 
     28  MRawEvtData *fRawEvt;                 //!  Raw event data
    2529
    26   MHCalibrationChargeBlindPix::FitFunc_t fFitFunc;
     30public:
     31
     32  enum FitFunc_t { kEPoisson4, kEPoisson5,
     33                   kEPoisson6, kEPoisson7,
     34                   kEPolya, kEMichele }; // Possible fit functions types (see MHCalibrationChargeBlindPix)
     35 
     36  static const FitFunc_t fgFitFunc = kEPoisson4;    //! Default for fFitFunc
     37
     38private:
     39
     40  FitFunc_t fFitFunc;                 // The actual fit function type
     41 
     42  Bool_t SetupHists   (const MParList *pList );
     43  Bool_t ReInitHists  (      MParList *pList );
     44  Bool_t FillHists    (const MParContainer *par, const Stat_t w=1 );
     45  Bool_t FinalizeHists();
     46
     47  void   FitBlindPixel( MHCalibrationChargeBlindPix &hist, MCalibrationBlindPix &pix);
     48
     49  Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print); 
    2750 
    2851public:
    2952
    3053  MHCalibrationChargeBlindCam(const char *name=NULL, const char *title=NULL);
    31   ~MHCalibrationChargeBlindCam();
    32 
    33   Bool_t SetupFill( const MParList *pList);
    34   Bool_t ReInit   (       MParList *pList);
    35   Bool_t Fill     ( const MParContainer *par, const Stat_t w=1);
    36   Bool_t Finalize ( );
    3754
    3855  // Clone
     
    4057 
    4158  // Draw
    42   void   Draw(Option_t *opt="");
    43  
    44   const Int_t GetSize() const  { return fBlindPixelsArray->GetSize(); }
    45  
    46         MHCalibrationChargeBlindPix &operator[] (UInt_t i);
    47   const MHCalibrationChargeBlindPix &operator[] (UInt_t i)  const;
    48 
    49   void   SetFitFunc(const MHCalibrationChargeBlindPix::FitFunc_t func)  { fFitFunc = func;  } 
     59  void  Draw(Option_t *opt="");
     60  void  SetFitFunc( const FitFunc_t func=fgFitFunc)  { fFitFunc = func;  }
     61  void  SetSPheCut( const Axis_t a=fgSPheCut )  { fSPheCut = a;  }   
    5062 
    5163  ClassDef(MHCalibrationChargeBlindCam, 1)      // Histogram class for Blind Pixel Calibration
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.cc

    r4963 r4986  
    3232//  Performs the Single Photo-electron fit to extract the Poisson mean and its errors.
    3333//
    34 //  Different fits can be chosen with the function ChangeFitFunc().
     34//  Different fits can be chosen with the function SetFitFunc().
    3535//
    3636//  The fit result is accepted under the condition that:
     
    6969//////////////////////////////////////////////////////////////////////////////
    7070#include "MHCalibrationChargeBlindPix.h"
    71 #include "MExtractBlindPixel.h"
     71#include "MHCalibrationChargeBlindCam.h"
    7272
    7373#include <TStyle.h>
     
    8888#include "MParList.h"
    8989
    90 #include "MRawEvtData.h"
    9190#include "MRawEvtPixelIter.h"
    92 
    93 #include "MExtractedSignalBlindPixel.h"
    94 #include "MCalibrationChargeBlindPix.h"
    9591
    9692ClassImp(MHCalibrationChargeBlindPix);
     
    10197const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr   = 0.002;
    10298const Float_t  MHCalibrationChargeBlindPix::gkSignalInitializer  = -9999.;
    103 
    104 const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 128;
    105 const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -0.5;
    106 const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 511.5;
    107 const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       =  20.;
    10899const Float_t  MHCalibrationChargeBlindPix::fgNumSinglePheLimit  =  50.;
    109100// --------------------------------------------------------------------------
     
    112103//
    113104// Sets:
    114 // - the default number for fNbins        (fgChargeNbins)
    115 // - the default number for fFirst        (fgChargeFirst)
    116 // - the default number for fLast         (fgChargeLast)
    117 // - the default number for fSinglePheCut (fgSingePheCut)
    118105// - the default number for fNumSinglePheLimit (fgNumSinglePheLimit)
    119106// - the default number of bins after stripping (30)
    120 //
    121 // - the default name of the  fHGausHist ("HCalibrationChargeBlindPix")
    122 // - the default title of the fHGausHist ("Distribution of Summed FADC slices Blind Pixel ")
    123 // - the default x-axis title for fHGausHist ("Sum FADC Slices")
    124 // - the default y-axis title for fHGausHist ("Nr. of events")
    125107//
    126108// Initializes:
     
    128110// - fASinglePheFADCSlices(0);
    129111// - fAPedestalFADCSlices(0);
    130 // - fPixId to 0
    131112//
    132113// Calls:
     
    134115//
    135116MHCalibrationChargeBlindPix::MHCalibrationChargeBlindPix(const char *name, const char *title)
    136     :  fBlindPix(NULL), fSignal(NULL), fRawEvt(NULL),
    137        fSinglePheFit(NULL),
     117    :  fSinglePheFit(NULL),
    138118       fFitLegend(NULL),
    139119       fHSinglePheFADCSlices(NULL), fHPedestalFADCSlices(NULL)
     
    143123    fTitle = title ? title : "Statistics of the FADC sums of Blind Pixel calibration events";
    144124
    145     SetNbins( fgChargeNbins );
    146     SetFirst( fgChargeFirst );
    147     SetLast ( fgChargeLast  );
    148    
    149125    fASinglePheFADCSlices.ResizeTo(1);
    150126    fAPedestalFADCSlices.ResizeTo(1);
    151127
    152     SetSinglePheCut();
    153128    SetNumSinglePheLimit();
    154129    SetProbLimit(0.001);
    155130    SetBinsAfterStripping(0);
    156 
    157     fHGausHist.SetName("HCalibrationChargeBlindPix");
    158     fHGausHist.SetTitle("Distribution of Summed FADC slices Blind Pixel"); 
    159     fHGausHist.SetXTitle("Signal Amplitude");
    160     fHGausHist.SetYTitle("Nr. of events");
    161 
    162     fPixId     = 0;
    163131
    164132    Clear();
     
    224192  fLambdaCheckErr = gkSignalInitializer;
    225193 
    226   //  fFitFunc = kEMichele;
    227   fFitFunc = kEPoisson5;
     194  fFitFunc = MHCalibrationChargeBlindCam::kEPoisson5;
    228195
    229196  fNumSinglePhes    = 0;
     
    356323  pix.fNDF            = fNDF;             
    357324  pix.fProb           = fProb;             
    358   pix.fMeanPedestal   = fMeanPedestal;     
    359   pix.fSigmaPedestal  = fSigmaPedestal;   
    360   pix.fMeanPedestalErr  = fMeanPedestalErr; 
    361   pix.fSigmaPedestalErr = fSigmaPedestalErr;
    362325
    363326  return &pix;
     
    427390// --------------------------------------------------------------------------
    428391//
    429 // Gets the pointers to:
    430 // - MRawEvtData
    431 // - MExtractedSignalBlindPixel
     392// Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
    432393//
    433 Bool_t MHCalibrationChargeBlindPix::SetupFill(const MParList *pList)
    434 {
    435 
    436   fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
    437   if (!fRawEvt)
    438     {
    439       *fLog << err << "MRawEvtData not found... aborting." << endl;
    440       return kFALSE;
    441     }
    442  
    443   fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
    444   if (!fSignal)
    445     {
    446       *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
    447       return kFALSE;
    448     }
    449  
    450   return kTRUE;
    451 }
    452 
    453 // --------------------------------------------------------------------------
    454 //
    455 // Gets or creates the pointers to:
    456 // - MCalibrationChargeBlindPix
    457 //
    458 // Calls:
    459 // - MHGausHist::InitBins()
    460 //
    461 Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
    462 {
    463 
    464   fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
    465   if (!fBlindPix)
    466       return kFALSE;
    467 
    468   const Int_t samples = fSignal->GetNumFADCSamples();
    469   const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
    470 
    471   //
    472   // Modify the histogram size in case, integrals have been used
    473   //
    474   if ( fLast < samples*integ*fgChargeLast )
    475     {
    476       SetLast        ( samples * (fgChargeLast+0.5) - 0.5 );
    477       SetSinglePheCut( samples * fgSinglePheCut );
    478     }
    479 
    480   MHCalibrationPix::InitBins();
    481  
    482   return kTRUE;
    483 }
    484 
    485 // --------------------------------------------------------------------------
    486 //
    487 // Retrieves from MExtractedSignalBlindPixel:
    488 // - number of FADC samples
    489 // - extracted signal
    490 // - blind Pixel ID
    491 //
    492 // Resizes (if necessary):
    493 // - fASinglePheFADCSlices to sum of HiGain and LoGain samples
    494 // - fAPedestalFADCSlices to sum of HiGain and LoGain samples
    495 //
    496 // Fills the following histograms:
    497 // - MHGausEvents::FillHistAndArray(signal)
    498 //
    499 // Creates MRawEvtPixelIter, jumps to blind pixel ID,
    500 // fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
    501 // with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
    502 //
    503 Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
    504 {
    505 
    506   const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()
    507                       +(Int_t)fRawEvt->GetNumLoGainSamples();
    508 
    509   if (!fASinglePheFADCSlices.IsValid())
    510     {
    511       fASinglePheFADCSlices.ResizeTo(samples);
    512       fAPedestalFADCSlices.ResizeTo(samples);
    513     }
    514 
    515   if (fASinglePheFADCSlices.GetNrows() != samples)
    516     {
    517       fASinglePheFADCSlices.ResizeTo(samples);
    518       fAPedestalFADCSlices.ResizeTo(samples);
    519     }
    520 
    521   Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
    522  
    523   if (slices == 0.)
    524     {
    525       *fLog << err
    526             << "Number of used signal slices in MExtractedSignalBlindPix "
    527             << "is zero  ... abort."
    528             << endl;
    529       return kFALSE;
    530     }
    531  
    532   //
    533   // Signal extraction and histogram filling
    534   //
    535   const Float_t signal = fSignal->GetExtractedSignal(fPixId);
    536 
    537   if (signal > -0.5)
    538     FillHist(signal);
    539   else
    540     return kTRUE;
    541 
    542   //
    543   // In order to study the single-phe posistion, we extract the slices
    544   //
    545   const Int_t blindpixIdx = fSignal->GetBlindPixelIdx(fPixId);
    546 
    547   MRawEvtPixelIter pixel(fRawEvt);
    548   pixel.Jump(blindpixIdx);
    549 
    550   if (signal > fSinglePheCut)
    551       FillSinglePheFADCSlices(pixel);
    552   else
    553       FillPedestalFADCSlices(pixel);
    554 
    555   return kTRUE;
    556 }
    557 
    558 // --------------------------------------------------------------------------
    559 //
    560 // Returns kFALSE, if empty
    561 //
    562 // - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
    563 // - Retrieves the pedestals from MExtractedSignalBlindPixel
    564 // - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
    565 // - Executes FitPedestal()
    566 // - Executes FitSinglePhe()
    567 // - Retrieves fit results and stores them in MCalibrationChargeBlindPix
    568 //
    569 Bool_t MHCalibrationChargeBlindPix::Finalize()
    570 {
    571  
    572   if (IsEmpty())
    573   {
    574     *fLog << err << GetDescriptor() << " ID: " << fPixId
    575           << " My histogram has not been filled !! " << endl;
    576       return kFALSE;
    577   }
    578 
    579   fMeanPedestal     = fSignal->GetPed();
    580   fMeanPedestalErr  = fSignal->GetPedErr();
    581   fSigmaPedestal    = fSignal->GetPedRms();
    582   fSigmaPedestalErr = fSignal->GetPedRmsErr();
    583 
     394void MHCalibrationChargeBlindPix::FinalizeSinglePheSpectrum()
     395{
     396 
    584397  if (fNumSinglePhes > 1)
    585398      for (Int_t i=0;i<fASinglePheFADCSlices.GetNrows();i++)
     
    587400  if (fNumPedestals > 1)
    588401      for (Int_t i=0;i<fAPedestalFADCSlices.GetNrows();i++)
    589           fAPedestalFADCSlices[i]  = fAPedestalFADCSlices[i]/fNumPedestals;
    590 
    591   FitPedestal();
    592 
    593   fBlindPix->SetValid(kTRUE);
    594 
    595   if (FitSinglePhe())
    596     fBlindPix->SetSinglePheFitOK();
    597   else
    598     fBlindPix->SetValid(IsPedestalFitOK());
    599 
    600   fBlindPix->SetLambda      (    fLambda               );
    601   fBlindPix->SetLambdaVar   (    fLambdaErr*fLambdaErr );
    602   fBlindPix->SetMu0         (    fMu0                  );
    603   fBlindPix->SetMu0Err      (    fMu0Err               );
    604   fBlindPix->SetMu1         (    fMu1                  );
    605   fBlindPix->SetMu1Err      (    fMu1Err               );
    606   fBlindPix->SetSigma0      (    fSigma0               );
    607   fBlindPix->SetSigma0Err   (    fSigma0Err            );
    608   fBlindPix->SetSigma1      (    fSigma1               );
    609   fBlindPix->SetSigma1Err   (    fSigma1Err            );
    610   fBlindPix->SetProb        (    fProb                 );
    611 
    612   fBlindPix->SetLambdaCheck    ( fLambdaCheck          );
    613   fBlindPix->SetLambdaCheckErr ( fLambdaCheckErr       );
    614 
    615   return kTRUE;
    616 }
    617 
     402        fAPedestalFADCSlices[i]  = fAPedestalFADCSlices[i]/fNumPedestals;
     403}
    618404
    619405// --------------------------------------------------------------------------
     
    733519  switch (fFitFunc)
    734520    {
    735     case kEPoisson4:
     521    case MHCalibrationChargeBlindCam::kEPoisson4:
    736522      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,rmin,rmax,6);
    737523      rmin += 6.5;
    738524      break;
    739     case kEPoisson5:
     525    case MHCalibrationChargeBlindCam::kEPoisson5:
    740526      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,rmin,rmax,6);
    741527      rmin = 0.;
    742528      break;
    743     case kEPoisson6:
     529    case MHCalibrationChargeBlindCam::kEPoisson6:
    744530      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,rmin,rmax,6);
    745531      break;
    746     case kEPolya:
     532    case MHCalibrationChargeBlindCam::kEPolya:
    747533      fSinglePheFit = new TF1("SinglePheFit",&fPolya,rmin,rmax,8);
    748534      break;
    749     case kEMichele:
     535    case MHCalibrationChargeBlindCam::kEMichele:
    750536      fSinglePheFit = new TF1("SinglePheFit",&fFitFuncMichele,rmin,rmax,9);
    751537      break;
     
    786572    {
    787573     
    788     case kEPoisson4:
     574    case MHCalibrationChargeBlindCam::kEPoisson4:
    789575        fSinglePheFit->SetParNames(  "#lambda",   "#mu_{0}",    "#mu_{1}", "#sigma_{0}",  "#sigma_{1}","Area");
    790576        fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
     
    796582        fSinglePheFit->SetParLimits(5,norm-(0.5*norm),norm+(0.7*norm));
    797583        break;
    798     case kEPoisson5:
    799     case kEPoisson6:
     584    case MHCalibrationChargeBlindCam::kEPoisson5:
     585    case MHCalibrationChargeBlindCam::kEPoisson6:
    800586      fSinglePheFit->SetParNames("#lambda","#mu_{0}","#mu_{1}","#sigma_{0}","#sigma_{1}","Area");
    801587      fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,800.,si_0_guess,500.,norm);
     
    808594      break;
    809595
    810     case kEPolya:
     596    case MHCalibrationChargeBlindCam::kEPolya:
    811597        fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
    812598                                     delta1_guess,delta2_guess,
    813599                                     electronicAmp_guess,
    814                                      fSigmaPedestal,
     600                                     10.,
    815601                                     norm,
    816                                      fMeanPedestal);
     602                                     0.);
    817603      fSinglePheFit->SetParNames("#lambda","b_{tot}",
    818604                                 "#delta_{1}","#delta_{2}",
     
    825611      fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
    826612                                    electronicAmp_guess+electronicAmp_limit);   
    827       fSinglePheFit->SetParLimits(5,
    828                                     fSigmaPedestal-3.*fSigmaPedestalErr,
    829                                     fSigmaPedestal+3.*fSigmaPedestalErr);
     613      fSinglePheFit->SetParLimits(5,0.,40.);
    830614      fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
    831       fSinglePheFit->SetParLimits(7,
    832                                     fMeanPedestal-3.*fMeanPedestalErr,
    833                                     fMeanPedestal+3.*fMeanPedestalErr);
    834       break;
    835     case kEMichele:
     615      fSinglePheFit->SetParLimits(7,-10.,10.);
     616      break;
     617    case MHCalibrationChargeBlindCam::kEMichele:
    836618      fSinglePheFit->SetParNames("#lambda_{cat}","#lambda_{dyn}",
    837619                                 "#mu_{0}","#mu_{1cat}","#mu_{1dyn}",
     
    879661    {
    880662     
    881     case kEPoisson4:
    882     case kEPoisson5:
    883     case kEPoisson6:
    884     case kEPoisson7:
     663    case MHCalibrationChargeBlindCam::kEPoisson4:
     664    case MHCalibrationChargeBlindCam::kEPoisson5:
     665    case MHCalibrationChargeBlindCam::kEPoisson6:
     666    case MHCalibrationChargeBlindCam::kEPoisson7:
    885667      fLambda = fSinglePheFit->GetParameter(0);
    886668      fMu0    = fSinglePheFit->GetParameter(1);
     
    895677      fSigma1Err = fSinglePheFit->GetParError(4);
    896678      break;
    897     case kEPolya:
     679    case MHCalibrationChargeBlindCam::kEPolya:
    898680      fLambda =  fSinglePheFit->GetParameter(0);
    899681      fMu0    =  fSinglePheFit->GetParameter(7);
     
    907689      fSigma0Err = fSinglePheFit->GetParError(5);
    908690      fSigma1Err = 0.;
    909     case kEMichele:
     691    case MHCalibrationChargeBlindCam::kEMichele:
    910692      fLambda =  fSinglePheFit->GetParameter(0);
    911693      fMu0    =  fSinglePheFit->GetParameter(2);
     
    1037819      fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
    1038820      fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
    1039                                 (fFitFunc ==  kEPoisson4) ? "Poisson(k=4))" :
    1040                                 (fFitFunc ==  kEPoisson5) ? "Poisson(k=5))" :
    1041                                 (fFitFunc ==  kEPoisson6) ? "Poisson(k=6))" :
    1042                                 (fFitFunc ==  kEPolya   ) ? "Polya(k=4))"   :
    1043                                 (fFitFunc ==  kEMichele ) ?  "Michele)"     : " none )" ));
     821                                (fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson4) ? "Poisson(k=4))" :
     822                                (fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson5) ? "Poisson(k=5))" :
     823                                (fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson6) ? "Poisson(k=6))" :
     824                                (fFitFunc ==  MHCalibrationChargeBlindCam::kEPolya   ) ? "Polya(k=4))"   :
     825                                (fFitFunc ==  MHCalibrationChargeBlindCam::kEMichele ) ?  "Michele)"     
     826                                                                                       : " none )" ));
    1044827      fFitLegend->SetTextSize(0.05);
    1045828  }
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.h

    r4963 r4986  
    77#endif
    88
     9#ifndef MARS_MHCalibrationChargeBlindCam
     10#include "MHCalibrationChargeBlindCam.h"
     11#endif
     12
    913#ifndef ROOT_TF1
    1014#include <TF1.h>
     
    1822class TPaveText;
    1923class TText;
    20 class MRawEvtData;
     24class MExtractedSignalBlindPixel;
    2125class MRawEvtPixelIter;
    22 class MCalibrationChargeBlindPix;
    23 class MExtractBlindPixel;
    24 class MExtractedSignalBlindPixel;
    2526
    2627class MHCalibrationChargeBlindPix : public MHCalibrationPix
     
    2829private:
    2930
    30   static const Int_t    fgChargeNbins;       //! Default for fNBins        (now set to: 5300   )
    31   static const Axis_t   fgChargeFirst;       //! Default for fFirst        (now set to: -100.5 )
    32   static const Axis_t   fgChargeLast;        //! Default for fLast         (now set to: 5199.5 )
    33   static const Float_t  fgSinglePheCut;      //! Default for fSinglePheCut (now set to: 200    )
    3431  static const Float_t  fgNumSinglePheLimit; //! Default for fNumSinglePheLimit (now set to: 50)
    3532  static const Float_t  gkSignalInitializer; //! Signal initializer (-9999.)
     
    4138  Float_t fNumSinglePheLimit;                // Minimum number of single-phe events
    4239
    43   MCalibrationChargeBlindPix *fBlindPix;     //! Storage container results 
    44   MExtractedSignalBlindPixel *fSignal;       //! Storage container extracted signal
    45   MRawEvtData                *fRawEvt;       //! Storage container raw data
    46  
    4740  TVector fASinglePheFADCSlices;             // Averaged FADC slice entries supposed single-phe events
    4841  TVector fAPedestalFADCSlices;              // Averaged FADC slice entries supposed pedestal   events
     
    6861  Int_t     fNDF;                            // Ndof of single-phe fit
    6962  Double_t  fProb;                           // Probability of singleo-phe fit
    70   Double_t  fMeanPedestal;                   // Mean pedestal from pedestal run
    71   Double_t  fSigmaPedestal;                  // Sigma pedestal from pedestal run
    72   Double_t  fMeanPedestalErr;                // Error of Mean pedestal from pedestal run
    73   Double_t  fSigmaPedestalErr;               // Error of Sigma pedestal from pedestal run
    7463                                     
    7564  Byte_t    fFlags;                          // Bit-field for the flags
    7665  enum { kSinglePheFitOK, kPedestalFitOK };  // Possible bits to be set
    7766
     67  MHCalibrationChargeBlindCam::FitFunc_t fFitFunc;
     68
    7869  TPaveText *fFitLegend;                     //! Some legend to display the fit results
    7970  TH1F      *fHSinglePheFADCSlices;          //! A histogram created and deleted only in Draw()
    8071  TH1F      *fHPedestalFADCSlices;           //! A histogram created and deleted only in Draw()
    8172
    82   // Fill histos
    83   void  FillSinglePheFADCSlices(const MRawEvtPixelIter &iter);
    84   void  FillPedestalFADCSlices( const MRawEvtPixelIter &iter);
    85 
    8673  // Fit
    8774  Bool_t InitFit();
    8875  void   ExitFit(); 
    8976 
     77  void DrawLegend(Option_t *opt="");
     78 
    9079public:
    9180
     
    9887  //  TObject *Clone(const char *) const;
    9988
    100   Bool_t SetupFill(const MParList *pList);
    101   Bool_t ReInit   (      MParList *pList);
    102   Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
    103   Bool_t Finalize();
    104  
    10589  // Getters
    10690  const Double_t GetLambda        ()  const { return fLambda;         }
     
    128112 
    129113  // Setters
    130   void SetCalibrationChargeBlindPix ( MCalibrationChargeBlindPix *pix)    { fBlindPix          = pix;  }
    131   void SetSinglePheCut      ( const Float_t cut =fgSinglePheCut      )    { fSinglePheCut      = cut;  }
     114  void SetFitFunc(const MHCalibrationChargeBlindCam::FitFunc_t func)  { fFitFunc = func;  }
     115  void SetSinglePheCut      ( const Float_t cut = 0.               )    { fSinglePheCut      = cut;  }
    132116  void SetNumSinglePheLimit ( const Float_t lim =fgNumSinglePheLimit )    { fNumSinglePheLimit = lim;  }
    133 
    134   void SetMeanPedestal      ( const Float_t f )   { fMeanPedestal     = f;  }
    135   void SetMeanPedestalErr   ( const Float_t f )   { fMeanPedestalErr  = f;  }
    136   void SetSigmaPedestal     ( const Float_t f )   { fSigmaPedestal    = f;  }
    137   void SetSigmaPedestalErr  ( const Float_t f )   { fSigmaPedestalErr = f;  }
    138117
    139118  void SetSinglePheFitOK    ( const Bool_t b=kTRUE);
    140119  void SetPedestalFitOK     ( const Bool_t b=kTRUE);
    141120 
     121  // Fill histos
     122  void  FillSinglePheFADCSlices(const MRawEvtPixelIter &iter);
     123  void  FillPedestalFADCSlices( const MRawEvtPixelIter &iter);
     124  void  FinalizeSinglePheSpectrum();
     125 
    142126  // Draws
    143127  void Draw(Option_t *opt="");
    144128
    145 private:
    146   void DrawLegend(Option_t *opt="");
    147  
    148129  // Fits
    149 public:
    150   enum FitFunc_t { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; // The possible fit functions
    151 
    152 private:
    153   FitFunc_t fFitFunc;
    154 
    155 public:
    156130  Bool_t FitSinglePhe (Option_t *opt="RL0+Q");
    157131  void   FitPedestal  (Option_t *opt="RL0+Q");
    158132
    159   void   ChangeFitFunc(const FitFunc_t func)  { fFitFunc = func;  }
    160  
    161133  // Simulation
    162134  Bool_t SimulateSinglePhe(const Double_t lambda,
  • trunk/MagicSoft/Mars/mhcalib/Makefile

    r4940 r4986  
    3232# mimage     MHillas
    3333
    34 SRCFILES = MHCalibrationChargeBlindPix.cc \
    35            MHCalibrationChargeBlindCam.cc \
    36            MHCalibrationChargePix.cc \
    37            MHCalibrationCam.cc \
     34SRCFILES = MHCalibrationCam.cc \
    3835           MHCalibrationPix.cc \
    3936           MHCalibrationChargeCam.cc \
     37           MHCalibrationChargePix.cc \
     38           MHCalibrationChargeBlindCam.cc \
     39           MHCalibrationChargeBlindPix.cc \
    4040           MHCalibrationChargePINDiode.cc \
    4141           MHCalibrationRelTimeCam.cc \
Note: See TracChangeset for help on using the changeset viewer.