Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:42:58

0001 #include <DQM/RPCMonitorDigi/interface/RPCMonitorDigi.h>
0002 #include <DQM/RPCMonitorClient/interface/RPCBookFolderStructure.h>
0003 #include <DQM/RPCMonitorClient/interface/RPCRollMapHisto.h>
0004 #include <DQM/RPCMonitorClient/interface/RPCNameHelper.h>
0005 #include <Geometry/RPCGeometry/interface/RPCGeometry.h>
0006 
0007 void RPCMonitorDigi::bookRollME(DQMStore::IBooker& ibooker,
0008                                 const RPCDetId& detId,
0009                                 const RPCGeometry* rpcGeo,
0010                                 const std::string& recHitType,
0011                                 std::map<std::string, MonitorElement*>& meMap) {
0012   ibooker.setCurrentFolder(
0013       fmt::format("{}/{}/{}", subsystemFolder_, recHitType, RPCBookFolderStructure::folderStructure(detId)));
0014 
0015   //get number of strips in current roll
0016   int nstrips = this->stripsInRoll(detId, rpcGeo);
0017   if (nstrips == 0) {
0018     nstrips = 1;
0019   }
0020 
0021   /// Name components common to current RPCDetId
0022   const std::string nameRoll = RPCNameHelper::name(detId, useRollInfo_);
0023 
0024   if (!RPCMonitorDigi::useRollInfo_) {
0025     if (detId.region() != 0 ||                                                     //Endcaps
0026         (abs(detId.ring()) == 2 && detId.station() == 2 && detId.layer() != 1) ||  //Wheel -/+2 RB2out
0027         (abs(detId.ring()) != 2 && detId.station() == 2 && detId.layer() == 1)) {
0028       nstrips *= 3;
0029     }  //Wheel -1,0,+1 RB2in
0030     else {
0031       nstrips *= 2;
0032     }
0033   }
0034 
0035   std::string tmpStr;
0036 
0037   tmpStr = "Occupancy_" + nameRoll;
0038   meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, nstrips, 0.5, nstrips + 0.5);
0039 
0040   tmpStr = "BXDistribution_" + nameRoll;
0041   meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 7, -3.5, 3.5);
0042 
0043   if (detId.region() == 0) {
0044     tmpStr = "Multiplicity_" + nameRoll;
0045     meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 30, 0.5, 30.5);
0046 
0047   } else {
0048     tmpStr = "Multiplicity_" + nameRoll;
0049     meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 15, 0.5, 15.5);
0050   }
0051 
0052   tmpStr = "NumberOfClusters_" + nameRoll;
0053   meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 10, 0.5, 10.5);
0054 }
0055 
0056 void RPCMonitorDigi::bookSectorRingME(DQMStore::IBooker& ibooker,
0057                                       const std::string& recHitType,
0058                                       std::map<std::string, MonitorElement*>& meMap) {
0059   for (int wheel = -2; wheel <= 2; wheel++) {
0060     ibooker.setCurrentFolder(
0061         fmt::format("{}/{}/Barrel/Wheel_{}/SummaryBySectors", subsystemFolder_, recHitType, wheel));
0062 
0063     for (int sector = 1; sector <= 12; sector++) {
0064       const std::string meName = fmt::format("Occupancy_Wheel_{}_Sector_{}", wheel, sector);
0065       const std::string meClus = fmt::format("ClusterSize_Wheel_{}_Sector_{}", wheel, sector);
0066 
0067       if (sector == 9 || sector == 11) {
0068         meMap[meName] = ibooker.book2D(meName, meName, 91, 0.5, 91.5, 15, 0.5, 15.5);
0069         meMap[meClus] = ibooker.book2D(meClus, meClus, 16, 1, 17, 15, 0.5, 15.5);
0070       } else if (sector == 4) {
0071         meMap[meName] = ibooker.book2D(meName, meName, 91, 0.5, 91.5, 21, 0.5, 21.5);
0072         meMap[meClus] = ibooker.book2D(meClus, meClus, 16, 1, 17, 21, 0.5, 21.5);
0073       } else {
0074         meMap[meName] = ibooker.book2D(meName, meName, 91, 0.5, 91.5, 17, 0.5, 17.5);
0075         meMap[meClus] = ibooker.book2D(meClus, meClus, 16, 1, 17, 17, 0.5, 17.5);
0076       }
0077 
0078       meMap[meName]->setAxisTitle("strip", 1);
0079       RPCRollMapHisto::setBarrelRollAxis(meMap[meName], wheel, 2, true);
0080 
0081       meMap[meClus]->setAxisTitle("Cluster size", 1);
0082       meMap[meClus]->setBinLabel(1, "1", 1);
0083       meMap[meClus]->setBinLabel(5, "5", 1);
0084       meMap[meClus]->setBinLabel(10, "10", 1);
0085       meMap[meClus]->setBinLabel(15, "15", 1);
0086       meMap[meClus]->setBinLabel(meMap[meClus]->getNbinsX(), "Overflow", 1);
0087       RPCRollMapHisto::setBarrelRollAxis(meMap[meClus], wheel, 2, true);
0088     }
0089   }
0090 
0091   for (int region = -1; region <= 1; region++) {
0092     if (region == 0)
0093       continue;
0094 
0095     std::string regionName = "Endcap-";
0096     if (region == 1)
0097       regionName = "Endcap+";
0098 
0099     for (int disk = 1; disk <= RPCMonitorDigi::numberOfDisks_; disk++) {
0100       ibooker.setCurrentFolder(
0101           fmt::format("{}/{}/{}/Disk_{}/SummaryByRings/", subsystemFolder_, recHitType, regionName, region * disk));
0102 
0103       for (int ring = RPCMonitorDigi::numberOfInnerRings_; ring <= 3; ring++) {
0104         //Occupancy
0105         const std::string meName1 = fmt::format("Occupancy_Disk_{}_Ring_{}_CH01-CH18", (region * disk), ring);
0106 
0107         auto me1 = ibooker.book2D(meName1, meName1, 96, 0.5, 96.5, 18, 0.5, 18.5);
0108         me1->setAxisTitle("strip", 1);
0109 
0110         for (int i = 1; i <= 18; i++) {
0111           const std::string ylabel = fmt::format("R{}_CH{:02d}", ring, i);
0112           me1->setBinLabel(i, ylabel, 2);
0113         }
0114 
0115         me1->setBinLabel(1, "1", 1);
0116         me1->setBinLabel(16, "RollA", 1);
0117         me1->setBinLabel(32, "32", 1);
0118         me1->setBinLabel(33, "1", 1);
0119         me1->setBinLabel(48, "RollB", 1);
0120         me1->setBinLabel(64, "32", 1);
0121         me1->setBinLabel(65, "1", 1);
0122         me1->setBinLabel(80, "RollC", 1);
0123         me1->setBinLabel(96, "32", 1);
0124 
0125         const std::string meName2 = fmt::format("Occupancy_Disk_{}_Ring_{}_CH19-CH36", (region * disk), ring);
0126 
0127         auto me2 = ibooker.book2D(meName2, meName2, 96, 0.5, 96.5, 18, 18.5, 36.5);
0128         me2->setAxisTitle("strip", 1);
0129 
0130         for (int i = 1; i <= 18; i++) {
0131           const std::string ylabel = fmt::format("R{}_CH{:02d}", ring, i + 18);
0132           me2->setBinLabel(i, ylabel, 2);
0133         }
0134 
0135         me2->setBinLabel(1, "1", 1);
0136         me2->setBinLabel(16, "RollA", 1);
0137         me2->setBinLabel(32, "32", 1);
0138         me2->setBinLabel(33, "1", 1);
0139         me2->setBinLabel(48, "RollB", 1);
0140         me2->setBinLabel(64, "32", 1);
0141         me2->setBinLabel(65, "1", 1);
0142         me2->setBinLabel(80, "RollC", 1);
0143         me2->setBinLabel(96, "32", 1);
0144 
0145         meMap[meName1] = me1;
0146         meMap[meName2] = me2;
0147 
0148         //Cluster size
0149         const std::string meClus1 = fmt::format("ClusterSize_Disk_{}_Ring_{}_CH01-CH09", (region * disk), ring);
0150         const std::string meClus2 = fmt::format("ClusterSize_Disk_{}_Ring_{}_CH10-CH18", (region * disk), ring);
0151         const std::string meClus3 = fmt::format("ClusterSize_Disk_{}_Ring_{}_CH19-CH27", (region * disk), ring);
0152         const std::string meClus4 = fmt::format("ClusterSize_Disk_{}_Ring_{}_CH28-CH36", (region * disk), ring);
0153 
0154         auto mecl1 = ibooker.book2D(meClus1, meClus1, 11, 1, 12, 27, 0.5, 27.5);
0155         auto mecl2 = ibooker.book2D(meClus2, meClus2, 11, 1, 12, 27, 27.5, 54.5);
0156         auto mecl3 = ibooker.book2D(meClus3, meClus3, 11, 1, 12, 27, 54.5, 81.5);
0157         auto mecl4 = ibooker.book2D(meClus4, meClus4, 11, 1, 12, 27, 81.5, 108.5);
0158 
0159         std::array<MonitorElement*, 4> meCls = {{mecl1, mecl2, mecl3, mecl4}};
0160 
0161         for (unsigned int icl = 0; icl < meCls.size(); icl++) {
0162           meCls[icl]->setAxisTitle("Cluster size", 1);
0163 
0164           for (int i = 1; i <= 9; i++) {
0165             const std::string ylabel1 = fmt::format("R{}_CH{:02d}_C", ring, (icl * 9) + i);
0166             const std::string ylabel2 = fmt::format("R{}_CH{:02d}_B", ring, (icl * 9) + i);
0167             const std::string ylabel3 = fmt::format("R{}_CH{:02d}_A", ring, (icl * 9) + i);
0168             meCls[icl]->setBinLabel(1 + (i - 1) * 3, ylabel1, 2);
0169             meCls[icl]->setBinLabel(2 + (i - 1) * 3, ylabel2, 2);
0170             meCls[icl]->setBinLabel(3 + (i - 1) * 3, ylabel3, 2);
0171           }
0172           meCls[icl]->setBinLabel(1, "1", 1);
0173           meCls[icl]->setBinLabel(5, "5", 1);
0174           meCls[icl]->setBinLabel(10, "10", 1);
0175           meCls[icl]->setBinLabel(mecl1->getNbinsX(), "Overflow", 1);
0176         }
0177 
0178         meMap[meClus1] = mecl1;
0179         meMap[meClus2] = mecl2;
0180         meMap[meClus3] = mecl3;
0181         meMap[meClus4] = mecl4;
0182       }  //loop ring
0183     }    //loop disk
0184   }      //loop region
0185 }
0186 
0187 void RPCMonitorDigi::bookWheelDiskME(DQMStore::IBooker& ibooker,
0188                                      const std::string& recHitType,
0189                                      std::map<std::string, MonitorElement*>& meMap) {
0190   ibooker.setCurrentFolder(subsystemFolder_ + "/" + recHitType + "/" + globalFolder_);
0191 
0192   std::string tmpStr;
0193 
0194   for (int wheel = -2; wheel <= 2; wheel++) {  //Loop on wheel
0195     tmpStr = fmt::format("1DOccupancy_Wheel_{}", wheel);
0196     meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 12, 0.5, 12.5);
0197     for (int i = 1; i <= 12; ++i) {
0198       meMap[tmpStr]->setBinLabel(i, fmt::format("Sec{}", i), 1);
0199     }
0200 
0201     tmpStr = fmt::format("Occupancy_Roll_vs_Sector_Wheel_{}", wheel);
0202     meMap[tmpStr] = RPCRollMapHisto::bookBarrel(ibooker, wheel, tmpStr, tmpStr, true);
0203 
0204     tmpStr = fmt::format("BxDistribution_Wheel_{}", wheel);
0205     meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 9, -4.5, 4.5);
0206 
0207   }  //end loop on wheel
0208 
0209   for (int disk = -RPCMonitorDigi::numberOfDisks_; disk <= RPCMonitorDigi::numberOfDisks_; disk++) {
0210     if (disk == 0)
0211       continue;
0212 
0213     tmpStr = fmt::format("Occupancy_Ring_vs_Segment_Disk_{}", disk);
0214     meMap[tmpStr] = RPCRollMapHisto::bookEndcap(ibooker, disk, tmpStr, tmpStr, true);
0215 
0216     tmpStr = fmt::format("BxDistribution_Disk_{}", disk);
0217     meMap[tmpStr] = ibooker.book1D(tmpStr, tmpStr, 9, -4.5, 4.5);
0218   }
0219 
0220   for (int ring = RPCMonitorDigi::numberOfInnerRings_; ring <= 3; ring++) {
0221     const std::string meName = fmt::format("1DOccupancy_Ring_{}", ring);
0222     meMap[meName] = ibooker.book1D(
0223         meName, meName, RPCMonitorDigi::numberOfDisks_ * 2, 0.5, (RPCMonitorDigi::numberOfDisks_ * 2.0) + 0.5);
0224     for (int xbin = 1; xbin <= RPCMonitorDigi::numberOfDisks_ * 2; xbin++) {
0225       std::string label;
0226       if (xbin < RPCMonitorDigi::numberOfDisks_ + 1)
0227         label = fmt::format("Disk {}", (xbin - (RPCMonitorDigi::numberOfDisks_ + 1)));
0228       else
0229         label = fmt::format("Disk {}", (xbin - RPCMonitorDigi::numberOfDisks_));
0230       meMap[meName]->setBinLabel(xbin, label, 1);
0231     }
0232   }
0233 }
0234 
0235 //returns the number of strips in each roll
0236 int RPCMonitorDigi::stripsInRoll(const RPCDetId& id, const RPCGeometry* rpcGeo) const {
0237   const RPCRoll* rpcRoll = rpcGeo->roll(id);
0238   if (!rpcRoll)
0239     return 1;
0240 
0241   return rpcRoll->nstrips();
0242 }
0243 
0244 void RPCMonitorDigi::bookRegionME(DQMStore::IBooker& ibooker,
0245                                   const std::string& recHitType,
0246                                   std::map<std::string, MonitorElement*>& meMap) {
0247   std::string currentFolder = subsystemFolder_ + "/" + recHitType + "/" + globalFolder_;
0248   ibooker.setCurrentFolder(currentFolder);
0249 
0250   std::stringstream name;
0251   std::stringstream title;
0252 
0253   //Number of Digis
0254   name.str("");
0255   title.str("");
0256   name << "Multiplicity_Barrel";
0257   title << "Multiplicity per Event per Roll - Barrel";
0258   meMap[name.str()] = ibooker.book1D(name.str(), title.str(), 50, 0.5, 50.5);
0259 
0260   name.str("");
0261   title.str("");
0262   name << "Multiplicity_Endcap+";
0263   title << "Multiplicity per Event per Roll - Endcap+";
0264   meMap[name.str()] = ibooker.book1D(name.str(), title.str(), 32, 0.5, 32.5);
0265 
0266   name.str("");
0267   title.str("");
0268   name << "Multiplicity_Endcap-";
0269   title << "Multiplicity per Event per Roll - Endcap-";
0270   meMap[name.str()] = ibooker.book1D(name.str(), title.str(), 32, 0.5, 32.5);
0271 
0272   meMap["Occupancy_for_Endcap"] = ibooker.book2D("Occupancy_for_Endcap",
0273                                                  "Occupancy Endcap",
0274                                                  (int)RPCMonitorDigi::numberOfDisks_ * 2.0,
0275                                                  0.5,
0276                                                  ((float)RPCMonitorDigi::numberOfDisks_ * 2.0) + 0.5,
0277                                                  2,
0278                                                  1.5,
0279                                                  3.5);
0280   meMap["Occupancy_for_Endcap"]->setAxisTitle("Disk", 1);
0281   meMap["Occupancy_for_Endcap"]->setAxisTitle("Ring", 2);
0282 
0283   std::stringstream binlabel;
0284   for (int bin = 1; bin <= RPCMonitorDigi::numberOfDisks_ * 2; bin++) {
0285     binlabel.str("");
0286     if (bin < (RPCMonitorDigi::numberOfDisks_ + 1)) {  //negative endcap
0287       binlabel << (bin - (RPCMonitorDigi::numberOfDisks_ + 1));
0288     } else {  //positive endcaps
0289       binlabel << (bin - RPCMonitorDigi::numberOfDisks_);
0290     }
0291     meMap["Occupancy_for_Endcap"]->setBinLabel(bin, binlabel.str(), 1);
0292   }
0293 
0294   meMap["Occupancy_for_Endcap"]->setBinLabel(1, "2", 2);
0295   meMap["Occupancy_for_Endcap"]->setBinLabel(2, "3", 2);
0296 
0297   meMap["Occupancy_for_Barrel"] =
0298       ibooker.book2D("Occupancy_for_Barrel", "Occupancy Barrel", 12, 0.5, 12.5, 5, -2.5, 2.5);
0299   meMap["Occupancy_for_Barrel"]->setAxisTitle("Sec", 1);
0300   meMap["Occupancy_for_Barrel"]->setAxisTitle("Wheel", 2);
0301 
0302   for (int bin = 1; bin <= 12; bin++) {
0303     binlabel.str("");
0304     binlabel << bin;
0305     meMap["Occupancy_for_Barrel"]->setBinLabel(bin, binlabel.str(), 1);
0306     if (bin <= 5) {
0307       binlabel.str("");
0308       binlabel << (bin - 3);
0309       meMap["Occupancy_for_Barrel"]->setBinLabel(bin, binlabel.str(), 2);
0310     }
0311   }
0312 }