Belle II Software development
TRGCDCT2DDQMModule.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 : TRGCDCT2DDQMModule.cc
12// Section : TRG CDCT2D
13// Owner :
14// Email :
15//---------------------------------------------------------------
16// Description : A trigger module for TRG CDCT2DDQM
17//---------------------------------------------------------------
18// 1.00 : 2017/05/08 : First version
19//---------------------------------------------------------------
20#include <trg/cdc/modules/trgcdct2dDQM/TRGCDCT2DDQMModule.h>
21
22#include <framework/datastore/StoreObjPtr.h>
23#include <framework/datastore/StoreArray.h>
24#include <framework/datastore/DataStore.h>
25
26#include <TDirectory.h>
27#include <TRandom3.h>
28#include <TPostScript.h>
29#include <TCanvas.h>
30#include <TStyle.h>
31#include <unistd.h>
32#include <iostream>
33#include <fstream>
34#include <framework/logging/Logger.h>
35
36using namespace std;
37using namespace Belle2;
38
39REG_MODULE(TRGCDCT2DDQM);
40
41
43{
44
45 setDescription("DQM for CDCT2D Trigger system");
47
48 addParam("generatePostscript", m_generatePostscript,
49 "Genarete postscript file or not",
50 false);
51 addParam("postScriptName", m_postScriptName,
52 "postscript file name",
53 string("t2ddqm.ps"));
54
55
56}
57
59{
60 oldDir = gDirectory;
61 dirDQM = NULL;
62 //dirDQM = oldDir->mkdir("TRGCDCT2D");
63 if (!oldDir->Get("TRGCDCT2D"))dirDQM = oldDir->mkdir("TRGCDCT2D");
64 else dirDQM = (TDirectory*)oldDir->Get("TRGCDCT2D");
65 dirDQM->cd();
66
67 //TSF hit distribution as a function of tsfid
68 h_tsfhit = new TH1I("hCDCT2D_tsfhit", "hCDCT2D_tsfhit", 2500, 0, 2500);
69 h_tsfhit->SetTitle("TSF hit in 2D module");
70 h_tsfhit->GetXaxis()->SetTitle("TSF ID");
71
72 //2D phi distribution
73 h_phi = new TH1D("hCDCT2D_phi", "hCDCT2D_phi", 80, -1, 7);
74 h_phi->SetTitle("2D track phi");
75 h_phi->GetXaxis()->SetTitle("rad");
76
77 //2D pt distribution
78 h_pt = new TH1D("hCDCT2D_pt", "hCDCT2D_pt", 30, 0, 3);
79 h_pt->SetTitle("2D track pt");
80 h_pt->GetXaxis()->SetTitle("GeV");
81
82 //2D omega distribution
83 h_omega = new TH1D("hCDCT2D_omega", "hCDCT2D_omega", 80, -0.02, 0.02);
84 h_omega->SetTitle("2D track omega");
85 h_omega->GetXaxis()->SetTitle("");
86
87
88 //2D foundtime distribution
89 h_time = new TH1D("hCDCT2D_time", "hCDCT2D_time", 100, -50, 50);
90 h_time->SetTitle("2D track foundtime");
91 h_time->GetXaxis()->SetTitle("CLK 32ns");
92
93 oldDir->cd();
94}
95
97{
98
99 dirDQM->cd();
100
101 h_tsfhit->Reset();
102 h_phi->Reset();
103 h_pt->Reset();
104 h_omega->Reset();
105 h_time->Reset();
106
107 oldDir->cd();
108}
109
111{
112
114 _exp = bevt->getExperiment();
115 _run = bevt->getRun();
116
117 // calls back the defineHisto() function, but the HistoManager module has to be in the path
118 REG_HISTOGRAM
119
120 char c_name_tsf[100];
121 sprintf(c_name_tsf, "CDCTriggerSegmentHits");
122 entAry_tsf.isRequired(c_name_tsf);
123 if (!entAry_tsf || !entAry_tsf.getEntries()) return;
124 char c_name_t2d[100];
125 sprintf(c_name_t2d, "CDCTrigger2DFinderTracks");
126 entAry_t2d.isRequired(c_name_t2d);
127 if (!entAry_t2d || !entAry_t2d.getEntries()) return;
128
129}
130
132{
133 dirDQM->cd();
134
135 //Draw and save histograms
137 gStyle->SetOptStat(0);
138 TCanvas c1("c1", "", 0, 0, 500, 300);
139 c1.cd();
140
141 TPostScript* ps_tsfhit = new TPostScript((m_postScriptName + ".tsfhit" + ".ps").c_str(), 112);
142 h_tsfhit->Draw();
143 c1.Update();
144 ps_tsfhit->Close();
145
146 TPostScript* ps_phi = new TPostScript((m_postScriptName + ".phi" + ".ps").c_str(), 112);
147 h_phi->Draw();
148 c1.Update();
149 ps_phi->Close();
150
151 TPostScript* ps_pt = new TPostScript((m_postScriptName + ".pt" + ".ps").c_str(), 112);
152 h_pt->Draw();
153 c1.Update();
154 ps_pt->Close();
155
156 TPostScript* ps_omega = new TPostScript((m_postScriptName + ".omega" + ".ps").c_str(), 112);
157 h_omega->Draw();
158 c1.Update();
159 ps_omega->Close();
160
161 TPostScript* ps_time = new TPostScript((m_postScriptName + ".time" + ".ps").c_str(), 112);
162 h_time->Draw();
163 c1.Update();
164 ps_time->Close();
165 }
166
167 oldDir->cd();
168}
169
171{
172
173 dirDQM->cd();
174
175
176 //Fill
177 for (int ii = 0; ii < entAry_tsf.getEntries(); ii++) {
178 int id = entAry_tsf[ii]->getSegmentID();
179 h_tsfhit->Fill(id);
180 }
181 for (int ii = 0; ii < entAry_t2d.getEntries(); ii++) {
182 double phi = entAry_t2d[ii]->getPhi0();
183 h_phi->Fill(phi);
184 double pt = entAry_t2d[ii]->getPt();
185 h_pt->Fill(pt);
186 double omega = entAry_t2d[ii]->getOmega();
187 h_omega->Fill(omega);
188 double time = entAry_t2d[ii]->getTime();
189 h_time->Fill(time);
190 }
191
192
193 oldDir->cd();
194
195}
196
197
HistoModule()
Constructor.
Definition HistoModule.h:32
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
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
StoreArray< CDCTriggerTrack > entAry_t2d
T2D data store.
unsigned _exp
experiment number
TH1D * h_time
2D foundtime distribution
virtual void initialize() override
initialize
TH1D * h_pt
2D pt distribution
TDirectory * oldDir
TDirectories.
virtual void event() override
Event.
virtual void endRun() override
End Run.
TH1D * h_omega
2D omega distribution
TH1D * h_phi
2D phi distribution
virtual void beginRun() override
begin Run
TH1I * h_tsfhit
TSF hit distribution as a function of tsfid.
TDirectory * dirDQM
TDirectories.
std::string m_postScriptName
name of ps file
StoreArray< CDCTriggerSegmentHit > entAry_tsf
TSF data store.
virtual void defineHisto() override
Define Histogram.
bool m_generatePostscript
flag to save ps file
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.