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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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::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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 12 of file EnsembleCalibrationLA.cc.

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  tTopoToken_(esConsumes<edm::Transition::EndRun>()) {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 13 of file EnsembleCalibrationLA.h.

13 {}

◆ endJob()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 24 of file EnsembleCalibrationLA.cc.

24  {
25  Book book("la_ensemble");
26  TChain* const chain = new TChain("la_ensemble");
27  for (auto const& file : inputFiles)
28  chain->Add((file + inFileLocation).c_str());
29 
30  int methods = 0;
31  for (unsigned int method : vMethods)
32  methods |= method;
33 
35  laff.fill(chain, book);
36  laff.fit(book);
37  laff.summarize_ensembles(book);
38 
41  write_samples_plots(book);
43  }

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

◆ endRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 45 of file EnsembleCalibrationLA.cc.

45  {
46  tTopo_ = &eSetup.getData(tTopoToken_);
47  }

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

◆ write_calibrations()

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

Definition at line 104 of file EnsembleCalibrationLA.cc.

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

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

Referenced by endJob().

◆ write_ensembles_plots()

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

Definition at line 88 of file EnsembleCalibrationLA.cc.

88  {
89  TFile file((Prefix + "sampleFits.root").c_str(), "RECREATE");
90  for (Book::const_iterator hist = book.begin(".*(profile|ratio|reconstruction|symm|symmchi2|_w\\d)");
91  hist != book.end();
92  ++hist)
93  hist->second->Write();
94  file.Close();
95  }

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

Referenced by endJob().

◆ write_ensembles_text()

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

Definition at line 49 of file EnsembleCalibrationLA.cc.

49  {
50  for (auto const& ensemble : LA_Filler_Fitter::ensemble_summary(book)) {
51  std::fstream file((Prefix + ensemble.first + ".dat").c_str(), std::ios::out);
52  for (auto const& summary : ensemble.second)
53  file << summary << std::endl;
54 
55  const std::pair<std::pair<float, float>, std::pair<float, float> > line =
56  LA_Filler_Fitter::offset_slope(ensemble.second);
57  const float pull = LA_Filler_Fitter::pull(ensemble.second);
58 
59  unsigned index = 15;
61  {
62  std::cout << ensemble.first << std::endl;
63  std::regex format(".*(T[IO]B)_layer(\\d)([as])_(.*)");
64  if (std::regex_match(ensemble.first, format)) {
65  const bool TIB = "TIB" == std::regex_replace(ensemble.first, format, "\\1");
66  const bool stereo = "s" == std::regex_replace(ensemble.first, format, "\\3");
67  const unsigned layer = boost::lexical_cast<unsigned>(std::regex_replace(ensemble.first, format, "\\2"));
68  label = std::regex_replace(ensemble.first, format, "\\4");
69  index = LA_Filler_Fitter::layer_index(TIB, stereo, layer);
70 
71  calibrations[label].slopes[index] = line.second.first;
72  calibrations[label].offsets[index] = line.first.first;
73  calibrations[label].pulls[index] = pull;
74  }
75  }
76 
77  file << std::endl
78  << std::endl
79  << "# Best Fit Line: " << line.first.first << "(" << line.first.second << ") + x* " << line.second.first
80  << "(" << line.second.second << ")" << std::endl
81  << "# Pull (average sigma of (x_measure-x_truth)/e_measure): " << pull << std::endl
82  << "LA_Calibration( METHOD_XXXXX , xxx, " << line.second.first << ", " << line.first.first << ", " << pull
83  << ")," << std::endl;
84  file.close();
85  }
86  }

References calibrations, gather_cfg::cout, LA_Filler_Fitter::ensemble_summary(), FrontierConditions_GlobalTag_cff::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().

◆ write_samples_plots()

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

Definition at line 97 of file EnsembleCalibrationLA.cc.

97  {
98  TFile file((Prefix + "ensembleFits.root").c_str(), "RECREATE");
99  for (Book::const_iterator hist = book.begin(".*(measure|merr|ensembleReco|pull)"); hist != book.end(); ++hist)
100  hist->second->Write();
101  file.Close();
102  }

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

Referenced by endJob().

Member Data Documentation

◆ calibrations

std::map<std::string, MethodCalibrations> sistrip::EnsembleCalibrationLA::calibrations
private

Definition at line 36 of file EnsembleCalibrationLA.h.

Referenced by write_calibrations(), and write_ensembles_text().

◆ highBin

const double sistrip::EnsembleCalibrationLA::highBin
private

Definition at line 26 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ inFileLocation

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

Definition at line 24 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ inputFiles

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

Definition at line 23 of file EnsembleCalibrationLA.h.

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

◆ lowBin

const double sistrip::EnsembleCalibrationLA::lowBin
private

Definition at line 26 of file EnsembleCalibrationLA.h.

Referenced by endJob().

◆ maxEvents

const unsigned sistrip::EnsembleCalibrationLA::maxEvents
private

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

Referenced by endJob().

◆ tTopo_

const TrackerTopology* sistrip::EnsembleCalibrationLA::tTopo_
private

Definition at line 39 of file EnsembleCalibrationLA.h.

Referenced by endJob(), and endRun().

◆ tTopoToken_

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

Definition at line 38 of file EnsembleCalibrationLA.h.

Referenced by endRun().

◆ vMethods

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

Definition at line 27 of file EnsembleCalibrationLA.h.

Referenced by endJob().

sistrip::EnsembleCalibrationLA::calibrations
std::map< std::string, MethodCalibrations > calibrations
Definition: EnsembleCalibrationLA.h:36
LA_Filler_Fitter::offset_slope
static std::pair< std::pair< float, float >, std::pair< float, float > > offset_slope(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:145
mps_fire.i
i
Definition: mps_fire.py:428
sistrip::EnsembleCalibrationLA::nbins
const unsigned nbins
Definition: EnsembleCalibrationLA.h:25
gather_cfg.cout
cout
Definition: gather_cfg.py:144
AlcaSiPixelAliHarvester0T_cff.method
method
Definition: AlcaSiPixelAliHarvester0T_cff.py:41
Book::const_iterator
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
Definition: Book.h:56
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
sistrip::EnsembleCalibrationLA::write_calibrations
void write_calibrations() const
Definition: EnsembleCalibrationLA.cc:104
sistrip::EnsembleCalibrationLA::write_ensembles_text
void write_ensembles_text(const Book &)
Definition: EnsembleCalibrationLA.cc:49
Book
Definition: Book.h:16
sistrip::EnsembleCalibrationLA::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: EnsembleCalibrationLA.h:38
sistrip::EnsembleCalibrationLA::maxEvents
const unsigned maxEvents
Definition: EnsembleCalibrationLA.h:25
sistrip::EnsembleCalibrationLA::write_ensembles_plots
void write_ensembles_plots(const Book &) const
Definition: EnsembleCalibrationLA.cc:88
compare.hist
hist
Definition: compare.py:376
sistrip::TIB
Definition: ConstantsForGranularity.h:66
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
Book::end
iterator end(string_t re=".*")
Definition: Book.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
sistrip::EnsembleCalibrationLA::vMethods
std::vector< int > vMethods
Definition: EnsembleCalibrationLA.h:27
LA_Filler_Fitter::layer_index
static unsigned layer_index(bool TIB, bool stereo, unsigned layer)
Definition: LA_Filler_Fitter.h:105
sistrip::EnsembleCalibrationLA::write_samples_plots
void write_samples_plots(const Book &) const
Definition: EnsembleCalibrationLA.cc:97
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
LA_Filler_Fitter::pull
static float pull(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:169
sistrip::EnsembleCalibrationLA::Prefix
const std::string Prefix
Definition: EnsembleCalibrationLA.h:24
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
Book::begin
iterator begin(string_t re=".*")
Definition: Book.h:57
LA_Filler_Fitter::ensemble_summary
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
Definition: LA_Results.cc:116
format
sistrip::EnsembleCalibrationLA::lowBin
const double lowBin
Definition: EnsembleCalibrationLA.h:26
LA_Filler_Fitter
Definition: LA_Filler_Fitter.h:14
sistrip::EnsembleCalibrationLA::highBin
const double highBin
Definition: EnsembleCalibrationLA.h:26
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
sistrip::EnsembleCalibrationLA::inFileLocation
const std::string inFileLocation
Definition: EnsembleCalibrationLA.h:24
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
sistrip::EnsembleCalibrationLA::inputFiles
const std::vector< std::string > inputFiles
Definition: EnsembleCalibrationLA.h:23
mps_splice.line
line
Definition: mps_splice.py:76
label
const char * label
Definition: PFTauDecayModeTools.cc:11
chain
Definition: chain.py:1
sistrip::EnsembleCalibrationLA::samples
const unsigned samples
Definition: EnsembleCalibrationLA.h:25
sistrip::EnsembleCalibrationLA::tTopo_
const TrackerTopology * tTopo_
Definition: EnsembleCalibrationLA.h:39