CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TDTTPGClient.cc
Go to the documentation of this file.
2 
11 #include "TRandom.h"
12 
13 #include <TF1.h>
14 #include <stdio.h>
15 #include <sstream>
16 #include <math.h>
17 #include <TProfile.h>
18 #include <TProfile2D.h>
19 
20 using namespace edm;
21 using namespace std;
22 
24 {
25  parameters_=ps;
26  initialize();
27 }
28 
30  LogInfo("TriggerDQM")<<"[TriggerDQM]: ending... ";
31 }
32 
33 //--------------------------------------------------------
35 
36  counterLS_=0;
37  counterEvt_=0;
38 
39  // get back-end interface
41 
42  // base folder for the contents of this job
43  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","");
44 // cout << "Monitor name = " << monitorName_ << endl;
45  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
46 // cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
47  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
48 // cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
49  output_dir_ = parameters_.getUntrackedParameter<string>("output_dir","");
50 // cout << "DQM output dir = " << output_dir_ << endl;
51  input_dir_ = parameters_.getUntrackedParameter<string>("input_dir","");
52 // cout << "DQM input dir = " << input_dir_ << endl;
53 
54  LogInfo( "TriggerDQM");
55 
56 
57 }
58 
59 //--------------------------------------------------------
61 
62  LogInfo("TriggerDQM")<<"[TriggerDQM]: Begin Job";
63 
64  // get backendinterface
66 
67  dbe_->setCurrentFolder(output_dir_);
68 
69  // booking
70 
71  dttpgphmapcorrf = dbe_->book2D("DT_TPG_phi_map_corr_frac",
72  "Fraction of correlated best triggers per station",20,1,21,12,0,12);
73  dttpgphmap2ndf = dbe_->book2D("DT_TPG_phi_map_2nd_frac",
74  "Fraction of second tracks per station",20,1,21,12,0,12);
75  dttpgphmapbxf[0] = dbe_->book2D("DT_TPG_phi_map_bx-1_frac",
76  "Fraction of triggers per station (BX=-1)",20,1,21,12,0,12);
77  dttpgphmapbxf[1] = dbe_->book2D("DT_TPG_phi_map_bx0_frac",
78  "Fraction of triggers per station (BX=0)",20,1,21,12,0,12);
79  dttpgphmapbxf[2] = dbe_->book2D("DT_TPG_phi_map_bx+1_frac",
80  "Fraction of triggers per station (BX=1)",20,1,21,12,0,12);
81  setMapPhLabel(dttpgphmapcorrf);
82  setMapPhLabel(dttpgphmap2ndf);
83  setMapPhLabel(dttpgphmapbxf[0]);
84  setMapPhLabel(dttpgphmapbxf[1]);
85  setMapPhLabel(dttpgphmapbxf[2]);
86 
87  dttpgthmaphf = dbe_->book2D("DT_TPG_theta_map_corr_frac",
88  "Fraction of H quality best triggers per station",15,1,16,12,0,12);
89  dttpgthmapbxf[0] = dbe_->book2D("DT_TPG_theta_map_bx-1_frac",
90  "Fraction of triggers per station (BX=-1)",15,1,16,12,0,12);
91  dttpgthmapbxf[1] = dbe_->book2D("DT_TPG_theta_map_bx0_frac",
92  "Fraction of triggers per station (BX=0)",15,1,16,12,0,12);
93  dttpgthmapbxf[2] = dbe_->book2D("DT_TPG_theta_map_bx+1_frac",
94  "Fraction of triggers per station (BX=1)",15,1,16,12,0,12);
95  setMapThLabel(dttpgthmaphf);
96  setMapThLabel(dttpgthmapbxf[0]);
97  setMapThLabel(dttpgthmapbxf[1]);
98  setMapThLabel(dttpgthmapbxf[2]);
99 
100 
101 
102 }
103 
104 //--------------------------------------------------------
105 void L1TDTTPGClient::beginRun(const Run& r, const EventSetup& context) {
106 }
107 
108 //--------------------------------------------------------
110  // optionally reset histograms here
111  // clientHisto->Reset();
112 }
113 //--------------------------------------------------------
114 
116  const edm::EventSetup& c){
117 
118 }
119 //--------------------------------------------------------
120 void L1TDTTPGClient::analyze(const Event& e, const EventSetup& context){
121 // cout << "L1TDTTPGClient::analyze" << endl;
122  counterEvt_++;
123  if (prescaleEvt_<1) return;
124  if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
125 
126  string nName = "DT_TPG_phi_best_map_corr";
127  string dName = "DT_TPG_phi_best_map";
128  makeRatioHisto(dttpgphmapcorrf,nName,dName);
129  dName = "DT_TPG_phi_map";
130  nName = "DT_TPG_phi_map_2nd";
131  makeRatioHisto(dttpgphmap2ndf,nName,dName);
132  nName = "DT_TPG_phi_map_bx-1";
133  makeRatioHisto(dttpgphmapbxf[0],nName,dName);
134  nName = "DT_TPG_phi_map_bx0";
135  makeRatioHisto(dttpgphmapbxf[1],nName,dName);
136  nName = "DT_TPG_phi_map_bx+1";
137  makeRatioHisto(dttpgphmapbxf[2],nName,dName);
138 
139  nName = "DT_TPG_theta_best_map_h";
140  dName = "DT_TPG_theta_best_map";
141  makeRatioHisto(dttpgthmaphf,nName,dName);
142  dName = "DT_TPG_theta_map";
143  nName = "DT_TPG_theta_map_bx-1";
144  makeRatioHisto(dttpgthmapbxf[0],nName,dName);
145  nName = "DT_TPG_theta_map_bx0";
146  makeRatioHisto(dttpgthmapbxf[1],nName,dName);
147  nName = "DT_TPG_theta_map_bx+1";
148  makeRatioHisto(dttpgthmapbxf[2],nName,dName);
149 
150 
151 }
152 
153 //--------------------------------------------------------
154 void L1TDTTPGClient::endRun(const Run& r, const EventSetup& context){
155 }
156 
157 //--------------------------------------------------------
159 }
160 
161 void L1TDTTPGClient::makeRatioHisto(MonitorElement *ratioME, string &nName, string &dName)
162 {
163 
164  TH2F *numerator;
165  TH2F *denominator;
166 
167  denominator = this->get2DHisto(input_dir_+"/"+dName,dbe_);
168  numerator = this->get2DHisto(input_dir_+"/"+nName,dbe_);
169 
170  if (numerator && denominator) {
171 
172  TH2F * ratio = ratioME->getTH2F();
173  if (ratio) {
174  ratio->Divide(numerator,denominator);
175  }
176  else {
177  LogInfo("TriggerDQM") << "[TriggerDQM]: ratio histo named \"" << ratioME->getName() << "\" not found!" << endl;
178  }
179  }
180  else {
181  if (!numerator)
182  LogInfo("TriggerDQM") << "[TriggerDQM]: numerator histo \"" << nName << "\" not found!" << endl;
183  if (!denominator)
184  LogInfo("TriggerDQM") << "[TriggerDQM]: denominator histo \"" << dName << "\" not found!" << endl;
185  }
186 
187 }
188 
189 TH1F * L1TDTTPGClient::get1DHisto(string meName, DQMStore * dbi)
190 {
191 
192  MonitorElement * me_ = dbi->get(meName);
193 
194  if (!me_) {
195  LogInfo("TriggerDQM") << "ME NOT FOUND.";
196  return NULL;
197  }
198 
199  return me_->getTH1F();
200 }
201 
202 TH2F * L1TDTTPGClient::get2DHisto(string meName, DQMStore * dbi)
203 {
204 
205 
206  MonitorElement * me_ = dbi->get(meName);
207 
208  if (!me_) {
209  LogInfo("TriggerDQM") << "ME NOT FOUND.";
210  return NULL;
211  }
212 
213  return me_->getTH2F();
214 }
215 
216 
217 
218 TProfile2D * L1TDTTPGClient::get2DProfile(string meName, DQMStore * dbi)
219 {
220 
221 
222  MonitorElement * me_ = dbi->get(meName);
223 
224  if (!me_) {
225  LogInfo("TriggerDQM") << "ME NOT FOUND.";
226  return NULL;
227  }
228 
229  return me_->getTProfile2D();
230 }
231 
232 
233 TProfile * L1TDTTPGClient::get1DProfile(string meName, DQMStore * dbi)
234 {
235 
236 
237  MonitorElement * me_ = dbi->get(meName);
238 
239  if (!me_) {
240  LogInfo("TriggerDQM") << "ME NOT FOUND.";
241  return NULL;
242  }
243 
244  return me_->getTProfile();
245 }
246 
247 
249 {
250 
251  me->setAxisTitle("DTTF Sector",2);
252  for(int i=0;i<5;i++){
253  ostringstream wheel;
254  wheel << i-2;
255  me->setBinLabel(1+i*4,"Wheel "+ wheel.str(),1);
256  }
257 
258 }
259 
260 
262 {
263 
264  me->setAxisTitle("DTTF Sector",2);
265  for(int i=0;i<5;i++){
266  ostringstream wheel;
267  wheel << i-2;
268  me->setBinLabel(1+i*3,"Wheel "+ wheel.str(),1);
269  }
270 
271 }
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic.
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void setMapThLabel(MonitorElement *me)
void makeRatioHisto(MonitorElement *ratioME, std::string &nName, std::string &dName)
TProfile2D * getTProfile2D(void) const
TProfile * get1DProfile(std::string meName, DQMStore *dbi)
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)
#define NULL
Definition: scimark2.h:8
void analyze(const edm::Event &e, const edm::EventSetup &c)
Fake Analyze.
virtual ~L1TDTTPGClient()
Destructor.
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
TH1F * get1DHisto(std::string meName, DQMStore *dbi)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
DQMStore * dbe_
void endJob()
Endjob.
L1TDTTPGClient(const edm::ParameterSet &ps)
Constructor.
TH1F * getTH1F(void) const
TProfile2D * get2DProfile(std::string meName, DQMStore *dbi)
TProfile * getTProfile(void) const
void setMapPhLabel(MonitorElement *me)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void beginJob(void)
BeginJob.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33