BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnHistToF.cxx
Go to the documentation of this file.
1
/*
2
* To change this license header, choose License Headers in Project Properties.
3
* To change this template file, choose Tools | Templates
4
* and open the template in the editor.
5
*/
6
7
/*
8
* File: BmnHistToF.cxx
9
* Author: ilnur
10
*
11
* Created on November 27, 2016, 4:24 PM
12
*/
13
14
#include "
BmnHistToF.h
"
15
16
#include "
BmnRawDataDecoder.h
"
17
18
BmnHistToF::BmnHistToF
(
TString
title,
TString
path)
19
:
BmnHist
()
20
{
21
fTitle
= title;
22
fName
= title +
"_cl"
;
23
fSelectedPlane
= -1;
24
fSelectedStrip
= -1;
25
fSelectedSide
= -1;
26
TString
name;
27
name =
fTitle
+
"_Leading_Time"
;
28
histLeadingTime
=
new
TH1D
(name, name, 500, 0, 2500);
29
histLeadingTime
->GetXaxis()->SetTitle(
"Time, ns"
);
30
histLeadingTime
->GetYaxis()->SetTitle(
"Activations count"
);
31
name =
fTitle
+
"_Leading_Time_Specific"
;
32
histLeadingTimeSpecific
=
new
TH1D
(name, name, 500, 0, 2500);
33
histLeadingTimeSpecific
->GetXaxis()->SetTitle(
"Time, ns"
);
34
histLeadingTimeSpecific
->GetYaxis()->SetTitle(
"Activations count"
);
35
name =
fTitle
+
"_Amplitude"
;
36
histAmp
=
new
TH1D
(name, name, 4096, 0, 96);
37
histAmp
->GetXaxis()->SetTitle(
"Amplitude, ns"
);
38
histAmp
->GetYaxis()->SetTitle(
"Activations count"
);
39
TGaxis
* ay = (
TGaxis
*)
histAmp
->GetYaxis();
40
ay->
SetMaxDigits
(2);
41
name =
fTitle
+
"_Amplitude_Specific"
;
42
histAmpSpecific
=
new
TH1D
(name, name, 4096, 0, 96);
43
histAmpSpecific
->GetXaxis()->SetTitle(
"Amplitude, ns"
);
44
histAmpSpecific
->GetYaxis()->SetTitle(
"Activations count"
);
45
name =
fTitle
+
"_Strip"
;
46
histStrip
=
new
TH1I
(name, name,
TOF400_STRIP_COUNT
, 0,
TOF400_STRIP_COUNT
);
47
histStrip
->GetXaxis()->SetTitle(
"Strip #"
);
48
histStrip
->GetYaxis()->SetTitle(
"Activations count"
);
49
histAmp
->GetYaxis()->SetNoExponent(
kFALSE
);
50
name =
fTitle
+
"_StripSimult"
;
51
histStripSimult
=
new
TH1I
(name, name,
TOF400_STRIP_COUNT
, 0,
TOF400_STRIP_COUNT
);
52
histStripSimult
->GetXaxis()->SetTitle(
"Strip count"
);
53
histStripSimult
->GetYaxis()->SetTitle(
"Activations count"
);
54
name =
fTitle
+
"_State"
;
55
histState
=
new
TH2F
(name, name,
TOF400_STRIP_COUNT
, 0,
TOF400_STRIP_COUNT
, 2, 0, 2);
56
histState
->GetXaxis()->SetTitle(
"Strip #"
);
57
histState
->GetYaxis()->SetTitle(
"Side"
);
58
name =
fTitle
+
"_State2D"
;
59
histStrip2d
=
60
new
TH2I
(name, name,
TOF400_STRIP_COUNT
, 0,
TOF400_STRIP_COUNT
,
TOF400_PLANE_COUNT
, 0,
TOF400_PLANE_COUNT
);
61
histStrip2d
->GetXaxis()->SetTitle(
"Strip #"
);
62
histStrip2d
->GetYaxis()->SetTitle(
"Plane #"
);
63
64
histSimultaneous
.SetDirectory(0);
65
histL
->SetDirectory(0);
66
histR
->SetDirectory(0);
67
fServer
= NULL;
68
frecoTree
= NULL;
69
Events
= NULL;
70
name =
fTitle
+
"Canvas2d"
;
71
can2d
=
new
TCanvas
(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 1);
72
can2d
->Divide(2, 1);
73
can2dPads
.resize(2 * 1);
74
for
(
Int_t
iPad = 0; iPad < 2 * 1; iPad++) {
75
PadInfo
* p =
new
PadInfo
();
76
can2dPads
[iPad] = p;
77
p->
opt
=
"colz nostat"
;
78
}
79
can2dPads
[0]->current =
histStrip2d
;
80
can2dPads
[1]->current =
histState
;
81
name =
fTitle
+
"CanvasTimes"
;
82
canTimes
=
new
TCanvas
(name, name, PAD_WIDTH *
TOF_ROWS
, PAD_HEIGHT *
TOF_COLS
);
83
canTimes
->Divide(
TOF_ROWS
,
TOF_COLS
);
84
canTimesPads
.resize(
TOF_ROWS
*
TOF_COLS
);
85
for
(
Int_t
iPad = 0; iPad <
TOF_ROWS
*
TOF_COLS
; iPad++) {
86
PadInfo
* p =
new
PadInfo
();
87
canTimesPads
[iPad] = p;
88
canTimes
->GetPad(iPad + 1)->SetGrid();
89
}
90
canTimesPads
[0]->current =
histLeadingTime
;
91
canTimesPads
[1]->current =
histAmp
;
92
canTimesPads
[2]->current =
histLeadingTimeSpecific
;
93
canTimesPads
[3]->current =
histAmpSpecific
;
94
canTimesPads
[4]->current =
histStrip
;
95
canTimesPads
[5]->current =
histStripSimult
;
96
for
(
size_t
iPad = 0; iPad <
canTimesPads
.size(); iPad++)
97
if
(
canTimesPads
[iPad]->current) {
98
Names
.push_back(
canTimesPads
[iPad]->current->GetName());
99
BmnHist::SetHistStyleTH1
(
canTimesPads
[iPad]->current);
100
}
101
for
(
size_t
iPad = 0; iPad <
can2dPads
.size(); iPad++)
102
if
(
can2dPads
[iPad]->current) {
103
// Names.push_back(canTimesPads[iPad]->current->GetName());
104
BmnHist::SetHistStyleTH1
(
can2dPads
[iPad]->current);
105
}
106
}
107
108
BmnHistToF::~BmnHistToF
()
109
{
110
delete
histL
;
111
delete
histR
;
112
delete
Events
;
113
delete
canTimes
;
114
delete
can2d
;
115
if
(
fDir
)
116
return
;
117
for
(
auto
pad :
canTimesPads
)
118
delete
pad;
119
for
(
auto
pad :
can2dPads
)
120
delete
pad;
121
}
122
123
void
BmnHistToF::FillFromDigi
(
DigiArrays
* fDigiArrays)
124
{
125
TClonesArray
* digits = fDigiArrays->
tof400
;
126
if
(!digits)
127
return
;
128
histL
->Reset();
129
histR
->Reset();
130
histSimultaneous
.Reset();
131
Events
->Clear();
132
for
(
Int_t
digIndex = 0; digIndex < digits->
GetEntriesFast
(); digIndex++) {
133
BmnTof1Digit
* td = (
BmnTof1Digit
*)digits->
At
(digIndex);
134
Int_t
strip = td->
GetStrip
();
135
if
((strip == 0) || (strip == (
TOF400_STRIP_COUNT
- 1)))
// noisy
136
continue
;
137
histLeadingTime
->Fill(td->
GetTime
());
138
histAmp
->Fill(td->
GetAmplitude
());
139
histStrip
->Fill(strip);
140
histStrip2d
->Fill(strip, td->
GetPlane
(), 1);
141
if
((td->
GetPlane
() ==
fSelectedPlane
)) {
142
histState
->Reset();
143
histState
->Fill(td->
GetStrip
(), td->
GetSide
(), td->
GetAmplitude
());
144
}
145
if
(td->
GetSide
() == 0)
146
histL
->Fill(strip);
147
else
148
histR
->Fill(strip);
149
if
(((td->
GetPlane
() ==
fSelectedPlane
) || (
fSelectedPlane
< 0))
150
&& ((td->
GetStrip
() ==
fSelectedStrip
) || (
fSelectedStrip
< 0))
151
&& ((td->
GetSide
() ==
fSelectedSide
) || (
fSelectedSide
< 0)))
152
{
153
histAmpSpecific
->Fill(td->
GetAmplitude
());
154
histLeadingTimeSpecific
->Fill(td->
GetTime
());
155
}
156
157
// new ((*Events)[Events->GetEntriesFast()])
158
// BmnTof1Digit(td->GetPlane(), td->GetStrip(), td->GetSide(), td->GetTime(),
159
// td->GetAmplitude());
160
// frecoTree->Fill();
161
}
162
// histSimultaneous = (*histL) * (*histR);
163
Int_t
s;
164
histStripSimult
->ResetStats();
165
for
(
Int_t
binIndex = 1; binIndex <
TOF400_STRIP_COUNT
; binIndex++) {
166
s = ((
histL
->GetBinContent(binIndex) *
histR
->GetBinContent(binIndex)) != 0) ? 1 : 0;
167
if
(s)
168
histStripSimult
->AddBinContent(s);
169
}
170
// if (fEventsBranch != NULL)
171
// fEventsBranch->Fill();
172
}
173
174
void
BmnHistToF::Register
(
THttpServer
* serv)
175
{
176
fServer
= serv;
177
fServer
->Register(
"/"
,
this
);
178
TString
path =
"/"
+
fTitle
+
"/"
;
179
fServer
->Register(path,
canTimes
);
180
fServer
->Register(path,
can2d
);
181
182
TString
cmd =
"/"
+
fName
+
"/->SetRefRun(%arg1%)"
;
183
TString
cmdTitle = path +
"SetRefRun"
;
184
fServer
->RegisterCommand(cmdTitle.
Data
(), cmd.
Data
(),
"button;"
);
185
fServer
->Restrict(cmdTitle.
Data
(),
"visible=shift"
);
186
fServer
->Restrict(cmdTitle.
Data
(),
"allow=shift"
);
187
fServer
->Restrict(cmdTitle.
Data
(),
"deny=guest"
);
188
cmdTitle = path +
"ChangeSelection"
;
189
fServer
->RegisterCommand(cmdTitle,
TString
(
"/"
) +
fName
.Data() +
"/->SetSelection(%arg1%,%arg2%,%arg3%)"
,
190
"button;"
);
191
fServer
->Restrict(cmdTitle,
"visible=shift"
);
192
fServer
->Restrict(cmdTitle,
"allow=shift"
);
193
fServer
->Restrict(cmdTitle.
Data
(),
"deny=guest"
);
194
cmdTitle = path +
TString
(
"Reset"
);
195
fServer
->RegisterCommand(cmdTitle,
TString
(
"/"
) +
fName
.Data() +
"/->Reset()"
,
"button;"
);
196
fServer
->Restrict(cmdTitle.
Data
(),
"visible=shift"
);
197
fServer
->Restrict(cmdTitle.
Data
(),
"allow=shift"
);
198
// fServer->Restrict(cmdTitle.Data(), "deny=guest");
199
}
200
201
void
BmnHistToF::SetDir
(
TFile
* outFile,
TTree
* recoTree)
202
{
203
frecoTree
= recoTree;
204
fDir
= NULL;
205
if
(outFile != NULL)
206
fDir
= outFile->
mkdir
(
fTitle
+
"_hists"
);
207
histLeadingTime
->SetDirectory(
fDir
);
208
histLeadingTimeSpecific
->SetDirectory(
fDir
);
209
histAmp
->SetDirectory(
fDir
);
210
histAmpSpecific
->SetDirectory(
fDir
);
211
histStrip
->SetDirectory(
fDir
);
212
histStripSimult
->SetDirectory(
fDir
);
213
histState
->SetDirectory(
fDir
);
214
if
(
Events
!= NULL)
215
delete
Events
;
216
Events
=
new
TClonesArray
(
"BmnTof1Digit"
);
217
if
(
frecoTree
!= NULL)
218
frecoTree
->Branch(
fTitle
.Data(), &
Events
);
219
}
220
221
void
BmnHistToF::SetSelection
(
Int_t
Plane,
Int_t
Strip
,
Int_t
Side)
222
{
223
SetPlane
(Plane);
224
SetStrip
(
Strip
);
225
SetSide
(Side);
226
TString
command;
227
if
(
fSelectedPlane
>= 0)
228
command =
Form
(
"%s.fPlane == %d"
,
fTitle
.Data(),
fSelectedPlane
);
229
if
(
fSelectedStrip
>= 0) {
230
if
(command.
Length
() > 0)
231
command = command +
" && "
;
232
command = command +
Form
(
"%s.fStrip == %d"
,
fTitle
.Data(),
fSelectedStrip
);
233
}
234
if
(
fSelectedSide
>= 0) {
235
if
(command.
Length
() > 0)
236
command = command +
" && "
;
237
command = command +
Form
(
"%s.fSide == %d"
,
fTitle
.Data(),
fSelectedSide
);
238
}
239
histAmpSpecific
->Reset();
240
histLeadingTimeSpecific
->Reset();
241
histAmpSpecific
->SetTitle(
"Amplitude For: "
+ command);
242
histLeadingTimeSpecific
->SetTitle(
"Leading Time For: "
+ command);
243
if
(
frecoTree
!= NULL) {
244
histAmpSpecific
->SetTitle(
"Amplitude For: "
+ command);
245
TString
direction =
"fAmplitude>>"
+
TString
(
histAmpSpecific
->GetName());
246
// TCanvas *c1 = new TCanvas("c1");
247
frecoTree
->Draw(direction.
Data
(), command.
Data
(),
"goff"
);
248
histLeadingTimeSpecific
->SetTitle(
"Leading Time For: "
+ command);
249
direction =
"fTime>>"
+
TString
(
histLeadingTimeSpecific
->GetName());
250
// TDirectory *d = gDirectory->GetDirectory();
251
// TDirectory()
252
frecoTree
->Draw(direction.
Data
(), command.
Data
(),
"goff"
);
253
// delete c1;
254
}
255
}
256
257
void
BmnHistToF::Reset
()
258
{
259
for
(
auto
& h :
canTimesPads
) {
260
h->current->Reset();
261
}
262
for
(
auto
& h :
can2dPads
) {
263
h->current->Reset();
264
}
265
}
266
267
void
BmnHistToF::DrawBoth
()
268
{
269
BmnHist::DrawRef
(
canTimes
, &
canTimesPads
);
270
BmnHist::DrawRef
(
can2d
, &
can2dPads
);
271
}
272
273
BmnStatus
BmnHistToF::SetRefRun
(
Int_t
id
)
274
{
275
if
(
refID
!=
id
) {
276
TString
FileName =
Form
(
"bmn_run%04d_hist.root"
,
id
);
277
printf(
"SetRefRun: %s\n"
, FileName.
Data
());
278
refRunName
= FileName;
279
refID
= id;
280
BmnHist::LoadRefRun
(
refID
,
refPath
+ FileName,
fTitle
,
canTimesPads
,
Names
);
281
DrawBoth
();
282
}
283
return
kBMNSUCCESS
;
284
}
285
286
void
BmnHistToF::ClearRefRun
()
287
{
288
for
(
auto
& pad :
canTimesPads
) {
289
if
(pad->ref)
290
delete
pad->ref;
291
pad->ref = NULL;
292
}
293
refID
= 0;
294
}
BmnStatus
BmnStatus
Define status code.
Definition
BmnEnums.h:93
kBMNSUCCESS
@ kBMNSUCCESS
Success.
Definition
BmnEnums.h:94
BmnHistToF.h
TOF_ROWS
#define TOF_ROWS
Definition
BmnHistToF.h:39
TOF400_PLANE_COUNT
#define TOF400_PLANE_COUNT
Definition
BmnHistToF.h:36
TOF_COLS
#define TOF_COLS
Definition
BmnHistToF.h:38
TOF400_STRIP_COUNT
#define TOF400_STRIP_COUNT
Definition
BmnHistToF.h:37
BmnRawDataDecoder.h
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
Form
char * Form(const char *fmt,...)
Strip
char * Strip(const char *str, char c=' ')
BmnHistToF::histL
TH1I * histL
Definition
BmnHistToF.h:78
BmnHistToF::can2dPads
vector< PadInfo * > can2dPads
Definition
BmnHistToF.h:85
BmnHistToF::fSelectedPlane
Int_t fSelectedPlane
Definition
BmnHistToF.h:75
BmnHistToF::SetRefRun
BmnStatus SetRefRun(Int_t id)
Definition
BmnHistToF.cxx:273
BmnHistToF::BmnHistToF
BmnHistToF(TString title, TString path="")
Definition
BmnHistToF.cxx:18
BmnHistToF::SetStrip
void SetStrip(Int_t v)
Definition
BmnHistToF.h:59
BmnHistToF::histR
TH1I * histR
Definition
BmnHistToF.h:79
BmnHistToF::histStrip2d
TH2I * histStrip2d
Definition
BmnHistToF.h:73
BmnHistToF::FillFromDigi
void FillFromDigi(DigiArrays *fDigiArrays)
Definition
BmnHistToF.cxx:123
BmnHistToF::canTimes
TCanvas * canTimes
Definition
BmnHistToF.h:82
BmnHistToF::histStripSimult
TH1I * histStripSimult
Definition
BmnHistToF.h:72
BmnHistToF::histSimultaneous
TH1I histSimultaneous
Definition
BmnHistToF.h:80
BmnHistToF::histStrip
TH1I * histStrip
Definition
BmnHistToF.h:71
BmnHistToF::histLeadingTimeSpecific
TH1D * histLeadingTimeSpecific
Definition
BmnHistToF.h:68
BmnHistToF::SetPlane
void SetPlane(Int_t v)
Definition
BmnHistToF.h:57
BmnHistToF::SetSide
void SetSide(Int_t v)
Definition
BmnHistToF.h:58
BmnHistToF::Events
TClonesArray * Events
Definition
BmnHistToF.h:66
BmnHistToF::histState
TH2F * histState
Definition
BmnHistToF.h:74
BmnHistToF::fSelectedSide
Int_t fSelectedSide
Definition
BmnHistToF.h:77
BmnHistToF::fSelectedStrip
Int_t fSelectedStrip
Definition
BmnHistToF.h:76
BmnHistToF::Register
void Register(THttpServer *serv)
Definition
BmnHistToF.cxx:174
BmnHistToF::ClearRefRun
void ClearRefRun()
Definition
BmnHistToF.cxx:286
BmnHistToF::Reset
void Reset()
Definition
BmnHistToF.cxx:257
BmnHistToF::Names
vector< TString > Names
Definition
BmnHistToF.h:81
BmnHistToF::~BmnHistToF
virtual ~BmnHistToF()
Definition
BmnHistToF.cxx:108
BmnHistToF::canTimesPads
vector< PadInfo * > canTimesPads
Definition
BmnHistToF.h:84
BmnHistToF::histAmpSpecific
TH1D * histAmpSpecific
Definition
BmnHistToF.h:70
BmnHistToF::histAmp
TH1D * histAmp
Definition
BmnHistToF.h:69
BmnHistToF::DrawBoth
void DrawBoth()
Definition
BmnHistToF.cxx:267
BmnHistToF::SetDir
void SetDir(TFile *outFile=NULL, TTree *recoTree=NULL)
Definition
BmnHistToF.cxx:201
BmnHistToF::SetSelection
void SetSelection(Int_t Plane, Int_t Strip, Int_t Side)
Definition
BmnHistToF.cxx:221
BmnHistToF::can2d
TCanvas * can2d
Definition
BmnHistToF.h:83
BmnHistToF::histLeadingTime
TH1D * histLeadingTime
Definition
BmnHistToF.h:67
BmnHist::fServer
THttpServer * fServer
Definition
BmnHist.h:87
BmnHist::refID
Int_t refID
Definition
BmnHist.h:92
BmnHist::refPath
TString refPath
Definition
BmnHist.h:90
BmnHist::fDir
TDirectory * fDir
Definition
BmnHist.h:89
BmnHist::DrawRef
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
Definition
BmnHist.cxx:15
BmnHist::frecoTree
TTree * frecoTree
Definition
BmnHist.h:88
BmnHist::SetHistStyleTH1
static void SetHistStyleTH1(TH1 *h)
Definition
BmnHist.cxx:195
BmnHist::refRunName
TString refRunName
Definition
BmnHist.h:91
BmnHist::LoadRefRun
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
Definition
BmnHist.cxx:100
BmnHist::BmnHist
BmnHist(Int_t periodID=7, BmnSetup setup=kBMNSETUP)
Definition
BmnHist.cxx:3
BmnTof1Digit
Definition
BmnTof1Digit.h:10
BmnTof1Digit::GetPlane
Short_t GetPlane() const
Definition
BmnTof1Digit.h:23
BmnTof1Digit::GetSide
Short_t GetSide() const
Definition
BmnTof1Digit.h:25
BmnTof1Digit::GetStrip
Short_t GetStrip() const
Definition
BmnTof1Digit.h:24
BmnTof1Digit::GetTime
Float_t GetTime() const
Definition
BmnTof1Digit.h:27
BmnTof1Digit::GetAmplitude
Float_t GetAmplitude() const
Definition
BmnTof1Digit.h:26
DigiArrays
Definition
DigiArrays.h:10
DigiArrays::tof400
TClonesArray * tof400
Definition
DigiArrays.h:129
PadInfo
Storage for pad content and it's options.
Definition
PadInfo.h:20
PadInfo::opt
string opt
Definition
PadInfo.h:88
TCanvas
TDirectoryFile::mkdir
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
TFile
TGaxis
TGaxis::SetMaxDigits
static void SetMaxDigits(Int_t maxd=5)
TH1D
TH1I
TH2F
TH2I
THttpServer
TNamed::fTitle
TString fTitle
TNamed::fName
TString fName
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObject::TClonesArray
friend friend class TClonesArray
TString
TString::Length
Ssiz_t Length() const
TString::Data
const char * Data() const
TTree
monitor
BmnHistToF.cxx
Generated on
for BmnRoot by
1.17.0