BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnArmTrig.cxx
Go to the documentation of this file.
1
#include "FairGeoInterface.h"
2
#include "FairGeoLoader.h"
3
#include "FairGeoNode.h"
4
#include "
TClonesArray.h
"
5
#include "
TGeoArb8.h
"
6
#include "TGeoMCGeometry.h"
7
#include "
TGeoManager.h
"
8
#include "
TLorentzVector.h
"
9
#include "
TParticle.h
"
10
#include "TVirtualMC.h"
11
12
#include <iostream>
13
// #include "BmnArmTrigGeo.h"
14
#include "
BmnArmTrig.h
"
15
#include "
BmnArmTrigPoint.h
"
16
#include "CbmStack.h"
17
#include "FairGeoRootBuilder.h"
18
#include "FairMCPoint.h"
19
#include "FairRootManager.h"
20
#include "FairVolume.h"
21
#include "
TVector3.h
"
22
// add on for debug
23
// #include "FairGeoG3Builder.h"
24
#include "FairRun.h"
25
#include "FairRuntimeDb.h"
26
#include "
TObjArray.h
"
27
#include "
TParticlePDG.h
"
28
29
// ----- Default constructor -------------------------------------------
30
31
BmnArmTrig::BmnArmTrig
()
32
{
33
fArmTrigCollection
=
new
TClonesArray
(
"BmnArmTrigPoint"
);
34
volDetector
= 0;
35
fPosIndex
= 0;
36
// fpreflag = 0;
37
// fpostflag = 0;
38
// fEventID=-1;
39
fVerboseLevel = 1;
40
}
41
// -------------------------------------------------------------------------
42
43
// ----- Standard constructor ------------------------------------------
44
45
BmnArmTrig::BmnArmTrig
(
const
char
* name,
Bool_t
active)
46
:
FairDetector
(name, active)
47
{
48
fArmTrigCollection
=
new
TClonesArray
(
"BmnArmTrigPoint"
);
49
fPosIndex
= 0;
50
volDetector
= 0;
51
// fpreflag = 0;
52
// fpostflag = 0;
53
// fEventID=-1;
54
fVerboseLevel = 1;
55
}
56
// -------------------------------------------------------------------------
57
58
// ----- Destructor ----------------------------------------------------
59
60
BmnArmTrig::~BmnArmTrig
()
61
{
62
if
(
fArmTrigCollection
) {
63
fArmTrigCollection
->Delete();
64
delete
fArmTrigCollection
;
65
}
66
}
67
// -------------------------------------------------------------------------
68
69
// ----- Public method Intialize ---------------------------------------
70
71
void
BmnArmTrig::Initialize
()
72
{
73
// Init function
74
75
FairDetector::Initialize();
76
// FairRun* sim = FairRun::Instance();
77
// FairRuntimeDb* rtdb = sim->GetRuntimeDb();
78
}
79
// -------------------------------------------------------------------------
80
81
void
BmnArmTrig::BeginEvent
()
82
{
83
// Begin of the event
84
}
85
86
// ----- Public method ProcessHits --------------------------------------
87
Bool_t
BmnArmTrig::ProcessHits
(FairVolume* vol)
88
{
89
90
static
Double_t
timeIn;
91
static
Double_t
timeOut;
92
static
Double_t
lengthtrack;
93
94
Int_t
ivol = vol->getMCid();
95
96
if
(gMC->IsTrackEntering()) {
97
98
ResetParameters
();
99
100
fELoss
= 0.;
101
fIsPrimary
= 0;
102
fCharge
= -1;
103
fPdgId
= 0;
104
105
lengthtrack = 0.;
106
107
TLorentzVector
PosIn;
108
gMC->TrackPosition(PosIn);
109
fPosIn
.SetXYZ(PosIn.
X
(), PosIn.
Y
(), PosIn.
Z
());
110
111
TLorentzVector
MomIn;
112
gMC->TrackMomentum(MomIn);
113
fMomIn
.SetXYZ(MomIn.
Px
(), MomIn.
Py
(), MomIn.
Pz
());
114
115
timeIn = gMC->TrackTime() * 1.0e09;
116
117
TParticle
* part = 0;
118
part = gMC->GetStack()->GetCurrentTrack();
119
120
if
(part) {
121
fIsPrimary
= (
Int_t
)part->
IsPrimary
();
122
fCharge
= (
Int_t
)part->
GetPDG
()->
Charge
() / 3.;
123
fPdgId
= (
Int_t
)part->
GetPdgCode
();
124
}
125
}
126
127
Double_t
eLoss = gMC->Edep();
128
if
(eLoss > 0)
129
fELoss
+= eLoss;
130
131
Double_t
slengthtrack = gMC->TrackStep();
132
lengthtrack += slengthtrack;
133
134
if
((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && (
fELoss
> 0)) {
135
TLorentzVector
PosOut;
136
gMC->TrackPosition(PosOut);
137
fPosOut
.SetXYZ(PosOut.
X
(), PosOut.
Y
(), PosOut.
Z
());
138
139
TLorentzVector
MomOut;
140
gMC->TrackMomentum(MomOut);
141
fMomOut
.SetXYZ(MomOut.
Px
(), MomOut.
Py
(), MomOut.
Pz
());
142
143
timeOut = gMC->TrackTime() * 1.0e09;
144
145
fTrackID
= gMC->GetStack()->GetCurrentTrackNumber();
146
147
Double_t
time = gMC->TrackTime() * 1.0e09;
148
Double_t
length = gMC->TrackLength();
149
150
Int_t
copyNo = 0;
151
152
Int_t
iCell;
153
gMC->CurrentVolOffID(1, iCell);
154
155
AddHit
(
fTrackID
, ivol, copyNo,
fPosIn
,
fPosOut
,
fMomIn
,
fMomOut
, time, length,
fELoss
,
fIsPrimary
,
fCharge
,
156
fPdgId
, timeIn, timeOut, lengthtrack);
157
158
((
CbmStack
*)gMC->GetStack())->AddPoint(
kARMTRIG
);
159
}
160
161
return
kTRUE
;
162
}
163
164
// ----- Public method EndOfEvent -----------------------------------------
165
166
void
BmnArmTrig::EndOfEvent
()
167
{
168
if
(fVerboseLevel)
169
Print
(
""
);
170
Reset
();
171
}
172
173
// ----- Public method Register -------------------------------------------
174
175
void
BmnArmTrig::Register
()
176
{
177
FairRootManager::Instance()->Register(
"ArmTrigPoint"
,
"ArmTrig"
,
fArmTrigCollection
,
kTRUE
);
178
}
179
180
// ----- Public method GetCollection --------------------------------------
181
182
TClonesArray
*
BmnArmTrig::GetCollection
(
Int_t
iColl)
const
183
{
184
if
(iColl == 0)
185
return
fArmTrigCollection
;
186
187
return
NULL;
188
}
189
190
// ----- Public method Print ----------------------------------------------
191
192
void
BmnArmTrig::Print
(
Option_t
*)
const
193
{
194
Int_t
nHits =
fArmTrigCollection
->GetEntriesFast();
195
cout <<
"-I- BmnArmTrig: "
<< nHits <<
" points registered in this event."
<< endl;
196
197
if
(fVerboseLevel > 1)
198
for
(
Int_t
i
= 0;
i
< nHits;
i
++)
199
(*
fArmTrigCollection
)[
i
]->Print();
200
}
201
202
// ----- Public method Reset ----------------------------------------------
203
204
void
BmnArmTrig::Reset
()
205
{
206
fArmTrigCollection
->Delete();
207
208
fPosIndex
= 0;
209
}
210
211
// guarda in FairRootManager::CopyClones
212
// ----- Public method CopyClones -----------------------------------------
213
214
void
BmnArmTrig::CopyClones
(
TClonesArray
* cl1,
TClonesArray
* cl2,
Int_t
offset)
215
{
216
Int_t
nEntries = cl1->
GetEntriesFast
();
217
// cout << "-I- BmnArmTrig: " << nEntries << " entries to add." << endl;
218
TClonesArray
& clref = *cl2;
219
BmnArmTrigPoint
* oldpoint = NULL;
220
for
(
Int_t
i
= 0;
i
< nEntries;
i
++) {
221
oldpoint = (
BmnArmTrigPoint
*)cl1->
At
(
i
);
222
Int_t
index = oldpoint->GetTrackID() + offset;
223
oldpoint->SetTrackID(index);
224
new
(clref[
fPosIndex
])
BmnArmTrigPoint
(*oldpoint);
225
fPosIndex
++;
226
}
227
cout <<
" -I- BmnArmTrig: "
<< cl2->
GetEntriesFast
() <<
" merged entries."
<< endl;
228
}
229
230
//--------------------------------------------------------------------------------------------------------------------------------------
231
232
void
BmnArmTrig::ConstructGeometry
()
233
{
234
TString
fileName = GetGeometryFileName();
235
236
cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
<< fileName << endl;
237
238
if
(fileName.
EndsWith
(
".root"
)) {
239
LOG(info) <<
"Constructing ArmTrig geometry from ROOT file "
<< fileName.
Data
();
240
ConstructRootGeometry();
241
}
else
if
(fileName.
EndsWith
(
".geo"
)) {
242
LOG(info) <<
"Constructing ArmTrig geometry from ASCII file "
<< fileName.
Data
();
243
ConstructAsciiGeometry
();
244
}
else
245
LOG(fatal) <<
"Geometry format of ArmTrig file "
<< fileName.
Data
() <<
" not supported."
;
246
}
247
//--------------------------------------------------------------------------------------------------------------------------------------
248
249
void
BmnArmTrig::ConstructAsciiGeometry
()
250
{
251
// FairGeoLoader* geoLoad = FairGeoLoader::Instance();
252
// FairGeoInterface* geoFace = geoLoad->getGeoInterface();
253
// BmnArmTrigGeo* ArmTrigGeo = new BmnArmTrigGeo();
254
// ArmTrigGeo->setGeomFile(GetGeometryFileName());
255
// geoFace->addGeoModule(ArmTrigGeo);
256
//
257
// Bool_t rc = geoFace->readSet(ArmTrigGeo);
258
// if (rc) ArmTrigGeo->create(geoLoad->getGeoBuilder());
259
// TList* volList = ArmTrigGeo->getListOfVolumes();
260
//
261
// // store geo parameter
262
// FairRun *fRun = FairRun::Instance();
263
// FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb();
264
// BmnArmTrigGeoPar* par = (BmnArmTrigGeoPar*) (rtdb->getContainer("BmnArmTrigGeoPar"));
265
// TObjArray *fSensNodes = par->GetGeoSensitiveNodes();
266
// TObjArray *fPassNodes = par->GetGeoPassiveNodes();
267
//
268
// TListIter iter(volList);
269
// FairGeoNode *node = nullptr;
270
// FairGeoVolume *aVol = nullptr;
271
//
272
// while ((node = (FairGeoNode*) iter.Next())) {
273
// aVol = dynamic_cast<FairGeoVolume*> (node);
274
//
275
// if (node->isSensitive()) fSensNodes->AddLast(aVol);
276
// else fPassNodes->AddLast(aVol);
277
// }
278
//
279
// par->setChanged();
280
// par->setInputVersion(fRun->GetRunId(), 1);
281
// ProcessNodes(volList);
282
}
283
284
//--------------------------------------------------------------------------------------------------------------------------------------
285
286
Bool_t
BmnArmTrig::CheckIfSensitive
(std::string name)
287
{
288
TString
tsname = name;
289
if
(tsname.
Contains
(
"Active"
))
290
return
kTRUE
;
291
292
return
kFALSE
;
293
}
294
//-------------------------------------------------------------------------
295
296
// ----- Private method AddHit --------------------------------------------
297
298
BmnArmTrigPoint
*
BmnArmTrig::AddHit
(
Int_t
trackID,
299
Int_t
detID,
300
Int_t
copyNo,
301
TVector3
posIn,
302
TVector3
posOut,
303
TVector3
momIn,
304
TVector3
momOut,
305
Double_t
time,
306
Double_t
length,
307
Double_t
eLoss,
308
Bool_t
isPrimary,
309
Double_t
charge,
310
Int_t
pdgId,
311
Double_t
timeIn,
312
Double_t
timeOut,
313
Double_t
lengthtrack)
314
{
315
316
TClonesArray
& clref = *
fArmTrigCollection
;
317
Int_t
size = clref.
GetEntriesFast
();
318
return
new
(clref[size])
BmnArmTrigPoint
(trackID, detID, copyNo, posIn, posOut, momIn, momOut, time, length, eLoss,
319
isPrimary, charge, pdgId, timeIn, timeOut, lengthtrack);
320
}
i
int i
Definition
P4_F32vec4.h:22
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
TClonesArray.h
TGeoArb8.h
TGeoManager.h
TLorentzVector.h
TObjArray.h
TParticlePDG.h
TParticle.h
TVector3.h
kARMTRIG
@ kARMTRIG
Definition
BmnDetectorList.h:30
BmnArmTrigPoint
Definition
BmnArmTrigPoint.h:19
BmnArmTrig::fIsPrimary
Int_t fIsPrimary
MC volume ID of MUO.
Definition
BmnArmTrig.h:134
BmnArmTrig::fPosIn
TVector3 fPosIn
volume id
Definition
BmnArmTrig.h:125
BmnArmTrig::CheckIfSensitive
virtual Bool_t CheckIfSensitive(std::string name)
Definition
BmnArmTrig.cxx:286
BmnArmTrig::fMomIn
TVector3 fMomIn
position (out)
Definition
BmnArmTrig.h:127
BmnArmTrig::BeginEvent
virtual void BeginEvent()
Definition
BmnArmTrig.cxx:81
BmnArmTrig::fPdgId
Int_t fPdgId
track charge
Definition
BmnArmTrig.h:136
BmnArmTrig::Reset
virtual void Reset()
Virtual method Reset.
Definition
BmnArmTrig.cxx:204
BmnArmTrig::Initialize
virtual void Initialize()
Virtual method Initialize Initialises detector.
Definition
BmnArmTrig.cxx:71
BmnArmTrig::Register
virtual void Register()
Virtual method Register.
Definition
BmnArmTrig.cxx:175
BmnArmTrig::AddHit
BmnArmTrigPoint * AddHit(Int_t trackID, Int_t detID, Int_t copyNo, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Bool_t isPrimary, Double_t charge, Int_t pdgId, Double_t timeIn, Double_t timeOut, Double_t lengthtrack)
Definition
BmnArmTrig.cxx:298
BmnArmTrig::fELoss
Double32_t fELoss
length
Definition
BmnArmTrig.h:131
BmnArmTrig::CopyClones
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Virtual method CopyClones.
Definition
BmnArmTrig.cxx:214
BmnArmTrig::fPosOut
TVector3 fPosOut
position (in)
Definition
BmnArmTrig.h:126
BmnArmTrig::ConstructAsciiGeometry
virtual void ConstructAsciiGeometry()
Definition
BmnArmTrig.cxx:249
BmnArmTrig::volDetector
Int_t volDetector
Definition
BmnArmTrig.h:133
BmnArmTrig::fArmTrigCollection
TClonesArray * fArmTrigCollection
Definition
BmnArmTrig.h:138
BmnArmTrig::fMomOut
TVector3 fMomOut
momentum (in)
Definition
BmnArmTrig.h:128
BmnArmTrig::ProcessHits
virtual Bool_t ProcessHits(FairVolume *vol=0)
Virtual method ProcessHits.
Definition
BmnArmTrig.cxx:87
BmnArmTrig::fPosIndex
Int_t fPosIndex
energy loss
Definition
BmnArmTrig.h:132
BmnArmTrig::ConstructGeometry
virtual void ConstructGeometry()
Virtual method Construct geometry.
Definition
BmnArmTrig.cxx:232
BmnArmTrig::EndOfEvent
virtual void EndOfEvent()
Virtual method EndOfEvent.
Definition
BmnArmTrig.cxx:166
BmnArmTrig::BmnArmTrig
BmnArmTrig()
Default constructor.
Definition
BmnArmTrig.cxx:31
BmnArmTrig::~BmnArmTrig
virtual ~BmnArmTrig()
Destructor.
Definition
BmnArmTrig.cxx:60
BmnArmTrig::fTrackID
Int_t fTrackID
Definition
BmnArmTrig.h:122
BmnArmTrig::Print
virtual void Print(Option_t *) const
Virtual method Print.
Definition
BmnArmTrig.cxx:192
BmnArmTrig::fCharge
Double_t fCharge
is track primary?
Definition
BmnArmTrig.h:135
BmnArmTrig::ResetParameters
void ResetParameters()
length
Definition
BmnArmTrig.h:150
BmnArmTrig::GetCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
Definition
BmnArmTrig.cxx:182
CbmStack
CbmStack.h.
Definition
CbmStack.h:43
FairDetector
TClonesArray
TLorentzVector
TLorentzVector::Y
Double_t Y() const
TLorentzVector::Px
Double_t Px() const
TLorentzVector::Pz
Double_t Pz() const
TLorentzVector::X
Double_t X() const
TLorentzVector::Py
Double_t Py() const
TLorentzVector::Z
Double_t Z() const
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TParticlePDG::Charge
Double_t Charge() const
TParticle
TParticle::GetPdgCode
Int_t GetPdgCode() const
TParticle::GetPDG
TParticlePDG * GetPDG(Int_t mode=0) const
TParticle::IsPrimary
Bool_t IsPrimary() const
TString
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
TString::Data
const char * Data() const
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TVector3
BmnArmTrigPoint.h
BmnArmTrig.h
detectors
armTriggers
BmnArmTrig.cxx
Generated on
for BmnRoot by
1.17.0