File indexing completed on 2024-04-06 12:07:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DQM/DTMonitorClient/src/DTLocalTriggerBaseTest.h"
0012
0013
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "DQMServices/Core/interface/DQMStore.h"
0017
0018
0019 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0020
0021
0022 #include "TF1.h"
0023 #include "TProfile.h"
0024
0025
0026 #include <iostream>
0027 #include <sstream>
0028
0029 using namespace edm;
0030 using namespace std;
0031
0032 DTLocalTriggerBaseTest::~DTLocalTriggerBaseTest() {
0033 LogVerbatim(category()) << "[" << testName << "Test]: analyzed " << nevents << " events";
0034 }
0035
0036 void DTLocalTriggerBaseTest::beginRun(edm::Run const& run, edm::EventSetup const& context) {
0037 nevents = 0;
0038 nLumiSegs = 0;
0039
0040 LogVerbatim(category()) << "[" << testName << "Test]: BeginRun";
0041 muonGeom = &context.getData(muonGeomToken_);
0042 }
0043
0044 void DTLocalTriggerBaseTest::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0045 DQMStore::IGetter& igetter,
0046 edm::LuminosityBlock const& lumiSeg,
0047 edm::EventSetup const& context) {
0048 if (!runOnline)
0049 return;
0050
0051 LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest")
0052 << "[" << testName << "Test]: End of LS transition, performing the DQM client operation";
0053
0054
0055 nLumiSegs++;
0056 if (nLumiSegs % prescaleFactor != 0)
0057 return;
0058
0059 LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest") << "[" << testName << "Test]: " << nLumiSegs << " updates";
0060
0061 runClientDiagnostic(ibooker, igetter);
0062 }
0063
0064 void DTLocalTriggerBaseTest::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0065 LogTrace(category()) << "[" << testName << "Test] endJob called!";
0066
0067 if (!runOnline) {
0068 LogVerbatim(category()) << "[" << testName << "Test] Client called in offline mode, performing client operations";
0069 runClientDiagnostic(ibooker, igetter);
0070 }
0071 }
0072
0073 void DTLocalTriggerBaseTest::endRun(Run const& run, EventSetup const& context) {
0074 LogTrace(category()) << "[" << testName << "Test] endRun called!";
0075 }
0076
0077 void DTLocalTriggerBaseTest::setConfig(const edm::ParameterSet& ps, string name) {
0078 testName = name;
0079
0080 LogTrace(category()) << "[" << testName << "Test]: Constructor";
0081
0082 sourceFolder = ps.getUntrackedParameter<string>("folderRoot", "");
0083 runOnline = ps.getUntrackedParameter<bool>("runOnline", true);
0084 hwSources = ps.getUntrackedParameter<vector<string> >("hwSources");
0085
0086 if (ps.getUntrackedParameter<bool>("localrun", true)) {
0087 trigSources.push_back("");
0088 } else {
0089 trigSources = ps.getUntrackedParameter<vector<string> >("trigSources");
0090 }
0091
0092 parameters = ps;
0093 nevents = 0;
0094
0095 prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
0096 }
0097
0098 string DTLocalTriggerBaseTest::fullName(string htype) { return hwSource + "_" + htype + trigSource; }
0099
0100 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, const DTChamberId& chambid) {
0101 stringstream wheel;
0102 wheel << chambid.wheel();
0103 stringstream station;
0104 station << chambid.station();
0105 stringstream sector;
0106 sector << chambid.sector();
0107
0108 string folderName = topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() + "/";
0109 if (!subfolder.empty()) {
0110 folderName += subfolder + "/";
0111 }
0112
0113 string histoname = sourceFolder + folderName + fullName(histoTag) + "_W" + wheel.str() + "_Sec" + sector.str() +
0114 "_St" + station.str();
0115
0116 return histoname;
0117 }
0118
0119 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, int wh) {
0120 stringstream wheel;
0121 wheel << wh;
0122
0123 string folderName = topFolder() + "Wheel" + wheel.str() + "/";
0124 if (!subfolder.empty()) {
0125 folderName += subfolder + "/";
0126 }
0127
0128 string histoname = sourceFolder + folderName + fullName(histoTag) + "_W" + wheel.str();
0129
0130 return histoname;
0131 }
0132
0133 void DTLocalTriggerBaseTest::bookSectorHistos(
0134 DQMStore::IBooker& ibooker, int wheel, int sector, string hTag, string folder) {
0135 stringstream wh;
0136 wh << wheel;
0137 stringstream sc;
0138 sc << sector;
0139 int sectorid = (wheel + 3) + (sector - 1) * 5;
0140 string basedir = topFolder() + "Wheel" + wh.str() + "/Sector" + sc.str() + "/";
0141 if (!folder.empty()) {
0142 basedir += folder + "/";
0143 }
0144
0145 ibooker.setCurrentFolder(basedir);
0146
0147 string fullTag = fullName(hTag);
0148 string hname = fullTag + "_W" + wh.str() + "_Sec" + sc.str();
0149 LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
0150 if (hTag.find("BXDistribPhi") != string::npos) {
0151 MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 25, -4.5, 20.5, 4, 0.5, 4.5);
0152 me->setBinLabel(1, "MB1", 2);
0153 me->setBinLabel(2, "MB2", 2);
0154 me->setBinLabel(3, "MB3", 2);
0155 me->setBinLabel(4, "MB4", 2);
0156 secME[sectorid][fullTag] = me;
0157 return;
0158 } else if (hTag.find("QualDistribPhi") != string::npos) {
0159 MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 7, -0.5, 6.5, 4, 0.5, 4.5);
0160 me->setBinLabel(1, "MB1", 2);
0161 me->setBinLabel(2, "MB2", 2);
0162 me->setBinLabel(3, "MB3", 2);
0163 me->setBinLabel(4, "MB4", 2);
0164 me->setBinLabel(1, "LI", 1);
0165 me->setBinLabel(2, "LO", 1);
0166 me->setBinLabel(3, "HI", 1);
0167 me->setBinLabel(4, "HO", 1);
0168 me->setBinLabel(5, "LL", 1);
0169 me->setBinLabel(6, "HL", 1);
0170 me->setBinLabel(7, "HH", 1);
0171 secME[sectorid][fullTag] = me;
0172 return;
0173 } else if (hTag.find("Phi") != string::npos || hTag.find("TkvsTrig") != string::npos) {
0174 MonitorElement* me = ibooker.book1D(hname.c_str(), hname.c_str(), 4, 0.5, 4.5);
0175 me->setBinLabel(1, "MB1", 1);
0176 me->setBinLabel(2, "MB2", 1);
0177 me->setBinLabel(3, "MB3", 1);
0178 me->setBinLabel(4, "MB4", 1);
0179 secME[sectorid][fullTag] = me;
0180 return;
0181 }
0182
0183 if (hTag.find("Theta") != string::npos) {
0184 MonitorElement* me = ibooker.book1D(hname.c_str(), hname.c_str(), 3, 0.5, 3.5);
0185 me->setBinLabel(1, "MB1", 1);
0186 me->setBinLabel(2, "MB2", 1);
0187 me->setBinLabel(3, "MB3", 1);
0188 secME[sectorid][fullTag] = me;
0189 return;
0190 }
0191 }
0192
0193 void DTLocalTriggerBaseTest::bookCmsHistos(DQMStore::IBooker& ibooker, string hTag, string folder, bool isGlb) {
0194 string basedir = topFolder();
0195 if (!folder.empty()) {
0196 basedir += folder + "/";
0197 }
0198
0199 ibooker.setCurrentFolder(basedir);
0200
0201 string hname = isGlb ? hTag : fullName(hTag);
0202 LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
0203
0204 MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 5, -2, 3);
0205 me->setAxisTitle("Sector", 1);
0206 me->setAxisTitle("Wheel", 2);
0207 cmsME[hname] = me;
0208 }
0209
0210 void DTLocalTriggerBaseTest::bookWheelHistos(DQMStore::IBooker& ibooker, int wheel, string hTag, string folder) {
0211 stringstream wh;
0212 wh << wheel;
0213 string basedir;
0214 if (hTag.find("Summary") != string::npos) {
0215 basedir = topFolder();
0216 } else {
0217 basedir = topFolder() + "Wheel" + wh.str() + "/";
0218 }
0219 if (!folder.empty()) {
0220 basedir += folder + "/";
0221 }
0222
0223 ibooker.setCurrentFolder(basedir);
0224
0225 string fullTag = fullName(hTag);
0226 string hname = fullTag + "_W" + wh.str();
0227
0228 LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
0229
0230 if (hTag.find("Phi") != string::npos || hTag.find("Summary") != string::npos) {
0231 MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 4, 1, 5);
0232
0233
0234 me->setBinLabel(1, "MB1", 2);
0235 me->setBinLabel(2, "MB2", 2);
0236 me->setBinLabel(3, "MB3", 2);
0237 me->setBinLabel(4, "MB4", 2);
0238 me->setAxisTitle("Sector", 1);
0239
0240 whME[wheel][fullTag] = me;
0241 return;
0242 }
0243
0244 if (hTag.find("Theta") != string::npos) {
0245 MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 3, 1, 4);
0246
0247
0248 me->setBinLabel(1, "MB1", 2);
0249 me->setBinLabel(2, "MB2", 2);
0250 me->setBinLabel(3, "MB3", 2);
0251 me->setAxisTitle("Sector", 1);
0252
0253 whME[wheel][fullTag] = me;
0254 return;
0255 }
0256 }
0257
0258 pair<float, float> DTLocalTriggerBaseTest::phiRange(const DTChamberId& id) {
0259 float min, max;
0260 int station = id.station();
0261 int sector = id.sector();
0262 int wheel = id.wheel();
0263
0264 const DTLayer* layer = muonGeom->layer(DTLayerId(id, 1, 1));
0265 const DTTopology& topo = layer->specificTopology();
0266 min = topo.wirePosition(topo.firstChannel());
0267 max = topo.wirePosition(topo.lastChannel());
0268
0269 if (station == 4) {
0270 const DTLayer* layer2;
0271 float lposx;
0272
0273 if (sector == 4) {
0274 layer2 = muonGeom->layer(DTLayerId(wheel, station, 13, 1, 1));
0275 lposx = layer->toLocal(layer2->position()).x();
0276 } else if (sector == 10) {
0277 layer2 = muonGeom->layer(DTLayerId(wheel, station, 14, 1, 1));
0278 lposx = layer->toLocal(layer2->position()).x();
0279 } else
0280 return make_pair(min, max);
0281
0282 DTTopology topo2 = layer2->specificTopology();
0283
0284 if (lposx > 0) {
0285 max = lposx * .5 + topo2.wirePosition(topo2.lastChannel());
0286 min -= lposx * .5;
0287 } else {
0288 min = lposx * .5 + topo2.wirePosition(topo2.firstChannel());
0289 max -= lposx * .5;
0290 }
0291 }
0292
0293 return make_pair(min, max);
0294 }