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