CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalDQMStatusReader.cc
Go to the documentation of this file.
1 /*
2  * \file EcalDQMStatusReader.cc
3  *
4  * \author G. Della Ricca
5  *
6 */
7 
8 #include <fstream>
9 #include <iostream>
10 #include <string>
11 #include <cstring>
12 #include <time.h>
13 #include <unistd.h>
14 
18 
23 
25 
27 
29 
31 
32  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
33 
34 }
35 
37 
39 
40  std::vector<EcalDQMStatusDictionary::codeDef> dictionary;
42 
43  const EcalDQMChannelStatus* channelStatus = 0;
44  if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMChannelStatusRcd >() ) ) {
46  c.get< EcalDQMChannelStatusRcd >().get(handle);
47  if ( handle.isValid() ) channelStatus = handle.product();
48  }
49 
50  const EcalDQMTowerStatus* towerStatus = 0;
51  if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMTowerStatusRcd >() ) ) {
53  c.get< EcalDQMTowerStatusRcd >().get(handle);
54  if ( handle.isValid() ) towerStatus = handle.product();
55  }
56 
57  // barrel
58  for ( int ism=1; ism<=36; ism++ ) {
59  for ( int ic=1; ic<=1700; ic++ ) {
60  int jsm = Numbers::iSM(ism, EcalBarrel);
61  EBDetId id(jsm, ic, EBDetId::SMCRYSTALMODE);
62  if ( channelStatus ) {
63  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
64  if ( it != channelStatus->end() ) {
65  if ( it->getStatusCode() != 0 ) {
66  if ( verbose_ ) std::cout << "# EB:channel, ic=" << ic << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
67  std::vector<EcalDQMStatusDictionary::codeDef> codes;
68  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
69  for ( unsigned int i=0; i<codes.size(); i++ ) {
70  std::cout << "Crystal " << Numbers::sEB(ism) << " " << ic << " " << codes[i].desc << std::endl;
71  }
72  }
73  }
74  }
75  }
76  }
77 
78  for ( int ix=1; ix<=17; ix++ ) {
79  for ( int iy=1; iy<=72; iy++ ) {
80  if ( EcalTrigTowerDetId::validDetId(+1, EcalBarrel, ix, iy) ) {
81  EcalTrigTowerDetId id(+1, EcalBarrel, ix, iy);
82  if ( towerStatus ) {
83  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
84  if ( it != towerStatus->end() ) {
85  if ( it->getStatusCode() != 0 ) {
86  if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
87  std::vector<EcalDQMStatusDictionary::codeDef> codes;
88  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
89  for ( unsigned int i=0; i<codes.size(); i++ ) {
90  std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
91  }
92  }
93  }
94  }
95  }
96  if ( EcalTrigTowerDetId::validDetId(-1, EcalBarrel, ix, iy) ) {
97  EcalTrigTowerDetId id(-1, EcalBarrel, ix, iy);
98  if ( towerStatus ) {
99  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
100  if ( it != towerStatus->end() ) {
101  if ( it->getStatusCode() != 0 ) {
102  if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
103  std::vector<EcalDQMStatusDictionary::codeDef> codes;
104  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
105  for ( unsigned int i=0; i<codes.size(); i++ ) {
106  std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
107  }
108  }
109  }
110  }
111  }
112  }
113  }
114 
115  // endcap
116  for ( int ix=1; ix<=100; ix++ ) {
117  for ( int iy=1; iy<=100; iy++ ) {
118  if ( EEDetId::validDetId(ix, iy, +1) ) {
119  EEDetId id(ix, iy, +1);
120  if ( channelStatus ) {
121  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
122  if ( it != channelStatus->end() ) {
123  if ( it->getStatusCode() != 0 ) {
124  if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
125  std::vector<EcalDQMStatusDictionary::codeDef> codes;
126  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
127  for ( unsigned int i=0; i<codes.size(); i++ ) {
128  std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
129  }
130  }
131  }
132  }
133  }
134  if ( EEDetId::validDetId(ix, iy, -1) ) {
135  EEDetId id(ix, iy, -1);
136  if ( channelStatus ) {
137  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
138  if ( it != channelStatus->end() ) {
139  if ( it->getStatusCode() != 0 ) {
140  if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
141  std::vector<EcalDQMStatusDictionary::codeDef> codes;
142  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
143  for ( unsigned int i=0; i<codes.size(); i++ ) {
144  std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
145  }
146  }
147  }
148  }
149  }
150  }
151  }
152 
153  for ( int ix=1; ix<=20; ix++ ) {
154  for ( int iy=1; iy<=20; iy++ ) {
155  if ( EcalScDetId::validDetId(ix, iy, +1) ) {
156  EcalScDetId id(ix, iy, +1);
157  if ( towerStatus ) {
158  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
159  if ( it != towerStatus->end() ) {
160  if ( it->getStatusCode() != 0 ) {
161  if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
162  std::vector<EcalDQMStatusDictionary::codeDef> codes;
163  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
164  for ( unsigned int i=0; i<codes.size(); i++ ) {
165  std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
166  }
167  }
168  }
169  }
170  }
171  if ( EcalScDetId::validDetId(ix, iy, -1) ) {
172  EcalScDetId id(ix, iy, -1);
173  if ( towerStatus ) {
174  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
175  if ( it != towerStatus->end() ) {
176  if ( it->getStatusCode() != 0 ) {
177  if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
178  std::vector<EcalDQMStatusDictionary::codeDef> codes;
179  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
180  for ( unsigned int i=0; i<codes.size(); i++ ) {
181  std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
182  }
183  }
184  }
185  }
186  }
187  }
188  }
189 
190 }
191 
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
T getUntrackedParameter(std::string const &, T const &) const
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:223
int i
Definition: DBlmapReader.cc:9
static void getCodes(std::vector< codeDef > &codeVec, uint32_t code)
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
void beginRun(const edm::Run &r, const edm::EventSetup &c)
const_iterator find(uint32_t rawId) const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
static void getDictionary(std::vector< codeDef > &dict)
static unsigned iSC(const EcalScDetId &id)
Definition: Numbers.cc:434
tuple handle
Definition: patZpeak.py:22
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
static unsigned indexEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:709
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
const_iterator find(uint32_t rawId) const
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
EcalDQMStatusReader(const edm::ParameterSet &ps)
bool isValid() const
Definition: ESHandle.h:37
static const int SMCRYSTALMODE
Definition: EBDetId.h:167
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
static unsigned iTT(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
Definition: Numbers.cc:482
Definition: Run.h:41