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