CMS 3D CMS Logo

DQWorkerTask.h
Go to the documentation of this file.
1 #ifndef DQWorkerTask_H
2 #define DQWorkerTask_H
3 
5 
7 
8 #include "Collections.h"
9 
10 #include <bitset>
11 
12 namespace edm {
14  class ConsumesCollector;
15 } // namespace edm
16 
17 namespace ecaldqm {
18 
19  struct Dependency {
21  std::set<Collections> requisite;
22 
24  Dependency(Collections _d, int _r1 = -1, int _r2 = -1, int _r3 = -1, int _r4 = -1) : dependant(_d), requisite() {
25  if (_r1 >= 0)
26  append(Collections(_r1));
27  if (_r2 >= 0)
28  append(Collections(_r2));
29  if (_r3 >= 0)
30  append(Collections(_r3));
31  if (_r4 >= 0)
32  append(Collections(_r4));
33  }
34  void append(Collections _r) {
35  if (_r != int(dependant))
36  requisite.insert(_r);
37  }
38  void append(std::set<Collections> const& _s) {
39  for (std::set<Collections>::const_iterator sItr(_s.begin()); sItr != _s.end(); ++sItr)
40  append(*sItr);
41  }
42  };
43 
44  struct DependencySet {
46  void push_back(Dependency const& _d) {
47  std::vector<Dependency>::iterator dItr(set_.begin());
48  std::vector<Dependency>::iterator dEnd(set_.end());
49  for (; dItr != dEnd; ++dItr)
50  if (dItr->dependant == _d.dependant)
51  dItr->append(_d.requisite);
52  if (dItr == dEnd)
53  set_.push_back(_d);
54  }
55  std::vector<Collections> formSequence() const {
56  std::vector<Collections> sequence;
57  for (unsigned iD(0); iD < set_.size(); iD++) {
58  if (std::find(sequence.begin(), sequence.end(), set_[iD].dependant) != sequence.end())
59  continue;
60  formSequenceFragment_(set_[iD], sequence, sequence.end());
61  }
62  return sequence;
63  }
64 
65  private:
66  std::vector<Dependency> set_;
67 
68  void formSequenceFragment_(Dependency const&, std::vector<Collections>&, std::vector<Collections>::iterator) const;
69  };
70 
71  class DQWorkerTask : public DQWorker {
72  public:
74 
75  DQWorkerTask();
76  ~DQWorkerTask() override {}
77 
79 
80  virtual void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) {}
81  virtual void endEvent(edm::Event const&, edm::EventSetup const&) {}
82 
83  virtual bool filterRunType(short const*) { return true; };
84  virtual bool filterTrigger(edm::TriggerResultsByName const&) { return true; };
85  virtual void addDependencies(DependencySet&) {}
86 
87  // mechanisms to register EDGetTokens for any additional objects used internally
89 
90  // "Dry-run" mode when passed a null pointer
91  // Returns true if the module runs on the collection
92  virtual bool analyze(void const*, Collections) { return false; }
93 
94  protected:
95  void setME(edm::ParameterSet const&) final;
96  };
97 } // namespace ecaldqm
98 #endif
ecaldqm::DependencySet::set_
std::vector< Dependency > set_
Definition: DQWorkerTask.h:66
ecaldqm
Definition: DQWorker.h:37
TriggerResultsByName
ecaldqm::Dependency::requisite
std::set< Collections > requisite
Definition: DQWorkerTask.h:21
ecaldqm::Dependency::Dependency
Dependency(Collections _d, int _r1=-1, int _r2=-1, int _r3=-1, int _r4=-1)
Definition: DQWorkerTask.h:24
ecaldqm::DependencySet
Definition: DQWorkerTask.h:44
edm
HLT enums.
Definition: AlignableModifier.h:19
ecaldqm::DependencySet::DependencySet
DependencySet()
Definition: DQWorkerTask.h:45
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ecaldqm::DQWorkerTask::setTokens
virtual void setTokens(edm::ConsumesCollector &)
Definition: DQWorkerTask.h:88
ecaldqm::Dependency
Definition: DQWorkerTask.h:19
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ecaldqm::Dependency::append
void append(Collections _r)
Definition: DQWorkerTask.h:34
ecaldqm::DQWorkerTask::setME
void setME(edm::ParameterSet const &) final
Definition: DQWorkerTask.cc:13
ecaldqm::DQWorker
Definition: DQWorker.h:41
ecaldqm::DQWorkerTask::analyze
virtual bool analyze(void const *, Collections)
Definition: DQWorkerTask.h:92
ecaldqm::DQWorkerTask::addDependencies
virtual void addDependencies(DependencySet &)
Definition: DQWorkerTask.h:85
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
ecaldqm::Dependency::append
void append(std::set< Collections > const &_s)
Definition: DQWorkerTask.h:38
ecaldqm::DQWorkerTask::DQWorkerTask
DQWorkerTask()
Definition: DQWorkerTask.cc:8
ecaldqm::DependencySet::formSequence
std::vector< Collections > formSequence() const
Definition: DQWorkerTask.h:55
EcalDCCHeaderBlock::EcalDCCEventSettings
Definition: EcalDCCHeaderBlock.h:64
edm::ParameterSet
Definition: ParameterSet.h:47
ecaldqm::DependencySet::push_back
void push_back(Dependency const &_d)
Definition: DQWorkerTask.h:46
edm::TriggerResultsByName
Definition: TriggerResultsByName.h:48
ecaldqm::Collections
Collections
Definition: Collections.h:8
DQWorker.h
EcalDCCHeaderBlock.h
edm::EventSetup
Definition: EventSetup.h:58
Collections.h
ecaldqm::Dependency::Dependency
Dependency()
Definition: DQWorkerTask.h:23
ecaldqm::Dependency::dependant
Collections dependant
Definition: DQWorkerTask.h:20
ecaldqm::DQWorkerTask::filterRunType
virtual bool filterRunType(short const *)
Definition: DQWorkerTask.h:83
ecaldqm::DQWorkerTask::EventSettings
EcalDCCHeaderBlock::EcalDCCEventSettings EventSettings
Definition: DQWorkerTask.h:73
ecaldqm::DQWorkerTask::filterTrigger
virtual bool filterTrigger(edm::TriggerResultsByName const &)
Definition: DQWorkerTask.h:84
ecaldqm::DQWorkerTask::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &)
Definition: DQWorkerTask.cc:11
ecaldqm::DependencySet::formSequenceFragment_
void formSequenceFragment_(Dependency const &, std::vector< Collections > &, std::vector< Collections >::iterator) const
Definition: DQWorkerTask.cc:22
ecaldqm::DQWorkerTask::~DQWorkerTask
~DQWorkerTask() override
Definition: DQWorkerTask.h:76
ecaldqm::DQWorkerTask::endEvent
virtual void endEvent(edm::Event const &, edm::EventSetup const &)
Definition: DQWorkerTask.h:81
edm::Event
Definition: Event.h:73
ecaldqm::DQWorkerTask::beginEvent
virtual void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &)
Definition: DQWorkerTask.h:80
edm::ConsumesCollector
Definition: ConsumesCollector.h:45