CMS 3D CMS Logo

MEtoEDMConverter.cc
Go to the documentation of this file.
1 
2 
10 #include <cassert>
11 
13 #include "classlib/utils/StringList.h"
14 #include "classlib/utils/StringOps.h"
17 
18 using namespace lat;
19 
21  std::string MsgLoggerCat = "MEtoEDMConverter_MEtoEDMConverter";
22 
23  // get information from parameter set
24  fName = iPSet.getUntrackedParameter<std::string>("Name", "MEtoEDMConverter");
25  verbosity = iPSet.getUntrackedParameter<int>("Verbosity", 0);
26  frequency = iPSet.getUntrackedParameter<int>("Frequency", 50);
27  path = iPSet.getUntrackedParameter<std::string>("MEPathToSave");
28  // use value of first digit to determine default output level (inclusive)
29  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
30  verbosity %= 10;
31 
32  // print out Parameter Set information being used
33  if (verbosity >= 0) {
34  edm::LogInfo(MsgLoggerCat) << "\n===============================\n"
35  << "Initialized as EDProducer with parameter values:\n"
36  << " Name = " << fName << "\n"
37  << " Verbosity = " << verbosity << "\n"
38  << " Frequency = " << frequency << "\n"
39  << " Path = " << path << "\n"
40  << "===============================\n";
41  }
42 
43  std::string sName;
44 
45  // create persistent objects
46 
47  sName = fName + "Run";
48  produces<MEtoEDM<TH1F>, edm::Transition::EndRun>(sName);
49  produces<MEtoEDM<TH1S>, edm::Transition::EndRun>(sName);
50  produces<MEtoEDM<TH1D>, edm::Transition::EndRun>(sName);
51  produces<MEtoEDM<TH2F>, edm::Transition::EndRun>(sName);
52  produces<MEtoEDM<TH2S>, edm::Transition::EndRun>(sName);
53  produces<MEtoEDM<TH2D>, edm::Transition::EndRun>(sName);
54  produces<MEtoEDM<TH3F>, edm::Transition::EndRun>(sName);
55  produces<MEtoEDM<TProfile>, edm::Transition::EndRun>(sName);
56  produces<MEtoEDM<TProfile2D>, edm::Transition::EndRun>(sName);
57  produces<MEtoEDM<double>, edm::Transition::EndRun>(sName);
58  produces<MEtoEDM<long long>, edm::Transition::EndRun>(sName);
59  produces<MEtoEDM<TString>, edm::Transition::EndRun>(sName);
60 
61  sName = fName + "Lumi";
62  produces<MEtoEDM<TH1F>, edm::Transition::EndLuminosityBlock>(sName);
63  produces<MEtoEDM<TH1S>, edm::Transition::EndLuminosityBlock>(sName);
64  produces<MEtoEDM<TH1D>, edm::Transition::EndLuminosityBlock>(sName);
65  produces<MEtoEDM<TH2F>, edm::Transition::EndLuminosityBlock>(sName);
66  produces<MEtoEDM<TH2S>, edm::Transition::EndLuminosityBlock>(sName);
67  produces<MEtoEDM<TH2D>, edm::Transition::EndLuminosityBlock>(sName);
68  produces<MEtoEDM<TH3F>, edm::Transition::EndLuminosityBlock>(sName);
69  produces<MEtoEDM<TProfile>, edm::Transition::EndLuminosityBlock>(sName);
70  produces<MEtoEDM<TProfile2D>, edm::Transition::EndLuminosityBlock>(sName);
71  produces<MEtoEDM<double>, edm::Transition::EndLuminosityBlock>(sName);
72  produces<MEtoEDM<long long>, edm::Transition::EndLuminosityBlock>(sName);
73  produces<MEtoEDM<TString>, edm::Transition::EndLuminosityBlock>(sName);
74 
75  consumesMany<DQMToken, edm::InLumi>();
76  consumesMany<DQMToken, edm::InRun>();
77  usesResource("DQMStore");
78 
79  static_assert(sizeof(int64_t) == sizeof(long long), "type int64_t is not the same length as long long");
80 }
81 
83 
85 
87 
88 std::shared_ptr<meedm::Void> MEtoEDMConverter::globalBeginRun(edm::Run const& iRun,
89  const edm::EventSetup& iSetup) const {
90  return std::shared_ptr<meedm::Void>();
91 }
92 
93 void MEtoEDMConverter::globalEndRun(edm::Run const& iRun, const edm::EventSetup& iSetup) {}
94 
96  DQMStore* store = edm::Service<DQMStore>().operator->();
97  store->meBookerGetter([&](DQMStore::IBooker& b, DQMStore::IGetter& g) { putData(g, iRun, false, iRun.run(), 0); });
98 }
99 
101  edm::EventSetup const&) const {
102  return std::shared_ptr<meedm::Void>();
103 }
104 
106  DQMStore* store = edm::Service<DQMStore>().operator->();
108  putData(g, iLumi, true, iLumi.run(), iLumi.id().luminosityBlock());
109  });
110 }
111 
112 template <class T>
113 void MEtoEDMConverter::putData(DQMStore::IGetter& iGetter, T& iPutTo, bool iLumiOnly, uint32_t run, uint32_t lumi) {
114  std::string MsgLoggerCat = "MEtoEDMConverter_putData";
115 
116  if (verbosity > 0)
117  edm::LogInfo(MsgLoggerCat) << "\nStoring MEtoEDM dataformat histograms.";
118 
119  // extract ME information into vectors
120  std::vector<MonitorElement*>::iterator mmi, mme;
121  std::vector<MonitorElement*> items(iGetter.getAllContents(path, run, lumi));
122 
123  unsigned int n1F = 0;
124  unsigned int n1S = 0;
125  unsigned int n1D = 0;
126  unsigned int n2F = 0;
127  unsigned int n2S = 0;
128  unsigned int n2D = 0;
129  unsigned int n3F = 0;
130  unsigned int nProf = 0;
131  unsigned int nProf2 = 0;
132  unsigned int nDouble = 0;
133  unsigned int nInt64 = 0;
134  unsigned int nString = 0;
135 
136  for (mmi = items.begin(), mme = items.end(); mmi != mme; ++mmi) {
137  MonitorElement* me = *mmi;
138 
139  // store only flagged ME at endLumi transition, and Run-based
140  // histo at endRun transition
141  if (iLumiOnly && !me->getLumiFlag())
142  continue;
143  if (!iLumiOnly && me->getLumiFlag())
144  continue;
145 
146  switch (me->kind()) {
148  ++nInt64;
149  break;
150 
152  ++nDouble;
153  break;
154 
156  ++nString;
157  break;
158 
160  ++n1F;
161  break;
162 
164  ++n1S;
165  break;
166 
168  ++n1D;
169  break;
170 
172  ++n2F;
173  break;
174 
176  ++n2S;
177  break;
178 
180  ++n2D;
181  break;
182 
184  ++n3F;
185  break;
186 
188  ++nProf;
189  break;
190 
192  ++nProf2;
193  break;
194 
195  default:
196  edm::LogError(MsgLoggerCat) << "ERROR: The DQM object '" << me->getFullname()
197  << "' is neither a ROOT object nor a recognised "
198  << "simple object.\n";
199  continue;
200  }
201  }
202 
203  std::unique_ptr<MEtoEDM<long long> > pOutInt(new MEtoEDM<long long>(nInt64));
204  std::unique_ptr<MEtoEDM<double> > pOutDouble(new MEtoEDM<double>(nDouble));
205  std::unique_ptr<MEtoEDM<TString> > pOutString(new MEtoEDM<TString>(nString));
206  std::unique_ptr<MEtoEDM<TH1F> > pOut1(new MEtoEDM<TH1F>(n1F));
207  std::unique_ptr<MEtoEDM<TH1S> > pOut1s(new MEtoEDM<TH1S>(n1S));
208  std::unique_ptr<MEtoEDM<TH1D> > pOut1d(new MEtoEDM<TH1D>(n1D));
209  std::unique_ptr<MEtoEDM<TH2F> > pOut2(new MEtoEDM<TH2F>(n2F));
210  std::unique_ptr<MEtoEDM<TH2S> > pOut2s(new MEtoEDM<TH2S>(n2S));
211  std::unique_ptr<MEtoEDM<TH2D> > pOut2d(new MEtoEDM<TH2D>(n2D));
212  std::unique_ptr<MEtoEDM<TH3F> > pOut3(new MEtoEDM<TH3F>(n3F));
213  std::unique_ptr<MEtoEDM<TProfile> > pOutProf(new MEtoEDM<TProfile>(nProf));
214  std::unique_ptr<MEtoEDM<TProfile2D> > pOutProf2(new MEtoEDM<TProfile2D>(nProf2));
215 
216  for (mmi = items.begin(), mme = items.end(); mmi != mme; ++mmi) {
217  MonitorElement* me = *mmi;
218 
219  // store only flagged ME at endLumi transition, and Run-based
220  // histo at endRun transition
221  // DQMStore should only hand out matching MEs
222  assert(iLumiOnly == me->getLumiFlag());
223 
224  // get monitor elements
225  switch (me->kind()) {
227  pOutInt->putMEtoEdmObject(me->getFullname(), me->getIntValue());
228  break;
229 
231  pOutDouble->putMEtoEdmObject(me->getFullname(), me->getFloatValue());
232  break;
233 
235  pOutString->putMEtoEdmObject(me->getFullname(), me->getStringValue());
236  break;
237 
239  pOut1->putMEtoEdmObject(me->getFullname(), *me->getTH1F());
240  break;
241 
243  pOut1s->putMEtoEdmObject(me->getFullname(), *me->getTH1S());
244  break;
245 
247  pOut1d->putMEtoEdmObject(me->getFullname(), *me->getTH1D());
248  break;
249 
251  pOut2->putMEtoEdmObject(me->getFullname(), *me->getTH2F());
252  break;
253 
255  pOut2s->putMEtoEdmObject(me->getFullname(), *me->getTH2S());
256  break;
257 
259  pOut2d->putMEtoEdmObject(me->getFullname(), *me->getTH2D());
260  break;
261 
263  pOut3->putMEtoEdmObject(me->getFullname(), *me->getTH3F());
264  break;
265 
267  pOutProf->putMEtoEdmObject(me->getFullname(), *me->getTProfile());
268  break;
269 
271  pOutProf2->putMEtoEdmObject(me->getFullname(), *me->getTProfile2D());
272  break;
273 
274  default:
275  edm::LogError(MsgLoggerCat) << "ERROR: The DQM object '" << me->getFullname()
276  << "' is neither a ROOT object nor a recognised "
277  << "simple object.\n";
278  continue;
279  }
280 
281  } // end loop through monitor elements
282 
283  std::string sName;
284 
285  if (iLumiOnly) {
286  sName = fName + "Lumi";
287  } else {
288  sName = fName + "Run";
289  }
290 
291  // produce objects to put in events
292  iPutTo.put(std::move(pOutInt), sName);
293  iPutTo.put(std::move(pOutDouble), sName);
294  iPutTo.put(std::move(pOutString), sName);
295  iPutTo.put(std::move(pOut1), sName);
296  iPutTo.put(std::move(pOut1s), sName);
297  iPutTo.put(std::move(pOut1d), sName);
298  iPutTo.put(std::move(pOut2), sName);
299  iPutTo.put(std::move(pOut2s), sName);
300  iPutTo.put(std::move(pOut2d), sName);
301  iPutTo.put(std::move(pOut3), sName);
302  iPutTo.put(std::move(pOutProf), sName);
303  iPutTo.put(std::move(pOutProf2), sName);
304 }
305 
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
MEtoEDMConverter::MEtoEDMConverter
MEtoEDMConverter(const edm::ParameterSet &)
Definition: MEtoEDMConverter.cc:20
MEtoEDMConverter::endLuminosityBlockProduce
void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: MEtoEDMConverter.cc:105
MEtoEDMConverter::putData
void putData(DQMStore::IGetter &g, T &iPutTo, bool iLumiOnly, uint32_t run, uint32_t lumi)
Definition: MEtoEDMConverter.cc:113
MonitorElementData::Kind::INT
MEtoEDM
Definition: MEtoEDMFormat.h:37
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
MonitorElementData::Kind::TH1S
edm::Run
Definition: Run.h:45
MEtoEDMConverter.h
MonitorElementData::Kind::TH1F
MonitorElementData::Kind::STRING
edm::LogInfo
Definition: MessageLogger.h:254
cms::cuda::assert
assert(be >=bs)
dqm::implementation::DQMStore::meBookerGetter
void meBookerGetter(iFunc f)
Definition: DQMStore.h:632
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
MEtoEDMConverter::endRunProduce
void endRunProduce(edm::Run &, const edm::EventSetup &) override
Definition: MEtoEDMConverter.cc:95
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
dqm::implementation::IGetter::getAllContents
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
MEtoEDMConverter::beginJob
void beginJob() override
Definition: MEtoEDMConverter.cc:84
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
MonitorElementData::Kind::TH2D
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
MEtoEDMConverter::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: MEtoEDMConverter.cc:306
MainPageGenerator.fName
fName
Definition: MainPageGenerator.py:301
MonitorElementData::Kind::TH2F
MEtoEDMConverter::~MEtoEDMConverter
~MEtoEDMConverter() override
MEtoEDMConverter::globalBeginLuminosityBlock
std::shared_ptr< meedm::Void > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
Definition: MEtoEDMConverter.cc:100
dqm::legacy::DQMStore
Definition: DQMStore.h:727
DQMToken.h
MEtoEDMConverter::verbosity
int verbosity
Definition: MEtoEDMConverter.h:88
MEtoEDMConverter::path
std::string path
Definition: MEtoEDMConverter.h:90
MEtoEDMFormat.h
MEtoEDMConverter::globalBeginRun
std::shared_ptr< meedm::Void > globalBeginRun(edm::Run const &, const edm::EventSetup &) const override
Definition: MEtoEDMConverter.cc:88
b
double b
Definition: hdecay.h:118
MEtoEDMConverter::globalEndRun
void globalEndRun(edm::Run const &, const edm::EventSetup &) override
Definition: MEtoEDMConverter.cc:93
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
MEtoEDMConverter::fName
std::string fName
Definition: MEtoEDMConverter.h:87
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
edm::EventSetup
Definition: EventSetup.h:57
MonitorElementData::Kind::TH1D
MEtoEDMConverter::endJob
void endJob() override
Definition: MEtoEDMConverter.cc:86
MonitorElementData::Kind::TH2S
MEtoEDMConverter::frequency
int frequency
Definition: MEtoEDMConverter.h:89
edm::Transition::EndLuminosityBlock
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
MonitorElementData::Kind::TPROFILE2D
MonitorElementData::Kind::TH3F
T
long double T
Definition: Basic3DVectorLD.h:48
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker
Definition: DQMStore.h:43
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
edm::Event
Definition: Event.h:73
edm::Transition::EndRun
lumi
Definition: LumiSectionData.h:20
MonitorElementData::Kind::TPROFILE
MonitorElementData::Kind::REAL
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4