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/N21-03-08/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 55 of file BeamSysts.h.

Member Enumeration Documentation

anonymous enum
protectedinherited
anonymous enum
protectedinherited
Enumerator
kFHC 
kRHC 
kNumFluxType 

Definition at line 22 of file BeamSysts.h.

anonymous enum
protectedinherited
Enumerator
kND 
kFD 
kNumDets 

Definition at line 23 of file BeamSysts.h.

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

Definition at line 24 of file BeamSysts.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file BeamSysts.h.

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

Referenced by ana::GetPPFXFluxUnivWgtSmooth_NT().

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

Member Function Documentation

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

Definition at line 350 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().

352  {
354 
355  int flux = kFHC;
356  if(nu->isRHC) flux = kRHC;
357 
358  // Need different histogram per detector
359  int det = 0;
360  switch (nu->det)
361  {
362  case caf::kNEARDET : det = kND; break;
363  case caf::kFARDET : det = kFD; break;
364  default: std::cerr <<"Wrong detector; ignore" << std::endl; return 1;
365  }
366 
367  //Set the different weights for p/m sigma and neutrino flavor/energy
368 
369  double energy = nu->E; // True neutrino energy
370 
371  //Find the neutrino flavor
372  int flav = 0;
373  switch(nu->pdgorig)
374  {
375  case 14: flav = kNumu; break;
376  case 12: flav = kNue; break;
377  case -14: flav = kAntiNumu; break;
378  case -12: flav = kAntiNue; break;
379  default: std::cerr << "Wrong nu flavor; ignore" << std::endl; return 1;
380  }
381 
382  //Find the right histogram for the detector and sign
383  TH1D* h = fHistos[flux][det][sign][flav];
384  if (h == 0){
385  std::cerr << fHistName+": Can't find desired histogram; ignore"<< std:: endl;
386  return 1;
387  }
388  //Only use weights if the energy is in the range of the histogram
389  if (energy > h->GetXaxis()->GetXmin() &&
390  energy < h->GetXaxis()->GetXmax() ){
391  return h->Interpolate(energy);
392  }
393 
394  //Main use case is for PPFX smoothened weights.
395  //Return the weight in the last bin if the energy is larger than the range of the histogram
396  //Generalized for all BeamWeightFuncs and BeamSysts
397  if (energy > h->GetXaxis()->GetXmax())
398  return h->GetBinContent(h->GetNbinsX());
399 
400  return 1;
401  }
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:281
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34
def sign(x)
Definition: canMan.py:197
void ana::BeamSystOrWeightBase::InitializeHistograms ( ) const
protectedinherited

Definition at line 281 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().

282  {
283  // Already been called
284  if(fHistos[0][0][0][0]) return;
285 
286  //open file
287  TFile fin (fFileName.c_str(),"read");
288  if(fin.IsZombie()){
289  std::cerr << "Warning: couldn't open " << fFileName << std::endl;
290  return;
291  }
292 
293  //Check that desired systematic is in file
294  // Loop through the detector folder, over all histograms
295 
296  TIter iterHist(gDirectory->GetListOfKeys());
297  TKey* keyHist;
298  int foundHisto=0;
299  bool isSeparatedByFlavor = false;
300 
301  while((keyHist = (TKey*)iterHist())) {
302  TString histName = keyHist->GetName(); // Get a histogram name
303  if(histName.Contains(fHistName)){ //is it the desired syst
304  foundHisto++;
305 
306  int flux=0;
307  if(histName.Contains("FHC")) flux = kFHC;
308  if(histName.Contains("RHC")) flux = kRHC;
309 
310  int det = 0;
311  if(histName.Contains("ND")) det = kND;
312  if(histName.Contains("FD")) det = kFD;
313 
314  int sign = 0;
315  if(histName.Contains("minus")) sign = kMinus;
316  if(histName.Contains("plus" )) sign = kPlus;
317 
318  int flav = 0;
319  if(histName.Contains("numu")) flav = kNumu;
320  if(histName.Contains("nue")) flav = kNue;
321  if(histName.Contains("anumu")) flav = kAntiNumu;
322  if(histName.Contains("anue")) flav = kAntiNue;
323 
324  //store relevant histograms
325  fHistos[flux][det][sign][flav] = (TH1D*) fin.Get(histName)->Clone();
326  // disassociate it from the file it came from
327  fHistos[flux][det][sign][flav]->SetDirectory(0);
328  }
329  if(histName.Contains("numu")){
330  isSeparatedByFlavor=true;
331  }
332  }
333 
334  if (foundHisto==0) {
335  std::cerr << "Beam systematic histogram " << fHistName
336  << " is not in file " << fFileName <<"; aborting" << std::endl;
337  abort();
338  }
339 
340  if (!isSeparatedByFlavor) {
341  std::cerr << "Beam systematic "<< fHistName
342  << " doesn't have required flavor information; aborting"
343  << std::endl;
344  abort();
345  }
346  fin.Close();
347  }
TString fin
Definition: Style.C:24
OStream cerr
Definition: OStream.cxx:7
Loaders::FluxType flux
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34
def sign(x)
Definition: canMan.py:197
double ana::BeamWeightFunc::operator() ( const caf::SRNeutrinoProxy sr) const

Definition at line 23 of file BeamSysts.cxx.

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

24  {
25  // if (sr->mc.nnu != 1)
26  // return 1.;
27 
28  return GetWeight(sr, kPlus);
29  }
double GetWeight(const caf::SRNeutrinoProxy *nu, ESign sign) const
Definition: BeamSysts.cxx:350

Member Data Documentation

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

Definition at line 31 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: