// Federico.Carminati@cern.ch
#include <RVersion.h>
-#include <TBrowser.h>
+#include <TArrayI.h>
#include <TClonesArray.h>
+#include <TFile.h>
+#include <TGeoGlobalMagField.h>
#include <TGeoManager.h>
+#include <TParticle.h>
+#include <TROOT.h>
#include <TStopwatch.h>
#include <TSystem.h>
#include <TVirtualMC.h>
-#include <TParticle.h>
-#include <TROOT.h>
-#include <TFile.h>
-#include "AliLog.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
#include "AliDetector.h"
#include "AliGenerator.h"
+#include "AliGeomManager.h"
#include "AliHeader.h"
+#include "AliHit.h"
#include "AliLego.h"
+#include "AliLog.h"
#include "AliMC.h"
+#include "AliMagF.h"
#include "AliRun.h"
-#include "AliHit.h"
+#include "AliSimulation.h"
#include "AliStack.h"
-#include "AliMagF.h"
#include "AliTrackReference.h"
-#include "AliSimulation.h"
-#include "AliGeomManager.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
-#include "AliCDBEntry.h"
-
ClassImp(AliMC)
}
}else{
// Create modules, materials, geometry
+ if (!gGeoManager) new TGeoManager("ALICE", "ALICE geometry");
TStopwatch stw;
TIter next(gAlice->Modules());
AliModule *detector;
SetAllAlignableVolumes();
}
// Misalign geometry via AliSimulation instance
- if (!AliSimulation::GetInstance()) return kFALSE;
+ if (!AliSimulation::Instance()) return kFALSE;
AliGeomManager::SetGeometry(gGeoManager);
if(!AliGeomManager::CheckSymNamesLUT("ALL"))
AliFatal("Current loaded geometry differs in the definition of symbolic names!");
- return AliSimulation::GetInstance()->MisalignGeometry(AliRunLoader::GetRunLoader());
+ return AliSimulation::Instance()->MisalignGeometry(AliRunLoader::Instance());
}
//_______________________________________________________________________
AliModule *detector;
AliInfo("Optical properties definition");
while((detector = dynamic_cast<AliModule*>(next()))) {
+ // Initialise detector geometry
+ if(gAlice->IsRootGeometry()) detector->CreateMaterials();
// Initialise detector optical properties
detector->DefineOpticalProperties();
}
AliModule *detector;
while((detector = dynamic_cast<AliModule*>(next()))) {
stw.Start();
- // Initialise detector geometry
- if(gAlice->IsRootGeometry()) detector->CreateMaterials();
detector->Init();
AliInfo(Form("%10s R:%.2fs C:%.2fs",
detector->GetName(),stw.RealTime(),stw.CpuTime()));
void AliMC::PreTrack()
{
// Actions before the track's transport
+
TObjArray &dets = *gAlice->Modules();
AliModule *module;
for(Int_t i=0; i<=gAlice->GetNdets(); i++)
if((module = dynamic_cast<AliModule*>(dets[i])))
module->PreTrack();
-
}
//_______________________________________________________________________
//
// --- If lego option, do it and leave
- if (gAlice->Lego())
- gAlice->Lego()->StepManager();
+ if (AliSimulation::Instance()->Lego())
+ AliSimulation::Instance()->Lego()->StepManager();
else {
Int_t copy;
//Update energy deposition tables
Float_t ed, ed2;
Int_t kn, i, left, j, id;
const Float_t kzero=0;
- Int_t ievent=AliRunLoader::GetRunLoader()->GetHeader()->GetEvent()+1;
+ Int_t ievent=AliRunLoader::Instance()->GetHeader()->GetEvent()+1;
//
// Energy loss information
if(ievent) {
AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- AliRunLoader *runloader=AliRunLoader::GetRunLoader();
+ AliRunLoader *runloader=AliRunLoader::Instance();
/*******************************/
/* Clean after eventual */
runloader->MakeStack();//or make a new one
- if(gAlice->Lego() == 0x0)
+ if(AliSimulation::Instance()->Lego() == 0x0)
{
AliDebug(1, "fRunLoader->MakeTree(K)");
runloader->MakeTree("K");
gAlice->GetEventNrInRun());
// fRunLoader->WriteKinematics("OVERWRITE"); is there any reason to rewrite here since MakeTree does so
- if(gAlice->Lego())
+ if(AliSimulation::Instance()->Lego())
{
- gAlice->Lego()->BeginEvent();
+ AliSimulation::Instance()->Lego()->BeginEvent();
return;
}
}
}
+//_______________________________________________________________________
+void AliMC::ResetDigits()
+{
+ //
+ // Reset all Detectors digits
+ //
+ TIter next(gAlice->Modules());
+ AliModule *detector;
+ while((detector = dynamic_cast<AliModule*>(next()))) {
+ detector->ResetDigits();
+ }
+}
+
+//_______________________________________________________________________
+void AliMC::ResetSDigits()
+{
+ //
+ // Reset all Detectors digits
+ //
+ TIter next(gAlice->Modules());
+ AliModule *detector;
+ while((detector = dynamic_cast<AliModule*>(next()))) {
+ detector->ResetSDigits();
+ }
+}
+
//_______________________________________________________________________
void AliMC::PostTrack()
{
// Posts tracks for each module
+
TObjArray &dets = *gAlice->Modules();
AliModule *module;
//
// Called at the end of each primary track
//
- AliRunLoader *runloader=AliRunLoader::GetRunLoader();
+
+ AliRunLoader *runloader=AliRunLoader::Instance();
// static Int_t count=0;
// const Int_t times=10;
// This primary is finished, purify stack
{
//
// Remaps the track labels of the hits
- AliRunLoader *runloader=AliRunLoader::GetRunLoader();
+ AliRunLoader *runloader=AliRunLoader::Instance();
AliStack* stack = runloader->Stack();
TList* hitLists = GetHitLists();
TIter next(hitLists);
//
// Called at the end of the event.
//
-
- //
- if(gAlice->Lego()) gAlice->Lego()->FinishEvent();
+ if(AliSimulation::Instance()->Lego()) AliSimulation::Instance()->Lego()->FinishEvent();
TIter next(gAlice->Modules());
AliModule *detector;
fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
}
- AliRunLoader *runloader=AliRunLoader::GetRunLoader();
+ AliRunLoader *runloader=AliRunLoader::Instance();
AliHeader* header = runloader->GetHeader();
AliStack* stack = runloader->Stack();
header->SetNtrack(stack->GetNtrack());
// Write out the kinematics
- if (!gAlice->Lego()) stack->FinishEvent();
+ if (!AliSimulation::Instance()->Lego()) stack->FinishEvent();
// Synchronize the TreeTR with TreeK
if (fTmpTreeTR) ReorderAndExpandTreeTR();
AliError("Can not get TreeE from RL");
}
- if(gAlice->Lego() == 0x0)
+ if(AliSimulation::Instance()->Lego() == 0x0)
{
runloader->WriteKinematics("OVERWRITE");
runloader->WriteTrackRefs("OVERWRITE");
AliDebug(1, "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
}
-//_______________________________________________________________________
-void AliMC::Field(const Double_t* x, Double_t* b) const
-{
- // Calculates field "b" at point "x"
- gAlice->Field(x,b);
-}
-
//_______________________________________________________________________
void AliMC::Init()
{
//
// Returns current track
//
- return AliRunLoader::GetRunLoader()->Stack()->GetCurrentTrackNumber();
+ return AliRunLoader::Instance()->Stack()->GetCurrentTrackNumber();
}
//_______________________________________________________________________
//
// Dumps particle i in the stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader->Stack())
runloader->Stack()->DumpPart(i);
}
//
// Dumps the particle stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader->Stack())
runloader->Stack()->DumpPStack();
}
// Returns number of tracks in stack
//
Int_t ntracks = -1;
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader->Stack())
ntracks = runloader->Stack()->GetNtrack();
return ntracks;
// return number of primary that has generated track
//
Int_t nprimary = -999;
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader->Stack())
nprimary = runloader->Stack()->GetPrimary(track);
return nprimary;
{
// Returns the i-th particle from the stack taking into account
// the remaping done by PurifyKine
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
return runloader->Stack()->Particle(i);
//
// Returns pointer to Particles array
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
return runloader->Stack()->Particles();
}
//_______________________________________________________________________
-void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
- Float_t *vpos, Float_t *polar, Float_t tof,
+void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg, const Float_t *pmom,
+ const Float_t *vpos, const Float_t *polar, Float_t tof,
TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) const
{
// Delegate to stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
{
// Delegate to stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
{
//
// Set high water mark for last track in event
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->SetHighWaterMark(nt);
//
// Delegate to stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->KeepTrack(track);
{
// Delegate to stack
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->FlagTrack(track);
//
// Set current track number
//
- AliRunLoader * runloader = AliRunLoader::GetRunLoader();
+ AliRunLoader * runloader = AliRunLoader::Instance();
if (runloader)
if (runloader->Stack())
runloader->Stack()->SetCurrentTrack(track);
fTmpTrackReferences.Clear();
}
+//_______________________________________________________________________
void AliMC::RemapTrackReferencesIDs(Int_t *map)
{
//
fTmpTrackReferences.Compress();
}
+//_______________________________________________________________________
void AliMC::FixParticleDecaytime()
{
//
// Transverse velocity
Double_t vt = p.Pt() / p.E();
- if ((b = gAlice->Field()->SolenoidField()) > 0.) { // [kG]
+ if ((b = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->SolenoidField()) > 0.) { // [kG]
// Radius of helix
// Maximum and minimum decay time
//
// Check for curlers first
- if (fRDecayMax * fRDecayMax / rho / rho / 2. > 1.) return;
+ const Double_t kOvRhoSqr2 = 1./(rho*TMath::Sqrt(2.));
+ if (fRDecayMax * kOvRhoSqr2 > 1.) return;
//
- tmax = TMath::ACos(1. - fRDecayMax * fRDecayMax / rho / rho / 2.) / omega; // [ct]
- tmin = TMath::ACos(1. - fRDecayMin * fRDecayMin / rho / rho / 2.) / omega; // [ct]
+ tmax = TMath::ACos((1.-fRDecayMax*kOvRhoSqr2)*(1.+fRDecayMax*kOvRhoSqr2)) / omega; // [ct]
+ tmin = TMath::ACos((1.-fRDecayMin*kOvRhoSqr2)*(1.+fRDecayMin*kOvRhoSqr2)) / omega; // [ct]
} else {
tmax = fRDecayMax / vt; // [ct]
tmin = fRDecayMin / vt; // [ct]
fTmpTreeTR->Branch("TrackReferences", "TClonesArray", &pRef, 4000);
}
+//_______________________________________________________________________
void AliMC::ReorderAndExpandTreeTR()
{
//
// Reorder and expand the temporary track reference tree in order to match the kinematics tree
//
- AliRunLoader *rl = AliRunLoader::GetRunLoader();
+ AliRunLoader *rl = AliRunLoader::Instance();
//
// TreeTR
AliDebug(1, "fRunLoader->MakeTrackRefsContainer()");