Skip to content

Commit

Permalink
add SiPixelLorentzAngleFullMapCompare to Pixel Payload Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Jan 27, 2022
1 parent 6c99ba9 commit 6dcc84e
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace SiPixelPI {
static const unsigned int phase0size = 1440;
static const unsigned int phase1size = 1856;
static const unsigned int phase2size = 3892;
static const unsigned int mismatched = 9999;

//============================================================================
// struct to store info useful to construct topology based on the detid list
Expand Down Expand Up @@ -789,7 +790,11 @@ namespace SiPixelPI {
t2.SetTextSize(0.1);
t2.SetTextAngle(45);
t2.SetTextColor(kRed);
t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str()));
if (size != SiPixelPI::mismatched) {
t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str()));
} else {
t2.DrawLatexNDC(0.6, 0.50, "MISMATCHED PAYLOAD SIZE!");
}
}

/*--------------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,128 @@ namespace {
std::string label_;
};

/************************************************
Full Pixel Tracker Map for Comparison Base Class
*************************************************/
template <IOVMultiplicity nIOVs, int ntags>
class SiPixelLorentzAngleFullMapCompareBase : public PlotImage<SiPixelLorentzAngle, nIOVs, ntags> {
public:
SiPixelLorentzAngleFullMapCompareBase() : PlotImage<SiPixelLorentzAngle, nIOVs, ntags>("SiPixelLorentzAngle Map") {
label_ = "SiPixelLorentzAngleFullPixelMap";
payloadString = "Lorentz Angle";
}

bool fill() override {
gStyle->SetPalette(kBlueRedYellow);

// trick to deal with the multi-ioved tag and two tag case at the same time
auto theIOVs = PlotBase::getTag<0>().iovs;
auto f_tagname = PlotBase::getTag<0>().name;
std::string l_tagname = "";
auto firstiov = theIOVs.front();
std::tuple<cond::Time_t, cond::Hash> lastiov;

// we don't support (yet) comparison with more than 2 tags
assert(this->m_plotAnnotations.ntags < 3);

if (this->m_plotAnnotations.ntags == 2) {
auto tag2iovs = PlotBase::getTag<1>().iovs;
l_tagname = PlotBase::getTag<1>().name;
lastiov = tag2iovs.front();
} else {
lastiov = theIOVs.back();
}

std::shared_ptr<SiPixelLorentzAngle> last_payload = this->fetchPayload(std::get<1>(lastiov));
std::shared_ptr<SiPixelLorentzAngle> first_payload = this->fetchPayload(std::get<1>(firstiov));

if (first_payload.get() && last_payload.get()) {
// creat the base map
Phase1PixelSummaryMap fullMap("",
fmt::sprintf("%s Diff", payloadString),
fmt::sprintf("%s difference #Delta#mu_{H}/#mu_{H} [%%]", payloadString));
fullMap.createTrackerBaseMap();

std::map<uint32_t, float> l_LAMap_ = last_payload->getLorentzAngles();
std::map<uint32_t, float> f_LAMap_ = first_payload->getLorentzAngles();

std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
std::string firstIOVsince = std::to_string(std::get<0>(firstiov));

if (l_LAMap_.size() != f_LAMap_.size()) {
edm::LogError(label_) << "There are " << l_LAMap_.size() << "dets in payload" << std::get<1>(lastiov)
<< "and " << f_LAMap_.size() << " dets in payload" << std::get<1>(firstiov)
<< "display is not possible!";

TCanvas canvas("Canv", "Canv", 1200, 1000);
SiPixelPI::displayNotSupported(canvas, SiPixelPI::mismatched);
std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
return false;
}

if (l_LAMap_.size() == SiPixelPI::phase0size || l_LAMap_.size() > SiPixelPI::phase1size) {
edm::LogError(label_) << "There are " << l_LAMap_.size()
<< " DetIds in this payload. SiPixelLorentzAngleFullPixelMap maps are not supported "
"for non-Phase1 Pixel geometries !";
TCanvas canvas("Canv", "Canv", 1200, 1000);
SiPixelPI::displayNotSupported(canvas, l_LAMap_.size());
std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
return false;
} else {
if (l_LAMap_.size() < SiPixelPI::phase1size) {
edm::LogWarning(label_) << "\n ********* WARNING! ********* \n There are " << l_LAMap_.size()
<< " DetIds in this payload !"
<< "\n **************************** \n";
}
}

// fill the map
for (const auto &[id, value] : l_LAMap_) {
assert(value != 0.); // do not divide by 0
const auto &diff = (value - f_LAMap_[id]) * 100.f / value;
fullMap.fillTrackerMap(id, diff);
}

// print the map
TCanvas canvas("Canv", "Canv", 3000, 2000);
fullMap.printTrackerMap(canvas, 0.03); // is the top margin of the canvas

// take care of the legend
auto ltx = TLatex();
ltx.SetTextFont(62);
ltx.SetTextSize(0.025);
ltx.SetTextAlign(11);
std::string ltxText;
if (this->m_plotAnnotations.ntags == 2) {
ltxText = fmt::sprintf("#color[2]{%s, %s} vs #color[4]{%s, %s}",
f_tagname,
std::to_string(std::get<0>(firstiov)),
l_tagname,
std::to_string(std::get<0>(lastiov)));
} else {
ltxText = fmt::sprintf("%s IOV: #color[2]{%s} vs IOV: #color[4]{%s}",
f_tagname,
std::to_string(std::get<0>(firstiov)),
std::to_string(std::get<0>(lastiov)));
}
ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, ltxText.c_str());

std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
} // if has got the payloads
return true;
}

protected:
std::string payloadString;
std::string label_;
};

using SiPixelLorentzAngleFullMapCompareSingleTag = SiPixelLorentzAngleFullMapCompareBase<MULTI_IOV, 1>;
using SiPixelLorentzAngleFullMapCompareTwoTags = SiPixelLorentzAngleFullMapCompareBase<SINGLE_IOV, 2>;

} // namespace

PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) {
Expand All @@ -965,4 +1087,6 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) {
PAYLOAD_INSPECTOR_CLASS(SiPixelFPixLorentzAngleMap);
PAYLOAD_INSPECTOR_CLASS(SiPixelFullLorentzAngleMapByROC);
PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleFullPixelMap);
PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleFullMapCompareSingleTag);
PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleFullMapCompareTwoTags);
}
2 changes: 1 addition & 1 deletion DQM/TrackerRemapper/interface/Phase1PixelSummaryMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Phase1PixelSummaryMap {

void resetOption(const char* option);
void createTrackerBaseMap();
void printTrackerMap(TCanvas& canvas);
void printTrackerMap(TCanvas& canvas, const float topMargin = 0.02);
bool fillTrackerMap(unsigned int id, double value);

protected:
Expand Down
6 changes: 3 additions & 3 deletions DQM/TrackerRemapper/src/Phase1PixelSummaryMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ void Phase1PixelSummaryMap::createTrackerBaseMap() {
}

//============================================================================
void Phase1PixelSummaryMap::printTrackerMap(TCanvas& canvas) {
void Phase1PixelSummaryMap::printTrackerMap(TCanvas& canvas, const float topMargin) {
//canvas = TCanvas("c1","c1",plotWidth,plotHeight);
canvas.cd();
canvas.SetTopMargin(0.02);
canvas.SetTopMargin(topMargin);
canvas.SetBottomMargin(0.02);
canvas.SetLeftMargin(0.02);
canvas.SetRightMargin(0.14);
Expand Down Expand Up @@ -122,7 +122,7 @@ void Phase1PixelSummaryMap::printTrackerMap(TCanvas& canvas) {
txt.SetTextAngle(0);

//# draw new-style title
txt.SetTextSize(0.05);
txt.SetTextSize((topMargin == 0.02) ? 0.05 : 0.03);
txt.DrawLatex(0.5, 0.95, (fmt::sprintf("Pixel Tracker Map: %s", m_title)).c_str());
txt.SetTextSize(0.03);

Expand Down

0 comments on commit 6dcc84e

Please sign in to comment.