CMS 3D CMS Logo

DTLocalTriggerBaseTest.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author C. Battilana S. Marcellini - INFN Bologna
5  *
6  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah ncpp-um-my
7  *
8  */
9 
10 // This class header
12 
13 // Framework headers
17 
18 // Geometry
21 
22 // Root
23 #include "TF1.h"
24 #include "TProfile.h"
25 
26 //C++ headers
27 #include <iostream>
28 #include <sstream>
29 
30 using namespace edm;
31 using namespace std;
32 
34  LogVerbatim(category()) << "[" << testName << "Test]: analyzed " << nevents << " events";
35 }
36 
38  nevents = 0;
39  nLumiSegs = 0;
40 
41  LogVerbatim(category()) << "[" << testName << "Test]: BeginRun";
42  context.get<MuonGeometryRecord>().get(muonGeom);
43 }
44 
46  DQMStore::IGetter& igetter,
47  edm::LuminosityBlock const& lumiSeg,
48  edm::EventSetup const& context) {
49  if (!runOnline)
50  return;
51 
52  LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest")
53  << "[" << testName << "Test]: End of LS transition, performing the DQM client operation";
54 
55  // counts number of lumiSegs and prescale
56  nLumiSegs++;
57  if (nLumiSegs % prescaleFactor != 0)
58  return;
59 
60  LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest") << "[" << testName << "Test]: " << nLumiSegs << " updates";
61 
62  runClientDiagnostic(ibooker, igetter);
63 }
64 
66  LogTrace(category()) << "[" << testName << "Test] endJob called!";
67 
68  if (!runOnline) {
69  LogVerbatim(category()) << "[" << testName << "Test] Client called in offline mode, performing client operations";
70  runClientDiagnostic(ibooker, igetter);
71  }
72 }
73 
74 void DTLocalTriggerBaseTest::endRun(Run const& run, EventSetup const& context) {
75  LogTrace(category()) << "[" << testName << "Test] endRun called!";
76 }
77 
79  testName = name;
80 
81  LogTrace(category()) << "[" << testName << "Test]: Constructor";
82 
83  sourceFolder = ps.getUntrackedParameter<string>("folderRoot", "");
84  runOnline = ps.getUntrackedParameter<bool>("runOnline", true);
85  hwSources = ps.getUntrackedParameter<vector<string> >("hwSources");
86 
87  if (ps.getUntrackedParameter<bool>("localrun", true)) {
88  trigSources.push_back("");
89  } else {
90  trigSources = ps.getUntrackedParameter<vector<string> >("trigSources");
91  }
92 
93  parameters = ps;
94  nevents = 0;
95 
96  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
97 }
98 
99 string DTLocalTriggerBaseTest::fullName(string htype) { return hwSource + "_" + htype + trigSource; }
100 
101 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, const DTChamberId& chambid) {
102  stringstream wheel;
103  wheel << chambid.wheel();
104  stringstream station;
105  station << chambid.station();
106  stringstream sector;
107  sector << chambid.sector();
108 
109  string folderName = topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() + "/";
110  if (!subfolder.empty()) {
111  folderName += subfolder + "/";
112  }
113 
114  string histoname = sourceFolder + folderName + fullName(histoTag) + "_W" + wheel.str() + "_Sec" + sector.str() +
115  "_St" + station.str();
116 
117  return histoname;
118 }
119 
120 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, int wh) {
121  stringstream wheel;
122  wheel << wh;
123 
124  string folderName = topFolder() + "Wheel" + wheel.str() + "/";
125  if (!subfolder.empty()) {
126  folderName += subfolder + "/";
127  }
128 
129  string histoname = sourceFolder + folderName + fullName(histoTag) + "_W" + wheel.str();
130 
131  return histoname;
132 }
133 
135  DQMStore::IBooker& ibooker, int wheel, int sector, string hTag, string folder) {
136  stringstream wh;
137  wh << wheel;
138  stringstream sc;
139  sc << sector;
140  int sectorid = (wheel + 3) + (sector - 1) * 5;
141  string basedir = topFolder() + "Wheel" + wh.str() + "/Sector" + sc.str() + "/";
142  if (!folder.empty()) {
143  basedir += folder + "/";
144  }
145 
146  ibooker.setCurrentFolder(basedir);
147 
148  string fullTag = fullName(hTag);
149  string hname = fullTag + "_W" + wh.str() + "_Sec" + sc.str();
150  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
151  if (hTag.find("BXDistribPhi") != string::npos) {
152  MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 25, -4.5, 20.5, 4, 0.5, 4.5);
153  me->setBinLabel(1, "MB1", 2);
154  me->setBinLabel(2, "MB2", 2);
155  me->setBinLabel(3, "MB3", 2);
156  me->setBinLabel(4, "MB4", 2);
157  secME[sectorid][fullTag] = me;
158  return;
159  } else if (hTag.find("QualDistribPhi") != string::npos) {
160  MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 7, -0.5, 6.5, 4, 0.5, 4.5);
161  me->setBinLabel(1, "MB1", 2);
162  me->setBinLabel(2, "MB2", 2);
163  me->setBinLabel(3, "MB3", 2);
164  me->setBinLabel(4, "MB4", 2);
165  me->setBinLabel(1, "LI", 1);
166  me->setBinLabel(2, "LO", 1);
167  me->setBinLabel(3, "HI", 1);
168  me->setBinLabel(4, "HO", 1);
169  me->setBinLabel(5, "LL", 1);
170  me->setBinLabel(6, "HL", 1);
171  me->setBinLabel(7, "HH", 1);
172  secME[sectorid][fullTag] = me;
173  return;
174  } else if (hTag.find("Phi") != string::npos || hTag.find("TkvsTrig") != string::npos) {
175  MonitorElement* me = ibooker.book1D(hname.c_str(), hname.c_str(), 4, 0.5, 4.5);
176  me->setBinLabel(1, "MB1", 1);
177  me->setBinLabel(2, "MB2", 1);
178  me->setBinLabel(3, "MB3", 1);
179  me->setBinLabel(4, "MB4", 1);
180  secME[sectorid][fullTag] = me;
181  return;
182  }
183 
184  if (hTag.find("Theta") != string::npos) {
185  MonitorElement* me = ibooker.book1D(hname.c_str(), hname.c_str(), 3, 0.5, 3.5);
186  me->setBinLabel(1, "MB1", 1);
187  me->setBinLabel(2, "MB2", 1);
188  me->setBinLabel(3, "MB3", 1);
189  secME[sectorid][fullTag] = me;
190  return;
191  }
192 }
193 
194 void DTLocalTriggerBaseTest::bookCmsHistos(DQMStore::IBooker& ibooker, string hTag, string folder, bool isGlb) {
195  string basedir = topFolder();
196  if (!folder.empty()) {
197  basedir += folder + "/";
198  }
199 
200  ibooker.setCurrentFolder(basedir);
201 
202  string hname = isGlb ? hTag : fullName(hTag);
203  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
204 
205  MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 5, -2, 3);
206  me->setAxisTitle("Sector", 1);
207  me->setAxisTitle("Wheel", 2);
208  cmsME[hname] = me;
209 }
210 
211 void DTLocalTriggerBaseTest::bookWheelHistos(DQMStore::IBooker& ibooker, int wheel, string hTag, string folder) {
212  stringstream wh;
213  wh << wheel;
214  string basedir;
215  if (hTag.find("Summary") != string::npos) {
216  basedir = topFolder(); //Book summary histo outside wheel directories
217  } else {
218  basedir = topFolder() + "Wheel" + wh.str() + "/";
219  }
220  if (!folder.empty()) {
221  basedir += folder + "/";
222  }
223 
224  ibooker.setCurrentFolder(basedir);
225 
226  string fullTag = fullName(hTag);
227  string hname = fullTag + "_W" + wh.str();
228 
229  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
230 
231  if (hTag.find("Phi") != string::npos || hTag.find("Summary") != string::npos) {
232  MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 4, 1, 5);
233 
234  // setLabelPh(me);
235  me->setBinLabel(1, "MB1", 2);
236  me->setBinLabel(2, "MB2", 2);
237  me->setBinLabel(3, "MB3", 2);
238  me->setBinLabel(4, "MB4", 2);
239  me->setAxisTitle("Sector", 1);
240 
241  whME[wheel][fullTag] = me;
242  return;
243  }
244 
245  if (hTag.find("Theta") != string::npos) {
246  MonitorElement* me = ibooker.book2D(hname.c_str(), hname.c_str(), 12, 1, 13, 3, 1, 4);
247 
248  // setLabelTh(me);
249  me->setBinLabel(1, "MB1", 2);
250  me->setBinLabel(2, "MB2", 2);
251  me->setBinLabel(3, "MB3", 2);
252  me->setAxisTitle("Sector", 1);
253 
254  whME[wheel][fullTag] = me;
255  return;
256  }
257 }
258 
259 pair<float, float> DTLocalTriggerBaseTest::phiRange(const DTChamberId& id) {
260  float min, max;
261  int station = id.station();
262  int sector = id.sector();
263  int wheel = id.wheel();
264 
265  const DTLayer* layer = muonGeom->layer(DTLayerId(id, 1, 1));
266  const DTTopology& topo = layer->specificTopology();
267  min = topo.wirePosition(topo.firstChannel());
268  max = topo.wirePosition(topo.lastChannel());
269 
270  if (station == 4) {
271  const DTLayer* layer2;
272  float lposx;
273 
274  if (sector == 4) {
275  layer2 = muonGeom->layer(DTLayerId(wheel, station, 13, 1, 1));
276  lposx = layer->toLocal(layer2->position()).x();
277  } else if (sector == 10) {
278  layer2 = muonGeom->layer(DTLayerId(wheel, station, 14, 1, 1));
279  lposx = layer->toLocal(layer2->position()).x();
280  } else
281  return make_pair(min, max);
282 
283  DTTopology topo2 = layer2->specificTopology();
284 
285  if (lposx > 0) {
286  max = lposx * .5 + topo2.wirePosition(topo2.lastChannel());
287  min -= lposx * .5;
288  } else {
289  min = lposx * .5 + topo2.wirePosition(topo2.firstChannel());
290  max -= lposx * .5;
291  }
292  }
293 
294  return make_pair(min, max);
295 }
GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3177
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
DTLocalTriggerBaseTest::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTLocalTriggerBaseTest.cc:65
dtDQMOfflineClients_cff.runOnline
runOnline
Definition: dtDQMOfflineClients_cff.py:6
MessageLogger.h
DTLocalTriggerBaseTest::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
Definition: DTLocalTriggerBaseTest.cc:37
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
printsummarytable.folder
folder
Definition: printsummarytable.py:7
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
edm::min
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:116
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
DTLocalTriggerBaseTest::fullName
std::string fullName(std::string htype)
Create fullname from histo partial name.
Definition: DTLocalTriggerBaseTest.cc:99
DTLocalTriggerBaseTest::getMEName
std::string getMEName(std::string histoTag, std::string subfolder, const DTChamberId &chambid)
Get the ME name (by chamber)
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTLocalTriggerBaseTest::bookCmsHistos
void bookCmsHistos(DQMStore::IBooker &, std::string hTag, std::string folder="", bool isGlb=false)
Book the new MEs (CMS summary)
Definition: DTLocalTriggerBaseTest.cc:194
DTLocalTriggerBaseTest::phiRange
std::pair< float, float > phiRange(const DTChamberId &id)
Calculate phi range for histograms.
Definition: DTLocalTriggerBaseTest.cc:259
DTTopology
Definition: DTTopology.h:28
DTLocalTriggerBaseTest::setConfig
void setConfig(const edm::ParameterSet &ps, std::string name)
Set configuration variables.
Definition: DTLocalTriggerBaseTest.cc:78
DTTopology::wirePosition
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DTLocalTriggerBaseTest::~DTLocalTriggerBaseTest
~DTLocalTriggerBaseTest() override
Destructor.
Definition: DTLocalTriggerBaseTest.cc:33
DTTopology::firstChannel
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
DTLocalTriggerBaseTest.h
L1TBPTX_cfi.testName
testName
Definition: L1TBPTX_cfi.py:24
DTLocalTriggerBaseTest::bookSectorHistos
void bookSectorHistos(DQMStore::IBooker &, int wheel, int sector, std::string hTag, std::string folder="")
Book the new MEs (for each sector)
Definition: DTLocalTriggerBaseTest.cc:134
makeHippyCampaign.basedir
basedir
Definition: makeHippyCampaign.py:14
DTLayerId
Definition: DTLayerId.h:12
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
newFWLiteAna.fullName
fullName
Definition: newFWLiteAna.py:122
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
dtResolutionTest_cfi.histoTag
histoTag
Definition: dtResolutionTest_cfi.py:21
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:675
dtFineDelayCorr_cfi.hwSource
hwSource
Definition: dtFineDelayCorr_cfi.py:26
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
Skims_PDWG_cff.prescaleFactor
prescaleFactor
Definition: Skims_PDWG_cff.py:25
dtFineDelayCorr_cfi.hwSources
hwSources
Definition: dtFineDelayCorr_cfi.py:9
edm::EventSetup
Definition: EventSetup.h:58
DTLocalTriggerBaseTest::bookWheelHistos
void bookWheelHistos(DQMStore::IBooker &, int wheel, std::string hTag, std::string folder="")
Book the new MEs (for each wheel)
Definition: DTLocalTriggerBaseTest.cc:211
DTLayer
Definition: DTLayer.h:25
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
DTTopology::lastChannel
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTLayer::specificTopology
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
MuonGeometryRecord.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DTLocalTriggerBaseTest::endRun
void endRun(edm::Run const &run, edm::EventSetup const &context) override
Perform client diagnostic in offline.
Definition: DTLocalTriggerBaseTest.cc:74
DTLocalTriggerBaseTest::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Perform client diagnostic in online.
Definition: DTLocalTriggerBaseTest.cc:45