File indexing completed on 2021-06-23 03:27:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0012 #include "CondCore/Utilities/interface/PayloadInspector.h"
0013 #include "CondCore/CondDB/interface/Time.h"
0014 #include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h"
0015 #include "CondCore/SiPixelPlugins/interface/SiPixelTemplateHelper.h"
0016 #include "DQM/TrackerRemapper/interface/Phase1PixelMaps.h"
0017 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0018
0019
0020 #include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
0021 #include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"
0022 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0023 #include "DataFormats/DetId/interface/DetId.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025
0026 #include <memory>
0027 #include <map>
0028 #include <sstream>
0029 #include <iostream>
0030 #include <algorithm>
0031
0032
0033 #include "TH2.h"
0034 #include "TProfile2D.h"
0035 #include "TH2Poly.h"
0036 #include "TGraph.h"
0037 #include "TH2F.h"
0038 #include "TLegend.h"
0039 #include "TCanvas.h"
0040 #include "TLine.h"
0041 #include "TGraph.h"
0042 #include "TStyle.h"
0043 #include "TLatex.h"
0044 #include "TPave.h"
0045 #include "TPaveStats.h"
0046 #include "TGaxis.h"
0047
0048 namespace {
0049
0050 using namespace cond::payloadInspector;
0051
0052
0053
0054
0055 class SiPixelTemplateDBObjectTest : public Histogram1D<SiPixelTemplateDBObject, SINGLE_IOV> {
0056 public:
0057 SiPixelTemplateDBObjectTest()
0058 : Histogram1D<SiPixelTemplateDBObject, SINGLE_IOV>(
0059 "SiPixelTemplateDBObject test", "SiPixelTemplateDBObject test", 10, 0.0, 100.) {}
0060
0061 bool fill() override {
0062 auto tag = PlotBase::getTag<0>();
0063 for (auto const& iov : tag.iovs) {
0064 std::vector<SiPixelTemplateStore> thePixelTemp_;
0065 std::shared_ptr<SiPixelTemplateDBObject> payload = Base::fetchPayload(std::get<1>(iov));
0066 if (payload.get()) {
0067 if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) {
0068 throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector")
0069 << "\nERROR: Templates not filled correctly. Check the conditions. Using "
0070 "SiPixelTemplateDBObject version "
0071 << payload->version() << "\n\n";
0072 }
0073
0074 SiPixelTemplate templ(thePixelTemp_);
0075
0076 for (const auto& theTemp : thePixelTemp_) {
0077 std::cout << "\n\n"
0078 << "Template ID = " << theTemp.head.ID << ", Template Version " << theTemp.head.templ_version
0079 << ", Bfield = " << theTemp.head.Bfield << ", NTy = " << theTemp.head.NTy
0080 << ", NTyx = " << theTemp.head.NTyx << ", NTxx = " << theTemp.head.NTxx
0081 << ", Dtype = " << theTemp.head.Dtype << ", Bias voltage " << theTemp.head.Vbias
0082 << ", temperature " << theTemp.head.temperature << ", fluence " << theTemp.head.fluence
0083 << ", Q-scaling factor " << theTemp.head.qscale << ", 1/2 multi dcol threshold "
0084 << theTemp.head.s50 << ", 1/2 single dcol threshold " << theTemp.head.ss50 << ", y Lorentz Width "
0085 << theTemp.head.lorywidth << ", y Lorentz Bias " << theTemp.head.lorybias << ", x Lorentz width "
0086 << theTemp.head.lorxwidth << ", x Lorentz Bias " << theTemp.head.lorxbias
0087 << ", Q/Q_avg fractions for Qbin defs " << theTemp.head.fbin[0] << ", " << theTemp.head.fbin[1]
0088 << ", " << theTemp.head.fbin[2] << ", pixel x-size " << theTemp.head.xsize << ", y-size "
0089 << theTemp.head.ysize << ", zsize " << theTemp.head.zsize << "\n"
0090 << std::endl;
0091 }
0092
0093 std::map<unsigned int, short> templMap = payload->getTemplateIDs();
0094 for (auto const& entry : templMap) {
0095 std::cout << "DetID: " << entry.first << " template ID: " << entry.second << std::endl;
0096 templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f);
0097
0098 std::cout << "\t lorywidth " << templ.lorywidth() << " lorxwidth: " << templ.lorxwidth() << " lorybias "
0099 << templ.lorybias() << " lorxbias: " << templ.lorxbias() << "\n"
0100 << std::endl;
0101 }
0102
0103 fillWithValue(1.);
0104
0105 }
0106 }
0107 return true;
0108 }
0109 };
0110
0111
0112
0113
0114 template <SiPixelPI::DetType myType>
0115 class SiPixelTemplateLA : public PlotImage<SiPixelTemplateDBObject, SINGLE_IOV> {
0116 struct header_info {
0117 int ID;
0118 float lorywidth;
0119 float lorxwidth;
0120 float lorybias;
0121 float lorxbias;
0122 float Vbias;
0123 float temperature;
0124 int templ_version;
0125 float Bfield;
0126 float xsize;
0127 float ysize;
0128 float zsize;
0129 };
0130
0131 public:
0132 SiPixelTemplateLA() : PlotImage<SiPixelTemplateDBObject, SINGLE_IOV>("SiPixelTemplate assumed value of uH") {}
0133
0134 bool fill() override {
0135 gStyle->SetPalette(kRainBow);
0136 TGaxis::SetMaxDigits(2);
0137
0138 auto tag = PlotBase::getTag<0>();
0139 auto iov = tag.iovs.front();
0140 std::vector<SiPixelTemplateStore> thePixelTemp_;
0141 std::shared_ptr<SiPixelTemplateDBObject> payload = fetchPayload(std::get<1>(iov));
0142
0143 if (payload.get()) {
0144 if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) {
0145 throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector")
0146 << "\nERROR: Templates not filled correctly. Check the conditions. Using "
0147 "SiPixelTemplateDBObject version "
0148 << payload->version() << "\n\n";
0149 }
0150
0151
0152 SiPixelTemplate templ(thePixelTemp_);
0153 std::map<int, header_info> theInfos;
0154 for (const auto& theTemp : thePixelTemp_) {
0155 header_info info;
0156 info.ID = theTemp.head.ID;
0157 info.lorywidth = theTemp.head.lorywidth;
0158 info.lorxwidth = theTemp.head.lorxwidth;
0159 info.lorybias = theTemp.head.lorybias;
0160 info.lorxbias = theTemp.head.lorxbias;
0161 info.Vbias = theTemp.head.Vbias;
0162 info.temperature = theTemp.head.temperature;
0163 info.templ_version = theTemp.head.templ_version;
0164 info.Bfield = theTemp.head.Bfield;
0165 info.xsize = theTemp.head.xsize;
0166 info.ysize = theTemp.head.ysize;
0167 info.zsize = theTemp.head.zsize;
0168
0169 theInfos[theTemp.head.ID] = info;
0170 }
0171
0172
0173 Phase1PixelMaps theMaps("");
0174 if (myType == SiPixelPI::t_all) {
0175 theMaps.resetOption("COLZA L");
0176 } else {
0177 theMaps.resetOption("COLZL");
0178 }
0179
0180 if (myType == SiPixelPI::t_barrel) {
0181 theMaps.bookBarrelHistograms("templateLABarrel", "#muH", "#mu_{H} [1/T]");
0182 } else if (myType == SiPixelPI::t_forward) {
0183 theMaps.bookForwardHistograms("templateLAForward", "#muH", "#mu_{H} [1/T]");
0184 } else if (myType == SiPixelPI::t_all) {
0185 theMaps.bookBarrelHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
0186 theMaps.bookForwardHistograms("templateLA", "#muH", "#mu_{H} [1/T]");
0187 } else {
0188 edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
0189 << " un-recognized detector type " << myType << std::endl;
0190 return false;
0191 }
0192
0193 std::map<unsigned int, short> templMap = payload->getTemplateIDs();
0194 if (templMap.size() == SiPixelPI::phase0size || templMap.size() > SiPixelPI::phase1size) {
0195 edm::LogError("SiPixelTemplateDBObject_PayloadInspector")
0196 << "There are " << templMap.size()
0197 << " DetIds in this payload. SiPixelTempate Lorentz Angle maps are not supported for non-Phase1 Pixel "
0198 "geometries !";
0199 TCanvas canvas("Canv", "Canv", 1200, 1000);
0200 SiPixelPI::displayNotSupported(canvas, templMap.size());
0201 std::string fileName(m_imageFileName);
0202 canvas.SaveAs(fileName.c_str());
0203 return false;
0204 } else {
0205 if (templMap.size() < SiPixelPI::phase1size) {
0206 edm::LogWarning("SiPixelTemplateDBObject_PayloadInspector")
0207 << "\n ********* WARNING! ********* \n There are " << templMap.size() << " DetIds in this payload !"
0208 << "\n **************************** \n";
0209 }
0210 }
0211
0212 for (auto const& entry : templMap) {
0213 templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f);
0214
0215
0216 float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield;
0217 COUT << "uH: " << uH << " lor x width:" << templ.lorxwidth() << " z size: " << theInfos[entry.second].zsize
0218 << " B-field: " << theInfos[entry.second].Bfield << std::endl;
0219
0220 auto detid = DetId(entry.first);
0221 if (myType == SiPixelPI::t_all) {
0222 if ((detid.subdetId() == PixelSubdetector::PixelBarrel)) {
0223 theMaps.fillBarrelBin("templateLA", entry.first, uH);
0224 }
0225 if ((detid.subdetId() == PixelSubdetector::PixelEndcap)) {
0226 theMaps.fillForwardBin("templateLA", entry.first, uH);
0227 }
0228 } else if ((detid.subdetId() == PixelSubdetector::PixelBarrel) && (myType == SiPixelPI::t_barrel)) {
0229 theMaps.fillBarrelBin("templateLABarrel", entry.first, uH);
0230 } else if ((detid.subdetId() == PixelSubdetector::PixelEndcap) && (myType == SiPixelPI::t_forward)) {
0231 theMaps.fillForwardBin("templateLAForward", entry.first, uH);
0232 }
0233 }
0234
0235 theMaps.beautifyAllHistograms();
0236
0237 TCanvas canvas("Canv", "Canv", (myType == SiPixelPI::t_barrel) ? 1200 : 1600, 1000);
0238 if (myType == SiPixelPI::t_barrel) {
0239 theMaps.drawBarrelMaps("templateLABarrel", canvas);
0240 } else if (myType == SiPixelPI::t_forward) {
0241 theMaps.drawForwardMaps("templateLAForward", canvas);
0242 } else if (myType == SiPixelPI::t_all) {
0243 theMaps.drawSummaryMaps("templateLA", canvas);
0244 }
0245
0246 canvas.cd();
0247 std::string fileName(m_imageFileName);
0248 canvas.SaveAs(fileName.c_str());
0249 }
0250 return true;
0251 }
0252 };
0253
0254 using SiPixelTemplateLABPixMap = SiPixelTemplateLA<SiPixelPI::t_barrel>;
0255 using SiPixelTemplateLAFPixMap = SiPixelTemplateLA<SiPixelPI::t_forward>;
0256 using SiPixelTemplateLAMap = SiPixelTemplateLA<SiPixelPI::t_all>;
0257
0258 using namespace templateHelper;
0259
0260
0261
0262
0263 using SiPixelTemplateIDsFullPixelMap =
0264 SiPixelFullPixelIDMap<SiPixelTemplateDBObject, SiPixelTemplateStore, SiPixelTemplate>;
0265
0266
0267
0268
0269 using SiPixelTemplateTitles_Display =
0270 SiPixelTitles_Display<SiPixelTemplateDBObject, SiPixelTemplateStore, SiPixelTemplate>;
0271
0272
0273
0274
0275 using SiPixelTemplateHeaderTable = SiPixelHeaderTable<SiPixelTemplateDBObject, SiPixelTemplateStore, SiPixelTemplate>;
0276
0277
0278
0279
0280 using SiPixelTemplateIDsBPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_barrel>;
0281 using SiPixelTemplateIDsFPixMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_forward>;
0282 using SiPixelTemplateIDsMap = SiPixelIDs<SiPixelTemplateDBObject, SiPixelPI::t_all>;
0283
0284 }
0285
0286
0287 PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) {
0288 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest);
0289 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFullPixelMap);
0290 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateTitles_Display);
0291 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeaderTable);
0292 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsMap);
0293 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap);
0294 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap);
0295 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAMap);
0296 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap);
0297 PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAFPixMap);
0298 }