CMS 3D CMS Logo

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 &) override
 
void endJob () override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
 EnsembleCalibrationLA (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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, MethodCalibrationscalibrations
 
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
 
const TrackerTopologytTopo_
 
std::vector< int > vMethods
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
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 13 of file EnsembleCalibrationLA.cc.

13  :
14  inputFiles( conf.getParameter<std::vector<std::string> >("InputFiles") ),
15  inFileLocation( conf.getParameter<std::string>("InFileLocation")),
16  Prefix( conf.getUntrackedParameter<std::string>("Prefix","")),
17  maxEvents( conf.getUntrackedParameter<unsigned>("MaxEvents",0)),
18  samples( conf.getParameter<unsigned>("Samples")),
19  nbins( conf.getParameter<unsigned>("NBins")),
20  lowBin( conf.getParameter<double>("LowBin")),
21  highBin( conf.getParameter<double>("HighBin")),
22  vMethods( conf.getParameter<std::vector<int> >("Methods"))
23 {}
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  
)
inlineoverride
void sistrip::EnsembleCalibrationLA::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 25 of file EnsembleCalibrationLA.cc.

References FrontierConditions_GlobalTag_cff::file, LA_Filler_Fitter::fill(), LA_Filler_Fitter::fit(), highBin, inFileLocation, inputFiles, lowBin, maxEvents, AlcaSiPixelAliHarvester0T_cff::method, nbins, samples, LA_Filler_Fitter::summarize_ensembles(), tTopo_, vMethods, write_calibrations(), write_ensembles_plots(), write_ensembles_text(), and write_samples_plots().

Referenced by analyze(), and o2olib.O2ORunMgr::executeJob().

26 {
27  Book book("la_ensemble");
28  TChain*const chain = new TChain("la_ensemble");
29  for(auto const& file : inputFiles) chain->Add((file+inFileLocation).c_str());
30 
31  int methods = 0;
32  for(unsigned int method : vMethods) methods|=method;
33 
35  laff.fill(chain,book);
36  laff.fit(book);
37  laff.summarize_ensembles(book);
38 
41  write_samples_plots(book);
43 }
Definition: chain.py:1
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::endRun ( const edm::Run ,
const edm::EventSetup eSetup 
)
override

Definition at line 45 of file EnsembleCalibrationLA.cc.

References edm::EventSetup::get(), edm::ESHandle< T >::product(), and tTopo_.

Referenced by analyze().

46 {
48  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
49  tTopo_ = tTopoHandle.product();
50 }
T get() const
Definition: EventSetup.h:68
T const * product() const
Definition: ESHandle.h:84
void sistrip::EnsembleCalibrationLA::write_calibrations ( ) const
private

Definition at line 109 of file EnsembleCalibrationLA.cc.

References calibrations, FrontierConditions_GlobalTag_cff::file, mps_fire::i, MillePedeFileConverter_cfg::out, and Prefix.

Referenced by analyze(), endJob(), and write_samples_plots().

109  {
110  std::fstream file((Prefix+"calibrations.dat").c_str(),std::ios::out);
111  for(auto const& cal : calibrations) {
112  file << cal.first << std::endl
113  << "\t slopes("; for(float i : cal.second.slopes) file << i<< ","; file << ")" << std::endl
114  << "\t offsets("; for(float i : cal.second.offsets) file << i<< ","; file << ")" << std::endl
115  << "\t pulls("; for(float i : cal.second.pulls) file << i<< ","; file << ")" << std::endl;
116  }
117  file.close();
118 }
std::map< std::string, MethodCalibrations > calibrations
void sistrip::EnsembleCalibrationLA::write_ensembles_plots ( const Book book) const
private

Definition at line 93 of file EnsembleCalibrationLA.cc.

References Book::begin(), Book::end(), FrontierConditions_GlobalTag_cff::file, create_public_lumi_plots::hist, Prefix, and write_samples_plots().

Referenced by analyze(), endJob(), and write_ensembles_text().

93  {
94  TFile file((Prefix+"sampleFits.root").c_str(),"RECREATE");
95  for(Book::const_iterator hist = book.begin(".*(profile|ratio|reconstruction|symm|symmchi2|_w\\d)"); hist!=book.end(); ++hist)
96  hist->second->Write();
97  file.Close();
98 }
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 52 of file EnsembleCalibrationLA.cc.

References calibrations, gather_cfg::cout, LA_Filler_Fitter::ensemble_summary(), FrontierConditions_GlobalTag_cff::file, cmsPerfStripChart::format, label, LA_Filler_Fitter::layer_index(), mps_splice::line, LA_Filler_Fitter::offset_slope(), MillePedeFileConverter_cfg::out, Prefix, LA_Filler_Fitter::pull(), AlCaHLTBitMon_QueryRunRegistry::string, heppy_report::summary, sistrip::TIB, and write_ensembles_plots().

Referenced by analyze(), and endJob().

53 {
54  for(auto const& ensemble : LA_Filler_Fitter::ensemble_summary(book)) {
55  std::fstream file((Prefix+ensemble.first+".dat").c_str(),std::ios::out);
56  for(auto const& summary : ensemble.second)
57  file << summary << std::endl;
58 
59  const std::pair<std::pair<float,float>,std::pair<float,float> > line = LA_Filler_Fitter::offset_slope(ensemble.second);
60  const float pull = LA_Filler_Fitter::pull(ensemble.second);
61 
62  unsigned index = 15;
64  {
65  std::cout << ensemble.first << std::endl;
66  boost::regex format(".*(T[IO]B)_layer(\\d)([as])_(.*)");
67  if(boost::regex_match(ensemble.first,format)) {
68  const bool TIB = "TIB" == boost::regex_replace(ensemble.first, format, "\\1");
69  const bool stereo = "s" == boost::regex_replace(ensemble.first, format, "\\3");
70  const unsigned layer = boost::lexical_cast<unsigned>(boost::regex_replace(ensemble.first, format, "\\2"));
71  label = boost::regex_replace(ensemble.first, format, "\\4");
72  index = LA_Filler_Fitter::layer_index(TIB,stereo,layer);
73 
74  calibrations[label].slopes[index]=line.second.first;
75  calibrations[label].offsets[index]=line.first.first;
76  calibrations[label].pulls[index]=pull;
77  }
78  }
79 
80  file << std::endl << std::endl
81  << "# Best Fit Line: "
82  << line.first.first <<"("<< line.first.second<<") + x* "
83  << line.second.first<<"("<< line.second.second<<")"
84  << std::endl
85  << "# Pull (average sigma of (x_measure-x_truth)/e_measure): " << pull
86  << std::endl
87  << "LA_Calibration( METHOD_XXXXX , xxx, " << line.second.first << ", " << line.first.first << ", " << pull << ")," << std::endl;
88  file.close();
89  }
90 }
std::map< std::string, MethodCalibrations > calibrations
static unsigned layer_index(bool TIB, bool stereo, unsigned layer)
static std::pair< std::pair< float, float >, std::pair< float, float > > offset_slope(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:131
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
Definition: LA_Results.cc:106
char const * label
format
Some error handling for the usage.
static float pull(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:155
void sistrip::EnsembleCalibrationLA::write_samples_plots ( const Book book) const
private

Definition at line 101 of file EnsembleCalibrationLA.cc.

References Book::begin(), Book::end(), FrontierConditions_GlobalTag_cff::file, create_public_lumi_plots::hist, Prefix, and write_calibrations().

Referenced by analyze(), endJob(), and write_ensembles_plots().

101  {
102  TFile file((Prefix+"ensembleFits.root").c_str(),"RECREATE");
103  for(Book::const_iterator hist = book.begin(".*(measure|merr|ensembleReco|pull)"); hist!=book.end(); ++hist)
104  hist->second->Write();
105  file.Close();
106 }
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 40 of file EnsembleCalibrationLA.h.

Referenced by write_calibrations(), and write_ensembles_text().

const double sistrip::EnsembleCalibrationLA::highBin
private

Definition at line 28 of file EnsembleCalibrationLA.h.

Referenced by endJob().

const std::string sistrip::EnsembleCalibrationLA::inFileLocation
private

Definition at line 26 of file EnsembleCalibrationLA.h.

Referenced by endJob().

const std::vector<std::string> sistrip::EnsembleCalibrationLA::inputFiles
private

Definition at line 25 of file EnsembleCalibrationLA.h.

Referenced by endJob(), and VarParsing.VarParsing::parseArguments().

const double sistrip::EnsembleCalibrationLA::lowBin
private

Definition at line 28 of file EnsembleCalibrationLA.h.

Referenced by endJob().

const unsigned sistrip::EnsembleCalibrationLA::maxEvents
private

Definition at line 27 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 27 of file EnsembleCalibrationLA.h.

Referenced by endJob().

const TrackerTopology* sistrip::EnsembleCalibrationLA::tTopo_
private

Definition at line 42 of file EnsembleCalibrationLA.h.

Referenced by endJob(), and endRun().

std::vector<int> sistrip::EnsembleCalibrationLA::vMethods
private

Definition at line 29 of file EnsembleCalibrationLA.h.

Referenced by endJob().