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  theMaps.bookBarrelBins("templateLABarrel");
183  } else if (myType == SiPixelPI::t_forward) {
184  theMaps.bookForwardHistograms("templateLAForward", "#muH", "#mu_{H} [1/T]");
185  theMaps.bookForwardBins("templateLAForward");
186  } else if (myType == SiPixelPI::t_all) {
187  theMaps.bookBarrelHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
188  theMaps.bookBarrelBins("templateLA");
189  theMaps.bookForwardHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
190  theMaps.bookForwardBins("templateLA");
191  } else {
192  edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
193  << " un-recognized detector type " << myType << std::endl;
194  return false;
195  }
196 
197  std::map<unsigned int, short> templMap = payload->getTemplateIDs();
198  if (templMap.size() == SiPixelPI::phase0size || templMap.size() > SiPixelPI::phase1size) {
199  edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
200  << "There are " << templMap.size()
201  << " DetIds in this payload. SiPixelTempate Lorentz Angle maps are not supported for non-Phase1 Pixel "
202  "geometries !";
203  TCanvas canvas("Canv", "Canv", 1200, 1000);
204  SiPixelPI::displayNotSupported(canvas, templMap.size());
205  std::string fileName(m_imageFileName);
206  canvas.SaveAs(fileName.c_str());
207  return false;
208  } else {
209  if (templMap.size() < SiPixelPI::phase1size) {
210  edm::LogWarning("SiPixelTemplateDBObject_PayloadInspector")
211  << "\n ********* WARNING! ********* \n There are " << templMap.size() << " DetIds in this payload !"
212  << "\n **************************** \n";
213  }
214  }
215 
216  for (auto const& entry : templMap) {
217  templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f);
218 
219  //mu_H = lorentz width / sensor thickness / B field
220  float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield;
221  COUT << "uH: " << uH << " lor x width:" << templ.lorxwidth() << " z size: " << theInfos[entry.second].zsize
222  << " B-field: " << theInfos[entry.second].Bfield << std::endl;
223 
224  auto detid = DetId(entry.first);
225  if (myType == SiPixelPI::t_all) {
226  if ((detid.subdetId() == PixelSubdetector::PixelBarrel)) {
227  theMaps.fillBarrelBin("templateLA", entry.first, uH);
228  }
229  if ((detid.subdetId() == PixelSubdetector::PixelEndcap)) {
230  theMaps.fillForwardBin("templateLA", entry.first, uH);
231  }
232  } else if ((detid.subdetId() == PixelSubdetector::PixelBarrel) && (myType == SiPixelPI::t_barrel)) {
233  theMaps.fillBarrelBin("templateLABarrel", entry.first, uH);
234  } else if ((detid.subdetId() == PixelSubdetector::PixelEndcap) && (myType == SiPixelPI::t_forward)) {
235  theMaps.fillForwardBin("templateLAForward", entry.first, uH);
236  }
237  }
238 
239  theMaps.beautifyAllHistograms();
240 
241  TCanvas canvas("Canv", "Canv", (myType == SiPixelPI::t_barrel) ? 1200 : 1600, 1000);
242  if (myType == SiPixelPI::t_barrel) {
243  theMaps.drawBarrelMaps("templateLABarrel", canvas);
244  } else if (myType == SiPixelPI::t_forward) {
245  theMaps.drawForwardMaps("templateLAForward", canvas);
246  } else if (myType == SiPixelPI::t_all) {
247  theMaps.drawSummaryMaps("templateLA", canvas);
248  }
249 
250  canvas.cd();
251  std::string fileName(m_imageFileName);
252  canvas.SaveAs(fileName.c_str());
253  }
254  return true;
255  } // fill
256  };
257 
258  using SiPixelTemplateLABPixMap = SiPixelTemplateLA<SiPixelPI::t_barrel>;
259  using SiPixelTemplateLAFPixMap = SiPixelTemplateLA<SiPixelPI::t_forward>;
260  using SiPixelTemplateLAMap = SiPixelTemplateLA<SiPixelPI::t_all>;
261 
262  using namespace templateHelper;
263 
264  //************************************************
265  // Full Pixel Tracker Map of Template IDs
266  // ***********************************************/
267  using SiPixelTemplateIDsFullPixelMap =
269 
270  //************************************************
271  // Display of Template Titles
272  // **********************************************/
273  using SiPixelTemplateTitles_Display =
275 
276  //***********************************************
277  // Display of Template Header
278  // **********************************************/
280 
281  //***********************************************
282  // TH2Poly Map of IDs
283  //***********************************************/
284  using SiPixelTemplateIDsBPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_barrel>;
285  using SiPixelTemplateIDsFPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_forward>;
286  using SiPixelTemplateIDsMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_all>;
287 
288 } // namespace
289 
290 // Register the classes as boost python plugin
292  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest);
293  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFullPixelMap);
294  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateTitles_Display);
295  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeaderTable);
296  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsMap);
297  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap);
298  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap);
299  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAMap);
300  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap);
301  PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAFPixMap);
302 }
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:129
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:781
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
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Phase1PixelMaps.h
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
Time.h
SiPixelTemplateDBObject.h
align::ID
uint32_t ID
Definition: Definitions.h:24
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
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:416