Changeset 3015


Ignore:
Timestamp:
02/04/04 15:03:44 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3014 r3015  
    1414      Thomas Bretz. Some modifications had to be done, however.
    1515    - Class to hold MHPedestalPixel is still MPedestalCam
     16    - MPedCalcPedRun does nothing any more (except from what is was
     17      doing before)
     18
    1619
    1720 2004/02/03: Markus Gaug
  • trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc

    r2974 r3015  
    4848const Float_t gkSq2Pi = 2.506628274631;
    4949const Float_t gkProbLimit = 0.01;
     50const Int_t   MHPedestalPixel::gkChargeNbins    = 500 ;
     51const Int_t   MHPedestalPixel::gkChargevsNbins  = 1000;
     52const Axis_t  MHPedestalPixel::gkChargevsNFirst = -0.5;
     53const Axis_t  MHPedestalPixel::gkChargevsNLast  = 999.5;
     54const Axis_t  MHPedestalPixel::gkChargeFirst    = -0.5;
     55const Axis_t  MHPedestalPixel::gkChargeLast     = 499.5;
    5056
    5157// --------------------------------------------------------------------------
     
    5359// Default Constructor.
    5460//
    55 MHPedestalPixel::MHPedestalPixel(const char *name, const char *title)
     61MHPedestalPixel::MHPedestalPixel()
    5662      : fPixId(-1),
    57         fChargeNbins(500),
    58         fChargeFirst(-0.5),
    59         fChargeLast(499.5),
    60         fChargevsNbins(1000),
    61         fChargevsNFirst(-0.5),
    62         fChargevsNLast(999.5),       
    6363        fGausFit(NULL)
    6464{
    65 
    66     fName  = name  ? name  : "MHPedestalPixel";
    67     fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits";
    68 
    69     // Create a large number of bins, later we will rebin
    70     fHPedestalCharge = new TH1F("HPedestalCharge","Distribution of Summed FADC Pedestal Slices Pixel ",
    71                         fChargeNbins,fChargeFirst,fChargeLast);
    72     fHPedestalCharge->SetXTitle("Sum FADC Slices");
    73     fHPedestalCharge->SetYTitle("Nr. of events");
    74     fHPedestalCharge->Sumw2();
    75 
    76     // We define a reasonable number and later enlarge it if necessary
    77     fHPedestalChargevsN = new TH1I("HChargevsN","Sum of Charges vs. Event Number Pixel ",
    78                            fChargevsNbins,fChargevsNFirst,fChargevsNLast);
    79     fHPedestalChargevsN->SetXTitle("Event Nr.");
    80     fHPedestalChargevsN->SetYTitle("Sum of FADC slices");
    81 
    82     fHPedestalCharge->SetDirectory(NULL);
    83     fHPedestalChargevsN->SetDirectory(NULL);
    84 
    85     Clear();
     65 
     66  // Create a large number of bins, later we will rebin
     67  fHPedestalCharge = new TH1F("HPedestalCharge","Distribution of Summed FADC Pedestal Slices Pixel ",
     68                              gkChargeNbins,gkChargeFirst,gkChargeLast);
     69  fHPedestalCharge->SetXTitle("Sum FADC Slices");
     70  fHPedestalCharge->SetYTitle("Nr. of events");
     71  fHPedestalCharge->Sumw2();
     72 
     73  // We define a reasonable number and later enlarge it if necessary
     74  fHPedestalChargevsN = new TH1I("HChargevsN","Sum of Charges vs. Event Number Pixel ",
     75                                 gkChargevsNbins,gkChargevsNFirst,gkChargevsNLast);
     76  fHPedestalChargevsN->SetXTitle("Event Nr.");
     77  fHPedestalChargevsN->SetYTitle("Sum of FADC slices");
     78 
     79  fHPedestalCharge->SetDirectory(NULL);
     80  fHPedestalChargevsN->SetDirectory(NULL);
     81 
     82  Clear();
    8683}
    8784
     
    9188  delete fHPedestalCharge;
    9289  delete fHPedestalChargevsN;
    93 
     90 
    9491  if (fGausFit)
    9592    delete fGausFit;
     
    111108  fChargeNdf       = -1;
    112109
    113   fChargeFirst     = -0.5;
    114   fChargeLast      = 499.5;
     110  fChargeFirst     = gkChargeFirst;
     111  fChargeLast      = gkChargeLast;
    115112
    116113  if (fGausFit)
    117114    delete fGausFit;
    118115
     116  CLRBIT(fFlags,kFitted);
     117  CLRBIT(fFlags,kFitOK);
     118  CLRBIT(fFlags,kOscillating);
     119
    119120  return;
    120121}
     
    160161  fPixId = id;
    161162
    162   TString nameQ = TString(fHPedestalCharge->GetName());
    163   nameQ += id;
    164   fHPedestalCharge->SetName(nameQ.Data());
    165 
    166   TString nameQvsN  = TString(fHPedestalChargevsN->GetName());
    167   nameQvsN += id;
    168   fHPedestalChargevsN->SetName(nameQvsN.Data());
    169 
    170   TString titleQ = TString(fHPedestalCharge->GetTitle());
    171   titleQ += id;
    172   fHPedestalCharge->SetTitle(titleQ.Data());
    173 
    174   TString titleQvsN  = TString(fHPedestalChargevsN->GetTitle());
    175   titleQvsN += id;
    176   fHPedestalChargevsN->SetTitle(titleQvsN.Data());
    177 
    178 }
    179 
    180 
    181 Bool_t MHPedestalPixel::SetupFill(const MParList *plist)
    182 {
    183  
    184   Reset();
    185 
    186   return kTRUE;
    187 }
    188 
    189 
    190 
     163  fHPedestalCharge->SetName(Form("%s%d", fHPedestalCharge->GetName(), id));
     164  fHPedestalChargevsN->SetName(Form("%s%d", fHPedestalChargevsN->GetName(), id));
     165  fHPedestalCharge->SetTitle(Form("%s%d", fHPedestalCharge->GetTitle(), id));
     166  fHPedestalChargevsN->SetTitle(Form("%s%d", fHPedestalChargevsN->GetTitle(), id));
     167
     168}
    191169
    192170TObject *MHPedestalPixel::DrawClone(Option_t *option) const
     
    223201  gROOT->SetSelectedPad(NULL);
    224202 
    225   TCanvas *c = MakeDefCanvas(this,600,900);
     203  TCanvas *c = MH::MakeDefCanvas(this,600,900);
    226204 
    227205  c->Divide(1,2);
     
    233211  if (fHPedestalCharge->Integral() > 0)
    234212    gPad->SetLogy(1);
    235   else
    236     gPad->SetLogy(0);
    237213
    238214  fHPedestalCharge->Draw(opt);
     
    243219  if (fGausFit)
    244220    {
    245       if (IsFitOK())
    246         fGausFit->SetLineColor(kGreen);         
    247       else
    248         fGausFit->SetLineColor(kRed);
    249      
     221      fGausFit->SetLineColor(IsFitOK() ? kGreen : kRed);
    250222      fGausFit->Draw("same");
    251223    }
     
    265237
    266238
     239// --------------------------------------------------------------------------
     240//
     241// 1) Return if the charge distribution is already succesfully fitted 
     242//    or if the histogram is empty
     243// 2) Cut the histograms empty edges
     244// 3) Fit the histograms with a Gaussian
     245// 4) In case of failure print out the fit results
     246// 5) Retrieve the results and store them in this class
     247//
    267248Bool_t MHPedestalPixel::FitCharge(Option_t *option)
    268249{
     
    282263  //
    283264  const Stat_t   entries     = fHPedestalCharge->Integral();
    284   const Double_t area_guess  = entries/gkSq2Pi;
    285265  const Double_t mu_guess    = fHPedestalCharge->GetBinCenter(fHPedestalCharge->GetMaximumBin());
    286266  const Double_t sigma_guess = mu_guess/15.;
    287 
    288   TString name = TString("GausFit");
    289   name += fPixId;
    290 
    291   fGausFit = new TF1(name.Data(),"gaus",rmin,rmax);
     267  const Double_t area_guess  = entries/gkSq2Pi/sigma_guess;
     268
     269  fGausFit = new TF1(Form("%s%d","GausFit ",fPixId),"gaus",rmin,rmax);
    292270
    293271  if (!fGausFit)
     
    312290    {
    313291
    314       Axis_t rtry = fGausFit->GetParameter(1) - 3.0*fGausFit->GetParameter(2);
     292      Axis_t rtry = fGausFit->GetParameter(1) - 2.0*fGausFit->GetParameter(2);
    315293      rmin        = (rtry < rmin ? rmin : rtry);
    316       rmax        = fGausFit->GetParameter(1) + 3.0*fGausFit->GetParameter(2);
     294      rmax        = fGausFit->GetParameter(1) + 2.0*fGausFit->GetParameter(2);
    317295      fGausFit->SetRange(rmin,rmax); 
    318296
     
    353331{
    354332
    355   Int_t nbins = 50;
    356 
    357   CutEdges(fHPedestalCharge,nbins);
     333  Int_t nbins = 30;
     334
     335  MH::CutEdges(fHPedestalCharge,nbins);
    358336
    359337  fChargeFirst = fHPedestalCharge->GetBinLowEdge(fHPedestalCharge->GetXaxis()->GetFirst());
    360338  fChargeLast  = fHPedestalCharge->GetBinLowEdge(fHPedestalCharge->GetXaxis()->GetLast())
    361                       +fHPedestalCharge->GetBinWidth(0);
    362 
    363   CutEdges(fHPedestalChargevsN,0);
     339                +fHPedestalCharge->GetBinWidth(0);
     340
     341  MH::CutEdges(fHPedestalChargevsN,0);
    364342
    365343}
     
    370348  *fLog << all << "Pedestal Fits Pixel: "  << fPixId  << endl;
    371349
    372   if (TESTBIT(fFlags,kFitted))
    373     {
    374      
    375       *fLog << all << "Results of the Summed Charges Fit: "                      << endl;
    376       *fLog << all << "Chisquare: "        << fChargeChisquare                   << endl;
    377       *fLog << all << "DoF: "              << fChargeNdf                         << endl;
    378       *fLog << all << "Probability: "      << fChargeProb                        << endl;
    379       *fLog << all << "Results of fit: "   ;
    380         if (TESTBIT(fFlags,kFitOK))
    381           *fLog << inf << "OK" << endl;
    382         else
    383           *fLog << err << "NOT OK" << endl;         
    384       *fLog << all                                                               << endl;
    385     }
    386   else
    387     {
    388       *fLog << all << "Pedestal Histogram has not yet been fitted"               << endl;     
    389       *fLog << all                                                               << endl;     
    390     }
     350  if (!TESTBIT(fFlags,kFitted))
     351    {
     352      gLog << "Pedestal Histogram has not yet been fitted" << endl;
     353      return;
     354    }
     355 
     356  gLog << "Results of the Summed Charges Fit: "   << endl;
     357  gLog << "Chisquare:      " << fChargeChisquare  << endl;
     358  gLog << "DoF:            " << fChargeNdf        << endl;
     359  gLog << "Probability:    " << fChargeProb       << endl;
     360  gLog << "Results of fit: " << (TESTBIT(fFlags,kFitOK) ? "Ok.": "Not OK!") << endl;
    391361   
    392362}
  • trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h

    r2997 r3015  
    1414private:
    1515
     16  static const Int_t  gkChargeNbins;
     17  static const Int_t  gkChargevsNbins;
     18  static const Axis_t gkChargevsNFirst;
     19  static const Axis_t gkChargevsNLast;
     20  static const Axis_t gkChargeFirst;
     21  static const Axis_t gkChargeLast;
     22 
    1623  Int_t fPixId;                  // Pixel Nr
    1724
    18   const Int_t   fChargeNbins;
    1925  Axis_t  fChargeFirst;
    2026  Axis_t  fChargeLast;
    21 
     27 
    2228  const Int_t   fChargevsNbins;
    2329  const Axis_t  fChargevsNFirst;
     
    4147  Byte_t   fFlags;
    4248
    43   enum   { kFitted, kFitOK };
     49   enum { kFitted, kFitOK, kOscillating };
    4450 
    4551public:
    4652
    47   MHPedestalPixel(const char *name=NULL, const char *title=NULL);
     53  MHPedestalPixel();
    4854  ~MHPedestalPixel();
    4955
     
    7379  Bool_t FillChargevsN(Float_t q);
    7480
    75   Bool_t SetupFill(const MParList *pList);
    76   Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
    77  
    7881  // Fits
    7982  Bool_t FitCharge(Option_t *option="RQ0"); 
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc

    r3005 r3015  
    124124  fNumPixels        = 0;
    125125  fNumSamplesTot    = 0;
    126   fUseHists         = kFALSE;
    127126 
    128127  fRawEvt    = NULL;
     
    160159
    161160    fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
    162 
    163     if (!fSignals && fUseHists)
    164     {
    165         *fLog << warn << "Cannot find MExtractedSignalCam... will not use histograms!" << endl;
    166         fUseHists = kFALSE;
    167     }
    168161
    169162    fNumSamplesTot=0;
     
    207200    // the other one
    208201    fNumHiGainSamples = runheader->GetNumSamplesHiGain() & ~1;
    209 
    210     if (fUseHists)
    211       fPedestals->InitUseHists();
    212202
    213203    return kTRUE;
     
    260250        fSumx2[idx] += msum*msum;
    261251
    262         if (fUseHists)
    263           {
    264             MExtractedSignalPix &sig =  (*fSignals)[idx];           
    265             const Float_t signal = sig.GetExtractedSignalHiGain();
    266             (*fPedestals)[idx].FillHists(signal);
    267           }
    268252    }
    269253   
     
    290274  while (pixel.Next())
    291275    {
    292       const UInt_t pixid = pixel.GetPixelId();
     276      const Int_t pixid = pixel.GetPixelId();
    293277     
    294278      const Float_t sum  = fSumx.At(pixid);
     
    307291      (*fPedestals)[pixid].Set(higainped, higainrms);
    308292
    309       if (fUseHists)
    310         (*fPedestals)[pixid].FitCharge();
    311      
    312293    }
    313294 
    314   fPedestals->SetNumTotSlices(fNumSamplesTot);
    315 
    316   if (fUseHists)
    317     fPedestals->SetNumExtractSlices(fSignals->GetNumUsedHiGainFADCSlices());
     295  fPedestals->SetTotalEntries(fNumSamplesTot);
    318296
    319297  return kTRUE;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc

    r3007 r3015  
    630630      // so that we can use it for the fit
    631631      //
    632       if (fPedestals->IsUseHists())
     632      if (fPedestals->GetHistSize() > fBlindPixelId)
    633633        {
    634634          //
    635635          // retrieve the pedestal pix of the blind pixel
    636636          //
    637           MPedestalPix &ped = (*fPedestals)[fBlindPixelId];
     637          MHPedestalPixel &pedhist = (*fPedestals)(fBlindPixelId);
     638          MPedestalPix    &pedpix  = (*fPedestals)[fBlindPixelId];
    638639          //
    639640          // retrieve the histogram containers
    640641          //
    641642          MHCalibrationBlindPixel *hist = blindpixel.GetHist();
    642           MHPedestalPixel *pedhist = ped.GetHist();
    643643          //
    644644          // Set the corresponding values
    645645          //
    646646          const Float_t nslices     = (Float_t)fSignals->GetNumUsedFADCSlices();
    647           const Int_t   nentries    = pedhist->GetTotalEntries();
    648          
    649           const Float_t peddiff     = ped.GetMean() - ped.GetPedestal()*nslices;
    650 
    651           Float_t pederr  = ped.GetMeanErr()*ped.GetMeanErr();
    652           pederr         += ped.GetPedestalRms()*ped.GetPedestalRms()*nslices*nslices/nentries/nentries;
    653           pederr          = TMath::Sqrt(pederr);
    654          
    655           const Float_t pedsigma    = ped.GetSigma();
    656           const Float_t pedsigmaerr = ped.GetSigmaErr();
     647          const ULong_t nentries    = fPedestals->GetTotalEntries();
     648         
     649          const Float_t peddiff     = (pedhist.GetChargeMean()-pedpix.GetPedestal())*nslices;
     650
     651          const Float_t sqrslice    = TMath::Sqrt(nslices);
     652
     653          Float_t pederr  = pedhist.GetChargeMeanErr()*pedhist.GetChargeMeanErr();
     654          pederr         += pedpix.GetPedestalRms()*pedpix.GetPedestalRms()/nentries;
     655          pederr          = TMath::Sqrt(pederr)*sqrslice;
     656         
     657          const Float_t pedsigma    = pedhist.GetChargeSigma()*sqrslice;
     658          const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*sqrslice;
    657659         
    658660          hist->SetMeanPedestal(peddiff);
Note: See TracChangeset for help on using the changeset viewer.