CMS 3D CMS Logo

L1TDTTPGClient.cc
Go to the documentation of this file.
2 
9 #include "TRandom.h"
10 
11 #include <TF1.h>
12 #include <cstdio>
13 #include <sstream>
14 #include <cmath>
15 #include <TProfile.h>
16 #include <TProfile2D.h>
17 
18 using namespace edm;
19 using namespace std;
20 
22  parameters_ = ps;
23  initialize();
24 }
25 
26 L1TDTTPGClient::~L1TDTTPGClient() { LogInfo("TriggerDQM") << "[TriggerDQM]: ending... "; }
27 
28 //--------------------------------------------------------
30  counterLS_ = 0;
31  counterEvt_ = 0;
32 
33  // get back-end interface
34  //dbe_ = Service<DQMStore>().operator->();
35 
36  // base folder for the contents of this job
37  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName", "");
38  // cout << "Monitor name = " << monitorName_ << endl;
39  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
40  // cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
41  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
42  // cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
43  output_dir_ = parameters_.getUntrackedParameter<string>("output_dir", "");
44  // cout << "DQM output dir = " << output_dir_ << endl;
45  input_dir_ = parameters_.getUntrackedParameter<string>("input_dir", "");
46  // cout << "DQM input dir = " << input_dir_ << endl;
47 
48  LogInfo("TriggerDQM");
49 }
50 
51 //--------------------------------------------------------
53  ibooker.setCurrentFolder(output_dir_);
54 
55  // booking
56 
57  dttpgphmapcorrf = ibooker.book2D(
58  "DT_TPG_phi_map_corr_frac", "Fraction of correlated best triggers per station", 20, 1, 21, 12, 0, 12);
59  dttpgphmap2ndf =
60  ibooker.book2D("DT_TPG_phi_map_2nd_frac", "Fraction of second tracks per station", 20, 1, 21, 12, 0, 12);
61  dttpgphmapbxf[0] =
62  ibooker.book2D("DT_TPG_phi_map_bx-1_frac", "Fraction of triggers per station (BX=-1)", 20, 1, 21, 12, 0, 12);
63  dttpgphmapbxf[1] =
64  ibooker.book2D("DT_TPG_phi_map_bx0_frac", "Fraction of triggers per station (BX=0)", 20, 1, 21, 12, 0, 12);
65  dttpgphmapbxf[2] =
66  ibooker.book2D("DT_TPG_phi_map_bx+1_frac", "Fraction of triggers per station (BX=1)", 20, 1, 21, 12, 0, 12);
67  setMapPhLabel(dttpgphmapcorrf);
68  setMapPhLabel(dttpgphmap2ndf);
69  setMapPhLabel(dttpgphmapbxf[0]);
70  setMapPhLabel(dttpgphmapbxf[1]);
71  setMapPhLabel(dttpgphmapbxf[2]);
72 
73  dttpgthmaphf = ibooker.book2D(
74  "DT_TPG_theta_map_corr_frac", "Fraction of H quality best triggers per station", 15, 1, 16, 12, 0, 12);
75  dttpgthmapbxf[0] =
76  ibooker.book2D("DT_TPG_theta_map_bx-1_frac", "Fraction of triggers per station (BX=-1)", 15, 1, 16, 12, 0, 12);
77  dttpgthmapbxf[1] =
78  ibooker.book2D("DT_TPG_theta_map_bx0_frac", "Fraction of triggers per station (BX=0)", 15, 1, 16, 12, 0, 12);
79  dttpgthmapbxf[2] =
80  ibooker.book2D("DT_TPG_theta_map_bx+1_frac", "Fraction of triggers per station (BX=1)", 15, 1, 16, 12, 0, 12);
81  setMapThLabel(dttpgthmaphf);
82  setMapThLabel(dttpgthmapbxf[0]);
83  setMapThLabel(dttpgthmapbxf[1]);
84  setMapThLabel(dttpgthmapbxf[2]);
85 
86  // cout << "L1TDTTPGClient::analyze" << endl;
87  counterEvt_++;
88  if (prescaleEvt_ < 1)
89  return;
90  if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
91  return;
92 
93  string nName = "DT_TPG_phi_best_map_corr";
94  string dName = "DT_TPG_phi_best_map";
95  makeRatioHisto(igetter, dttpgphmapcorrf, nName, dName);
96  dName = "DT_TPG_phi_map";
97  nName = "DT_TPG_phi_map_2nd";
98  makeRatioHisto(igetter, dttpgphmap2ndf, nName, dName);
99  nName = "DT_TPG_phi_map_bx-1";
100  makeRatioHisto(igetter, dttpgphmapbxf[0], nName, dName);
101  nName = "DT_TPG_phi_map_bx0";
102  makeRatioHisto(igetter, dttpgphmapbxf[1], nName, dName);
103  nName = "DT_TPG_phi_map_bx+1";
104  makeRatioHisto(igetter, dttpgphmapbxf[2], nName, dName);
105 
106  nName = "DT_TPG_theta_best_map_h";
107  dName = "DT_TPG_theta_best_map";
108  makeRatioHisto(igetter, dttpgthmaphf, nName, dName);
109  dName = "DT_TPG_theta_map";
110  nName = "DT_TPG_theta_map_bx-1";
111  makeRatioHisto(igetter, dttpgthmapbxf[0], nName, dName);
112  nName = "DT_TPG_theta_map_bx0";
113  makeRatioHisto(igetter, dttpgthmapbxf[1], nName, dName);
114  nName = "DT_TPG_theta_map_bx+1";
115  makeRatioHisto(igetter, dttpgthmapbxf[2], nName, dName);
116 }
117 
118 void L1TDTTPGClient::makeRatioHisto(DQMStore::IGetter &igetter, MonitorElement *ratioME, string &nName, string &dName) {
119  TH2F *numerator;
120  TH2F *denominator;
121 
122  denominator = this->get2DHisto(input_dir_ + "/" + dName, igetter);
123  numerator = this->get2DHisto(input_dir_ + "/" + nName, igetter);
124 
125  if (numerator && denominator) {
126  TH2F *ratio = ratioME->getTH2F();
127  if (ratio) {
128  ratio->Divide(numerator, denominator);
129  } else {
130  LogInfo("TriggerDQM") << "[TriggerDQM]: ratio histo named \"" << ratioME->getName() << "\" not found!" << endl;
131  }
132  } else {
133  if (!numerator)
134  LogInfo("TriggerDQM") << "[TriggerDQM]: numerator histo \"" << nName << "\" not found!" << endl;
135  if (!denominator)
136  LogInfo("TriggerDQM") << "[TriggerDQM]: denominator histo \"" << dName << "\" not found!" << endl;
137  }
138 }
139 
140 TH1F *L1TDTTPGClient::get1DHisto(string meName, DQMStore::IGetter &igetter) {
141  MonitorElement *me_ = igetter.get(meName);
142 
143  if (!me_) {
144  LogInfo("TriggerDQM") << "ME NOT FOUND.";
145  return nullptr;
146  }
147 
148  return me_->getTH1F();
149 }
150 
151 TH2F *L1TDTTPGClient::get2DHisto(string meName, DQMStore::IGetter &igetter) {
152  MonitorElement *me_ = igetter.get(meName);
153 
154  if (!me_) {
155  LogInfo("TriggerDQM") << "ME NOT FOUND.";
156  return nullptr;
157  }
158 
159  return me_->getTH2F();
160 }
161 
162 TProfile2D *L1TDTTPGClient::get2DProfile(string meName, DQMStore::IGetter &igetter) {
163  MonitorElement *me_ = igetter.get(meName);
164 
165  if (!me_) {
166  LogInfo("TriggerDQM") << "ME NOT FOUND.";
167  return nullptr;
168  }
169 
170  return me_->getTProfile2D();
171 }
172 
173 TProfile *L1TDTTPGClient::get1DProfile(string meName, DQMStore::IGetter &igetter) {
174  MonitorElement *me_ = igetter.get(meName);
175 
176  if (!me_) {
177  LogInfo("TriggerDQM") << "ME NOT FOUND.";
178  return nullptr;
179  }
180 
181  return me_->getTProfile();
182 }
183 
185  me->setAxisTitle("DTTF Sector", 2);
186  for (int i = 0; i < 5; i++) {
187  ostringstream wheel;
188  wheel << i - 2;
189  me->setBinLabel(1 + i * 4, "Wheel " + wheel.str(), 1);
190  }
191 }
192 
194  me->setAxisTitle("DTTF Sector", 2);
195  for (int i = 0; i < 5; i++) {
196  ostringstream wheel;
197  wheel << i - 2;
198  me->setBinLabel(1 + i * 3, "Wheel " + wheel.str(), 1);
199  }
200 }
static AlgebraicMatrix initialize()
virtual TProfile * getTProfile() const
void setMapThLabel(MonitorElement *me)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
TProfile * get1DProfile(std::string meName, DQMStore::IGetter &igetter)
TH1F * get1DHisto(std::string meName, DQMStore::IGetter &igetter)
TProfile2D * get2DProfile(std::string meName, DQMStore::IGetter &igetter)
virtual TH2F * getTH2F() const
TH2F * get2DHisto(std::string meName, DQMStore::IGetter &igetter)
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
~L1TDTTPGClient() override
Destructor.
Log< level::Info, false > LogInfo
L1TDTTPGClient(const edm::ParameterSet &ps)
Constructor.
virtual TH1F * getTH1F() const
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
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
void makeRatioHisto(DQMStore::IGetter &igetter, MonitorElement *ratioME, std::string &nName, std::string &dName)
const std::string & getName() const
get name of ME
HLT enums.
void setMapPhLabel(MonitorElement *me)
virtual TProfile2D * getTProfile2D() const