17 #include "TStopwatch.h"
76 throw cms::Exception(
"InvalidConfiguration") <<
"Undefined collection " << _collection;
95 for(std::vector<ecaldqm::DQWorkerTask *>::iterator wItr(
taskLists_[_collection].
begin()); wItr !=
taskLists_[_collection].end(); ++wItr){
117 if(_evt.getByToken(collectionTokens_[_collection], ebHndl) && _evt.getByToken(collectionTokens_[_collection], eeHndl)){
118 unsigned nEB(ebHndl->size());
119 unsigned nEE(eeHndl->size());
121 if(nEB == 0 && nEE == 0)
return;
124 for(
unsigned iId(0); iId < nEB; iId++) ids.
push_back(
DetId(ebHndl->at(iId)));
125 for(
unsigned iId(0); iId < nEE; iId++) ids.
push_back(
DetId(eeHndl->at(iId)));
135 for(std::vector<ecaldqm::DQWorkerTask *>::iterator wItr(taskLists_[_collection].
begin()); wItr != taskLists_[_collection].end(); ++wItr){
137 if(evaluateTime_) sw->Start();
138 if(enabled_[task]) task->
analyze(const_cast<const DetIdCollection*>(&ids), _collection);
141 taskTimes_[task] += sw->RealTime();
147 else if(!allowMissingCollections_)
152 EcalDQMonitorTask::formSchedule_(std::vector<ecaldqm::Collections>
const& _usedCollections, std::multimap<ecaldqm::Collections, ecaldqm::Collections>
const& _dependencies)
154 typedef std::multimap<ecaldqm::Collections, ecaldqm::Collections>::const_iterator mmiter;
156 std::vector<ecaldqm::Collections> preSchedule;
157 std::vector<ecaldqm::Collections>::iterator insertPoint, findPoint;
159 for(std::vector<ecaldqm::Collections>::const_iterator colItr(_usedCollections.begin()); colItr != _usedCollections.end(); ++colItr){
162 if((insertPoint =
find(preSchedule.begin(), preSchedule.end(), *colItr)) == preSchedule.end()) inserted =
false;
164 std::pair<mmiter, mmiter> range(_dependencies.equal_range(*colItr));
166 for(mmiter depItr(range.first); depItr != range.second; ++depItr){
168 if(depItr->second == depItr->first)
169 throw cms::Exception(
"Fatal") <<
"Collection " << depItr->second <<
" depends on itself";
170 if(
find(_usedCollections.begin(), _usedCollections.end(), depItr->second) == _usedCollections.end())
171 throw cms::Exception(
"Fatal") <<
"Collection " << depItr->first <<
" depends on Collection " << depItr->second;
173 if((findPoint =
find(preSchedule.begin(), preSchedule.end(), depItr->second)) == preSchedule.end())
174 preSchedule.insert(insertPoint, depItr->second);
175 else if(findPoint > insertPoint)
176 throw cms::Exception(
"InvalidConfiguration") <<
"Circular dependencies in Collections";
180 if(!inserted) preSchedule.push_back(*colItr);
184 for(std::vector<ecaldqm::Collections>::const_iterator colItr(preSchedule.begin()); colItr != preSchedule.end(); ++colItr){
185 std::pair<Processor, ecaldqm::Collections> sch;
189 sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>;
break;
191 sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>;
break;
193 sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>;
break;
195 sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>;
break;
197 sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>;
break;
199 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
201 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
203 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
205 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
207 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
209 sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
break;
211 sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>;
break;
213 sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>;
break;
215 sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>;
break;
217 sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>;
break;
219 sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>;
break;
221 sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
break;
223 sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
break;
225 sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
break;
227 sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
break;
229 sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
break;
231 sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
break;
233 sch.first = &EcalDQMonitorTask::runOnCollection<reco::BasicClusterCollection>;
break;
235 sch.first = &EcalDQMonitorTask::runOnCollection<reco::BasicClusterCollection>;
break;
237 sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
break;
239 sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
break;
241 throw cms::Exception(
"InvalidConfiguration") <<
"Undefined collection " << *colItr;
244 sch.second = *colItr;
std::map< ecaldqm::DQWorkerTask *, bool > enabled_
void formSchedule_(std::vector< ecaldqm::Collections > const &, std::multimap< ecaldqm::Collections, ecaldqm::Collections > const &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetToken collectionTokens_[ecaldqm::nCollections]
void push_back(T const &t)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< ecaldqm::DQWorkerTask *, double > taskTimes_
std::string const collectionName[nCollections]
virtual void analyze(const void *, Collections)
void registerCollection(ecaldqm::Collections, edm::InputTag const &)
std::vector< std::pair< Processor, ecaldqm::Collections > > schedule_
std::vector< ecaldqm::DQWorkerTask * > taskLists_[ecaldqm::nCollections]
T const * product() const
bool allowMissingCollections_
void runOnCollection(edm::Event const &, ecaldqm::Collections)