Ignore:
Timestamp:
04/12/03 16:40:23 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MApplyPadding.cc

    r1713 r1951  
    7878// Default constructor.
    7979//
    80 MApplyPadding::MApplyPadding(const char *name, const char *title) : fRunType(0), fGroup(0), fUseHistogram(kTRUE), fFixedSigmabar(0.0)
     80MApplyPadding::MApplyPadding(const char *name, const char *title) : fRunType(0), fGroup(0), fUseHistogram(kTRUE), fFixedSigmabar(0.0), fRnd(0)
    8181{
    8282  fName  = name  ? name  : "MApplyPadding";
     
    8787// --------------------------------------------------------------------------
    8888//
    89 // Destructor.
    90 //
    91 MApplyPadding::~MApplyPadding()
    92 {
    93   //nothing yet
    94 }
    95 
    96 // --------------------------------------------------------------------------
    97 //
    9889// You can provide a TH1D* histogram containing the target Sigmabar in
    9990// bins of theta. Be sure to use the same binning as for the analysis
    10091//
    101 Bool_t MApplyPadding::SetDefiningHistogram(TH1D *histo)
     92void MApplyPadding::SetDefiningHistogram(TH1D *histo)
    10293{
    10394  fHSigmabarMax = histo;
    104   return kTRUE;
    10595}
    10696
     
    113103Bool_t MApplyPadding::PreProcess(MParList *pList)
    114104{
    115   fRnd = new TRandom3(0);
    116 
    117105  fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
    118106  if (!fMcEvt)
     
    163151   if ((!fUseHistogram) && (fHSigmabarMax==NULL)) {
    164152     
    165      fHSigmabarMax = new TH1D();
     153     fHSigmabarMax = new TH1D;
    166154     fHSigmabarMax->SetNameTitle("fHSigmabarMax","Sigmabarmax for this analysis");
    167      TAxis &x = *fHSigmabarMax->GetXaxis();
    168 #if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
    169      TString xtitle = x.GetTitle();
    170 #endif
    171      fHSigmabarMax->SetBins(binstheta->GetNumBins(), 0, 1);
    172      // Set the binning of the current histogram to the binning
    173      // in one of the two given histograms
    174      x.Set(binstheta->GetNumBins(), binstheta->GetEdges());
    175 #if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
    176      x.SetTitle(xtitle);
    177 #endif
    178      
     155
     156     MH::SetBinning(fHSigmabarMax, binstheta);
     157
    179158     // -------------------------------------------------
    180159     // read in SigmabarParams
     
    229208
    230209  // Get sigmabar which we have to pad to
    231   Double_t otherSig;
     210  Double_t otherSig = fFixedSigmabar;
    232211  if (fUseHistogram) {
    233     Int_t binNumber = fHSigmabarMax->GetXaxis()->FindBin(fMcEvt->GetTheta()*kRad2Deg);
     212    Int_t binNumber = fHSigmabarMax->GetXaxis()->FindBin(fMcEvt->GetTelescopeTheta()*kRad2Deg);
    234213    otherSig = fHSigmabarMax->GetBinContent(binNumber);
    235   } else {
    236     otherSig = fFixedSigmabar;
    237214  }
    238215
    239216  // Determine quadratic difference other-mine
    240   Double_t quadraticDiff = otherSig*otherSig - mySig*mySig;
    241 
     217  const Double_t quadraticDiff = otherSig*otherSig - mySig*mySig;
     218
     219  // crosscheck, should never happen
    242220  if (quadraticDiff < 0) {
    243221    *fLog << err << dbginf << "Event has higher Sigmabar="<<mySig<<" than Sigmabarmax="<<otherSig << " ...Skipping this event" <<endl;
     
    248226 
    249227  // Pad if quadratic difference > 0
    250   if (quadraticDiff > 0) {   
    251 
    252228   MPedestalCam newPed;
    253229   newPed.InitSize(fPed->GetSize());
     
    257233
    258234   for (UInt_t i=0; i<npix; i++) {
    259      MCerPhotPix pix = fEvt->operator[](i);     
     235     MCerPhotPix &pix = (*fEvt)[i];
    260236     if (!pix.IsPixelUsed())
    261237       continue;
    262238     pix.SetNumPhotons(pix.GetNumPhotons() +
    263239                       sqrt(quadraticDiff)*
    264                        fRnd->Gaus(0.0, 1.0)/
     240                       fRnd.Gaus(0.0, 1.0)/
    265241                       fCam->GetPixRatio(pix.GetPixId())
    266242                       );
     
    268244     Double_t error = pix.GetErrorPhot();
    269245     pix.SetErrorPhot(sqrt(error*error + quadraticDiff));
    270      MPedestalPix ppix = fPed->operator[](i);
    271      MPedestalPix npix;
    272      npix.SetSigma(sqrt(ppix.GetSigma()*ppix.GetSigma() + quadraticDiff));
    273      newPed[i]=npix;
     246     MPedestalPix &ppix = (*fPed)[i];
     247     newPed[i].SetSigma(sqrt(ppix.GetSigma()*ppix.GetSigma() + quadraticDiff));
    274248    } //for
    275249   // Calculate Sigmabar again and crosscheck
     
    278252   // fTest->Fill(otherSig,mySig);
    279253   return kTRUE;
    280   } //if
    281   return kFALSE;
    282 }
    283 
    284 Bool_t MApplyPadding::PostProcess()
    285 {
    286   //  fTest->DrawClone();
    287   return kTRUE;
    288 }
     254}
     255
Note: See TracChangeset for help on using the changeset viewer.