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::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  MethodCalibrations
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob () override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
 EnsembleCalibrationLA (const edm::ParameterSet &)
 
 ~EnsembleCalibrationLA () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
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_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken_
 
std::vector< int > vMethods
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 10 of file EnsembleCalibrationLA.h.

Constructor & Destructor Documentation

◆ EnsembleCalibrationLA()

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

Definition at line 11 of file EnsembleCalibrationLA.cc.

12  : inputFiles(conf.getParameter<std::vector<std::string> >("InputFiles")),
13  inFileLocation(conf.getParameter<std::string>("InFileLocation")),
14  Prefix(conf.getUntrackedParameter<std::string>("Prefix", "")),
15  maxEvents(conf.getUntrackedParameter<unsigned>("MaxEvents", 0)),
16  samples(conf.getParameter<unsigned>("Samples")),
17  nbins(conf.getParameter<unsigned>("NBins")),
18  lowBin(conf.getParameter<double>("LowBin")),
19  highBin(conf.getParameter<double>("HighBin")),
20  vMethods(conf.getParameter<std::vector<int> >("Methods")),
21  tTopoToken_(esConsumes<edm::Transition::EndRun>()) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > inputFiles

◆ ~EnsembleCalibrationLA()

sistrip::EnsembleCalibrationLA::~EnsembleCalibrationLA ( )
override

Definition at line 23 of file EnsembleCalibrationLA.cc.

23 {};

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 13 of file EnsembleCalibrationLA.h.

13 {}

◆ beginRun()

void sistrip::EnsembleCalibrationLA::beginRun ( const edm::Run ,
const edm::EventSetup eSetup 
)
override

Definition at line 46 of file EnsembleCalibrationLA.cc.

46 {}

◆ endJob()

void sistrip::EnsembleCalibrationLA::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 25 of file EnsembleCalibrationLA.cc.

References geometryDiff::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 o2olib.O2ORunMgr::executeJob().

25  {
26  Book book("la_ensemble");
27  TChain* const chain = new TChain("la_ensemble");
28  for (auto const& file : inputFiles)
29  chain->Add((file + inFileLocation).c_str());
30 
31  int methods = 0;
32  for (unsigned int method : vMethods)
33  methods |= method;
34 
36  laff.fill(chain, book);
37  laff.fit(book);
38  laff.summarize_ensembles(book);
39 
42  write_samples_plots(book);
44  }
const std::vector< std::string > inputFiles
void write_samples_plots(const Book &) const
Definition: Book.h:16
void write_ensembles_plots(const Book &) const

◆ endRun()

void sistrip::EnsembleCalibrationLA::endRun ( const edm::Run ,
const edm::EventSetup eSetup 
)
override

Definition at line 48 of file EnsembleCalibrationLA.cc.

References edm::EventSetup::getData(), tTopo_, and tTopoToken_.

48  {
49  tTopo_ = &eSetup.getData(tTopoToken_);
50  }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_

◆ write_calibrations()

void sistrip::EnsembleCalibrationLA::write_calibrations ( ) const
private

Definition at line 107 of file EnsembleCalibrationLA.cc.

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

Referenced by endJob().

107  {
108  std::fstream file((Prefix + "calibrations.dat").c_str(), std::ios::out);
109  for (auto const& cal : calibrations) {
110  file << cal.first << std::endl << "\t slopes(";
111  for (float i : cal.second.slopes)
112  file << i << ",";
113  file << ")" << std::endl << "\t offsets(";
114  for (float i : cal.second.offsets)
115  file << i << ",";
116  file << ")" << std::endl << "\t pulls(";
117  for (float i : cal.second.pulls)
118  file << i << ",";
119  file << ")" << std::endl;
120  }
121  file.close();
122  }
std::map< std::string, MethodCalibrations > calibrations

◆ write_ensembles_plots()

void sistrip::EnsembleCalibrationLA::write_ensembles_plots ( const Book book) const
private

Definition at line 91 of file EnsembleCalibrationLA.cc.

References Book::begin(), Book::end(), geometryDiff::file, compareTotals::hist, and Prefix.

Referenced by endJob().

91  {
92  TFile file((Prefix + "sampleFits.root").c_str(), "RECREATE");
93  for (Book::const_iterator hist = book.begin(".*(profile|ratio|reconstruction|symm|symmchi2|_w\\d)");
94  hist != book.end();
95  ++hist)
96  hist->second->Write();
97  file.Close();
98  }
iterator begin(string_t re=".*")
Definition: Book.h:57
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
Definition: Book.h:56
iterator end(string_t re=".*")
Definition: Book.h:65

◆ write_ensembles_text()

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(), geometryDiff::file, dqm-mbProfile::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, edmLumisInFiles::summary, and sistrip::TIB.

Referenced by endJob().

52  {
53  for (auto const& ensemble : LA_Filler_Fitter::ensemble_summary(book)) {
54  std::fstream file((Prefix + ensemble.first + ".dat").c_str(), std::ios::out);
55  for (auto const& summary : ensemble.second)
56  file << summary << std::endl;
57 
58  const std::pair<std::pair<float, float>, std::pair<float, float> > line =
59  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  std::regex format(".*(T[IO]B)_layer(\\d)([as])_(.*)");
67  if (std::regex_match(ensemble.first, format)) {
68  const bool TIB = "TIB" == std::regex_replace(ensemble.first, format, "\\1");
69  const bool stereo = "s" == std::regex_replace(ensemble.first, format, "\\3");
70  const unsigned layer = std::stoul(std::regex_replace(ensemble.first, format, "\\2"));
71  label = std::regex_replace(ensemble.first, format, "\\4");
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
81  << std::endl
82  << "# Best Fit Line: " << line.first.first << "(" << line.first.second << ") + x* " << line.second.first
83  << "(" << line.second.second << ")" << std::endl
84  << "# Pull (average sigma of (x_measure-x_truth)/e_measure): " << pull << std::endl
85  << "LA_Calibration( METHOD_XXXXX , xxx, " << line.second.first << ", " << line.first.first << ", " << pull
86  << ")," << std::endl;
87  file.close();
88  }
89  }
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:143
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
Definition: LA_Results.cc:114
char const * label
static float pull(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:167

◆ write_samples_plots()

void sistrip::EnsembleCalibrationLA::write_samples_plots ( const Book book) const
private

Definition at line 100 of file EnsembleCalibrationLA.cc.

References Book::begin(), Book::end(), geometryDiff::file, compareTotals::hist, and Prefix.

Referenced by endJob().

100  {
101  TFile file((Prefix + "ensembleFits.root").c_str(), "RECREATE");
102  for (Book::const_iterator hist = book.begin(".*(measure|merr|ensembleReco|pull)"); hist != book.end(); ++hist)
103  hist->second->Write();
104  file.Close();
105  }
iterator begin(string_t re=".*")
Definition: Book.h:57
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
Definition: Book.h:56
iterator end(string_t re=".*")
Definition: Book.h:65

Member Data Documentation

◆ calibrations

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().

◆ highBin

const double sistrip::EnsembleCalibrationLA::highBin
private

Definition at line 29 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ inFileLocation

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

Definition at line 27 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ inputFiles

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

◆ lowBin

const double sistrip::EnsembleCalibrationLA::lowBin
private

Definition at line 29 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ maxEvents

const unsigned sistrip::EnsembleCalibrationLA::maxEvents
private

Definition at line 28 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ nbins

const unsigned sistrip::EnsembleCalibrationLA::nbins
private

◆ Prefix

const std::string sistrip::EnsembleCalibrationLA::Prefix
private

◆ samples

const unsigned sistrip::EnsembleCalibrationLA::samples
private

Definition at line 28 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ tTopo_

const TrackerTopology* sistrip::EnsembleCalibrationLA::tTopo_
private

Definition at line 42 of file EnsembleCalibrationLA.h.

Referenced by endJob(), and endRun().

◆ tTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> sistrip::EnsembleCalibrationLA::tTopoToken_
private

Definition at line 41 of file EnsembleCalibrationLA.h.

Referenced by endRun().

◆ vMethods

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

Definition at line 30 of file EnsembleCalibrationLA.h.

Referenced by endJob().