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  * \author E. Di Marco
5  *
6 */
7 
8 #include <iostream>
9 #include <vector>
10 
15 
17 
20 
23 
25 
27 
29 
31 
33 
35 
36  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
37 
38  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
39 
40  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
41 
42  meEEDaqFraction_ = 0;
44  for (int i = 0; i < 18; i++) {
45  meEEDaqActive_[i] = 0;
46  }
47 
48 }
49 
51 
52 }
53 
55 
56  if ( dqmStore_ ) {
57 
59 
60  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
61 
62  meEEDaqFraction_ = dqmStore_->bookFloat( "DAQSummary" );
63  meEEDaqFraction_->Fill(0.0);
64 
65  name = "DAQSummaryMap";
66  meEEDaqActiveMap_ = dqmStore_->book2D(name, name, 40, 0., 200., 20, 0., 100.);
67  meEEDaqActiveMap_->setAxisTitle("ix / ix+100", 1);
69 
70  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
71 
72  for (int i = 0; i < 18; i++) {
73  meEEDaqActive_[i] = dqmStore_->bookFloat( "EcalEndcap_" + Numbers::sEE(i+1) );
74  meEEDaqActive_[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 itx = 0; itx < 40; itx++ ) {
91  for ( int ity = 0; ity < 20; ity++ ) {
92  readyLumi[itx][ity] = 1;
93  }
94  }
95 
96  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDAQTowerStatusRcd>() ) ) {
97  edm::LogWarning("EEDaqInfoTask") << "EcalDAQTowerStatus record not found";
98  return;
99  }
100 
102  iSetup.get<EcalDAQTowerStatusRcd>().get(pDAQStatus);
103  if ( !pDAQStatus.isValid() ) {
104  edm::LogWarning("EEDaqInfoTask") << "EcalDAQTowerStatus record not valid";
105  return;
106  }
107  const EcalDAQTowerStatus* daqStatus = pDAQStatus.product();
108 
110  iSetup.get< EcalMappingRcd >().get(pElecMapping);
111  if( !pElecMapping.isValid() ) {
112  edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
113  return;
114  }
115  const EcalElectronicsMapping *map = pElecMapping.product();
116 
117  std::vector<DetId> crystals;
118  std::vector<EcalScDetId> scs;
119 
120  for(unsigned i=0 ; i<sizeof(DccId_)/sizeof(int) ; i++){
121  for(int t=1 ; t<=nTowerMax_ ; t++){
122 
123  crystals = map->dccTowerConstituents(DccId_[i], t);
124  if(!crystals.size()) continue;
125 
126  scs = map->getEcalScDetId(DccId_[i], t, false);
127 
128  for(unsigned u=0 ; u<scs.size() ; u++){
129 
130  uint16_t dbStatus = 0; // 0 = good
131  EcalDAQTowerStatus::const_iterator daqStatusIt = daqStatus->find( scs[u].rawId() );
132  if ( daqStatusIt != daqStatus->end() ) dbStatus = daqStatusIt->getStatusCode();
133 
134  if ( dbStatus > 0 ) {
135  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
136  int jy = scs[u].iy() - 1;
137  readyRun[jx][jy] = 0;
138  readyLumi[jx][jy] = 0;
139  }
140  }
141  }
142  }
143 
144 }
145 
147 
149  iSetup.get< EcalMappingRcd >().get(handle);
150  const EcalElectronicsMapping *map = handle.product();
151  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
152  else this->fillMonitorElements(readyLumi, map);
153 
154 }
155 
157 
158  if ( ! mergeRuns_ ) this->reset();
159 
160  for ( int itx = 0; itx < 40; itx++ ) {
161  for ( int ity = 0; ity < 20; ity++ ) {
162  readyRun[itx][ity] = 1;
163  }
164  }
165 
166 }
167 
169 
171  c.get< EcalMappingRcd >().get(handle);
172  const EcalElectronicsMapping *map = handle.product();
173  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
174  else this->fillMonitorElements(readyRun, map);
175 
176 }
177 
179 
181 
182  for (int i = 0; i < 18; i++) {
183  if ( meEEDaqActive_[i] ) meEEDaqActive_[i]->Reset();
184  }
185 
187 
188 }
189 
190 
192 
193  if ( dqmStore_ ) {
194 
195  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
196 
198 
200 
201  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
202 
203  for (int i = 0; i < 18; i++) {
204  if ( meEEDaqActive_[i] ) dqmStore_->removeElement( meEEDaqActive_[i]->getName() );
205  }
206 
207  }
208 
209 }
210 
212 
213  float readySum[18];
214  int nValidChannels[18];
215  for ( int ism = 0; ism < 18; ism++ ) {
216  readySum[ism] = 0;
217  nValidChannels[ism] = 0;
218  }
219  float readySumTot = 0.;
220  int nValidChannelsTot = 0;
221 
222  if(meEEDaqActiveMap_){
223  for(int ix=1 ; ix<=meEEDaqActiveMap_->getNbinsX() ; ix++){
224  for(int iy=1 ; iy<=meEEDaqActiveMap_->getNbinsY() ; iy++){
225  meEEDaqActiveMap_->setBinContent( ix, iy, -1.0 );
226  }
227  }
228  }
229 
230  std::vector<DetId> crystals;
231  std::vector<EcalScDetId> scs;
232 
233  for ( unsigned iDcc = 0; iDcc < sizeof(DccId_)/sizeof(int); iDcc++) {
234  for ( int t = 1; t<=nTowerMax_; t++ ) {
235 
236  crystals = map->dccTowerConstituents(DccId_[iDcc], t);
237  if(!crystals.size()) continue;
238 
239  scs = map->getEcalScDetId(DccId_[iDcc], t, false);
240 
241  for(unsigned u=0 ; u<scs.size() ; u++){ // most of the time one DCC tower = one SC
242 
243  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
244  int jy = scs[u].iy() - 1;
245 
246  if(meEEDaqActiveMap_) meEEDaqActiveMap_->setBinContent( jx+1, jy+1, ready[jx][jy] );
247 
248  int ncrystals = 0;
249 
250  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
251  EEDetId id(*it);
252  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
253  }
254 
255  if(ready[jx][jy]) {
256  readySum[iDcc] += ncrystals;
257  readySumTot += ncrystals;
258  }
259 
260  nValidChannels[iDcc] += ncrystals;
261  nValidChannelsTot += ncrystals;
262 
263  }
264  }
265  if( meEEDaqActive_[iDcc] ) meEEDaqActive_[iDcc]->Fill( readySum[iDcc]/float(nValidChannels[iDcc]) );
266  }
267 
268  if( meEEDaqFraction_ ) meEEDaqFraction_->Fill( readySumTot/float(nValidChannelsTot) );
269 
270 }
271 
273 
274 }
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:223
int i
Definition: DBlmapReader.cc:9
void endJob(void)
EndJob.
std::string prefixME_
Definition: EEDaqInfoTask.h:65
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:56
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:810
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:72
static const int nTowerMax_
Definition: EEDaqInfoTask.h:57
void removeElement(const std::string &name)
Definition: DQMStore.cc:2773
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:63
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:76
int getNbinsX(void) const
get # of bins in X-axis
int readyRun[40][20]
Definition: EEDaqInfoTask.h:75
MonitorElement * meEEDaqFraction_
Definition: EEDaqInfoTask.h:71
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:1001
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:73
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
Definition: Run.h:41
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.
void cleanup(void)
Cleanup.