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  * $Date: 2012/04/27 13:46:01 $
5  * $Revision: 1.15 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 #include <vector>
12 
17 
20 
23 
25 
27 
29 
31 
33 
34  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
35 
36  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
37 
38  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
39 
40  meEBDaqFraction_ = 0;
42  for (int i = 0; i < 36; i++) {
43  meEBDaqActive_[i] = 0;
44  }
45 
46 }
47 
49 
50 }
51 
53 
55 
56  if ( dqmStore_ ) {
57 
58  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
59 
60  name = "DAQSummary";
62  meEBDaqFraction_->Fill(0.0);
63 
64  name = "DAQSummaryMap";
65  meEBDaqActiveMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
66  meEBDaqActiveMap_->setAxisTitle("jphi", 1);
67  meEBDaqActiveMap_->setAxisTitle("jeta", 2);
68 
69  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
70 
71  for (int i = 0; i < 36; i++) {
72  name = "EcalBarrel_" + Numbers::sEB(i+1);
74  meEBDaqActive_[i]->Fill(0.0);
75  }
76 
77  }
78 
79 }
80 
82 
83  if ( enableCleanup_ ) this->cleanup();
84 
85 }
86 
88 
89  // information is by run, so fill the same for the run and for every lumi section
90  for ( int iett = 0; iett < 34; iett++ ) {
91  for ( int iptt = 0; iptt < 72; iptt++ ) {
92  readyLumi[iptt][iett] = 1;
93  }
94  }
95 
96 
97  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDAQTowerStatusRcd>() ) ) {
98  edm::LogWarning("EBDaqInfoTask") << "EcalDAQTowerStatus record not found";
99  return;
100  }
101 
103  iSetup.get<EcalDAQTowerStatusRcd>().get(pDAQStatus);
104  if ( !pDAQStatus.isValid() ) {
105  edm::LogWarning("EBDaqInfoTask") << "EcalDAQTowerStatus record not valid";
106  return;
107  }
108  const EcalDAQTowerStatus* daqStatus = pDAQStatus.product();
109 
110  for(int iz=-1; iz<=1; iz+=2) {
111  for(int iptt=0 ; iptt<72; iptt++) {
112  for(int iett=0 ; iett<17; iett++) {
113  if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,iett+1,iptt+1 )){
114 
115  EcalTrigTowerDetId ebid(iz,EcalBarrel,iett+1,iptt+1);
116 
117  uint16_t dbStatus = 0; // 0 = good
118  EcalDAQTowerStatus::const_iterator daqStatusIt = daqStatus->find( ebid.rawId() );
119  if ( daqStatusIt != daqStatus->end() ) dbStatus = daqStatusIt->getStatusCode();
120 
121  if ( dbStatus > 0 ) {
122  int ipttEB = iptt;
123  int iettEB = (iz==-1) ? iett : 17+iett;
124  readyRun[ipttEB][iettEB] = 0;
125  readyLumi[ipttEB][iettEB] = 0;
126  }
127 
128  }
129  }
130  }
131  }
132 
133 }
134 
135 
136 
138 
140 
141 }
142 
144 
145  if ( ! mergeRuns_ ) this->reset();
146 
147  for ( int iett = 0; iett < 34; iett++ ) {
148  for ( int iptt = 0; iptt < 72; iptt++ ) {
149  readyRun[iptt][iett] = 1;
150  }
151  }
152 
153 }
154 
156 
158 
159 }
160 
162 
164 
165  for (int i = 0; i < 36; i++) {
166  if ( meEBDaqActive_[i] ) meEBDaqActive_[i]->Reset();
167  }
168 
170 
171 }
172 
173 
175 
176  if ( dqmStore_ ) {
177 
178  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
179 
181 
183 
184  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
185 
186  for (int i = 0; i < 36; i++) {
187  if ( meEBDaqActive_[i] ) dqmStore_->removeElement( meEBDaqActive_[i]->getName() );
188  }
189 
190  }
191 
192 }
193 
194 void EBDaqInfoTask::fillMonitorElements(int ready[72][34]) {
195 
196  float readySum[36];
197  for ( int ism = 0; ism < 36; ism++ ) readySum[ism] = 0;
198  float readySumTot = 0.;
199 
200  for ( int iett = 0; iett < 34; iett++ ) {
201  for ( int iptt = 0; iptt < 72; iptt++ ) {
202 
203  if(meEBDaqActiveMap_) meEBDaqActiveMap_->setBinContent( iptt+1, iett+1, ready[iptt][iett] );
204 
205  int ism = ( iett<17 ) ? iptt/4 : 18+iptt/4;
206  if(ready[iptt][iett]) {
207  readySum[ism]++;
208  readySumTot++;
209  }
210 
211  }
212  }
213 
214  for ( int ism = 0; ism < 36; ism++ ) {
215  if( meEBDaqActive_[ism] ) meEBDaqActive_[ism]->Fill( readySum[ism]/68. );
216  }
217 
218  if( meEBDaqFraction_ ) meEBDaqFraction_->Fill(readySumTot/34./72.);
219 
220 }
221 
223 
224 }
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:94
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:73
const_iterator find(uint32_t rawId) const
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
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:45
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
MonitorElement * meEBDaqActiveMap_
Definition: EBDaqInfoTask.h:70
MonitorElement * meEBDaqFraction_
Definition: EBDaqInfoTask.h:68
int readyRun[72][34]
Definition: EBDaqInfoTask.h:72
void beginJob(void)
BeginJob.
std::string prefixME_
Definition: EBDaqInfoTask.h:62
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
std::vector< Item >::const_iterator const_iterator
MonitorElement * meEBDaqActive_[36]
Definition: EBDaqInfoTask.h:69
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:850
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
DQMStore * dqmStore_
Definition: EBDaqInfoTask.h:60
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:434
Definition: Run.h:36
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.