CMS 3D CMS Logo

EcalWeightXtalGroups_PayloadInspector.cc
Go to the documentation of this file.
6 
7 // the data format of the condition to be inspected
9 
10 #include "TH2F.h"
11 #include "TCanvas.h"
12 #include "TStyle.h"
13 #include "TLine.h"
14 #include "TLatex.h"
15 
16 #include <string>
17 
18 namespace {
19 
20  enum { kEBChannels = 61200, kEEChannels = 14648, kSides = 2, kRMS = 5, TEMPLATESAMPLES = 12 };
21  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
22  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
23 
24  /*****************************************************
25  2d plot of Ecal WeightXtal Groups of 1 IOV
26  *****************************************************/
27  class EcalWeightXtalGroupsPlot : public cond::payloadInspector::PlotImage<EcalWeightXtalGroups> {
28  public:
29  EcalWeightXtalGroupsPlot()
30  : cond::payloadInspector::PlotImage<EcalWeightXtalGroups>("Ecal Weight Xtal Groups - map ") {
31  setSingleIov(true);
32  }
33 
34  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
35  TH2F* barrel = new TH2F("EB", "mean EB", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
36  TH2F* endc_p = new TH2F("EE+", "mean EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
37  TH2F* endc_m = new TH2F("EE-", "mean EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
38 
39  auto iov = iovs.front();
40  std::shared_ptr<EcalWeightXtalGroups> payload = fetchPayload(std::get<1>(iov));
41  unsigned int run = std::get<0>(iov);
42 
43  if (payload.get()) {
44  if (payload->barrelItems().empty())
45  return false;
46 
47  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
48  uint32_t rawid = EBDetId::unhashIndex(cellid);
49 
50  std::vector<EcalXtalGroupId>::const_iterator value_ptr = payload->find(rawid);
51  // unsigned int id()
52  if (value_ptr == payload->end())
53  continue; // cell absent from payload
54 
55  unsigned int weight = (unsigned int)((*value_ptr).id());
56  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
57  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
58 
59  if (eta > 0.)
60  eta = eta - 0.5; // 0.5 to 84.5
61  else
62  eta = eta + 0.5; // -84.5 to -0.5
63 
64  barrel->Fill(phi, eta, weight);
65  } // loop over cellid
66 
67  if (payload->endcapItems().empty())
68  return false;
69 
70  // looping over the EE channels
71  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
72  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
73  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
74  if (EEDetId::validDetId(ix, iy, iz)) {
75  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
76  uint32_t rawid = myEEId.rawId();
77 
78  std::vector<EcalXtalGroupId>::const_iterator value_ptr = payload->find(rawid);
79 
80  if (value_ptr == payload->end())
81  continue; // cell absent from payload
82 
83  unsigned int weight = (unsigned int)((*value_ptr).id());
84 
85  if (iz == 1)
86  endc_p->Fill(ix, iy, weight);
87  else
88  endc_m->Fill(ix, iy, weight);
89  } // validDetId
90  } // payload
91 
92  gStyle->SetPalette(1);
93  gStyle->SetOptStat(0);
94  TCanvas canvas("CC map", "CC map", 1600, 450);
95  TLatex t1;
96  t1.SetNDC();
97  t1.SetTextAlign(26);
98  t1.SetTextSize(0.05);
99  t1.DrawLatex(0.5, 0.96, Form("Ecal Weight Xtal Groups, IOV %i", run));
100 
101  float xmi[3] = {0.0, 0.24, 0.76};
102  float xma[3] = {0.24, 0.76, 1.00};
103  TPad** pad = new TPad*;
104  for (int obj = 0; obj < 3; obj++) {
105  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
106  pad[obj]->Draw();
107  }
108  // EcalDrawMaps ICMap;
109  pad[0]->cd();
110  // ICMap.DrawEE(endc_m, 0., 2.);
111  DrawEE(endc_m, 0., 2.5);
112  pad[1]->cd();
113  // ICMap.DrawEB(barrel, 0., 2.);
114  DrawEB(barrel, 0., 2.5);
115  pad[2]->cd();
116  // ICMap.DrawEE(endc_p, 0., 2.);
117  DrawEE(endc_p, 0., 2.5);
118 
119  std::string ImageName(m_imageFileName);
120  canvas.SaveAs(ImageName.c_str());
121  return true;
122  } // fill method
123  };
124 
125 } // namespace
126 
127 // Register the classes as boost python plugin
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
PayloadInspector.h
EBDetId.h
EEDetId.h
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer< EcalXtalGroupId >
EcalWeightXtalGroups.h
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
PVValHelper::eta
Definition: PVValidationHelpers.h:69
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
createfilelist.int
int
Definition: createfilelist.py:10
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EcalDrawUtils.h
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
DDAxes::phi
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
EEDetId::XYMODE
static const int XYMODE
Definition: EEDetId.h:335
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EBDetId::MIN_HASH
static const int MIN_HASH
Definition: EBDetId.h:149
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
weight
Definition: weight.py:1
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13