Public Member Functions | Public Attributes | List of all members
cmf::GeniePCASyst Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/CovarianceMatrixFit/core/ShifterAndWeighter.h"

Public Member Functions

 GeniePCASyst ()=default
 
void LoadGeniePCASystHists (std::string const &shortName)
 
std::map< float, float > CalcGeniePCASystWeights (cmf::MetaData const &currentMD, int mode, double energy)
 

Public Attributes

std::map< std::string, TH1D * > fGeniePCAHists
 

Detailed Description

Definition at line 66 of file ShifterAndWeighter.h.

Constructor & Destructor Documentation

cmf::GeniePCASyst::GeniePCASyst ( )
default

Member Function Documentation

std::map< float, float > cmf::GeniePCASyst::CalcGeniePCASystWeights ( cmf::MetaData const &  currentMD,
int  mode,
double  energy 
)

Definition at line 411 of file ShifterAndWeighter.cxx.

References cmf::MetaData::BeamType(), cmf::MetaData::detector, cmf::MetaData::interactionType, cmf::MetaData::IsNCSelected(), cmf::MetaData::IsNuESelected(), cmf::MetaData::IsNuMuSelected(), findDuplicateFiles::key, cmf::kFHC, cmf::kNC, cmf::kNEARDET, cmf::kNuECC, cmf::kNuMuCC, simb::kQE, and string.

414  {
416 
417  key = (currentMD.BeamType() == cmf::kFHC) ? "FHC" : "RHC";
418  key += (currentMD.detector == cmf::kNEARDET) ? "ND" : "FD";
419  if ( currentMD.IsNuMuSelected() ) key += "NumuSel";
420  else if( currentMD.IsNuESelected() ) key += "NueSel";
421  else if( currentMD.IsNCSelected() ) key += "NCSel";
422 
423  // if it's any of the interactions we're not interested in then just return 1
424  cmf::InteractionType_t interaction = currentMD.interactionType;
425 
426  if (currentMD.IsNuMuSelected() &&
427  interaction == cmf::kNuMuCC &&
428  mode == simb::kQE) key += "SigQE";
429  else if(currentMD.IsNuESelected() &&
430  interaction == cmf::kNuECC &&
431  mode == simb::kQE) key += "SigQE";
432  else if(currentMD.IsNuMuSelected() &&
433  interaction == cmf::kNuMuCC &&
434  mode != simb::kQE) key += "SigNonQE";
435  else if(currentMD.IsNuESelected() &&
436  interaction == cmf::kNuECC &&
437  mode != simb::kQE) key += "SigNonQE";
438  else if(interaction == cmf::kNC) key += "NC";
439  else key += "BkgFlav";
440 
441  // for some reason background histograms don't exist for numu so ignore these
442  if( fGeniePCAHists.count(key + "minus") < 1 ||
443  fGeniePCAHists.count(key + "plus") < 1)
444  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0} };
445 
446  // find the right histogram for the detector and sign
447  TH1D* hMinus = fGeniePCAHists[key + "minus"];
448  TH1D* hPlus = fGeniePCAHists[key + "plus" ];
449 
450  double scaleMinus = 1.;
451 
452  if(hMinus){
453  if(energy > hMinus->GetXaxis()->GetXmin() &&
454  energy < hMinus->GetXaxis()->GetXmax())
455  scaleMinus = hMinus->Interpolate(energy);
456  }
457 
458  double scalePlus = 1.;
459 
460  if(hPlus){
461  if(energy > hPlus->GetXaxis()->GetXmin() &&
462  energy < hPlus->GetXaxis()->GetXmax())
463  scalePlus = hPlus->Interpolate(energy);
464  }
465 
466  return { {-1.0, scaleMinus}, {0.0, 1.0}, {1.0, scalePlus} };
467  }
enum cmf::interaction_type InteractionType_t
std::map< std::string, TH1D * > fGeniePCAHists
double energy
Definition: plottest35.C:25
enum BeamMode string
void cmf::GeniePCASyst::LoadGeniePCASystHists ( std::string const &  shortName)

Definition at line 338 of file ShifterAndWeighter.cxx.

References fin, cet::search_path::find_file(), analysePickle::hist, compareCafs::histName, findDuplicateFiles::key, LOG_DEBUG, and string.

339  {
340  // Someone already called us
341  if(!fGeniePCAHists.empty()) return;
342 
343  const std::string kGeniePCASystFile = "CAFAna/data/xs/genie_small_pc_shifts_fn_2018.root";
344 
345  std::string fileGeniePCA;
346 
347  cet::search_path sp("FW_SEARCH_PATH");
348  if ( !sp.find_file(kGeniePCASystFile, fileGeniePCA) ) {
349  throw cet::exception("GeniePCASystematicFileError")
350  << "Cannot find Genie PCA systematics file "
351  << fileGeniePCA
352  << " bail ungracefully\n\n"
353  << __FILE__ << ":" << __LINE__;
354  }
355 
356  TFile fin(fileGeniePCA.c_str(), "read");
357  if (fin.IsZombie()){
358  throw cet::exception("Weighters")
359  << "Warning: couldn't open "
360  << fileGeniePCA
361  << ". Crashing!";
362  }
363 
364  //Check that desired systematic is in file
365  // Loop through the detector folder, over all histograms
366  TIter iterDir(gDirectory->GetListOfKeys());
367  TKey* keyDir;
368  int foundHist = 0;
369 
371 
372  while((keyDir = (TKey*)iterDir())) {
373  TString histName = keyDir->GetName();
374  if(histName.Contains(shortName)) {
375  foundHist++;
376 
377  key = (histName.Contains("FHC") ) ? "FHC" : "RHC";
378  key += (histName.Contains("ND") ) ? "ND" : "FD";
379  key += (histName.Contains("Numu") ) ? "NumuSel" : "NueSel";
380 
381  if (histName.Contains("SigQE" )) key += "SigQE";
382  else if(histName.Contains("SigNonQE")) key += "SigNonQE";
383  else if(histName.Contains("Other" )) key += "BkgFlav";
384  else if(histName.Contains("NC" )) key += "NC";
385 
386  key += (histName.Contains("minus")) ? "minus" : "plus";
387 
388  // grab relevant histogram
389  TH1D *hist = (TH1D*)fin.Get(histName)->Clone();
390 
391  if(hist) {
392  // store relevant histograms
394 
395  // disassociate from file
396  fGeniePCAHists[key]->SetDirectory(nullptr);
397  }
398  else {
399  throw cet::exception("Weighters")
400  << "Genie PCA histogram "
401  << histName
402  << " does not exist! Something has gone terribly wrong!";
403  } // end if statement checking hist exists
404  } // end hist name check
405  } // end while loop
406 
407  LOG_DEBUG("GeniePCASysts") << "Genie PCA histograms loaded!";
408  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TString fin
Definition: Style.C:24
std::map< std::string, TH1D * > fGeniePCAHists
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.
enum BeamMode string

Member Data Documentation

std::map<std::string, TH1D*> cmf::GeniePCASyst::fGeniePCAHists

Definition at line 75 of file ShifterAndWeighter.h.


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