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