CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalDQMonitorTask2.cc
Go to the documentation of this file.
1 #include "../interface/EcalDQMonitorTask.h"
2 
3 #include "../interface/DQWorkerTask.h"
4 
18 
19 #include "TStopwatch.h"
20 
21 template <typename CollectionClass>
22 void
23 EcalDQMonitorTask::runOnCollection(edm::Event const& _evt, ecaldqm::Collections _col, std::set<ecaldqm::DQWorker*> const& _enabledTasks)
24 {
26  if(!_evt.getByToken(collectionTokens_[_col], hndl)){
28  throw cms::Exception("ObjectNotFound") << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col] << " does not exist";
29  edm::LogWarning("EcalDQM") << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col] << " does not exist";
30  return;
31  }
32 
33  CollectionClass const* collection(hndl.product());
34 
35  TStopwatch sw;
36  sw.Reset();
37 
38  executeOnWorkers_([collection, _col, &_enabledTasks, &sw, this](ecaldqm::DQWorker* worker){
39  if(_enabledTasks.find(worker) != _enabledTasks.end()){
40  if(this->evaluateTime_) sw.Start();
41  static_cast<ecaldqm::DQWorkerTask*>(worker)->analyze(collection, _col);
42  if(this->evaluateTime_) this->taskTimes_[worker] += sw.RealTime();
43  }
44  }, "analyze");
45 
46  edm::LogInfo("EcalDQM") << moduleName_ << "::runOn" << ecaldqm::collectionName[_col] << " returning";
47 }
48 
49 void
50 EcalDQMonitorTask::formSchedule(std::vector<ecaldqm::Collections> const& _preSchedule, edm::ParameterSet const& _tagPSet)
51 {
52  for(std::vector<ecaldqm::Collections>::const_iterator colItr(_preSchedule.begin()); colItr != _preSchedule.end(); ++colItr){
53  std::pair<Processor, ecaldqm::Collections> sch;
54 
56 
57  switch(*colItr){
58  case ecaldqm::kSource:
59  collectionTokens_[*colItr] = edm::EDGetToken(consumes<FEDRawDataCollection>(tag));
60  sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>;
61  break;
63  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRawDataCollection>(tag));
64  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>;
65  break;
69  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDetIdCollection>(tag));
70  sch.first = &EcalDQMonitorTask::runOnCollection<EBDetIdCollection>;
71  break;
75  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDetIdCollection>(tag));
76  sch.first = &EcalDQMonitorTask::runOnCollection<EEDetIdCollection>;
77  break;
84  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalElectronicsIdCollection>(tag));
85  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
86  break;
87  case ecaldqm::kEBSrFlag:
88  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBSrFlagCollection>(tag));
89  sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>;
90  break;
91  case ecaldqm::kEESrFlag:
92  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EESrFlagCollection>(tag));
93  sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>;
94  break;
95  case ecaldqm::kEBDigi:
96  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDigiCollection>(tag));
97  sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>;
98  break;
99  case ecaldqm::kEEDigi:
100  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDigiCollection>(tag));
101  sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>;
102  break;
104  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalPnDiodeDigiCollection>(tag));
105  sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>;
106  break;
109  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalTrigPrimDigiCollection>(tag));
110  sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
111  break;
118  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalUncalibratedRecHitCollection>(tag));
119  sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
120  break;
121  case ecaldqm::kEBRecHit:
123  case ecaldqm::kEERecHit:
125  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRecHitCollection>(tag));
126  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
127  break;
131  sch.first = &EcalDQMonitorTask::runOnCollection<edm::View<reco::CaloCluster> >;
132  break;
135  collectionTokens_[*colItr] = edm::EDGetToken(consumes<reco::SuperClusterCollection>(tag));
136  sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
137  break;
138  default:
139  throw cms::Exception("InvalidConfiguration") << "Undefined collection " << *colItr;
140  }
141 
142  sch.second = *colItr;
143 
144  schedule_.push_back(sch);
145  }
146 }
T getUntrackedParameter(std::string const &, T const &) const
void formSchedule(std::vector< ecaldqm::Collections > const &, edm::ParameterSet const &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetToken collectionTokens_[ecaldqm::nCollections]
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void analyze(edm::Event const &, edm::EventSetup const &) override
std::string const collectionName[nCollections]
Definition: Collections.h:45
void runOnCollection(edm::Event const &, ecaldqm::Collections, std::set< ecaldqm::DQWorker * > const &)
std::string const moduleName_
Definition: EcalDQMonitor.h:40
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1)
Definition: EcalDQMonitor.h:56
std::vector< std::pair< Processor, ecaldqm::Collections > > schedule_
std::map< ecaldqm::DQWorker *, double > taskTimes_
T const * product() const
Definition: Handle.h:81