#include <EnsembleCalibrationLA.h>
Classes | |
struct | MethodCalibrations |
Public Member Functions | |
void | analyze (const edm::Event &, const edm::EventSetup &) |
void | endJob () |
EnsembleCalibrationLA (const edm::ParameterSet &) | |
Private Member Functions | |
void | write_calibrations () const |
void | write_ensembles_plots (const Book &) const |
void | write_ensembles_text (const Book &) |
void | write_samples_plots (const Book &) const |
Private Attributes | |
std::map< std::string, MethodCalibrations > | calibrations |
const double | highBin |
const std::string | inFileLocation |
const std::vector< std::string > | inputFiles |
const double | lowBin |
const unsigned | maxEvents |
const unsigned | nbins |
const std::string | Prefix |
const unsigned | samples |
std::vector< int > | vMethods |
Definition at line 9 of file EnsembleCalibrationLA.h.
sistrip::EnsembleCalibrationLA::EnsembleCalibrationLA | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 12 of file EnsembleCalibrationLA.cc.
: inputFiles( conf.getParameter<std::vector<std::string> >("InputFiles") ), inFileLocation( conf.getParameter<std::string>("InFileLocation")), Prefix( conf.getUntrackedParameter<std::string>("Prefix","")), maxEvents( conf.getUntrackedParameter<unsigned>("MaxEvents",0)), samples( conf.getParameter<unsigned>("Samples")), nbins( conf.getParameter<unsigned>("NBins")), lowBin( conf.getParameter<double>("LowBin")), highBin( conf.getParameter<double>("HighBin")), vMethods( conf.getParameter<std::vector<int> >("Methods")) {}
void sistrip::EnsembleCalibrationLA::analyze | ( | const edm::Event & | , |
const edm::EventSetup & | |||
) | [inline, virtual] |
void sistrip::EnsembleCalibrationLA::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 25 of file EnsembleCalibrationLA.cc.
References mergeVDriftHistosByStation::file, LA_Filler_Fitter::fill(), LA_Filler_Fitter::fit(), highBin, inFileLocation, inputFiles, lowBin, maxEvents, PFRecoTauDiscriminationAgainstElectronMVA_cfi::method, nbins, samples, LA_Filler_Fitter::summarize_ensembles(), vMethods, write_calibrations(), write_ensembles_plots(), write_ensembles_text(), and write_samples_plots().
{ Book book("la_ensemble"); TChain*const chain = new TChain("la_ensemble"); BOOST_FOREACH(std::string file, inputFiles) chain->Add((file+inFileLocation).c_str()); int methods = 0; BOOST_FOREACH(unsigned method, vMethods) methods|=method; LA_Filler_Fitter laff(methods,samples,nbins,lowBin,highBin,maxEvents); laff.fill(chain,book); laff.fit(book); laff.summarize_ensembles(book); write_ensembles_text(book); write_ensembles_plots(book); write_samples_plots(book); write_calibrations(); }
void sistrip::EnsembleCalibrationLA::write_calibrations | ( | ) | const [private] |
Definition at line 103 of file EnsembleCalibrationLA.cc.
References calibrations, mergeVDriftHistosByStation::file, i, dbtoconf::out, and Prefix.
Referenced by endJob().
{ fstream file((Prefix+"calibrations.dat").c_str(),std::ios::out); std::pair<std::string,MethodCalibrations> cal; BOOST_FOREACH(cal,calibrations) { file << cal.first << std::endl << "\t slopes("; BOOST_FOREACH(float i, cal.second.slopes) file << i<< ","; file << ")" << std::endl << "\t offsets("; BOOST_FOREACH(float i, cal.second.offsets) file << i<< ","; file << ")" << std::endl << "\t pulls("; BOOST_FOREACH(float i, cal.second.pulls) file << i<< ","; file << ")" << std::endl; } file.close(); }
void sistrip::EnsembleCalibrationLA::write_ensembles_plots | ( | const Book & | book | ) | const [private] |
Definition at line 87 of file EnsembleCalibrationLA.cc.
References Book::begin(), Book::end(), mergeVDriftHistosByStation::file, estimatePileup::hist, and Prefix.
Referenced by endJob().
void sistrip::EnsembleCalibrationLA::write_ensembles_text | ( | const Book & | book | ) | [private] |
Definition at line 46 of file EnsembleCalibrationLA.cc.
References calibrations, gather_cfg::cout, LA_Filler_Fitter::ensemble_summary(), mergeVDriftHistosByStation::file, diffTreeTool::format(), getHLTprescales::index, label, LA_Filler_Fitter::layer_index(), geometryCSVtoXML::line, LA_Filler_Fitter::offset_slope(), dbtoconf::out, Prefix, LA_Filler_Fitter::pull(), summarizeEdmComparisonLogfiles::summary, and sistrip::TIB.
Referenced by endJob().
{ std::pair<std::string, std::vector<LA_Filler_Fitter::EnsembleSummary> > ensemble; BOOST_FOREACH(ensemble, LA_Filler_Fitter::ensemble_summary(book)) { fstream file((Prefix+ensemble.first+".dat").c_str(),std::ios::out); BOOST_FOREACH(LA_Filler_Fitter::EnsembleSummary summary, ensemble.second) file << summary << std::endl; const std::pair<std::pair<float,float>,std::pair<float,float> > line = LA_Filler_Fitter::offset_slope(ensemble.second); const float pull = LA_Filler_Fitter::pull(ensemble.second); unsigned index = 15; std::string label; { std::cout << ensemble.first << std::endl; boost::regex format(".*(T[IO]B)_layer(\\d)([as])_(.*)"); if(boost::regex_match(ensemble.first,format)) { const bool TIB = "TIB" == boost::regex_replace(ensemble.first, format, "\\1"); const bool stereo = "s" == boost::regex_replace(ensemble.first, format, "\\3"); const unsigned layer = boost::lexical_cast<unsigned>(boost::regex_replace(ensemble.first, format, "\\2")); label = boost::regex_replace(ensemble.first, format, "\\4"); index = LA_Filler_Fitter::layer_index(TIB,stereo,layer); calibrations[label].slopes[index]=line.second.first; calibrations[label].offsets[index]=line.first.first; calibrations[label].pulls[index]=pull; } } file << std::endl << std::endl << "# Best Fit Line: " << line.first.first <<"("<< line.first.second<<") + x* " << line.second.first<<"("<< line.second.second<<")" << std::endl << "# Pull (average sigma of (x_measure-x_truth)/e_measure): " << pull << std::endl << "LA_Calibration( METHOD_XXXXX , xxx, " << line.second.first << ", " << line.first.first << ", " << pull << ")," << std::endl; file.close(); } }
void sistrip::EnsembleCalibrationLA::write_samples_plots | ( | const Book & | book | ) | const [private] |
Definition at line 95 of file EnsembleCalibrationLA.cc.
References Book::begin(), Book::end(), mergeVDriftHistosByStation::file, estimatePileup::hist, and Prefix.
Referenced by endJob().
std::map<std::string,MethodCalibrations> sistrip::EnsembleCalibrationLA::calibrations [private] |
Definition at line 39 of file EnsembleCalibrationLA.h.
Referenced by write_calibrations(), and write_ensembles_text().
const double sistrip::EnsembleCalibrationLA::highBin [private] |
Definition at line 27 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const std::string sistrip::EnsembleCalibrationLA::inFileLocation [private] |
Definition at line 25 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const std::vector<std::string> sistrip::EnsembleCalibrationLA::inputFiles [private] |
Definition at line 24 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const double sistrip::EnsembleCalibrationLA::lowBin [private] |
Definition at line 27 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const unsigned sistrip::EnsembleCalibrationLA::maxEvents [private] |
Definition at line 26 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const unsigned sistrip::EnsembleCalibrationLA::nbins [private] |
Definition at line 26 of file EnsembleCalibrationLA.h.
Referenced by endJob().
const std::string sistrip::EnsembleCalibrationLA::Prefix [private] |
Definition at line 25 of file EnsembleCalibrationLA.h.
Referenced by write_calibrations(), write_ensembles_plots(), write_ensembles_text(), and write_samples_plots().
const unsigned sistrip::EnsembleCalibrationLA::samples [private] |
Definition at line 26 of file EnsembleCalibrationLA.h.
Referenced by endJob().
std::vector<int> sistrip::EnsembleCalibrationLA::vMethods [private] |
Definition at line 28 of file EnsembleCalibrationLA.h.
Referenced by endJob().