Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-31 22:35:52

0001 #include "DQM/RPCMonitorClient/interface/RPCRollMapHisto.h"
0002 #include <fmt/format.h>
0003 
0004 typedef dqm::reco::MonitorElement MonitorElement;
0005 //typedef DQMEDHarvester::MonitorElement MonitorElement;
0006 typedef dqm::reco::DQMStore::IBooker IBooker;
0007 
0008 MonitorElement* RPCRollMapHisto::bookBarrel(
0009     IBooker& booker, const int wheel, const std::string& name, const std::string& title, const bool useRollInfo) {
0010   MonitorElement* me = booker.book2D(name, title, 12, 0.5, 12.5, 21, 0.5, 21.5);
0011 
0012   TH2* h = dynamic_cast<TH2*>(me->getTH1());
0013   h->GetXaxis()->SetNoAlphanumeric(true);
0014   // Set x-axis labels
0015   for (int i = 1; i <= 12; ++i) {
0016     me->setBinLabel(i, fmt::format("Sec{}", i), 1);
0017   }
0018 
0019   // Set y-axis labels
0020   RPCRollMapHisto::setBarrelRollAxis(me, wheel, 2, useRollInfo);
0021 
0022   return me;
0023 }
0024 
0025 void RPCRollMapHisto::setBarrelRollAxis(MonitorElement* me, const int wheel, const int axis, const bool useRollInfo) {
0026   TH1* h = dynamic_cast<TH1*>(me->getTH1());
0027   if (axis == 1)
0028     h->GetXaxis()->SetNoAlphanumeric(true);
0029   else if (axis == 2)
0030     h->GetYaxis()->SetNoAlphanumeric(true);
0031 
0032   const std::array<const std::string, 21> labelsRoll = {
0033       {"RB1in_B",  "RB1in_F",  "RB1out_B", "RB1out_F", "RB2in_B", "RB2in_F", "RB2in_M",
0034        "RB2out_B", "RB2out_F", "RB3-_B",   "RB3-_F",   "RB3+_B",  "RB3+_F",  "RB4,-_B",
0035        "RB4,-_F",  "RB4+_B",   "RB4+_F",   "RB4--_B",  "RB4--_F", "RB4++_B", "RB4++_F"}};
0036   const std::array<const std::string, 21> labelsCh = {{"RB1in",  "",     "RB1out", "",      "RB2in", "",      "",
0037                                                        "RB2out", "",     "RB3-",   "",      "RB3+",  "",      "RB4,-",
0038                                                        "",       "RB4+", "",       "RB4--", "",      "RB4++", ""}};
0039 
0040   for (int i = 0, n = std::min(21, me->getNbinsY()); i < n; ++i) {
0041     const std::string label = useRollInfo ? labelsRoll[i] : labelsCh[i];
0042     me->setBinLabel(i + 1, label, 2);
0043   }
0044   if (useRollInfo and std::abs(wheel) == 2) {
0045     // We have RB2out_M for the wheel +-2, otherwise, RB2in_M as in the default array
0046     me->setBinLabel(7, "RB2out_M", 2);
0047   }
0048 }
0049 
0050 void RPCRollMapHisto::setEndcapRollAxis(MonitorElement* me, const int disk, const int axis, const bool useRollInfo) {
0051   TH1* h = dynamic_cast<TH1*>(me->getTH1());
0052   if (axis == 1)
0053     h->GetXaxis()->SetNoAlphanumeric(true);
0054   else if (axis == 2)
0055     h->GetYaxis()->SetNoAlphanumeric(true);
0056 
0057   // NOTE: Let us keep only Ring2 and Ring3 for the Run3
0058   //       There will be Ring1, RE3/1 and RE4/1 only from the phase-2
0059   const std::array<const std::string, 6> labelsRoll = {{//"C", "Ring1 B", "A",
0060                                                         "C",
0061                                                         "Ring2 B",
0062                                                         "A",
0063                                                         "C",
0064                                                         "Ring3 B",
0065                                                         "A"}};
0066   const std::array<const std::string, 6> labelsCh = {{//"", "Ring1", "",
0067                                                       "",
0068                                                       "Ring2",
0069                                                       "",
0070                                                       "",
0071                                                       "Ring3",
0072                                                       ""}};
0073 
0074   //const int offset = std::abs(disk) >= 3 ? 0 : 3;
0075   for (int i = 0; i < 6; ++i) {
0076     const std::string label = useRollInfo ? labelsRoll[i] : labelsCh[i];
0077     me->setBinLabel(i + 1, label, 2);
0078   }
0079 }
0080 
0081 MonitorElement* RPCRollMapHisto::bookEndcap(
0082     IBooker& booker, const int disk, const std::string& name, const std::string& title, const bool useRollInfo) {
0083   MonitorElement* me = booker.book2D(name, title, 36, 0.5, 36.5, 6, 0.5, 6.5);
0084   TH2* h = dynamic_cast<TH2*>(me->getTH1());
0085   h->GetXaxis()->SetNoAlphanumeric(true);
0086   h->GetYaxis()->SetNoAlphanumeric(true);
0087 
0088   // Set x-axis labels
0089   for (int i = 1; i <= 36; ++i) {
0090     me->setBinLabel(i, fmt::format("{}", i), 1);
0091   }
0092   me->setAxisTitle("Segments", 1);
0093 
0094   RPCRollMapHisto::setEndcapRollAxis(me, disk, 2, useRollInfo);
0095 
0096   return me;
0097 }