5 #include <fmt/printf.h> 25 #include "TPaveStats.h" 47 enum type { t_LV = 0, t_HV = 1, t_V };
53 template <SiStripDetVOffPI::type my_type>
54 class SiStripDetVOff_TrackerMapBase :
public PlotImage<SiStripDetVOff, SINGLE_IOV> {
58 bool fill()
override {
59 auto tag = PlotBase::getTag<0>();
60 auto iov =
tag.iovs.front();
62 unsigned long IOVsince = std::get<0>(iov);
63 std::shared_ptr<SiStripDetVOff>
payload = fetchPayload(std::get<1>(iov));
65 std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>(
"SiStripIsModuleVOff");
70 case SiStripDetVOffPI::t_LV: {
71 titleMap = fmt::sprintf(
"TrackerMap of LV VOff modules | Tag: %s | IOV: %s",
tagname, getIOVsince(IOVsince));
74 case SiStripDetVOffPI::t_HV: {
75 titleMap = fmt::sprintf(
"TrackerMap of HV VOff modules | Tag: %s | IOV: %s",
tagname, getIOVsince(IOVsince));
78 case SiStripDetVOffPI::t_V: {
80 fmt::sprintf(
"TrackerMap of VOff modules (HV or LV) | Tag: %s | IOV: %s",
tagname, getIOVsince(IOVsince));
84 edm::LogError(
"SiStripDetVOff_IsModuleVOff_TrackerMap") <<
"Unrecognized type: " << my_type << std::endl;
88 tmap->setTitle(titleMap);
90 std::vector<uint32_t> detid;
93 for (
const auto&
d : detid) {
94 if ((
payload->IsModuleLVOff(
d) && (my_type == SiStripDetVOffPI::t_LV)) ||
95 (
payload->IsModuleHVOff(
d) && (my_type == SiStripDetVOffPI::t_HV)) ||
96 (
payload->IsModuleVOff(
d) && (my_type == SiStripDetVOffPI::t_V))) {
103 tmap->save(
true, 0., 1.01,
fileName);
109 const char* getIOVsince(
const unsigned long IOV) {
111 static char buf[256];
113 if (IOV < 4294967296) {
115 std::sprintf(
buf,
"%d",
run);
120 localtime_r(&
t, <);
121 strftime(
buf,
sizeof(
buf),
"%F %R:%S", <);
128 using SiStripDetVOff_IsModuleVOff_TrackerMap = SiStripDetVOff_TrackerMapBase<SiStripDetVOffPI::t_V>;
129 using SiStripDetVOff_IsModuleLVOff_TrackerMap = SiStripDetVOff_TrackerMapBase<SiStripDetVOffPI::t_LV>;
130 using SiStripDetVOff_IsModuleHVOff_TrackerMap = SiStripDetVOff_TrackerMapBase<SiStripDetVOffPI::t_HV>;
135 template <SiStripDetVOffPI::type my_type>
136 class SiStripDetVOffListOfModules :
public Histogram1DD<SiStripDetVOff, SINGLE_IOV> {
138 SiStripDetVOffListOfModules()
140 "SiStrip Off modules",
"SiStrip Off modules", 15148, 0., 15148.,
"DetId of VOff module") {}
142 bool fill()
override {
143 auto tag = PlotBase::getTag<0>();
144 for (
auto const& iov :
tag.iovs) {
145 std::shared_ptr<SiStripDetVOff>
payload = Base::fetchPayload(std::get<1>(iov));
147 std::vector<uint32_t> detid;
153 for (
const auto&
d : detid) {
155 case SiStripDetVOffPI::t_LV: {
158 fillWithBinAndValue(
i,
double(
d));
162 case SiStripDetVOffPI::t_HV: {
165 fillWithBinAndValue(
i,
double(
d));
169 case SiStripDetVOffPI::t_V: {
172 fillWithBinAndValue(
i,
double(
d));
177 edm::LogError(
"SiStripDetVOffListOfModules") <<
"Unrecognized type: " << my_type << std::endl;
188 using SiStripVOffListOfModules = SiStripDetVOffListOfModules<SiStripDetVOffPI::t_V>;
189 using SiStripLVOffListOfModules = SiStripDetVOffListOfModules<SiStripDetVOffPI::t_LV>;
190 using SiStripHVOffListOfModules = SiStripDetVOffListOfModules<SiStripDetVOffPI::t_HV>;
196 class SiStripDetVOffTest :
public Histogram1D<SiStripDetVOff, SINGLE_IOV> {
203 bool fill()
override {
204 auto tag = PlotBase::getTag<0>();
205 for (
auto const& iov :
tag.iovs) {
206 std::shared_ptr<SiStripDetVOff>
payload = Base::fetchPayload(std::get<1>(iov));
208 std::vector<uint32_t> detid;
214 for (
const auto&
d : detid) {
220 std::map<unsigned int, SiStripDetSummary::Values> mapHV = summaryHV.getCounts();
221 std::map<unsigned int, SiStripDetSummary::Values> mapLV = summaryLV.getCounts();
226 std::stringstream
ss;
227 ss <<
"Summary of HV off detectors:" << std::endl;
228 summaryHV.print(
ss,
true);
230 ss <<
"Summary of LV off detectors:" << std::endl;
231 summaryLV.print(
ss,
true);
247 class SiStripDetVOffByRegion :
public PlotImage<SiStripDetVOff, SINGLE_IOV> {
249 SiStripDetVOffByRegion()
254 bool fill()
override {
255 auto tag = PlotBase::getTag<0>();
256 auto iov =
tag.iovs.front();
257 std::shared_ptr<SiStripDetVOff>
payload = fetchPayload(std::get<1>(iov));
259 unsigned long IOV = std::get<0>(iov);
261 if (IOV < 4294967296) {
262 run = std::get<0>(iov);
267 std::vector<uint32_t> detid;
273 for (
const auto&
d : detid) {
279 std::map<unsigned int, SiStripDetSummary::Values> mapHV = summaryHV.getCounts();
280 std::map<unsigned int, SiStripDetSummary::Values> mapLV = summaryLV.getCounts();
281 std::vector<unsigned int>
keys;
285 std::back_inserter(
keys),
290 TCanvas
canvas(
"DetVOff Partion summary",
"SiStripDetVOff region summary", 1200, 1000);
292 auto h_HV = std::make_unique<TH1F>(
293 "HVbyRegion",
"SiStrip HV/LV summary by region;; modules with HV off", mapHV.size(), 0., mapHV.size());
294 auto h_LV = std::make_unique<TH1F>(
295 "LVbyRegion",
"SiStrip HV/LV summary by region;; modules with LV off", mapLV.size(), 0., mapLV.size());
297 h_HV->SetStats(
false);
298 h_LV->SetStats(
false);
300 h_HV->SetTitle(
nullptr);
301 h_LV->SetTitle(
nullptr);
303 canvas.SetBottomMargin(0.18);
304 canvas.SetLeftMargin(0.10);
305 canvas.SetRightMargin(0.10);
308 std::vector<int> boundaries;
309 unsigned int iBin = 0;
316 int countHV = mapHV[
index].count;
317 int countLV = mapLV[
index].count;
319 if (currentDetector.empty())
320 currentDetector =
"TIB";
322 switch ((
index) / 1000) {
337 h_HV->SetBinContent(iBin, countHV);
339 h_HV->GetXaxis()->LabelsOption(
"v");
341 h_LV->SetBinContent(iBin, countLV);
343 h_LV->GetXaxis()->LabelsOption(
"v");
346 boundaries.push_back(iBin);
352 h_HV->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
353 h_LV->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
355 h_HV->SetMarkerStyle(20);
356 h_HV->SetMarkerSize(1);
357 h_HV->SetLineColor(kRed);
358 h_HV->SetMarkerColor(kRed);
360 h_HV->Draw(
"TEXT45same");
362 h_LV->SetMarkerStyle(21);
363 h_LV->SetMarkerSize(1);
364 h_LV->SetLineColor(kBlue);
365 h_LV->SetLineStyle(9);
366 h_LV->SetMarkerColor(kBlue);
367 h_LV->Draw(
"HISTsame");
368 h_LV->Draw(
"TEXT45same");
373 TLine
l[boundaries.size()];
375 for (
const auto&
line : boundaries) {
377 h_HV->GetBinLowEdge(
line),
canvas.cd()->GetUymin(), h_HV->GetBinLowEdge(
line),
canvas.cd()->GetUymax());
378 l[
i].SetLineWidth(1);
379 l[
i].SetLineStyle(9);
380 l[
i].SetLineColor(2);
385 TLegend
legend = TLegend(0.45, 0.80, 0.90, 0.9);
386 legend.SetHeader((std::get<1>(iov)).c_str(),
"C");
389 legend.SetTextSize(0.025);
395 t1.SetTextSize(0.05);
396 if (IOV < 4294967296)
397 t1.DrawLatex(0.5, 0.96, Form(
"SiStrip DetVOff, IOV %i",
run));
402 localtime_r(&
t, <);
403 strftime(
buf,
sizeof(
buf),
"%F %R:%S", <);
405 t1.DrawLatex(0.5, 0.96, Form(
"SiStrip DetVOff, IOV %s",
buf));
409 h_HV.get()->GetYaxis()->SetLabelOffset(999);
410 h_HV.get()->GetYaxis()->SetTickLength(0);
411 h_HV.get()->GetYaxis()->SetTitleOffset(999);
413 h_LV.get()->GetYaxis()->SetLabelOffset(999);
414 h_LV.get()->GetYaxis()->SetTickLength(0);
415 h_LV.get()->GetYaxis()->SetTitleOffset(999);
418 auto l_axis = std::make_unique<TGaxis>(
419 gPad->GetUxmin(), gPad->GetUymin(), gPad->GetUxmin(), gPad->GetUymax(), 0, extrema.second, 510);
420 l_axis->SetLineColor(kRed);
421 l_axis->SetTextColor(kRed);
422 l_axis->SetLabelColor(kRed);
423 l_axis->SetTitleOffset(1.2);
424 l_axis->SetTitleColor(kRed);
425 l_axis->SetTitle(h_HV.get()->GetYaxis()->GetTitle());
429 auto r_axis = std::make_unique<TGaxis>(
430 gPad->GetUxmax(), gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax(), 0, extrema.second, 510,
"+L");
431 r_axis->SetLineColor(kBlue);
432 r_axis->SetTextColor(kBlue);
433 r_axis->SetLabelColor(kBlue);
434 r_axis->SetTitleColor(kBlue);
435 r_axis->SetTitleOffset(1.2);
436 r_axis->SetTitle(h_LV.get()->GetYaxis()->GetTitle());
std::pair< int, const char * > regionType(int index)
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
U second(std::pair< T, U > const &p)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
Container::value_type value_type
void add(DetId detid, float value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)