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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-24/CAFAna/Systs/BeamSysts.h"

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

Public Member Functions

 BeamSystOrWeightBase (const std::string &fname, const std::string &shortName)
 
 ~BeamSystOrWeightBase ()
 

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

Definition at line 14 of file BeamSysts.h.

Member Enumeration Documentation

anonymous enum
protected
anonymous enum
protected
Enumerator
kFHC 
kRHC 
kNumFluxType 

Definition at line 22 of file BeamSysts.h.

anonymous enum
protected
Enumerator
kND 
kFD 
kNumDets 

Definition at line 23 of file BeamSysts.h.

Enumerator
kMinus 
kPlus 
kNumSigns 

Definition at line 24 of file BeamSysts.h.

Constructor & Destructor Documentation

ana::BeamSystOrWeightBase::BeamSystOrWeightBase ( const std::string fname,
const std::string shortName 
)

Definition at line 259 of file BeamSysts.cxx.

262  {
263  }
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34
ana::BeamSystOrWeightBase::~BeamSystOrWeightBase ( )

Definition at line 266 of file BeamSysts.cxx.

References fHistos, MECModelEnuComparisons::i, calib::j, kNumDets, kNumFlavors, kNumFluxType, kNumSigns, and submit_hadd::l.

267  {
268  for(int l = 0; l < kNumFluxType; ++l){
269  for(int i = 0; i < kNumDets; ++i){
270  for(int j = 0; j < kNumSigns; ++j){
271  for(int k = 0; k < kNumFlavors; ++k){
272  delete fHistos[l][i][j][k];
273  fHistos[l][i][j][k] = 0;
274  }
275  }
276  }
277  }
278  }
const double j
Definition: BetheBloch.cxx:29
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34

Member Function Documentation

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

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, fHistName, fHistos, flux, make_syst_table_plots::h, InitializeHistograms(), caf::Proxy< caf::SRNeutrino >::isRHC, kAntiNue, kAntiNumu, caf::kFARDET, kFD, kFHC, kND, caf::kNEARDET, kNue, kNumu, kRHC, caf::Proxy< caf::SRNeutrino >::pdgorig, and canMan::sign().

Referenced by ana::BeamWeightFunc::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
protected

Definition at line 281 of file BeamSysts.cxx.

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

Referenced by 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

Member Data Documentation

std::string ana::BeamSystOrWeightBase::fFileName
protected

Definition at line 31 of file BeamSysts.h.

Referenced by InitializeHistograms().

std::string ana::BeamSystOrWeightBase::fHistName
protected

Definition at line 32 of file BeamSysts.h.

Referenced by GetWeight(), and InitializeHistograms().

TH1D* ana::BeamSystOrWeightBase::fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
mutableprotected

Definition at line 34 of file BeamSysts.h.

Referenced by GetWeight(), InitializeHistograms(), and ~BeamSystOrWeightBase().


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