CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEDcsInfoTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEDcsInfoTask.cc
3  *
4  * \author E. Di Marco
5  *
6 */
7 
8 #include <iostream>
9 
14 
16 
19 
21 
24 
26 
28 
30 
32 
33  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
34 
35  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
36 
37  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
38 
39  meEEDcsFraction_ = 0;
41  for (int i = 0; i < 18; i++) {
42  meEEDcsActive_[i] = 0;
43  }
44 
45 }
46 
48 
49 }
50 
52 
53  if ( dqmStore_ ) {
54 
56 
57  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
58 
59  meEEDcsFraction_ = dqmStore_->bookFloat( "DCSSummary" );
60  meEEDcsFraction_->Fill(0.0);
61 
62  name = "DCSSummaryMap";
63  meEEDcsActiveMap_ = dqmStore_->book2D(name, name, 40, 0., 200., 20, 0., 100.);
64  meEEDcsActiveMap_->setAxisTitle("ix / ix+100", 1);
66 
67  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
68 
69  for (int i = 0; i < 18; i++) {
70  meEEDcsActive_[i] = dqmStore_->bookFloat( "EcalEndcap_" + Numbers::sEE(i+1) );
71  meEEDcsActive_[i]->Fill(-1.0);
72  }
73 
74  }
75 
76 }
77 
79 
80  if ( enableCleanup_ ) this->cleanup();
81 
82 }
83 
85 
86  // information is by run, so fill the same for the run and for every lumi section
87  for ( int itx = 0; itx < 40; itx++ ) {
88  for ( int ity = 0; ity < 20; ity++ ) {
89  readyLumi[itx][ity] = 1;
90  }
91  }
92 
93  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
94  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not found";
95  return;
96  }
97 
99  iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
100  if ( !pDCSStatus.isValid() ) {
101  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not valid";
102  return;
103  }
104  const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
105 
107  iSetup.get< EcalMappingRcd >().get(pElecMapping);
108  if( !pElecMapping.isValid() ) {
109  edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
110  return;
111  }
112  const EcalElectronicsMapping *map = pElecMapping.product();
113 
114  std::vector<DetId> crystals;
115  std::vector<EcalScDetId> scs;
116 
117  for(unsigned i=0 ; i<sizeof(DccId_)/sizeof(int) ; i++){
118  for(int t=1 ; t<=nTowerMax_ ; t++){
119 
120  crystals = map->dccTowerConstituents(DccId_[i], t);
121  if(!crystals.size()) continue;
122 
123  scs = map->getEcalScDetId(DccId_[i], t, false);
124 
125  for(unsigned u=0 ; u<scs.size() ; u++){
126 
127  uint16_t dbStatus = 0; // 0 = good
128  EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( scs[u].rawId() );
129  if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
130 
131  if ( dbStatus > 0 ) {
132  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
133  int jy = scs[u].iy() - 1;
134  readyRun[jx][jy] = 0;
135  readyLumi[jx][jy] = 0;
136  }
137  }
138  }
139  }
140 
141 // for(int iz=-1; iz<=1; iz+=2) {
142 // for(int itx=0 ; itx<20; itx++) {
143 // for(int ity=0 ; ity<20; ity++) {
144 // if (EcalScDetId::validDetId(itx+1,ity+1,iz )){
145 
146 // EcalScDetId eeid(itx+1,ity+1,iz);
147 
148 // uint16_t dbStatus = 0; // 0 = good
149 // EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( eeid.rawId() );
150 // if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
151 
152 // if ( dbStatus > 0 ) {
153 // int offsetSC = (iz > 0) ? 0 : 20;
154 // readyRun[offsetSC+itx][ity] = 0;
155 // readyLumi[offsetSC+itx][ity] = 0;
156 // }
157 
158 // }
159 // }
160 // }
161 // }
162 
163 }
164 
166 
168  iSetup.get< EcalMappingRcd >().get(handle);
169  const EcalElectronicsMapping *map = handle.product();
170  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
171  else this->fillMonitorElements(readyLumi, map);
172 
173 }
174 
176 
177  if ( ! mergeRuns_ ) this->reset();
178 
179  for ( int itx = 0; itx < 40; itx++ ) {
180  for ( int ity = 0; ity < 20; ity++ ) {
181  readyRun[itx][ity] = 1;
182  }
183  }
184 
185 }
186 
188 
190  c.get< EcalMappingRcd >().get(handle);
191  const EcalElectronicsMapping *map = handle.product();
192  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
193  else this->fillMonitorElements(readyRun, map);
194 
195 }
196 
198 
200 
201  for (int i = 0; i < 18; i++) {
202  if ( meEEDcsActive_[i] ) meEEDcsActive_[i]->Reset();
203  }
204 
206 
207 }
208 
209 
211 
212  if ( dqmStore_ ) {
213 
214  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
215 
217 
219 
220  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
221 
222  for (int i = 0; i < 18; i++) {
223  if ( meEEDcsActive_[i] ) dqmStore_->removeElement( meEEDcsActive_[i]->getName() );
224  }
225 
226  }
227 
228 }
229 
231 
232  float readySum[18];
233  int nValidChannels[18];
234  for ( int ism = 0; ism < 18; ism++ ) {
235  readySum[ism] = 0;
236  nValidChannels[ism] = 0;
237  }
238  float readySumTot = 0.;
239  int nValidChannelsTot = 0;
240 
241  if(meEEDcsActiveMap_){
242  for(int ix=1 ; ix<=meEEDcsActiveMap_->getNbinsX() ; ix++){
243  for(int iy=1 ; iy<=meEEDcsActiveMap_->getNbinsY() ; iy++){
244  meEEDcsActiveMap_->setBinContent( ix, iy, -1.0 );
245  }
246  }
247  }
248 
249  std::vector<DetId> crystals;
250  std::vector<EcalScDetId> scs;
251 
252  for ( unsigned iDcc = 0; iDcc < sizeof(DccId_)/sizeof(int); iDcc++) {
253  for ( int t = 1; t<=nTowerMax_; t++ ) {
254 
255  crystals = map->dccTowerConstituents(DccId_[iDcc], t);
256  if(!crystals.size()) continue;
257 
258  scs = map->getEcalScDetId(DccId_[iDcc], t, false);
259 
260  for(unsigned u=0 ; u<scs.size() ; u++){ // most of the time one DCC tower = one SC
261 
262  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
263  int jy = scs[u].iy() - 1;
264 
265  if(meEEDcsActiveMap_) meEEDcsActiveMap_->setBinContent( jx+1, jy+1, ready[jx][jy] );
266 
267  int ncrystals = 0;
268 
269  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
270  EEDetId id(*it);
271  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
272  }
273 
274  if(ready[jx][jy]) {
275  readySum[iDcc] += ncrystals;
276  readySumTot += ncrystals;
277  }
278 
279  nValidChannels[iDcc] += ncrystals;
280  nValidChannelsTot += ncrystals;
281  }
282  }
283 
284  if( meEEDcsActive_[iDcc] ) meEEDcsActive_[iDcc]->Fill( readySum[iDcc]/float(nValidChannels[iDcc]) );
285  }
286 
287  if( meEEDcsFraction_ ) meEEDcsFraction_->Fill( readySumTot/float(nValidChannelsTot) );
288 
289 }
290 
292 
293 }
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
static const int nTowerMax_
Definition: EEDcsInfoTask.h:57
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
void reset(void)
Reset.
Some &quot;id&quot; conversions.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
void cleanup(void)
Cleanup.
EEDcsInfoTask(const edm::ParameterSet &ps)
Constructor.
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)
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
int readyLumi[40][20]
Definition: EEDcsInfoTask.h:76
MonitorElement * meEEDcsActiveMap_
Definition: EEDcsInfoTask.h:73
void beginJob(void)
BeginJob.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2773
int readyRun[40][20]
Definition: EEDcsInfoTask.h:75
tuple handle
Definition: patZpeak.py:22
void endJob(void)
EndJob.
DQMStore * dqmStore_
Definition: EEDcsInfoTask.h:63
static const int DccId_[18]
Definition: EEDcsInfoTask.h:56
MonitorElement * meEEDcsFraction_
Definition: EEDcsInfoTask.h:71
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
virtual ~EEDcsInfoTask()
Destructor.
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
int getNbinsX(void) const
get # of bins in X-axis
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * meEEDcsActive_[18]
Definition: EEDcsInfoTask.h:72
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
void fillMonitorElements(int ready[40][20], const EcalElectronicsMapping *)
Definition: Run.h:41
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.
std::string prefixME_
Definition: EEDcsInfoTask.h:65