CMS 3D CMS Logo

List of all members | 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 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
 
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)
 

Protected Member Functions

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

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

Detailed Description

Definition at line 24 of file AlcaBeamMonitorClient.h.

Member Typedef Documentation

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

Definition at line 41 of file AlcaBeamMonitorClient.h.

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

Definition at line 44 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),
27  "MonitorName", "YourSubsystemName")),
30 
31  if (monitorName_ != "") 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(
41  pair<string, string>("lumi", "Lumibased BeamSpotFit"));
42  histoByCategoryNames_.insert(
43  pair<string, string>("lumi", "Lumibased PrimaryVertex"));
44  histoByCategoryNames_.insert(
45  pair<string, string>("lumi", "Lumibased DataBase"));
46  histoByCategoryNames_.insert(
47  pair<string, string>("lumi", "Lumibased Scalers"));
48  histoByCategoryNames_.insert(
49  pair<string, string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
50  histoByCategoryNames_.insert(
51  pair<string, string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
52  histoByCategoryNames_.insert(
53  pair<string, string>("validation", "Lumibased Scalers-DataBase fit"));
54  histoByCategoryNames_.insert(
55  pair<string, string>("validation", "Lumibased PrimaryVertex-DataBase"));
56  histoByCategoryNames_.insert(
57  pair<string, string>("validation", "Lumibased PrimaryVertex-Scalers"));
58 
59  for (vector<string>::iterator itV = varNamesV_.begin();
60  itV != varNamesV_.end(); itV++) {
61  for (multimap<string, string>::iterator itM = histoByCategoryNames_.begin();
62  itM != histoByCategoryNames_.end(); itM++) {
63  histosMap_[*itV][itM->first][itM->second] = nullptr;
64  positionsMap_[*itV][itM->first][itM->second] =
65  3 * numberOfValuesToSave_; // value, error, ok
67  }
68  }
69 }
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 71 of file AlcaBeamMonitorClient.cc.

71 {}

Member Function Documentation

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

Definition at line 113 of file AlcaBeamMonitorClient.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file AlcaBeamMonitorClient.cc.

74 {}
void AlcaBeamMonitorClient::beginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 109 of file AlcaBeamMonitorClient.cc.

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

Definition at line 77 of file AlcaBeamMonitorClient.cc.

References dbe_, histosMap_, genParticles_cff::map, and monitorName_.

78  {
79  for (HistosContainer::iterator itM = histosMap_.begin();
80  itM != histosMap_.end(); itM++) {
81  for (map<string, map<string, MonitorElement*> >::iterator itMM =
82  itM->second.begin();
83  itMM != itM->second.end(); itMM++) {
84  if (itMM->first != "run") {
85  for (map<string, MonitorElement*>::iterator itMMM =
86  itMM->second.begin();
87  itMMM != itMM->second.end(); itMMM++) {
88  if (itMMM->second != nullptr) {
89  if (itMM->first == "lumi") {
90  dbe_->removeElement(monitorName_ + "Debug",
91  itMMM->second->getName());
92  } else if (itMM->first == "validation") {
93  dbe_->removeElement(monitorName_ + "Validation",
94  itMMM->second->getName());
95  } else {
96  LogInfo("AlcaBeamMonitorClient") << "Unrecognized category "
97  << itMM->first;
98  // assert(0);
99  }
100  itMMM->second = nullptr;
101  }
102  }
103  }
104  }
105  }
106 }
void AlcaBeamMonitorClient::endJob ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
protected

Definition at line 347 of file AlcaBeamMonitorClient.cc.

References DEFINE_FWK_MODULE.

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

Definition at line 117 of file AlcaBeamMonitorClient.cc.

References dbe_, MonitorElement::getTProfile(), mps_fire::i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), monitorName_, numberOfValuesToSave_, tmp, and valuesMap_.

118  {
119  MonitorElement* tmp = nullptr;
120  tmp = dbe_->get(monitorName_ + "Service/hHistoLumiValues");
121  if (!tmp) {
122  return;
123  }
124  valuesMap_[iLumi.id().luminosityBlock()] = vector<double>();
125  for (int i = 0; i < 3 * numberOfValuesToSave_; i++) {
126  valuesMap_[iLumi.id().luminosityBlock()].push_back(
127  tmp->getTProfile()->GetBinContent(i + 1));
128  }
129 }
LuminosityBlockID id() const
TProfile * getTProfile() const
LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_
void AlcaBeamMonitorClient::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 132 of file AlcaBeamMonitorClient.cc.

References stringResolutionProvider_cfi::bin, dbe_, plotBeamSpotDB::first, histosMap_, edm::RunBase::id(), genParticles_cff::map, SiStripPI::max, allConversions_cfi::maxDelta, min(), monitorName_, dataset::name, positionsMap_, edm::RunID::run(), edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::title, and valuesMap_.

132  {
133  // use this in case any LS is missing.
134  if (valuesMap_.empty()) {
135  LogInfo("AlcaBeamMonitorClient")
136  << "The histogram "
137  << monitorName_ +
138  "Service/hHistoLumiValues which contains all the values has not "
139  "been found in any lumi!";
140  return;
141  }
142  int lastLumi = (--valuesMap_.end())->first;
143  int firstLumi = valuesMap_.begin()->first;
144 
145  // create and cd into new folder
146  dbe_->setCurrentFolder(monitorName_ + "Validation");
147 
148  LogInfo("AlcaBeamMonitorClient") << "End of run " << iRun.id().run() << "("
149  << firstLumi << "-" << lastLumi << ")";
150 
151  string name;
152  string title;
153  // x,y,z,sigmaX,sigmaY,sigmaZ
154  for (HistosContainer::iterator itM = histosMap_.begin();
155  itM != histosMap_.end(); itM++) {
156  for (map<string, map<string, MonitorElement*> >::iterator itMM =
157  itM->second.begin();
158  itMM != itM->second.end(); itMM++) {
159  if (itMM->first != "run") {
160  for (map<string, MonitorElement*>::iterator itMMM =
161  itMM->second.begin();
162  itMMM != itMM->second.end(); itMMM++) {
163  name = string("h") + itM->first + itMMM->first;
164  title = itM->first + "_{0} " + itMMM->first;
165  if (itMM->first == "lumi") {
166  dbe_->setCurrentFolder(monitorName_ + "Debug");
167  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1,
168  firstLumi - 0.5, lastLumi + 0.5);
169  itMMM->second->setEfficiencyFlag();
170  } else if (itMM->first == "validation" &&
171  itMMM->first == "Lumibased Scalers-DataBase fit") {
172  dbe_->setCurrentFolder(monitorName_ + "Validation");
173  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1,
174  firstLumi - 0.5, lastLumi + 0.5);
175  itMMM->second->setEfficiencyFlag();
176  } else if (itMM->first == "validation" &&
177  itMMM->first != "Lumibased Scalers-DataBase fit" &&
178  (itM->first == "x" || itM->first == "y" ||
179  itM->first == "z")) {
180  dbe_->setCurrentFolder(monitorName_ + "Validation");
181  itMMM->second = dbe_->book1D(name, title, lastLumi - firstLumi + 1,
182  firstLumi - 0.5, lastLumi + 0.5);
183  itMMM->second->setEfficiencyFlag();
184  }
185  else if (itMM->first == "validation" &&
186  (itM->first == "sigmaX" || itM->first == "sigmaY" ||
187  itM->first == "sigmaZ")) {
188  dbe_->setCurrentFolder(monitorName_ + "Validation");
189  itMMM->second = nullptr;
190  } else {
191  LogInfo("AlcaBeamMonitorClient") << "Unrecognized category "
192  << itMM->first;
193  // assert(0);
194  }
195  if (itMMM->second != nullptr) {
196  if (itMMM->first.find('-') != string::npos) {
197  itMMM->second->setAxisTitle(
198  string("#Delta ") + itM->first + "_{0} (cm)", 2);
199  } else {
200  itMMM->second->setAxisTitle(itM->first + "_{0} (cm)", 2);
201  }
202  itMMM->second->setAxisTitle("Lumisection", 1);
203  }
204  }
205  }
206  }
207  }
208 
209  unsigned int bin = 0;
210  for (HistosContainer::iterator itH = histosMap_.begin();
211  itH != histosMap_.end(); itH++) {
212  for (map<string, map<string, MonitorElement*> >::iterator itHH =
213  itH->second.begin();
214  itHH != itH->second.end(); itHH++) {
215  for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin();
216  itHHH != itHH->second.end(); itHHH++) {
217  for (map<LuminosityBlockNumber_t, vector<double> >::iterator itVal =
218  valuesMap_.begin();
219  itVal != valuesMap_.end(); itVal++) {
220  if (itHHH->second != nullptr) {
221  // cout << positionsMap_[itH->first][itHH->first][itHHH->first]
222  //<< endl;
223  if (itVal->second[positionsMap_[itH->first][itHH->first]
224  [itHHH->first] +
225  2] == 1) {
226  bin = itHHH->second->getTH1()->FindBin(itVal->first);
227  itHHH->second->setBinContent(
228  bin, itVal->second[positionsMap_[itH->first][itHH->first]
229  [itHHH->first]]);
230  itHHH->second->setBinError(
231  bin, itVal->second[positionsMap_[itH->first][itHH->first]
232  [itHHH->first] +
233  1]);
234  }
235  }
236  }
237  }
238  }
239  }
240 
241 
242  const double bigNumber = 1000000.;
243  for (HistosContainer::iterator itH = histosMap_.begin();
244  itH != histosMap_.end(); itH++) {
245  for (map<string, map<string, MonitorElement*> >::iterator itHH =
246  itH->second.begin();
247  itHH != itH->second.end(); itHH++) {
248  double min = bigNumber;
249  double max = -bigNumber;
250  double minDelta = bigNumber;
251  double maxDelta = -bigNumber;
252  // double minDeltaProf = bigNumber;
253  // double maxDeltaProf = -bigNumber;
254  if (itHH->first != "run") {
255  for (map<string, MonitorElement*>::iterator itHHH =
256  itHH->second.begin();
257  itHHH != itHH->second.end(); itHHH++) {
258  if (itHHH->second != nullptr) {
259  for (int bin = 1; bin <= itHHH->second->getTH1()->GetNbinsX();
260  bin++) {
261  if (itHHH->second->getTH1()->GetBinError(bin) != 0 ||
262  itHHH->second->getTH1()->GetBinContent(bin) != 0) {
263  if (itHHH->first == "Lumibased BeamSpotFit" ||
264  itHHH->first == "Lumibased PrimaryVertex" ||
265  itHHH->first == "Lumibased DataBase" ||
266  itHHH->first == "Lumibased Scalers") {
267  if (min > itHHH->second->getTH1()->GetBinContent(bin)) {
268  min = itHHH->second->getTH1()->GetBinContent(bin);
269  }
270  if (max < itHHH->second->getTH1()->GetBinContent(bin)) {
271  max = itHHH->second->getTH1()->GetBinContent(bin);
272  }
273  } else if (itHHH->first ==
274  "Lumibased PrimaryVertex-DataBase fit" ||
275  itHHH->first ==
276  "Lumibased PrimaryVertex-Scalers fit" ||
277  itHHH->first == "Lumibased Scalers-DataBase fit" ||
278  itHHH->first == "Lumibased PrimaryVertex-DataBase" ||
279  itHHH->first == "Lumibased PrimaryVertex-Scalers") {
280  if (minDelta > itHHH->second->getTH1()->GetBinContent(bin)) {
281  minDelta = itHHH->second->getTH1()->GetBinContent(bin);
282  }
283  if (maxDelta < itHHH->second->getTH1()->GetBinContent(bin)) {
284  maxDelta = itHHH->second->getTH1()->GetBinContent(bin);
285  }
286  }
287  else {
288  LogInfo("AlcaBeamMonitorClient")
289  << "The histosMap_ have a histogram named "
290  << itHHH->first
291  << " that I can't recognize in this loop!";
292  // assert(0);
293  }
294  }
295  }
296  }
297  }
298  for (map<string, MonitorElement*>::iterator itHHH =
299  itHH->second.begin();
300  itHHH != itHH->second.end(); itHHH++) {
301  if (itHHH->second != nullptr) {
302  if (itHHH->first == "Lumibased BeamSpotFit" ||
303  itHHH->first == "Lumibased PrimaryVertex" ||
304  itHHH->first == "Lumibased DataBase" ||
305  itHHH->first == "Lumibased Scalers") {
306  if ((max == -bigNumber && min == bigNumber) || max - min == 0) {
307  itHHH->second->getTH1()->SetMinimum(
308  itHHH->second->getTH1()->GetMinimum() - 0.01);
309  itHHH->second->getTH1()->SetMaximum(
310  itHHH->second->getTH1()->GetMaximum() + 0.01);
311  } else {
312  itHHH->second->getTH1()->SetMinimum(min - 0.1 * (max - min));
313  itHHH->second->getTH1()->SetMaximum(max + 0.1 * (max - min));
314  }
315  } else if (itHHH->first == "Lumibased PrimaryVertex-DataBase fit" ||
316  itHHH->first == "Lumibased PrimaryVertex-Scalers fit" ||
317  itHHH->first == "Lumibased Scalers-DataBase fit" ||
318  itHHH->first == "Lumibased PrimaryVertex-DataBase" ||
319  itHHH->first == "Lumibased PrimaryVertex-Scalers") {
320  if ((maxDelta == -bigNumber && minDelta == bigNumber) ||
321  maxDelta - minDelta == 0) {
322  itHHH->second->getTH1()->SetMinimum(
323  itHHH->second->getTH1()->GetMinimum() - 0.01);
324  itHHH->second->getTH1()->SetMaximum(
325  itHHH->second->getTH1()->GetMaximum() + 0.01);
326  } else {
327  itHHH->second->getTH1()->SetMinimum(minDelta -
328  2 * (maxDelta - minDelta));
329  itHHH->second->getTH1()->SetMaximum(maxDelta +
330  2 * (maxDelta - minDelta));
331  }
332  }
333  else {
334  LogInfo("AlcaBeamMonitorClient")
335  << "The histosMap_ have a histogram named " << itHHH->first
336  << " that I can't recognize in this loop!";
337  }
338  }
339  }
340  }
341  }
342  }
343 
344 }
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:39
PositionContainer positionsMap_
unsigned int LuminosityBlockNumber_t
U second(std::pair< T, U > const &p)
T min(T a, T b)
Definition: MathUtil.h:58
bin
set the eta bin as selection string.
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_

Member Data Documentation

DQMStore* AlcaBeamMonitorClient::dbe_
private
std::multimap<std::string,std::string> AlcaBeamMonitorClient::histoByCategoryNames_
private

Definition at line 57 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient().

HistosContainer AlcaBeamMonitorClient::histosMap_
private

Definition at line 55 of file AlcaBeamMonitorClient.h.

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

std::string AlcaBeamMonitorClient::monitorName_
private
int AlcaBeamMonitorClient::numberOfValuesToSave_
private

Definition at line 51 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endLuminosityBlock().

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

Definition at line 59 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endRun().

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

Definition at line 58 of file AlcaBeamMonitorClient.h.

Referenced by endLuminosityBlock(), and endRun().

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

Definition at line 56 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient().