BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnEcal.cxx
Go to the documentation of this file.
1
2
/*************************************************************************************
3
*
4
* Class BmnEcal
5
*
6
* Adopted for BMN by: Elena Litvinenko (EL)
7
* e-mail: litvin@nf.jinr.ru
8
* Version: 10-02-2016
9
* Last update: 10-02-2016 (EL)
10
* Updated: 23-06-2021 by Petr Alekseev <pnaleks@gmail.com>
11
*
12
************************************************************************************/
13
14
#include "
BmnEcal.h
"
15
16
#include "
BmnEcalGeo.h
"
17
#include "
BmnEcalPoint.h
"
18
#include "CbmStack.h"
19
#include "FairGeoInterface.h"
20
#include "FairGeoLoader.h"
21
#include "FairGeoNode.h"
22
#include "FairGeoRootBuilder.h"
23
#include "FairRootManager.h"
24
#include "FairRun.h"
25
#include "FairRuntimeDb.h"
26
#include "FairVolume.h"
27
#include "
TClonesArray.h
"
28
#include "
TGeoArb8.h
"
29
#include "TGeoMCGeometry.h"
30
#include "
TGeoManager.h
"
31
#include "
TLorentzVector.h
"
32
#include "
TObjArray.h
"
33
#include "
TParticle.h
"
34
#include "
TParticlePDG.h
"
35
#include "TVirtualMC.h"
36
37
#include <iostream>
38
39
// ----- Default constructor -------------------------------------------
40
BmnEcal::BmnEcal
()
41
{
42
fEcalCollection
=
new
TClonesArray
(
"BmnEcalPoint"
);
43
fVerboseLevel = 1;
44
}
45
// -------------------------------------------------------------------------
46
47
// ----- Standard constructor ------------------------------------------
48
BmnEcal::BmnEcal
(
const
char
* name,
Bool_t
active)
49
:
FairDetector
(name, active)
50
{
51
fEcalCollection
=
new
TClonesArray
(
"BmnEcalPoint"
);
52
fVerboseLevel = 1;
53
}
54
// -------------------------------------------------------------------------
55
56
// ----- Destructor ----------------------------------------------------
57
BmnEcal::~BmnEcal
()
58
{
59
if
(
fEcalCollection
) {
60
fEcalCollection
->Delete();
61
delete
fEcalCollection
;
62
}
63
}
64
// -------------------------------------------------------------------------
65
66
// ----- Public method Intialize ---------------------------------------
67
void
BmnEcal::Initialize
()
68
{
69
// Init function
70
71
FairDetector::Initialize();
72
// FairRun* sim = FairRun::Instance();
73
// FairRuntimeDb* rtdb=sim->GetRuntimeDb();
74
}
75
// -------------------------------------------------------------------------
76
77
void
BmnEcal::BeginEvent
()
78
{
79
// Begin of the event
80
}
81
82
// ----- Public method ProcessHits --------------------------------------
83
Bool_t
BmnEcal::ProcessHits
(FairVolume* vol)
84
{
85
86
// #define EDEBUG
87
#ifdef EDEBUG
88
static
Int_t
lEDEBUGcounter = 0;
89
if
(lEDEBUGcounter < 1)
90
std::cout <<
"EDEBUG-- BmnEcal::ProcessHits: entered"
<< gMC->CurrentVolPath() << endl;
91
#endif
92
// #undef EDEBUG
93
94
if
(gMC->IsTrackEntering()) {
95
fELoss
= 0.;
96
fTime
= gMC->TrackTime() * 1.0e09;
97
fLength
= gMC->TrackLength();
98
gMC->TrackPosition(
fPos
);
99
gMC->TrackMomentum(
fMom
);
100
}
101
102
fELoss
+= gMC->Edep();
103
104
if
(gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
105
106
if
(
fELoss
== 0.)
107
return
kFALSE
;
108
109
fTrackID
= gMC->GetStack()->GetCurrentTrackNumber();
110
fVolumeID
= vol->getMCid();
111
112
// Using data of the exiting track instead of the entering (why?)
113
fTime
= gMC->TrackTime() * 1.0e09;
114
fLength
= gMC->TrackLength();
115
gMC->TrackPosition(
fPos
);
116
gMC->TrackMomentum(
fMom
);
117
118
Int_t
copyNo;
119
gMC->CurrentVolID(copyNo);
120
Int_t
copyNoMother;
121
gMC->CurrentVolOffID(1, copyNoMother);
122
123
AddHit
(
fTrackID
,
fVolumeID
, copyNo, copyNoMother,
TVector3
(
fPos
.X(),
fPos
.Y(),
fPos
.Z()),
124
TVector3
(
fMom
.Px(),
fMom
.Py(),
fMom
.Pz()),
fTime
,
fLength
,
fELoss
);
125
126
((
CbmStack
*)gMC->GetStack())->AddPoint(
kECAL
);
127
}
128
129
return
kTRUE
;
130
}
131
132
// ----------------------------------------------------------------------------
133
134
// ----- Public method EndOfEvent -----------------------------------------
135
void
BmnEcal::EndOfEvent
()
136
{
137
if
(fVerboseLevel)
138
Print
(
""
);
139
Reset
();
140
}
141
142
// ----- Public method Register -------------------------------------------
143
void
BmnEcal::Register
()
144
{
145
FairRootManager::Instance()->Register(
"EcalPoint"
,
"Ecal"
,
fEcalCollection
,
fToFile
);
146
}
147
148
// ----- Public method GetCollection --------------------------------------
149
TClonesArray
*
BmnEcal::GetCollection
(
Int_t
iColl)
const
150
{
151
if
(iColl == 0)
152
return
fEcalCollection
;
153
154
return
NULL;
155
}
156
157
// ----- Public method Print ----------------------------------------------
158
void
BmnEcal::Print
(
Option_t
*)
const
159
{
160
Int_t
nHits =
fEcalCollection
->GetEntriesFast();
161
cout <<
"-I- BmnEcal: "
<< nHits <<
" points registered in this event."
<< endl;
162
163
if
(fVerboseLevel > 1)
164
for
(
Int_t
i
= 0;
i
< nHits;
i
++)
165
(*
fEcalCollection
)[
i
]->Print();
166
}
167
168
// ----- Public method Reset ----------------------------------------------
169
void
BmnEcal::Reset
()
170
{
171
fEcalCollection
->Clear();
172
}
173
174
// guarda in FairRootManager::CopyClones
175
// ----- Public method CopyClones -----------------------------------------
176
void
BmnEcal::CopyClones
(
TClonesArray
* cl1,
TClonesArray
* cl2,
Int_t
offset)
177
{
178
Int_t
nEntries = cl1->
GetEntriesFast
();
179
// cout << "-I- BmnEcal: " << nEntries << " entries to add." << endl;
180
TClonesArray
& clref = *cl2;
181
BmnEcalPoint
* oldpoint = NULL;
182
for
(
Int_t
i
= 0;
i
< nEntries;
i
++) {
183
oldpoint = (
BmnEcalPoint
*)cl1->
At
(
i
);
184
Int_t
index = oldpoint->GetTrackID() + offset;
185
oldpoint->SetTrackID(index);
186
new
(clref[cl2->
GetEntriesFast
()])
BmnEcalPoint
(*oldpoint);
187
}
188
cout <<
" -I- BmnEcal: "
<< cl2->
GetEntriesFast
() <<
" merged entries."
<< endl;
189
}
190
191
// ----- Public method ConstructGeometry ----------------------------------
192
void
BmnEcal::ConstructGeometry
()
193
{
194
195
TString
geoFileName = GetGeometryFileName();
196
if
(geoFileName.
EndsWith
(
".root"
)) {
197
LOG(info) <<
"Constructing ECAL geometry from ROOT file "
<< geoFileName.
Data
();
198
ConstructRootGeometry();
199
return
;
200
}
201
202
FairGeoLoader* geoLoad = FairGeoLoader::Instance();
203
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
204
BmnEcalGeo
* ecalGeo =
new
BmnEcalGeo
();
205
ecalGeo->setGeomFile(GetGeometryFileName());
206
geoFace->addGeoModule(ecalGeo);
207
208
Bool_t
rc = geoFace->readSet(ecalGeo);
209
if
(rc)
210
ecalGeo->create(geoLoad->getGeoBuilder());
211
TList
* volList = ecalGeo->getListOfVolumes();
212
213
// store geo parameter
214
FairRun* fRun = FairRun::Instance();
215
FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
216
BmnEcalGeoPar
* par = (
BmnEcalGeoPar
*)(rtdb->getContainer(
"BmnEcalGeoPar"
));
217
TObjArray
* fSensNodes = par->
GetGeoSensitiveNodes
();
218
TObjArray
* fPassNodes = par->
GetGeoPassiveNodes
();
219
220
TListIter
iter(volList);
221
FairGeoNode* node = NULL;
222
FairGeoVolume* aVol = NULL;
223
224
while
((node = (FairGeoNode*)iter.
Next
())) {
225
aVol =
dynamic_cast<
FairGeoVolume*
>
(node);
226
227
if
(node->isSensitive()) {
228
fSensNodes->
AddLast
(aVol);
229
}
else
{
230
fPassNodes->
AddLast
(aVol);
231
}
232
}
233
par->setChanged();
234
par->setInputVersion(fRun->GetRunId(), 1);
235
236
ProcessNodes(volList);
237
}
238
239
// ----- Public method CheckIfSensitive -----------------------------------
240
Bool_t
BmnEcal::CheckIfSensitive
(std::string name)
241
{
242
TString
tsname = name;
243
if
(tsname.
Contains
(
"laySci"
))
244
return
kTRUE
;
// lay
245
246
return
kFALSE
;
247
}
248
249
// ----- Private method AddHit --------------------------------------------
250
BmnEcalPoint
*
BmnEcal::AddHit
(
Int_t
trackID,
251
Int_t
detID,
252
Int_t
copyNo,
253
Int_t
copyNoMother,
254
TVector3
pos,
255
TVector3
mom,
256
Double_t
time,
257
Double_t
length,
258
Double_t
eLoss)
259
{
260
TClonesArray
& clref = *
fEcalCollection
;
261
Int_t
size = clref.
GetEntriesFast
();
262
return
new
(clref[size])
BmnEcalPoint
(trackID, detID, copyNo, copyNoMother, pos, mom, time, length, eLoss);
263
}
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
kECAL
@ kECAL
Definition
BmnDetectorList.h:23
BmnEcalGeoPar
Definition
BmnEcalGeoPar.h:18
BmnEcalGeoPar::GetGeoSensitiveNodes
TObjArray * GetGeoSensitiveNodes()
Definition
BmnEcalGeoPar.h:30
BmnEcalGeoPar::GetGeoPassiveNodes
TObjArray * GetGeoPassiveNodes()
Definition
BmnEcalGeoPar.h:31
BmnEcalGeo
Definition
BmnEcalGeo.h:17
BmnEcalPoint
Definition
BmnEcalPoint.h:18
BmnEcal::~BmnEcal
virtual ~BmnEcal()
Destructor.
Definition
BmnEcal.cxx:57
BmnEcal::ProcessHits
virtual Bool_t ProcessHits(FairVolume *vol=0)
Virtual method ProcessHits.
Definition
BmnEcal.cxx:83
BmnEcal::CopyClones
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Virtual method CopyClones.
Definition
BmnEcal.cxx:176
BmnEcal::Register
virtual void Register()
Virtual method Register.
Definition
BmnEcal.cxx:143
BmnEcal::BmnEcal
BmnEcal()
Default constructor.
Definition
BmnEcal.cxx:40
BmnEcal::fELoss
Double32_t fELoss
length
Definition
BmnEcal.h:120
BmnEcal::fMom
TLorentzVector fMom
position
Definition
BmnEcal.h:117
BmnEcal::fPos
TLorentzVector fPos
volume id
Definition
BmnEcal.h:116
BmnEcal::AddHit
BmnEcalPoint * AddHit(Int_t trackID, Int_t detID, Int_t copyNo, Int_t copyNoMother, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss)
Definition
BmnEcal.cxx:250
BmnEcal::CheckIfSensitive
virtual Bool_t CheckIfSensitive(std::string name)
Definition
BmnEcal.cxx:240
BmnEcal::BeginEvent
virtual void BeginEvent()
Definition
BmnEcal.cxx:77
BmnEcal::fVolumeID
Int_t fVolumeID
track index
Definition
BmnEcal.h:115
BmnEcal::fTime
Double32_t fTime
momentum
Definition
BmnEcal.h:118
BmnEcal::Print
virtual void Print(Option_t *) const
Virtual method Print.
Definition
BmnEcal.cxx:158
BmnEcal::fEcalCollection
TClonesArray * fEcalCollection
energy loss
Definition
BmnEcal.h:122
BmnEcal::EndOfEvent
virtual void EndOfEvent()
Virtual method EndOfEvent.
Definition
BmnEcal.cxx:135
BmnEcal::fTrackID
Int_t fTrackID
Definition
BmnEcal.h:114
BmnEcal::GetCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
Definition
BmnEcal.cxx:149
BmnEcal::fToFile
Bool_t fToFile
Hit collection.
Definition
BmnEcal.h:124
BmnEcal::fLength
Double32_t fLength
time
Definition
BmnEcal.h:119
BmnEcal::Initialize
virtual void Initialize()
Virtual method Initialize Initialises detector.
Definition
BmnEcal.cxx:67
BmnEcal::ConstructGeometry
virtual void ConstructGeometry()
Virtual method Construct geometry.
Definition
BmnEcal.cxx:192
BmnEcal::Reset
virtual void Reset()
Virtual method Reset.
Definition
BmnEcal.cxx:169
CbmStack
CbmStack.h.
Definition
CbmStack.h:43
FairDetector
TClonesArray
TListIter
TListIter::Next
TObject * Next() override
TList
TObjArray
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObjArray::AddLast
void AddLast(TObject *obj) override
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
BmnEcalGeo.h
BmnEcalPoint.h
BmnEcal.h
detectors
ecal
BmnEcal.cxx
Generated on
for BmnRoot by
1.17.0