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.
2 
4 
16 
17 #include "TStopwatch.h"
18 
19 using namespace ecaldqm;
20 
21 template <class C>
22 void
24 {
25  edm::Handle<C> hndl;
26  if(_evt.getByLabel(collectionTags_[_colName], hndl)){
27 
28  TStopwatch* sw(0);
29  if(evaluateTime_){
30  sw = new TStopwatch;
31  sw->Stop();
32  }
33 
34  DQWorkerTask* task(0);
35 
36  for(std::vector<DQWorkerTask *>::iterator wItr(taskLists_[_colName].begin()); wItr != taskLists_[_colName].end(); ++wItr){
37  task = *wItr;
38  if(evaluateTime_) sw->Start();
39  if(enabled_[task]) task->analyze(hndl.product(), _colName);
40  if(evaluateTime_){
41  sw->Stop();
42  taskTimes_[task] += sw->RealTime();
43  }
44  }
45 
46  delete sw;
47  }
48  else if(!allowMissingCollections_)
49  throw cms::Exception("ObjectNotFound") << "Collection with InputTag " << collectionTags_[_colName] << " does not exist";
50 }
51 
52 template <>
53 void
54 EcalDQMonitorTask::runOnCollection<DetIdCollection>(const edm::Event& _evt, Collections _colName)
55 {
58  if(_evt.getByLabel(collectionTags_[_colName], ebHndl) && _evt.getByLabel(collectionTags_[_colName], eeHndl)){
59  unsigned nEB(ebHndl->size());
60  unsigned nEE(eeHndl->size());
61 
62  if(nEB == 0 && nEE == 0) return;
63 
64  DetIdCollection ids;
65  for(unsigned iId(0); iId < nEB; iId++) ids.push_back(DetId(ebHndl->at(iId)));
66  for(unsigned iId(0); iId < nEE; iId++) ids.push_back(DetId(eeHndl->at(iId)));
67 
68  TStopwatch* sw(0);
69  if(evaluateTime_){
70  sw = new TStopwatch;
71  sw->Stop();
72  }
73 
74  DQWorkerTask* task(0);
75 
76  for(std::vector<DQWorkerTask *>::iterator wItr(taskLists_[_colName].begin()); wItr != taskLists_[_colName].end(); ++wItr){
77  task = *wItr;
78  if(evaluateTime_) sw->Start();
79  if(enabled_[task]) task->analyze(const_cast<const DetIdCollection*>(&ids), _colName);
80  if(evaluateTime_){
81  sw->Stop();
82  taskTimes_[task] += sw->RealTime();
83  }
84  }
85 
86  delete sw;
87  }
88  else if(!allowMissingCollections_)
89  throw cms::Exception("ObjectNotFound") << "DetIdCollection with InputTag " << collectionTags_[_colName] << " does not exist";
90 }
91 
92 void
93 EcalDQMonitorTask::formSchedule_(const std::vector<Collections>& _usedCollections, const std::multimap<Collections, Collections>& _dependencies)
94 {
95  using namespace std;
96  typedef multimap<Collections, Collections>::const_iterator mmiter;
97 
98  vector<Collections> preSchedule;
99  vector<Collections>::iterator insertPoint, findPoint;
100 
101  for(vector<Collections>::const_iterator colItr(_usedCollections.begin()); colItr != _usedCollections.end(); ++colItr){
102 
103  bool inserted(true);
104  if((insertPoint = find(preSchedule.begin(), preSchedule.end(), *colItr)) == preSchedule.end()) inserted = false;
105 
106  pair<mmiter, mmiter> range(_dependencies.equal_range(*colItr));
107 
108  for(mmiter depItr(range.first); depItr != range.second; ++depItr){
109 
110  if(depItr->second == depItr->first)
111  throw cms::Exception("Fatal") << "Collection " << depItr->second << " depends on itself";
112  if(find(_usedCollections.begin(), _usedCollections.end(), depItr->second) == _usedCollections.end())
113  throw cms::Exception("Fatal") << "Collection " << depItr->first << " depends on Collection " << depItr->second;
114 
115  if((findPoint = find(preSchedule.begin(), preSchedule.end(), depItr->second)) == preSchedule.end())
116  preSchedule.insert(insertPoint, depItr->second);
117  else if(findPoint > insertPoint)
118  throw cms::Exception("InvalidConfiguration") << "Circular dependencies in Collections";
119 
120  }
121 
122  if(!inserted) preSchedule.push_back(*colItr);
123 
124  }
125 
126  for(vector<Collections>::const_iterator colItr(preSchedule.begin()); colItr != preSchedule.end(); ++colItr){
127  std::pair<Processor, Collections> sch;
128 
129  switch(*colItr){
130  case kSource:
131  sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>; break;
132  case kEcalRawData:
133  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>; break;
134  case kGainErrors:
135  sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>; break;
136  case kChIdErrors:
137  sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>; break;
138  case kGainSwitchErrors:
139  sch.first = &EcalDQMonitorTask::runOnCollection<DetIdCollection>; break;
140  case kTowerIdErrors:
141  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
142  case kBlockSizeErrors:
143  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
144  case kMEMTowerIdErrors:
145  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
146  case kMEMBlockSizeErrors:
147  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
148  case kMEMChIdErrors:
149  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
150  case kMEMGainErrors:
151  sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>; break;
152  case kEBSrFlag:
153  sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>; break;
154  case kEESrFlag:
155  sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>; break;
156  case kEBDigi:
157  sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>; break;
158  case kEEDigi:
159  sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>; break;
160  case kPnDiodeDigi:
161  sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>; break;
162  case kTrigPrimDigi:
163  sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>; break;
164  case kTrigPrimEmulDigi:
165  sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>; break;
166  case kEBUncalibRecHit:
167  sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>; break;
168  case kEEUncalibRecHit:
169  sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>; break;
170  case kEBRecHit:
171  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>; break;
172  case kEERecHit:
173  sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>; break;
174  case kEBBasicCluster:
175  sch.first = &EcalDQMonitorTask::runOnCollection<reco::BasicClusterCollection>; break;
176  case kEEBasicCluster:
177  sch.first = &EcalDQMonitorTask::runOnCollection<reco::BasicClusterCollection>; break;
178  case kEBSuperCluster:
179  sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>; break;
180  case kEESuperCluster:
181  sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>; break;
182  default:
183  throw cms::Exception("InvalidConfiguration") << "Undefined collection " << *colItr;
184  }
185 
186  sch.second = *colItr;
187 
188  schedule_.push_back(sch);
189  }
190 
191 }
void push_back(T const &t)
Definition: EDCollection.h:68
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void formSchedule_(const std::vector< ecaldqm::Collections > &, const std::multimap< ecaldqm::Collections, ecaldqm::Collections > &)
virtual void analyze(const void *, Collections)
Definition: DQWorkerTask.h:25
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Definition: DetId.h:20
T const * product() const
Definition: Handle.h:74
#define begin
Definition: vmac.h:31
void runOnCollection(const edm::Event &, ecaldqm::Collections)