Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
ana::BeamWeightFunc Class Reference

Incorporate into a weight Var like Var wei(BeamWeight(... More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/CAFAna/Systs/BeamSysts.h"

Inheritance diagram for ana::BeamWeightFunc:
ana::BeamSystOrWeightBase

Public Member Functions

 BeamWeightFunc (const std::string &fname, const std::string &histname)
 
double operator() (const caf::SRNeutrinoProxy *sr) const
 

Protected Types

enum  { kFHC, kRHC, kNumFluxType }
 
enum  { kND, kFD, kNumDets }
 
enum  ESign { kMinus, kPlus, kNumSigns }
 
enum  {
  kNue, kAntiNue, kNumu, kAntiNumu,
  kNumFlavors
}
 

Protected Member Functions

void InitializeHistograms () const
 
double GetWeight (const caf::SRNeutrinoProxy *nu, ESign sign) const
 

Protected Attributes

std::string fFileName
 
std::string fHistName
 
TH1D * fHistos [kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
 

Detailed Description

Incorporate into a weight Var like Var wei(BeamWeight(...

Definition at line 54 of file BeamSysts.h.

Member Enumeration Documentation

anonymous enum
protectedinherited
anonymous enum
protectedinherited
Enumerator
kFHC 
kRHC 
kNumFluxType 

Definition at line 21 of file BeamSysts.h.

anonymous enum
protectedinherited
Enumerator
kND 
kFD 
kNumDets 

Definition at line 22 of file BeamSysts.h.

enum ana::BeamSystOrWeightBase::ESign
protectedinherited
Enumerator
kMinus 
kPlus 
kNumSigns 

Definition at line 23 of file BeamSysts.h.

Constructor & Destructor Documentation

ana::BeamWeightFunc::BeamWeightFunc ( const std::string fname,
const std::string histname 
)
inline

Definition at line 57 of file BeamSysts.h.

References ana::GetPPFXFluxUnivWgtSmooth_NT(), ana::GetPPFXUnivSyst(), and sr.

Referenced by ana::GetPPFXFluxUnivWgtSmooth_NT().

58  : BeamSystOrWeightBase(fname, histname)
59  {
60  }
BeamSystOrWeightBase(const std::string &fname, const std::string &shortName)
Definition: BeamSysts.cxx:223

Member Function Documentation

double ana::BeamSystOrWeightBase::GetWeight ( const caf::SRNeutrinoProxy nu,
ESign  sign 
) const
protectedinherited

Definition at line 314 of file BeamSysts.cxx.

References om::cerr, fillBadChanDBTables::det, caf::Proxy< caf::SRNeutrino >::det, caf::Proxy< caf::SRNeutrino >::E, allTimeWatchdog::endl, energy, ana::BeamSystOrWeightBase::fHistName, ana::BeamSystOrWeightBase::fHistos, flux, make_syst_table_plots::h, ana::BeamSystOrWeightBase::InitializeHistograms(), caf::Proxy< caf::SRNeutrino >::isRHC, ana::BeamSystOrWeightBase::kAntiNue, ana::BeamSystOrWeightBase::kAntiNumu, caf::kFARDET, ana::BeamSystOrWeightBase::kFD, ana::BeamSystOrWeightBase::kFHC, ana::BeamSystOrWeightBase::kND, caf::kNEARDET, ana::BeamSystOrWeightBase::kNue, ana::BeamSystOrWeightBase::kNumu, ana::BeamSystOrWeightBase::kRHC, caf::Proxy< caf::SRNeutrino >::pdgorig, and canMan::sign().

Referenced by operator()(), and ana::BeamSyst::TruthShift().

316  {
318 
319  int flux = kFHC;
320  if(nu->isRHC) flux = kRHC;
321 
322  // Need different histogram per detector
323  int det = 0;
324  switch (nu->det)
325  {
326  case caf::kNEARDET : det = kND; break;
327  case caf::kFARDET : det = kFD; break;
328  default: std::cerr <<"Wrong detector; ignore" << std::endl; return 1;
329  }
330 
331  //Set the different weights for p/m sigma and neutrino flavor/energy
332 
333  double energy = nu->E; // True neutrino energy
334 
335  //Find the neutrino flavor
336  int flav = 0;
337  switch(nu->pdgorig)
338  {
339  case 14: flav = kNumu; break;
340  case 12: flav = kNue; break;
341  case -14: flav = kAntiNumu; break;
342  case -12: flav = kAntiNue; break;
343  default: std::cerr << "Wrong nu flavor; ignore" << std::endl; return 1;
344  }
345 
346  //Find the right histogram for the detector and sign
347  TH1D* h = fHistos[flux][det][sign][flav];
348  if (h == 0){
349  std::cerr << fHistName+": Can't find desired histogram; ignore"<< std:: endl;
350  return 1;
351  }
352  //Only use weights if the energy is in the range of the histogram
353  if (energy > h->GetXaxis()->GetXmin() &&
354  energy < h->GetXaxis()->GetXmax() ){
355  return h->Interpolate(energy);
356  }
357 
358  //Main use case is for PPFX smoothened weights.
359  //Return the weight in the last bin if the energy is larger than the range of the histogram
360  //Generalized for all BeamWeightFuncs and BeamSysts
361  if (energy > h->GetXaxis()->GetXmax())
362  return h->GetBinContent(h->GetNbinsX());
363 
364  return 1;
365  }
Near Detector underground.
Definition: SREnums.h:10
Far Detector at Ash River.
Definition: SREnums.h:11
caf::Proxy< bool > isRHC
Definition: SRProxy.h:537
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:525
OStream cerr
Definition: OStream.cxx:7
caf::Proxy< float > E
Definition: SRProxy.h:520
Loaders::FluxType flux
double energy
Definition: plottest35.C:25
caf::Proxy< short int > pdgorig
Definition: SRProxy.h:553
void InitializeHistograms() const
Definition: BeamSysts.cxx:245
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:33
def sign(x)
Definition: canMan.py:197
void ana::BeamSystOrWeightBase::InitializeHistograms ( ) const
protectedinherited

Definition at line 245 of file BeamSysts.cxx.

References om::cerr, fillBadChanDBTables::det, allTimeWatchdog::endl, ana::BeamSystOrWeightBase::fFileName, ana::BeamSystOrWeightBase::fHistName, ana::BeamSystOrWeightBase::fHistos, fin, flux, compareCafs::histName, ana::BeamSystOrWeightBase::kAntiNue, ana::BeamSystOrWeightBase::kAntiNumu, ana::BeamSystOrWeightBase::kFD, ana::BeamSystOrWeightBase::kFHC, ana::BeamSystOrWeightBase::kMinus, ana::BeamSystOrWeightBase::kND, ana::BeamSystOrWeightBase::kNue, ana::BeamSystOrWeightBase::kNumu, ana::BeamSystOrWeightBase::kPlus, ana::BeamSystOrWeightBase::kRHC, and canMan::sign().

Referenced by ana::BeamSystOrWeightBase::GetWeight().

246  {
247  // Already been called
248  if(fHistos[0][0][0][0]) return;
249 
250  //open file
251  TFile fin (fFileName.c_str(),"read");
252  if(fin.IsZombie()){
253  std::cerr << "Warning: couldn't open " << fFileName << std::endl;
254  return;
255  }
256 
257  //Check that desired systematic is in file
258  // Loop through the detector folder, over all histograms
259 
260  TIter iterHist(gDirectory->GetListOfKeys());
261  TKey* keyHist;
262  int foundHisto=0;
263  bool isSeparatedByFlavor = false;
264 
265  while((keyHist = (TKey*)iterHist())) {
266  TString histName = keyHist->GetName(); // Get a histogram name
267  if(histName.Contains(fHistName)){ //is it the desired syst
268  foundHisto++;
269 
270  int flux=0;
271  if(histName.Contains("FHC")) flux = kFHC;
272  if(histName.Contains("RHC")) flux = kRHC;
273 
274  int det = 0;
275  if(histName.Contains("ND")) det = kND;
276  if(histName.Contains("FD")) det = kFD;
277 
278  int sign = 0;
279  if(histName.Contains("minus")) sign = kMinus;
280  if(histName.Contains("plus" )) sign = kPlus;
281 
282  int flav = 0;
283  if(histName.Contains("numu")) flav = kNumu;
284  if(histName.Contains("nue")) flav = kNue;
285  if(histName.Contains("anumu")) flav = kAntiNumu;
286  if(histName.Contains("anue")) flav = kAntiNue;
287 
288  //store relevant histograms
289  fHistos[flux][det][sign][flav] = (TH1D*) fin.Get(histName)->Clone();
290  // disassociate it from the file it came from
291  fHistos[flux][det][sign][flav]->SetDirectory(0);
292  }
293  if(histName.Contains("numu")){
294  isSeparatedByFlavor=true;
295  }
296  }
297 
298  if (foundHisto==0) {
299  std::cerr << "Beam systematic histogram " << fHistName
300  << " is not in file " << fFileName <<"; aborting" << std::endl;
301  abort();
302  }
303 
304  if (!isSeparatedByFlavor) {
305  std::cerr << "Beam systematic "<< fHistName
306  << " doesn't have required flavor information; aborting"
307  << std::endl;
308  abort();
309  }
310  fin.Close();
311  }
TString fin
Definition: Style.C:24
OStream cerr
Definition: OStream.cxx:7
Loaders::FluxType flux
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:33
def sign(x)
Definition: canMan.py:197
double ana::BeamWeightFunc::operator() ( const caf::SRNeutrinoProxy sr) const

Definition at line 16 of file BeamSysts.cxx.

References ana::BeamSystOrWeightBase::GetWeight(), and ana::BeamSystOrWeightBase::kPlus.

17  {
18  // if (sr->mc.nnu != 1)
19  // return 1.;
20 
21  return GetWeight(sr, kPlus);
22  }
double GetWeight(const caf::SRNeutrinoProxy *nu, ESign sign) const
Definition: BeamSysts.cxx:314

Member Data Documentation

std::string ana::BeamSystOrWeightBase::fFileName
protectedinherited

Definition at line 30 of file BeamSysts.h.

Referenced by ana::BeamSystOrWeightBase::InitializeHistograms().

std::string ana::BeamSystOrWeightBase::fHistName
protectedinherited
TH1D* ana::BeamSystOrWeightBase::fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
mutableprotectedinherited

The documentation for this class was generated from the following files: