Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:19

0001 #ifndef DQWorkerTask_H
0002 #define DQWorkerTask_H
0003 
0004 #include "DQM/EcalCommon/interface/DQWorker.h"
0005 
0006 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
0007 
0008 #include "Collections.h"
0009 
0010 #include <bitset>
0011 
0012 namespace edm {
0013   class TriggerResultsByName;
0014   class ConsumesCollector;
0015 }  // namespace edm
0016 
0017 namespace ecaldqm {
0018 
0019   struct Dependency {
0020     Collections dependant;
0021     std::set<Collections> requisite;
0022 
0023     Dependency() : dependant(Collections(-1)), requisite() {}
0024     Dependency(Collections _d, int _r1 = -1, int _r2 = -1, int _r3 = -1, int _r4 = -1) : dependant(_d), requisite() {
0025       if (_r1 >= 0)
0026         append(Collections(_r1));
0027       if (_r2 >= 0)
0028         append(Collections(_r2));
0029       if (_r3 >= 0)
0030         append(Collections(_r3));
0031       if (_r4 >= 0)
0032         append(Collections(_r4));
0033     }
0034     void append(Collections _r) {
0035       if (_r != int(dependant))
0036         requisite.insert(_r);
0037     }
0038     void append(std::set<Collections> const& _s) {
0039       for (std::set<Collections>::const_iterator sItr(_s.begin()); sItr != _s.end(); ++sItr)
0040         append(*sItr);
0041     }
0042   };
0043 
0044   struct DependencySet {
0045     DependencySet() : set_() {}
0046     void push_back(Dependency const& _d) {
0047       std::vector<Dependency>::iterator dItr(set_.begin());
0048       std::vector<Dependency>::iterator dEnd(set_.end());
0049       for (; dItr != dEnd; ++dItr)
0050         if (dItr->dependant == _d.dependant)
0051           dItr->append(_d.requisite);
0052       if (dItr == dEnd)
0053         set_.push_back(_d);
0054     }
0055     std::vector<Collections> formSequence() const {
0056       std::vector<Collections> sequence;
0057       for (unsigned iD(0); iD < set_.size(); iD++) {
0058         if (std::find(sequence.begin(), sequence.end(), set_[iD].dependant) != sequence.end())
0059           continue;
0060         formSequenceFragment_(set_[iD], sequence, sequence.end());
0061       }
0062       return sequence;
0063     }
0064 
0065   private:
0066     std::vector<Dependency> set_;
0067 
0068     void formSequenceFragment_(Dependency const&, std::vector<Collections>&, std::vector<Collections>::iterator) const;
0069   };
0070 
0071   class DQWorkerTask : public DQWorker {
0072   public:
0073     typedef EcalDCCHeaderBlock::EcalDCCEventSettings EventSettings;
0074 
0075     DQWorkerTask();
0076     ~DQWorkerTask() override {}
0077 
0078     static void fillDescriptions(edm::ParameterSetDescription&);
0079 
0080     virtual void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) {}
0081     virtual void endEvent(edm::Event const&, edm::EventSetup const&) {}
0082 
0083     virtual bool filterRunType(short const*) { return true; };
0084     virtual bool filterTrigger(edm::TriggerResultsByName const&) { return true; };
0085     virtual void addDependencies(DependencySet&) {}
0086 
0087     // mechanisms to register EDGetTokens for any additional objects used internally
0088     virtual void setTokens(edm::ConsumesCollector&) {}
0089 
0090     // "Dry-run" mode when passed a null pointer
0091     // Returns true if the module runs on the collection
0092     virtual bool analyze(void const*, Collections) { return false; }
0093 
0094   protected:
0095     void setME(edm::ParameterSet const&) final;
0096   };
0097 }  // namespace ecaldqm
0098 #endif