CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEDaqInfoTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEDaqInfoTask.cc
3  *
4  * $Date: 2012/04/27 13:46:14 $
5  * $Revision: 1.18 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 #include <vector>
12 
17 
19 
22 
25 
27 
29 
31 
33 
35 
37 
38  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
39 
40  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
41 
42  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
43 
44  meEEDaqFraction_ = 0;
46  for (int i = 0; i < 18; i++) {
47  meEEDaqActive_[i] = 0;
48  }
49 
50 }
51 
53 
54 }
55 
57 
58  if ( dqmStore_ ) {
59 
61 
62  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
63 
64  meEEDaqFraction_ = dqmStore_->bookFloat( "DAQSummary" );
65  meEEDaqFraction_->Fill(0.0);
66 
67  name = "DAQSummaryMap";
68  meEEDaqActiveMap_ = dqmStore_->book2D(name, name, 40, 0., 200., 20, 0., 100.);
69  meEEDaqActiveMap_->setAxisTitle("ix / ix+100", 1);
71 
72  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
73 
74  for (int i = 0; i < 18; i++) {
75  meEEDaqActive_[i] = dqmStore_->bookFloat( "EcalEndcap_" + Numbers::sEE(i+1) );
76  meEEDaqActive_[i]->Fill(0.0);
77  }
78 
79  }
80 
81 }
82 
84 
85  if ( enableCleanup_ ) this->cleanup();
86 
87 }
88 
90 
91  // information is by run, so fill the same for the run and for every lumi section
92  for ( int itx = 0; itx < 40; itx++ ) {
93  for ( int ity = 0; ity < 20; ity++ ) {
94  readyLumi[itx][ity] = 1;
95  }
96  }
97 
98  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDAQTowerStatusRcd>() ) ) {
99  edm::LogWarning("EEDaqInfoTask") << "EcalDAQTowerStatus record not found";
100  return;
101  }
102 
104  iSetup.get<EcalDAQTowerStatusRcd>().get(pDAQStatus);
105  if ( !pDAQStatus.isValid() ) {
106  edm::LogWarning("EEDaqInfoTask") << "EcalDAQTowerStatus record not valid";
107  return;
108  }
109  const EcalDAQTowerStatus* daqStatus = pDAQStatus.product();
110 
112  iSetup.get< EcalMappingRcd >().get(pElecMapping);
113  if( !pElecMapping.isValid() ) {
114  edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
115  return;
116  }
117  const EcalElectronicsMapping *map = pElecMapping.product();
118 
119  std::vector<DetId> crystals;
120  std::vector<EcalScDetId> scs;
121 
122  for(unsigned i=0 ; i<sizeof(DccId_)/sizeof(int) ; i++){
123  for(int t=1 ; t<=nTowerMax_ ; t++){
124 
125  crystals = map->dccTowerConstituents(DccId_[i], t);
126  if(!crystals.size()) continue;
127 
128  scs = map->getEcalScDetId(DccId_[i], t, false);
129 
130  for(unsigned u=0 ; u<scs.size() ; u++){
131 
132  uint16_t dbStatus = 0; // 0 = good
133  EcalDAQTowerStatus::const_iterator daqStatusIt = daqStatus->find( scs[u].rawId() );
134  if ( daqStatusIt != daqStatus->end() ) dbStatus = daqStatusIt->getStatusCode();
135 
136  if ( dbStatus > 0 ) {
137  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
138  int jy = scs[u].iy() - 1;
139  readyRun[jx][jy] = 0;
140  readyLumi[jx][jy] = 0;
141  }
142  }
143  }
144  }
145 
146 }
147 
149 
151  iSetup.get< EcalMappingRcd >().get(handle);
152  const EcalElectronicsMapping *map = handle.product();
153  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
154  else this->fillMonitorElements(readyLumi, map);
155 
156 }
157 
159 
160  if ( ! mergeRuns_ ) this->reset();
161 
162  for ( int itx = 0; itx < 40; itx++ ) {
163  for ( int ity = 0; ity < 20; ity++ ) {
164  readyRun[itx][ity] = 1;
165  }
166  }
167 
168 }
169 
171 
173  c.get< EcalMappingRcd >().get(handle);
174  const EcalElectronicsMapping *map = handle.product();
175  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
176  else this->fillMonitorElements(readyRun, map);
177 
178 }
179 
181 
183 
184  for (int i = 0; i < 18; i++) {
185  if ( meEEDaqActive_[i] ) meEEDaqActive_[i]->Reset();
186  }
187 
189 
190 }
191 
192 
194 
195  if ( dqmStore_ ) {
196 
197  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
198 
200 
202 
203  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
204 
205  for (int i = 0; i < 18; i++) {
206  if ( meEEDaqActive_[i] ) dqmStore_->removeElement( meEEDaqActive_[i]->getName() );
207  }
208 
209  }
210 
211 }
212 
214 
215  float readySum[18];
216  int nValidChannels[18];
217  for ( int ism = 0; ism < 18; ism++ ) {
218  readySum[ism] = 0;
219  nValidChannels[ism] = 0;
220  }
221  float readySumTot = 0.;
222  int nValidChannelsTot = 0;
223 
224  if(meEEDaqActiveMap_){
225  for(int ix=1 ; ix<=meEEDaqActiveMap_->getNbinsX() ; ix++){
226  for(int iy=1 ; iy<=meEEDaqActiveMap_->getNbinsY() ; iy++){
227  meEEDaqActiveMap_->setBinContent( ix, iy, -1.0 );
228  }
229  }
230  }
231 
232  std::vector<DetId> crystals;
233  std::vector<EcalScDetId> scs;
234 
235  for ( unsigned iDcc = 0; iDcc < sizeof(DccId_)/sizeof(int); iDcc++) {
236  for ( int t = 1; t<=nTowerMax_; t++ ) {
237 
238  crystals = map->dccTowerConstituents(DccId_[iDcc], t);
239  if(!crystals.size()) continue;
240 
241  scs = map->getEcalScDetId(DccId_[iDcc], t, false);
242 
243  for(unsigned u=0 ; u<scs.size() ; u++){ // most of the time one DCC tower = one SC
244 
245  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
246  int jy = scs[u].iy() - 1;
247 
248  if(meEEDaqActiveMap_) meEEDaqActiveMap_->setBinContent( jx+1, jy+1, ready[jx][jy] );
249 
250  int ncrystals = 0;
251 
252  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
253  EEDetId id(*it);
254  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
255  }
256 
257  if(ready[jx][jy]) {
258  readySum[iDcc] += ncrystals;
259  readySumTot += ncrystals;
260  }
261 
262  nValidChannels[iDcc] += ncrystals;
263  nValidChannelsTot += ncrystals;
264 
265  }
266  }
267  if( meEEDaqActive_[iDcc] ) meEEDaqActive_[iDcc]->Fill( readySum[iDcc]/float(nValidChannels[iDcc]) );
268  }
269 
270  if( meEEDaqFraction_ ) meEEDaqFraction_->Fill( readySumTot/float(nValidChannelsTot) );
271 
272 }
273 
275 
276 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:226
int i
Definition: DBlmapReader.cc:9
void endJob(void)
EndJob.
std::string prefixME_
Definition: EEDaqInfoTask.h:67
virtual ~EEDaqInfoTask()
Destructor.
void beginJob(void)
BeginJob.
void setBinContent(int binx, double content)
set content of bin (1-D)
Some &quot;id&quot; conversions.
static const int DccId_[18]
Definition: EEDaqInfoTask.h:58
void reset(void)
Reset.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
const_iterator find(uint32_t rawId) const
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
dictionary map
Definition: Association.py:205
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
MonitorElement * meEEDaqActive_[18]
Definition: EEDaqInfoTask.h:74
static const int nTowerMax_
Definition: EEDaqInfoTask.h:59
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
tuple handle
Definition: patZpeak.py:22
EEDaqInfoTask(const edm::ParameterSet &ps)
Constructor.
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
DQMStore * dqmStore_
Definition: EEDaqInfoTask.h:65
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
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.
int readyLumi[40][20]
Definition: EEDaqInfoTask.h:78
int getNbinsX(void) const
get # of bins in X-axis
int readyRun[40][20]
Definition: EEDaqInfoTask.h:77
MonitorElement * meEEDaqFraction_
Definition: EEDaqInfoTask.h:73
std::vector< Item >::const_iterator const_iterator
void fillMonitorElements(int ready[40][20], const EcalElectronicsMapping *)
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
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)
MonitorElement * meEEDaqActiveMap_
Definition: EEDaqInfoTask.h:75
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.
void cleanup(void)
Cleanup.