CMS 3D CMS Logo

EcalTPGFineGrainStripEE_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TStyle.h"
14 #include "TLine.h"
15 #include "TLatex.h"
16 
17 #include <string>
18 
19 namespace {
20  enum { NTCC = 108, NTower = 28, NStrip = 5, NXtal = 5 };
21  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
22 
23  /***********************************************
24  2d plot of ECAL TPGStripStatus of 1 IOV
25  ************************************************/
26  class EcalTPGFineGrainStripEEPlot : public cond::payloadInspector::PlotImage<EcalTPGFineGrainStripEE> {
27  public:
28  EcalTPGFineGrainStripEEPlot()
29  : cond::payloadInspector::PlotImage<EcalTPGFineGrainStripEE>("EcalTPGFineGrainStripEE - map ") {
30  setSingleIov(true);
31  }
32 
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
34  TH2F* endc_thresh_p =
35  new TH2F("EE+", "EE+ TPGFineGrainStrip Threshold", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
36  TH2F* endc_thresh_m =
37  new TH2F("EE-", "EE- TPGFineGrainStrip Threshold", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
38 
39  TH2F* endc_lut_p =
40  new TH2F("EE+", "EE+ TPG Crystal Status Lut", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
41  TH2F* endc_lut_m =
42  new TH2F("EE-", "EE- TPG Crystal Status Lut", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
43  int EEcount[2] = {0, 0};
44 
45  std::string mappingFile = "Geometry/EcalMapping/data/EEMap.txt";
46  std::ifstream f(edm::FileInPath(mappingFile).fullPath().c_str());
47  if (!f.good()) {
48  std::cout << "EcalTPGFineGrainStripEE File EEMap.txt not found" << std::endl;
49  throw cms::Exception("FileNotFound");
50  }
51 
52  uint32_t rawEE[NTCC][NTower][NStrip][NXtal];
53  int NbrawEE[NTCC][NTower][NStrip];
54  for (int TCC = 0; TCC < NTCC; TCC++)
55  for (int TT = 0; TT < NTower; TT++)
56  for (int ST = 0; ST < NStrip; ST++)
57  NbrawEE[TCC][TT][ST] = 0;
58 
59  while (!f.eof()) {
60  int ix, iy, iz, CL;
61  int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
62  int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
63  f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >>
64  pseudostrip_in_TCC >> pseudostrip_in_TT;
65 
66  EEDetId detid(ix, iy, iz, EEDetId::XYMODE);
67  uint32_t rawId = detid.denseIndex();
68  if (tccid > NTCC || tower > NTower || pseudostrip_in_TT > NStrip || xtal_in_pseudostrip > NXtal) {
69  // std::cout << " tccid " << tccid << " tower " << tower << " pseudostrip_in_TT "<< pseudostrip_in_TT
70  // <<" xtal_in_pseudostrip " << xtal_in_pseudostrip << std::endl;
71  } else {
72  rawEE[tccid - 1][tower - 1][pseudostrip_in_TT - 1][xtal_in_pseudostrip - 1] = rawId;
73  NbrawEE[tccid - 1][tower - 1][pseudostrip_in_TT - 1]++;
74  }
75  } // read EEMap file
76 
77  f.close();
78  //double wei[2] = {0., 0.};
79 
80  auto iov = iovs.front();
81  std::shared_ptr<EcalTPGFineGrainStripEE> payload = fetchPayload(std::get<1>(iov));
82  unsigned int run = std::get<0>(iov);
83  double max1 = 1.0, max2 = 1.0;
84 
85  if (payload.get()) {
86  const EcalTPGFineGrainStripEEMap& stripMap = (*payload).getMap();
87  // std::cout << " tower map size " << stripMap.size() << std::endl;
89  for (itSt = stripMap.begin(); itSt != stripMap.end(); ++itSt) {
90  EcalTPGFineGrainStripEE::Item item = (*itSt).second;
91 
92  // let's decode the ID
93  int strip = itSt->first / 8;
94  int pseudostrip = strip & 0x7;
95  strip /= 8;
96  int tt = strip & 0x7F;
97  strip /= 128;
98  int tccid = strip & 0x7F;
99  int NbXtalInStrip = NbrawEE[tccid - 1][tt - 1][pseudostrip - 1];
100  //if(NbXtalInStrip != NXtal) std::cout << " Strip TCC " << tccid << " TT " << tt << " ST " << pseudostrip
101  // << " Nx Xtals " << NbXtalInStrip << std::endl;
102 
103  for (int Xtal = 0; Xtal < NbXtalInStrip; Xtal++) {
104  uint32_t rawId = rawEE[tccid - 1][tt - 1][pseudostrip - 1][Xtal];
105  // std::cout << " rawid " << rawId << std::endl;
106  EEDetId detid = EEDetId::detIdFromDenseIndex(rawId);
107  float x = (float)detid.ix();
108  float y = (float)detid.iy();
109  int iz = detid.zside();
110  if (iz == -1)
111  iz++;
112  //if(Xtal == 0) wei[iz] += 1.;
113  if (iz == 0) {
114  endc_thresh_m->Fill(x + 0.5, y + 0.5, item.threshold);
115  endc_lut_m->Fill(x + 0.5, y + 0.5, item.lut);
116  EEcount[0]++;
117 
118  if (max1 < item.threshold)
119  max1 = item.threshold;
120 
121  if (max2 < item.lut)
122  max2 = item.lut;
123 
124  } else {
125  endc_thresh_p->Fill(x + 0.5, y + 0.5, item.threshold);
126  endc_lut_p->Fill(x + 0.5, y + 0.5, item.lut);
127  EEcount[1]++;
128 
129  if (max1 < item.threshold)
130  max1 = item.threshold;
131 
132  if (max2 < item.lut)
133  max2 = item.lut;
134  }
135  }
136  }
137  } // payload
138  // std::cout << " nb strip EE- " << wei[0] << " EE+ " << wei[1] << std::endl;
139 
140  gStyle->SetPalette(1);
141  gStyle->SetOptStat(0);
142  const Int_t NRGBs = 5;
143  const Int_t NCont = 255;
144 
145  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
146  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
147  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
148  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
149  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
150  gStyle->SetNumberContours(NCont);
151 
152  Double_t w = 1200;
153  Double_t h = 1400;
154  TCanvas canvas("c", "c", w, h);
155 
156  TLatex t1;
157  t1.SetNDC();
158  t1.SetTextAlign(26);
159  t1.SetTextSize(0.04);
160  t1.DrawLatex(0.5, 0.96, Form("Ecal TPG Fine Grain StripEE, IOV %i", run));
161 
162  float xmi[4] = {0.0, 0.5, 0.0, 0.5};
163  float xma[4] = {0.5, 1.0, 0.5, 1.0};
164 
165  float ymi[4] = {0.47, 0.47, 0.0, 0.0};
166  float yma[4] = {0.94, 0.94, 0.47, 0.47};
167  TPad** pad = new TPad*;
168  for (int obj = 0; obj < 4; obj++) {
169  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], ymi[obj], xma[obj], yma[obj]);
170  pad[obj]->Draw();
171  }
172 
173  // t1.DrawLatex(0.2, 0.94, Form("%i crystals", EBstat));
174 
175  pad[0]->cd();
176  DrawEE(endc_thresh_m, 0., max1);
177  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEcount[0]));
178 
179  pad[1]->cd();
180  DrawEE(endc_thresh_p, 0., max1);
181  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEcount[1]));
182 
183  pad[2]->cd();
184  DrawEE(endc_lut_m, 0., max2);
185  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEcount[0]));
186 
187  pad[3]->cd();
188  DrawEE(endc_lut_p, 0., max2);
189  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEcount[1]));
190 
191  std::string ImageName(m_imageFileName);
192 
193  canvas.SaveAs(ImageName.c_str());
194 
195  delete pad;
196  delete endc_lut_p;
197  delete endc_lut_m;
198  delete endc_thresh_p;
199  delete endc_thresh_m;
200  return true;
201  } // fill method
202  };
203 
204 } // namespace
205 
206 // Register the classes as boost python plugin
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
EcalTPGFineGrainStripEEMapIterator
std::map< uint32_t, EcalTPGFineGrainStripEE::Item >::const_iterator EcalTPGFineGrainStripEEMapIterator
Definition: EcalTPGFineGrainStripEE.h:31
DDAxes::y
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
PayloadInspector.h
EcalTPGFineGrainStripEE
Definition: EcalTPGFineGrainStripEE.h:9
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EEDetId.h
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
EcalTPGFineGrainStripEE::Item
Definition: EcalTPGFineGrainStripEE.h:14
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
DDAxes::x
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
DivergingColor.red
list red
Definition: DivergingColor.py:172
PayloadInspectorModule.h
L1DTConfigBti_cff.CL
CL
Definition: L1DTConfigBti_cff.py:39
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
FileInPath.h
EcalTPGFineGrainStripEE.h
EEDetId::detIdFromDenseIndex
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
edm::FileInPath
Definition: FileInPath.h:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
w
const double w
Definition: UKUtility.cc:23
jets_cff.payload
payload
Definition: jets_cff.py:32
h
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
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
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:863
DivergingColor.blue
list blue
Definition: DivergingColor.py:173
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalDrawUtils.h
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
EcalTPGFineGrainStripEEMap
std::map< uint32_t, EcalTPGFineGrainStripEE::Item > EcalTPGFineGrainStripEEMap
Definition: EcalTPGFineGrainStripEE.h:30
csctfunpacker_cfi.mappingFile
mappingFile
Definition: csctfunpacker_cfi.py:14
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
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
Exception
Definition: hltDiff.cc:246
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:852
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18