HighLAND
nueP0DPileUpSystematics.cxx
1 #include "nueP0DPileUpSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 
4 //********************************************************************
5 nueP0DPileUpSystematics::nueP0DPileUpSystematics():EventWeightBase(1){
6 //********************************************************************
7 
8  _fgd1 = new BinnedParams("nueFGD1_P0D_PileUp",BinnedParams::k1D_SYMMETRIC);
9  _fgd2 = new BinnedParams("nueFGD2_P0D_PileUp",BinnedParams::k1D_SYMMETRIC);
10  SetNParameters(_fgd1->GetNBins()+_fgd2->GetNBins());
11 }
12 
13 //********************************************************************
15 //********************************************************************
16 
17  Weight_h eventWeight= 1;
18 
19  const AnaEventB& event = *static_cast<const AnaEventB*>(&eventBB);
20 
21  if( box.DetectorFV != SubDetId::kFGD1 && box.DetectorFV != SubDetId::kFGD2) return eventWeight;
22 
23  // Get the run period (from 0 to 8)
24  Int_t runPeriod = anaUtils::GetRunPeriod(event.EventInfo.Run);
25 
26  // MainTrack should be in FV. This condition is already in box.DetectorFV
27  // if (!anaUtils::InFiducialVolume(box.DetectorFV, box.MainTrack->PositionStart)) return eventWeight;
28 
29  // Get the pileup values for this run period
30  Float_t pileup;
31  Float_t pileup_error;
32  Int_t index;
33  if (box.DetectorFV==SubDetId::kFGD1){
34  if(!_fgd1->GetBinValues(runPeriod, pileup, pileup_error, index)) return eventWeight;
35  }
36  else if(box.DetectorFV==SubDetId::kFGD2){
37  if(!_fgd2->GetBinValues(runPeriod, pileup, pileup_error, index)) return eventWeight;
38  }
39  else return eventWeight;
40 
41  // compute the weight
42  eventWeight.Systematic = 1 - pileup - pileup_error * toy.GetToyVariations(_index)->Variations[index];
43  eventWeight.Correction = 1 - pileup;
44 
45  return eventWeight;
46 }
47 
Int_t _index
The index of this systematic (needed by SystematicsManager);.
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
SubDetId_h DetectorFV
Indicate the FV we are interested in.
Definition: ToyBoxB.hxx:52
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
bool GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
int GetRunPeriod(int run, int subrun=-1)
Returns the run period (sequentially: 0,1,2,3,4,5 ...)
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
Weight_h ComputeWeight(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &box)
Int_t GetNBins()
Get the number of bins.