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

- 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 39 of file AlcaBeamMonitorClient.h.

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

Definition at line 42 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_.empty()) 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 111 of file AlcaBeamMonitorClient.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file AlcaBeamMonitorClient.cc.

74 {}
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::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 115 of file AlcaBeamMonitorClient.cc.

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

116  {
117  MonitorElement* tmp = nullptr;
118  tmp = dbe_->get(monitorName_ + "Service/hHistoLumiValues");
119  if (!tmp) {
120  return;
121  }
122  valuesMap_[iLumi.id().luminosityBlock()] = vector<double>();
123  for (int i = 0; i < 3 * numberOfValuesToSave_; i++) {
124  valuesMap_[iLumi.id().luminosityBlock()].push_back(
125  tmp->getTProfile()->GetBinContent(i + 1));
126  }
127 }
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 130 of file AlcaBeamMonitorClient.cc.

References stringResolutionProvider_cfi::bin, dbe_, DEFINE_FWK_MODULE, 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, runGCPTkAlMap::title, and valuesMap_.

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

Referenced by AlcaBeamMonitorClient().

HistosContainer AlcaBeamMonitorClient::histosMap_
private

Definition at line 53 of file AlcaBeamMonitorClient.h.

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

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

Definition at line 49 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endLuminosityBlock().

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

Definition at line 57 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient(), and endRun().

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

Definition at line 56 of file AlcaBeamMonitorClient.h.

Referenced by endLuminosityBlock(), and endRun().

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

Definition at line 54 of file AlcaBeamMonitorClient.h.

Referenced by AlcaBeamMonitorClient().