Belle II Software development
TRGCDCT3DDQMModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//---------------------------------------------------------------
9// $Id$
10//---------------------------------------------------------------
11// Filename : TRGCDCT3DModule.cc
12// Section : TRG CDCT3D
13// Owner :
14// Email :
15//---------------------------------------------------------------
16// Description : A trigger module for TRG CDCT3D
17//---------------------------------------------------------------
18// 1.00 : 2017/05/08 : First version
19//---------------------------------------------------------------
20#include <trg/cdc/modules/trgcdct3dDQM/TRGCDCT3DDQMModule.h>
21
22#include <framework/datastore/StoreObjPtr.h>
23#include <framework/datastore/StoreArray.h>
24
25#include <TDirectory.h>
26#include <TPostScript.h>
27#include <TCanvas.h>
28#include <iostream>
29
30using namespace std;
31using namespace Belle2;
32
33REG_MODULE(TRGCDCT3DDQM);
34
35
37{
38
39 setDescription("DQM for CDCT3D Trigger system");
41
42 addParam("T3DMOD", m_T3DMOD,
43 "T3D module number",
44 0);
45 addParam("generatePostscript", m_generatePostscript,
46 "Genarete postscript file or not",
47 false);
48 addParam("postScriptName", m_postScriptName,
49 "postscript file name",
50 string("cdct3ddqm.ps"));
51
52
53}
54
56{
57 oldDir = gDirectory;
58 dirDQM = NULL;
59 //dirDQM = oldDir->mkdir("TRGCDCT3D");
60 if (!oldDir->Get("TRGCDCT3D"))dirDQM = oldDir->mkdir("TRGCDCT3D");
61 else dirDQM = (TDirectory*)oldDir->Get("TRGCDCT3D");
62 dirDQM->cd();
63 //dz distribution
64 h_dz = new TH1D(Form("hdz_mod%d", m_T3DMOD), Form("hdz_mod%d", m_T3DMOD), 80, -40, 40);
65 h_dz->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
66 h_dz->GetXaxis()->SetTitle("dz");
67 //phi distribution
68 h_phi = new TH1D(Form("hphi_mod%d", m_T3DMOD), Form("hphi_mod%d", m_T3DMOD), 100, -6, 6);
69 h_phi->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
70 h_phi->GetXaxis()->SetTitle("phi");
71 //tanlambda distribution
72 h_tanlambda = new TH1D(Form("htanlambda_mod%d", m_T3DMOD), Form("htanlambda_mod%d", m_T3DMOD), 100, -2.5, 2.5);
73 h_tanlambda->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
74 h_tanlambda->GetXaxis()->SetTitle("tanlambda");
75 //pt distribution
76 h_pt = new TH1D(Form("hpt_mod%d", m_T3DMOD), Form("hpt_mod%d", m_T3DMOD), 100, 0, 3);
77 h_pt->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
78 h_pt->GetXaxis()->SetTitle("pt");
79
80 //2D phi distribution
81 h_phi_2D = new TH1D(Form("hphi_2D_mod%d", m_T3DMOD), Form("hphi_2D_mod%d", m_T3DMOD), 100, -6, 6);
82 h_phi_2D->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
83 h_phi_2D->GetXaxis()->SetTitle("phi_2D");
84 //2D pt distribution
85 h_pt_2D = new TH1D(Form("hpt_2D_mod%d", m_T3DMOD), Form("hpt_2D_mod%d", m_T3DMOD), 100, 0, 3);
86 h_pt_2D->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
87 h_pt_2D->GetXaxis()->SetTitle("pt_2D");
88 //TSF1 ID
89 h_ID_TSF1 = new TH1D(Form("hID_TSF1_mod%d", m_T3DMOD), Form("hID_TSF1_mod%d", m_T3DMOD), 160, 160, 319);
90 h_ID_TSF1->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
91 h_ID_TSF1->GetXaxis()->SetTitle("ID_TSF1");
92 //TSF3 ID
93 h_ID_TSF3 = new TH1D(Form("hID_TSF3_mod%d", m_T3DMOD), Form("hID_TSF3_mod%d", m_T3DMOD), 224, 512, 735);
94 h_ID_TSF3->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
95 h_ID_TSF3->GetXaxis()->SetTitle("ID_TSF3");
96 //TSF5 ID
97 h_ID_TSF5 = new TH1D(Form("hID_TSF5_mod%d", m_T3DMOD), Form("hID_TSF5_mod%d", m_T3DMOD), 288, 992, 1279);
98 h_ID_TSF5->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
99 h_ID_TSF5->GetXaxis()->SetTitle("ID_TSF5");
100 //TSF7 ID
101 h_ID_TSF7 = new TH1D(Form("hID_TSF7_mod%d", m_T3DMOD), Form("hID_TSF7_mod%d", m_T3DMOD), 352, 1600, 1951);
102 h_ID_TSF7->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
103 h_ID_TSF7->GetXaxis()->SetTitle("ID_TSF7");
104 //TSF1 rt
105 h_rt_TSF1 = new TH1D(Form("hrt_TSF1_mod%d", m_T3DMOD), Form("hrt_TSF1_mod%d", m_T3DMOD), 512, 0, 511);
106 h_rt_TSF1->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
107 h_rt_TSF1->GetXaxis()->SetTitle("rt_TSF1");
108 //TSF3 rt
109 h_rt_TSF3 = new TH1D(Form("hrt_TSF3_mod%d", m_T3DMOD), Form("hrt_TSF3_mod%d", m_T3DMOD), 512, 0, 511);
110 h_rt_TSF3->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
111 h_rt_TSF3->GetXaxis()->SetTitle("rt_TSF3");
112 //TSF5 rt
113 h_rt_TSF5 = new TH1D(Form("hrt_TSF5_mod%d", m_T3DMOD), Form("hrt_TSF5_mod%d", m_T3DMOD), 512, 0, 511);
114 h_rt_TSF5->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
115 h_rt_TSF5->GetXaxis()->SetTitle("rt_TSF5");
116 //TSF7 rt
117 h_rt_TSF7 = new TH1D(Form("hrt_TSF7_mod%d", m_T3DMOD), Form("hrt_TSF7_mod%d", m_T3DMOD), 512, 0, 511);
118 h_rt_TSF7->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
119 h_rt_TSF7->GetXaxis()->SetTitle("rt_TSF7");
120 //TSF1 validity
121 h_validity_TSF1 = new TH1D(Form("hvalidity_TSF1_mod%d", m_T3DMOD), Form("hvalidity_TSF1_mod%d", m_T3DMOD), 16, 0, 15);
122 h_validity_TSF1->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
123 h_validity_TSF1->GetXaxis()->SetTitle("validity_TSF1");
124 //TSF3 validity
125 h_validity_TSF3 = new TH1D(Form("hvalidity_TSF3_mod%d", m_T3DMOD), Form("hvalidity_TSF3_mod%d", m_T3DMOD), 16, 0, 15);
126 h_validity_TSF3->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
127 h_validity_TSF3->GetXaxis()->SetTitle("validity_TSF3");
128 //TSF5 validity
129 h_validity_TSF5 = new TH1D(Form("hvalidity_TSF5_mod%d", m_T3DMOD), Form("hvalidity_TSF5_mod%d", m_T3DMOD), 16, 0, 15);
130 h_validity_TSF5->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
131 h_validity_TSF5->GetXaxis()->SetTitle("validity_TSF5");
132 //TSF7 validity
133 h_validity_TSF7 = new TH1D(Form("hvalidity_TSF7_mod%d", m_T3DMOD), Form("hvalidity_TSF7_mod%d", m_T3DMOD), 16, 0, 15);
134 h_validity_TSF7->SetTitle(Form("Exp%d Run%d 3Dmodule%d", _exp, _run, m_T3DMOD));
135 h_validity_TSF7->GetXaxis()->SetTitle("validity_TSF7");
136
137 oldDir->cd();
138}
139
141{
142
143 dirDQM->cd();
144
145 h_dz->Reset();
146 h_phi->Reset();
147 h_tanlambda->Reset();
148 h_pt->Reset();
149 h_phi_2D->Reset();
150 h_pt_2D->Reset();
151 h_ID_TSF1->Reset();
152
153 oldDir->cd();
154}
155
157{
158
160 _exp = bevt->getExperiment();
161 _run = bevt->getRun();
162
163 // calls back the defineHisto() function, but the HistoManager module has to be in the path
164 REG_HISTOGRAM
165
166 char c_name_3D[100];
167 sprintf(c_name_3D, "FirmTRGCDC3DFitterTracks%d", m_T3DMOD);
168 char c_name_2D[100];
169 sprintf(c_name_2D, "FirmTRGCDC2DFinderTracks%d", m_T3DMOD);
170 entAry.isRequired(c_name_3D);
171 entAry_2D.isRequired(c_name_2D);
172 char c_name_TSF[100];
173 sprintf(c_name_TSF, "FirmCDCTriggerSegmentHits%d", m_T3DMOD);
174 entAry_TSF.isRequired(c_name_TSF);
175 if (!entAry || !entAry.getEntries()) return;
176 if (!entAry_2D || !entAry_2D.getEntries()) return;
177 if (!entAry_TSF || !entAry_TSF.getEntries()) return;
178
179}
180
182{
183 dirDQM->cd();
184
185 //Draw and save histograms
187 //gStyle->SetOptStat(0);
188 TCanvas c1("c1", "", 0, 0, 500, 300);
189 c1.cd();
190
191 TPostScript* ps_dz = new TPostScript((m_postScriptName + ".dz_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
192 h_dz->Draw();
193 c1.Update();
194 ps_dz->Close();
195
196 TPostScript* ps_phi = new TPostScript((m_postScriptName + ".phi_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
197 h_phi->Draw();
198 c1.Update();
199 ps_phi->Close();
200
201 TPostScript* ps_tanlambda = new TPostScript((m_postScriptName + ".tanlambda_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
202 h_tanlambda->Draw();
203 c1.Update();
204 ps_tanlambda->Close();
205
206 TPostScript* ps_pt = new TPostScript((m_postScriptName + ".pt_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
207 h_pt->Draw();
208 c1.Update();
209 ps_pt->Close();
210
211 TPostScript* ps_phi_2D = new TPostScript((m_postScriptName + ".phi_2D_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
212 h_phi_2D->Draw();
213 c1.Update();
214 ps_phi_2D->Close();
215
216 TPostScript* ps_pt_2D = new TPostScript((m_postScriptName + ".pt_2D_T3DModule" + to_string(m_T3DMOD) + ".ps").c_str(), 112);
217 h_pt_2D->Draw();
218 c1.Update();
219 ps_pt_2D->Close();
220 }
221
222 oldDir->cd();
223}
224
226{
227
228 dirDQM->cd();
229
230 //Fill 3D histo
231 if (!(!entAry || !entAry.getEntries())) {
232 for (int i = 0; i < entAry.getEntries(); i++) {
233 h_dz->Fill(entAry[i]->getZ0());
234 h_phi->Fill(entAry[i]->getPhi0());
235 h_tanlambda->Fill(entAry[i]->getTanLambda());
236 if (entAry[i]->getOmega() != 0)
237 h_pt->Fill(fabs(1. / entAry[i]->getOmega() * 0.3 * 1.5 * 0.01));
238 }
239 }
240 //Fill 2D histo
241 if (!(!entAry_2D || !entAry_2D.getEntries())) {
242 for (int i = 0; i < entAry_2D.getEntries(); i++) {
243 h_phi_2D->Fill(entAry_2D[i]->getPhi0());
244 if (entAry_2D[i]->getOmega() != 0)
245 h_pt_2D->Fill(fabs(1. / entAry_2D[i]->getOmega() * 0.3 * 1.5 * 0.01));
246 }
247 }
248 //Fill stereo TSF histo
249 if (!(!entAry_TSF || !entAry_TSF.getEntries())) {
250 for (int i = 0; i < entAry_TSF.getEntries(); i++) {
251 int sl = entAry_TSF[i]->getISuperLayer();
252 int id = entAry_TSF[i]->getSegmentID();
253 int pr = entAry_TSF[i]->getPriorityPosition();
254 int lr = entAry_TSF[i]->getLeftRight();
255 int rt = entAry_TSF[i]->priorityTime();
256 int validity = lr * 4 + pr;
257 if (lr == 0 || pr == 0) continue;
258 if (sl == 1) {
259 h_ID_TSF1->Fill(id);
260 h_rt_TSF1->Fill(rt);
261 h_validity_TSF1->Fill(validity);
262 } else if (sl == 3) {
263 h_ID_TSF3->Fill(id);
264 h_rt_TSF3->Fill(rt);
265 h_validity_TSF3->Fill(validity);
266 } else if (sl == 5) {
267 h_ID_TSF5->Fill(id);
268 h_rt_TSF5->Fill(rt);
269 h_validity_TSF5->Fill(validity);
270 } else if (sl == 7) {
271 h_ID_TSF7->Fill(id);
272 h_rt_TSF7->Fill(rt);
273 h_validity_TSF7->Fill(validity);
274 }
275
276
277 }
278 }
279
280 oldDir->cd();
281
282}
283
284
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
TH1D * h_rt_TSF3
TSF3 priority time of T3D in each module.
TH1D * h_validity_TSF5
TSF5 validity of T3D in each module.
int m_T3DMOD
T3D module number.
unsigned _exp
experiment number
virtual void initialize() override
initialize
TH1D * h_rt_TSF7
TSF7 priority time of T3D in each module.
TH1D * h_pt
pt of T3D in each module
TDirectory * oldDir
TDirectories for DQM histograms.
virtual void event() override
Event.
TH1D * h_ID_TSF5
TSF5 ID of T3D in each module.
TH1D * h_rt_TSF1
TSF1 priority time of T3D in each module.
TH1D * h_pt_2D
pt (from 2D) of T3D in each module
virtual void endRun() override
End Run.
StoreArray< CDCTriggerTrack > entAry_2D
2D data store
TH1D * h_phi
phi of T3D in each module
TH1D * h_validity_TSF7
TSF7 validity of T3D in each module.
virtual void beginRun() override
begin Run
StoreArray< CDCTriggerSegmentHit > entAry_TSF
Stereo TSF data store.
TH1D * h_validity_TSF3
TSF3 validity of T3D in each module.
TH1D * h_rt_TSF5
TSF5 priority time of T3D in each module.
TH1D * h_ID_TSF1
TSF1 ID of T3D in each module.
StoreArray< CDCTriggerTrack > entAry
3D data store
TDirectory * dirDQM
TDirectories for DQM histograms.
TH1D * h_dz
dz of T3D in each module
TH1D * h_validity_TSF1
TSF1 validity of T3D in each module.
std::string m_postScriptName
name of ps file
TH1D * h_tanlambda
tanlambda of T3D in each module
TH1D * h_ID_TSF7
TSF7 ID of T3D in each module.
virtual void defineHisto() override
Define Histogram.
bool m_generatePostscript
flag to save ps file
TH1D * h_phi_2D
phi (from 2D) of T3D in each module
TH1D * h_ID_TSF3
TSF3 ID of T3D in each module.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.