CMS 3D CMS Logo

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