Skip to content

Commit c130e76

Browse files
committed
Finding detId from fMC
1 parent 4d834d7 commit c130e76

File tree

2 files changed

+21
-53
lines changed

2 files changed

+21
-53
lines changed

Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,19 @@ class Detector : public o2::base::DetImpl<Detector>
101101

102102
float ringSize(float zmod, float eta);
103103

104-
unsigned int mNumberOfSectors;
105-
unsigned int mNumberOfRingsA;
106-
unsigned int mNumberOfRingsC;
107-
float mDzScint;
108-
float mDzPlate;
104+
unsigned int mNumberOfRingsA, mNumberOfRingsC, mNumberOfSectors;
105+
float mDzScint, mDzPlate;
109106

110-
std::vector<float> mRingSizesA = {};
111-
std::vector<float> mRingSizesC = {};
107+
std::vector<float> mRingSizesA = {}, mRingSizesC = {};
112108

113-
float mEtaMaxA, mEtaMaxC;
114-
float mEtaMinA, mEtaMinC;
109+
float mEtaMaxA, mEtaMaxC, mEtaMinA, mEtaMinC;
115110
float mZA, mZC;
116111

117112
bool mPlateBehindA, mFullContainer;
118113

119114
void defineSensitiveVolumes();
120115
void definePassiveVolumes();
121116

122-
unsigned int getChannelId(TVector3 vec);
123-
124117
/// Transient data about track passing the sensor, needed by ProcessHits()
125118
struct TrackData { // this is transient
126119
bool mHitStarted; //! hit creation started

Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Detector::~Detector()
127127

128128
void Detector::InitializeO2Detector()
129129
{
130-
LOG(info) << "Initialize FD detector";
130+
LOG(info) << "Initialize Forward Detector";
131131
mGeometryTGeo = GeometryTGeo::Instance();
132132
defineSensitiveVolumes();
133133
}
@@ -139,6 +139,9 @@ bool Detector::ProcessHits(FairVolume* vol)
139139
return kFALSE;
140140
}
141141

142+
int detId;
143+
int volID = fMC->CurrentVolID(detId);
144+
142145
auto stack = (o2::data::Stack*)fMC->GetStack();
143146

144147
// Check track status to define when hit is started and when it is stopped
@@ -170,7 +173,6 @@ bool Detector::ProcessHits(FairVolume* vol)
170173
TLorentzVector positionStop;
171174
fMC->TrackPosition(positionStop);
172175
int trackId = stack->GetCurrentTrackNumber();
173-
unsigned int detId = getChannelId(mTrackData.mPositionStart.Vect());
174176

175177
math_utils::Point3D<float> posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z());
176178
math_utils::Point3D<float> posStop(positionStop.X(), positionStop.Y(), positionStop.Z());
@@ -186,7 +188,7 @@ bool Detector::ProcessHits(FairVolume* vol)
186188
return true;
187189
}
188190

189-
o2::fd::Hit* Detector::addHit(int trackId, unsigned int cellId,
191+
o2::fd::Hit* Detector::addHit(int trackId, unsigned int detId,
190192
const math_utils::Point3D<float>& startPos,
191193
const math_utils::Point3D<float>& endPos,
192194
const math_utils::Vector3D<float>& startMom,
@@ -195,7 +197,7 @@ o2::fd::Hit* Detector::addHit(int trackId, unsigned int cellId,
195197
double eLoss,
196198
int particlePdg)
197199
{
198-
mHits->emplace_back(trackId, cellId, startPos,
200+
mHits->emplace_back(trackId, detId, startPos,
199201
endPos, startMom, startE, endTime, eLoss, particlePdg);
200202
return &(mHits->back());
201203
}
@@ -277,14 +279,14 @@ void Detector::buildModules()
277279
TGeoVolume* vCave = gGeoManager->GetVolume("cave");
278280

279281
if (!vCave) {
280-
LOG(fatal) << "Could not find the top volume (cave)!";
282+
LOG(fatal) << "Could not find the top volume!";
281283
}
282284

283285
TGeoVolumeAssembly* vFDA = buildModuleA();
284286
TGeoVolumeAssembly* vFDC = buildModuleC();
285287

286288
vCave->AddNode(vFDA, 1, new TGeoTranslation(0., 0., mZA));
287-
vCave->AddNode(vFDC, 1, new TGeoTranslation(0., 0., mZC));
289+
vCave->AddNode(vFDC, 2, new TGeoTranslation(0., 0., mZC));
288290
}
289291

290292
TGeoVolumeAssembly* Detector::buildModuleA()
@@ -311,7 +313,7 @@ TGeoVolumeAssembly* Detector::buildModuleA()
311313
nod->SetLineColor(kRed);
312314
ring->AddNode(nod, cellId);
313315
}
314-
mod->AddNode(ring, 1);
316+
mod->AddNode(ring, ir + 1);
315317
}
316318

317319
// Aluminium plates on one or both sides of the A side module
@@ -355,7 +357,7 @@ TGeoVolumeAssembly* Detector::buildModuleC()
355357
nod->SetLineColor(kBlue);
356358
ring->AddNode(nod, cellId);
357359
}
358-
mod->AddNode(ring, 1);
360+
mod->AddNode(ring, ir + 1);
359361
}
360362

361363
// Aluminium plates on both sides of the C side module
@@ -368,7 +370,7 @@ TGeoVolumeAssembly* Detector::buildModuleC()
368370
double dpz = mDzScint / 2 + mDzPlate / 2;
369371

370372
mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz));
371-
mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, -dpz));
373+
mod->AddNode(pnod2, 2, new TGeoTranslation(0, 0, -dpz));
372374
}
373375

374376
return mod;
@@ -381,47 +383,20 @@ void Detector::defineSensitiveVolumes()
381383
TGeoVolume* v;
382384
TString volumeName;
383385

384-
int nCellA = mNumberOfRingsA * mNumberOfSectors;
385-
int nCellC = mNumberOfRingsC * mNumberOfSectors;
386+
int nCellsA = mNumberOfRingsA * mNumberOfSectors;
387+
int nCellsC = mNumberOfRingsC * mNumberOfSectors;
386388

387-
LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellA;
389+
LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellsA;
390+
LOG(info) << "number of C rings = " << mNumberOfRingsC << " number of cells = " << nCellsC;
388391

389-
for (int iv = 0; iv < nCellA + nCellC; iv++) {
392+
for (int iv = 0; iv < nCellsA + nCellsC; iv++) {
390393
volumeName = "fd_node" + std::to_string(iv);
391394
v = gGeoManager->GetVolume(volumeName);
392-
LOG(info) << "Adding FD Sensitive Volume => " << v->GetName();
395+
LOG(info) << "Adding sensitive volume => " << v->GetName();
393396
AddSensitiveVolume(v);
394397
}
395398
}
396399

397-
unsigned int Detector::getChannelId(TVector3 vec)
398-
{
399-
float phi = vec.Phi();
400-
if (phi < 0) {
401-
phi += TMath::TwoPi();
402-
}
403-
404-
float r = vec.Perp();
405-
float z = vec.Z();
406-
407-
int isect = int(phi / (TMath::TwoPi() / mNumberOfSectors));
408-
409-
std::vector<float> rd = z > 0 ? mRingSizesA : mRingSizesC;
410-
int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors;
411-
412-
int ir = 0;
413-
414-
for (int i = 1; i < rd.size(); i++) {
415-
if (r < rd[i]) {
416-
break;
417-
} else {
418-
ir++;
419-
}
420-
}
421-
422-
return ir * mNumberOfSectors + isect + noff;
423-
}
424-
425400
float Detector::ringSize(float z, float eta)
426401
{
427402
return z * TMath::Tan(2 * TMath::ATan(TMath::Exp(-eta)));

0 commit comments

Comments
 (0)