CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBDaqInfoTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBDaqInfoTask.cc
3  *
4  * \author E. Di Marco
5  *
6 */
7 
8 #include <iostream>
9 #include <vector>
10 
15 
18 
21 
23 
25 
27 
29 
31 
32  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
33 
34  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
35 
36  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
37 
38  meEBDaqFraction_ = 0;
40  for (int i = 0; i < 36; i++) {
41  meEBDaqActive_[i] = 0;
42  }
43 
44 }
45 
47 
48 }
49 
51 
53 
54  if ( dqmStore_ ) {
55 
56  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
57 
58  name = "DAQSummary";
60  meEBDaqFraction_->Fill(0.0);
61 
62  name = "DAQSummaryMap";
63  meEBDaqActiveMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
64  meEBDaqActiveMap_->setAxisTitle("jphi", 1);
65  meEBDaqActiveMap_->setAxisTitle("jeta", 2);
66 
67  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
68 
69  for (int i = 0; i < 36; i++) {
70  name = "EcalBarrel_" + Numbers::sEB(i+1);
72  meEBDaqActive_[i]->Fill(0.0);
73  }
74 
75  }
76 
77 }
78 
80 
81  if ( enableCleanup_ ) this->cleanup();
82 
83 }
84 
86 
87  // information is by run, so fill the same for the run and for every lumi section
88  for ( int iett = 0; iett < 34; iett++ ) {
89  for ( int iptt = 0; iptt < 72; iptt++ ) {
90  readyLumi[iptt][iett] = 1;
91  }
92  }
93 
94 
95  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDAQTowerStatusRcd>() ) ) {
96  edm::LogWarning("EBDaqInfoTask") << "EcalDAQTowerStatus record not found";
97  return;
98  }
99 
101  iSetup.get<EcalDAQTowerStatusRcd>().get(pDAQStatus);
102  if ( !pDAQStatus.isValid() ) {
103  edm::LogWarning("EBDaqInfoTask") << "EcalDAQTowerStatus record not valid";
104  return;
105  }
106  const EcalDAQTowerStatus* daqStatus = pDAQStatus.product();
107 
108  for(int iz=-1; iz<=1; iz+=2) {
109  for(int iptt=0 ; iptt<72; iptt++) {
110  for(int iett=0 ; iett<17; iett++) {
111  if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,iett+1,iptt+1 )){
112 
113  EcalTrigTowerDetId ebid(iz,EcalBarrel,iett+1,iptt+1);
114 
115  uint16_t dbStatus = 0; // 0 = good
116  EcalDAQTowerStatus::const_iterator daqStatusIt = daqStatus->find( ebid.rawId() );
117  if ( daqStatusIt != daqStatus->end() ) dbStatus = daqStatusIt->getStatusCode();
118 
119  if ( dbStatus > 0 ) {
120  int ipttEB = iptt;
121  int iettEB = (iz==-1) ? iett : 17+iett;
122  readyRun[ipttEB][iettEB] = 0;
123  readyLumi[ipttEB][iettEB] = 0;
124  }
125 
126  }
127  }
128  }
129  }
130 
131 }
132 
133 
134 
136 
138 
139 }
140 
142 
143  if ( ! mergeRuns_ ) this->reset();
144 
145  for ( int iett = 0; iett < 34; iett++ ) {
146  for ( int iptt = 0; iptt < 72; iptt++ ) {
147  readyRun[iptt][iett] = 1;
148  }
149  }
150 
151 }
152 
154 
156 
157 }
158 
160 
162 
163  for (int i = 0; i < 36; i++) {
164  if ( meEBDaqActive_[i] ) meEBDaqActive_[i]->Reset();
165  }
166 
168 
169 }
170 
171 
173 
174  if ( dqmStore_ ) {
175 
176  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
177 
179 
181 
182  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
183 
184  for (int i = 0; i < 36; i++) {
185  if ( meEBDaqActive_[i] ) dqmStore_->removeElement( meEBDaqActive_[i]->getName() );
186  }
187 
188  }
189 
190 }
191 
192 void EBDaqInfoTask::fillMonitorElements(int ready[72][34]) {
193 
194  float readySum[36];
195  for ( int ism = 0; ism < 36; ism++ ) readySum[ism] = 0;
196  float readySumTot = 0.;
197 
198  for ( int iett = 0; iett < 34; iett++ ) {
199  for ( int iptt = 0; iptt < 72; iptt++ ) {
200 
201  if(meEBDaqActiveMap_) meEBDaqActiveMap_->setBinContent( iptt+1, iett+1, ready[iptt][iett] );
202 
203  int ism = ( iett<17 ) ? iptt/4 : 18+iptt/4;
204  if(ready[iptt][iett]) {
205  readySum[ism]++;
206  readySumTot++;
207  }
208 
209  }
210  }
211 
212  for ( int ism = 0; ism < 36; ism++ ) {
213  if( meEBDaqActive_[ism] ) meEBDaqActive_[ism]->Fill( readySum[ism]/68. );
214  }
215 
216  if( meEBDaqFraction_ ) meEBDaqFraction_->Fill(readySumTot/34./72.);
217 
218 }
219 
221 
222 }
void cleanup(void)
Cleanup.
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
void setBinContent(int binx, double content)
set content of bin (1-D)
void fillMonitorElements(int ready[72][34])
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
void endJob(void)
EndJob.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void reset(void)
Reset.
int readyLumi[72][34]
Definition: EBDaqInfoTask.h:71
const_iterator find(uint32_t rawId) const
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:809
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void Fill(long long x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
MonitorElement * meEBDaqActiveMap_
Definition: EBDaqInfoTask.h:68
MonitorElement * meEBDaqFraction_
Definition: EBDaqInfoTask.h:66
int readyRun[72][34]
Definition: EBDaqInfoTask.h:70
void beginJob(void)
BeginJob.
std::string prefixME_
Definition: EBDaqInfoTask.h:60
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
virtual ~EBDaqInfoTask()
Destructor.
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
MonitorElement * meEBDaqActive_[36]
Definition: EBDaqInfoTask.h:67
bool isValid() const
Definition: ESHandle.h:37
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
DQMStore * dqmStore_
Definition: EBDaqInfoTask.h:58
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
EBDaqInfoTask(const edm::ParameterSet &ps)
Constructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.