-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathR3BFi12.cxx
318 lines (279 loc) · 10.9 KB
/
R3BFi12.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/******************************************************************************
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
* Copyright (C) 2019 Members of R3B Collaboration *
* *
* This software is distributed under the terms of the *
* GNU General Public Licence (GPL) version 3, *
* copied verbatim in the file "LICENSE". *
* *
* In applying this license GSI does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
******************************************************************************/
#include "R3BFi12.h"
#include "FairGeoInterface.h"
#include "FairGeoLoader.h"
#include "FairGeoNode.h"
#include "FairGeoRootBuilder.h"
#include "FairRootManager.h"
#include "FairRun.h"
#include "FairRuntimeDb.h"
#include "FairVolume.h"
#include "R3BFibPoint.h"
//#include "R3BGeoFi12.h"
#include "R3BMCStack.h"
#include "R3BTGeoPar.h"
#include "TClonesArray.h"
#include "TGeoArb8.h"
#include "TGeoBBox.h"
#include "TGeoBoolNode.h"
#include "TGeoCompositeShape.h"
#include "TGeoCone.h"
#include "TGeoMCGeometry.h"
#include "TGeoManager.h"
#include "TGeoMaterial.h"
#include "TGeoMatrix.h"
#include "TGeoMedium.h"
#include "TGeoPara.h"
#include "TGeoPgon.h"
#include "TGeoSphere.h"
#include "TObjArray.h"
#include "TParticle.h"
#include "TVirtualMC.h"
#include <stdlib.h>
R3BFi12::R3BFi12()
: R3BFi12("")
{
}
R3BFi12::R3BFi12(const TString& geoFile, const TGeoTranslation& trans, const TGeoRotation& rot)
: R3BFi12(geoFile, { trans, rot })
{
}
R3BFi12::R3BFi12(const TString& geoFile, const TGeoCombiTrans& combi)
: R3BDetector("R3BFI12", kFI12, geoFile, combi)
, fFi12Collection(new TClonesArray("R3BFibPoint"))
, fPosIndex(0)
, kGeoSaved(kFALSE)
, flGeoPar(new TList())
{
flGeoPar->SetName(GetName());
ResetParameters();
}
R3BFi12::~R3BFi12()
{
if (flGeoPar)
{
delete flGeoPar;
}
if (fFi12Collection)
{
fFi12Collection->Delete();
delete fFi12Collection;
}
}
void R3BFi12::Initialize()
{
FairDetector::Initialize();
LOG(INFO) << "R3BFi12: initialisation";
LOG(DEBUG) << "R3BFi12: Vol. (McId) " << gMC->VolId("FI12Log");
}
void R3BFi12::SetSpecialPhysicsCuts()
{
LOG(INFO) << "-I- R3BFi12: Adding customized Physics cut ... ";
if (gGeoManager)
{
TGeoMedium* pSi = gGeoManager->GetMedium("silicon");
if (pSi)
{
// Setting processes for Si only
gMC->Gstpar(pSi->GetId(), "LOSS", 3);
gMC->Gstpar(pSi->GetId(), "STRA", 1.0);
gMC->Gstpar(pSi->GetId(), "PAIR", 1.0);
gMC->Gstpar(pSi->GetId(), "COMP", 1.0);
gMC->Gstpar(pSi->GetId(), "PHOT", 1.0);
gMC->Gstpar(pSi->GetId(), "ANNI", 1.0);
gMC->Gstpar(pSi->GetId(), "BREM", 1.0);
gMC->Gstpar(pSi->GetId(), "HADR", 1.0);
gMC->Gstpar(pSi->GetId(), "DRAY", 1.0);
gMC->Gstpar(pSi->GetId(), "DCAY", 1.0);
gMC->Gstpar(pSi->GetId(), "MULS", 1.0);
gMC->Gstpar(pSi->GetId(), "RAYL", 1.0);
// Setting Energy-CutOff for Si Only
Double_t cutE = fCutE; // GeV-> 1 keV
LOG(INFO) << "-I- R3BFi12: silicon Medium Id " << pSi->GetId() << " Energy Cut-Off : " << cutE << " GeV";
// Si
gMC->Gstpar(pSi->GetId(), "CUTGAM", cutE); /** gammas (GeV)*/
gMC->Gstpar(pSi->GetId(), "CUTELE", cutE); /** electrons (GeV)*/
gMC->Gstpar(pSi->GetId(), "CUTNEU", cutE); /** neutral hadrons (GeV)*/
gMC->Gstpar(pSi->GetId(), "CUTHAD", cutE); /** charged hadrons (GeV)*/
gMC->Gstpar(pSi->GetId(), "CUTMUO", cutE); /** muons (GeV)*/
gMC->Gstpar(pSi->GetId(), "BCUTE", cutE); /** electron bremsstrahlung (GeV)*/
gMC->Gstpar(pSi->GetId(), "BCUTM", cutE); /** muon and hadron bremsstrahlung(GeV)*/
gMC->Gstpar(pSi->GetId(), "DCUTE", cutE); /** delta-rays by electrons (GeV)*/
gMC->Gstpar(pSi->GetId(), "DCUTM", cutE); /** delta-rays by muons (GeV)*/
gMC->Gstpar(pSi->GetId(), "PPCUTM", -1.); /** direct pair production by muons (GeV)*/
}
} //! gGeoManager
}
// ----- Public method ProcessHits --------------------------------------
Bool_t R3BFi12::ProcessHits(FairVolume* vol)
{
// 2 Simple Det PLane
// get Info from DCH planes
Int_t copyNo = -1;
Int_t planeNr = -1;
// Get the Geo info from MC Point
gMC->CurrentVolID(copyNo);
gMC->CurrentVolOffID(1, planeNr);
if (gMC->IsTrackEntering())
{
fELoss = 0.;
// fTime = gMC->TrackTime() * 1.0e09;
// fLength = gMC->TrackLength();
fTime_in = gMC->TrackTime() * 1.0e09;
fLength_in = gMC->TrackLength();
gMC->TrackPosition(fPosIn);
gMC->TrackMomentum(fMomIn);
}
// Sum energy loss for all steps in the active volume
fELoss += gMC->Edep();
// Set additional parameters at exit of active volume. Create R3BFi12Point.
if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared())
{
fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
fVolumeID = vol->getMotherCopyNo();
gMC->TrackPosition(fPosOut);
gMC->TrackMomentum(fMomOut);
// if (fELoss == 0.)
// return kFALSE;
fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays...
fLength_out = gMC->TrackLength();
fTime = (fTime_out + fTime_in) / 2.;
fLength = (fLength_out + fLength_in) / 2.;
if (gMC->IsTrackExiting())
{
const Double_t* oldpos;
const Double_t* olddirection;
Double_t newpos[3];
Double_t newdirection[3];
Double_t safety;
gGeoManager->FindNode(fPosOut.X(), fPosOut.Y(), fPosOut.Z());
oldpos = gGeoManager->GetCurrentPoint();
olddirection = gGeoManager->GetCurrentDirection();
for (Int_t i = 0; i < 3; i++)
{
newdirection[i] = -1 * olddirection[i];
}
gGeoManager->SetCurrentDirection(newdirection);
// TGeoNode *bla = gGeoManager->FindNextBoundary(2);
safety = gGeoManager->GetSafeDistance();
gGeoManager->SetCurrentDirection(-newdirection[0], -newdirection[1], -newdirection[2]);
for (Int_t i = 0; i < 3; i++)
{
newpos[i] = oldpos[i] - (3 * safety * olddirection[i]);
}
fPosOut.SetX(newpos[0]);
fPosOut.SetY(newpos[1]);
fPosOut.SetZ(newpos[2]);
}
AddHit(fTrackID,
/*fVolumeID*/ /*copyNo*/ planeNr,
planeNr,
TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()),
TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()),
TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()),
TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()),
fTime,
fLength,
fELoss);
// Increment number of Fi12Points for this track
R3BStack* stack = (R3BStack*)gMC->GetStack();
stack->AddPoint(kFI12);
ResetParameters();
}
return kTRUE;
}
// ----- Public method EndOfEvent -----------------------------------------
void R3BFi12::BeginEvent() {}
// ----- Public method EndOfEvent -----------------------------------------
void R3BFi12::EndOfEvent()
{
if (fVerboseLevel)
Print();
fFi12Collection->Clear();
ResetParameters();
}
// ----------------------------------------------------------------------------
// ----- Public method Register -------------------------------------------
void R3BFi12::Register() { FairRootManager::Instance()->Register("Fi12Point", GetName(), fFi12Collection, kTRUE); }
// ----------------------------------------------------------------------------
// ----- Public method GetCollection --------------------------------------
TClonesArray* R3BFi12::GetCollection(Int_t iColl) const
{
if (iColl == 0)
return fFi12Collection;
else
return NULL;
}
// ----------------------------------------------------------------------------
// ----- Public method Print ----------------------------------------------
void R3BFi12::Print(Option_t* option) const
{
Int_t nHits = fFi12Collection->GetEntriesFast();
LOG(INFO) << "R3BFi12: " << nHits << " points registered in this event";
}
// ----------------------------------------------------------------------------
// ----- Public method Reset ----------------------------------------------
void R3BFi12::Reset()
{
fFi12Collection->Clear();
ResetParameters();
}
// ----------------------------------------------------------------------------
// ----- Public method CopyClones -----------------------------------------
void R3BFi12::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)
{
Int_t nEntries = cl1->GetEntriesFast();
LOG(INFO) << "R3BFi12: " << nEntries << " entries to add";
TClonesArray& clref = *cl2;
R3BFibPoint* oldpoint = NULL;
for (Int_t i = 0; i < nEntries; i++)
{
oldpoint = (R3BFibPoint*)cl1->At(i);
Int_t index = oldpoint->GetTrackID() + offset;
oldpoint->SetTrackID(index);
new (clref[fPosIndex]) R3BFibPoint(*oldpoint);
fPosIndex++;
}
LOG(INFO) << "R3BFi12: " << cl2->GetEntriesFast() << " merged entries";
}
// ----- Private method AddHit --------------------------------------------
R3BFibPoint* R3BFi12::AddHit(Int_t trackID,
Int_t detID,
Int_t plane,
TVector3 posIn,
TVector3 posOut,
TVector3 momIn,
TVector3 momOut,
Double_t time,
Double_t length,
Double_t eLoss)
{
TClonesArray& clref = *fFi12Collection;
Int_t size = clref.GetEntriesFast();
if (fVerboseLevel > 1)
{
LOG(INFO) << "R3BFi12: Adding Point at (" << posIn.X() << ", " << posIn.Y() << ", " << posIn.Z()
<< ") cm, detector " << detID << ", track " << trackID << ", energy loss " << eLoss * 1e06 << " keV";
}
return new (clref[size]) R3BFibPoint(trackID, detID, plane, posIn, posOut, momIn, momOut, time, length, eLoss);
}
Bool_t R3BFi12::CheckIfSensitive(std::string name)
{
if (TString(name).Contains("FI12LogActive"))
{
return kTRUE;
}
return kFALSE;
}
ClassImp(R3BFi12)