]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMC.cxx
Distance between creation points CFs
[u/mrichter/AliRoot.git] / STEER / AliMC.cxx
index 13380f34d50cb181aeb07668110808167942b62e..3ad70446c83d131bf71d8a8107755c08a2175182 100644 (file)
 
 /* $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 <RVersion.h>
 #include <TBrowser.h>
 #include <TStopwatch.h>
 #include <TSystem.h>
@@ -41,6 +48,7 @@ AliMC::AliMC() :
   fSum2Energy(0),
   fTrRmax(1.e10),
   fTrZmax(1.e10),
+  fDebug(0),
   fImedia(0),
   fTransParName("\0"),
   fMCQA(0),
@@ -48,6 +56,7 @@ AliMC::AliMC() :
   fTrackReferences(0)
 
 {
+  //default constructor
 }
 
 //_______________________________________________________________________
@@ -59,13 +68,14 @@ AliMC::AliMC(const char *name, const char *title) :
   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();
 
@@ -83,6 +93,7 @@ AliMC::AliMC(const AliMC &mc) :
   fSum2Energy(0),
   fTrRmax(1.e10),
   fTrZmax(1.e10),
+  fDebug(0),
   fImedia(0),
   fTransParName("\0"),
   fMCQA(0),
@@ -98,6 +109,7 @@ AliMC::AliMC(const AliMC &mc) :
 //_______________________________________________________________________
 AliMC::~AliMC()
 {
+  //destructor
   delete fGenerator;
   delete fImedia;
   delete fMCQA;
@@ -112,8 +124,9 @@ AliMC::~AliMC()
 }
 
 //_______________________________________________________________________
-void AliMC::Copy(AliMC &) const
+void AliMC::Copy(TObject &) const
 {
+  //dummy Copy function
   Fatal("Copy","Not implemented!\n");
 }
 
@@ -161,7 +174,7 @@ void  AliMC::InitGeometry()
 }
 
 //_______________________________________________________________________
-void  AliMC::GeneratePrimaries()
+void  AliMC::GeneratePrimaries() 
 { 
   //
   // Generate primary particles and fill them in the stack.
@@ -203,8 +216,10 @@ void AliMC::FinishRun()
   fGenerator->FinishRun();
 
   //Output energy summary tables
-  if (GetDebug()) Info("FinishRun"," EnergySummary()");
-  EnergySummary();
+  if (GetDebug()) {
+    Info("FinishRun"," EnergySummary()");
+    EnergySummary();
+  }
 
 }
 
@@ -224,6 +239,7 @@ void AliMC::BeginPrimary()
 //_______________________________________________________________________
 void AliMC::PreTrack()
 {
+  // Actions before the track's transport
      TObjArray &dets = *gAlice->Modules();
      AliModule *module;
 
@@ -252,6 +268,11 @@ void AliMC::Stepping()
     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));
@@ -414,6 +435,16 @@ void AliMC::BeginEvent()
     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);
+  }
+  //
 }
 
 //_______________________________________________________________________
@@ -432,6 +463,7 @@ void AliMC::ResetHits()
 //_______________________________________________________________________
 void AliMC::PostTrack()
 {
+  // Posts tracks for each module
      TObjArray &dets = *gAlice->Modules();
      AliModule *module;
 
@@ -450,6 +482,10 @@ void AliMC::FinishPrimary()
   //  static Int_t count=0;
   //  const Int_t times=10;
   // This primary is finished, purify stack
+#if ROOT_VERSION_CODE > 262152
+  if (!(gMC->SecondariesAreOrdered()))
+       runloader->Stack()->ReorderKine();
+#endif
   runloader->Stack()->PurifyKine();
   
   TIter next(gAlice->Modules());
@@ -543,17 +579,17 @@ void AliMC::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();
-   gMC->DefineParticles();  //Create standard MC particles
-
    //Read the cuts for all materials
    ReadTransPar();
    //Build the special IMEDIA table
@@ -847,6 +883,8 @@ Int_t AliMC::GetPrimary(Int_t track) const
 //_______________________________________________________________________
 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())
@@ -869,7 +907,7 @@ TObjArray* AliMC::Particles() const {
 //_______________________________________________________________________
 void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
                       Float_t *vpos, Float_t *polar, Float_t tof,
-                      TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
+                      TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) const
 { 
 // Delegate to stack
 //
@@ -885,7 +923,7 @@ void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg,
                      Double_t px, Double_t py, Double_t pz, Double_t e,
                      Double_t vx, Double_t vy, Double_t vz, Double_t tof,
                      Double_t polx, Double_t poly, Double_t polz,
-                     TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
+                     TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) const
 { 
   // Delegate to stack
   //
@@ -897,7 +935,7 @@ void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg,
 }
 
 //_______________________________________________________________________
-void AliMC::SetHighWaterMark(const Int_t nt)
+void AliMC::SetHighWaterMark(Int_t nt) const
 {
     //
     // Set high water mark for last track in event
@@ -908,7 +946,7 @@ void AliMC::SetHighWaterMark(const Int_t nt)
 }
 
 //_______________________________________________________________________
-void AliMC::KeepTrack(const Int_t track)
+void AliMC::KeepTrack(Int_t track) const
 { 
   //
   // Delegate to stack
@@ -920,7 +958,7 @@ void AliMC::KeepTrack(const Int_t track)
 }
  
 //_______________________________________________________________________
-void AliMC::FlagTrack(Int_t track)
+void AliMC::FlagTrack(Int_t track) const
 {
   // Delegate to stack
   //
@@ -931,7 +969,7 @@ void AliMC::FlagTrack(Int_t track)
 }
 
 //_______________________________________________________________________
-void AliMC::SetCurrentTrack(Int_t track)
+void AliMC::SetCurrentTrack(Int_t track) const
 { 
   //
   // Set current track number