CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
sistrip::EnsembleCalibrationLA Class Reference

#include <EnsembleCalibrationLA.h>

Inheritance diagram for sistrip::EnsembleCalibrationLA:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  MethodCalibrations
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
void endJob ()
 
 EnsembleCalibrationLA (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 9 of file EnsembleCalibrationLA.h.

Constructor & Destructor Documentation

sistrip::EnsembleCalibrationLA::EnsembleCalibrationLA ( const edm::ParameterSet conf)
explicit

Definition at line 12 of file EnsembleCalibrationLA.cc.

12  :
13  inputFiles( conf.getParameter<std::vector<std::string> >("InputFiles") ),
14  inFileLocation( conf.getParameter<std::string>("InFileLocation")),
15  Prefix( conf.getUntrackedParameter<std::string>("Prefix","")),
16  maxEvents( conf.getUntrackedParameter<unsigned>("MaxEvents",0)),
17  samples( conf.getParameter<unsigned>("Samples")),
18  nbins( conf.getParameter<unsigned>("NBins")),
19  lowBin( conf.getParameter<double>("LowBin")),
20  highBin( conf.getParameter<double>("HighBin")),
21  vMethods( conf.getParameter<std::vector<int> >("Methods"))
22 {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > inputFiles

Member Function Documentation

void sistrip::EnsembleCalibrationLA::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlinevirtual

Implements edm::EDAnalyzer.

Definition at line 14 of file EnsembleCalibrationLA.h.

14 {}
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, PFRecoTauDiscriminationAgainstElectronMVA2_cfi::method, nbins, samples, AlCaHLTBitMon_QueryRunRegistry::string, LA_Filler_Fitter::summarize_ensembles(), vMethods, write_calibrations(), write_ensembles_plots(), write_ensembles_text(), and write_samples_plots().

26 {
27  Book book("la_ensemble");
28  TChain*const chain = new TChain("la_ensemble");
29  BOOST_FOREACH(std::string file, inputFiles) chain->Add((file+inFileLocation).c_str());
30 
31  int methods = 0; BOOST_FOREACH(unsigned method, vMethods) methods|=method;
32 
34  laff(methods,samples,nbins,lowBin,highBin,maxEvents);
35  laff.fill(chain,book);
36  laff.fit(book);
37  laff.summarize_ensembles(book);
38 
41  write_samples_plots(book);
43 }
string fill
Definition: lumiContext.py:319
void write_ensembles_plots(const Book &) const
const std::vector< std::string > inputFiles
void write_samples_plots(const Book &) const
Definition: Book.h:16
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().

103  {
104  fstream file((Prefix+"calibrations.dat").c_str(),std::ios::out);
105  std::pair<std::string,MethodCalibrations> cal;
106  BOOST_FOREACH(cal,calibrations) {
107  file << cal.first << std::endl
108  << "\t slopes("; BOOST_FOREACH(float i, cal.second.slopes) file << i<< ","; file << ")" << std::endl
109  << "\t offsets("; BOOST_FOREACH(float i, cal.second.offsets) file << i<< ","; file << ")" << std::endl
110  << "\t pulls("; BOOST_FOREACH(float i, cal.second.pulls) file << i<< ","; file << ")" << std::endl;
111  }
112  file.close();
113 }
std::map< std::string, MethodCalibrations > calibrations
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
tuple out
Definition: dbtoconf.py:99
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().

87  {
88  TFile file((Prefix+"sampleFits.root").c_str(),"RECREATE");
89  for(Book::const_iterator hist = book.begin(".*(profile|ratio|reconstruction|symm|symmchi2|_w\\d)"); hist!=book.end(); ++hist)
90  hist->second->Write();
91  file.Close();
92 }
iterator begin(string_t re=".*")
Definition: Book.h:48
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
Definition: Book.h:47
iterator end(string_t re=".*")
Definition: Book.h:50
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, cfg-viewer::format(), getHLTprescales::index, diffTwoXMLs::label, LA_Filler_Fitter::layer_index(), geometryCSVtoXML::line, LA_Filler_Fitter::offset_slope(), dbtoconf::out, Prefix, LA_Filler_Fitter::pull(), AlCaHLTBitMon_QueryRunRegistry::string, edmLumisInFiles::summary, and sistrip::TIB.

Referenced by endJob().

46  {
47  std::pair<std::string, std::vector<LA_Filler_Fitter::EnsembleSummary> > ensemble;
48  BOOST_FOREACH(ensemble, LA_Filler_Fitter::ensemble_summary(book)) {
49  fstream file((Prefix+ensemble.first+".dat").c_str(),std::ios::out);
50  BOOST_FOREACH(LA_Filler_Fitter::EnsembleSummary summary, ensemble.second)
51  file << summary << std::endl;
52 
53  const std::pair<std::pair<float,float>,std::pair<float,float> > line = LA_Filler_Fitter::offset_slope(ensemble.second);
54  const float pull = LA_Filler_Fitter::pull(ensemble.second);
55 
56  unsigned index = 15;
57  std::string label;
58  {
59  std::cout << ensemble.first << std::endl;
60  boost::regex format(".*(T[IO]B)_layer(\\d)([as])_(.*)");
61  if(boost::regex_match(ensemble.first,format)) {
62  const bool TIB = "TIB" == boost::regex_replace(ensemble.first, format, "\\1");
63  const bool stereo = "s" == boost::regex_replace(ensemble.first, format, "\\3");
64  const unsigned layer = boost::lexical_cast<unsigned>(boost::regex_replace(ensemble.first, format, "\\2"));
65  label = boost::regex_replace(ensemble.first, format, "\\4");
66  index = LA_Filler_Fitter::layer_index(TIB,stereo,layer);
67 
68  calibrations[label].slopes[index]=line.second.first;
69  calibrations[label].offsets[index]=line.first.first;
70  calibrations[label].pulls[index]=pull;
71  }
72  }
73 
74  file << std::endl << std::endl
75  << "# Best Fit Line: "
76  << line.first.first <<"("<< line.first.second<<") + x* "
77  << line.second.first<<"("<< line.second.second<<")"
78  << std::endl
79  << "# Pull (average sigma of (x_measure-x_truth)/e_measure): " << pull
80  << std::endl
81  << "LA_Calibration( METHOD_XXXXX , xxx, " << line.second.first << ", " << line.first.first << ", " << pull << ")," << std::endl;
82  file.close();
83  }
84 }
std::map< std::string, MethodCalibrations > calibrations
static unsigned layer_index(bool TIB, bool stereo, unsigned layer)
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
Definition: LA_Results.cc:105
U second(std::pair< T, U > const &p)
tuple out
Definition: dbtoconf.py:99
string const
Definition: compareJSON.py:14
tuple cout
Definition: gather_cfg.py:121
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().

95  {
96  TFile file((Prefix+"ensembleFits.root").c_str(),"RECREATE");
97  for(Book::const_iterator hist = book.begin(".*(measure|merr|ensembleReco|pull)"); hist!=book.end(); ++hist)
98  hist->second->Write();
99  file.Close();
100 }
iterator begin(string_t re=".*")
Definition: Book.h:48
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
Definition: Book.h:47
iterator end(string_t re=".*")
Definition: Book.h:50

Member Data Documentation

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(), and VarParsing.VarParsing::parseArguments().

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
const std::string sistrip::EnsembleCalibrationLA::Prefix
private
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().