File indexing completed on 2024-04-06 12:09:17
0001 #include "DQMOffline/CalibMuon/interface/DTPreCalibrationTask.h"
0002
0003
0004 #include "DQMServices/Core/interface/DQMStore.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ServiceRegistry/interface/Service.h"
0010 #include <FWCore/Framework/interface/EventSetup.h>
0011
0012
0013 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0014 #include "Geometry/DTGeometry/interface/DTLayer.h"
0015 #include "Geometry/DTGeometry/interface/DTTopology.h"
0016 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0017
0018
0019 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
0020 #include "CondFormats/DTObjects/interface/DTStatusFlag.h"
0021 #include "CondFormats/DataRecord/interface/DTStatusFlagRcd.h"
0022
0023 #include "TFile.h"
0024 #include "TH2F.h"
0025
0026 using namespace edm;
0027 using namespace std;
0028
0029 DTPreCalibrationTask::DTPreCalibrationTask(const edm::ParameterSet &ps) {
0030 LogTrace("DTPreCalibSummary") << "[DTPrecalibrationTask]: Constructor" << endl;
0031
0032
0033 digiLabel = consumes<DTDigiCollection>(ps.getUntrackedParameter<string>("digiLabel"));
0034
0035
0036 minTriggerWidth = ps.getUntrackedParameter<int>("minTriggerWidth", 2000);
0037 maxTriggerWidth = ps.getUntrackedParameter<int>("maxTriggerWidth", 6000);
0038
0039
0040 folderName = ps.getUntrackedParameter<string>("folderName");
0041 }
0042
0043 DTPreCalibrationTask::~DTPreCalibrationTask() {}
0044
0045 void DTPreCalibrationTask::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &) {
0046 for (int wheel = -2; wheel <= 2; wheel++) {
0047 for (int sector = 1; sector <= 14; sector++) {
0048 LogTrace("DTPreCalibSummary") << "[DTPrecalibrationTask]: Book histos for wheel " << wheel << ", sector "
0049 << sector << endl;
0050 iBooker.setCurrentFolder(folderName + "/TimeBoxes");
0051 bookTimeBoxes(iBooker, wheel, sector);
0052 iBooker.setCurrentFolder(folderName + "/OccupancyHistos");
0053 if (sector < 13)
0054 bookOccupancyPlot(iBooker, wheel, sector);
0055 }
0056 }
0057 }
0058
0059 void DTPreCalibrationTask::analyze(const edm::Event &event, const edm::EventSetup &setup) {
0060
0061 edm::Handle<DTDigiCollection> dtdigis;
0062 event.getByToken(digiLabel, dtdigis);
0063
0064
0065 DTDigiCollection::DigiRangeIterator dtLayerId_It;
0066 for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) {
0067 for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
0068 digiIt != ((*dtLayerId_It).second).second;
0069 ++digiIt) {
0070
0071 int tdcTime = (*digiIt).countsTDC();
0072 TimeBoxes[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),
0073 (*dtLayerId_It).first.superlayerId().chamberId().sector())]
0074 ->Fill(tdcTime);
0075
0076
0077 const DTLayerId dtLId = (*dtLayerId_It).first;
0078 int yBin = (dtLId.station() - 1) * 12 + dtLId.layer() + 4 * (dtLId.superlayer() - 1);
0079 if (dtLId.station() == 4 && dtLId.superlayer() == 3)
0080 yBin = (dtLId.station() - 1) * 12 + dtLId.layer() + 4 * (dtLId.superlayer() - 2);
0081 if ((*dtLayerId_It).first.superlayerId().chamberId().sector() < 13)
0082 OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(),
0083 (*dtLayerId_It).first.superlayerId().chamberId().sector())]
0084 ->Fill((*digiIt).wire(), yBin);
0085 else {
0086 if (dtLId.superlayer() != 3)
0087 yBin = 44 + dtLId.layer();
0088 else
0089 yBin = 48 + dtLId.layer();
0090 if ((*dtLayerId_It).first.superlayerId().chamberId().sector() == 13)
0091 OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(), 4)]->Fill(
0092 (*digiIt).wire(), yBin);
0093 if ((*dtLayerId_It).first.superlayerId().chamberId().sector() == 14)
0094 OccupancyHistos[make_pair((*dtLayerId_It).first.superlayerId().chamberId().wheel(), 10)]->Fill(
0095 (*digiIt).wire(), yBin);
0096 }
0097 }
0098 }
0099 }
0100
0101 void DTPreCalibrationTask::bookTimeBoxes(DQMStore::IBooker &iBooker, int wheel, int sector) {
0102 stringstream wh;
0103 wh << wheel;
0104 stringstream sec;
0105 sec << sector;
0106
0107
0108 TimeBoxes[make_pair(wheel, sector)] = iBooker.book1D("TimeBox_W" + wh.str() + "_Sec" + sec.str(),
0109 "Time Box W" + wh.str() + "_Sec" + sec.str(),
0110 (maxTriggerWidth - minTriggerWidth) / 50,
0111 minTriggerWidth,
0112 maxTriggerWidth);
0113 TimeBoxes[make_pair(wheel, sector)]->setAxisTitle("TDC counts");
0114 }
0115
0116 void DTPreCalibrationTask::bookOccupancyPlot(DQMStore::IBooker &iBooker, int wheel, int sector) {
0117 stringstream wh;
0118 wh << wheel;
0119 stringstream sec;
0120 sec << sector;
0121
0122
0123 if (sector == 4 || sector == 10)
0124 OccupancyHistos[make_pair(wheel, sector)] = iBooker.book2D("Occupancy_W" + wh.str() + "_Sec" + sec.str(),
0125 "Occupancy W" + wh.str() + "_Sec" + sec.str(),
0126 100,
0127 1,
0128 100,
0129 52,
0130 1,
0131 53);
0132 else
0133 OccupancyHistos[make_pair(wheel, sector)] = iBooker.book2D("Occupancy_W" + wh.str() + "_Sec" + sec.str(),
0134 "Occupancy W" + wh.str() + "_Sec" + sec.str(),
0135 100,
0136 1,
0137 100,
0138 44,
0139 1,
0140 45);
0141 OccupancyHistos[make_pair(wheel, sector)]->setAxisTitle("wire number", 1);
0142 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(1, "M1L1", 2);
0143 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(2, "M1L2", 2);
0144 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(3, "M1L3", 2);
0145 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(4, "M1L4", 2);
0146 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(5, "M1L5", 2);
0147 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(6, "M1L6", 2);
0148 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(7, "M1L7", 2);
0149 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(8, "M1L8", 2);
0150 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(9, "M1L9", 2);
0151 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(10, "M1L10", 2);
0152 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(11, "M1L11", 2);
0153 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(12, "M1L12", 2);
0154 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(13, "M2L1", 2);
0155 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(14, "M2L2", 2);
0156 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(15, "M2L3", 2);
0157 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(16, "M2L4", 2);
0158 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(17, "M2L5", 2);
0159 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(18, "M2L6", 2);
0160 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(19, "M2L7", 2);
0161 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(20, "M2L8", 2);
0162 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(21, "M2L9", 2);
0163 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(22, "M2L10", 2);
0164 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(23, "M2L11", 2);
0165 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(24, "M2L12", 2);
0166 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(25, "M3L1", 2);
0167 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(26, "M3L2", 2);
0168 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(27, "M3L3", 2);
0169 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(28, "M3L4", 2);
0170 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(29, "M3L5", 2);
0171 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(30, "M3L6", 2);
0172 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(31, "M3L7", 2);
0173 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(32, "M3L8", 2);
0174 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(33, "M3L9", 2);
0175 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(34, "M3L10", 2);
0176 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(35, "M3L11", 2);
0177 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(36, "M3L12", 2);
0178 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(37, "M4L1", 2);
0179 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(38, "M4L2", 2);
0180 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(39, "M4L3", 2);
0181 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(40, "M4L4", 2);
0182 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(41, "M4L5", 2);
0183 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(42, "M4L6", 2);
0184 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(43, "M4L7", 2);
0185 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(44, "M4L8", 2);
0186 if (sector == 4) {
0187 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(45, "M4Sec13L1", 2);
0188 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(46, "M4Sec13L2", 2);
0189 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(47, "M4Sec13L3", 2);
0190 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(48, "M4Sec13L4", 2);
0191 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(49, "M4Sec13L5", 2);
0192 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(50, "M4Sec13L6", 2);
0193 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(51, "M4Sec13L7", 2);
0194 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(52, "M4Sec13L8", 2);
0195 }
0196 if (sector == 10) {
0197 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(45, "M4Sec14L1", 2);
0198 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(46, "M4Sec14L2", 2);
0199 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(47, "M4Sec14L3", 2);
0200 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(48, "M4Sec14L4", 2);
0201 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(49, "M4Sec14L5", 2);
0202 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(50, "M4Sec14L6", 2);
0203 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(51, "M4Sec14L7", 2);
0204 OccupancyHistos[make_pair(wheel, sector)]->setBinLabel(52, "M4Sec14L8", 2);
0205 }
0206 }