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