File indexing completed on 2024-04-06 12:07:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DQM/DTMonitorModule/src/DTDCSByLumiTask.h"
0012
0013
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015
0016
0017 #include "Geometry/DTGeometry/interface/DTLayer.h"
0018 #include "Geometry/DTGeometry/interface/DTTopology.h"
0019
0020 #include "DQMServices/Core/interface/DQMStore.h"
0021 #include "FWCore/Framework/interface/EventSetupRecord.h"
0022 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0023 #include "FWCore/Utilities/interface/Transition.h"
0024
0025 #include <iostream>
0026
0027 using namespace edm;
0028 using namespace std;
0029
0030 DTDCSByLumiTask::DTDCSByLumiTask(const edm::ParameterSet& ps)
0031 : theEvents(0),
0032 theLumis(0),
0033 dtGeometryToken_(esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>()),
0034 dtHVStatusToken_(esConsumes<DTHVStatus, DTHVStatusRcd, edm::Transition::EndLuminosityBlock>()) {
0035 LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: Constructor" << endl;
0036
0037
0038
0039 }
0040
0041 DTDCSByLumiTask::~DTDCSByLumiTask() {
0042 LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
0043 << "DTDCSByLumiTask: processed " << theEvents << " events in " << theLumis << " lumi sections" << endl;
0044 }
0045
0046 void DTDCSByLumiTask::dqmBeginRun(const edm::Run& run, const edm::EventSetup& context) {
0047 LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: begin run" << endl;
0048
0049 theDTGeom = context.getHandle(dtGeometryToken_);
0050
0051 DTHVRecordFound = true;
0052
0053 eventsetup::EventSetupRecordKey recordKey(eventsetup::EventSetupRecordKey::TypeTag::findType("DTHVStatusRcd"));
0054
0055 std::vector<eventsetup::EventSetupRecordKey> recordKeys;
0056 context.fillAvailableRecordKeys(recordKeys);
0057 vector<eventsetup::EventSetupRecordKey>::iterator it = find(recordKeys.begin(), recordKeys.end(), recordKey);
0058
0059 if (it == recordKeys.end()) {
0060
0061 LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "Record DTHVStatusRcd does not exist " << std::endl;
0062
0063 DTHVRecordFound = false;
0064 }
0065 }
0066
0067 void DTDCSByLumiTask::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const&) {
0068
0069 ibooker.setCurrentFolder(topFolder());
0070
0071 for (int wheel = -2; wheel <= 2; wheel++) {
0072 stringstream wheel_str;
0073 wheel_str << wheel;
0074
0075 {
0076
0077 auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
0078 MonitorElement* ME =
0079 ibooker.book1D("hActiveUnits" + wheel_str.str(), "Active Untis x LS Wh" + wheel_str.str(), 2, 0.5, 2.5);
0080 hActiveUnits.push_back(ME);
0081 }
0082 }
0083 }
0084
0085 void DTDCSByLumiTask::dqmBeginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const&) {
0086 theLumis++;
0087
0088 LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
0089 << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock() << " " << theLumis
0090 << " lumi processed by this job" << endl;
0091
0092 for (int wheel = 0; wheel < 5; wheel++) {
0093 hActiveUnits[wheel]->Reset();
0094 }
0095 }
0096
0097 void DTDCSByLumiTask::dqmEndLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) {
0098 const DTHVStatus* dtHVStatus = nullptr;
0099 if (DTHVRecordFound) {
0100 dtHVStatus = &context.getData(dtHVStatusToken_);
0101 }
0102
0103 vector<const DTLayer*>::const_iterator layersIt = theDTGeom->layers().begin();
0104 vector<const DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
0105
0106 for (; layersIt != layersEnd; ++layersIt) {
0107 int wheel = (*layersIt)->id().wheel();
0108
0109 int nWiresLayer = (*layersIt)->specificTopology().channels();
0110 hActiveUnits[wheel + 2]->Fill(1, nWiresLayer);
0111 int nActiveWires = nWiresLayer;
0112
0113 int flagA = -100;
0114 int flagC = -100;
0115 int flagS = -100;
0116 int first = -100;
0117 int last = -100;
0118
0119
0120
0121
0122
0123 if (DTHVRecordFound) {
0124 if (!dtHVStatus->get((*layersIt)->id(), 0, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
0125 nActiveWires -= (last - first + 1);
0126 }
0127
0128 if (!dtHVStatus->get((*layersIt)->id(), 1, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
0129 nActiveWires -= (last - first + 1);
0130 }
0131 } else {
0132 nActiveWires = -1.;
0133 }
0134
0135 hActiveUnits[wheel + 2]->Fill(2, nActiveWires);
0136 }
0137 }
0138
0139 void DTDCSByLumiTask::analyze(const edm::Event&, const edm::EventSetup&) { theEvents++; }
0140
0141 string DTDCSByLumiTask::topFolder() const { return string("DT/EventInfo/DCSContents"); }
0142
0143
0144
0145
0146