Public Types | Public Member Functions | Public Attributes | List of all members
fnex::BeamSyst Class Reference

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

Public Types

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

Public Member Functions

 BeamSyst ()
 
 BeamSyst (std::string filename, std::string shortName)
 
void setFileAndHistNames (std::string filename, std::string shortName)
 
void LoadBeamSystHists ()
 
std::map< float, float > CalcBeamSystWeights (novadaq::cnv::DetId const &curDet, fnex::BeamType_t const &beamType, double energy, int pdgOrig)
 

Public Attributes

std::vector< std::vector< std::vector< std::vector< TH1D * > > > > fBeamSystHists
 
std::string fFileName
 
std::string fShortName
 

Detailed Description

Definition at line 35 of file ShifterAndWeighter.h.

Member Enumeration Documentation

anonymous enum
Enumerator
kFHC 
kRHC 
kNumFlux 

Definition at line 50 of file ShifterAndWeighter.h.

anonymous enum
Enumerator
kND 
kFD 
kNumDets 

Definition at line 51 of file ShifterAndWeighter.h.

anonymous enum
Enumerator
kMinus 
kPlus 
kNumSigns 

Definition at line 52 of file ShifterAndWeighter.h.

anonymous enum

Constructor & Destructor Documentation

fnex::BeamSyst::BeamSyst ( )

Definition at line 2113 of file ShifterAndWeighter.cxx.

2114  {
2115  //Default constructor, may need to zero some things
2116 
2117  }
fnex::BeamSyst::BeamSyst ( std::string  filename,
std::string  shortName 
)

Definition at line 2119 of file ShifterAndWeighter.cxx.

References fFileName, plotROC::fileName, and galleryMaker::shortName.

2120  {
2123  }
fileName
Definition: plotROC.py:78
std::string fFileName
std::string fShortName
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.

Member Function Documentation

std::map< float, float > fnex::BeamSyst::CalcBeamSystWeights ( novadaq::cnv::DetId const &  curDet,
fnex::BeamType_t const &  beamType,
double  energy,
int  pdgOrig 
)

Definition at line 2215 of file ShifterAndWeighter.cxx.

References fillBadChanDBTables::det, GetXaxis(), plot_timing_data::horn, ana::DecompType::kAntiNue, ana::DecompType::kAntiNumu, novadaq::cnv::kFARDET, fnex::kFHC, novadaq::cnv::kNEARDET, fc::kNue, fc::kNumu, fnex::kRHC, LOG_VERBATIM, LOG_WARNING, scale, and canMan::sign().

Referenced by fnex::ShifterAndWeighter::BeamSystWeight(), and fnex::ShifterAndWeighter::PPFXSmoothCVWeight().

2216  {
2217  // Need different histogram per detector, don't bother doing
2218  // anything if we have a bogus detector
2219  int det = kNumDets;
2220  if(curDet == novadaq::cnv::kNEARDET)
2221  det = kND;
2222  else if(curDet == novadaq::cnv::kFARDET)
2223  det = kFD;
2224  else{
2225  LOG_VERBATIM("BeamSystFileError")
2226  << "Wrong detector; ignore";
2227  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0} };
2228  }
2229 
2230 
2231  //Find the neutrino flavor
2232  int flav = 0;
2233  switch(pdgOrig){
2234  case 14: flav = kNumu; break;
2235  case 12: flav = kNue; break;
2236  case -14: flav = kAntiNumu; break;
2237  case -12: flav = kAntiNue; break;
2238  case 13:
2239  //Cosmic muon
2240  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0} };
2241  default:
2242  LOG_WARNING("BeamSystFileError")
2243  << "Wrong nu flavor; "
2244  << pdgOrig
2245  << " ignore";
2246 
2247  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0}};
2248  }
2249 
2250  // Need different histogram per horn current
2251  int horn = kNumFlux;
2252  if(beamType == fnex::kFHC)
2253  horn = kFHC;
2254  else if(beamType == fnex::kRHC)
2255  horn = kRHC;
2256  else{
2257  LOG_VERBATIM("BeamSystFileError")
2258  << "Wrong horn type: "
2259  << beamType
2260  << "; ignore";
2261 
2262  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0} };
2263  }
2264 
2265  //Find the right histogram for the detector and sign
2266  double scale[2] = {1, 1};
2267  TH1D* hPlusMinus[2] = {0};
2268  for(int sign = kMinus; sign < kNumSigns; ++sign){
2269  hPlusMinus[sign] = fBeamSystHists[horn][det][sign][flav];
2270 
2271  if(hPlusMinus[sign] == 0){
2272  LOG_WARNING("BeamSystFileError")
2273  << ": Can't find desired histogram; ignore";
2274  return { {-1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0} };
2275  }
2276 
2277  //Only use weights if the energy is in the range of the histogram
2278  else if (energy > hPlusMinus[sign]->GetXaxis()->GetXmin() &&
2279  energy < hPlusMinus[sign]->GetXaxis()->GetXmax() ){
2280  scale[sign] = hPlusMinus[sign]->Interpolate(energy);
2281  }
2282  }
2283 
2284  return { {-1.0, scale[kMinus]}, {0.0, 1.0}, {1.0, scale[kPlus]} };
2285  } // std::map<double, double> BeamSystWeightFn::CalcWeights(const fnex::Event&)
Double_t scale
Definition: plot.C:25
Far Detector at Ash River, MN.
std::vector< std::vector< std::vector< std::vector< TH1D * > > > > fBeamSystHists
correl_xv GetXaxis() -> SetDecimals()
double energy
Definition: plottest35.C:25
Near Detector in the NuMI cavern.
#define LOG_WARNING(category)
#define LOG_VERBATIM(category)
def sign(x)
Definition: canMan.py:197
void fnex::BeamSyst::LoadBeamSystHists ( )

Definition at line 2133 of file ShifterAndWeighter.cxx.

References d, fillBadChanDBTables::det, fFileName, fin, make_syst_table_plots::h, compareCafs::histName, plot_timing_data::horn, ana::DecompType::kAntiNue, ana::DecompType::kAntiNumu, fnex::kFHC, fc::kNue, fc::kNumu, fnex::kRHC, LOG_WARNING, and canMan::sign().

Referenced by fnex::ShifterAndWeighter::LoadBeamSystHists2017(), fnex::ShifterAndWeighter::LoadFluxBeamSystHists(), and fnex::ShifterAndWeighter::LoadSABeamSystHists().

2134  {
2135  // Someone already called us
2136  if(!fBeamSystHists.empty()) return;
2137 
2138  fBeamSystHists.resize(kNumFlux);
2139  for(size_t h = 0; h < fBeamSystHists.size(); ++h){
2140  fBeamSystHists[h].resize(kNumDets);
2141  for(size_t d = 0; d < fBeamSystHists[h].size(); ++d){
2142  fBeamSystHists[h][d].resize(kNumSigns);
2143  for(size_t pm = 0; pm < fBeamSystHists[h][d].size(); ++pm){
2144  fBeamSystHists[h][d][pm].resize(kNumFlavors);
2145  }
2146  }
2147  }
2148 
2149  //open file
2150  TFile fin (fFileName.c_str(),"read");
2151  if(fin.IsZombie()){
2152  LOG_WARNING("ShifterAndWeighter")
2153  << "Warning: couldn't open beam systematic file "
2154  << fFileName;
2155  return;
2156  }
2157 
2158  //Check that desired systematic is in file
2159  // Loop through the detector folder, over all histograms
2160  TIter iterHist(gDirectory->GetListOfKeys());
2161  TKey* keyHist;
2162  int foundHisto = 0;
2163  bool isSeparatedByFlavor = false;
2164 
2165  while((keyHist = (TKey*)iterHist())) {
2166  TString histName = keyHist->GetName(); // Get a histogram name
2167  if(histName.Contains(fShortName)){ //is it the desired syst
2168  ++foundHisto;
2169 
2170  int horn = 0;
2171  if(histName.Contains("FHC")) horn = kFHC;
2172  if(histName.Contains("RHC")) horn = kRHC;
2173 
2174  int det = 0;
2175  if(histName.Contains("ND")) det = kND;
2176  if(histName.Contains("FD")) det = kFD;
2177 
2178  int sign = 0;
2179  if(histName.Contains("minus")) sign = kMinus;
2180  if(histName.Contains("plus" )) sign = kPlus;
2181 
2182  int flav = 0;
2183  if(histName.Contains("numu" )) flav = kNumu;
2184  if(histName.Contains("nue" )) flav = kNue;
2185  if(histName.Contains("anumu")) flav = kAntiNumu;
2186  if(histName.Contains("anue" )) flav = kAntiNue;
2187 
2188  //store relevant histograms
2189  fBeamSystHists[horn][det][sign][flav] = (TH1D*) fin.Get(histName)->Clone();
2190  // disassociate it from the file it came from
2191  fBeamSystHists[horn][det][sign][flav]->SetDirectory(0);
2192  }
2193  if(histName.Contains("numu")){
2194  isSeparatedByFlavor=true;
2195  }
2196  }
2197 
2198  if (foundHisto == 0) {
2199  throw cet::exception("BeamSystFileError")
2200  << "Beam systematic "
2201  << fShortName
2202  << " is not in this file";
2203  }
2204 
2205  if (!isSeparatedByFlavor) {
2206  throw cet::exception("BeamSystFileError")
2207  << "Beam systematic "
2208  << fShortName
2209  << " doesn't have required flavor information";
2210  }
2211  fin.Close();
2212  }
TString fin
Definition: Style.C:24
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::string fFileName
std::vector< std::vector< std::vector< std::vector< TH1D * > > > > fBeamSystHists
Float_t d
Definition: plot.C:236
#define LOG_WARNING(category)
std::string fShortName
def sign(x)
Definition: canMan.py:197
void fnex::BeamSyst::setFileAndHistNames ( std::string  filename,
std::string  shortName 
)

Definition at line 2126 of file ShifterAndWeighter.cxx.

References fFileName, plotROC::fileName, and galleryMaker::shortName.

Referenced by fnex::ShifterAndWeighter::LoadBeamSystHists2017(), fnex::ShifterAndWeighter::LoadFluxBeamSystHists(), and fnex::ShifterAndWeighter::LoadSABeamSystHists().

2127  {
2130  }
fileName
Definition: plotROC.py:78
std::string fFileName
std::string fShortName
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.

Member Data Documentation

std::vector< std::vector< std::vector< std::vector<TH1D*> > > > fnex::BeamSyst::fBeamSystHists
std::string fnex::BeamSyst::fFileName

Definition at line 47 of file ShifterAndWeighter.h.

std::string fnex::BeamSyst::fShortName

Definition at line 48 of file ShifterAndWeighter.h.


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