Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Detectors/TPC/simulation/include/TPCSimulation/Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,8 @@ class Detector : public o2::base::DetImpl<Detector>
int mElectronCounter = 0;
int mStepCounter = 0;
double mLastReferenceR = 0; ///<! track length at the last stored track reference (cm)
ElementalHit mHitLast{}; ///<! buffer last processed hit to be able to fill it to mHitsPerSectorCollection
HitGroup* mCurrentGroup = nullptr; ///<! hit group currently being filled
int mOldTrackId = -1; ///<! track of the current hit group
int mOldSectorId = -1; ///<! sector of the current hit group
int mGroupCounter = 0; ///<! number of hits in the current hit group
int mCurrentSector = -1; ///<! sector of the current hit group

/// Create the detector materials
virtual void CreateMaterials();
Expand Down
43 changes: 7 additions & 36 deletions Detectors/TPC/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -280,42 +280,14 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
}

// ADD HIT
// the first hit of an event starts the grouping afresh
if (!mCurrentGroup) {
mOldTrackId = trackID;
mOldSectorId = sectorID;
mGroupCounter = 0;
}

// a new group is starting -> put it into the container
if (mGroupCounter == 0) {
mHitsPerSectorCollection[sectorID]->emplace_back(trackID);
mCurrentGroup = &(mHitsPerSectorCollection[sectorID]->back());
}
if (trackID == mOldTrackId && mOldSectorId == sectorID) {
mGroupCounter++;
mHitCounter++;
mElectronCounter += numberOfElectrons;
mCurrentGroup->addHit(position.X(), position.Y(), position.Z(), time, numberOfElectrons);

// add last buffered hit, which was not yet added to the current group
if (mHitLast.GetEnergyLoss() >= 0) {
mCurrentGroup->addHit(mHitLast.GetX(), mHitLast.GetY(), mHitLast.GetZ(), mHitLast.GetTime(), mHitLast.GetEnergyLoss());
mGroupCounter++;
mHitCounter++;
mElectronCounter += mHitLast.GetEnergyLoss();
mHitLast.mELoss = -1;
}
}
// finish group
else {
mOldTrackId = trackID;
mOldSectorId = sectorID;
mGroupCounter = 0;

// buffer this hit, otherwise it wouldnt be stored in the HitGroup
mHitLast = ElementalHit(position.X(), position.Y(), position.Z(), time, numberOfElectrons);
// start a new group for the first hit of an event and whenever the track or the sector changes
if (!mCurrentGroup || mCurrentGroup->GetTrackID() != trackID || mCurrentSector != sectorID) {
mCurrentGroup = &mHitsPerSectorCollection[sectorID]->emplace_back(trackID);
mCurrentSector = sectorID;
}
mCurrentGroup->addHit(position.X(), position.Y(), position.Z(), time, numberOfElectrons);
mHitCounter++;
mElectronCounter += numberOfElectrons;

// LOG(info) << "tpc::AddHit" << FairLogger::endl
//<< " -- " << trackNumberID <<"," << volumeID << " " << vol->GetName()
Expand All @@ -335,7 +307,6 @@ void Detector::EndOfEvent()
{
// the hit grouping must not carry over into the next event
mCurrentGroup = nullptr;
mHitLast.mELoss = -1;
if (!o2::utils::ShmManager::Instance().isOperational()) {
for (int i = 0; i < Sector::MAXSECTOR; ++i) {
mHitsPerSectorCollection[i]->clear();
Expand Down