1 #ifndef CondCore_SiStripPlugins_SiStripCondObjectRepresent_h 2 #define CondCore_SiStripPlugins_SiStripCondObjectRepresent_h 10 #include <fmt/printf.h> 28 #include "TPaveLabel.h" 37 {
"TIB", kRed}, {
"TOB", kGreen}, {
"TID", kBlack}, {
"TEC", kBlue}};
39 {
"TIB", kFullCircle}, {
"TOB", kFullTriangleUp}, {
"TID", kFullSquare}, {
"TEC", kFullTriangleDown}};
51 void fillAll(
unsigned int detid,
const std::vector<type> &store) {
65 <<
"data size of numerator mismatched the data size of denominator";
75 void subtract(
unsigned int detid,
const std::vector<type> &subtractor) {
76 if (
m_info[detid].
size() != subtractor.size()) {
78 <<
"data size of numerator mismatched the data size of denominator";
82 for (
const auto &sub : subtractor) {
88 std::vector<type>
data(
unsigned int detid) {
return m_info[detid]; }
90 std::pair<std::vector<type>, std::vector<type> >
demuxedData(
unsigned int detid) {
94 assert(v1.size() == v2.size());
95 return std::make_pair(v1, v2);
97 throw cms::Exception(
"Logic error") <<
"not being in compared mode, data cannot be demultiplexed";
104 std::vector<type> &
values,
105 const unsigned int prev_det,
106 unsigned int &prev_apv,
107 const unsigned int detid) {
108 unsigned int istrip = 0;
116 flush = (prev_det != 0 && prev_det != detid);
119 flush = (istrip != 0);
124 mon->Fill(prev_apv, prev_det,
entry.mean());
145 std::vector<unsigned int>
v;
146 for (
const auto &element :
m_info) {
150 v.push_back(element.first);
157 std::map<unsigned int, std::vector<type> >
m_info;
173 template <
class Item,
class type>
184 edm::FileInPath(
"Geometry/TrackerCommonData/data/trackerParameters.xml").
fullPath())) {
194 const unsigned int run()
const {
return run_; }
211 switch (myGranularity) {
222 edm::LogError(
"LogicError") <<
"Unknown granularity type: " << myGranularity;
235 <<
"storeAllValues definition not found for " <<
payloadName() <<
"\n;";
244 const char *thePlotType =
"";
247 thePlotType = Form(
"Display - IOV: %i",
run_);
250 thePlotType =
"Display";
259 thePlotType = Form(
"TrackerMap - %s",
hash_.c_str());
290 for (
const auto &detId : listOfDetIds) {
291 auto entriesToAdd = SiStripCondData2_.data(detId);
292 for (
const auto &
entry : entriesToAdd) {
313 for (
const auto &detId : listOfDetIds) {
333 for (
const auto &detId : listOfDetIds) {
345 for (
const auto &detId : listOfDetIds) {
357 std::pair<float, float> &
range,
359 const int nsigmas_of_saturation)
376 std::map<unsigned int, float> info_per_detid;
381 for (
const auto &detId : listOfDetIds) {
384 unsigned int nElements =
values.size();
405 info_per_detid[detId] =
min;
408 info_per_detid[detId] =
max;
411 info_per_detid[detId] =
mean;
414 info_per_detid[detId] =
rms;
423 for (
const auto &
item : info_per_detid) {
434 auto myMode = op_mode_;
441 <<
" in a conditions served per APV";
452 <<
" in a conditions served per module";
462 Form(
"#LT %s #GT per %s;#LT%s per %s#GT %s;n. %ss",
468 opType(op_mode_).c_str()),
476 Form(
"#LT %s #GT per %s;#LT%s per %s#GT %s;n. %ss",
482 opType(op_mode_).c_str()),
493 unsigned int prev_det = 0;
494 unsigned int prev_apv = 0;
499 <<
" listOfDetIds.size(): " << listOfDetIds.size() << std::endl;
501 for (
const auto &detId : listOfDetIds) {
505 SiStripCondData_.fillMonitor1D(myMode, l_mon, l_entryContainer,
values.second, prev_det, prev_apv, detId);
513 TH1F *h_first = (TH1F *)(f_mon->
getHist()).Clone(
"h_first");
514 h_first->SetStats(kFALSE);
516 h_first->GetYaxis()->CenterTitle(
true);
517 h_first->GetXaxis()->CenterTitle(
true);
518 h_first->SetLineWidth(2);
519 h_first->SetLineColor(kBlack);
523 canvas.SetBottomMargin(0.11);
524 canvas.SetLeftMargin(0.13);
525 canvas.SetRightMargin(0.05);
528 TLegend *
legend =
new TLegend(0.52, 0.82, 0.95, 0.9);
529 legend->SetTextSize(0.025);
532 float theMax = h_first->GetMaximum();
533 h_first->SetMaximum(theMax * 1.30);
536 legend->AddEntry(h_first, Form(
"IOV: %i",
run_),
"L");
539 TH1F *h_last = (TH1F *)(l_mon->
getHist()).Clone(
"h_last");
540 h_last->SetStats(kFALSE);
542 h_last->GetYaxis()->CenterTitle(
true);
543 h_last->GetXaxis()->CenterTitle(
true);
544 h_last->SetLineWidth(2);
545 h_last->SetLineColor(kBlue);
547 std::cout << h_first->GetEntries() <<
" ---- " << h_last->GetEntries() << std::endl;
549 float theMax = (h_first->GetMaximum() > h_last->GetMaximum()) ? h_first->GetMaximum() : h_last->GetMaximum();
551 h_first->SetMaximum(theMax * 1.30);
552 h_last->SetMaximum(theMax * 1.30);
555 h_last->Draw(
"same");
558 legend->AddEntry(h_first, Form(
"IOV: %i",
run_),
"F");
569 std::map<unsigned int, SiStripDetSummary::Values> f_map;
570 std::map<unsigned int, SiStripDetSummary::Values> l_map;
577 for (
const auto &detId : listOfDetIds) {
587 for (
const auto &detId : listOfDetIds) {
597 for (
const auto &detId : listOfDetIds) {
607 std::cout <<
"f map size: " << f_map.size() <<
" l map size:" << l_map.size() << std::endl;
608 assert(f_map.size() == l_map.size());
629 canvas.SetBottomMargin(0.18);
630 canvas.SetLeftMargin(0.17);
631 canvas.SetRightMargin(0.05);
634 std::vector<int> boundaries;
635 unsigned int iBin = 0;
640 for (
const auto &element : f_map) {
642 int count = element.second.count;
643 double mean = (element.second.mean) /
count;
645 if (currentDetector.empty())
646 currentDetector =
"TIB";
648 switch ((element.first) / 1000) {
663 h1->SetBinContent(iBin,
mean);
665 h1->GetXaxis()->LabelsOption(
"v");
668 boundaries.push_back(iBin);
675 for (
const auto &element : l_map) {
677 int count = element.second.count;
678 double mean = (element.second.mean) /
count;
680 h2->SetBinContent(iBin,
mean);
682 h2->GetXaxis()->LabelsOption(
"v");
686 h1->GetYaxis()->SetRangeUser(0., h1->GetMaximum() * 1.30);
687 h1->SetMarkerStyle(20);
688 h1->SetMarkerSize(1.5);
693 h2->GetYaxis()->SetRangeUser(0., h2->GetMaximum() * 1.30);
694 h2->SetMarkerStyle(25);
695 h2->SetMarkerColor(kBlue);
696 h2->SetLineColor(kBlue);
697 h2->SetMarkerSize(1.5);
698 h2->Draw(
"HISTsame");
704 TLine *
l[boundaries.size()];
706 for (
const auto &
line : boundaries) {
708 l[
i]->SetLineWidth(1);
709 l[
i]->SetLineStyle(9);
710 l[
i]->SetLineColor(2);
715 TLegend *
legend =
new TLegend(0.52, 0.82, 0.95, 0.9);
717 legend->AddEntry(h1, Form(
"IOV: %i",
run_),
"PL");
721 legend->SetTextSize(0.025);
729 std::map<std::string, TH1F *> h_parts;
730 std::map<std::string, TH1F *> h_parts2;
731 std::vector<std::string>
parts = {
"TEC",
"TOB",
"TIB",
"TID"};
745 device =
"unrecognized device";
750 TString globalTitle = Form(
"%s - %s %s;%s %s;n. %s",
759 h_parts[
part]->SetTitle(
"");
762 h_parts2[
part]->SetTitle(
"");
769 for (
const auto &detId : listOfDetIds) {
778 h_parts2[
"TIB"]->Fill(
value);
780 h_parts[
"TIB"]->Fill(
value);
785 h_parts2[
"TID"]->Fill(
value);
787 h_parts[
"TID"]->Fill(
value);
792 h_parts2[
"TOB"]->Fill(
value);
794 h_parts[
"TOB"]->Fill(
value);
799 h_parts2[
"TEC"]->Fill(
value);
801 h_parts[
"TEC"]->Fill(
value);
805 edm::LogError(
"LogicError") <<
"Unknown partition: " << subid;
815 ltx.SetTextSize(0.05);
816 ltx.SetTextAlign(31);
826 h_parts[
part]->SetMinimum(1.);
827 h_parts[
part]->SetStats(
false);
828 h_parts[
part]->SetLineWidth(2);
833 float theMax = h_parts[
part]->GetMaximum();
834 h_parts[
part]->SetMaximum(theMax * 1.30);
836 h_parts[
part]->SetLineColor(kBlack);
839 h_parts2[
part]->SetMinimum(1.);
840 h_parts2[
part]->SetStats(
false);
841 h_parts2[
part]->SetLineWidth(2);
842 h_parts2[
part]->SetLineColor(kBlue);
843 h_parts2[
part]->SetFillColorAlpha(kBlue, 0.15);
845 float theMax = (h_parts[
part]->GetMaximum() > h_parts2[
part]->GetMaximum()) ? h_parts[
part]->GetMaximum()
846 : h_parts2[
part]->GetMaximum();
848 h_parts[
part]->SetMaximum(theMax * 1.30);
849 h_parts2[
part]->SetMaximum(theMax * 1.30);
852 h_parts[
part]->Draw();
854 h_parts2[
part]->Draw(
"same");
857 TLegend *leg =
new TLegend(.13, 0.81, 0.92, 0.93);
861 leg->SetHeader(
"#bf{Two Tags Difference}",
"C");
862 leg->AddEntry(h_parts[
part],
866 leg->SetHeader((
"tag: #bf{" +
tagName() +
"}").c_str(),
"C");
869 leg->SetTextSize(0.04);
874 (fmt::sprintf(
"#splitline{#mu = %.2f}{r.m.s. = %.2f}", h_parts[
part]->GetMean(), h_parts[
part]->GetRMS()))
876 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(),
877 1 - gPad->GetTopMargin() + 0.01,
881 leg->SetHeader(
"#bf{Two Tags Comparison}",
"C");
882 leg->AddEntry(h_parts[
part], (fmt::sprintf(
"%s : %i",
tagName(),
run())).c_str(),
"F");
883 leg->AddEntry(h_parts2[
part], (fmt::sprintf(
"%s : %i",
tagName2(),
run2())).c_str(),
"F");
885 leg->SetHeader((
"tag: #bf{" +
tagName() +
"}").c_str(),
"C");
886 leg->AddEntry(h_parts[
part], (fmt::sprintf(
"IOV since: %i", this->
run())).c_str(),
"F");
887 leg->AddEntry(h_parts2[
part], (fmt::sprintf(
"IOV since: %i", this->
run2())).c_str(),
"F");
889 leg->SetTextSize(0.035);
891 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(),
892 1 - gPad->GetTopMargin() + 0.01,
893 (fmt::sprintf(
"#color[2]{%s} %s Values Comparison",
part,
payloadType_)).c_str());
905 throw cms::Exception(
"Logic error") <<
"not being in compared mode, cannot plot correlations";
908 std::map<std::string, TH2F *> h2_parts;
909 std::vector<std::string>
parts = {
"TEC",
"TOB",
"TIB",
"TID"};
923 device =
"unrecognized device";
928 TString globalTitle = Form(
"%s - %s %s;%s %s (#color[4]{%s});%s %s (#color[4]{%s});n. %s",
946 for (
const auto &detId : listOfDetIds) {
965 edm::LogError(
"LogicError") <<
"Unknown partition: " << subid;
982 h2_parts[
part]->GetZaxis()->SetTitleOffset(1.6);
983 h2_parts[
part]->GetZaxis()->SetTitleSize(0.04);
984 h2_parts[
part]->GetZaxis()->CenterTitle();
985 h2_parts[
part]->GetZaxis()->SetMaxDigits(2);
991 h2_parts[
part]->Draw(
"colz");
993 TLegend *leg =
new TLegend(.13, 0.87, 0.27, 0.93);
994 leg->SetTextSize(0.045);
995 leg->SetHeader(Form(
"#bf{%s}",
part.c_str()),
"C");
1018 std::map<std::string, std::string>
units_ = {{
"SiStripPedestals",
"[ADC counts]"},
1019 {
"SiStripApvGain",
""},
1020 {
"SiStripNoises",
"[ADC counts]"},
1021 {
"SiStripLorentzAngle",
"[1/T}]"},
1022 {
"SiStripBackPlaneCorrection",
""},
1023 {
"SiStripBadStrip",
""},
1024 {
"SiStripDetVOff",
""}};
const std::string & hash() const
static constexpr auto TEC
std::map< unsigned int, Values > getCounts()
SiStripDetSummary summary
const std::string & payloadName() const
const plotType & getPlotType() const
std::string opType(SiStripPI::OpMode mode)
void setGranularity(bool isPerStrip, bool isPerAPV)
std::pair< int, const char * > regionType(int index)
TrackerTopology m_trackerTopo
void setGranularity(granularity myGranularity)
void setAdditionalIOV(const unsigned int run, const std::string &hash, const std::string &tagname)
void divide(unsigned int detid, const std::vector< type > &denominator)
std::pair< std::vector< type >, std::vector< type > > demuxedData(unsigned int detid)
std::string to_string(const V &value)
void fillValuePlot(TCanvas &canvas, const SiStripPI::OpMode &op_mode_, int nbins, float min, float max)
Log< level::Error, false > LogError
static const std::map< std::string, int > k_markermap
void setPaletteStyle(SiStripPI::palette palette)
std::shared_ptr< Item > payload_
const std::string & tagName() const
void subtract(SiStripDataContainer *dataCont2)
std::map< unsigned int, std::vector< type > > m_info
void setTitle(std::string s)
void setPayloadType(std::string myPayloadType)
void fillCorrelationByPartition(TCanvas &canvas, int nbins, float min, float max)
std::vector< unsigned int > detIds(bool verbose)
std::tuple< cond::Time_t, cond::Hash > MetaData
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
SiStripDataContainer(const std::shared_ptr< Item > &payload, const SiStripPI::MetaData &metadata, const std::string &tagname)
void setPlotType(plotType myType)
SiStripCondDataItem< type > SiStripCondData_
const SiStripPI::MetaData metaData() const
void setPalette(int numpalette)
virtual void storeAllValues()
void fillByPushBack(unsigned int detid, const type &value)
void add(DetId detid, float value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
void makeNicePlotStyle(TH1 *hist)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void fillMonitor1D(const SiStripPI::OpMode &mymode, SiStripPI::Monitor1D *&mon, SiStripPI::Entry &entry, std::vector< type > &values, const unsigned int prev_det, unsigned int &prev_apv, const unsigned int detid)
static constexpr auto TOB
std::string estimatorType(SiStripPI::estimator e)
const std::string & tagName2() const
const unsigned int run() const
virtual ~SiStripDataContainer()=default
static constexpr auto TIB
void fillByPartition(TCanvas &canvas, int nbins, float min, float max)
void fillAll(unsigned int detid, const std::vector< type > &store)
const std::string & topoMode() const
void fillSummary(TCanvas &canvas)
std::map< std::string, std::string > units_
SiStripCondDataItem< type > siStripCondData()
static const std::map< std::string, int > k_colormap
const std::string & hash2() const
virtual ~SiStripCondDataItem()=default
std::vector< type > data(unsigned int detid)
static const uint16_t STRIPS_PER_APV
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
void fillTrackerMap(TrackerMap *&tmap, std::pair< float, float > &range, const SiStripPI::estimator &est, const int nsigmas_of_saturation)
const unsigned int run2() const
Log< level::Warning, false > LogWarning
std::tuple< int, std::string, std::string > additionalIOV_
const char * plotDescriptor()
static constexpr auto TID
void compare(SiStripDataContainer *dataCont2)
void fill(int layer, int ring, int nmod, float x)
void divide(SiStripDataContainer *dataCont2)
void subtract(unsigned int detid, const std::vector< type > &subtractor)