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 template <typename CollectionClass>
20 void
21 EcalDQMonitorTask::runOnCollection(edm::Event const& _evt, ecaldqm::Collections _col, std::set<ecaldqm::DQWorker*> const& _enabledTasks)
22 {
24  if(!_evt.getByToken(collectionTokens_[_col], hndl)){
26  throw cms::Exception("ObjectNotFound") << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col] << " does not exist";
27  edm::LogWarning("EcalDQM") << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col] << " does not exist";
28  return;
29  }
30 
31  CollectionClass const* collection(hndl.product());
32 
33  executeOnWorkers_([collection, _col, &_enabledTasks, this](ecaldqm::DQWorker* worker){
34  if(_enabledTasks.find(worker) != _enabledTasks.end())
35  static_cast<ecaldqm::DQWorkerTask*>(worker)->analyze(collection, _col);
36  }, "analyze");
37 
38  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << moduleName_ << "::runOn" << ecaldqm::collectionName[_col] << " returning";
39 }
40 
41 void
42 EcalDQMonitorTask::formSchedule(std::vector<ecaldqm::Collections> const& _preSchedule, edm::ParameterSet const& _tagPSet)
43 {
44  for(std::vector<ecaldqm::Collections>::const_iterator colItr(_preSchedule.begin()); colItr != _preSchedule.end(); ++colItr){
45  std::pair<Processor, ecaldqm::Collections> sch;
46 
48 
49  switch(*colItr){
50  case ecaldqm::kSource:
51  collectionTokens_[*colItr] = edm::EDGetToken(consumes<FEDRawDataCollection>(tag));
52  sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>;
53  break;
55  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRawDataCollection>(tag));
56  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>;
57  break;
61  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDetIdCollection>(tag));
62  sch.first = &EcalDQMonitorTask::runOnCollection<EBDetIdCollection>;
63  break;
67  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDetIdCollection>(tag));
68  sch.first = &EcalDQMonitorTask::runOnCollection<EEDetIdCollection>;
69  break;
76  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalElectronicsIdCollection>(tag));
77  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
78  break;
79  case ecaldqm::kEBSrFlag:
80  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBSrFlagCollection>(tag));
81  sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>;
82  break;
83  case ecaldqm::kEESrFlag:
84  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EESrFlagCollection>(tag));
85  sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>;
86  break;
87  case ecaldqm::kEBDigi:
88  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDigiCollection>(tag));
89  sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>;
90  break;
91  case ecaldqm::kEEDigi:
92  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDigiCollection>(tag));
93  sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>;
94  break;
96  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalPnDiodeDigiCollection>(tag));
97  sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>;
98  break;
101  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalTrigPrimDigiCollection>(tag));
102  sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
103  break;
110  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalUncalibratedRecHitCollection>(tag));
111  sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
112  break;
113  case ecaldqm::kEBRecHit:
115  case ecaldqm::kEERecHit:
117  collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRecHitCollection>(tag));
118  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
119  break;
123  sch.first = &EcalDQMonitorTask::runOnCollection<edm::View<reco::CaloCluster> >;
124  break;
127  collectionTokens_[*colItr] = edm::EDGetToken(consumes<reco::SuperClusterCollection>(tag));
128  sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
129  break;
130  default:
131  throw cms::Exception("InvalidConfiguration") << "Undefined collection " << *colItr;
132  }
133 
134  sch.second = *colItr;
135 
136  schedule_.push_back(sch);
137  }
138 }
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:464
edm::EDGetToken collectionTokens_[ecaldqm::nCollections]
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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:39
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1)
Definition: EcalDQMonitor.h:45
std::vector< std::pair< Processor, ecaldqm::Collections > > schedule_
T const * product() const
Definition: Handle.h:81