CMS 3D CMS Logo

SiPixelTemplateDBObject_PayloadInspector.cc
Go to the documentation of this file.
1 
10 
18 
19 // the data format of the condition to be inspected
25 
26 #include <memory>
27 #include <map>
28 #include <sstream>
29 #include <iostream>
30 #include <algorithm>
31 
32 // include ROOT
33 #include "TH2.h"
34 #include "TProfile2D.h"
35 #include "TH2Poly.h"
36 #include "TGraph.h"
37 #include "TH2F.h"
38 #include "TLegend.h"
39 #include "TCanvas.h"
40 #include "TLine.h"
41 #include "TGraph.h"
42 #include "TStyle.h"
43 #include "TLatex.h"
44 #include "TPave.h"
45 #include "TPaveStats.h"
46 #include "TGaxis.h"
47 
48 namespace {
49 
50  using namespace cond::payloadInspector;
51 
52  /************************************************
53  test class
54  *************************************************/
55  class SiPixelTemplateDBObjectTest : public Histogram1D<SiPixelTemplateDBObject, SINGLE_IOV> {
56  public:
57  SiPixelTemplateDBObjectTest()
59  "SiPixelTemplateDBObject test", "SiPixelTemplateDBObject test", 10, 0.0, 100.) {}
60 
61  bool fill() override {
62  auto tag = PlotBase::getTag<0>();
63  for (auto const& iov : tag.iovs) {
64  std::vector<SiPixelTemplateStore> thePixelTemp_;
65  std::shared_ptr<SiPixelTemplateDBObject> payload = Base::fetchPayload(std::get<1>(iov));
66  if (payload.get()) {
67  if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) {
68  throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector")
69  << "\nERROR: Templates not filled correctly. Check the conditions. Using "
70  "SiPixelTemplateDBObject version "
71  << payload->version() << "\n\n";
72  }
73 
74  SiPixelTemplate templ(thePixelTemp_);
75 
76  for (const auto& theTemp : thePixelTemp_) {
77  std::cout << "\n\n"
78  << "Template ID = " << theTemp.head.ID << ", Template Version " << theTemp.head.templ_version
79  << ", Bfield = " << theTemp.head.Bfield << ", NTy = " << theTemp.head.NTy
80  << ", NTyx = " << theTemp.head.NTyx << ", NTxx = " << theTemp.head.NTxx
81  << ", Dtype = " << theTemp.head.Dtype << ", Bias voltage " << theTemp.head.Vbias
82  << ", temperature " << theTemp.head.temperature << ", fluence " << theTemp.head.fluence
83  << ", Q-scaling factor " << theTemp.head.qscale << ", 1/2 multi dcol threshold "
84  << theTemp.head.s50 << ", 1/2 single dcol threshold " << theTemp.head.ss50 << ", y Lorentz Width "
85  << theTemp.head.lorywidth << ", y Lorentz Bias " << theTemp.head.lorybias << ", x Lorentz width "
86  << theTemp.head.lorxwidth << ", x Lorentz Bias " << theTemp.head.lorxbias
87  << ", Q/Q_avg fractions for Qbin defs " << theTemp.head.fbin[0] << ", " << theTemp.head.fbin[1]
88  << ", " << theTemp.head.fbin[2] << ", pixel x-size " << theTemp.head.xsize << ", y-size "
89  << theTemp.head.ysize << ", zsize " << theTemp.head.zsize << "\n"
90  << std::endl;
91  }
92 
93  std::map<unsigned int, short> templMap = payload->getTemplateIDs();
94  for (auto const& entry : templMap) {
95  std::cout << "DetID: " << entry.first << " template ID: " << entry.second << std::endl;
96  templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f);
97 
98  std::cout << "\t lorywidth " << templ.lorywidth() << " lorxwidth: " << templ.lorxwidth() << " lorybias "
99  << templ.lorybias() << " lorxbias: " << templ.lorxbias() << "\n"
100  << std::endl;
101  }
102 
103  fillWithValue(1.);
104 
105  } // payload
106  } // iovs
107  return true;
108  } // fill
109  };
110 
111  /************************************************
112  // testing TH2Poly classes for plotting
113  *************************************************/
114  template <SiPixelPI::DetType myType>
115  class SiPixelTemplateLA : public PlotImage<SiPixelTemplateDBObject, SINGLE_IOV> {
116  struct header_info {
117  int ID;
118  float lorywidth;
119  float lorxwidth;
120  float lorybias;
121  float lorxbias;
122  float Vbias;
123  float temperature;
124  int templ_version;
125  float Bfield;
126  float xsize;
127  float ysize;
128  float zsize;
129  };
130 
131  public:
132  SiPixelTemplateLA() : PlotImage<SiPixelTemplateDBObject, SINGLE_IOV>("SiPixelTemplate assumed value of uH") {}
133 
134  bool fill() override {
135  gStyle->SetPalette(kRainBow);
136  TGaxis::SetMaxDigits(2);
137 
138  auto tag = PlotBase::getTag<0>();
139  auto iov = tag.iovs.front();
140  std::vector<SiPixelTemplateStore> thePixelTemp_;
141  std::shared_ptr<SiPixelTemplateDBObject> payload = fetchPayload(std::get<1>(iov));
142 
143  if (payload.get()) {
144  if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) {
145  throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector")
146  << "\nERROR: Templates not filled correctly. Check the conditions. Using "
147  "SiPixelTemplateDBObject version "
148  << payload->version() << "\n\n";
149  }
150 
151  // store the map of ID / interesting quantities
152  SiPixelTemplate templ(thePixelTemp_);
153  std::map<int, header_info> theInfos;
154  for (const auto& theTemp : thePixelTemp_) {
155  header_info info;
156  info.ID = theTemp.head.ID;
157  info.lorywidth = theTemp.head.lorywidth;
158  info.lorxwidth = theTemp.head.lorxwidth;
159  info.lorybias = theTemp.head.lorybias;
160  info.lorxbias = theTemp.head.lorxbias;
161  info.Vbias = theTemp.head.Vbias;
162  info.temperature = theTemp.head.temperature;
163  info.templ_version = theTemp.head.templ_version;
164  info.Bfield = theTemp.head.Bfield;
165  info.xsize = theTemp.head.xsize;
166  info.ysize = theTemp.head.ysize;
167  info.zsize = theTemp.head.zsize;
168 
169  theInfos[theTemp.head.ID] = info;
170  }
171 
172  // Book the TH2Poly
173  Phase1PixelMaps theMaps("");
174  if (myType == SiPixelPI::t_all) {
175  theMaps.resetOption("COLZA L");
176  } else {
177  theMaps.resetOption("COLZL");
178  }
179 
180  if (myType == SiPixelPI::t_barrel) {
181  theMaps.bookBarrelHistograms("templateLABarrel", "#muH", "#mu_{H} [1/T]");
182  } else if (myType == SiPixelPI::t_forward) {
183  theMaps.bookForwardHistograms("templateLAForward", "#muH", "#mu_{H} [1/T]");
184  } else if (myType == SiPixelPI::t_all) {
185  theMaps.bookBarrelHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
186  theMaps.bookForwardHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
187  } else {
188  edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
189  << " un-recognized detector type " << myType << std::endl;
190  return false;
191  }
192 
193  std::map<unsigned int, short> templMap = payload->getTemplateIDs();
194  if (templMap.size() == SiPixelPI::phase0size || templMap.size() > SiPixelPI::phase1size) {
195  edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
196  << "There are " << templMap.size()
197  << " DetIds in this payload. SiPixelTempate Lorentz Angle maps are not supported for non-Phase1 Pixel "
198  "geometries !";
199  TCanvas canvas("Canv", "Canv", 1200, 1000);
200  SiPixelPI::displayNotSupported(canvas, templMap.size());
201  std::string fileName(m_imageFileName);
202  canvas.SaveAs(fileName.c_str());
203  return false;
204  } else {
205  if (templMap.size() < SiPixelPI::phase1size) {
206  edm::LogWarning("SiPixelTemplateDBObject_PayloadInspector")
207  << "\n ********* WARNING! ********* \n There are " << templMap.size() << " DetIds in this payload !"
208  << "\n **************************** \n";
209  }
210  }
211 
212  for (auto const& entry : templMap) {
213  templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f);
214 
215  //mu_H = lorentz width / sensor thickness / B field
216  float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield;
217  COUT << "uH: " << uH << " lor x width:" << templ.lorxwidth() << " z size: " << theInfos[entry.second].zsize
218  << " B-field: " << theInfos[entry.second].Bfield << std::endl;
219 
220  auto detid = DetId(entry.first);
221  if (myType == SiPixelPI::t_all) {
222  if ((detid.subdetId() == PixelSubdetector::PixelBarrel)) {
223  theMaps.fillBarrelBin("templateLA", entry.first, uH);
224  }
225  if ((detid.subdetId() == PixelSubdetector::PixelEndcap)) {
226  theMaps.fillForwardBin("templateLA", entry.first, uH);
227  }
228  } else if ((detid.subdetId() == PixelSubdetector::PixelBarrel) && (myType == SiPixelPI::t_barrel)) {
229  theMaps.fillBarrelBin("templateLABarrel", entry.first, uH);
230  } else if ((detid.subdetId() == PixelSubdetector::PixelEndcap) && (myType == SiPixelPI::t_forward)) {
231  theMaps.fillForwardBin("templateLAForward", entry.first, uH);
232  }
233  }
234 
235  theMaps.beautifyAllHistograms();
236 
237  TCanvas canvas("Canv", "Canv", (myType == SiPixelPI::t_barrel) ? 1200 : 1600, 1000);
238  if (myType == SiPixelPI::t_barrel) {
239  theMaps.drawBarrelMaps("templateLABarrel", canvas);
240  } else if (myType == SiPixelPI::t_forward) {
241  theMaps.drawForwardMaps("templateLAForward", canvas);
242  } else if (myType == SiPixelPI::t_all) {
243  theMaps.drawSummaryMaps("templateLA", canvas);
244  }
245 
246  canvas.cd();
247  std::string fileName(m_imageFileName);
248  canvas.SaveAs(fileName.c_str());
249  }
250  return true;
251  } // fill
252  };
253 
254  using SiPixelTemplateLABPixMap = SiPixelTemplateLA<SiPixelPI::t_barrel>;
255  using SiPixelTemplateLAFPixMap = SiPixelTemplateLA<SiPixelPI::t_forward>;
256  using SiPixelTemplateLAMap = SiPixelTemplateLA<SiPixelPI::t_all>;
257 
258  using namespace templateHelper;
259 
260  //************************************************
261  // Full Pixel Tracker Map of Template IDs
262  // ***********************************************/
263  using SiPixelTemplateIDsFullPixelMap =
265 
266  //************************************************
267  // Display of Template Titles
268  // **********************************************/
269  using SiPixelTemplateTitles_Display =
271 
272  //***********************************************
273  // Display of Template Header
274  // **********************************************/
276 
277  //***********************************************
278  // TH2Poly Map of IDs
279  //***********************************************/
280  using SiPixelTemplateIDsBPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_barrel>;
281  using SiPixelTemplateIDsFPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_forward>;
282  using SiPixelTemplateIDsMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_all>;
283 
284 } // namespace
285 
286 // Register the classes as boost python plugin
288  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest);
289  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFullPixelMap);
290  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateTitles_Display);
291  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeaderTable);
292  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsMap);
293  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap);
294  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap);
295  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAMap);
296  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap);
297  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAFPixMap);
298 }
templateHelper::SiPixelIDs
Definition: SiPixelTemplateHelper.h:310
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
SiPixelPI::t_barrel
Definition: SiPixelPayloadInspectorHelper.h:574
PixelSubdetector.h
SiPixelTemplate::pushfile
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Definition: SiPixelTemplate.cc:130
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
cond::payloadInspector::Histogram1
Definition: PayloadInspector.h:711
templateHelper::SiPixelHeaderTable
Definition: SiPixelTemplateHelper.h:152
SiPixelTemplate
Definition: SiPixelTemplate.h:246
mps_splice.entry
entry
Definition: mps_splice.py:68
PayloadInspector.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiPixelPI::t_all
Definition: SiPixelPayloadInspectorHelper.h:574
ysize
const Int_t ysize
Definition: trackSplitPlot.h:43
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
xsize
const Int_t xsize
Definition: trackSplitPlot.h:42
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:782
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiPixelPI::phase0size
static const unsigned int phase0size
Definition: SiPixelPayloadInspectorHelper.h:42
PayloadInspectorModule.h
DetId
Definition: DetId.h:17
templateHelper::SiPixelTitles_Display
Definition: SiPixelTemplateHelper.h:39
SiPixelTemplate.h
StandaloneTrackerTopology.h
jets_cff.payload
payload
Definition: jets_cff.py:32
cond::payloadInspector
Definition: PayloadInspector.h:42
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
Phase1PixelMaps
Definition: Phase1PixelMaps.h:31
Phase1PixelMaps.h
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
Time.h
SiPixelTemplateDBObject.h
align::ID
uint32_t ID
Definition: Definitions.h:24
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
SiPixelPI::phase1size
static const unsigned int phase1size
Definition: SiPixelPayloadInspectorHelper.h:43
SiPixelTemplateDBObject
Definition: SiPixelTemplateDBObject.h:16
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
jvcParameters_cfi.temperature
temperature
Definition: jvcParameters_cfi.py:7
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
COUT
#define COUT
Definition: PVValidationHelpers.h:13
SiPixelPI::t_forward
Definition: SiPixelPayloadInspectorHelper.h:574
templateHelper
Definition: SiPixelTemplateHelper.h:33
SiPixelTemplateHelper.h
DetId.h
Exception
Definition: hltDiff.cc:245
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
SiPixelPayloadInspectorHelper.h
cond::payloadInspector::SINGLE_IOV
Definition: PayloadInspector.h:295
templateHelper::SiPixelFullPixelIDMap
Definition: SiPixelTemplateHelper.h:414