/* $Id$ */
+// This class is extracted from the AliRun class
+// and contains all the MC-related functionality
+// The number of dependencies has to be reduced...
+// Author: F.Carminati
+// Federico.Carminati@cern.ch
+
#include <TBrowser.h>
#include <TStopwatch.h>
#include <TSystem.h>
fSum2Energy(0),
fTrRmax(1.e10),
fTrZmax(1.e10),
+ fDebug(0),
fImedia(0),
fTransParName("\0"),
fMCQA(0),
fTrackReferences(0)
{
+ //default constructor
}
//_______________________________________________________________________
fSum2Energy(0),
fTrRmax(1.e10),
fTrZmax(1.e10),
+ fDebug(0),
fImedia(new TArrayI(1000)),
fTransParName("\0"),
fMCQA(0),
fHitLists(new TList()),
fTrackReferences(new TClonesArray("AliTrackReference", 100))
{
-
+ //constructor
// Set transport parameters
SetTransPar();
fSum2Energy(0),
fTrRmax(1.e10),
fTrZmax(1.e10),
+ fDebug(0),
fImedia(0),
fTransParName("\0"),
fMCQA(0),
//_______________________________________________________________________
AliMC::~AliMC()
{
+ //destructor
delete fGenerator;
delete fImedia;
delete fMCQA;
}
//_______________________________________________________________________
-void AliMC::Copy(AliMC &) const
+void AliMC::Copy(TObject &) const
{
+ //dummy Copy function
Fatal("Copy","Not implemented!\n");
}
fGenerator->FinishRun();
//Output energy summary tables
- if (GetDebug()) Info("FinishRun"," EnergySummary()");
- EnergySummary();
+ if (GetDebug()) {
+ Info("FinishRun"," EnergySummary()");
+ EnergySummary();
+ }
}
//_______________________________________________________________________
void AliMC::PreTrack()
{
+ // Actions before the track's transport
TObjArray &dets = *gAlice->Modules();
AliModule *module;
Int_t copy;
//Update energy deposition tables
AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
+ //
+ // write tracke reference for track which is dissapearing - MI
+ if (gMC->IsTrackDisappeared()) {
+ if (gMC->Etot()>0.05) AddTrackReference(GetCurrentTrackNumber());
+ }
//Call the appropriate stepping routine;
AliModule *det = dynamic_cast<AliModule*>(gAlice->Modules()->At(id));
runloader->Stack()->Reset();//clean stack -> tree is unloaded
else
runloader->MakeStack();//or make a new one
-
- if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(K)");
- runloader->MakeTree("K");
+
+ if(gAlice->Lego() == 0x0)
+ {
+ if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(K)");
+ runloader->MakeTree("K");
+ }
+
if (GetDebug()) Info("BeginEvent"," gMC->SetStack(fRunLoader->Stack())");
gMC->SetStack(gAlice->GetRunLoader()->Stack());//Was in InitMC - but was moved here
//because we don't have guarantee that
gAlice->GetEventNrInRun());
// fRunLoader->WriteKinematics("OVERWRITE"); is there any reason to rewrite here since MakeTree does so
- if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTrackRefsContainer()");
- runloader->MakeTrackRefsContainer();//for insurance
+ if(gAlice->Lego())
+ {
+ gAlice->Lego()->BeginEvent();
+ return;
+ }
+
if (GetDebug()) Info("BeginEvent"," ResetHits()");
ResetHits();
+
if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(H)");
runloader->MakeTree("H");
+
+ if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTrackRefsContainer()");
+ runloader->MakeTrackRefsContainer();//for insurance
- //
- if(gAlice->Lego())
- {
- gAlice->Lego()->BeginEvent();
- return;
- }
//create new branches and SetAdresses
TIter next(gAlice->Modules());
if (GetDebug()) Info("BeginEvent"," %s->SetTreeAddress()",detector->GetName());
detector->SetTreeAddress();
}
+ // make branch for AliRun track References
+ TTree * treeTR = runloader->TreeTR();
+ if (treeTR){
+ // make branch for central track references
+ if (!fTrackReferences) fTrackReferences = new TClonesArray("AliTrackReference",0);
+ TBranch *branch;
+ branch = treeTR->Branch("AliRun",&fTrackReferences);
+ branch->SetAddress(&fTrackReferences);
+ }
+ //
}
//_______________________________________________________________________
//_______________________________________________________________________
void AliMC::PostTrack()
{
+ // Posts tracks for each module
TObjArray &dets = *gAlice->Modules();
AliModule *module;
// const Int_t times=10;
// This primary is finished, purify stack
runloader->Stack()->PurifyKine();
-
+
TIter next(gAlice->Modules());
AliModule *detector;
while((detector = dynamic_cast<AliModule*>(next()))) {
detector->FinishPrimary();
- if(detector->GetLoader())
- detector->GetLoader()->TreeH()->Fill();
+ AliLoader* loader = detector->GetLoader();
+ if(loader)
+ {
+ TTree* treeH = loader->TreeH();
+ if (treeH) treeH->Fill(); //can be Lego run and treeH can not exist
+ }
}
// Write out track references if any
Error("FinishEvent","Can not get TreeE from RL");
}
- runloader->WriteKinematics("OVERWRITE");
- runloader->WriteTrackRefs("OVERWRITE");
- runloader->WriteHits("OVERWRITE");
-
+ if(gAlice->Lego() == 0x0)
+ {
+ runloader->WriteKinematics("OVERWRITE");
+ runloader->WriteTrackRefs("OVERWRITE");
+ runloader->WriteHits("OVERWRITE");
+ }
+
if (GetDebug())
{
Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
//_______________________________________________________________________
void AliMC::Field(const Double_t* x, Double_t* b) const
{
+ // Calculates field "b" at point "x"
gAlice->Field(x,b);
}
//_______________________________________________________________________
void AliMC::Init()
{
+ // MC initialization
//=================Create Materials and geometry
gMC->Init();
//_______________________________________________________________________
TParticle* AliMC::Particle(Int_t i) const
{
+ // Returns the i-th particle from the stack taking into account
+ // the remaping done by PurifyKine
AliRunLoader * runloader = gAlice->GetRunLoader();
if (runloader)
if (runloader->Stack())
}
//_______________________________________________________________________
-void AliMC::SetHighWaterMark(const Int_t nt)
+void AliMC::SetHighWaterMark(Int_t nt)
{
//
// Set high water mark for last track in event
}
//_______________________________________________________________________
-void AliMC::KeepTrack(const Int_t track)
+void AliMC::KeepTrack(Int_t track)
{
//
// Delegate to stack