CMS 3D CMS Logo

EcalChannelStatus_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
9 
10 #include <memory>
11 #include <sstream>
12 
13 
14 
15 namespace {
16 
17  /*******************************************************
18 
19  2d histogram of ECAL barrel channel status of 1 IOV
20 
21  *******************************************************/
22 
23 
24  // inherit from one of the predefined plot class: Histogram2D
25  class EcalChannelStatusEBMap : public cond::payloadInspector::Histogram2D<EcalChannelStatus> {
26 
27  public:
28  static const int MIN_IETA = 1;
29  static const int MIN_IPHI = 1;
30  static const int MAX_IETA = 85;
31  static const int MAX_IPHI = 360;
32 
33  EcalChannelStatusEBMap() : cond::payloadInspector::Histogram2D<EcalChannelStatus>( "ECAL Barrel channel status - map ",
34  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -1*MAX_IETA, MAX_IETA+1) {
35  Base::setSingleIov( true );
36  }
37 
38  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
39  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ){
40 
41  for ( auto const & iov: iovs) {
42  std::shared_ptr<EcalChannelStatus> payload = Base::fetchPayload( std::get<1>(iov) );
43  if( payload.get() ){
44  // looping over the EB channels, via the dense-index, mapped into EBDetId's
45  if (!payload->barrelItems().size()) return false;
46  // set to -1 for ieta 0 (no crystal)
47  for(int iphi = MIN_IPHI; iphi < MAX_IPHI+1; iphi++) fillWithValue(iphi, 0, -1);
48  for(int cellid = EBDetId::MIN_HASH;
50  ++cellid) {
51  uint32_t rawid = EBDetId::unhashIndex(cellid);
52 
53  // check the existence of ECAL channel status, for a given ECAL barrel channel
54  if (payload->find(rawid) == payload->end()) continue;
55  // if (!(*payload)[rawid].getEncodedStatusCode()) continue;
56  float weight = (float)(*payload)[rawid].getEncodedStatusCode();
57 
58  // fill the Histogram2D here
59  fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta(), weight);
60  }// loop over cellid
61  }// if payload.get()
62  }// loop over IOV's (1 in this case)
63 
64  return true;
65  }// fill method
66  };
67 
68  class EcalChannelStatusEEMap : public cond::payloadInspector::Histogram2D<EcalChannelStatus> {
69 
70  public:
71  static const int IX_MIN =1;
72 
75  static const int IY_MIN =1;
76 
79  static const int IX_MAX =100;
80 
83  static const int IY_MAX =100;
84  EcalChannelStatusEEMap() : cond::payloadInspector::Histogram2D<EcalChannelStatus>( "ECAL Endcap channel status - map ",
85  "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
86  Base::setSingleIov( true );
87  }
88 
89  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ){
90 
91  for ( auto const & iov: iovs) {
92  std::shared_ptr<EcalChannelStatus> payload = Base::fetchPayload( std::get<1>(iov) );
93  if( payload.get() ){
94  if (!payload->endcapItems().size()) return false;
95 
96  // set to -1 everywhwere
97  for(int ix = IX_MIN; ix < 2.2*IX_MAX+1; ix++)
98  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
99  fillWithValue(ix, iy, -1);
100  // looping over the EE channels
101  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
102  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
103  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
104  if(EEDetId::validDetId(ix, iy, iz)) {
105  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
106  uint32_t rawid = myEEId.rawId();
107  // check the existence of ECAL channel status, for a given ECAL endcap channel
108  if (payload->find(rawid) == payload->end()) continue;
109  // if (!(*payload)[rawid].getEncodedStatusCode()) continue;
110  float weight = (float)(*payload)[rawid].getEncodedStatusCode();
111  if(iz == -1)
112  fillWithValue( ix, iy, weight);
113  else
114  fillWithValue( ix+IX_MAX+20, iy, weight);
115 
116  } // validDetId
117  } // payload
118  }// loop over IOV's (1 in this case)
119  return true;
120  }// fill method
121  };
122 
123 } // close namespace
124 
125 // Register the classes as boost python plugin
127  PAYLOAD_INSPECTOR_CLASS( EcalChannelStatusEBMap );
128  PAYLOAD_INSPECTOR_CLASS( EcalChannelStatusEEMap );
129 }
static const int XYMODE
Definition: EEDetId.h:339
Definition: weight.py:1
void fillWithValue(float xvalue, float yvalue, float weight=1)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
payload
payload postfix for testing
static const int MIN_HASH
Definition: EBDetId.h:156
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
Definition: plugin.cc:24
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override