48 #include "classlib/utils/StringList.h" 49 #include "classlib/utils/StringOps.h" 52 edm::one::WatchLuminosityBlocks,
53 edm::one::SharedResources,
54 edm::EndLuminosityBlockProducer,
55 edm::EndRunProducer> {
104 std::tuple<Tokens<TH1F>,
129 template <
typename T>
137 template <
typename T>
142 template <
typename T>
149 template <
size_t I,
size_t N>
150 struct ForEachHelper {
151 template <
typename Tuple,
typename Func>
152 static void call(Tuple &&tpl, Func &&
func) {
153 func(std::get<I - 1>(tpl));
154 ForEachHelper<I + 1, N>::call(std::forward<Tuple>(tpl), std::forward<Func>(
func));
159 struct ForEachHelper<
N,
N> {
160 template <
typename Tuple,
typename Func>
161 static void call(Tuple &&tpl, Func &&
func) {
162 func(std::get<N - 1>(tpl));
167 template <
typename Tuple,
typename Func>
168 void for_each(Tuple &&tpl, Func &&
func) {
170 ForEachHelper<1, size>::call(std::forward<Tuple>(tpl), std::forward<Func>(
func));
173 template <
typename T>
176 struct HistoTraits<TH1F> {
178 template <
typename...
Args>
180 return iBooker.
book1D(std::forward<Args>(
args)...);
184 struct HistoTraits<TH1S> {
186 template <
typename...
Args>
188 return iBooker.
book1S(std::forward<Args>(
args)...);
192 struct HistoTraits<TH1D> {
194 template <
typename...
Args>
196 return iBooker.
book1DD(std::forward<Args>(
args)...);
200 struct HistoTraits<TH1I> {
202 template <
typename...
Args>
204 return iBooker.
book1I(std::forward<Args>(
args)...);
208 struct HistoTraits<TH2F> {
210 template <
typename...
Args>
212 return iBooker.
book2D(std::forward<Args>(
args)...);
216 struct HistoTraits<TH2S> {
218 template <
typename...
Args>
220 return iBooker.
book2S(std::forward<Args>(
args)...);
224 struct HistoTraits<TH2D> {
226 template <
typename...
Args>
228 return iBooker.
book2DD(std::forward<Args>(
args)...);
232 struct HistoTraits<TH2I> {
234 template <
typename...
Args>
236 return iBooker.
book2I(std::forward<Args>(
args)...);
240 struct HistoTraits<TH3F> {
242 template <
typename...
Args>
244 return iBooker.
book3D(std::forward<Args>(
args)...);
248 struct HistoTraits<TProfile> {
250 template <
typename...
Args>
256 struct HistoTraits<TProfile2D> {
258 template <
typename...
Args>
265 template <
typename T>
266 struct AddMonitorElement {
267 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
270 MEtoEDMObject_object *metoedmobject,
273 const RunOrLumi &runOrLumi) {
280 list.Add(metoedmobject);
281 if (
histo->Merge(&list) == -1)
282 edm::LogError(
"EDMtoMEConverter") <<
"ERROR EDMtoMEConverter::getData(): merge failed for '" 283 << metoedmobject->GetName() <<
"'" << std::endl;
287 return HistoTraits<T>::book(iBooker, metoedmobject->GetName(), metoedmobject);
293 struct AddMonitorElement<double> {
294 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
297 MEtoEDMObject_object *metoedmobject,
300 const RunOrLumi &runOrLumi) {
303 me->Fill(*metoedmobject);
309 template <
typename T>
310 struct AddMonitorElementForIntegers {
311 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
314 MEtoEDMObject_object *metoedmobject,
317 const RunOrLumi &runOrLumi) {
320 T ival = getProcessedEvents(iGetter,
dir,
name, runOrLumi);
322 me->Fill(*metoedmobject + ival);
330 if (
name.find(
"processedEvents") != std::string::npos) {
332 return me->getIntValue();
346 struct AddMonitorElement<long long> {
347 template <
typename...
Args>
349 return AddMonitorElementForIntegers<long long>::call(std::forward<Args>(
args)...);
353 struct AddMonitorElement<
int> {
354 template <
typename...
Args>
356 return AddMonitorElementForIntegers<int>::call(std::forward<Args>(
args)...);
361 struct AddMonitorElement<TString> {
362 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
365 MEtoEDMObject_object *metoedmobject,
368 const RunOrLumi &runOrLumi) {
377 if (
reScope == MonitorElementData::Scope::JOB) {
378 ibooker.
setScope(MonitorElementData::Scope::JOB);
380 ibooker.
setScope(MonitorElementData::Scope::RUN);
397 constexpr
char MsgLoggerCat[] =
"EDMtoMEConverter_EDMtoMEConverter";
407 auto scopeDecode = std::map<std::string, MonitorElementData::Scope>{{
"", MonitorElementData::Scope::LUMI},
408 {
"LUMI", MonitorElementData::Scope::LUMI},
409 {
"RUN", MonitorElementData::Scope::RUN},
410 {
"JOB", MonitorElementData::Scope::JOB}};
419 edm::LogInfo(MsgLoggerCat) <<
"\n===============================\n" 420 <<
"Initialized as EDAnalyzer with parameter values:\n" 421 <<
" Name = " <<
name <<
"\n" 424 <<
"===============================\n";
427 assert(
sizeof(int64_t) ==
sizeof(
long long));
428 usesResource(
"DQMStore");
430 dqmLumiToken_ = produces<DQMToken, edm::Transition::EndLuminosityBlock>(
"endLumi");
431 dqmRunToken_ = produces<DQMToken, edm::Transition::EndRun>(
"endRun");
440 iRun.
put(dqmRunToken_, std::make_unique<DQMToken>());
449 iLumi.
put(dqmLumiToken_, std::make_unique<DQMToken>());
454 constexpr
char MsgLoggerCat[] =
"EDMtoMEConverter_getData";
457 edm::LogInfo(MsgLoggerCat) <<
"\nRestoring MonitorElements.";
459 for_each(
tokens_, [&](
const auto &tok) {
462 using MEtoEDM_T =
typename Tokens_T::Product;
464 tok.getData(iGetFrom, metoedm);
471 std::vector<typename MEtoEDM_T::MEtoEDMObject> metoedmobject = metoedm->getMEtoEdmObject();
473 for (
unsigned int i = 0;
i < metoedmobject.size(); ++
i) {
485 for (
unsigned j = 0;
j < fulldir.size() - 1; ++
j) {
487 if (
j != fulldir.size() - 2)
492 adjustScope(iBooker, iGetFrom,
reScope);
493 AddMonitorElement<METype>::call(iBooker, iGetter, &metoedmobject[
i].
object,
dir,
name, iGetFrom);
T getParameter(std::string const &) const
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
MonitorElement * book1I(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
virtual void setCurrentFolder(std::string const &fullpath)
void endLuminosityBlockProduce(edm::LuminosityBlock &, edm::EventSetup const &) override
dqm::legacy::DQMStore DQMStore
EDMtoMEConverter(const edm::ParameterSet &)
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
void beginRun(const edm::Run &, const edm::EventSetup &) final
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
dqm::legacy::MonitorElement MonitorElement
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
T getUntrackedParameter(std::string const &, T const &) const
dqm::reco::DQMStore DQMStore
void endRunProduce(edm::Run &run, edm::EventSetup const &setup) override
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
edm::EDGetTokenT< Product > runToken
void endRun(const edm::Run &, const edm::EventSetup &) final
~EDMtoMEConverter() override=default
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void put(std::unique_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, edm::EventSetup const &) final
edm::EDPutTokenT< DQMToken > dqmRunToken_
void getData(const edm::Run &iRun, edm::Handle< Product > &handle) const
void meBookerGetter(iFunc f)
MonitorElement * book1S(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
#define DEFINE_FWK_MODULE(type)
def split(sequence, size)
edm::EDPutTokenT< DQMToken > dqmLumiToken_
Log< level::Info, false > LogInfo
std::vector< edm::EDGetTokenT< int > > tokens_
std::tuple< Tokens< TH1F >, Tokens< TH1S >, Tokens< TH1D >, Tokens< TH1I >, Tokens< TH2F >, Tokens< TH2S >, Tokens< TH2D >, Tokens< TH2I >, Tokens< TH3F >, Tokens< TProfile >, Tokens< TProfile2D >, Tokens< double >, Tokens< int >, Tokens< long long >, Tokens< TString > > tokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
dqm::legacy::MonitorElement MonitorElement
void set(const edm::InputTag &runInputTag, const edm::InputTag &lumiInputTag, edm::ConsumesCollector &iC)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void put(std::unique_ptr< PROD > product)
Put a new product.
virtual MonitorElement * get(std::string const &fullpath) const
MonitorElement * book2DD(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::vector< uint32_t > TagList
void getData(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, T &iGetFrom)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * book3D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, FUNC onbooking=NOOP())
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::EDGetTokenT< Product > lumiToken
MonitorElementData::Scope reScope