Belle II Software  release-05-01-25
TRGCDCTSFDQMModule.cc
1 //---------------------------------------------------------------
2 // $Id$
3 //---------------------------------------------------------------
4 // Filename : TRGCDCTSFModule.cc
5 // Section : TRG CDCTSF
6 // Owner :
7 // Email :
8 //---------------------------------------------------------------
9 // Description : A trigger module for TRG CDCTSF
10 //---------------------------------------------------------------
11 // 1.00 : 2017/05/08 : First version
12 //---------------------------------------------------------------
13 #include <trg/cdc/modules/trgcdctsfDQM/TRGCDCTSFDQMModule.h>
14 
15 #include <framework/dataobjects/EventMetaData.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/datastore/StoreArray.h>
18 
19 #include <TDirectory.h>
20 #include <TPostScript.h>
21 #include <TCanvas.h>
22 #include <TStyle.h>
23 #include <iostream>
24 
25 using namespace std;
26 using namespace Belle2;
27 
28 REG_MODULE(TRGCDCTSFDQM);
29 
30 
31 TRGCDCTSFDQMModule::TRGCDCTSFDQMModule() : HistoModule()
32 {
33 
34  setDescription("DQM for CDCTSF Trigger system");
36 
37  addParam("TSFMOD", m_TSFMOD,
38  "TSF module number",
39  0);
40  addParam("generatePostscript", m_generatePostscript,
41  "Genarete postscript file or not",
42  false);
43  addParam("postScriptName", m_postScriptName,
44  "postscript file name",
45  string("gdldqm.ps"));
46 
47 
48 }
49 
51 {
52  oldDir = gDirectory;
53  dirDQM = NULL;
54  //dirDQM = oldDir->mkdir("TRGCDCTSF");
55  if (!oldDir->Get("TRGCDCTSF"))dirDQM = oldDir->mkdir("TRGCDCTSF");
56  else dirDQM = (TDirectory*)oldDir->Get("TRGCDCTSF");
57  dirDQM->cd();
58  //Total number of TSF hits per event in each superlayer
59  h_nhit = new TH1I(Form("hCDCTSF_nhit_mod%d", m_TSFMOD), Form("nhit_mod%d", m_TSFMOD), 16, 0, 16);
60  h_nhit->SetTitle(Form("Exp%d Run%d SuperLayer%d", _exp, _run, m_TSFMOD));
61  h_nhit->GetXaxis()->SetTitle("Total number of TSF hits/event");
62  //Total number of hits in each TSF
63  h_nhit_tsf = new TH1I(Form("hCDCTSF_nhit_tsf_mod%d", m_TSFMOD), Form("nhit_tsf_mod%d", m_TSFMOD), 200, 0, 200);
64  h_nhit_tsf->SetTitle(Form("Exp%d Run%d SuperLayer%d", _exp, _run, m_TSFMOD));
65  h_nhit_tsf->GetXaxis()->SetTitle("TSF ID");
66  h_nhit_tsf->GetYaxis()->SetTitle("Total number of hits");
67  //Validity of hits in each super layer
68  h_valid = new TH1I(Form("hCDCTSF_valid_mod%d", m_TSFMOD), Form("valid__mod%d", m_TSFMOD), 10, 0, 10);
69  h_valid->SetTitle(Form("Exp%d Run%d SuperLayer%d", _exp, _run, m_TSFMOD));
70  h_valid->GetXaxis()->SetTitle("Validity");
71  h_valid->GetYaxis()->SetTitle("#of tsf hits");
72  //Timing of hits in each super layer
73  h_timing = new TH1I(Form("hCDCTSF_timing_mod%d", m_TSFMOD), Form("timing__mod%d", m_TSFMOD), 520, -5, 515);
74  h_timing->SetTitle(Form("Exp%d Run%d SuperLayer%d", _exp, _run, m_TSFMOD));
75  h_timing->GetXaxis()->SetTitle("Timing");
76  h_timing->GetYaxis()->SetTitle("#of tsf hits");
77  oldDir->cd();
78 }
79 
81 {
82 
83  dirDQM->cd();
84 
85  h_nhit->Reset();
86  h_nhit_tsf->Reset();
87 
88  oldDir->cd();
89 }
90 
92 {
93 
95  _exp = bevt->getExperiment();
96  _run = bevt->getRun();
97 
98  // calls back the defineHisto() function, but the HistoManager module has to be in the path
99  REG_HISTOGRAM
100 
101  char c_name[100];
102  sprintf(c_name, "TRGCDCTSFUnpackerStore%d", m_TSFMOD);
103  entAry.isRequired(c_name);
104  if (!entAry || !entAry.getEntries()) return;
105 
106 }
107 
109 {
110  dirDQM->cd();
111 
112  //Draw and save histograms
113  if (m_generatePostscript) {
114  gStyle->SetOptStat(0);
115  TCanvas c1("c1", "", 0, 0, 500, 300);
116  c1.cd();
117 
118  TPostScript* ps_nhit = new TPostScript((m_postScriptName + ".tsf_total_nhit_superlayer" + to_string(m_TSFMOD) + ".ps").c_str(),
119  112);
120  h_nhit->Draw();
121  c1.Update();
122  ps_nhit->Close();
123 
124  TPostScript* ps_nhit_tsf = new TPostScript((m_postScriptName + ".tsf_nhit_superlayer" + to_string(m_TSFMOD) + ".ps").c_str(), 112);
125  h_nhit_tsf->Draw();
126  c1.Update();
127  ps_nhit_tsf->Close();
128 
129  }
130 
131  oldDir->cd();
132 }
133 
135 {
136 
137  dirDQM->cd();
138 
139 
140  //Fill
141  int nhit = 0;
142  for (int ii = 0; ii < entAry.getEntries(); ii++) {
143  nhit += entAry[ii]->m_netfhit;
144  }
145  h_nhit->Fill(nhit);
146 
147  /* cppcheck-suppress variableScope */
148  int id;
149  /* cppcheck-suppress variableScope */
150  int v ;
151  /* cppcheck-suppress variableScope */
152  int rt;
153  for (int ii = 0; ii < entAry.getEntries(); ii++) {
154  id = entAry[ii]->m_trackerhit0id;
155  v = entAry[ii]->m_trackerhit0v;
156  rt = entAry[ii]->m_trackerhit0rt;
157  if (v != 0) {
158  h_nhit_tsf->Fill(id);
159  h_valid->Fill(v);
160  h_timing->Fill(rt);
161  }
162  id = entAry[ii]->m_trackerhit1id;
163  v = entAry[ii]->m_trackerhit1v;
164  rt = entAry[ii]->m_trackerhit1rt;
165  if (v != 0) {
166  h_nhit_tsf->Fill(id);
167  h_valid->Fill(v);
168  h_timing->Fill(rt);
169  }
170  id = entAry[ii]->m_trackerhit2id;
171  v = entAry[ii]->m_trackerhit2v;
172  rt = entAry[ii]->m_trackerhit2rt;
173  if (v != 0) {
174  h_nhit_tsf->Fill(id);
175  h_valid->Fill(v);
176  h_timing->Fill(rt);
177  }
178  id = entAry[ii]->m_trackerhit3id;
179  v = entAry[ii]->m_trackerhit3v;
180  rt = entAry[ii]->m_trackerhit3rt;
181  if (v != 0) {
182  h_nhit_tsf->Fill(id);
183  h_valid->Fill(v);
184  h_timing->Fill(rt);
185  }
186  id = entAry[ii]->m_trackerhit4id;
187  v = entAry[ii]->m_trackerhit4v;
188  rt = entAry[ii]->m_trackerhit4rt;
189  if (v != 0) {
190  h_nhit_tsf->Fill(id);
191  h_valid->Fill(v);
192  h_timing->Fill(rt);
193  }
194  id = entAry[ii]->m_trackerhit5id;
195  v = entAry[ii]->m_trackerhit5v;
196  rt = entAry[ii]->m_trackerhit5rt;
197  if (v != 0) {
198  h_nhit_tsf->Fill(id);
199  h_valid->Fill(v);
200  h_timing->Fill(rt);
201  }
202  id = entAry[ii]->m_trackerhit6id;
203  v = entAry[ii]->m_trackerhit6v;
204  rt = entAry[ii]->m_trackerhit6rt;
205  if (v != 0) {
206  h_nhit_tsf->Fill(id);
207  h_valid->Fill(v);
208  h_timing->Fill(rt);
209  }
210  id = entAry[ii]->m_trackerhit7id;
211  v = entAry[ii]->m_trackerhit7v;
212  rt = entAry[ii]->m_trackerhit7rt;
213  if (v != 0) {
214  h_nhit_tsf->Fill(id);
215  h_valid->Fill(v);
216  h_timing->Fill(rt);
217  }
218  id = entAry[ii]->m_trackerhit8id;
219  v = entAry[ii]->m_trackerhit8v;
220  rt = entAry[ii]->m_trackerhit8rt;
221  if (v != 0) {
222  h_nhit_tsf->Fill(id);
223  h_valid->Fill(v);
224  h_timing->Fill(rt);
225  }
226  id = entAry[ii]->m_trackerhit9id;
227  v = entAry[ii]->m_trackerhit9v;
228  rt = entAry[ii]->m_trackerhit9rt;
229  if (v != 0) {
230  h_nhit_tsf->Fill(id);
231  h_valid->Fill(v);
232  h_timing->Fill(rt);
233  }
234 
235  // to fill 5 more TS for 15 TS version, only for TSF 1,3,5
236  if (entAry[ii]->m_N2DTS == 10) continue;
237 
238  id = entAry[ii]->m_trackerhit10id;
239  v = entAry[ii]->m_trackerhit10v;
240  rt = entAry[ii]->m_trackerhit10rt;
241  if (v != 0) {
242  h_nhit_tsf->Fill(id);
243  h_valid->Fill(v);
244  h_timing->Fill(rt);
245  }
246  id = entAry[ii]->m_trackerhit11id;
247  v = entAry[ii]->m_trackerhit11v;
248  rt = entAry[ii]->m_trackerhit11rt;
249  if (v != 0) {
250  h_nhit_tsf->Fill(id);
251  h_valid->Fill(v);
252  h_timing->Fill(rt);
253  }
254  id = entAry[ii]->m_trackerhit12id;
255  v = entAry[ii]->m_trackerhit12v;
256  rt = entAry[ii]->m_trackerhit12rt;
257  if (v != 0) {
258  h_nhit_tsf->Fill(id);
259  h_valid->Fill(v);
260  h_timing->Fill(rt);
261  }
262  id = entAry[ii]->m_trackerhit13id;
263  v = entAry[ii]->m_trackerhit13v;
264  rt = entAry[ii]->m_trackerhit13rt;
265  if (v != 0) {
266  h_nhit_tsf->Fill(id);
267  h_valid->Fill(v);
268  h_timing->Fill(rt);
269  }
270  id = entAry[ii]->m_trackerhit14id;
271  v = entAry[ii]->m_trackerhit14v;
272  rt = entAry[ii]->m_trackerhit14rt;
273  if (v != 0) {
274  h_nhit_tsf->Fill(id);
275  h_valid->Fill(v);
276  h_timing->Fill(rt);
277  }
278 
279 
280  }
281 
282  oldDir->cd();
283 
284 }
285 
286 
Belle2::TRGCDCTSFDQMModule::m_generatePostscript
bool m_generatePostscript
flag to save ps file
Definition: TRGCDCTSFDQMModule.h:59
Belle2::TRGCDCTSFDQMModule::h_nhit
TH1I * h_nhit
Total number of TSF hits per event in each superlayer.
Definition: TRGCDCTSFDQMModule.h:42
Belle2::TRGCDCTSFDQMModule::m_TSFMOD
int m_TSFMOD
TSF module number.
Definition: TRGCDCTSFDQMModule.h:71
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::TRGCDCTSFDQMModule::entAry
StoreArray< TRGCDCTSFUnpackerStore > entAry
TSF data store.
Definition: TRGCDCTSFDQMModule.h:74
Belle2::TRGCDCTSFDQMModule::h_timing
TH1I * h_timing
Timing of TSF hits in each superlayer.
Definition: TRGCDCTSFDQMModule.h:51
Belle2::TRGCDCTSFDQMModule::initialize
virtual void initialize() override
initialize
Definition: TRGCDCTSFDQMModule.cc:91
Belle2::TRGCDCTSFDQMModule::_run
unsigned _run
run number
Definition: TRGCDCTSFDQMModule.h:68
Belle2::TRGCDCTSFDQMModule::event
virtual void event() override
Event.
Definition: TRGCDCTSFDQMModule.cc:134
Belle2::TRGCDCTSFDQMModule::m_postScriptName
std::string m_postScriptName
name of ps file
Definition: TRGCDCTSFDQMModule.h:62
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::TRGCDCTSFDQMModule::_exp
unsigned _exp
experiment number
Definition: TRGCDCTSFDQMModule.h:65
Belle2::TRGCDCTSFDQMModule::h_nhit_tsf
TH1I * h_nhit_tsf
Total number of hits in each TSF.
Definition: TRGCDCTSFDQMModule.h:45
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::TRGCDCTSFDQMModule::beginRun
virtual void beginRun() override
begin Run
Definition: TRGCDCTSFDQMModule.cc:80
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::TRGCDCTSFDQMModule::h_valid
TH1I * h_valid
Valid type of TSF hits in each superlayer.
Definition: TRGCDCTSFDQMModule.h:48
Belle2::TRGCDCTSFDQMModule::oldDir
TDirectory * oldDir
TDirectories.
Definition: TRGCDCTSFDQMModule.h:54
Belle2::TRGCDCTSFDQMModule::defineHisto
virtual void defineHisto() override
Define Histogram.
Definition: TRGCDCTSFDQMModule.cc:50
Belle2::TRGCDCTSFDQMModule::endRun
virtual void endRun() override
End Run.
Definition: TRGCDCTSFDQMModule.cc:108
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::TRGCDCTSFDQMModule::dirDQM
TDirectory * dirDQM
TDirectories.
Definition: TRGCDCTSFDQMModule.h:56