Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:55

0001 #include "DQM/SiStripMonitorSummary/interface/SiStripCablingDQM.h"
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0004 #include "TCanvas.h"
0005 
0006 SiStripCablingDQM::SiStripCablingDQM(edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> token,
0007                                      edm::RunNumber_t iRun,
0008                                      edm::ParameterSet const &hPSet,
0009                                      edm::ParameterSet const &fPSet,
0010                                      const TrackerTopology *tTopo,
0011                                      const TkDetMap *tkDetMap)
0012     : SiStripBaseCondObjDQMGet<SiStripDetCabling, SiStripDetCablingRcd>{token, iRun, hPSet, fPSet, tTopo} {
0013   if (HistoMaps_On_) {
0014     Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "Cabling_TkMap", 0.);
0015   }
0016 }
0017 
0018 SiStripCablingDQM::~SiStripCablingDQM() {}
0019 
0020 void SiStripCablingDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
0021   // Get active and total detIds
0022   getConditionObject(eSetup);
0023   if (!condObj_) {
0024     edm::LogError("InvalidCablingHandle") << "Invalid Cabling Handle";
0025     return;
0026   }
0027   condObj_->addActiveDetectorsRawIds(activeDetIds);
0028   condObj_->addAllDetectorsRawIds(activeDetIds);
0029 
0030   // Initialize arrays for counting:
0031   int counterTIB[4];
0032   for (int i = 0; i < 4; i++)
0033     counterTIB[i] = 0;
0034   int counterTID[2][3];
0035   for (int i = 0; i < 2; i++) {
0036     for (int j = 0; j < 3; j++)
0037       counterTID[i][j] = 0;
0038   }
0039   int counterTOB[6];
0040   for (int i = 0; i < 6; i++)
0041     counterTOB[i] = 0;
0042   int counterTEC[2][9];
0043   for (int i = 0; i < 2; i++) {
0044     for (int j = 0; j < 9; j++)
0045       counterTEC[i][j] = 0;
0046   }
0047 
0048   // fill arrays for counting and fill Histo_Map with value for connected :
0049   for (const auto detId : activeDetIds) {
0050     StripSubdetector subdet(detId);
0051 
0052     if (HistoMaps_On_) {
0053       Tk_HM_->fill(detId, condObj_->nApvPairs(detId) * 2);
0054     }
0055     if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
0056       int32_t n_conn = 0;
0057       for (uint32_t connDet_i = 0; connDet_i < condObj_->getConnections(detId).size(); connDet_i++) {
0058         if (condObj_->getConnections(detId)[connDet_i] != nullptr &&
0059             condObj_->getConnections(detId)[connDet_i]->isConnected() != 0)
0060           n_conn++;
0061       }
0062       fillTkMap(detId, n_conn * 2.);
0063     }
0064     switch (subdet.subdetId()) {
0065       case StripSubdetector::TIB: {
0066         int i = tTopo_->tibLayer(detId) - 1;
0067         counterTIB[i]++;
0068         break;
0069       }
0070       case StripSubdetector::TID: {
0071         int j = tTopo_->tidWheel(detId) - 1;
0072         int side = tTopo_->tidSide(detId);
0073         if (side == 2) {
0074           counterTID[0][j]++;
0075         } else if (side == 1) {
0076           counterTID[1][j]++;
0077         }
0078         break;
0079       }
0080       case StripSubdetector::TOB: {
0081         int i = tTopo_->tobLayer(detId) - 1;
0082         counterTOB[i]++;
0083         break;
0084       }
0085       case StripSubdetector::TEC: {
0086         int j = tTopo_->tecWheel(detId) - 1;
0087         int side = tTopo_->tecSide(detId);
0088         if (side == 2) {
0089           counterTEC[0][j]++;
0090         } else if (side == 1) {
0091           counterTEC[1][j]++;
0092         }
0093         break;
0094       }
0095     }
0096 
0097   }  // idet
0098 
0099   // obtained from tracker.dat and hard-coded
0100   int TIBDetIds[4] = {672, 864, 540, 648};
0101   int TIDDetIds[2][3] = {{136, 136, 136}, {136, 136, 136}};
0102   int TOBDetIds[6] = {1008, 1152, 648, 720, 792, 888};
0103   int TECDetIds[2][9] = {{408, 408, 408, 360, 360, 360, 312, 312, 272}, {408, 408, 408, 360, 360, 360, 312, 312, 272}};
0104 
0105   DQMStore *dqmStore_ = edm::Service<DQMStore>().operator->();
0106 
0107   std::string FolderName = fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
0108 
0109   dqmStore_->setCurrentFolder(FolderName);
0110 
0111   //  dqmStore_->cd("SiStrip/MechanicalView/");
0112   MonitorElement *ME;
0113   ME = dqmStore_->book2D("SummaryOfCabling", "SummaryOfCabling", 6, 0.5, 6.5, 9, 0.5, 9.5);
0114   ME->setAxisTitle("Sub Det", 1);
0115   ME->setAxisTitle("Layer", 2);
0116 
0117   ME->setBinLabel(1, "TIB");
0118   ME->setBinLabel(2, "TID F");
0119   ME->setBinLabel(3, "TID B");
0120   ME->setBinLabel(4, "TOB");
0121   ME->setBinLabel(5, "TEC F");
0122   ME->setBinLabel(6, "TEC B");
0123 
0124   for (int i = 0; i < 4; i++) {
0125     ME->Fill(1, i + 1, float(counterTIB[i]) / TIBDetIds[i]);
0126   }
0127 
0128   for (int i = 0; i < 2; i++) {
0129     for (int j = 0; j < 3; j++) {
0130       ME->Fill(i + 2, j + 1, float(counterTID[i][j]) / TIDDetIds[i][j]);
0131     }
0132   }
0133 
0134   for (int i = 0; i < 6; i++) {
0135     ME->Fill(4, i + 1, float(counterTOB[i]) / TOBDetIds[i]);
0136   }
0137 
0138   for (int i = 0; i < 2; i++) {
0139     for (int j = 0; j < 9; j++) {
0140       ME->Fill(i + 5, j + 1, float(counterTEC[i][j]) / TECDetIds[i][j]);
0141     }
0142   }
0143 
0144   if (fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
0145     TCanvas c1("c1");
0146     ME->getTH1()->Draw("TEXT");
0147     ME->getTH1()->SetStats(kFALSE);
0148     std::string name(ME->getTitle());
0149     name += ".png";
0150     c1.Print(name.c_str());
0151   }
0152 }