BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
ToF400_Digit2Hit_Run7_SRC.C
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: ToF400_Digit2Hit_Run7_SRC.C
9
* Author: mikhailr
10
*
11
* Created on May 24, 2018, 3:17 PM
12
*/
13
14
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
15
#include "macro/run/bmnloadlibs.C"
16
17
using namespace
std
;
18
19
Double_t
AmpBD
,
TimeBD
,
NHitBD
;
20
21
Bool_t
FlagHit
=
kFALSE
;
22
Int_t
XforHit
= 0,
YforHit
= 0;
23
const
Int_t
NDet
= 20;
24
25
void
ToF400_Digit2Hit_Run7_SRC
(
TString
file =
"/home/storage/digits/SRC/bmn_run3482_digi.root"
,
Int_t
nEvForRead = 0)
26
{
27
28
bmnloadlibs();
// load BmnRoot libraries
29
30
// Init output tree and file
31
TTree
* treeHitIn =
new
TTree
(
"TOF400"
,
"TOF400"
);
32
vector<double>* XTof =
new
vector<double>;
33
vector<double>* YTof =
new
vector<double>;
34
vector<double>* ZTof =
new
vector<double>;
35
vector<double>* TimeTof =
new
vector<double>;
36
UInt_t
EventHeader_EventID;
37
38
treeHitIn->
Branch
(
"EventID"
, &EventHeader_EventID);
39
treeHitIn->
Branch
(
"XTof"
, &XTof);
40
treeHitIn->
Branch
(
"YTof"
, &YTof);
41
treeHitIn->
Branch
(
"ZTof"
, &ZTof);
42
treeHitIn->
Branch
(
"TimeTof"
, &TimeTof);
43
44
TString
outName = file;
45
Int_t
Point = outName.
First
(
'.'
);
46
outName.
Replace
(Point, 20,
"_Tof400Hit.root"
);
47
TFile
* FileHitOut =
new
TFile
(outName.
Data
(),
"RECREATE"
);
48
49
// Init BmnTOF1Detector
50
BmnTOF1Detector
* Plane[
NDet
];
51
TString
name;
52
for
(
Int_t
i
= 0;
i
<
NDet
;
i
++) {
53
name =
Form
(
"Plane%d"
,
i
);
54
Plane[
i
] =
new
BmnTOF1Detector
(
i
, 2, NULL);
55
Plane[
i
]->
SetCorrLR
(
"TOF400_LRcorr_RUN7.dat"
);
56
Plane[
i
]->
SetGeoFile
(
"geofile_full_src.root"
);
57
}
//*/
58
59
// Init tree with Digi
60
TChain
* eveTree =
new
TChain
(
"cbmsim"
);
61
TString
inName =
Form
(
"%s"
, file.Data());
62
cout << endl << endl <<
"Open file "
<< inName << endl << endl;
63
Int_t
AddReturn;
64
AddReturn = eveTree->
Add
(inName);
65
// cout << "AddReturn = " << AddReturn << endl;
66
67
TClonesArray
* ToF400Digits =
new
TClonesArray
(
"BmnTof1Digit"
);
68
eveTree->
SetBranchAddress
(
"TOF400"
, &ToF400Digits);
69
70
TClonesArray
* T0Digits =
new
TClonesArray
(
"BmnTrigDigit"
);
71
eveTree->
SetBranchAddress
(
"BC2"
, &T0Digits);
72
73
TClonesArray
* EventHeaderDig =
new
TClonesArray
(
"BmnEventHeader"
);
74
eveTree->
SetBranchAddress
(
"EventHeader"
, &EventHeaderDig);
75
76
Long64_t
nEvents = eveTree->
GetEntries
();
77
if
(nEvForRead == 0 || nEvForRead > nEvents)
78
nEvForRead = nEvents;
79
cout <<
"Will be read "
<< nEvForRead <<
" events from "
<< nEvents << endl;
80
81
// eveTree->Print();
82
83
// Read digi tree
84
for
(
Long64_t
iEv = 0; iEv < nEvForRead; iEv++) {
85
86
ToF400Digits->
Delete
();
87
T0Digits->
Delete
();
88
EventHeaderDig->
Delete
();
89
90
if
(iEv % 10000 == 0)
91
cout <<
"#EVENT: "
<< iEv << endl;
92
// cout << "Read event " << iEv << endl;
93
eveTree->
GetEntry
(iEv);
94
95
BmnEventHeader
* digHeader = (
BmnEventHeader
*)EventHeaderDig->
At
(0);
96
EventHeader_EventID = digHeader->
GetEventId
();
97
if
(iEv % 10000 == 0)
98
cout <<
"#EVENTHeader: "
<< EventHeader_EventID << endl;
99
100
// cout << "Check T0 digits " << endl;
101
Int_t
CountMod0 = 0, CountMod1 = 0;
102
for
(
Int_t
i
= 0;
i
< T0Digits->
GetEntriesFast
();
i
++) {
103
BmnTrigDigit
* digT0 = (
BmnTrigDigit
*)T0Digits->
At
(
i
);
104
if
(digT0->
GetMod
() == 0)
105
CountMod0++;
106
if
(digT0->
GetMod
() == 1)
107
CountMod1++;
108
}
109
110
if
(CountMod0 == 1 && CountMod1 >= 0)
// check T0
111
{
112
// cout << "Looking for right T0 digit" << "; nDigits = " << T0Digits->GetEntriesFast() << endl;
113
BmnTrigDigit
* digT0 = NULL;
114
for
(
Int_t
i
= 0;
i
< T0Digits->
GetEntriesFast
();
i
++) {
115
digT0 = (
BmnTrigDigit
*)T0Digits->
At
(
i
);
116
if
(digT0->
GetMod
() == 0)
117
break
;
// take first T0 digit. needed for ToF calculation.
118
}
119
if
(digT0->
GetAmp
() >= 19.26 && digT0->
GetAmp
() <= 22.06) {
120
121
XTof->clear();
122
YTof->clear();
123
ZTof->clear();
124
TimeTof->clear();
125
126
//--------------------------- RPC --------------------------------------------------
127
for
(
Int_t
i
= 0;
i
<
NDet
;
i
++)
128
Plane[
i
]->Clear();
129
130
// cout << "Read TOF400 Digits" << "; NDigits = " << ToF400Digits->GetEntriesFast() <<
131
// endl;
132
for
(
Int_t
iDig = 0; iDig < ToF400Digits->
GetEntriesFast
(); ++iDig) {
133
FlagHit
=
kFALSE
;
134
BmnTof1Digit
* digTof = (
BmnTof1Digit
*)ToF400Digits->
At
(iDig);
135
FlagHit
= Plane[digTof->
GetPlane
()]->SetDigit(digTof);
136
}
137
138
// cout << "Fiil vectors" << endl;
139
TVector3
XYZ;
140
XYZ.
SetXYZ
(0., 0., 0.);
141
Double_t
ToF = 0;
142
FlagHit
=
kFALSE
;
143
for
(
Int_t
i
= 0;
i
<
NDet
;
i
++) {
// loop over TOF400 Planes
144
Int_t
nHits = Plane[
i
]->FindHits(digT0);
145
// cout << "nHits in Plane " << i << " = " << nHits << endl;
146
if
(nHits > 0) {
147
for
(
Int_t
s = 0; s < 47; s++) {
// loop over Plane's strips
148
XYZ.
SetXYZ
(0., 0., 0.);
149
ToF = 0;
150
FlagHit
=
kFALSE
;
151
FlagHit
= Plane[
i
]->
GetXYZTime
(s, &XYZ, &ToF);
152
if
(
FlagHit
==
kTRUE
) {
153
// cout << "Plane = " << i << "; Strip = " << s << "; X="
154
// << XYZ.X() << "; Y=" << XYZ.Y() << "; Z=" << XYZ.Z()
155
// << "; Time=" << ToF << endl;
156
XTof->push_back(XYZ.
X
());
157
YTof->push_back(XYZ.
Y
());
158
ZTof->push_back(XYZ.
Z
());
159
TimeTof->push_back(ToF);
160
}
161
}
// end for (Int_t s = 0; s < 47; s++)
162
}
163
}
// end for (Int_t i = 0; i < NDet; i++)
164
165
// cout << "Fill output tree" << endl;
166
treeHitIn->
Fill
();
167
168
}
// end if (digT0->GetAmp() >= 17.3 && digT0->GetAmp() <= 19.2)
169
}
// end if (CountMod0 == 1 && CountMod1 <= 0)
170
}
// end for (Int_t iEv = 0; iEv < nEvForRead; iEv++)
171
172
cout <<
"End Data Analysis"
<< endl;
173
cout <<
"Save data in "
<< outName << endl;
174
FileHitOut->
cd
();
175
treeHitIn->
Write
();
176
FileHitOut->
Close
();
177
}
i
int i
Definition
P4_F32vec4.h:22
Bool_t
bool Bool_t
Int_t
int Int_t
UInt_t
unsigned int UInt_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
Long64_t
long long Long64_t
kTRUE
constexpr Bool_t kTRUE
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
Form
char * Form(const char *fmt,...)
BmnEventHeader
Definition
BmnEventHeader.h:24
BmnEventHeader::GetEventId
UInt_t GetEventId()
Get the event ID for this event.
Definition
BmnEventHeader.h:89
BmnTOF1Detector
Definition
BmnTOF1Detector.h:56
BmnTOF1Detector::GetXYZTime
Bool_t GetXYZTime(Int_t Str, TVector3 *XYZ, Double_t *ToF)
Definition
BmnTOF1Detector.cxx:702
BmnTOF1Detector::SetGeoFile
Bool_t SetGeoFile(TString NameFile)
Definition
BmnTOF1Detector.cxx:624
BmnTOF1Detector::SetCorrLR
Bool_t SetCorrLR(TString NameFile)
Definition
BmnTOF1Detector.cxx:489
BmnTof1Digit
Definition
BmnTof1Digit.h:10
BmnTof1Digit::GetPlane
Short_t GetPlane() const
Definition
BmnTof1Digit.h:23
BmnTrigDigit
Definition
BmnTrigDigit.h:7
BmnTrigDigit::GetAmp
Double_t GetAmp() const
Definition
BmnTrigDigit.h:19
BmnTrigDigit::GetMod
Short_t GetMod() const
Definition
BmnTrigDigit.h:15
TChain
TChain::SetBranchAddress
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
TChain::Add
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
TChain::GetEntries
Long64_t GetEntries() const override
TChain::GetEntry
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
TClonesArray
TClonesArray::Delete
void Delete(Option_t *option="") override
TDirectoryFile::cd
Bool_t cd() override
TFile
TFile::Close
void Close(Option_t *option="") override
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TString
TString::Replace
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
TString::First
Ssiz_t First(char c) const
TString::Data
const char * Data() const
TTree
TTree::Fill
virtual Int_t Fill()
TTree::Write
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
TTree::Branch
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
TVector3
TVector3::Z
Double_t Z() const
TVector3::SetXYZ
void SetXYZ(Double_t x, Double_t y, Double_t z)
TVector3::Y
Double_t Y() const
TVector3::X
Double_t X() const
NHitBD
Double_t NHitBD
Definition
ToF400_Digit2Hit_Run7_SRC.C:19
TimeBD
Double_t TimeBD
Definition
ToF400_Digit2Hit_Run7_SRC.C:19
FlagHit
Bool_t FlagHit
Definition
ToF400_Digit2Hit_Run7_SRC.C:21
AmpBD
Double_t AmpBD
Definition
ToF400_Digit2Hit_Run7_SRC.C:19
YforHit
Int_t YforHit
Definition
ToF400_Digit2Hit_Run7_SRC.C:22
XforHit
Int_t XforHit
Definition
ToF400_Digit2Hit_Run7_SRC.C:22
NDet
const Int_t NDet
Definition
ToF400_Digit2Hit_Run7_SRC.C:23
ToF400_Digit2Hit_Run7_SRC
void ToF400_Digit2Hit_Run7_SRC(TString file="/home/storage/digits/SRC/bmn_run3482_digi.root", Int_t nEvForRead=0)
Definition
ToF400_Digit2Hit_Run7_SRC.C:25
std
Definition
json.hpp:4446
macro
detectors
tof_400
ToF400_Digit2Hit_Run7_SRC.C
Generated on
for BmnRoot by
1.17.0