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/dbobjects/RunInfo.h>
25#include <framework/datastore/DataStore.h>
26
27#include <TDirectory.h>
28#include <TRandom3.h>
29#include <TPostScript.h>
30#include <TCanvas.h>
31#include <TStyle.h>
32#include <unistd.h>
33#include <iostream>
34#include <fstream>
35#include <framework/logging/Logger.h>
36
37using namespace std;
38using namespace Belle2;
39
40REG_MODULE(TRGCDCT2DDQM);
41
42
44{
45
46 setDescription("DQM for CDCT2D Trigger system");
48
49 addParam("generatePostscript", m_generatePostscript,
50 "Genarete postscript file or not",
51 false);
52 addParam("postScriptName", m_postScriptName,
53 "postscript file name",
54 string("t2ddqm.ps"));
55
56
57}
58
60{
61 oldDir = gDirectory;
62 dirDQM = NULL;
63 //dirDQM = oldDir->mkdir("TRGCDCT2D");
64 if (!oldDir->Get("TRGCDCT2D"))dirDQM = oldDir->mkdir("TRGCDCT2D");
65 else dirDQM = (TDirectory*)oldDir->Get("TRGCDCT2D");
66 dirDQM->cd();
67
68 //TSF hit distribution as a function of tsfid
69 h_tsfhit = new TH1I("hCDCT2D_tsfhit", "hCDCT2D_tsfhit", 2500, 0, 2500);
70 h_tsfhit->SetTitle("TSF hit in 2D module");
71 h_tsfhit->GetXaxis()->SetTitle("TSF ID");
72
73 //2D phi distribution
74 h_phi = new TH1D("hCDCT2D_phi", "hCDCT2D_phi", 80, -1, 7);
75 h_phi->SetTitle("2D track phi");
76 h_phi->GetXaxis()->SetTitle("rad");
77
78 //2D pt distribution
79 h_pt = new TH1D("hCDCT2D_pt", "hCDCT2D_pt", 30, 0, 3);
80 h_pt->SetTitle("2D track pt");
81 h_pt->GetXaxis()->SetTitle("GeV");
82
83 //2D omega distribution
84 h_omega = new TH1D("hCDCT2D_omega", "hCDCT2D_omega", 80, -0.02, 0.02);
85 h_omega->SetTitle("2D track omega");
86 h_omega->GetXaxis()->SetTitle("");
87
88
89 //2D foundtime distribution
90 h_time = new TH1D("hCDCT2D_time", "hCDCT2D_time", 100, -50, 50);
91 h_time->SetTitle("2D track foundtime");
92 h_time->GetXaxis()->SetTitle("CLK 32ns");
93
94 oldDir->cd();
95}
96
98{
99
100 dirDQM->cd();
101
102 h_tsfhit->Reset();
103 h_phi->Reset();
104 h_pt->Reset();
105 h_omega->Reset();
106 h_time->Reset();
107
108 oldDir->cd();
109}
110
112{
113
115 _exp = bevt->getExperiment();
116 _run = bevt->getRun();
117
118 // calls back the defineHisto() function, but the HistoManager module has to be in the path
119 REG_HISTOGRAM
120
121 char c_name_tsf[100];
122 sprintf(c_name_tsf, "CDCTriggerSegmentHits");
123 entAry_tsf.isRequired(c_name_tsf);
124 if (!entAry_tsf || !entAry_tsf.getEntries()) return;
125 char c_name_t2d[100];
126 sprintf(c_name_t2d, "CDCTrigger2DFinderTracks");
127 entAry_t2d.isRequired(c_name_t2d);
128 if (!entAry_t2d || !entAry_t2d.getEntries()) return;
129
130}
131
133{
134 dirDQM->cd();
135
136 //Draw and save histograms
138 gStyle->SetOptStat(0);
139 TCanvas c1("c1", "", 0, 0, 500, 300);
140 c1.cd();
141
142 TPostScript* ps_tsfhit = new TPostScript((m_postScriptName + ".tsfhit" + ".ps").c_str(), 112);
143 h_tsfhit->Draw();
144 c1.Update();
145 ps_tsfhit->Close();
146
147 TPostScript* ps_phi = new TPostScript((m_postScriptName + ".phi" + ".ps").c_str(), 112);
148 h_phi->Draw();
149 c1.Update();
150 ps_phi->Close();
151
152 TPostScript* ps_pt = new TPostScript((m_postScriptName + ".pt" + ".ps").c_str(), 112);
153 h_pt->Draw();
154 c1.Update();
155 ps_pt->Close();
156
157 TPostScript* ps_omega = new TPostScript((m_postScriptName + ".omega" + ".ps").c_str(), 112);
158 h_omega->Draw();
159 c1.Update();
160 ps_omega->Close();
161
162 TPostScript* ps_time = new TPostScript((m_postScriptName + ".time" + ".ps").c_str(), 112);
163 h_time->Draw();
164 c1.Update();
165 ps_time->Close();
166 }
167
168 oldDir->cd();
169}
170
172{
173
174 dirDQM->cd();
175
176
177 //Fill
178 for (int ii = 0; ii < entAry_tsf.getEntries(); ii++) {
179 int id = entAry_tsf[ii]->getSegmentID();
180 h_tsfhit->Fill(id);
181 }
182 for (int ii = 0; ii < entAry_t2d.getEntries(); ii++) {
183 double phi = entAry_t2d[ii]->getPhi0();
184 h_phi->Fill(phi);
185 double pt = entAry_t2d[ii]->getPt();
186 h_pt->Fill(pt);
187 double omega = entAry_t2d[ii]->getOmega();
188 h_omega->Fill(omega);
189 double time = entAry_t2d[ii]->getTime();
190 h_time->Fill(time);
191 }
192
193
194 oldDir->cd();
195
196}
197
198
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
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
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.