2424#include " TSystem.h"
2525#include " TClonesArray.h"
2626#include " TVirtualMC.h"
27- #include " TVectorD.h"
2827
2928#include " TFile.h"
3029
@@ -176,12 +175,14 @@ void Detector::SetSpecialPhysicsCuts()
176175
177176Bool_t Detector::ProcessHits (FairVolume* vol)
178177{
178+ static auto *refMC = TVirtualMC::GetMC ();
179+
179180 /* This method is called from the MC stepping for the sensitive volume only */
180181 // LOG(INFO) << "TPC::ProcessHits" << FairLogger::endl;
181- if (static_cast <int >(TVirtualMC::GetMC () ->TrackCharge ()) == 0 ) {
182+ if (static_cast <int >(refMC ->TrackCharge ()) == 0 ) {
182183
183184 // set a very large step size for neutral particles
184- TVirtualMC::GetMC () ->SetMaxStep (1 .e10 );
185+ refMC ->SetMaxStep (1 .e10 );
185186 return kFALSE ; // take only charged particles
186187 }
187188
@@ -197,21 +198,21 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
197198 // https://indico.cern.ch/event/316891/contributions/732168/
198199
199200 TLorentzVector momentum;
200- TVirtualMC::GetMC () ->TrackMomentum (momentum);
201- const Double_t rnd = TVirtualMC::GetMC () ->GetRandom ()->Rndm ();
201+ refMC ->TrackMomentum (momentum);
202+ const Double_t rnd = refMC ->GetRandom ()->Rndm ();
202203 if (mSimulationType == SimulationType::GEANT3 ) {
203204
204205 // betagamma = p/m
205- Float_t betaGamma = momentum.P ()/TVirtualMC::GetMC () ->TrackMass ();
206+ Float_t betaGamma = momentum.P ()/refMC ->TrackMass ();
206207 betaGamma = TMath::Max (betaGamma, static_cast <Float_t>(7 .e -3 )); // protection against too small bg
207208
208209 // NPRIM etc. are defined in "TPCSimulation/Constants.h"
209210 const Float_t pp = NPRIM * BetheBlochAleph (betaGamma, BBPARAM [0 ], BBPARAM [1 ], BBPARAM [2 ], BBPARAM [3 ], BBPARAM [4 ]);
210211
211- TVirtualMC::GetMC () ->SetMaxStep (-TMath::Log (rnd)/pp);
212+ refMC ->SetMaxStep (-TMath::Log (rnd)/pp);
212213 } else {
213214
214- TVirtualMC::GetMC () ->SetMaxStep (0.2 +(2 .*rnd-1 .)*0.05 ); // 2 mm +- rndm*0.5mm step
215+ refMC ->SetMaxStep (0.2 +(2 .*rnd-1 .)*0.05 ); // 2 mm +- rndm*0.5mm step
215216 }
216217
217218 // CONVERT THE ENERGY LOSS TO IONIZATION
@@ -227,15 +228,15 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
227228 Int_t nel=0 ;
228229 if (mSimulationType == SimulationType::GEANT3 ) {
229230
230- nel = 1 + static_cast <int >((TVirtualMC::GetMC () ->Edep ()-IPOT ) / WION );
231+ nel = 1 + static_cast <int >((refMC ->Edep ()-IPOT ) / WION );
231232 // LOG(INFO) << "TPC::AddHit" << FairLogger::endl << "GEANT3: Nelectrons: " << nel << FairLogger::endl;
232233 } else {
233234
234- const Double_t meanIon = TVirtualMC::GetMC () ->Edep () / (WION *SCALEWIONG4 );
235+ const Double_t meanIon = refMC ->Edep () / (WION *SCALEWIONG4 );
235236 if (meanIon > 0 )
236237 nel = static_cast <int >(FANOFACTORG4 * Gamma (meanIon/FANOFACTORG4 ));
237238 // LOG(INFO) << "TPC::AddHit" << FairLogger::endl << "GEANT4: Eloss: "
238- // << TVirtualMC::GetMC() ->Edep() << ", Nelectrons: "
239+ // << refMC ->Edep() << ", Nelectrons: "
239240 // << nel << FairLogger::endl;
240241 }
241242
@@ -246,14 +247,12 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
246247
247248 // ADD HIT
248249 TLorentzVector position;
249- TVirtualMC::GetMC ()->TrackPosition (position);
250- Double32_t time = TVirtualMC::GetMC ()->TrackTime () * 1.0e09 ;
251- Double32_t length = TVirtualMC::GetMC ()->TrackLength ();
252- int trackNumberID = TVirtualMC::GetMC ()->GetStack ()->GetCurrentTrackNumber ();
253- int volumeID = vol->getMCid ();
254- AddHit (trackNumberID, volumeID, TVector3 (position.X (), position.Y (), position.Z ()),
255- TVector3 (momentum.Px (), momentum.Py (), momentum.Pz ()), time, length,
256- nel);
250+ refMC->TrackPosition (position);
251+ float time = refMC->TrackTime () * 1.0e09 ;
252+ int trackID = refMC->GetStack ()->GetCurrentTrackNumber ();
253+ int detID = vol->getMCid ();
254+ addHit (position.X (), position.Y (), position.Z (), time, nel, trackID, detID);
255+
257256 // LOG(INFO) << "TPC::AddHit" << FairLogger::endl
258257 // << " -- " << trackNumberID <<"," << volumeID << " " << vol->GetName()
259258 // << ", Pos: (" << position.X() << ", " << position.Y() <<", "<< position.Z()<< ", " << r << ") "
@@ -262,7 +261,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
262261 // nel << FairLogger::endl;
263262
264263 // Increment number of Detector det points in TParticle
265- AliceO2::Data::Stack* stack = (AliceO2::Data::Stack*)TVirtualMC::GetMC () ->GetStack ();
264+ AliceO2::Data::Stack* stack = (AliceO2::Data::Stack*)refMC ->GetStack ();
266265 stack->AddPoint (kAliTpc );
267266
268267 return kTRUE ;
@@ -288,7 +287,7 @@ void Detector::Register()
288287 only during the simulation.
289288 */
290289
291- FairGenericRootManager ::Instance ()->Register (" TPCPoint" , " TPC" ,mPointCollection , kTRUE );
290+ FairRootManager ::Instance ()->Register (" TPCPoint" , " TPC" ,mPointCollection , kTRUE );
292291
293292}
294293
@@ -3041,19 +3040,6 @@ void Detector::DefineSensitiveVolumes()
30413040 }
30423041}
30433042
3044-
3045- Point* Detector::AddHit (Int_t trackID, Int_t detID,
3046- TVector3 pos, TVector3 mom,
3047- Double_t time, Double_t length,
3048- Double_t eLoss)
3049- {
3050- TClonesArray& clref = *mPointCollection ;
3051- Int_t size = clref.GetEntriesFast ();
3052- return new (clref[size]) Point (trackID, detID, pos, mom,
3053- time, length, eLoss);
3054- }
3055-
3056-
30573043Double_t Detector::BetheBlochAleph (Double_t bg, Double_t kp1, Double_t kp2, Double_t kp3, Double_t kp4, Double_t kp5){
30583044 Double_t beta = bg/TMath::Sqrt (1 .+ bg*bg);
30593045
0 commit comments