CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
AlcaBeamMonitorClient Class Reference

#include <AlcaBeamMonitorClient.h>

Inheritance diagram for AlcaBeamMonitorClient:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 AlcaBeamMonitorClient (const edm::ParameterSet &)
 
 ~AlcaBeamMonitorClient () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (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
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void beginJob (void) override
 
void beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override
 
void endLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
 
void endRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override
 
- 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 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)
 

Private Types

typedef std::map< std::string, std::map< std::string, std::map< std::string, MonitorElement * > > > HistosContainer
 
typedef std::map< std::string, std::map< std::string, std::map< std::string, int > > > PositionContainer
 

Private Attributes

DQMStoredbe_
 
std::multimap< std::string, std::string > histoByCategoryNames_
 
HistosContainer histosMap_
 
std::string monitorName_
 
int numberOfValuesToSave_
 
edm::ParameterSet parameters_
 
PositionContainer positionsMap_
 
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_
 
std::vector< std::string > varNamesV_
 

Additional Inherited Members

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

Detailed Description

Definition at line 23 of file AlcaBeamMonitorClient.h.

Member Typedef Documentation

Definition at line 26 of file AlcaBeamMonitorClient.h.

typedef std::map<std::string, std::map<std::string, std::map<std::string, MonitorElement*> > > AlcaBeamMonitorClient::HistosContainer
private

Definition at line 40 of file AlcaBeamMonitorClient.h.

Definition at line 25 of file AlcaBeamMonitorClient.h.

typedef std::map<std::string, std::map<std::string, std::map<std::string, int> > > AlcaBeamMonitorClient::PositionContainer
private

Definition at line 43 of file AlcaBeamMonitorClient.h.

Constructor & Destructor Documentation

AlcaBeamMonitorClient::AlcaBeamMonitorClient ( const edm::ParameterSet ps)

Definition at line 24 of file AlcaBeamMonitorClient.cc.

References dbe_, histoByCategoryNames_, histosMap_, monitorName_, numberOfValuesToSave_, Utilities::operator, positionsMap_, and varNamesV_.

25  : parameters_(ps),
26  monitorName_(parameters_.getUntrackedParameter<string>("MonitorName", "YourSubsystemName")),
29 
30  if (!monitorName_.empty())
31  monitorName_ = monitorName_ + "/";
32 
33  varNamesV_.push_back("x");
34  varNamesV_.push_back("y");
35  varNamesV_.push_back("z");
36  varNamesV_.push_back("sigmaX");
37  varNamesV_.push_back("sigmaY");
38  varNamesV_.push_back("sigmaZ");
39 
40  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotFit"));
41  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex"));
42  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased DataBase"));
43  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased Scalers"));
44  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
45  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
46  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased Scalers-DataBase fit"));
47  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-DataBase"));
48  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-Scalers"));
49 
50  for (vector<string>::iterator itV = varNamesV_.begin(); itV != varNamesV_.end(); itV++) {
51  for (multimap<string, string>::iterator itM = histoByCategoryNames_.begin(); itM != histoByCategoryNames_.end();
52  itM++) {
53  histosMap_[*itV][itM->first][itM->second] = nullptr;
54  positionsMap_[*itV][itM->first][itM->second] = 3 * numberOfValuesToSave_; // value, error, ok
56  }
57  }
58 }
T getUntrackedParameter(std::string const &, T const &) const
PositionContainer positionsMap_
std::multimap< std::string, std::string > histoByCategoryNames_
edm::ParameterSet parameters_
std::vector< std::string > varNamesV_
AlcaBeamMonitorClient::~AlcaBeamMonitorClient ( )
override

Definition at line 60 of file AlcaBeamMonitorClient.cc.

60 {}

Member Function Documentation

void AlcaBeamMonitorClient::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 71 of file AlcaBeamMonitorClient.cc.

71 {}
void AlcaBeamMonitorClient::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 63 of file AlcaBeamMonitorClient.cc.

63 {}
void AlcaBeamMonitorClient::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 66 of file AlcaBeamMonitorClient.cc.

66 {}
void AlcaBeamMonitorClient::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 74 of file AlcaBeamMonitorClient.cc.

References dbe_, dqm::dqmstoreimpl::DQMStore::get(), dqm::legacy::MonitorElement::getTProfile(), mps_fire::i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), monitorName_, numberOfValuesToSave_, createJobs::tmp, and valuesMap_.

74  {
75  MonitorElement* tmp = nullptr;
76  tmp = dbe_->get(monitorName_ + "Service/hHistoLumiValues");
77  if (!tmp) {
78  return;
79  }
80  valuesMap_[iLumi.id().luminosityBlock()] = vector<double>();
81  for (int i = 0; i < 3 * numberOfValuesToSave_; i++) {
82  valuesMap_[iLumi.id().luminosityBlock()].push_back(tmp->getTProfile()->GetBinContent(i + 1));
83  }
84 }
LuminosityBlockID id() const
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_
virtual TProfile * getTProfile() const
LuminosityBlockNumber_t luminosityBlock() const
tmp
align.sh
Definition: createJobs.py:716
void AlcaBeamMonitorClient::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 87 of file AlcaBeamMonitorClient.cc.

References newFWLiteAna::bin, dqm::dqmstoreimpl::DQMStore::book1D(), dbe_, DEFINE_FWK_MODULE, dqmdumpme::first, histosMap_, edm::RunBase::id(), genParticles_cff::map, SiStripPI::max, allConversions_cfi::maxDelta, min(), monitorName_, Skims_PA_cff::name, positionsMap_, edm::RunID::run(), edm::second(), dqm::dqmstoreimpl::DQMStore::setCurrentFolder(), dqm::impl::MonitorElement::setEfficiencyFlag(), AlCaHLTBitMon_QueryRunRegistry::string, overlapproblemtsosanalyzer_cfi::title, and valuesMap_.

87  {
88  // use this in case any LS is missing.
89  if (valuesMap_.empty()) {
90  LogInfo("AlcaBeamMonitorClient") << "The histogram "
91  << monitorName_ +
92  "Service/hHistoLumiValues which contains all the values has not "
93  "been found in any lumi!";
94  return;
95  }
96  int lastLumi = (--valuesMap_.end())->first;
97  int firstLumi = valuesMap_.begin()->first;
98 
99  // create and cd into new folder
100  dbe_->setCurrentFolder(monitorName_ + "Validation");
101 
102  LogInfo("AlcaBeamMonitorClient") << "End of run " << iRun.id().run() << "(" << firstLumi << "-" << lastLumi << ")";
103 
104  string name;
105  string title;
106  // x,y,z,sigmaX,sigmaY,sigmaZ
107  for (HistosContainer::iterator itM = histosMap_.begin(); itM != histosMap_.end(); itM++) {
108  for (map<string, map<string, MonitorElement*> >::iterator itMM = itM->second.begin(); itMM != itM->second.end();
109  itMM++) {
110  if (itMM->first != "run") {
111  for (map<string, MonitorElement*>::iterator itMMM = itMM->second.begin(); itMMM != itMM->second.end();
112  itMMM++) {
113  name = string("h") + itM->first + itMMM->first;
114  title = itM->first + "_{0} " + itMMM->first;
115  if (itMM->first == "lumi") {
116  dbe_->setCurrentFolder(monitorName_ + "Debug");
117  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1, firstLumi - 0.5, lastLumi + 0.5);
118  itMMM->second->setEfficiencyFlag();
119  } else if (itMM->first == "validation" && itMMM->first == "Lumibased Scalers-DataBase fit") {
120  dbe_->setCurrentFolder(monitorName_ + "Validation");
121  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1, firstLumi - 0.5, lastLumi + 0.5);
122  itMMM->second->setEfficiencyFlag();
123  } else if (itMM->first == "validation" && itMMM->first != "Lumibased Scalers-DataBase fit" &&
124  (itM->first == "x" || itM->first == "y" || itM->first == "z")) {
125  dbe_->setCurrentFolder(monitorName_ + "Validation");
126  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1, firstLumi - 0.5, lastLumi + 0.5);
127  itMMM->second->setEfficiencyFlag();
128  } else if (itMM->first == "validation" &&
129  (itM->first == "sigmaX" || itM->first == "sigmaY" || itM->first == "sigmaZ")) {
130  dbe_->setCurrentFolder(monitorName_ + "Validation");
131  itMMM->second = nullptr;
132  } else {
133  LogInfo("AlcaBeamMonitorClient") << "Unrecognized category " << itMM->first;
134  // assert(0);
135  }
136  if (itMMM->second != nullptr) {
137  if (itMMM->first.find('-') != string::npos) {
138  itMMM->second->setAxisTitle(string("#Delta ") + itM->first + "_{0} (cm)", 2);
139  } else {
140  itMMM->second->setAxisTitle(itM->first + "_{0} (cm)", 2);
141  }
142  itMMM->second->setAxisTitle("Lumisection", 1);
143  }
144  }
145  }
146  }
147  }
148 
149  unsigned int bin = 0;
150  for (HistosContainer::iterator itH = histosMap_.begin(); itH != histosMap_.end(); itH++) {
151  for (map<string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
152  itHH++) {
153  for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end(); itHHH++) {
154  for (map<LuminosityBlockNumber_t, vector<double> >::iterator itVal = valuesMap_.begin();
155  itVal != valuesMap_.end();
156  itVal++) {
157  if (itHHH->second != nullptr) {
158  // cout << positionsMap_[itH->first][itHH->first][itHHH->first]
159  //<< endl;
160  if (itVal->second[positionsMap_[itH->first][itHH->first][itHHH->first] + 2] == 1) {
161  bin = itHHH->second->getTH1()->FindBin(itVal->first);
162  itHHH->second->setBinContent(bin, itVal->second[positionsMap_[itH->first][itHH->first][itHHH->first]]);
163  itHHH->second->setBinError(bin, itVal->second[positionsMap_[itH->first][itHH->first][itHHH->first] + 1]);
164  }
165  }
166  }
167  }
168  }
169  }
170 
171 
172  const double bigNumber = 1000000.;
173  for (HistosContainer::iterator itH = histosMap_.begin(); itH != histosMap_.end(); itH++) {
174  for (map<string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
175  itHH++) {
176  double min = bigNumber;
177  double max = -bigNumber;
178  double minDelta = bigNumber;
179  double maxDelta = -bigNumber;
180  // double minDeltaProf = bigNumber;
181  // double maxDeltaProf = -bigNumber;
182  if (itHH->first != "run") {
183  for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
184  itHHH++) {
185  if (itHHH->second != nullptr) {
186  for (int bin = 1; bin <= itHHH->second->getTH1()->GetNbinsX(); bin++) {
187  if (itHHH->second->getTH1()->GetBinError(bin) != 0 || itHHH->second->getTH1()->GetBinContent(bin) != 0) {
188  if (itHHH->first == "Lumibased BeamSpotFit" || itHHH->first == "Lumibased PrimaryVertex" ||
189  itHHH->first == "Lumibased DataBase" || itHHH->first == "Lumibased Scalers") {
190  if (min > itHHH->second->getTH1()->GetBinContent(bin)) {
191  min = itHHH->second->getTH1()->GetBinContent(bin);
192  }
193  if (max < itHHH->second->getTH1()->GetBinContent(bin)) {
194  max = itHHH->second->getTH1()->GetBinContent(bin);
195  }
196  } else if (itHHH->first == "Lumibased PrimaryVertex-DataBase fit" ||
197  itHHH->first == "Lumibased PrimaryVertex-Scalers fit" ||
198  itHHH->first == "Lumibased Scalers-DataBase fit" ||
199  itHHH->first == "Lumibased PrimaryVertex-DataBase" ||
200  itHHH->first == "Lumibased PrimaryVertex-Scalers") {
201  if (minDelta > itHHH->second->getTH1()->GetBinContent(bin)) {
202  minDelta = itHHH->second->getTH1()->GetBinContent(bin);
203  }
204  if (maxDelta < itHHH->second->getTH1()->GetBinContent(bin)) {
205  maxDelta = itHHH->second->getTH1()->GetBinContent(bin);
206  }
207  } else {
208  LogInfo("AlcaBeamMonitorClient") << "The histosMap_ have a histogram named " << itHHH->first
209  << " that I can't recognize in this loop!";
210  // assert(0);
211  }
212  }
213  }
214  }
215  }
216  for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
217  itHHH++) {
218  if (itHHH->second != nullptr) {
219  if (itHHH->first == "Lumibased BeamSpotFit" || itHHH->first == "Lumibased PrimaryVertex" ||
220  itHHH->first == "Lumibased DataBase" || itHHH->first == "Lumibased Scalers") {
221  if ((max == -bigNumber && min == bigNumber) || max - min == 0) {
222  itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
223  itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
224  } else {
225  itHHH->second->getTH1()->SetMinimum(min - 0.1 * (max - min));
226  itHHH->second->getTH1()->SetMaximum(max + 0.1 * (max - min));
227  }
228  } else if (itHHH->first == "Lumibased PrimaryVertex-DataBase fit" ||
229  itHHH->first == "Lumibased PrimaryVertex-Scalers fit" ||
230  itHHH->first == "Lumibased Scalers-DataBase fit" ||
231  itHHH->first == "Lumibased PrimaryVertex-DataBase" ||
232  itHHH->first == "Lumibased PrimaryVertex-Scalers") {
233  if ((maxDelta == -bigNumber && minDelta == bigNumber) || maxDelta - minDelta == 0) {
234  itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
235  itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
236  } else {
237  itHHH->second->getTH1()->SetMinimum(minDelta - 2 * (maxDelta - minDelta));
238  itHHH->second->getTH1()->SetMaximum(maxDelta + 2 * (maxDelta - minDelta));
239  }
240  } else {
241  LogInfo("AlcaBeamMonitorClient") << "The histosMap_ have a histogram named " << itHHH->first
242  << " that I can't recognize in this loop!";
243  }
244  }
245  }
246  }
247  }
248  }
249 
250 }
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:36
PositionContainer positionsMap_
unsigned int LuminosityBlockNumber_t
U second(std::pair< T, U > const &p)
T min(T a, T b)
Definition: MathUtil.h:58
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1121

Member Data Documentation

DQMStore* AlcaBeamMonitorClient::dbe_
private

Definition at line 51 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), endLuminosityBlock(), and endRun().

std::multimap<std::string, std::string> AlcaBeamMonitorClient::histoByCategoryNames_
private

Definition at line 56 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient().

HistosContainer AlcaBeamMonitorClient::histosMap_
private

Definition at line 54 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endRun().

std::string AlcaBeamMonitorClient::monitorName_
private

Definition at line 47 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), endLuminosityBlock(), and endRun().

int AlcaBeamMonitorClient::numberOfValuesToSave_
private

Definition at line 50 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endLuminosityBlock().

edm::ParameterSet AlcaBeamMonitorClient::parameters_
private
PositionContainer AlcaBeamMonitorClient::positionsMap_
private

Definition at line 58 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endRun().

std::map<edm::LuminosityBlockNumber_t, std::vector<double> > AlcaBeamMonitorClient::valuesMap_
private

Definition at line 57 of file AlcaBeamMonitorClient.h.

Referenced by endLuminosityBlock(), and endRun().

std::vector<std::string> AlcaBeamMonitorClient::varNamesV_
private

Definition at line 55 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient().