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  * $Date: 2010/08/09 17:47:32 $
5  * $Revision: 1.11 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <fstream>
11 #include <iostream>
12 #include <string>
13 #include <cstring>
14 #include <time.h>
15 #include <unistd.h>
16 
20 
25 
27 
29 
31 
33 
34  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
35 
36 }
37 
39 
41 
42  std::vector<EcalDQMStatusDictionary::codeDef> dictionary;
44 
45  const EcalDQMChannelStatus* channelStatus = 0;
46  if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMChannelStatusRcd >() ) ) {
48  c.get< EcalDQMChannelStatusRcd >().get(handle);
49  if ( handle.isValid() ) channelStatus = handle.product();
50  }
51 
52  const EcalDQMTowerStatus* towerStatus = 0;
53  if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMTowerStatusRcd >() ) ) {
55  c.get< EcalDQMTowerStatusRcd >().get(handle);
56  if ( handle.isValid() ) towerStatus = handle.product();
57  }
58 
59  // barrel
60  for ( int ism=1; ism<=36; ism++ ) {
61  for ( int ic=1; ic<=1700; ic++ ) {
62  int jsm = Numbers::iSM(ism, EcalBarrel);
64  if ( channelStatus ) {
65  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
66  if ( it != channelStatus->end() ) {
67  if ( it->getStatusCode() != 0 ) {
68  if ( verbose_ ) std::cout << "# EB:channel, ic=" << ic << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
69  std::vector<EcalDQMStatusDictionary::codeDef> codes;
70  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
71  for ( unsigned int i=0; i<codes.size(); i++ ) {
72  std::cout << "Crystal " << Numbers::sEB(ism) << " " << ic << " " << codes[i].desc << std::endl;
73  }
74  }
75  }
76  }
77  }
78  }
79 
80  for ( int ix=1; ix<=17; ix++ ) {
81  for ( int iy=1; iy<=72; iy++ ) {
82  if ( EcalTrigTowerDetId::validDetId(+1, EcalBarrel, ix, iy) ) {
83  EcalTrigTowerDetId id(+1, EcalBarrel, ix, iy);
84  if ( towerStatus ) {
85  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
86  if ( it != towerStatus->end() ) {
87  if ( it->getStatusCode() != 0 ) {
88  if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
89  std::vector<EcalDQMStatusDictionary::codeDef> codes;
90  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
91  for ( unsigned int i=0; i<codes.size(); i++ ) {
92  std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
93  }
94  }
95  }
96  }
97  }
98  if ( EcalTrigTowerDetId::validDetId(-1, EcalBarrel, ix, iy) ) {
99  EcalTrigTowerDetId id(-1, EcalBarrel, ix, iy);
100  if ( towerStatus ) {
101  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
102  if ( it != towerStatus->end() ) {
103  if ( it->getStatusCode() != 0 ) {
104  if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
105  std::vector<EcalDQMStatusDictionary::codeDef> codes;
106  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
107  for ( unsigned int i=0; i<codes.size(); i++ ) {
108  std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
109  }
110  }
111  }
112  }
113  }
114  }
115  }
116 
117  // endcap
118  for ( int ix=1; ix<=100; ix++ ) {
119  for ( int iy=1; iy<=100; iy++ ) {
120  if ( EEDetId::validDetId(ix, iy, +1) ) {
121  EEDetId id(ix, iy, +1);
122  if ( channelStatus ) {
123  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
124  if ( it != channelStatus->end() ) {
125  if ( it->getStatusCode() != 0 ) {
126  if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
127  std::vector<EcalDQMStatusDictionary::codeDef> codes;
128  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
129  for ( unsigned int i=0; i<codes.size(); i++ ) {
130  std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
131  }
132  }
133  }
134  }
135  }
136  if ( EEDetId::validDetId(ix, iy, -1) ) {
137  EEDetId id(ix, iy, -1);
138  if ( channelStatus ) {
139  EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
140  if ( it != channelStatus->end() ) {
141  if ( it->getStatusCode() != 0 ) {
142  if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
143  std::vector<EcalDQMStatusDictionary::codeDef> codes;
144  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
145  for ( unsigned int i=0; i<codes.size(); i++ ) {
146  std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
147  }
148  }
149  }
150  }
151  }
152  }
153  }
154 
155  for ( int ix=1; ix<=20; ix++ ) {
156  for ( int iy=1; iy<=20; iy++ ) {
157  if ( EcalScDetId::validDetId(ix, iy, +1) ) {
158  EcalScDetId id(ix, iy, +1);
159  if ( towerStatus ) {
160  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
161  if ( it != towerStatus->end() ) {
162  if ( it->getStatusCode() != 0 ) {
163  if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
164  std::vector<EcalDQMStatusDictionary::codeDef> codes;
165  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
166  for ( unsigned int i=0; i<codes.size(); i++ ) {
167  std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
168  }
169  }
170  }
171  }
172  }
173  if ( EcalScDetId::validDetId(ix, iy, -1) ) {
174  EcalScDetId id(ix, iy, -1);
175  if ( towerStatus ) {
176  EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
177  if ( it != towerStatus->end() ) {
178  if ( it->getStatusCode() != 0 ) {
179  if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
180  std::vector<EcalDQMStatusDictionary::codeDef> codes;
181  EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
182  for ( unsigned int i=0; i<codes.size(); i++ ) {
183  std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
184  }
185  }
186  }
187  }
188  }
189  }
190  }
191 
192 }
193 
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:63
T getUntrackedParameter(std::string const &, T const &) const
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:226
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:94
void beginRun(const edm::Run &r, const edm::EventSetup &c)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
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:437
tuple handle
Definition: patZpeak.py:22
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
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:712
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
const_iterator find(uint32_t rawId) const
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
EcalDQMStatusReader(const edm::ParameterSet &ps)
std::vector< Item >::const_iterator const_iterator
bool isValid() const
Definition: ESHandle.h:37
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
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:485
Definition: Run.h:33