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

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

Public Member Functions

 CalibSyst ()=default
 
void LoadCalibSystRatios (std::string const &CalibFilename)
 
float CalibSystRatio (std::string const &systName, cmf::MetaData const &currentMD, double energy)
 

Public Attributes

std::map< std::string, std::vector< float > > fCalibSystRatios
 

Detailed Description

Definition at line 51 of file ShifterAndWeighter.h.

Constructor & Destructor Documentation

cmf::CalibSyst::CalibSyst ( )
default

Member Function Documentation

float cmf::CalibSyst::CalibSystRatio ( std::string const &  systName,
cmf::MetaData const &  currentMD,
double  energy 
)

Definition at line 301 of file ShifterAndWeighter.cxx.

References cmf::MetaData::BeamType(), bin, cmf::cBeamType_Strings, cmf::cSelectionType_Strings, cmf::MetaData::DetectorString(), cmf::CovarianceBinUtility::EnergyToBin(), cmf::CovarianceBinUtility::Instance(), LOG_WARNING, cmf::MetaData::selectionType, and string.

Referenced by cmf::ShifterAndWeighter::CalibSystWeight().

304  {
305  // use the metadata to figure out which ratios we need
306  std::string ratioName;
307 
308 #ifdef PRODUCTION5
309  ratioName = systName;
310  ratioName += "Total";
311  ratioName += cmf::cBeamType_Strings[currentMD.BeamType()];
312  ratioName += currentMD.DetectorString();
313  ratioName += cmf::cSelectionType_Strings[currentMD.selectionType];
314  ratioName += "Plus1Sigma";
315 #else
316  ratioName += currentMD.DetectorString();
317  ratioName += cmf::cBeamType_Strings[currentMD.BeamType()];
318  ratioName += cmf::cSelectionType_Strings[currentMD.selectionType];
319  ratioName += systName;
320 #endif
321 
322  // find the energy bin for this energy
324 
325  if(fCalibSystRatios.count(ratioName) < 1){
326  LOG_WARNING("CalibSystRatio")
327  << "requested calibration ratio for "
328  << ratioName
329  << " not found, returning 1";
330 
331  return 1;
332  }
333 
334  return fCalibSystRatios[ratioName][bin];
335  }
const std::string cSelectionType_Strings[12]
Definition: Constants.h:79
std::map< std::string, std::vector< float > > fCalibSystRatios
int EnergyToBin(double const &energy, cmf::MetaData const &md)
double energy
Definition: plottest35.C:25
float bin[41]
Definition: plottest35.C:14
#define LOG_WARNING(category)
const std::string cBeamType_Strings[4]
Definition: Constants.h:35
static CovarianceBinUtility * Instance()
enum BeamMode string
void cmf::CalibSyst::LoadCalibSystRatios ( std::string const &  CalibFilename)

Definition at line 177 of file ShifterAndWeighter.cxx.

References cmf::cBeamType_Strings, cmf::cDetType_Strings, cmf::cSelectionType_Strings, fin, cet::search_path::find_file(), MECModelEnuComparisons::i, cmf::SelectionUtility::Instance(), cmf::kNEARDET, cmf::kNuESelectionPeripheral, LOG_DEBUG, LOG_VERBATIM, LOG_WARNING, cmf::SelectionUtility::SelectionsToUse(), string, and systematics.

Referenced by cmf::ShifterAndWeighter::LoadCalibrationSystRatios().

178  {
179  // Someone already called us
180  if(!fCalibSystRatios.empty()) return;
181 
182  LOG_DEBUG("ShifterAndWeighter")
183  << "LoadCalibSystRatios";
184 
185  std::string fileCalib;
186 
187  LOG_DEBUG("ShifterAndWeighter")
188  << "Looking for calib syst file "
189  << CalibFilename;
190 
191  cet::search_path sp("FW_SEARCH_PATH");
192  if(!sp.find_file(CalibFilename, fileCalib)){
193  throw cet::exception("CalibSystematicFileError")
194  << "Cannot find calib systematics file "
195  << CalibFilename
196  << " bail ungracefully\n\n"
197  << __FILE__ << ":" << __LINE__;
198  }
199 
200  LOG_DEBUG("ShifterAndWeighter")
201  << "Found "
202  << CalibFilename
203  << " as "
204  << fileCalib;
205 
206  TFile fin(fileCalib.c_str(), "read");
207  if(fin.IsZombie()){
208  throw cet::exception("Weighters")
209  << "Warning: couldn't open "
210  << fileCalib
211  << ". Crashing";
212  }
213 
214  LOG_DEBUG("ShifterAndWeighter")
215  << "Opened file, apparently";
216 
217  // make some string collections with the combinations we need
218  // for the names of the histograms
219  auto const& dbs = cmf::SelectionUtility::Instance()->SelectionsToUse();
220 
221  std::vector<std::string> systematics;
222 
223 #ifdef PRODUCTION5
224  LOG_VERBATIM("p5") << __LINE__;
225  systematics.push_back("calibration");
226 #else
227  LOG_VERBATIM("p5") << __LINE__;
228  systematics.push_back("lightmodel-lightup-calibdown");
229  systematics.push_back("lightmodel-lightdown-calibup");
230  systematics.push_back("ckv-proton-shift-down");
231  systematics.push_back("calib-shift-xyview-pos-offset");
232  systematics.push_back("calib-shift-xyview-neg-offset");
233  systematics.push_back("calib-shift-func");
234 #endif
235 
236  std::string ratioName;
237  TH1D* ratioHist;
238  for(auto const& itr : dbs){
239  for(auto const& sel : itr.Selections()){
240 
241  if(itr.Detector() == cmf::kNEARDET &&
242  sel == cmf::kNuESelectionPeripheral) continue;
243 
244  for(auto const& syst : systematics){
245 
246 #ifdef PRODUCTION5
247  ratioName = syst;
248  ratioName += "Total";
249  ratioName += cmf::cBeamType_Strings[itr.BeamType()];
250  ratioName += cmf::cDetType_Strings[itr.Detector()];
251  ratioName += cmf::cSelectionType_Strings[sel];
252  ratioName += "Plus1Sigma";
253 
254  ratioHist = dynamic_cast<TH1D*>(fin.Get((ratioName).c_str()));
255 #else
256  ratioName = cmf::cDetType_Strings[itr.Detector()];
257  ratioName += cmf::cBeamType_Strings[itr.BeamType()];
258  ratioName += cmf::cSelectionType_Strings[sel];
259  ratioName += syst;
260 
261  // get the ratio from the TFile
262  ratioHist = dynamic_cast<TH1D*>(fin.Get((ratioName + "Ratio").c_str()));
263 #endif
264 
265  if(ratioHist == nullptr){
266  LOG_WARNING("CalibSyst")
267  << "failed to find "
268  << ratioName
269  << " in "
270  << fileCalib
271  << " try the next systematic ";
272 
273  continue;
274  } // end if the requested ratio is not there
275 
276  // loop over the histogram and put the ratios wrt nominal in
277  // the map
278  for(int i = 1; i < ratioHist->GetNbinsX() + 1; ++i){
279  fCalibSystRatios[ratioName].push_back(ratioHist->GetBinContent(i));
280 
281  // if(sel == selections.front() ||
282  // sel == selections.back() )
283  // LOG_VERBATIM("CalibSystRatios")
284  // << ratioName
285  // << " "
286  // << i
287  // << " "
288  // << ratioHist->GetBinCenter(i)
289  // << " "
290  // << fCalibSystRatios[ratioName].back();
291  }
292 
293  } // end loop over systematic names
294  } // end loop over selections
295  } // end loop over DetBeamSelSets
296 
297  LOG_DEBUG("CalibSyst") << "Calib histograms loaded!";
298  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TString fin
Definition: Style.C:24
const std::string cSelectionType_Strings[12]
Definition: Constants.h:79
static SelectionUtility * Instance()
std::map< std::string, std::vector< float > > fCalibSystRatios
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
#define LOG_WARNING(category)
bool systematics
Definition: fnexvscaf.C:31
const DetBeamSelSet & SelectionsToUse()
#define LOG_VERBATIM(category)
const std::string cDetType_Strings[5]
Definition: Constants.h:592
const std::string cBeamType_Strings[4]
Definition: Constants.h:35
enum BeamMode string

Member Data Documentation

std::map<std::string, std::vector<float> > cmf::CalibSyst::fCalibSystRatios

Definition at line 62 of file ShifterAndWeighter.h.


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