Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "DetectorsBase/Detector.h"
#include "DataFormatsFDD/Hit.h"
#include "FDDBase/Geometry.h"
#include <TVector3.h>

class FairModule;
class FairVolume;
Expand Down Expand Up @@ -73,6 +74,11 @@ class Detector : public o2::base::DetImpl<Detector>
std::vector<o2::fdd::Hit>* mHits = nullptr;
int mTrackRefLastTrackID = -1; //! last track that received a TrackReference in the current event

// state of the hit being built across steps in ProcessHits
Float_t mElossAD = 0.; //! energy loss collected so far
Int_t mNPhotonsAD = 0; //! photons collected so far
TVector3 mHitPosAD; //! position where the track entered

Detector& operator=(const Detector&);

Geometry* mGeometry = nullptr; //! Geometry
Expand Down
18 changes: 6 additions & 12 deletions Detectors/FIT/FDD/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,23 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
Int_t nPhotonsInStep_ad = Int_t(fFDDLightYield * destep_ad);
nPhotonsInStep_ad = gRandom->Poisson(nPhotonsInStep_ad);

static Float_t eloss_ad = 0.;
static Float_t tlength_ad = 0.;
static Int_t nPhotons_ad = 0;

static TVector3 vPos;

eloss_ad += destep_ad;
mElossAD += destep_ad;

if (fMC->IsTrackEntering()) {
nPhotons_ad = nPhotonsInStep_ad;
fMC->TrackPosition(vPos(0), vPos(1), vPos(2));
mNPhotonsAD = nPhotonsInStep_ad;
fMC->TrackPosition(mHitPosAD(0), mHitPosAD(1), mHitPosAD(2));

eloss_ad = 0.0;
mElossAD = 0.0;
return kFALSE;
}
nPhotons_ad += nPhotonsInStep_ad;
mNPhotonsAD += nPhotonsInStep_ad;

if (fMC->IsTrackExiting() || fMC->IsTrackStop() || fMC->IsTrackDisappeared()) {
Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber();

Float_t time = fMC->TrackTime() * 1.0e9; //time from seconds to ns

addHit(trackID, ADsector, vPos, time, eloss_ad, nPhotons_ad);
addHit(trackID, ADsector, mHitPosAD, time, mElossAD, mNPhotonsAD);
return kTRUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class Detector : public o2::base::DetImpl<Detector>
int mHcel5VolID = -1;
int mHcel6VolID = -1;

// state of a charged-particle hit being built across steps in ProcessHits
Float_t mMipEloss = 0; //! energy loss collected in the amplification gap
Double_t mMipEntry[3] = {0, 0, 0}; //! position where the track entered the gap

template <typename Det>
friend class o2::base::DetImpl;
ClassDefOverride(Detector, 1);
Expand Down
24 changes: 11 additions & 13 deletions Detectors/HMPID/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ bool Detector::ProcessHits(FairVolume* v)
} // photon hit PC

// Treat charged particles
static Float_t eloss; // need to store mip parameters between different steps
static Double_t in[3];

if (fMC->IsTrackEntering() && fMC->TrackCharge() && (volID == mHpad0VolID || volID == mHpad1VolID || volID == mHpad2VolID || volID == mHpad3VolID || volID == mHpad4VolID || volID == mHpad5VolID || volID == mHpad6VolID)) {
// Trackref stored when entering in the pad volume
Expand All @@ -127,18 +125,18 @@ bool Detector::ProcessHits(FairVolume* v)
if (fMC->TrackCharge() && (volID == mHcel0VolID || volID == mHcel1VolID || volID == mHcel2VolID || volID == mHcel3VolID || volID == mHcel4VolID || volID == mHcel5VolID || volID == mHcel6VolID)) {
// charged particle in amplification gap (Hcel)
if (fMC->IsTrackEntering() || fMC->IsNewTrack()) { // entering or newly created
eloss = 0; // reset Eloss collector
fMC->TrackPosition(in[0], in[1], in[2]); // take position at the entrance
mMipEloss = 0; // reset Eloss collector
fMC->TrackPosition(mMipEntry[0], mMipEntry[1], mMipEntry[2]); // take position at the entrance
} else if (fMC->IsTrackExiting() || fMC->IsTrackStop() || fMC->IsTrackDisappeared()) { // exiting or disappeared
eloss += fMC->Edep(); // take into account last step Eloss
mMipEloss += fMC->Edep(); // take into account last step Eloss
Int_t tid = fMC->GetStack()->GetCurrentTrackNumber(); // take TID
Int_t pid = fMC->TrackPid(); // take PID
Double_t out[3];
fMC->TrackPosition(out[0], out[1], out[2]); // take MARS position at exit
Float_t hitTime = (Float_t)fMC->TrackTime(); // hit formation time
out[0] = 0.5 * (out[0] + in[0]); //
out[1] = 0.5 * (out[1] + in[1]); // take hit position at the anod plane
out[2] = 0.5 * (out[2] + in[2]);
out[0] = 0.5 * (out[0] + mMipEntry[0]); //
out[1] = 0.5 * (out[1] + mMipEntry[1]); // take hit position at the anod plane
out[2] = 0.5 * (out[2] + mMipEntry[2]);
Int_t idch; // chamber number
if (volID == mHcel0VolID) {
idch = 0;
Expand All @@ -157,16 +155,16 @@ bool Detector::ProcessHits(FairVolume* v)
}
Double_t xl, yl;
o2::hmpid::Param::instance()->mars2Lors(idch, out, xl, yl); // take LORS position
if (eloss > 0) {
if (mMipEloss > 0) {
// HIT for MIP, position near anod plane, eloss will be set to Q
AddHit(out[0], out[1], out[2], hitTime, eloss, tid, idch);
GenFee(eloss); // generate feedback photons
AddHit(out[0], out[1], out[2], hitTime, mMipEloss, tid, idch);
GenFee(mMipEloss); // generate feedback photons
stack->addHit(GetDetId());
eloss = 0;
mMipEloss = 0;
}
} else {
// just going inside
eloss += fMC->Edep(); // collect this step eloss
mMipEloss += fMC->Edep(); // collect this step eloss
}
return kTRUE;
} // MIP in GAP
Expand Down
2 changes: 2 additions & 0 deletions Detectors/Passive/include/DetectorsPassive/Cave.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class Cave : public FairDetector

bool mHasZDC = true; //! flag indicating if ZDC will be included
bool mHasRB24 = true; //! flag indicating if RB24 will be included
int mPrimaryCounter = 0; //! primaries started, for the internal chunk seeding
int mChunkSeedCounter = 1; //! next seed index of the internal chunk seeding
ClassDefOverride(o2::passive::Cave, 1);
};
} // namespace passive
Expand Down
11 changes: 4 additions & 7 deletions Detectors/Passive/src/Cave.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,19 @@ void Cave::FinishPrimary()
// setting
void Cave::BeginPrimary()
{
static int primcounter = 0;

// only do it, if not in pure trackSeeding mode
if (!o2::conf::SimCutParams::Instance().trackSeed) {
auto& conf = o2::conf::SimConfig::Instance();
auto chunks = conf.getInternalChunkSize();
if (chunks != -1) {
if (primcounter % chunks == 0) {
static int counter = 1;
auto seed = counter + 10;
if (mPrimaryCounter % chunks == 0) {
auto seed = mChunkSeedCounter + 10;
gRandom->SetSeed(seed);
counter++;
mChunkSeedCounter++;
}
}
}
primcounter++;
mPrimaryCounter++;
}

bool Cave::ProcessHits(FairVolume*)
Expand Down
3 changes: 2 additions & 1 deletion Detectors/TPC/simulation/include/TPCSimulation/Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class Detector : public o2::base::DetImpl<Detector>
int mHitCounter = 0;
int mElectronCounter = 0;
int mStepCounter = 0;
ElementalHit mHitLast{}; ///<! buffer last processed hit to be able to fill it to mHitsPerSectorCollection
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
Expand Down
11 changes: 5 additions & 6 deletions Detectors/TPC/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
mStepCounter++;
auto& gasParam = ParameterGas::Instance();
auto& detParam = ParameterDetector::Instance();
const Int_t kMaxDistRef = 15; // maximal difference between 2 stored references - the parameter should be 15 cm as default
static Double_t lastReferenceR = 0; // keeps last reference point in radius (cm)
const Int_t kMaxDistRef = 15; // maximal difference between 2 stored references - the parameter should be 15 cm as default

/* This method is called from the MC stepping for the sensitive volume only */
// LOG(info) << "tpc::ProcessHits";
Expand Down Expand Up @@ -166,7 +165,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
// if (sectorID != 0) return kFALSE;

// ---| momentum and beta gamma |---
static TLorentzVector momentum; // static to make avoid creation/deletion of this expensive object
TLorentzVector momentum;
fMC->TrackMomentum(momentum);

const float time = fMC->TrackTime() * 1.0e9;
Expand All @@ -175,12 +174,12 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
if (fMC->IsTrackEntering() || fMC->IsTrackExiting()) {
stack->addTrackReference(o2::TrackReference(position.X(), position.Y(), position.Z(), momentum.X(), momentum.Y(),
momentum.Z(), fMC->TrackLength(), time, trackID, GetDetId()));
lastReferenceR = fMC->TrackLength();
mLastReferenceR = fMC->TrackLength();
}
if (TMath::Abs(lastReferenceR - fMC->TrackLength()) > kMaxDistRef) { /// we can speedup
if (TMath::Abs(mLastReferenceR - fMC->TrackLength()) > kMaxDistRef) { /// we can speedup
stack->addTrackReference(o2::TrackReference(position.X(), position.Y(), position.Z(), momentum.X(), momentum.Y(),
momentum.Z(), fMC->TrackLength(), time, trackID, GetDetId()));
lastReferenceR = fMC->TrackLength();
mLastReferenceR = fMC->TrackLength();
}

// ---| remove clusters between the IFC and the FC strips |---
Expand Down
31 changes: 16 additions & 15 deletions Steer/include/Steer/MaterialBudgetMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ class MaterialBudgetMap
void FinishEvent();

private:
Int_t mMode; //! mode
Float_t mTotRadl; //! Total Radiation length
Float_t mTotAbso; //! Total absorption length
Float_t mTotGcm2; //! Total g/cm2 traversed
TH2F* mHistRadl; //! Radiation length map
TH2F* mHistAbso; //! Interaction length map
TH2F* mHistGcm2; //! g/cm2 length map
TH2F* mHistReta; //! Radiation length map as a function of eta
TH2F* mRZR; //! Radiation lenghts at (R.Z)
TH2F* mRZA; //! Absorbtion lengths at (R,Z)
TH2F* mRZG; //! Density at (R,Z)
Bool_t mStopped; //! Scoring has been stopped
Float_t mRmin; //! minimum radius
Float_t mZmax; //! maximum radius
Float_t mRmax; //! maximum z
Int_t mMode; //! mode
Float_t mTotRadl; //! Total Radiation length
Float_t mTotAbso; //! Total absorption length
Float_t mTotGcm2; //! Total g/cm2 traversed
TH2F* mHistRadl; //! Radiation length map
TH2F* mHistAbso; //! Interaction length map
TH2F* mHistGcm2; //! g/cm2 length map
TH2F* mHistReta; //! Radiation length map as a function of eta
TH2F* mRZR; //! Radiation lenghts at (R.Z)
TH2F* mRZA; //! Absorbtion lengths at (R,Z)
TH2F* mRZG; //! Density at (R,Z)
Bool_t mStopped; //! Scoring has been stopped
Float_t mRmin; //! minimum radius
Float_t mZmax; //! maximum radius
Float_t mRmax; //! maximum z
Float_t mDistToBoundary = 0; //! distance to the scoring boundary from the previous step
};
} // namespace steer
} // namespace o2
Expand Down
11 changes: 5 additions & 6 deletions Steer/src/MaterialBudgetMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ void MaterialBudgetMap::Stepping()
// called from AliRun::Stepmanager from gustep.
// Accumulate the 3 parameters step by step
//
static Float_t t;
Float_t a, z, dens, radl, absl;
Int_t i, id, copy;
const char* vol;
static Float_t vect[3], dir[3];
Float_t vect[3], dir[3];

TString tmp1, tmp2;
copy = 1;
Expand Down Expand Up @@ -212,12 +211,12 @@ void MaterialBudgetMap::Stepping()
// Not the first step, add past contribution
if (!mStopped) {
if (absl) {
mTotAbso += t / absl;
mTotAbso += mDistToBoundary / absl;
}
if (radl) {
mTotRadl += t / radl;
mTotRadl += mDistToBoundary / radl;
}
mTotGcm2 += t * dens;
mTotGcm2 += mDistToBoundary * dens;
} // not stooped
} // not a new track !
mStopped = kTRUE;
Expand All @@ -231,7 +230,7 @@ void MaterialBudgetMap::Stepping()
dir[i] = mom[i];
}

t = eventgen::GeneratorGeantinos::PropagateCylinder(vect, dir, mRmax, mZmax);
mDistToBoundary = eventgen::GeneratorGeantinos::PropagateCylinder(vect, dir, mRmax, mZmax);

if (step) {
if (absl) {
Expand Down
2 changes: 1 addition & 1 deletion Steer/src/O2MCApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace steer
template <typename T>
void TypedVectorAttach(const char* name, fair::mq::Channel& channel, fair::mq::Parts& parts)
{
static auto mgr = FairRootManager::Instance();
auto mgr = FairRootManager::Instance();
auto vector = mgr->InitObjectAs<const std::vector<T>*>(name);
if (vector) {
auto buffer = (char*)&(*vector)[0];
Expand Down
Loading