40 #include "TPaveStats.h" 44 #include <Math/Polynomial.h> 53 const std::array<std::string, 5> factorString = {
54 {
"pixel geometry",
"column geometry",
"chip geometry",
"PU",
"invalid"}};
56 using FactorMap = std::map<unsigned int, double>;
57 using PUFactorMap = std::map<unsigned int, std::vector<double> >;
61 const int rocIdMaskBits = 0x1F;
63 struct packedBadRocFraction {
64 std::vector<int> badRocNumber;
65 std::vector<float> badRocFrac;
68 using BRFractions = std::unordered_map<uint32_t, packedBadRocFraction>;
71 BRFractions pbrf(std::shared_ptr<SiPixelDynamicInefficiency>
payload) {
73 const std::map<uint32_t, double>& PixelGeomFactorsDBIn =
payload->getPixelGeomFactors();
76 for (
const auto db_factor : PixelGeomFactorsDBIn) {
79 unsigned int rocMask = rocIdMaskBits <<
shift;
80 unsigned int rocId = (((db_factor.first) & rocMask) >>
shift);
81 uint32_t rawid = db_factor.first & (~rocMask);
83 if (
f.find(rawid) ==
f.end()) {
84 packedBadRocFraction
p;
85 f.insert(std::make_pair(rawid,
p));
90 double factor = db_factor.second;
91 double badFraction = 1 -
factor;
93 f.at(rawid).badRocNumber.emplace_back(rocId);
94 f.at(rawid).badRocFrac.emplace_back(badFraction);
101 bool isPhase0(
const BRFractions& fractions) {
104 const auto& p0detIds =
reader.getAllDetIds();
105 std::vector<uint32_t> ownDetIds;
109 std::back_inserter(ownDetIds),
110 [](std::pair<uint32_t, packedBadRocFraction>
d) -> uint32_t {
return d.first; });
112 for (
const auto& det : ownDetIds) {
114 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
122 double getMatchingGeomFactor(
const DetId& detid,
123 const std::map<unsigned int, double>& map_geomfactor,
124 const std::vector<uint32_t>& detIdmasks) {
125 double geomfactor_db = 1;
126 for (
auto map_element : map_geomfactor) {
131 for (; __i < detIdmasks.size(); __i++) {
139 if (__i != detIdmasks.size())
141 geomfactor_db *= map_element.second;
143 return geomfactor_db;
147 std::vector<double> getMatchingPUFactors(
const DetId& detid,
148 const std::map<
unsigned int, std::vector<double> >& map_pufactory,
149 const std::vector<uint32_t>& detIdmasks) {
150 std::vector<double> pufactors_db;
151 for (
const auto& map_element : map_pufactory) {
156 for (; __i < detIdmasks.size(); __i++) {
164 if (__i != detIdmasks.size())
166 pufactors_db = map_element.second;
173 [[maybe_unused]]
bool matches(
const DetId& detid,
const DetId& db_id,
const std::vector<uint32_t>& DetIdmasks) {
176 for (
size_t i = 0;
i < DetIdmasks.size(); ++
i) {
192 inputFile =
"Geometry/TrackerCommonData/data/trackerParameters.xml";
195 inputFile =
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
198 inputFile =
"Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml";
201 throw cms::Exception(
"SiPixelDynamicInefficiency_PayloadInspector") <<
"checkPhase: unrecongnized phase!";
211 std::vector<uint32_t> masks_geom;
214 masks_geom.push_back(tkTopo.pxbDetId(
max, 0, 0).rawId());
215 masks_geom.push_back(tkTopo.pxbDetId(0,
max, 0).rawId());
216 masks_geom.push_back(tkTopo.pxbDetId(0, 0,
max).rawId());
217 masks_geom.push_back(tkTopo.pxfDetId(
max, 0, 0, 0, 0).rawId());
218 masks_geom.push_back(tkTopo.pxfDetId(0,
max, 0, 0, 0).rawId());
219 masks_geom.push_back(tkTopo.pxfDetId(0, 0,
max, 0, 0).rawId());
220 masks_geom.push_back(tkTopo.pxfDetId(0, 0, 0,
max, 0).rawId());
221 masks_geom.push_back(tkTopo.pxfDetId(0, 0, 0, 0,
max).rawId());
223 return (masks_geom.size() == masks_db.size() &&
224 std::equal(masks_geom.begin(), masks_geom.end(), masks_db.begin()));
228 unsigned int maxDepthOfPUArray(
const std::map<
unsigned int, std::vector<double> >& map_pufactor) {
229 unsigned int size{0};
230 for (
const auto& [
id, vec] : map_pufactor) {
231 if (vec.size() >
size)
238 std::pair<int, int> getClosestFactors(
int input) {
244 while (
input % testNum != 0) {
247 return std::make_pair(testNum,
input / testNum);
253 std::string findStem(
const std::vector<std::string>& arr) {
259 int len =
s.length();
263 for (
int i = 0;
i < len;
i++) {
264 for (
int j =
i + 1;
j <= len;
j++) {
269 for (
k = 1;
k <
n;
k++) {
272 if (arr[
k].
find(stem) == std::string::npos)
279 if (
k ==
n &&
res.length() < stem.length())
291 std::vector<std::string>
regions;
292 for (
const auto&
rawId : listOfDetIds) {
294 t_info_fromXML.
init();
316 if (retVal.back() ==
'/')
322 void fillParametrizations(
std::vector<std::vector<double> >& listOfParametrizations,
323 std::vector<TF1*>& parametrizations,
324 std::vector<std::string>& formulas,
325 const std::vector<std::string>& namesOfParts) {
326 static constexpr
double xmin_ = 0.;
327 static constexpr
double xmax_ = 25.;
330 auto func = [](
double*
x,
double*
p) {
333 ROOT::Math::Polynomial pol(
n);
338 for (
auto&
params : listOfParametrizations) {
343 if (
str.length() >= 2 &&
str.substr(
str.length() - 2) ==
"/i") {
345 }
else if (
str.length() >= 2 &&
str.substr(
str.length() - 2) ==
"/o") {
349 TF1*
f1 =
new TF1((fmt::sprintf(
"region: #bf{%s}",
str)).c_str(),
func, xmin_, xmax_, npar);
354 double* arr =
params.data();
358 for (
unsigned int j = 0;
j <
params.size();
j++) {
359 f1->SetParameter(
j, arr[
j]);
362 parametrizations.push_back(
f1);
367 for (
unsigned int i = 1;
i <
params.size();
i++) {
381 class SiPixelDynamicInefficiencyTest :
public Histogram1D<SiPixelDynamicInefficiency, SINGLE_IOV> {
383 SiPixelDynamicInefficiencyTest()
385 "SiPixelDynamicInefficiency test",
"SiPixelDynamicInefficiency test", 1, 0.0, 1.0) {}
387 bool fill()
override {
388 auto tag = PlotBase::getTag<0>();
389 for (
auto const& iov :
tag.iovs) {
390 std::shared_ptr<SiPixelDynamicInefficiency>
payload = Base::fetchPayload(std::get<1>(iov));
394 std::map<unsigned int, double> map_pixelgeomfactor =
payload->getPixelGeomFactors();
395 std::map<unsigned int, double> map_colgeomfactor =
payload->getColGeomFactors();
396 std::map<unsigned int, double> map_chipgeomfactor =
payload->getChipGeomFactors();
397 std::map<unsigned int, std::vector<double> > map_pufactor =
payload->getPUFactors();
398 std::vector<uint32_t> detIdmasks_db =
payload->getDetIdmasks();
399 double theInstLumiScaleFactor_db =
payload->gettheInstLumiScaleFactor_();
401 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
"-------------------------------------------------------";
402 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
"Printing out DB content:\n";
404 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" PixelGeomFactors:";
405 for (
auto pixel : map_pixelgeomfactor)
407 <<
" MapID = " <<
pixel.first <<
"\tFactor = " <<
pixel.second;
410 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" ColGeomFactors:";
411 for (
auto col : map_colgeomfactor)
413 <<
" MapID = " <<
col.first <<
"\tFactor = " <<
col.second;
416 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" ChipGeomFactors:";
417 for (
auto chip : map_chipgeomfactor)
419 <<
" MapID = " << chip.first <<
"\tFactor = " << chip.second;
422 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" PUFactors:";
423 for (
auto pu : map_pufactor) {
425 <<
" MapID = " <<
pu.first <<
"\t Factor" << (
pu.second.size() > 1 ?
"s" :
"") <<
" = ";
426 for (
size_t i = 0,
n =
pu.second.size();
i <
n; ++
i)
427 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
pu.second[
i] << ((
i ==
n - 1) ?
"\n" :
", ");
431 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" DetIdmasks:";
432 for (
auto mask : detIdmasks_db)
436 edm::LogPrint(
"SiPixelDynamicInefficiencyTest") <<
" theInstLumiScaleFactor = " << theInstLumiScaleFactor_db;
447 template <SiPixelPI::DetType myType>
448 class SiPixelIneffROCfromDynIneffMap :
public PlotImage<SiPixelDynamicInefficiency, SINGLE_IOV> {
450 SiPixelIneffROCfromDynIneffMap()
455 bool fill()
override {
456 auto tag = PlotBase::getTag<0>();
457 auto iov =
tag.iovs.front();
459 std::shared_ptr<SiPixelDynamicInefficiency>
payload = fetchPayload(std::get<1>(iov));
461 const auto fr = SiPixDynIneff::pbrf(
payload);
463 if (SiPixDynIneff::isPhase0(fr)) {
465 <<
"SiPixelIneffROCfromDynIneff maps are not supported for non-Phase1 Pixel geometries !";
466 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
475 for (
const auto& element : fr) {
476 auto rawid = element.first;
478 auto packedinfo = element.second;
479 auto badRocs = packedinfo.badRocNumber;
480 auto badRocsF = packedinfo.badRocFrac;
482 for (
size_t i = 0;
i < badRocs.size();
i++) {
483 std::bitset<16> rocToMark;
484 rocToMark.set(badRocs[
i]);
488 theMap.fillSelectedRocs(rawid, rocToMark, badRocsF[
i] * 100.
f);
493 gStyle->SetOptStat(0);
495 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
504 const auto headerText = fmt::sprintf(
"#color[4]{%s}, IOV: #color[4]{%s}",
tagname, IOVstring);
508 theMap.drawBarrelMaps(
canvas, headerText);
511 theMap.drawForwardMaps(
canvas, headerText);
514 theMap.drawMaps(
canvas, headerText);
517 throw cms::Exception(
"SiPixelIneffROCfromDynIneffMap") <<
"\nERROR: unrecognized Pixel Detector part ";
523 canvas.SaveAs(
"outAll.root");
530 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
534 using SiPixelBPixIneffROCfromDynIneffMap = SiPixelIneffROCfromDynIneffMap<SiPixelPI::t_barrel>;
535 using SiPixelFPixIneffROCfromDynIneffMap = SiPixelIneffROCfromDynIneffMap<SiPixelPI::t_forward>;
536 using SiPixelFullIneffROCfromDynIneffMap = SiPixelIneffROCfromDynIneffMap<SiPixelPI::t_all>;
541 template <SiPixelPI::DetType myType, IOVMultiplicity nIOVs,
int ntags>
542 class SiPixelIneffROCComparisonBase :
public PlotImage<SiPixelDynamicInefficiency, nIOVs, ntags> {
544 SiPixelIneffROCComparisonBase()
546 Form(
"SiPixelDynamicInefficiency %s Pixel Map",
SiPixelPI::
DetNames[myType].c_str())),
550 bool fill()
override {
552 auto theIOVs = PlotBase::getTag<0>().iovs;
553 auto f_tagname = PlotBase::getTag<0>().
name;
555 auto firstiov = theIOVs.front();
556 std::tuple<cond::Time_t, cond::Hash> lastiov;
559 assert(this->m_plotAnnotations.ntags < 3);
561 if (this->m_plotAnnotations.ntags == 2) {
562 auto tag2iovs = PlotBase::getTag<1>().iovs;
563 l_tagname = PlotBase::getTag<1>().
name;
564 lastiov = tag2iovs.front();
566 lastiov = theIOVs.back();
569 std::shared_ptr<SiPixelDynamicInefficiency> last_payload = this->fetchPayload(std::get<1>(lastiov));
570 std::shared_ptr<SiPixelDynamicInefficiency> first_payload = this->fetchPayload(std::get<1>(firstiov));
572 const auto fp = SiPixDynIneff::pbrf(last_payload);
573 const auto lp = SiPixDynIneff::pbrf(first_payload);
575 if (SiPixDynIneff::isPhase0(
fp) || SiPixDynIneff::isPhase0(lp)) {
577 <<
"SiPixelDynamicInefficiency comparison maps are not supported for non-Phase1 Pixel geometries !";
578 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
587 gStyle->SetOptStat(0);
589 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
605 if (this->m_plotAnnotations.ntags == 2) {
607 fmt::sprintf(
"#color[2]{A: %s, %s} - #color[4]{B: %s, %s}", f_tagname, f_IOVstring, l_tagname, l_IOVstring);
609 headerText = fmt::sprintf(
"%s,IOV #color[2]{A: %s} - #color[4]{B: %s} ", f_tagname, f_IOVstring, l_IOVstring);
614 theMap.drawBarrelMaps(
canvas, headerText);
617 theMap.drawForwardMaps(
canvas, headerText);
620 theMap.drawMaps(
canvas, headerText);
624 <<
"\nERROR: unrecognized Pixel Detector part ";
628 fillTheMapFromPayload(theMap,
fp,
false);
631 fillTheMapFromPayload(theMap, lp,
true);
636 canvas.SaveAs(
"outAll.root");
643 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
648 for (
const auto& element : fr) {
649 auto rawid = element.
first;
651 auto packedinfo = element.second;
652 auto badRocs = packedinfo.badRocNumber;
653 auto badRocsF = packedinfo.badRocFrac;
655 for (
size_t i = 0;
i < badRocs.size();
i++) {
656 std::bitset<16> rocToMark;
657 rocToMark.set(badRocs[
i]);
673 using SiPixelBPixIneffROCsMapCompareSingleTag = SiPixelIneffROCComparisonBase<SiPixelPI::t_barrel, MULTI_IOV, 1>;
674 using SiPixelFPixIneffROCsMapCompareSingleTag = SiPixelIneffROCComparisonBase<SiPixelPI::t_forward, MULTI_IOV, 1>;
675 using SiPixelFullIneffROCsMapCompareSingleTag = SiPixelIneffROCComparisonBase<SiPixelPI::t_all, MULTI_IOV, 1>;
677 using SiPixelBPixIneffROCsMapCompareTwoTags = SiPixelIneffROCComparisonBase<SiPixelPI::t_barrel, SINGLE_IOV, 2>;
678 using SiPixelFPixIneffROCsMapCompareTwoTags = SiPixelIneffROCComparisonBase<SiPixelPI::t_forward, SINGLE_IOV, 2>;
679 using SiPixelFullIneffROCsMapCompareTwoTags = SiPixelIneffROCComparisonBase<SiPixelPI::t_all, SINGLE_IOV, 2>;
684 template <SiPixDynIneff::factor theFactor>
685 class SiPixelDynamicInefficiencyFullPixelMap :
public PlotImage<SiPixelDynamicInefficiency, SINGLE_IOV> {
687 SiPixelDynamicInefficiencyFullPixelMap()
689 label_ =
"SiPixelDynamicInefficiencyFullPixelMap";
690 payloadString = fmt::sprintf(
"%s Dynamic Inefficiency", SiPixDynIneff::factorString[theFactor]);
693 bool fill()
override {
694 gStyle->SetPalette(1);
695 auto tag = PlotBase::getTag<0>();
696 auto iov =
tag.iovs.front();
697 std::shared_ptr<SiPixelDynamicInefficiency>
payload = this->fetchPayload(std::get<1>(iov));
700 Phase1PixelSummaryMap fullMap(
"", fmt::sprintf(
"%s", payloadString), fmt::sprintf(
"%s", payloadString));
701 fullMap.createTrackerBaseMap();
703 SiPixDynIneff::FactorMap theMap{};
706 theMap =
payload->getPixelGeomFactors();
708 case SiPixDynIneff::colgeom:
709 theMap =
payload->getColGeomFactors();
711 case SiPixDynIneff::chipgeom:
712 theMap =
payload->getChipGeomFactors();
715 throw cms::Exception(label_) <<
"\nERROR: unrecognized type of geometry factor ";
718 std::vector<uint32_t> detIdmasks_db =
payload->getDetIdmasks();
721 edm::LogError(label_) << label_ <<
" maps are not supported for non-Phase1 Pixel geometries !";
722 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
731 const auto& p1detIds =
reader.getAllDetIds();
733 for (
const auto& det : p1detIds) {
734 const auto&
value = SiPixDynIneff::getMatchingGeomFactor(det, theMap, detIdmasks_db);
735 fullMap.fillTrackerMap(det,
value);
738 const auto&
range = fullMap.getZAxisRange();
742 fullMap.setZAxisRange(
range.first - 0.01,
range.second + 0.01);
745 TCanvas
canvas(
"Canv",
"Canv", 3000, 2000);
746 fullMap.printTrackerMap(
canvas);
750 ltx.SetTextSize(0.025);
751 ltx.SetTextAlign(11);
753 gPad->GetLeftMargin() + 0.01,
754 gPad->GetBottomMargin() + 0.01,
755 (
"#color[4]{" +
tag.name +
"}, IOV: #color[4]{" +
std::to_string(std::get<0>(iov)) +
"}").c_str());
768 using SiPixelDynamicInefficiencyGeomFactorMap = SiPixelDynamicInefficiencyFullPixelMap<SiPixDynIneff::geom>;
769 using SiPixelDynamicInefficiencyColGeomFactorMap = SiPixelDynamicInefficiencyFullPixelMap<SiPixDynIneff::colgeom>;
770 using SiPixelDynamicInefficiencyChipGeomFactorMap = SiPixelDynamicInefficiencyFullPixelMap<SiPixDynIneff::chipgeom>;
775 class SiPixelDynamicInefficiencyPUPixelMaps :
public PlotImage<SiPixelDynamicInefficiency, SINGLE_IOV> {
777 SiPixelDynamicInefficiencyPUPixelMaps()
779 label_ =
"SiPixelDynamicInefficiencyFullPixelMap";
780 payloadString = fmt::sprintf(
"%s Dynamic Inefficiency", SiPixDynIneff::factorString[
SiPixDynIneff::pu]);
783 bool fill()
override {
784 gStyle->SetPalette(1);
785 auto tag = PlotBase::getTag<0>();
786 auto iov =
tag.iovs.front();
787 std::shared_ptr<SiPixelDynamicInefficiency>
payload = this->fetchPayload(std::get<1>(iov));
790 std::vector<Phase1PixelSummaryMap> maps;
792 SiPixDynIneff::PUFactorMap theMap =
payload->getPUFactors();
793 std::vector<uint32_t> detIdmasks_db =
payload->getDetIdmasks();
796 edm::LogError(label_) << label_ <<
" maps are not supported for non-Phase1 Pixel geometries !";
797 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
804 unsigned int depth = SiPixDynIneff::maxDepthOfPUArray(theMap);
807 for (
unsigned int i = 0;
i <
depth;
i++) {
809 "", fmt::sprintf(
"%s, factor %i", payloadString,
i), fmt::sprintf(
"%s, factor %i", payloadString,
i));
810 maps[
i].createTrackerBaseMap();
816 const auto& p1detIds =
reader.getAllDetIds();
819 for (
const auto& det : p1detIds) {
820 const auto&
values = SiPixDynIneff::getMatchingPUFactors(det, theMap, detIdmasks_db);
830 for (
unsigned int i = 0;
i <
depth;
i++) {
831 const auto&
range = maps[
i].getZAxisRange();
833 maps[
i].setZAxisRange(
range.first - 0.01,
range.second + 0.01);
838 auto sides = SiPixDynIneff::getClosestFactors(
depth);
839 TCanvas
canvas(
"Canv",
"Canv", sides.second * 900, sides.first * 600);
840 canvas.Divide(sides.second, sides.first);
843 for (
unsigned int i = 0;
i <
depth;
i++) {
844 maps[
i].printTrackerMap(
canvas, 0.035,
i + 1);
847 ltx.SetTextSize(0.025);
848 ltx.SetTextAlign(11);
850 gPad->GetLeftMargin() + 0.01,
851 gPad->GetBottomMargin() + 0.01,
852 (
"#color[4]{" +
tag.name +
"}, IOV: #color[4]{" +
std::to_string(std::get<0>(iov)) +
"}").c_str());
869 class SiPixelDynamicInefficiencyPUParametrization :
public PlotImage<SiPixelDynamicInefficiency, SINGLE_IOV> {
871 SiPixelDynamicInefficiencyPUParametrization()
873 label_ =
"SiPixelDynamicInefficiencyPUParameterization";
875 fmt::sprintf(
"%s Dynamic Inefficiency parametrization", SiPixDynIneff::factorString[
SiPixDynIneff::pu]);
878 bool fill()
override {
879 gStyle->SetPalette(1);
880 auto tag = PlotBase::getTag<0>();
881 auto iov =
tag.iovs.front();
882 std::shared_ptr<SiPixelDynamicInefficiency>
payload = this->fetchPayload(std::get<1>(iov));
885 SiPixDynIneff::PUFactorMap theMap =
payload->getPUFactors();
886 std::vector<uint32_t> detIdmasks_db =
payload->getDetIdmasks();
889 edm::LogError(label_) << label_ <<
" maps are not supported for non-Phase1 Pixel geometries !";
890 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
897 std::vector<std::vector<double> > listOfParametrizations;
902 auto p1detIds =
reader.getAllDetIds();
908 std::map<unsigned int, std::vector<uint32_t> > modules_per_region;
911 for (
const auto& det : p1detIds) {
912 const auto&
values = SiPixDynIneff::getMatchingPUFactors(det, theMap, detIdmasks_db);
914 auto pIndex =
std::find(listOfParametrizations.begin(), listOfParametrizations.end(),
values);
916 if (pIndex == listOfParametrizations.end()) {
917 listOfParametrizations.push_back(
values);
918 std::vector<unsigned int> toInsert = {det};
919 modules_per_region.insert(std::make_pair(listOfParametrizations.size() - 1, toInsert));
921 modules_per_region.at(pIndex - listOfParametrizations.begin()).
push_back(det);
925 unsigned int depth = listOfParametrizations.size();
927 std::vector<std::string> namesOfParts;
928 namesOfParts.reserve(
depth);
930 for (
const auto& [
index,
modules] : modules_per_region) {
932 const auto& regName = SiPixDynIneff::attachLocationLabel(
modules, PhInfo);
933 namesOfParts.push_back(regName);
940 std::stringstream
ss;
941 ss <<
"region name: " << regName <<
" has the following modules attached: [";
947 <<
" has representation (";
948 for (
const auto& param : listOfParametrizations[
index]) {
957 std::vector<TF1*> parametrizations;
958 std::vector<std::string> formulas;
959 parametrizations.reserve(
depth);
960 formulas.reserve(
depth);
963 SiPixDynIneff::fillParametrizations(listOfParametrizations, parametrizations, formulas, namesOfParts);
966 auto sides = SiPixDynIneff::getClosestFactors(
depth);
967 TCanvas
canvas(
"Canv",
"Canv", sides.second * 900, sides.first * 600);
968 canvas.Divide(sides.second, sides.first);
971 for (
unsigned int i = 0;
i <
depth;
i++) {
975 parametrizations[
i]->Draw();
978 TH1*
h = parametrizations[
i]->GetHistogram();
979 TAxis* ax =
h->GetXaxis();
980 ax->SetTitle(
"Inst. luminosity [10^{33} cm^{-2}s^{-1}]");
982 TAxis* ay =
h->GetYaxis();
983 ay->SetRangeUser(0.80, 1.00);
984 ay->SetTitle(
"Double Column Efficiency parametrization");
991 ltx.SetTextSize(0.045);
992 ltx.SetTextAlign(11);
994 gPad->GetLeftMargin() + 0.03,
995 gPad->GetBottomMargin() + 0.08,
996 (
"#color[2]{" +
tag.name +
"},IOV: #color[2]{" +
std::to_string(std::get<0>(iov)) +
"}").c_str());
998 auto ltxForm = TLatex();
999 ltxForm.SetTextFont(62);
1000 ltxForm.SetTextColor(kRed);
1001 ltxForm.SetTextSize(0.035);
1002 ltxForm.SetTextAlign(11);
1003 ltxForm.DrawLatexNDC(gPad->GetLeftMargin() + 0.03, gPad->GetBottomMargin() + 0.04, formulas[
i].c_str());
1005 edm::LogPrint(label_) << namesOfParts[
i] <<
" => " << formulas[
i] << std::endl;
1020 template <IOVMultiplicity nIOVs,
int ntags>
1021 class SiPixelDynamicInefficiencyPUParamComparisonBase :
public PlotImage<SiPixelDynamicInefficiency, nIOVs, ntags> {
1023 SiPixelDynamicInefficiencyPUParamComparisonBase()
1025 Form(
"SiPixelDynamic Inefficiency parameterization comparison by Region %i tag(s)", ntags)) {
1026 label_ =
"SiPixelDynamicInefficiencyPUParameterization";
1029 bool fill()
override {
1030 gStyle->SetPalette(1);
1033 auto theIOVs = PlotBase::getTag<0>().iovs;
1034 auto f_tagname = PlotBase::getTag<0>().
name;
1036 auto firstiov = theIOVs.front();
1037 std::tuple<cond::Time_t, cond::Hash> lastiov;
1040 assert(this->m_plotAnnotations.ntags < 3);
1042 if (this->m_plotAnnotations.ntags == 2) {
1043 auto tag2iovs = PlotBase::getTag<1>().iovs;
1044 l_tagname = PlotBase::getTag<1>().
name;
1045 lastiov = tag2iovs.front();
1047 lastiov = theIOVs.back();
1050 std::shared_ptr<SiPixelDynamicInefficiency> last_payload = this->fetchPayload(std::get<1>(lastiov));
1051 std::shared_ptr<SiPixelDynamicInefficiency> first_payload = this->fetchPayload(std::get<1>(firstiov));
1053 if (first_payload.get() && last_payload.get()) {
1054 SiPixDynIneff::PUFactorMap f_theMap = first_payload->getPUFactors();
1055 std::vector<uint32_t> f_detIdmasks_db = first_payload->getDetIdmasks();
1057 SiPixDynIneff::PUFactorMap l_theMap = last_payload->getPUFactors();
1058 std::vector<uint32_t> l_detIdmasks_db = last_payload->getDetIdmasks();
1062 edm::LogError(label_) << label_ <<
" maps are not supported for non-Phase1 Pixel geometries !";
1063 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
1070 std::vector<std::vector<double> > f_listOfParametrizations;
1071 std::vector<std::vector<double> > l_listOfParametrizations;
1076 auto p1detIds =
reader.getAllDetIds();
1082 std::map<unsigned int, std::vector<uint32_t> > modules_per_region;
1085 for (
const auto& det : p1detIds) {
1086 const auto& f_values = SiPixDynIneff::getMatchingPUFactors(det, f_theMap, f_detIdmasks_db);
1087 const auto& l_values = SiPixDynIneff::getMatchingPUFactors(det, l_theMap, l_detIdmasks_db);
1090 auto fIndex =
std::find(f_listOfParametrizations.begin(), f_listOfParametrizations.end(), f_values);
1091 auto lIndex =
std::find(l_listOfParametrizations.begin(), l_listOfParametrizations.end(), l_values);
1094 if (fIndex == f_listOfParametrizations.end()) {
1095 f_listOfParametrizations.push_back(f_values);
1096 std::vector<unsigned int> toInsert = {det};
1097 modules_per_region.insert(std::make_pair(f_listOfParametrizations.size() - 1, toInsert));
1099 modules_per_region.at(fIndex - f_listOfParametrizations.begin()).
push_back(det);
1102 if (lIndex == l_listOfParametrizations.end()) {
1103 l_listOfParametrizations.push_back(l_values);
1107 unsigned int f_depth = f_listOfParametrizations.size();
1108 unsigned int l_depth = l_listOfParametrizations.size();
1110 if (l_depth != f_depth) {
1112 <<
" trying to compare dynamic inefficiencys payload with different detid masks!";
1113 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
1120 assert(f_depth == l_depth);
1122 std::vector<std::string> namesOfParts;
1123 namesOfParts.reserve(f_depth);
1125 for (
const auto& [
index,
modules] : modules_per_region) {
1127 const auto& regName = SiPixDynIneff::attachLocationLabel(
modules, PhInfo);
1128 namesOfParts.push_back(regName);
1135 std::stringstream
ss;
1136 ss <<
"region name: " << regName <<
" has the following modules attached: [";
1142 <<
" has representation (";
1143 for (
const auto& param : f_listOfParametrizations[
index]) {
1144 ss << param <<
", ";
1153 std::vector<TF1*> f_parametrizations;
1154 std::vector<std::string> f_formulas;
1155 f_parametrizations.reserve(f_depth);
1156 f_formulas.reserve(f_depth);
1158 std::vector<TF1*> l_parametrizations;
1159 std::vector<std::string> l_formulas;
1160 l_parametrizations.reserve(l_depth);
1161 l_formulas.reserve(l_depth);
1164 SiPixDynIneff::fillParametrizations(f_listOfParametrizations, f_parametrizations, f_formulas, namesOfParts);
1165 SiPixDynIneff::fillParametrizations(l_listOfParametrizations, l_parametrizations, l_formulas, namesOfParts);
1168 auto sides = SiPixDynIneff::getClosestFactors(f_depth);
1169 TCanvas
canvas(
"Canv",
"Canv", sides.second * 900, sides.first * 600);
1170 canvas.Divide(sides.second, sides.first);
1173 for (
unsigned int i = 0;
i < f_depth;
i++) {
1177 f_parametrizations[
i]->Draw();
1178 l_parametrizations[
i]->SetLineColor(kBlue);
1179 l_parametrizations[
i]->SetLineStyle(kDashed);
1180 l_parametrizations[
i]->Draw(
"same");
1183 TH1*
h = f_parametrizations[
i]->GetHistogram();
1184 TAxis* ax =
h->GetXaxis();
1185 ax->SetTitle(
"Inst. luminosity [10^{33} cm^{-2}s^{-1}]");
1187 TAxis* ay =
h->GetYaxis();
1188 ay->SetRangeUser(0.80, 1.00);
1189 ay->SetTitle(
"Double Column Efficiency parametrization");
1194 auto ltx = TLatex();
1195 ltx.SetTextFont(62);
1196 ltx.SetTextSize(0.045);
1197 ltx.SetTextAlign(11);
1199 gPad->GetLeftMargin() + 0.03,
1200 gPad->GetBottomMargin() + 0.16,
1201 (
"#color[2]{" + f_tagname +
"},IOV: #color[2]{" +
std::to_string(std::get<0>(firstiov)) +
"}").c_str());
1203 gPad->GetLeftMargin() + 0.03,
1204 gPad->GetBottomMargin() + 0.08,
1205 (
"#color[4]{" + l_tagname +
"},IOV: #color[4]{" +
std::to_string(std::get<0>(lastiov)) +
"}").c_str());
1207 auto ltxForm = TLatex();
1208 ltxForm.SetTextFont(62);
1209 ltxForm.SetTextColor(kRed);
1210 ltxForm.SetTextSize(0.035);
1211 ltxForm.SetTextAlign(11);
1212 ltxForm.DrawLatexNDC(gPad->GetLeftMargin() + 0.03, gPad->GetBottomMargin() + 0.12, f_formulas[
i].c_str());
1214 ltxForm.SetTextColor(kBlue);
1215 ltxForm.DrawLatexNDC(gPad->GetLeftMargin() + 0.03, gPad->GetBottomMargin() + 0.04, l_formulas[
i].c_str());
1217 edm::LogPrint(label_) << namesOfParts[
i] <<
" => " << f_formulas[
i] << std::endl;
1218 edm::LogPrint(label_) << namesOfParts[
i] <<
" => " << l_formulas[
i] << std::endl;
1233 using SiPixelDynamicInefficiencyPUParamComparisonTwoTags =
1234 SiPixelDynamicInefficiencyPUParamComparisonBase<SINGLE_IOV, 2>;
Log< level::Info, true > LogVerbatim
const char * pathToTopoXML()
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
static constexpr char const *const kPh1DefaultFile
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
constexpr Detector det() const
get the detector field from this detid
static std::string to_string(const XMLCh *ch)
bool equal(const T &first, const T &second)
static std::string const input
const SiPixelPI::phase phase() const
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static const unsigned int phase1size
SiPixelPI::regions filterThePartition()
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Log< level::Warning, true > LogPrint
const std::array< std::string, 3 > DetNames
void makeNicePlotStyle(TH1 *hist)
constexpr uint32_t rawId() const
get the raw id
void displayNotSupported(TCanvas &canv, const unsigned int size)
void fillSelectedRocs(const uint32_t &detid, const std::bitset< 16 > &theROCs, double value)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
uint32_t first(const DetId &id) const
static unsigned int const shift
static constexpr char const *const kPh0DefaultFile
std::string getStringFromRegionEnum(SiPixelPI::regions e)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.