Skip to content

Commit

Permalink
fix channel ids
Browse files Browse the repository at this point in the history
  • Loading branch information
pkurash committed Sep 18, 2024
1 parent c070c3f commit 1ea137b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class Detector : public o2::base::DetImpl<Detector>

void defineSensitiveVolumes();

int getChannelId(TVector3 vec);

/// Transient data about track passing the sensor, needed by ProcessHits()
struct TrackData { // this is transient
bool mHitStarted; //! hit creation started
Expand Down
39 changes: 32 additions & 7 deletions Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ bool Detector::ProcessHits(FairVolume* vol)
if (stopHit) {
TLorentzVector positionStop;
fMC->TrackPosition(positionStop);
Int_t trackId = fMC->GetStack()->GetCurrentTrackNumber();
int trackId = fMC->GetStack()->GetCurrentTrackNumber();

Hit *p = addHit(trackId, cellId, mTrackData.mPositionStart.Vect(), positionStop.Vect(),
int chId = getChannelId(mTrackData.mPositionStart.Vect());

Hit *p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(),
mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(),
positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart,
status);
Expand Down Expand Up @@ -199,7 +201,6 @@ void Detector::ConstructGeometry()
{
createMaterials();
buildModules();
//defineSensitiveVolumes();
}

void Detector::EndOfEvent()
Expand Down Expand Up @@ -271,8 +272,8 @@ void Detector::buildModules()
TGeoVolumeAssembly* vFVDA = buildModuleA();
TGeoVolumeAssembly* vFVDC = buildModuleC();

vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA));
vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC));
vCave->AddNode(vFVDA, 2, new TGeoTranslation(0., 0., mZmodA));
vCave->AddNode(vFVDC, 2, new TGeoTranslation(0., 0., mZmodC));
}

TGeoVolumeAssembly* Detector::buildModuleA()
Expand All @@ -297,7 +298,7 @@ TGeoVolumeAssembly* Detector::buildModuleA()
auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium);
ring->AddNode(nod, cellId);
}
mod->AddNode(ring, ir);
mod->AddNode(ring, 1);
}

return mod;
Expand Down Expand Up @@ -325,7 +326,7 @@ TGeoVolumeAssembly* Detector::buildModuleC()
auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium);
ring->AddNode(nod, cellId);
}
mod->AddNode(ring, ir);
mod->AddNode(ring, 1);
}

return mod;
Expand All @@ -348,4 +349,28 @@ void Detector::defineSensitiveVolumes()
}
}

int Detector::getChannelId(TVector3 vec)
{
float phi = vec.Phi();
if (phi < 0) phi += TMath::TwoPi();
float r = vec.Perp();
float z = vec.Z();

int isect = int(phi/(TMath::Pi()/4));

std::vector<float>rd = z > 0 ? mRingRadiiA : mRingRadiiC;
int noff = z > 0 ? 0 : mNumberOfRingsA*mNumberOfSectors;

int ir = 0;

for (int i = 1; i < rd.size(); i++) {
if (r < rd[i])
break;
else
ir ++;
}

return ir * mNumberOfSectors + isect + noff;
}

ClassImp(o2::fvd::Detector);

0 comments on commit 1ea137b

Please sign in to comment.