34 template <
size_t I,
size_t N>
35 struct ForEachHelper {
36 template <
typename Tuple,
typename Func>
38 void call(Tuple&& tpl, Func&& func) {
39 func(std::get<I-1>(tpl));
40 ForEachHelper<I+1, N>::call(std::forward<Tuple>(tpl), std::forward<Func>(func));
45 struct ForEachHelper<
N,
N> {
46 template <
typename Tuple,
typename Func>
48 void call(Tuple&& tpl, Func&& func) {
49 func(std::get<N-1>(tpl));
54 template <
typename Tuple,
typename Func>
55 void for_each(Tuple&& tpl, Func&& func) {
57 ForEachHelper<1, size>::call(std::forward<Tuple>(tpl), std::forward<Func>(func));
61 template <
typename T>
struct HistoTraits;
62 template <>
struct HistoTraits<TH1F> {
65 return dbe->book1D(std::forward<Args>(
args)...);
68 template <>
struct HistoTraits<TH1S> {
71 return dbe->book1S(std::forward<Args>(
args)...);
74 template <>
struct HistoTraits<TH1D> {
77 return dbe->book1DD(std::forward<Args>(
args)...);
80 template <>
struct HistoTraits<TH2F> {
83 return dbe->book2D(std::forward<Args>(
args)...);
86 template <>
struct HistoTraits<TH2S> {
89 return dbe->book2S(std::forward<Args>(
args)...);
92 template <>
struct HistoTraits<TH2D> {
95 return dbe->book2DD(std::forward<Args>(
args)...);
98 template <>
struct HistoTraits<TH3F> {
101 return dbe->book3D(std::forward<Args>(
args)...);
104 template <>
struct HistoTraits<TProfile>{
107 return dbe->bookProfile(std::forward<Args>(
args)...);
110 template <>
struct HistoTraits<TProfile2D> {
113 return dbe->bookProfile2D(std::forward<Args>(
args)...);
118 template <
typename T>
119 struct AddMonitorElement {
120 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
128 list.Add(metoedmobject);
129 if (
histo->Merge(&list) == -1)
130 std::cout <<
"ERROR EDMtoMEConverter::getData(): merge failed for '"
131 << metoedmobject->GetName() <<
"'" << std::endl;
136 dbe->setCurrentFolder(dir);
137 return HistoTraits<T>::book(dbe, metoedmobject->GetName(), metoedmobject);
142 struct AddMonitorElement<double> {
143 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
146 dbe->setCurrentFolder(dir);
148 me->
Fill(*metoedmobject);
154 template <
typename T>
155 struct AddMonitorElementForIntegers {
156 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
159 dbe->setCurrentFolder(dir);
160 T ival = getProcessedEvents(dbe, dir, name, runOrLumi);
162 me->
Fill(*metoedmobject + ival);
168 if(name.find(
"processedEvents") != std::string::npos) {
182 struct AddMonitorElement<long long> {
183 template <
typename ...Args>
186 return AddMonitorElementForIntegers<long long>::call(std::forward<Args>(
args)...);
190 struct AddMonitorElement<int> {
191 template <
typename ...Args>
194 return AddMonitorElementForIntegers<int>::call(std::forward<Args>(
args)...);
200 struct AddMonitorElement<TString> {
201 template <
typename MEtoEDMObject_
object,
typename RunOrLumi>
204 dbe->setCurrentFolder(dir);
206 return dbe->bookString(name, scont);
225 for_each(
tokens_, [&](
auto& tok) {
226 tok.set(runInputTag, lumiInputTag, iC);
229 constexpr char MsgLoggerCat[] =
"EDMtoMEConverter_EDMtoMEConverter";
248 if (verbosity >= 0) {
250 <<
"\n===============================\n"
251 <<
"Initialized as EDAnalyzer with parameter values:\n"
252 <<
" Name = " << name <<
"\n"
253 <<
" Verbosity = " << verbosity <<
"\n"
254 <<
" Frequency = " << frequency <<
"\n"
255 <<
"===============================\n";
261 assert(
sizeof(int64_t) ==
sizeof(
long long));
273 constexpr char MsgLoggerCat[] =
"EDMtoMEConverter_endJob";
276 <<
"Terminating having processed " <<
iCount.size() <<
" runs across "
289 constexpr char MsgLoggerCat[] =
"EDMtoMEConverter_beginRun";
291 int nrun = iRun.
run();
298 <<
"Processing run " << nrun <<
" (" <<
iCount.size() <<
" runs total)";
302 <<
"Processing run " << nrun <<
" (" <<
iCount.size() <<
" runs total)";
333 constexpr char MsgLoggerCat[] =
"EDMtoMEConverter_getData";
336 edm::LogInfo (MsgLoggerCat) <<
"\nRestoring MonitorElements.";
338 for_each(
tokens_, [&](
const auto& tok) {
341 using MEtoEDM_T =
typename Tokens_T::Product;
343 tok.getData(iGetFrom, metoedm);
350 std::vector<typename MEtoEDM_T::MEtoEDMObject> metoedmobject =
351 metoedm->getMEtoEdmObject();
353 for (
unsigned int i = 0;
i < metoedmobject.size(); ++
i) {
364 for (
unsigned j = 0;
j < fulldir.size() - 1; ++
j) {
366 if (
j != fulldir.size() - 2) dir +=
"/";
370 MonitorElement *me = AddMonitorElement<METype>::call(dbe, &metoedmobject[
i].
object, dir, name, iGetFrom);
371 maybeSetLumiFlag(me, iGetFrom);
374 for(
const auto&
tag: metoedmobject[
i].
tags) {
382 std::vector<std::string> stags;
383 dbe->getAllTags(stags);
384 for (
unsigned int i = 0;
i < stags.size(); ++
i) {
385 std::cout <<
"Tags: " << stags[
i] << std::endl;
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH2S * getTH2S(void) const
TH1S * getTH1S(void) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TProfile2D * getTProfile2D(void) const
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
EDMtoMEConverter(const edm::ParameterSet &)
TH3F * getTH3F(void) const
TH1D * getTH1D(void) const
virtual void endRun(const edm::Run &, const edm::EventSetup &)
TH2D * getTH2D(void) const
std::tuple< Tokens< TH1F >, Tokens< TH1S >, Tokens< TH1D >, Tokens< TH2F >, Tokens< TH2S >, Tokens< TH2D >, Tokens< TH3F >, Tokens< TProfile >, Tokens< TProfile2D >, Tokens< double >, Tokens< int >, Tokens< long long >, Tokens< TString > > tokens_
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const std::string getFullname(void) const
get full name of ME including Pathname
void set(const edm::InputTag &runInputTag, const edm::InputTag &lumiInputTag, edm::ConsumesCollector &iC)
virtual void respondToOpenInputFile(const edm::FileBlock &)
int64_t getIntValue(void) const
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
TProfile * getTProfile(void) const
virtual ~EDMtoMEConverter()
void getData(const edm::Run &iRun, edm::Handle< Product > &handle) const
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
TH2F * getTH2F(void) const
tuple size
Write out results.
void getData(T &iGetFrom)
T get(const Candidate &c)
std::map< int, int > iCount
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run