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  * $Date: 2012/04/27 13:46:14 $
5  * $Revision: 1.23 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 
16 
18 
21 
23 
26 
28 
30 
32 
34 
35  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
36 
37  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
38 
39  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
40 
41  meEEDcsFraction_ = 0;
43  for (int i = 0; i < 18; i++) {
44  meEEDcsActive_[i] = 0;
45  }
46 
47 }
48 
50 
51 }
52 
54 
55  if ( dqmStore_ ) {
56 
57  std::string name;
58 
59  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
60 
61  meEEDcsFraction_ = dqmStore_->bookFloat( "DCSSummary" );
62  meEEDcsFraction_->Fill(0.0);
63 
64  name = "DCSSummaryMap";
65  meEEDcsActiveMap_ = dqmStore_->book2D(name, name, 40, 0., 200., 20, 0., 100.);
66  meEEDcsActiveMap_->setAxisTitle("ix / ix+100", 1);
68 
69  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
70 
71  for (int i = 0; i < 18; i++) {
72  meEEDcsActive_[i] = dqmStore_->bookFloat( "EcalEndcap_" + Numbers::sEE(i+1) );
73  meEEDcsActive_[i]->Fill(-1.0);
74  }
75 
76  }
77 
78 }
79 
81 
82  if ( enableCleanup_ ) this->cleanup();
83 
84 }
85 
87 
88  // information is by run, so fill the same for the run and for every lumi section
89  for ( int itx = 0; itx < 40; itx++ ) {
90  for ( int ity = 0; ity < 20; ity++ ) {
91  readyLumi[itx][ity] = 1;
92  }
93  }
94 
95  if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
96  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not found";
97  return;
98  }
99 
101  iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
102  if ( !pDCSStatus.isValid() ) {
103  edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not valid";
104  return;
105  }
106  const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
107 
109  iSetup.get< EcalMappingRcd >().get(pElecMapping);
110  if( !pElecMapping.isValid() ) {
111  edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
112  return;
113  }
114  const EcalElectronicsMapping *map = pElecMapping.product();
115 
116  std::vector<DetId> crystals;
117  std::vector<EcalScDetId> scs;
118 
119  for(unsigned i=0 ; i<sizeof(DccId_)/sizeof(int) ; i++){
120  for(int t=1 ; t<=nTowerMax_ ; t++){
121 
122  crystals = map->dccTowerConstituents(DccId_[i], t);
123  if(!crystals.size()) continue;
124 
125  scs = map->getEcalScDetId(DccId_[i], t, false);
126 
127  for(unsigned u=0 ; u<scs.size() ; u++){
128 
129  uint16_t dbStatus = 0; // 0 = good
130  EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( scs[u].rawId() );
131  if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
132 
133  if ( dbStatus > 0 ) {
134  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
135  int jy = scs[u].iy() - 1;
136  readyRun[jx][jy] = 0;
137  readyLumi[jx][jy] = 0;
138  }
139  }
140  }
141  }
142 
143 // for(int iz=-1; iz<=1; iz+=2) {
144 // for(int itx=0 ; itx<20; itx++) {
145 // for(int ity=0 ; ity<20; ity++) {
146 // if (EcalScDetId::validDetId(itx+1,ity+1,iz )){
147 
148 // EcalScDetId eeid(itx+1,ity+1,iz);
149 
150 // uint16_t dbStatus = 0; // 0 = good
151 // EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( eeid.rawId() );
152 // if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
153 
154 // if ( dbStatus > 0 ) {
155 // int offsetSC = (iz > 0) ? 0 : 20;
156 // readyRun[offsetSC+itx][ity] = 0;
157 // readyLumi[offsetSC+itx][ity] = 0;
158 // }
159 
160 // }
161 // }
162 // }
163 // }
164 
165 }
166 
168 
170  iSetup.get< EcalMappingRcd >().get(handle);
171  const EcalElectronicsMapping *map = handle.product();
172  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
173  else this->fillMonitorElements(readyLumi, map);
174 
175 }
176 
178 
179  if ( ! mergeRuns_ ) this->reset();
180 
181  for ( int itx = 0; itx < 40; itx++ ) {
182  for ( int ity = 0; ity < 20; ity++ ) {
183  readyRun[itx][ity] = 1;
184  }
185  }
186 
187 }
188 
190 
192  c.get< EcalMappingRcd >().get(handle);
193  const EcalElectronicsMapping *map = handle.product();
194  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
195  else this->fillMonitorElements(readyRun, map);
196 
197 }
198 
200 
202 
203  for (int i = 0; i < 18; i++) {
204  if ( meEEDcsActive_[i] ) meEEDcsActive_[i]->Reset();
205  }
206 
208 
209 }
210 
211 
213 
214  if ( dqmStore_ ) {
215 
216  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
217 
219 
221 
222  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
223 
224  for (int i = 0; i < 18; i++) {
226  }
227 
228  }
229 
230 }
231 
233 
234  float readySum[18];
235  int nValidChannels[18];
236  for ( int ism = 0; ism < 18; ism++ ) {
237  readySum[ism] = 0;
238  nValidChannels[ism] = 0;
239  }
240  float readySumTot = 0.;
241  int nValidChannelsTot = 0;
242 
243  if(meEEDcsActiveMap_){
244  for(int ix=1 ; ix<=meEEDcsActiveMap_->getNbinsX() ; ix++){
245  for(int iy=1 ; iy<=meEEDcsActiveMap_->getNbinsY() ; iy++){
246  meEEDcsActiveMap_->setBinContent( ix, iy, -1.0 );
247  }
248  }
249  }
250 
251  std::vector<DetId> crystals;
252  std::vector<EcalScDetId> scs;
253 
254  for ( unsigned iDcc = 0; iDcc < sizeof(DccId_)/sizeof(int); iDcc++) {
255  for ( int t = 1; t<=nTowerMax_; t++ ) {
256 
257  crystals = map->dccTowerConstituents(DccId_[iDcc], t);
258  if(!crystals.size()) continue;
259 
260  scs = map->getEcalScDetId(DccId_[iDcc], t, false);
261 
262  for(unsigned u=0 ; u<scs.size() ; u++){ // most of the time one DCC tower = one SC
263 
264  int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
265  int jy = scs[u].iy() - 1;
266 
267  if(meEEDcsActiveMap_) meEEDcsActiveMap_->setBinContent( jx+1, jy+1, ready[jx][jy] );
268 
269  int ncrystals = 0;
270 
271  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
272  EEDetId id(*it);
273  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
274  }
275 
276  if(ready[jx][jy]) {
277  readySum[iDcc] += ncrystals;
278  readySumTot += ncrystals;
279  }
280 
281  nValidChannels[iDcc] += ncrystals;
282  nValidChannelsTot += ncrystals;
283  }
284  }
285 
286  if( meEEDcsActive_[iDcc] ) meEEDcsActive_[iDcc]->Fill( readySum[iDcc]/float(nValidChannels[iDcc]) );
287  }
288 
289  if( meEEDcsFraction_ ) meEEDcsFraction_->Fill( readySumTot/float(nValidChannelsTot) );
290 
291 }
292 
294 
295 }
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
static const int nTowerMax_
Definition: EEDcsInfoTask.h:59
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:654
dictionary map
Definition: Association.py:196
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:78
MonitorElement * meEEDcsActiveMap_
Definition: EEDcsInfoTask.h:75
void beginJob(void)
BeginJob.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
int readyRun[40][20]
Definition: EEDcsInfoTask.h:77
tuple handle
Definition: patZpeak.py:22
void endJob(void)
EndJob.
DQMStore * dqmStore_
Definition: EEDcsInfoTask.h:65
static const int DccId_[18]
Definition: EEDcsInfoTask.h:58
MonitorElement * meEEDcsFraction_
Definition: EEDcsInfoTask.h:73
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
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:74
std::vector< Item >::const_iterator const_iterator
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:845
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:429
void fillMonitorElements(int ready[40][20], const EcalElectronicsMapping *)
Definition: Run.h:33
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.
std::string prefixME_
Definition: EEDcsInfoTask.h:67