diff --git a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Detector.h b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Detector.h index 363c05dd4fec4..f25a7a18cfb4c 100644 --- a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Detector.h +++ b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Detector.h @@ -20,6 +20,7 @@ #include "DetectorsBase/Detector.h" #include "DataFormatsFDD/Hit.h" #include "FDDBase/Geometry.h" +#include class FairModule; class FairVolume; @@ -73,6 +74,11 @@ class Detector : public o2::base::DetImpl std::vector* 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 diff --git a/Detectors/FIT/FDD/simulation/src/Detector.cxx b/Detectors/FIT/FDD/simulation/src/Detector.cxx index 174a62785494e..e97c3fb63dae9 100644 --- a/Detectors/FIT/FDD/simulation/src/Detector.cxx +++ b/Detectors/FIT/FDD/simulation/src/Detector.cxx @@ -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; } diff --git a/Detectors/HMPID/simulation/include/HMPIDSimulation/Detector.h b/Detectors/HMPID/simulation/include/HMPIDSimulation/Detector.h index c37452c167430..04280748de6e3 100644 --- a/Detectors/HMPID/simulation/include/HMPIDSimulation/Detector.h +++ b/Detectors/HMPID/simulation/include/HMPIDSimulation/Detector.h @@ -98,6 +98,10 @@ class Detector : public o2::base::DetImpl 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 friend class o2::base::DetImpl; ClassDefOverride(Detector, 1); diff --git a/Detectors/HMPID/simulation/src/Detector.cxx b/Detectors/HMPID/simulation/src/Detector.cxx index 6205d6781c446..56cfcf934f7ee 100644 --- a/Detectors/HMPID/simulation/src/Detector.cxx +++ b/Detectors/HMPID/simulation/src/Detector.cxx @@ -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 @@ -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; @@ -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 diff --git a/Detectors/Passive/include/DetectorsPassive/Cave.h b/Detectors/Passive/include/DetectorsPassive/Cave.h index 7783b66cb4e7d..c13804f18c81e 100644 --- a/Detectors/Passive/include/DetectorsPassive/Cave.h +++ b/Detectors/Passive/include/DetectorsPassive/Cave.h @@ -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 diff --git a/Detectors/Passive/src/Cave.cxx b/Detectors/Passive/src/Cave.cxx index bc28c852fca95..80f96141e72b4 100644 --- a/Detectors/Passive/src/Cave.cxx +++ b/Detectors/Passive/src/Cave.cxx @@ -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*) diff --git a/Detectors/TPC/simulation/include/TPCSimulation/Detector.h b/Detectors/TPC/simulation/include/TPCSimulation/Detector.h index d8e341f9c30c5..1f5c2840ff9f5 100644 --- a/Detectors/TPC/simulation/include/TPCSimulation/Detector.h +++ b/Detectors/TPC/simulation/include/TPCSimulation/Detector.h @@ -155,7 +155,8 @@ class Detector : public o2::base::DetImpl int mHitCounter = 0; int mElectronCounter = 0; int mStepCounter = 0; - ElementalHit mHitLast{}; ///TrackMomentum(momentum); const float time = fMC->TrackTime() * 1.0e9; @@ -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 |--- diff --git a/Steer/include/Steer/MaterialBudgetMap.h b/Steer/include/Steer/MaterialBudgetMap.h index a81e805b6d494..02e9bec5d7358 100644 --- a/Steer/include/Steer/MaterialBudgetMap.h +++ b/Steer/include/Steer/MaterialBudgetMap.h @@ -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 diff --git a/Steer/src/MaterialBudgetMap.cxx b/Steer/src/MaterialBudgetMap.cxx index 08da2b4ac4818..aafff143fec8a 100644 --- a/Steer/src/MaterialBudgetMap.cxx +++ b/Steer/src/MaterialBudgetMap.cxx @@ -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; @@ -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; @@ -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) { diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index 82fdda4eace58..04da526e963de 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -59,7 +59,7 @@ namespace steer template 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*>(name); if (vector) { auto buffer = (char*)&(*vector)[0];