File indexing completed on 2025-05-15 02:27:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <fstream>
0010 #include <iostream>
0011
0012
0013 #include "TNamed.h"
0014 #include "TMath.h"
0015
0016
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 #include "FWCore/ServiceRegistry/interface/Service.h"
0020 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0021 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0022 #include "DataFormats/Common/interface/DetSetNew.h"
0023 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0024 #include "DataFormats/Common/interface/DetSetVector.h"
0025 #include "DataFormats/Common/interface/Handle.h"
0026 #include "DataFormats/TrackerCommon/interface/SiStripSubStructure.h"
0027 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0028 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0029 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
0030 #include "DQM/SiStripMonitorDigi/interface/SiStripMonitorDigi.h"
0031 #include "DQMServices/Core/interface/DQMStore.h"
0032 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
0033 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
0034 #include "CalibTracker/SiStripCommon/interface/SiStripDCSStatus.h"
0035 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0036 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0037 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0038 #include "DataFormats/Scalers/interface/DcsStatus.h"
0039 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0040 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
0041 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0042 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0043
0044
0045 namespace {
0046 const double NORBITS_PER_LS = 262144.;
0047 }
0048
0049
0050 SiStripMonitorDigi::SiStripMonitorDigi(const edm::ParameterSet& iConfig)
0051 :
0052 conf_(iConfig),
0053 show_mechanical_structure_view(true),
0054 show_readout_view(false),
0055 show_control_view(false),
0056 select_all_detectors(true),
0057 reset_each_run(false),
0058 folder_organizer(),
0059 m_cacheID_(0) {
0060 firstEvent = -1;
0061 eventNb = 0;
0062
0063
0064 SubDetPhasePartMap["TIB"] = "TI";
0065 SubDetPhasePartMap["TID__MINUS"] = "TI";
0066 SubDetPhasePartMap["TID__PLUS"] = "TI";
0067 SubDetPhasePartMap["TOB"] = "TO";
0068 SubDetPhasePartMap["TEC__MINUS"] = "TM";
0069 SubDetPhasePartMap["TEC__PLUS"] = "TP";
0070
0071 topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0072
0073
0074 digiProducerList = conf_.getParameter<std::vector<edm::InputTag> >("DigiProducersList");
0075 for (auto const& tag : digiProducerList) {
0076 digiProducerTokenList.push_back(consumes<edm::DetSetVector<SiStripDigi> >(tag));
0077 }
0078
0079
0080 edm::ParameterSet ParametersNumberOfDigis = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigis");
0081 layerswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("layerswitchon");
0082 moduleswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("moduleswitchon");
0083
0084 edm::ParameterSet ParametersNumberOfDigisPerStrip = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigisPerStrip");
0085 moduleswitchnumdigispstripon = ParametersNumberOfDigisPerStrip.getParameter<bool>("moduleswitchon");
0086
0087 edm::ParameterSet ParametersADCsHottestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsHottestStrip");
0088 layerswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("layerswitchon");
0089 moduleswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("moduleswitchon");
0090
0091 edm::ParameterSet ParametersADCsCoolestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsCoolestStrip");
0092 layerswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("layerswitchon");
0093 moduleswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("moduleswitchon");
0094
0095 edm::ParameterSet ParametersDigiADCs = conf_.getParameter<edm::ParameterSet>("TH1DigiADCs");
0096 layerswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("layerswitchon");
0097 moduleswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("moduleswitchon");
0098
0099 edm::ParameterSet ParametersStripOccupancy = conf_.getParameter<edm::ParameterSet>("TH1StripOccupancy");
0100 layerswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("layerswitchon");
0101 moduleswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("moduleswitchon");
0102
0103 edm::ParameterSet ParametersDigiProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfDigi");
0104 layerswitchnumdigisprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
0105
0106 edm::ParameterSet ParametersDigiADC = conf_.getParameter<edm::ParameterSet>("TProfDigiADC");
0107 layerswitchdigiadcprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
0108
0109 edm::ParameterSet ParametersTotDigiProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
0110 subdetswitchtotdigiprofon = ParametersTotDigiProf.getParameter<bool>("subdetswitchon");
0111
0112 edm::ParameterSet ParametersTotDigiFailure = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
0113 subdetswitchtotdigifailureon = ParametersTotDigiFailure.getParameter<bool>("subdetswitchon");
0114
0115 edm::ParameterSet ParametersDigiApvProf = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
0116 subdetswitchapvcycleprofon = ParametersDigiApvProf.getParameter<bool>("subdetswitchon");
0117
0118 edm::ParameterSet ParametersDigiApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
0119 subdetswitchapvcycleth2on = ParametersDigiApvTH2.getParameter<bool>("subdetswitchon");
0120
0121 edm::ParameterSet ParametersNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
0122 subdetswitchnapvshotson = ParametersNApvShots.getParameter<bool>("subdetswitchon");
0123
0124 edm::ParameterSet ParametersNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
0125 subdetswitchnstripsapvshotson = ParametersNStripApvShots.getParameter<bool>("subdetswitchon");
0126
0127 edm::ParameterSet ParametersChargeMedianApvShots = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
0128 subdetswitchchargemedianapvshotson = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
0129
0130 edm::ParameterSet ParametersApvNumberApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
0131 subdetswitchapvshotsApvon = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
0132
0133 edm::ParameterSet ParametersNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
0134 subdetswitchapvshotsonprof = ParametersNApvShotsProf.getParameter<bool>("subdetswitchon");
0135
0136
0137
0138 edm::ParameterSet ParametersGlobalNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
0139 globalswitchnapvshotson = ParametersGlobalNApvShots.getParameter<bool>("globalswitchon");
0140
0141 edm::ParameterSet ParametersGlobalNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfGlobalNShots");
0142 globalsummaryapvshotson = ParametersGlobalNApvShotsProf.getParameter<bool>("globalswitchon");
0143
0144 edm::ParameterSet ParametersGlobalNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
0145 globalswitchnstripsapvshotson = ParametersGlobalNStripApvShots.getParameter<bool>("globalswitchon");
0146
0147 edm::ParameterSet ParametersGlobalApvNumApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
0148 globalswitchapvshotsApvon = ParametersGlobalApvNumApvShots.getParameter<bool>("globalswitchon");
0149
0150 edm::ParameterSet ParametersGlobalChargeMedianApvShots =
0151 conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
0152 globalswitchchargemedianapvshotson = ParametersGlobalChargeMedianApvShots.getParameter<bool>("globalswitchon");
0153
0154 edm::ParameterSet ParametersGlobalNApvShotsTimeProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
0155 globalswitchapvshotsonprof = ParametersGlobalNApvShotsTimeProf.getParameter<bool>("globalswitchon");
0156
0157 edm::ParameterSet ParametersGlobalNDigisFEDID = conf_.getParameter<edm::ParameterSet>("TProfNDigisFED");
0158 globalswitchNDigisFEDID = ParametersGlobalNDigisFEDID.getParameter<bool>("globalswitchon");
0159
0160
0161
0162 digitkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
0163
0164 shotshistomapon = conf_.getParameter<bool>("TkHistoMapNApvShots_On");
0165 shotsstripshistomapon = conf_.getParameter<bool>("TkHistoMapNStripApvShots_On");
0166 shotschargehistomapon = conf_.getParameter<bool>("TkHistoMapMedianChargeApvShots_On");
0167
0168 createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
0169 Mod_On_ = conf_.getParameter<bool>("Mod_On");
0170 m_trendVs10LS = conf_.getParameter<bool>("TrendVs10LS");
0171
0172
0173 historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
0174 historyProducerToken_ = consumes<EventWithHistory>(conf_.getParameter<edm::InputTag>("HistoryProducer"));
0175
0176
0177 apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
0178 apvPhaseProducerToken_ = consumes<APVCyclePhaseCollection>(conf_.getParameter<edm::InputTag>("ApvPhaseProducer"));
0179
0180 gtEvmToken_ = consumes<L1GlobalTriggerEvmReadoutRecord>(edm::InputTag("gtEvmDigis"));
0181
0182 if (show_mechanical_structure_view) {
0183 tTopoTokenRun_ = esConsumes<edm::Transition::BeginRun>();
0184 tkDetMapTokenRun_ = esConsumes<edm::Transition::BeginRun>();
0185 SiStripDetCablingTokenRun_ = esConsumes<edm::Transition::BeginRun>();
0186 }
0187 if (subdetswitchtotdigifailureon) {
0188 runInfoTokenRun_ = esConsumes<edm::Transition::BeginRun>();
0189 }
0190 tTopoToken_ = esConsumes();
0191
0192
0193 bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
0194 if (checkDCS)
0195 dcsStatus_ = new SiStripDCSStatus(consumesCollector());
0196 else
0197 dcsStatus_ = nullptr;
0198
0199
0200 SBTransitionDone = false;
0201 SBDeclaredAt = 0;
0202 ignoreFirstNLumisections_ = TMath::Max(0, ParametersTotDigiFailure.getParameter<int32_t>("ignoreFirstNLumisections"));
0203 integrateNLumisections_ = TMath::Max(1, ParametersTotDigiFailure.getParameter<int32_t>("integrateNLumisections"));
0204 vecSubDetTotDigiProfLS.reserve(7);
0205 }
0206
0207
0208 SiStripMonitorDigi::~SiStripMonitorDigi() {
0209 if (dcsStatus_)
0210 delete dcsStatus_;
0211 }
0212
0213 void SiStripMonitorDigi::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) {
0214 if (show_mechanical_structure_view) {
0215 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
0216 if (m_cacheID_ != cacheID) {
0217 m_cacheID_ = cacheID;
0218 edm::LogInfo("SiStripMonitorDigi") << "SiStripMonitorDigi::bookHistograms: "
0219 << " Creating MEs for new Cabling ";
0220 createMEs(ibooker, es);
0221 }
0222 } else if (reset_each_run) {
0223 edm::LogInfo("SiStripMonitorDigi") << "SiStripMonitorDigi::bookHistograms: "
0224 << " Resetting MEs ";
0225 for (std::map<uint32_t, ModMEs>::const_iterator idet = DigiMEs.begin(); idet != DigiMEs.end(); idet++) {
0226 ResetModuleMEs(idet->first);
0227 }
0228 }
0229 }
0230
0231
0232 void SiStripMonitorDigi::dqmBeginRun(const edm::Run& run, const edm::EventSetup& es) {
0233 if (subdetswitchtotdigifailureon) {
0234
0235 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
0236 if (m_cacheID_ != cacheID) {
0237 m_cacheID_ = cacheID;
0238 }
0239
0240
0241 nFedTIB = 0;
0242 nFedTIDm = 0;
0243 nFedTIDp = 0;
0244 nFedTECm = 0;
0245 nFedTECp = 0;
0246 nFedTOB = 0;
0247
0248
0249
0250
0251 if (auto runInfoRec = es.tryToGet<RunInfoRcd>()) {
0252 edm::ESHandle<RunInfo> sumFED = runInfoRec->getHandle(runInfoTokenRun_);
0253
0254 if (sumFED.isValid()) {
0255 std::vector<int> FedsInIds = sumFED->m_fed_in;
0256 for (unsigned int it = 0; it < FedsInIds.size(); ++it) {
0257 int fedID = FedsInIds[it];
0258
0259
0260 if (fedID >= 50 && fedID <= 133)
0261 ++nFedTIB;
0262 if (fedID >= 134 && fedID <= 148)
0263 ++nFedTIDm;
0264 if (fedID >= 149 && fedID <= 163)
0265 ++nFedTIDp;
0266 if (fedID >= 164 && fedID <= 259)
0267 ++nFedTECm;
0268 if (fedID >= 260 && fedID <= 355)
0269 ++nFedTECp;
0270 if (fedID >= 356 && fedID <= 489)
0271 ++nFedTOB;
0272 }
0273 }
0274 }
0275 }
0276 }
0277
0278
0279 std::shared_ptr<bool> SiStripMonitorDigi::globalBeginLuminosityBlock(const edm::LuminosityBlock& lb,
0280 const edm::EventSetup& es) const {
0281 bool isStableBeams = false;
0282 return std::make_shared<bool>(isStableBeams);
0283 }
0284
0285
0286 void SiStripMonitorDigi::globalEndLuminosityBlock(const edm::LuminosityBlock& lb, const edm::EventSetup& es) {
0287 unsigned int currentLS = lb.id().luminosityBlock();
0288 const bool isStableBeams = luminosityBlockCache(lb.index());
0289 if (subdetswitchtotdigifailureon && isStableBeams && !SBTransitionDone) {
0290 SBDeclaredAt = (int)currentLS;
0291 SBTransitionDone = true;
0292 }
0293
0294 if (subdetswitchtotdigifailureon && currentLS % integrateNLumisections_ == 0) {
0295 int nFeds[6] = {96, 96, 84, 15, 15, 134};
0296 int nFedsConnected[6] = {nFedTECm, nFedTECp, nFedTIB, nFedTIDm, nFedTIDp, nFedTOB};
0297
0298 if (digiFailureMEs.SubDetTotDigiProfLS) {
0299 for (int ibin = 1; ibin < 7; ibin++) {
0300
0301
0302 float value = digiFailureMEs.SubDetTotDigiProfLS->getBinContent(ibin) - vecSubDetTotDigiProfLS[ibin];
0303 vecSubDetTotDigiProfLS[ibin] = digiFailureMEs.SubDetTotDigiProfLS->getBinContent(ibin);
0304
0305 float fillvalue = 2;
0306 if (isStableBeams
0307
0308 && ((int)currentLS - SBDeclaredAt) > ignoreFirstNLumisections_ &&
0309 (float)nFedsConnected[ibin - 1] / nFeds[ibin - 1] > 0.5 && value < 50.) {
0310 fillvalue = 1.01;
0311 }
0312
0313 for (int fillbin = (int)currentLS - integrateNLumisections_ + 1; fillbin <= (int)currentLS; fillbin++)
0314 digiFailureMEs.SubDetDigiFailures2D->Fill(fillbin, ibin - 1, fillvalue);
0315 }
0316 }
0317 }
0318 }
0319
0320 void SiStripMonitorDigi::createMEs(DQMStore::IBooker& ibooker, const edm::EventSetup& es) {
0321 if (show_mechanical_structure_view) {
0322
0323 const TrackerTopology* const tTopo = &es.getData(tTopoTokenRun_);
0324 const TkDetMap* tkDetMap = &es.getData(tkDetMapTokenRun_);
0325
0326
0327 SiStripDetCabling_ = &es.getData(SiStripDetCablingTokenRun_);
0328
0329
0330 std::vector<uint32_t> activeDets;
0331 activeDets.clear();
0332 SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
0333
0334
0335 for (std::vector<uint32_t>::iterator idets = activeDets.begin(); idets != activeDets.end(); idets++) {
0336 if (*idets == 0)
0337 activeDets.erase(idets);
0338 }
0339
0340
0341 SiStripFolderOrganizer folder_organizer;
0342
0343
0344
0345 if (digitkhistomapon)
0346 tkmapdigi = std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_NumberOfDigi", 0.0, true);
0347 if (shotshistomapon)
0348 tkmapNApvshots = std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_NApvShots", 0.0, true);
0349 if (shotsstripshistomapon)
0350 tkmapNstripApvshot =
0351 std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_NStripApvShots", 0.0, true);
0352 if (shotschargehistomapon)
0353 tkmapMedianChargeApvshots =
0354 std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_MedianChargeApvShots", 0.0, true);
0355
0356 std::vector<uint32_t> tibDetIds;
0357
0358
0359 edm::LogInfo("SiStripTkDQM|SiStripMonitorDigi") << "nr. of activeDets: " << activeDets.size();
0360 for (std::vector<uint32_t>::const_iterator detid_iterator = activeDets.begin(); detid_iterator != activeDets.end();
0361 detid_iterator++) {
0362 uint32_t detid = (*detid_iterator);
0363
0364 ModMEs local_modmes;
0365
0366 local_modmes.NumberOfDigis = nullptr;
0367 local_modmes.NumberOfDigisPerStrip = nullptr;
0368 local_modmes.ADCsHottestStrip = nullptr;
0369 local_modmes.ADCsCoolestStrip = nullptr;
0370 local_modmes.DigiADCs = nullptr;
0371 local_modmes.StripOccupancy = nullptr;
0372
0373 if (Mod_On_) {
0374
0375 folder_organizer.setDetectorFolder(detid, tTopo);
0376 if (reset_each_run)
0377 ResetModuleMEs(detid);
0378 createModuleMEs(ibooker, local_modmes, detid);
0379
0380
0381 DigiMEs.insert(std::make_pair(detid, local_modmes));
0382 }
0383
0384
0385 std::pair<std::string, int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
0386 SiStripHistoId hidmanager;
0387 std::string label = hidmanager.getSubdetid(detid, tTopo, false);
0388
0389
0390 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
0391
0392 if (iLayerME == LayerMEsMap.end()) {
0393 int32_t lnumber = det_layer_pair.second;
0394 std::vector<uint32_t> layerDetIds;
0395 if (det_layer_pair.first == "TIB") {
0396 SiStripSubStructure::getTIBDetectors(activeDets, layerDetIds, tTopo, lnumber, 0, 0, 0);
0397 } else if (det_layer_pair.first == "TOB") {
0398 SiStripSubStructure::getTOBDetectors(activeDets, layerDetIds, tTopo, lnumber, 0, 0);
0399 } else if (det_layer_pair.first == "TID" && lnumber > 0) {
0400 SiStripSubStructure::getTIDDetectors(activeDets, layerDetIds, tTopo, 2, abs(lnumber), 0, 0);
0401 } else if (det_layer_pair.first == "TID" && lnumber < 0) {
0402 SiStripSubStructure::getTIDDetectors(activeDets, layerDetIds, tTopo, 1, abs(lnumber), 0, 0);
0403 } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
0404 SiStripSubStructure::getTECDetectors(activeDets, layerDetIds, tTopo, 2, abs(lnumber), 0, 0, 0, 0);
0405 } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
0406 SiStripSubStructure::getTECDetectors(activeDets, layerDetIds, tTopo, 1, abs(lnumber), 0, 0, 0, 0);
0407 }
0408
0409 LayerDetMap[label] = layerDetIds;
0410
0411
0412 folder_organizer.setLayerFolder(detid, tTopo, det_layer_pair.second);
0413 createLayerMEs(ibooker, label, layerDetIds.size());
0414 }
0415
0416
0417 auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
0418 if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()) {
0419 ibooker.setCurrentFolder(sdet_pair.first);
0420 createSubDetMEs(ibooker, sdet_pair.second);
0421 }
0422
0423 }
0424
0425
0426
0427 ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0428
0429 if (globalsummaryapvshotson) {
0430 const char* HistoName = "Summary Mean Apv shots for SubDets";
0431 NApvShotsGlobalProf = ibooker.bookProfile(HistoName, HistoName, 6, 0.5, 6.5, 100, 0., 0., "");
0432 NApvShotsGlobalProf->setBinLabel(1, std::string("TEC-"));
0433 NApvShotsGlobalProf->setBinLabel(2, std::string("TEC+"));
0434 NApvShotsGlobalProf->setBinLabel(3, std::string("TIB"));
0435 NApvShotsGlobalProf->setBinLabel(4, std::string("TID-"));
0436 NApvShotsGlobalProf->setBinLabel(5, std::string("TID+"));
0437 NApvShotsGlobalProf->setBinLabel(6, std::string("TOB"));
0438 NApvShotsGlobalProf->setAxisTitle(" mean APV shots # / evt", 2);
0439 }
0440
0441
0442 if (globalswitchapvshotsonprof) {
0443 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
0444 const char* HistoName = "NApv_Shots_vs_Time";
0445 ShotsVsTimeApvShotsGlobal = ibooker.bookProfile(HistoName,
0446 HistoName,
0447 Parameters.getParameter<int32_t>("Nbins"),
0448 Parameters.getParameter<double>("xmin"),
0449 Parameters.getParameter<double>("xmax"),
0450 200,
0451 Parameters.getParameter<double>("ymin"),
0452 Parameters.getParameter<double>("ymax"),
0453 "");
0454 ShotsVsTimeApvShotsGlobal->setAxisTitle("Time (s)", 1);
0455 ShotsVsTimeApvShotsGlobal->setAxisTitle("# Apv Shots", 2);
0456 if (ShotsVsTimeApvShotsGlobal->kind() == MonitorElement::Kind::TPROFILE)
0457 ShotsVsTimeApvShotsGlobal->setCanExtend(TH1::kAllAxes);
0458 }
0459
0460
0461 if (globalswitchnstripsapvshotson) {
0462 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
0463 const char* HistoName = "Number_of_Strips_in_Apv_Shots";
0464 StripMultiplicityApvShotsGlobal = ibooker.book1D(HistoName,
0465 HistoName,
0466 Parameters.getParameter<int32_t>("Nbins"),
0467 Parameters.getParameter<double>("xmin"),
0468 Parameters.getParameter<double>("xmax"));
0469 StripMultiplicityApvShotsGlobal->setAxisTitle("# strips in Apv Shots", 1);
0470 }
0471
0472
0473 if (globalswitchnapvshotson) {
0474 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
0475 const char* HistoName = "Number_of_Apv_Shots";
0476 NApvShotsGlobal = ibooker.book1D(HistoName,
0477 HistoName,
0478 Parameters.getParameter<int32_t>("Nbins"),
0479 Parameters.getParameter<double>("xmin"),
0480 Parameters.getParameter<double>("xmax"));
0481 NApvShotsGlobal->setAxisTitle("# Apv Shots", 1);
0482 }
0483
0484
0485 if (globalswitchchargemedianapvshotson) {
0486 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
0487
0488 const char* HistoName = "Apv_Shots_Charge_Median";
0489 MedianChargeApvShotsGlobal = ibooker.book1D(HistoName,
0490 HistoName,
0491 Parameters.getParameter<int32_t>("Nbins"),
0492 Parameters.getParameter<double>("xmin"),
0493 Parameters.getParameter<double>("xmax"));
0494 MedianChargeApvShotsGlobal->setAxisTitle("Apv Shots Charge Median (ADC)", 1);
0495 }
0496
0497
0498 if (globalswitchapvshotsApvon) {
0499 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
0500
0501 const char* HistoName = "Apv_Shots_Apv_Number";
0502 NApvApvShotsGlobal = ibooker.book1D(HistoName,
0503 HistoName,
0504 Parameters.getParameter<int32_t>("Nbins"),
0505 Parameters.getParameter<double>("xmin"),
0506 Parameters.getParameter<double>("xmax"));
0507 NApvApvShotsGlobal->setAxisTitle("Apv Number", 1);
0508 }
0509
0510 if (globalswitchNDigisFEDID) {
0511
0512 edm::ParameterSet FEDDigi = conf_.getParameter<edm::ParameterSet>("TProfNDigisFED");
0513 const char* HistoName = "NumberOfDigisinFED_v_FEDID";
0514
0515 NumberOfFEDDigis = ibooker.bookProfile(HistoName,
0516 HistoName,
0517 FEDDigi.getParameter<int32_t>("Nbinsx"),
0518 FEDDigi.getParameter<double>("xmin"),
0519 FEDDigi.getParameter<double>("xmax"),
0520 FEDDigi.getParameter<int32_t>("Nbinsy"),
0521 FEDDigi.getParameter<double>("ymin"),
0522 FEDDigi.getParameter<double>("ymax"),
0523 "");
0524 NumberOfFEDDigis->setAxisTitle("FED ID", 1);
0525 NumberOfFEDDigis->setAxisTitle("Mean # of Digis in FED", 2);
0526 }
0527
0528
0529
0530
0531
0532 digiFailureMEs.SubDetTotDigiProfLS = nullptr;
0533 digiFailureMEs.SubDetDigiFailures2D = nullptr;
0534
0535 std::stringstream ss;
0536
0537 folder_organizer.getLayerFolderName(ss, 0, tTopo);
0538 ibooker.setCurrentFolder(ss.str());
0539
0540 if (subdetswitchtotdigifailureon) {
0541 const char* HistoName = "NumberOfDigisInLastLS";
0542 digiFailureMEs.SubDetTotDigiProfLS = ibooker.bookProfile(HistoName, HistoName, 6, 0.5, 6.5, 0., 0., "");
0543 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(1, std::string("TEC-"));
0544 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(2, std::string("TEC+"));
0545 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(3, std::string("TIB"));
0546 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(4, std::string("TID-"));
0547 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(5, std::string("TID+"));
0548 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(6, std::string("TOB"));
0549 }
0550
0551 if (subdetswitchtotdigifailureon) {
0552 std::string HistoName = "DataPresentInLS";
0553 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
0554
0555 digiFailureMEs.SubDetDigiFailures2D = ibooker.book2D(HistoName,
0556 HistoName,
0557 Parameters.getParameter<int32_t>("Nbins"),
0558 1,
0559 Parameters.getParameter<int32_t>("Nbins") + 1,
0560 6,
0561 0,
0562 6);
0563
0564 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(1, std::string("TEC-"), 2);
0565 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(2, std::string("TEC+"), 2);
0566 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(3, std::string("TIB"), 2);
0567 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(4, std::string("TID-"), 2);
0568 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(5, std::string("TID+"), 2);
0569 digiFailureMEs.SubDetDigiFailures2D->setBinLabel(6, std::string("TOB"), 2);
0570 digiFailureMEs.SubDetDigiFailures2D->setAxisTitle("Luminosity Section");
0571 }
0572 }
0573
0574 }
0575
0576
0577 void SiStripMonitorDigi::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0578
0579 if (dcsStatus_ && !dcsStatus_->getStatus(iEvent, iSetup))
0580 return;
0581
0582
0583 const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_);
0584
0585 TotalNShots = 0;
0586
0587 runNb = iEvent.id().run();
0588 eventNb++;
0589
0590 float iOrbitVar =
0591 m_trendVs10LS ? iEvent.orbitNumber() / (10 * NORBITS_PER_LS) : iEvent.orbitNumber() / NORBITS_PER_LS;
0592
0593 digi_detset_handles.clear();
0594
0595 std::vector<edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > >::const_iterator iToken =
0596 digiProducerTokenList.begin();
0597 for (std::vector<edm::InputTag>::const_iterator iter = digiProducerList.begin(), iEnd = digiProducerList.end();
0598 iter != iEnd;
0599 ++iter, ++iToken) {
0600 edm::Handle<edm::DetSetVector<SiStripDigi> > digi_handle;
0601 iEvent.getByToken(*iToken, digi_handle);
0602 if (digi_handle.isValid())
0603 digi_detset_handles.push_back(digi_handle.product());
0604 }
0605
0606
0607 for (auto& iSubdet : SubDetMEsMap) {
0608 iSubdet.second.totNDigis = 0;
0609 iSubdet.second.SubDetApvShots.clear();
0610 }
0611
0612 std::map<int, int> FEDID_v_digisum;
0613
0614 for (std::map<std::string, std::vector<uint32_t> >::const_iterator iterLayer = LayerDetMap.begin();
0615 iterLayer != LayerDetMap.end();
0616 iterLayer++) {
0617 std::string layer_label = iterLayer->first;
0618
0619 std::vector<uint32_t> layer_dets = iterLayer->second;
0620 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
0621
0622
0623 LayerMEs local_layermes;
0624
0625 if (iLayerME == LayerMEsMap.end())
0626 continue;
0627 else
0628 local_layermes = iLayerME->second;
0629
0630 int largest_adc_layer = 0;
0631 int smallest_adc_layer = 99999;
0632
0633 int ndigi_layer = 0;
0634
0635 uint16_t iDet = 0;
0636
0637 std::string_view subdet_label = "";
0638
0639
0640 for (std::vector<uint32_t>::const_iterator iterDets = layer_dets.begin(); iterDets != layer_dets.end();
0641 iterDets++) {
0642 iDet++;
0643
0644
0645 uint32_t detid = (*iterDets);
0646
0647
0648 if (subdet_label.empty())
0649 subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
0650
0651
0652
0653 std::map<uint32_t, ModMEs>::iterator pos = DigiMEs.find(detid);
0654 ModMEs local_modmes = pos->second;
0655
0656
0657 int loc = getDigiSourceIndex(detid);
0658
0659 int ndigi_det = 0;
0660
0661 if (loc > -1) {
0662 ndigi_det = (*(digi_detset_handles[loc]))[detid].size();
0663
0664
0665
0666
0667
0668 std::vector<const FedChannelConnection*> fedConnections = SiStripDetCabling_->getConnections(detid);
0669
0670
0671
0672 int good_fcc_index = -999;
0673 for (unsigned int x = 0; x < fedConnections.size(); x++) {
0674 if (fedConnections[x] != nullptr) {
0675 good_fcc_index = x;
0676 break;
0677 }
0678 }
0679 if (fedConnections[good_fcc_index] != nullptr) {
0680 int temp_fedid = fedConnections[good_fcc_index]->fedId();
0681 if (FEDID_v_digisum.find(temp_fedid) != FEDID_v_digisum.end()) {
0682 if (ndigi_det < 1000 && ndigi_det > 0) {
0683 FEDID_v_digisum[temp_fedid] = FEDID_v_digisum.find(temp_fedid)->second + ndigi_det;
0684 }
0685 } else {
0686 if (ndigi_det < 1000 && ndigi_det > 0) {
0687 FEDID_v_digisum[temp_fedid] = ndigi_det;
0688 }
0689 }
0690 } else {
0691 edm::LogInfo("SiStripMonitorDigi")
0692 << "SiStripMonitorDigi::analyze WARNING! no good connections for detid = " << detid << std::endl;
0693 }
0694
0695
0696 APVShotFinder theShotFinder = APVShotFinder((*(digi_detset_handles[loc]))[detid]);
0697 const std::vector<APVShot>& shots = theShotFinder.getShots();
0698 AddApvShotsToSubDet(shots, SubDetMEsMap[subdet_label].SubDetApvShots);
0699 if (shotshistomapon)
0700 tkmapNApvshots->fill(detid, shots.size());
0701 if (shotsstripshistomapon)
0702 FillApvShotsMap(tkmapNstripApvshot.get(), shots, detid, 1);
0703 if (shotschargehistomapon)
0704 FillApvShotsMap(tkmapMedianChargeApvshots.get(), shots, detid, 2);
0705 }
0706
0707 if (Mod_On_ && moduleswitchnumdigison && (local_modmes.NumberOfDigis != nullptr))
0708 (local_modmes.NumberOfDigis)->Fill(ndigi_det);
0709
0710 if (layerswitchnumdigisprofon)
0711 local_layermes.LayerNumberOfDigisProfile->Fill(iDet * 1.0, ndigi_det);
0712
0713 if (digitkhistomapon)
0714 tkmapdigi->fill(detid, ndigi_det);
0715
0716 if (ndigi_det == 0)
0717 continue;
0718
0719 const edm::DetSet<SiStripDigi>& digi_detset = (*(digi_detset_handles[loc]))[detid];
0720
0721 ndigi_layer += ndigi_det;
0722
0723
0724 int largest_adc = (digi_detset.data.begin())->adc();
0725 int smallest_adc = (digi_detset.data.begin())->adc();
0726
0727
0728 float det_occupancy = 0.0;
0729
0730 for (edm::DetSet<SiStripDigi>::const_iterator digiIter = digi_detset.data.begin();
0731 digiIter != digi_detset.data.end();
0732 digiIter++) {
0733 int this_adc = digiIter->adc();
0734
0735 if (this_adc > 0.0)
0736 det_occupancy++;
0737
0738 if (this_adc > largest_adc)
0739 largest_adc = this_adc;
0740 if (this_adc < smallest_adc)
0741 smallest_adc = this_adc;
0742
0743 if (Mod_On_ && moduleswitchnumdigispstripon && (local_modmes.NumberOfDigisPerStrip != nullptr) &&
0744 (this_adc > 0.0))
0745 (local_modmes.NumberOfDigisPerStrip)->Fill(digiIter->strip());
0746
0747 if (Mod_On_ && moduleswitchdigiadcson && (local_modmes.DigiADCs != nullptr))
0748 (local_modmes.DigiADCs)->Fill(static_cast<float>(this_adc));
0749
0750
0751 if (layerswitchdigiadcson) {
0752 fillME(local_layermes.LayerDigiADCs, this_adc);
0753 if (createTrendMEs)
0754 fillTrend(local_layermes.LayerDigiADCsTrend, this_adc, iOrbitVar);
0755 }
0756
0757 if (layerswitchdigiadcprofon)
0758 local_layermes.LayerDigiADCProfile->Fill(iDet * 1.0, this_adc);
0759
0760 }
0761
0762
0763 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
0764 if (nstrips > 0 && det_occupancy > 0) {
0765 det_occupancy = det_occupancy / nstrips;
0766 if (Mod_On_ && moduleswitchstripoccupancyon && (local_modmes.StripOccupancy != nullptr))
0767 (local_modmes.StripOccupancy)->Fill(det_occupancy);
0768 if (layerswitchstripoccupancyon) {
0769 fillME(local_layermes.LayerStripOccupancy, det_occupancy);
0770 if (createTrendMEs)
0771 fillTrend(local_layermes.LayerStripOccupancyTrend, det_occupancy, iOrbitVar);
0772 }
0773 }
0774
0775 if (largest_adc > largest_adc_layer)
0776 largest_adc_layer = largest_adc;
0777 if (smallest_adc < smallest_adc_layer)
0778 smallest_adc_layer = smallest_adc;
0779
0780
0781 if (Mod_On_ && moduleswitchadchotteston && (local_modmes.ADCsHottestStrip != nullptr))
0782 (local_modmes.ADCsHottestStrip)->Fill(static_cast<float>(largest_adc));
0783
0784
0785 if (Mod_On_ && moduleswitchadccooleston && (local_modmes.ADCsCoolestStrip != nullptr))
0786 (local_modmes.ADCsCoolestStrip)->Fill(static_cast<float>(smallest_adc));
0787
0788 }
0789
0790 if (layerswitchnumdigison) {
0791 fillME(local_layermes.LayerNumberOfDigis, ndigi_layer);
0792 if (createTrendMEs)
0793 fillTrend(local_layermes.LayerNumberOfDigisTrend, ndigi_layer, iOrbitVar);
0794 }
0795 if (layerswitchadchotteston) {
0796 fillME(local_layermes.LayerADCsHottestStrip, largest_adc_layer);
0797 if (createTrendMEs)
0798 fillTrend(local_layermes.LayerADCsHottestStripTrend, largest_adc_layer, iOrbitVar);
0799 }
0800 if (layerswitchadccooleston) {
0801 fillME(local_layermes.LayerADCsCoolestStrip, smallest_adc_layer);
0802 if (createTrendMEs)
0803 fillTrend(local_layermes.LayerADCsCoolestStripTrend, smallest_adc_layer, iOrbitVar);
0804 }
0805
0806 auto iSubdet = SubDetMEsMap.find(subdet_label);
0807 if (iSubdet != SubDetMEsMap.end()) {
0808 iSubdet->second.totNDigis += ndigi_layer;
0809
0810 }
0811 }
0812
0813 bool& isStableBeams = *luminosityBlockCache(iEvent.getLuminosityBlock().index());
0814 if (subdetswitchtotdigifailureon) {
0815
0816 edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvm_handle;
0817 iEvent.getByToken(gtEvmToken_, gtEvm_handle);
0818 L1GlobalTriggerEvmReadoutRecord const* gtevm = gtEvm_handle.product();
0819
0820 L1GtfeExtWord gtfeEvmExtWord;
0821 if (gtevm) {
0822 gtfeEvmExtWord = gtevm->gtfeWord();
0823 } else
0824 edm::LogInfo("DQMProvInfo") << " gtfeEvmWord inaccessible";
0825
0826
0827 if (gtfeEvmExtWord.beamMode() == 11)
0828 isStableBeams = true;
0829 }
0830
0831 for (auto& it : SubDetMEsMap) {
0832 if (subdetswitchtotdigifailureon) {
0833 if (it.first == "TEC__MINUS") {
0834 digiFailureMEs.SubDetTotDigiProfLS->Fill(1, it.second.totNDigis);
0835 } else if (it.first == "TEC__PLUS") {
0836 digiFailureMEs.SubDetTotDigiProfLS->Fill(2, it.second.totNDigis);
0837 } else if (it.first == "TIB") {
0838 digiFailureMEs.SubDetTotDigiProfLS->Fill(3, it.second.totNDigis);
0839 } else if (it.first == "TID__MINUS") {
0840 digiFailureMEs.SubDetTotDigiProfLS->Fill(4, it.second.totNDigis);
0841 } else if (it.first == "TID__PLUS") {
0842 digiFailureMEs.SubDetTotDigiProfLS->Fill(5, it.second.totNDigis);
0843 } else if (it.first == "TOB") {
0844 digiFailureMEs.SubDetTotDigiProfLS->Fill(6, it.second.totNDigis);
0845 }
0846 }
0847
0848 if (globalsummaryapvshotson) {
0849 if (it.first == "TEC__MINUS") {
0850 NApvShotsGlobalProf->Fill(1, it.second.SubDetApvShots.size());
0851 } else if (it.first == "TEC__PLUS") {
0852 NApvShotsGlobalProf->Fill(2, it.second.SubDetApvShots.size());
0853 } else if (it.first == "TIB") {
0854 NApvShotsGlobalProf->Fill(3, it.second.SubDetApvShots.size());
0855 } else if (it.first == "TID__MINUS") {
0856 NApvShotsGlobalProf->Fill(4, it.second.SubDetApvShots.size());
0857 } else if (it.first == "TID__PLUS") {
0858 NApvShotsGlobalProf->Fill(5, it.second.SubDetApvShots.size());
0859 } else if (it.first == "TOB") {
0860 NApvShotsGlobalProf->Fill(6, it.second.SubDetApvShots.size());
0861 }
0862 }
0863
0864 SubDetMEs subdetmes = it.second;
0865
0866
0867 uint ShotsSize = subdetmes.SubDetApvShots.size();
0868 TotalNShots += ShotsSize;
0869
0870 if (subdetswitchnapvshotson)
0871 subdetmes.SubDetNApvShotsTH1->Fill(ShotsSize);
0872 if (subdetswitchapvshotsonprof)
0873 subdetmes.SubDetNApvShotsProf->Fill(iOrbitVar, ShotsSize);
0874
0875 for (uint i = 0; i < ShotsSize;
0876 ++i) {
0877
0878 if (subdetswitchapvshotsApvon)
0879 subdetmes.SubDetNApvShotsNApvTH1->Fill(
0880 (subdetmes.SubDetApvShots[i].apvNumber() + 1));
0881 if (globalswitchapvshotsApvon)
0882 NApvApvShotsGlobal->Fill((subdetmes.SubDetApvShots[i].apvNumber() + 1));
0883
0884 if (subdetswitchnstripsapvshotson)
0885 subdetmes.SubDetNStripsApvShotsTH1->Fill(subdetmes.SubDetApvShots[i].nStrips());
0886 if (globalswitchnstripsapvshotson)
0887 StripMultiplicityApvShotsGlobal->Fill(subdetmes.SubDetApvShots[i].nStrips());
0888
0889 if (subdetswitchchargemedianapvshotson)
0890 subdetmes.SubDetChargeMedianApvShotsTH1->Fill(subdetmes.SubDetApvShots[i].median());
0891 if (globalswitchchargemedianapvshotson)
0892 MedianChargeApvShotsGlobal->Fill(subdetmes.SubDetApvShots[i].median());
0893 }
0894
0895 if (subdetswitchtotdigiprofon)
0896 subdetmes.SubDetTotDigiProf->Fill(iOrbitVar, subdetmes.totNDigis);
0897 }
0898
0899 if (globalswitchnapvshotson)
0900 NApvShotsGlobal->Fill(TotalNShots);
0901 if (globalswitchapvshotsonprof)
0902 ShotsVsTimeApvShotsGlobal->Fill(iOrbitVar, TotalNShots);
0903
0904 if (globalswitchNDigisFEDID) {
0905 std::map<int, int>::iterator it;
0906 for (it = FEDID_v_digisum.begin(); it != FEDID_v_digisum.end(); it++) {
0907 NumberOfFEDDigis->Fill(it->first, it->second);
0908 }
0909 }
0910
0911
0912
0913 edm::Handle<EventWithHistory> event_history;
0914 iEvent.getByToken(historyProducerToken_, event_history);
0915
0916
0917 edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
0918 iEvent.getByToken(apvPhaseProducerToken_, apv_phase_collection);
0919
0920 if (event_history.isValid() && !event_history.failedToGet() && apv_phase_collection.isValid() &&
0921 !apv_phase_collection.failedToGet()) {
0922 long long tbx = event_history->absoluteBX();
0923
0924 for (auto& it : SubDetMEsMap) {
0925 const auto& subdet = std::string(it.first);
0926 SubDetMEs& subdetmes = it.second;
0927
0928 int the_phase = APVCyclePhaseCollection::invalid;
0929 long long tbx_corr = tbx;
0930
0931 if (SubDetPhasePartMap.find(subdet) != SubDetPhasePartMap.end())
0932 the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[subdet]);
0933 if (the_phase == APVCyclePhaseCollection::nopartition || the_phase == APVCyclePhaseCollection::multiphase ||
0934 the_phase == APVCyclePhaseCollection::invalid)
0935 the_phase = 30;
0936 tbx_corr -= the_phase;
0937
0938 if (subdetswitchapvcycleprofon)
0939 subdetmes.SubDetDigiApvProf->Fill(tbx_corr % 70, subdetmes.totNDigis);
0940 if (subdetswitchapvcycleth2on)
0941 subdetmes.SubDetDigiApvTH2->Fill(tbx_corr % 70, subdetmes.totNDigis);
0942 }
0943 }
0944 }
0945
0946 void SiStripMonitorDigi::ResetModuleMEs(uint32_t idet) {
0947 std::map<uint32_t, ModMEs>::iterator pos = DigiMEs.find(idet);
0948 ModMEs mod_me = pos->second;
0949
0950 if (Mod_On_ && moduleswitchnumdigison)
0951 mod_me.NumberOfDigis->Reset();
0952 if (Mod_On_ && moduleswitchnumdigispstripon)
0953 mod_me.NumberOfDigisPerStrip->Reset();
0954 if (Mod_On_ && moduleswitchadchotteston)
0955 mod_me.ADCsHottestStrip->Reset();
0956 if (Mod_On_ && moduleswitchadccooleston)
0957 mod_me.ADCsCoolestStrip->Reset();
0958 if (Mod_On_ && moduleswitchdigiadcson)
0959 mod_me.DigiADCs->Reset();
0960 if (Mod_On_ && moduleswitchstripoccupancyon)
0961 mod_me.StripOccupancy->Reset();
0962 }
0963
0964 SiStripMonitorDigi::MonitorElement* SiStripMonitorDigi::bookMETrend(DQMStore::IBooker& ibooker,
0965 const char* ParameterSetLabel,
0966 const char* HistoName) {
0967 edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
0968 MonitorElement* me =
0969 ibooker.bookProfile(HistoName,
0970 HistoName,
0971 ParametersTrend.getParameter<int32_t>("Nbins"),
0972
0973 ParametersTrend.getParameter<double>("xmin"),
0974 ParametersTrend.getParameter<double>("xmax"),
0975
0976 100,
0977 ParametersTrend.getParameter<double>("ymin"),
0978 ParametersTrend.getParameter<double>("ymax"),
0979 "");
0980 if (!me)
0981 return me;
0982
0983 me->setAxisTitle("Lumisection", 1);
0984 if (me->kind() == MonitorElement::Kind::TPROFILE)
0985 me->setCanExtend(TH1::kAllAxes);
0986 return me;
0987 }
0988
0989
0990 SiStripMonitorDigi::MonitorElement* SiStripMonitorDigi::bookME1D(DQMStore::IBooker& ibooker,
0991 const char* ParameterSetLabel,
0992 const char* HistoName) {
0993 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
0994 return ibooker.book1D(HistoName,
0995 HistoName,
0996 Parameters.getParameter<int32_t>("Nbinx"),
0997 Parameters.getParameter<double>("xmin"),
0998 Parameters.getParameter<double>("xmax"));
0999 }
1000
1001
1002 void SiStripMonitorDigi::fillTrend(MonitorElement* me, float value, float timeinorbit) {
1003 if (!me)
1004 return;
1005 me->Fill(timeinorbit, value);
1006 }
1007
1008
1009
1010
1011 void SiStripMonitorDigi::createModuleMEs(DQMStore::IBooker& ibooker, ModMEs& mod_single, uint32_t detid) {
1012
1013 SiStripHistoId hidmanager;
1014 std::string hid;
1015
1016
1017 if (moduleswitchnumdigison) {
1018 hid = hidmanager.createHistoId("NumberOfDigis", "det", detid);
1019 mod_single.NumberOfDigis = ibooker.book1D(hid, hid, 21, -0.5, 20.5);
1020 mod_single.NumberOfDigis->setAxisTitle("number of digis in one detector module");
1021 mod_single.NumberOfDigis->setStatOverflows(kTRUE);
1022 }
1023
1024
1025 if (moduleswitchnumdigispstripon) {
1026 hid = hidmanager.createHistoId("NumberOfDigisPerStrip", "det", detid);
1027 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
1028 mod_single.NumberOfDigisPerStrip = ibooker.book1D(hid, hid, nstrips, -0.5, nstrips + 0.5);
1029 mod_single.NumberOfDigisPerStrip->setAxisTitle("number of (digis > 0) per strip");
1030 mod_single.NumberOfDigisPerStrip->setStatOverflows(kTRUE);
1031 }
1032
1033 if (moduleswitchadchotteston) {
1034 hid = hidmanager.createHistoId("ADCsHottestStrip", "det", detid);
1035 mod_single.ADCsHottestStrip = bookME1D(ibooker, "TH1ADCsHottestStrip", hid.c_str());
1036 mod_single.ADCsHottestStrip->setAxisTitle("number of ADCs for hottest strip");
1037 }
1038
1039
1040 if (moduleswitchadccooleston) {
1041 hid = hidmanager.createHistoId("ADCsCoolestStrip", "det", detid);
1042 mod_single.ADCsCoolestStrip = bookME1D(ibooker, "TH1ADCsCoolestStrip", hid.c_str());
1043 mod_single.ADCsCoolestStrip->setAxisTitle("number of ADCs for coolest strip");
1044 }
1045
1046
1047 if (moduleswitchdigiadcson) {
1048 hid = hidmanager.createHistoId("DigiADCs", "det", detid);
1049 mod_single.DigiADCs = bookME1D(ibooker, "TH1DigiADCs", hid.c_str());
1050 mod_single.DigiADCs->setAxisTitle("number of ADCs for each digi");
1051 }
1052
1053
1054 if (moduleswitchstripoccupancyon) {
1055 hid = hidmanager.createHistoId("StripOccupancy", "det", detid);
1056 mod_single.StripOccupancy = bookME1D(ibooker, "TH1StripOccupancy", hid.c_str());
1057 mod_single.StripOccupancy->setAxisTitle("strip occupancy");
1058 }
1059 }
1060
1061
1062
1063
1064
1065 void SiStripMonitorDigi::createLayerMEs(DQMStore::IBooker& ibooker, std::string label, int ndets) {
1066 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
1067 if (iLayerME == LayerMEsMap.end()) {
1068 SiStripHistoId hidmanager;
1069 LayerMEs layerMEs;
1070 layerMEs.LayerNumberOfDigis = nullptr;
1071 layerMEs.LayerNumberOfDigisTrend = nullptr;
1072 layerMEs.LayerADCsHottestStrip = nullptr;
1073 layerMEs.LayerADCsHottestStripTrend = nullptr;
1074 layerMEs.LayerADCsCoolestStrip = nullptr;
1075 layerMEs.LayerADCsCoolestStripTrend = nullptr;
1076 layerMEs.LayerDigiADCs = nullptr;
1077 layerMEs.LayerDigiADCsTrend = nullptr;
1078 layerMEs.LayerStripOccupancy = nullptr;
1079 layerMEs.LayerStripOccupancyTrend = nullptr;
1080 layerMEs.LayerNumberOfDigisProfile = nullptr;
1081 layerMEs.LayerDigiADCProfile = nullptr;
1082
1083
1084 if (layerswitchnumdigison) {
1085 layerMEs.LayerNumberOfDigis =
1086 bookME1D(ibooker,
1087 "TH1NumberOfDigis",
1088 hidmanager.createHistoLayer("Summary_TotalNumberOfDigis", "layer", label, "").c_str());
1089 if (createTrendMEs)
1090 layerMEs.LayerNumberOfDigisTrend =
1091 bookMETrend(ibooker,
1092 "TH1NumberOfDigis",
1093 hidmanager.createHistoLayer("Trend_NumberOfDigis", "layer", label, "").c_str());
1094 }
1095
1096
1097 if (layerswitchadchotteston) {
1098 layerMEs.LayerADCsHottestStrip =
1099 bookME1D(ibooker,
1100 "TH1ADCsHottestStrip",
1101 hidmanager.createHistoLayer("Summary_ADCsHottestStrip", "layer", label, "").c_str());
1102 if (createTrendMEs)
1103 layerMEs.LayerADCsHottestStripTrend =
1104 bookMETrend(ibooker,
1105 "TH1ADCsHottestStrip",
1106 hidmanager.createHistoLayer("Trend_ADCsHottestStrip", "layer", label, "").c_str());
1107 }
1108
1109
1110 if (layerswitchadccooleston) {
1111 layerMEs.LayerADCsCoolestStrip =
1112 bookME1D(ibooker,
1113 "TH1ADCsCoolestStrip",
1114 hidmanager.createHistoLayer("Summary_ADCsCoolestStrip", "layer", label, "").c_str());
1115 if (createTrendMEs)
1116 layerMEs.LayerADCsCoolestStripTrend =
1117 bookMETrend(ibooker,
1118 "TH1ADCsCoolestStrip",
1119 hidmanager.createHistoLayer("Trend_ADCsCoolestStrip", "layer", label, "").c_str());
1120 }
1121
1122
1123 if (layerswitchdigiadcson) {
1124 layerMEs.LayerDigiADCs =
1125 bookME1D(ibooker, "TH1DigiADCs", hidmanager.createHistoLayer("Summary_DigiADCs", "layer", label, "").c_str());
1126 if (createTrendMEs)
1127 layerMEs.LayerDigiADCsTrend = bookMETrend(
1128 ibooker, "TH1DigiADCs", hidmanager.createHistoLayer("Trend_DigiADCs", "layer", label, "").c_str());
1129 }
1130
1131
1132 if (layerswitchstripoccupancyon) {
1133 layerMEs.LayerStripOccupancy =
1134 bookME1D(ibooker,
1135 "TH1StripOccupancy",
1136 hidmanager.createHistoLayer("Summary_StripOccupancy", "layer", label, "").c_str());
1137 if (createTrendMEs)
1138 layerMEs.LayerStripOccupancyTrend =
1139 bookMETrend(ibooker,
1140 "TH1StripOccupancy",
1141 hidmanager.createHistoLayer("Trend_StripOccupancy", "layer", label, "").c_str());
1142 }
1143
1144 if (layerswitchnumdigisprofon) {
1145 std::string hid = hidmanager.createHistoLayer("NumberOfDigiProfile", "layer", label, "");
1146 layerMEs.LayerNumberOfDigisProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets + 0.5, 21, -0.5, 200.5);
1147 }
1148
1149
1150 if (layerswitchdigiadcprofon) {
1151 std::string hid = hidmanager.createHistoLayer("DigiADCProfile", "layer", label, "");
1152 layerMEs.LayerDigiADCProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets + 0.5, 64, -0.5, 255.5);
1153 }
1154
1155 LayerMEsMap[label] = layerMEs;
1156 }
1157 }
1158
1159
1160
1161 void SiStripMonitorDigi::createSubDetMEs(DQMStore::IBooker& ibooker, std::string_view label) {
1162 SubDetMEs subdetMEs;
1163
1164 std::string HistoName;
1165 std::string slabel = std::string(label);
1166
1167
1168 if (subdetswitchtotdigiprofon) {
1169 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
1170 HistoName = "TotalNumberOfDigiProfile__" + slabel;
1171 subdetMEs.SubDetTotDigiProf = ibooker.bookProfile(HistoName,
1172 HistoName,
1173 Parameters.getParameter<int32_t>("Nbins"),
1174 Parameters.getParameter<double>("xmin"),
1175 Parameters.getParameter<double>("xmax"),
1176 100,
1177 Parameters.getParameter<double>("ymin"),
1178 Parameters.getParameter<double>("ymax"),
1179 "");
1180 subdetMEs.SubDetTotDigiProf->setAxisTitle("Lumisection", 1);
1181
1182 if (subdetMEs.SubDetTotDigiProf->kind() == MonitorElement::Kind::TPROFILE)
1183 subdetMEs.SubDetTotDigiProf->setCanExtend(TH1::kAllAxes);
1184 }
1185
1186
1187 if (subdetswitchapvcycleprofon) {
1188 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
1189 HistoName = "Digi_vs_ApvCycle__" + slabel;
1190 subdetMEs.SubDetDigiApvProf = ibooker.bookProfile(HistoName,
1191 HistoName,
1192 Parameters.getParameter<int32_t>("Nbins"),
1193 Parameters.getParameter<double>("xmin"),
1194 Parameters.getParameter<double>("xmax"),
1195 200,
1196 Parameters.getParameter<double>("ymin"),
1197 Parameters.getParameter<double>("ymax"),
1198 "");
1199 subdetMEs.SubDetDigiApvProf->setAxisTitle("ApvCycle (Corrected Absolute Bx % 70)", 1);
1200 }
1201
1202
1203 if (subdetswitchapvcycleth2on) {
1204 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
1205
1206 HistoName = "Digi_vs_ApvCycle_2D__" + slabel;
1207
1208 double h2ymax = 9999.0;
1209 double yfact = Parameters.getParameter<double>("yfactor");
1210 if (slabel.find("TIB") != std::string::npos)
1211 h2ymax = (6984. * 256.) * yfact;
1212 else if (slabel.find("TID") != std::string::npos)
1213 h2ymax = (2208. * 256.) * yfact;
1214 else if (slabel.find("TOB") != std::string::npos)
1215 h2ymax = (12906. * 256.) * yfact;
1216 else if (slabel.find("TEC") != std::string::npos)
1217 h2ymax = (7552. * 2. * 256.) * yfact;
1218 subdetMEs.SubDetDigiApvTH2 =
1219 ibooker.book2D(HistoName,
1220 HistoName,
1221 Parameters.getParameter<int32_t>("Nbins"),
1222 Parameters.getParameter<double>("xmin"),
1223 Parameters.getParameter<double>("xmax"),
1224 Parameters.getParameter<int32_t>("Nbinsy"),
1225 Parameters.getParameter<double>("ymin"),
1226 h2ymax);
1227 subdetMEs.SubDetDigiApvTH2->setAxisTitle("absolute Bx mod(70)", 1);
1228 }
1229
1230
1231 if (subdetswitchnapvshotson) {
1232 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
1233
1234 HistoName = "Number_of_Apv_Shots_" + slabel;
1235 subdetMEs.SubDetNApvShotsTH1 = ibooker.book1D(HistoName,
1236 HistoName,
1237 Parameters.getParameter<int32_t>("Nbins"),
1238 Parameters.getParameter<double>("xmin"),
1239 Parameters.getParameter<double>("xmax"));
1240 subdetMEs.SubDetNApvShotsTH1->setAxisTitle("# Apv Shots", 1);
1241 }
1242
1243
1244 if (subdetswitchnstripsapvshotson) {
1245 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
1246
1247 HistoName = "Number_of_Strips_in_Apv_Shots_" + slabel;
1248 subdetMEs.SubDetNStripsApvShotsTH1 = ibooker.book1D(HistoName,
1249 HistoName,
1250 Parameters.getParameter<int32_t>("Nbins"),
1251 Parameters.getParameter<double>("xmin"),
1252 Parameters.getParameter<double>("xmax"));
1253 subdetMEs.SubDetNStripsApvShotsTH1->setAxisTitle("# strips in Apv Shots", 1);
1254 }
1255
1256
1257 if (subdetswitchchargemedianapvshotson) {
1258 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
1259
1260 HistoName = "Apv_Shots_Charge_Median_" + slabel;
1261 subdetMEs.SubDetChargeMedianApvShotsTH1 = ibooker.book1D(HistoName,
1262 HistoName,
1263 Parameters.getParameter<int32_t>("Nbins"),
1264 Parameters.getParameter<double>("xmin"),
1265 Parameters.getParameter<double>("xmax"));
1266 subdetMEs.SubDetChargeMedianApvShotsTH1->setAxisTitle("Apv Shots Charge Median (ADC)", 1);
1267 }
1268
1269 if (subdetswitchchargemedianapvshotson) {
1270 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
1271
1272 HistoName = "Apv_Shots_Apv_Number_" + slabel;
1273 subdetMEs.SubDetNApvShotsNApvTH1 = ibooker.book1D(HistoName,
1274 HistoName,
1275 Parameters.getParameter<int32_t>("Nbins"),
1276 Parameters.getParameter<double>("xmin"),
1277 Parameters.getParameter<double>("xmax"));
1278 subdetMEs.SubDetNApvShotsNApvTH1->setAxisTitle("Apv Number", 1);
1279 }
1280
1281
1282 if (subdetswitchapvshotsonprof) {
1283 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
1284 HistoName = "NApv_Shots_vs_Time_" + slabel;
1285 subdetMEs.SubDetNApvShotsProf = ibooker.bookProfile(HistoName,
1286 HistoName,
1287 Parameters.getParameter<int32_t>("Nbins"),
1288 Parameters.getParameter<double>("xmin"),
1289 Parameters.getParameter<double>("xmax"),
1290 200,
1291 Parameters.getParameter<double>("ymin"),
1292 Parameters.getParameter<double>("ymax"),
1293 "");
1294 subdetMEs.SubDetNApvShotsProf->setAxisTitle("Time (s)", 1);
1295 subdetMEs.SubDetNApvShotsProf->setAxisTitle("# Apv Shots", 2);
1296 if (subdetMEs.SubDetNApvShotsProf->kind() == MonitorElement::Kind::TPROFILE)
1297 subdetMEs.SubDetNApvShotsProf->setCanExtend(TH1::kAllAxes);
1298 }
1299
1300 SubDetMEsMap[label] = subdetMEs;
1301 }
1302
1303
1304
1305 int SiStripMonitorDigi::getDigiSourceIndex(uint32_t id) {
1306 int location = -1;
1307 for (unsigned int ival = 0; ival < digi_detset_handles.size(); ++ival) {
1308 edm::DetSetVector<SiStripDigi>::const_iterator isearch = digi_detset_handles[ival]->find(id);
1309 if (isearch != digi_detset_handles[ival]->end()) {
1310 location = ival;
1311 break;
1312 }
1313 }
1314 return location;
1315 }
1316
1317 void SiStripMonitorDigi::AddApvShotsToSubDet(const std::vector<APVShot>& moduleShots,
1318 std::vector<APVShot>& subdetShots) {
1319 for (uint i = 0; i < moduleShots.size(); i++) {
1320 subdetShots.push_back(moduleShots[i]);
1321 }
1322 }
1323
1324 void SiStripMonitorDigi::FillApvShotsMap(TkHistoMap* the_map, const std::vector<APVShot>& shots, uint32_t id, int mode) {
1325 for (uint i = 0; i < shots.size(); i++) {
1326 if (mode == 1)
1327 the_map->fill(id, shots[i].nStrips());
1328 if (mode == 2)
1329 the_map->fill(id, shots[i].median());
1330 }
1331 }
1332
1333
1334 DEFINE_FWK_MODULE(SiStripMonitorDigi);