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