MC-dependent part of AliRun extracted in AliMC (F.Carminati)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Oct 2003 16:32:20 +0000 (16:32 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Oct 2003 16:32:20 +0000 (16:32 +0000)
116 files changed:
ALIFAST/AliFTrackMaker.cxx
CRT/AliCRT.h
CRT/AliCRTv0.cxx
CRT/AliCRTv0.h
CRT/AliCRTv1.cxx
EMCAL/AliEMCALGetter.cxx
EMCAL/AliEMCALJetFinder.cxx
EMCAL/AliEMCALJetFinderInputSimPrep.cxx
EMCAL/AliEMCALJetMicroDst.cxx
EMCAL/AliEMCALv0.cxx
EMCAL/AliEMCALv1.cxx
EVGEN/AliDimuCombinator.cxx
EVGEN/AliGenCocktail.cxx
EVGEN/AliGenCocktailAfterBurner.cxx
EVGEN/AliGenFLUKAsource.cxx
EVGEN/AliGenHIJINGpara.cxx
EVGEN/AliGenParam.cxx
FMD/AliFMD.cxx
FMD/AliFMDv0.cxx
FMD/AliFMDv1.cxx
HBTAN/AliHBTReaderITSv1.cxx
ITS/AliITS.cxx
ITS/AliITSFindClustersV2.cxx
ITS/AliITSRiemannFit.cxx
ITS/AliITSTrackerV1.cxx
ITS/AliITSclustererV2.cxx
ITS/AliITShit.cxx
ITS/AliITStestV2.C
ITS/AliITSv5.cxx
ITS/AliITSv5asymm.cxx
ITS/AliITSv5symm.cxx
ITS/AliITSvPPRasymm.cxx
ITS/AliITSvPPRasymmFMD.cxx
ITS/AliITSvSPD02.cxx
ITS/AliITSvtest.cxx
MUON/AliMUONClusterFinderAZ.cxx
MUON/AliMUONDisplay.cxx
MUON/AliMUONEventReconstructor.cxx
MUON/AliMUONRecoDisplay.cxx
MUON/AliMUONv0.cxx
MUON/AliMUONv1.cxx
MUON/AliMUONv2.cxx
PHOS/AliPHOSGetter.cxx
PHOS/AliPHOSv1.cxx
PHOS/AliPHOSvImpacts.cxx
PMD/AliPMD.cxx
PMD/AliPMDDigitizer.cxx
PMD/AliPMDv0.cxx
PMD/AliPMDv1.cxx
PYTHIA6/AliGenPythia.cxx
RICH/AliRICH.cxx
RICH/AliRICH.h
RICH/AliRICHDisplay.cxx
RICH/AliRICHPoints.cxx
RICH/AliRICHResponseV0.cxx
RICH/AliRICHv0.cxx
RICH/AliRICHv1.cxx
RICH/AliRICHv3.cxx
START/AliSTART.cxx
START/AliSTARTv1.cxx
START/AliSTARTv2.cxx
STEER/AliDetector.cxx
STEER/AliDisplay.cxx
STEER/AliGenerator.cxx
STEER/AliHit.cxx
STEER/AliLego.cxx
STEER/AliLegoGenerator.cxx
STEER/AliLegoGeneratorEta.cxx
STEER/AliLegoGeneratorPhiZ.cxx
STEER/AliLegoGeneratorXYZ.cxx
STEER/AliMC.cxx [new file with mode: 0644]
STEER/AliMC.h [new file with mode: 0644]
STEER/AliMCQA.cxx
STEER/AliModule.cxx
STEER/AliPoints.cxx
STEER/AliRun.cxx
STEER/AliRun.h
STEER/AliStack.cxx
STEER/STEERLinkDef.h
STEER/libSTEER.pkg
STRUCT/AliFRAMEv0.cxx
STRUCT/AliFRAMEv1.cxx
STRUCT/AliFRAMEv2.cxx
STRUCT/AliSHILv2.cxx
STRUCT/AliSHILvF.cxx
THerwig/AliGenHerwig.cxx
TOF/AliTOF.cxx
TOF/AliTOFReconstructioner.cxx
TOF/AliTOFReconstructionerV2.cxx
TOF/AliTOFSDigitizer.cxx
TOF/AliTOFT0.cxx
TOF/AliTOFv0.cxx
TOF/AliTOFv1.cxx
TOF/AliTOFv2.cxx
TOF/AliTOFv2FHoles.cxx
TOF/AliTOFv3.cxx
TOF/AliTOFv4.cxx
TOF/AliTOFv4T0.cxx
TPC/AliTPC.cxx
TPC/AliTPCtrackerParam.cxx
TPC/AliTPCv1.cxx
TPC/AliTPCv2.cxx
TPC/AliTPCv3.cxx
TRD/AliTRD.cxx
TRD/AliTRDpid.cxx
TRD/AliTRDsimpleGen.cxx
TRD/AliTRDsimpleMC.cxx
TRD/AliTRDv0.cxx
TRD/AliTRDv1.cxx
VZERO/AliVZERO.cxx
VZERO/AliVZEROv0.cxx
VZERO/AliVZEROv2.cxx
ZDC/AliGenZDC.cxx
ZDC/AliZDC.cxx
ZDC/AliZDCv1.cxx
ZDC/AliZDCv2.cxx

index cf7557f..67617fb 100644 (file)
@@ -60,6 +60,7 @@
 #include "AliFTrackMaker.h"
 #include "AliFTrack.h"
 #include "AliFDet.h"
+#include "AliMC.h"
 
 const Double_t kPi       = TMath::Pi();
 const Double_t k2Pi      = 2*kPi;
@@ -200,10 +201,10 @@ void AliFTrackMaker::Make()
      Int_t idPart, idTrack;
      Double_t  charge, pT, eta, phi;
      TParticle *part;
-     Int_t  nparticles = gAlice->GetNtrack();
+     Int_t  nparticles = gAlice->GetMCApp()->GetNtrack();
      printf("%10s%10d\n","nparticles",nparticles);
      for(Int_t ind=0;ind<nparticles;ind++) {       
-       part = gAlice->Particle(ind);
+       part = gAlice->GetMCApp()->Particle(ind);
        idPart  = part->GetPdgCode();
        charge  = part->GetPDG()->Charge();
        pT      = part->Pt();  
index 3fcc578..7f32bac 100644 (file)
@@ -21,8 +21,8 @@ public:
   AliCRT& operator=(const AliCRT& crt);
   virtual void CreateMaterials();
 
-  virtual Int_t IsVersion() const;
-  virtual TString Version();
+//   virtual Int_t IsVersion() const;
+//   virtual TString Version();
 
   virtual void SetTreeAddress();
 
@@ -30,9 +30,9 @@ private:
   ClassDef(AliCRT, 1) // Cosmic Ray Trigger (ACORDE) base class
 };
 
-inline Int_t AliCRT::IsVersion() const
-{ return 0; }
+// inline Int_t AliCRT::IsVersion() const
+// { return 0; }
 
-inline TString AliCRT::Version()
-{ return TString(""); }
+// inline TString AliCRT::Version()
+// { return TString(""); }
 #endif // ALICRT_H
index b23d988..221c60e 100644 (file)
@@ -48,6 +48,7 @@
 #include <TGeometry.h>
 #include <TBRIK.h>
 #include <TNode.h>
+#include <TVirtualMC.h>
 
 #include "AliRun.h"
 #include "AliConst.h"
index e6d4e79..6d1dc18 100644 (file)
@@ -19,8 +19,8 @@ public:
 
   AliCRTv0& operator=(const AliCRTv0& crt);
 
-  virtual TString Version();
-  virtual Int_t   IsVersion() const;
+  //  virtual TString Version();
+  //  virtual Int_t   IsVersion() const;
 
   virtual void    CreateGeometry();
   virtual void    BuildGeometry();
@@ -34,9 +34,9 @@ private:
   ClassDef(AliCRTv0,1) // Cosmic Ray Trigger (ACORDE).
 };
 
-inline TString AliCRTv0::Version()
-{ return TString("v0"); }
+// inline TString AliCRTv0::Version()
+// { return TString("v0"); }
 
-inline Int_t AliCRTv0::IsVersion() const
-{ return 0; }
+// inline Int_t AliCRTv0::IsVersion() const
+// { return 0; }
 #endif // ALICRTV0_H
index 6c532d2..708bfb2 100644 (file)
 #include <TClonesArray.h>
 #include <TLorentzVector.h>
 #include <TPDGCode.h>
+#include <TVirtualMC.h>
 
 #include "AliRun.h"
 #include "AliConst.h"
 
 #include "AliCRThit.h"
 #include "AliCRTConstants.h"
+#include "AliMC.h"
 
 ClassImp(AliCRTv1)
  
@@ -85,7 +87,7 @@ AliCRTv1::AliCRTv1(const char *name, const char *title)
   fIshunt =  1; // All hits are associated with primary particles  
 
   fHits =  new TClonesArray("AliCRThit",400);
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
 
   SetMarkerColor(7);
   SetMarkerStyle(2);
@@ -585,7 +587,7 @@ void AliCRTv1::StepManager()
     else                                                  vol[0] = -1;// ?
     //vol[0]  = gMC->GetMedium();  //layer(flay)
 
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
 
     // Reset the deposited energy only when you reach the Magnet
     if ( (strcmp(gMC->CurrentVolName(),"CRT4")==0) ) eloss = 0;
index 66bb000..7ab61d2 100644 (file)
@@ -57,6 +57,7 @@
 #include "AliRunLoader.h"
 #include "AliStack.h"  
 #include "AliEMCALLoader.h"
+#include "AliMC.h"
 
 ClassImp(AliEMCALGetter)
   
@@ -602,7 +603,7 @@ TParticle * AliEMCALGetter::Secondary(const TParticle* p, const Int_t index) con
   if(p) {
   Int_t daughterIndex = p->GetDaughter(index-1) ; 
   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
-  return  rl->GetAliRun()->Particle(daughterIndex) ; 
+  return  rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; 
   }
   else
     return 0 ;
index c391d8f..eab4ee9 100644 (file)
@@ -59,6 +59,7 @@
 #include "AliEMCALGetter.h"
 // Interface to FORTRAN
 #include "Ecommon.h"
+#include "AliMC.h"
 
 
 ClassImp(AliEMCALJetFinder)
@@ -780,7 +781,7 @@ void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
 
     // this is for Pythia ??
     for (Int_t part = 0; part < npart; part++) {
-       TParticle *MPart = gAlice->Particle(part);
+       TParticle *MPart = gAlice->GetMCApp()->Particle(part);
        Int_t mpart   = MPart->GetPdgCode();
        Int_t child1  = MPart->GetFirstDaughter();
        Float_t pT    = MPart->Pt();
@@ -1157,7 +1158,7 @@ void AliEMCALJetFinder::FillFromHitFlaggedTracks(Int_t flag)
     fNtS  = 0;
     
     for (Int_t track = 0; track < ntracks; track++) {
-         TParticle *MPart = gAlice->Particle(track);
+         TParticle *MPart = gAlice->GetMCApp()->Particle(track);
          Float_t pT    = MPart->Pt();
          Float_t phi   = MPart->Phi();
          Float_t eta   = MPart->Eta();
@@ -1207,7 +1208,7 @@ void AliEMCALJetFinder::FillFromParticles()
 
        fTrackList[part] = 0;
 
-       MPart   = gAlice->Particle(part);
+       MPart   = gAlice->GetMCApp()->Particle(part);
        mpart   = MPart->GetPdgCode();
        child1  = MPart->GetFirstDaughter();
        child2  = MPart->GetLastDaughter();
@@ -1291,7 +1292,7 @@ void AliEMCALJetFinder::FillFromPartons()
 //  Go through the partons
     Int_t statusCode=0;
     for (Int_t part = 8; part < npart; part++) {
-       TParticle *MPart = gAlice->Particle(part);
+       TParticle *MPart = gAlice->GetMCApp()->Particle(part);
        Int_t mpart   = MPart->GetPdgCode();
        //      Int_t child1  = MPart->GetFirstDaughter();
        Float_t pT    = MPart->Pt();
@@ -1367,7 +1368,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                Int_t   idprim =    mHit->GetPrimary();  // primary particle
                
                //Determine the origin point of this particle - it made a hit in the EMCAL
-               TParticle         *trkPart = gAlice->Particle(iTrk);
+               TParticle         *trkPart = gAlice->GetMCApp()->Particle(iTrk);
                TParticlePDG  *trkPdg  = trkPart->GetPDG();
                Int_t      trkCode = trkPart->GetPdgCode();
                Double_t           trkChg;
@@ -1384,7 +1385,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                //Loop through the ancestry of the EMCAL entrance particles
                Int_t ancestor = trkPart->GetFirstMother();  //Get track's Mother
                while (ancestor != -1) {
-                   TParticle     *ancPart = gAlice->Particle(ancestor);  //get particle info on ancestor
+                   TParticle     *ancPart = gAlice->GetMCApp()->Particle(ancestor);  //get particle info on ancestor
                    TParticlePDG  *ancPdg  = ancPart->GetPDG();
                    Int_t             ancCode = ancPart->GetPdgCode();
                    Double_t       ancChg;
@@ -1401,7 +1402,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                }
                
                //Determine the origin point of the primary particle associated with the hit
-               TParticle     *primPart = gAlice->Particle(idprim);
+               TParticle     *primPart = gAlice->GetMCApp()->Particle(idprim);
                TParticlePDG  *primPdg  = primPart->GetPDG();
                Int_t      primCode = primPart->GetPdgCode();
                Double_t           primChg;
index 7b5b612..300c048 100755 (executable)
@@ -46,6 +46,7 @@
 #include "AliGenPythiaEventHeader.h"
 #include "AliGenerator.h"
 #include "AliHeader.h"
+#include "AliMC.h"
 
 
 ClassImp(AliEMCALJetFinderInputSimPrep)
@@ -221,7 +222,7 @@ void AliEMCALJetFinderInputSimPrep::FillTracks()    // Fill from particles simulati
     if (fDebug > 1) Info("FillTracks","Starting particle loop");
            
     for (Int_t part = 0; part < npart; part++) {
-       MPart = gAlice->Particle(part);
+       MPart = gAlice->GetMCApp()->Particle(part);
        //if (part%10) gObjectTable->Print();
        pdgP = MPart->GetPDG();
 
@@ -410,7 +411,7 @@ if (fDebug > 1) Info("FillParticles","Beginning FillParticles");
     TParticlePDG* pdgP = 0;
  
     for (Int_t part = 0; part < npart; part++) {
-       TParticle *MPart = gAlice->Particle(part);
+       TParticle *MPart = gAlice->GetMCApp()->Particle(part);
        pdgP = MPart->GetPDG();
        
        if (fDebug > 10) Info("FillParticles","Checking if particle is a primary");
@@ -523,7 +524,7 @@ void AliEMCALJetFinderInputSimPrep::FillPartonTracks(AliEMCALParton *parton)
        TParticle *tempPart;
        for (Int_t part = 0; part < npart; part++)
        {
-               tempPart = gAlice->Particle(part);
+               tempPart = gAlice->GetMCApp()->Particle(part);
                if (tempPart->GetStatusCode() != 1) continue;
                if (tempPart->Eta() > fEtaMax || tempPart->Eta() < fEtaMin || 
                    tempPart->Phi() > fPhiMax || tempPart->Phi() < fPhiMin ){
@@ -545,7 +546,7 @@ void AliEMCALJetFinderInputSimPrep::FillPartonTracks(AliEMCALParton *parton)
        ntracks=0;
        for (Int_t part = 0; part < npart; part++)
        {
-               tempPart = gAlice->Particle(part);
+               tempPart = gAlice->GetMCApp()->Particle(part);
                if (tempPart->GetStatusCode() != 1) continue;
                if (tempPart->Eta() > fEtaMax || tempPart->Eta() < fEtaMin ||
                    tempPart->Phi() > fPhiMax || tempPart->Phi() < fPhiMin ){ 
index d2bbec7..444b08f 100644 (file)
@@ -31,6 +31,7 @@
 #include <TBrowser.h>
 #include <TString.h>
 #include <TParticle.h>
+#include "AliMC.h"
 
 ClassImp(AliEMCALJetMicroDst)
 
@@ -337,7 +338,7 @@ void AliEMCALJetMicroDst::FillPartons()
   TParticle *MPart;
   Int_t ind;
   for(Int_t i=6; i<8; i++){
-     MPart = gAlice->Particle(i);
+     MPart = gAlice->GetMCApp()->Particle(i);
      ind   = i-6;
      xpt[ind]  = MPart->Pt();
      xeta[ind] = MPart->Eta();
index 2e3fe27..f13ea3d 100644 (file)
@@ -35,6 +35,7 @@
 #include "TNode.h"
 #include "TRandom.h"
 #include "TGeometry.h"
+#include "TVirtualMC.h"
 
 // --- Standard library ---
 
index 061196c..0540291 100644 (file)
@@ -38,6 +38,7 @@
 #include "TTree.h"
 #include "TGeometry.h"
 #include "TParticle.h"
+#include "TVirtualMC.h"
 
 // --- Standard library ---
 
@@ -55,6 +56,7 @@
 #include "AliEMCALGeometry.h"
 #include "AliConst.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliEMCALv1)
 
@@ -71,7 +73,7 @@ AliEMCALv1::AliEMCALv1(const char *name, const char *title):
     // Standard Creator.
 
     fHits= new TClonesArray("AliEMCALHit",1000);
-    gAlice->AddHitList(fHits);
+    gAlice->GetMCApp()->AddHitList(fHits);
 
     fNhits = 0;
     fIshunt     =  2; // All hits are associated with particles entering the calorimeter
@@ -130,7 +132,7 @@ void AliEMCALv1::StepManager(void){
   Float_t        pmom[4]={0.,0.,0.,0.};
   TLorentzVector pos; // Lorentz vector of the track current position.
   TLorentzVector mom; // Lorentz vector of the track current momentum.
-  Int_t tracknumber =  gAlice->GetCurrentTrackNumber();
+  Int_t tracknumber =  gAlice->GetMCApp()->GetCurrentTrackNumber();
   Int_t primary = 0;
   static Int_t iparent = 0;
   static Float_t ienergy = 0;
@@ -152,7 +154,7 @@ void AliEMCALv1::StepManager(void){
       Int_t parent = iparent ;
       while ( parent != -1 ) { // <------------- flags this particle to be kept and
        //all the ancestors of this particle
-       part = gAlice->Particle(parent) ;
+       part = gAlice->GetMCApp()->Particle(parent) ;
        part->SetBit(kKeepBit);
        parent = part->GetFirstMother() ;
       }
@@ -196,7 +198,7 @@ void AliEMCALv1::StepManager(void){
                                             ;
       xyzte[4] = lightYield  ;
    
-      primary = gAlice->GetPrimary(tracknumber);
+      primary = gAlice->GetMCApp()->GetPrimary(tracknumber);
 
       if (gDebug == 2) 
        Info("StepManager", "id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
index 96010db..4d64b09 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AliDimuCombinator.h" 
 #include "AliRun.h" 
+#include "AliMC.h"
 
 //
 ClassImp(AliDimuCombinator)
@@ -66,7 +67,7 @@ AliDimuCombinator::AliDimuCombinator(const AliDimuCombinator & combinator)
 // 
 TParticle* AliDimuCombinator::Particle(Int_t i)
 {
-    return gAlice->Particle(i);
+    return gAlice->GetMCApp()->Particle(i);
 }
 
 TParticle* AliDimuCombinator::FirstMuon()
index 4e9a2e9..89a6580 100644 (file)
@@ -30,6 +30,7 @@
 #include "AliGenCocktailEntry.h"
 #include "AliCollisionGeometry.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliGenCocktail)
 
@@ -129,7 +130,7 @@ AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
     AliGenCocktailEntry *preventry = 0;
     AliGenerator* gen = 0;
 
-    TObjArray *partArray = gAlice->Particles();
+    TObjArray *partArray = gAlice->GetMCApp()->Particles();
 
 //
 //  Generate the vertex position used by all generators
index 3cd0497..8127ab0 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliGenCocktailAfterBurner.h"
 #include "AliGenCocktailEntry.h"
 #include "AliStack.h"
+#include "AliMC.h"
 
 
 ClassImp(AliGenCocktailAfterBurner)
@@ -344,7 +345,7 @@ void AliGenCocktailAfterBurner::SetTracks(Int_t stackno)
       mech = AliGenCocktailAfterBurner::IntToMCProcess(p->GetUniqueID());
       weight = p->GetWeight();
 
-      gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+      gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                        polx, poly, polz, mech, ntr, weight);
     }
 }
index 520da1f..c99ef8e 100644 (file)
@@ -24,6 +24,7 @@
 #include <RVersion.h>
 #include "TPDGCode.h"
 #include "TDatabasePDG.h"
+#include <TVirtualMC.h>
 
 #include "AliGenFLUKAsource.h"
 #include "AliRun.h"
index 7617404..99d8b5a 100644 (file)
@@ -43,6 +43,7 @@
 #include <TF1.h>
 #include <TParticle.h>
 #include <TPDGCode.h>
+#include <TVirtualMC.h>
 
 #include "AliConst.h"
 #include "AliDecayer.h"
index 32191ad..9203eb9 100644 (file)
 #include <TParticlePDG.h>
 #include <TDatabasePDG.h>
 #include <TLorentzVector.h>
+#include <TVirtualMC.h>
 
 #include <TF1.h>
 #include <TCanvas.h>
 #include <TH1.h>
+#include "AliMC.h"
 
 ClassImp(AliGenParam)
 
@@ -442,7 +444,7 @@ void AliGenParam::Generate()
          } // kinematic selection
          else  // nodecay option, so parent will be tracked by GEANT (pions, kaons, eta, omegas, baryons)
          {
-           gAlice->
+           gAlice->GetMCApp()->
                PushTrack(fTrackIt,-1,iPart,p,origin0,polar,0,kPPrimary,nt,wgtp);
             ipa++; 
          }
index 3218fee..feb90fe 100644 (file)
@@ -63,6 +63,7 @@
 #include "AliLoader.h"
 #include "AliMagF.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp (AliFMD)
   //_____________________________________________________________________________
@@ -91,7 +92,7 @@ AliDetector (name, title)
   // Digits for each Si disk
   fDigits = new TClonesArray ("AliFMDdigit", 1000);
   fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
-  gAlice->AddHitList (fHits);
+  gAlice->GetMCApp()->AddHitList (fHits);
 
   fIshunt = 0;
   //  fMerger = 0;
index a183fc4..8185875 100644 (file)
@@ -37,6 +37,7 @@
 #include <TNode.h>
 #include <TTUBE.h>
 #include <TLorentzVector.h>
+#include <TVirtualMC.h>
 
 #include "AliFMDv0.h"
 #include "AliMagF.h"
index bb217fa..1a8aa6b 100644 (file)
@@ -48,6 +48,7 @@
 #include "AliFMDv1.h"
 #include "AliMagF.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliFMDv1)
 
@@ -414,7 +415,7 @@ void AliFMDv1::StepManager()
          gMC->IsTrackStop())
         {
             hits[6]=de+1000.*gMC->Edep();
-      new(lhits[fNhits++]) AliFMDhit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+      new(lhits[fNhits++]) AliFMDhit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
         } // IsTrackExiting()
      }
   }
index 8e96eec..82c3e33 100644 (file)
@@ -20,6 +20,7 @@
 #include <AliMagF.h>
 #include <AliKalmanTrack.h>
 #include <AliITSIOTrack.h>
+#include "AliMC.h"
 
 ClassImp(AliHBTReaderITSv1)
 /********************************************************************/
@@ -170,7 +171,7 @@ Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
       
       gAliceFile->cd();
       gAlice->GetEvent(currentEvent);
-      gAlice->Particles();
+      gAlice->GetMCApp()->Particles();
 
       Int_t nentr=(Int_t)tracktree->GetEntries();
       
@@ -188,7 +189,7 @@ Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
            continue;
          }
 
-        TParticle *p = (TParticle*)gAlice->Particle(label);
+        TParticle *p = (TParticle*)gAlice->GetMCApp()->Particle(label);
         if(!p)
          {
            Warning("Read","Can not get particle with label &d",label);
index c68fe67..1235c18 100644 (file)
@@ -104,6 +104,7 @@ the AliITS class.
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSPD.h"
 #include "AliITSsimulationSSD.h"
+#include "AliMC.h"
 
 ClassImp(AliITS)
 
@@ -175,7 +176,7 @@ AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
 
     fIshunt     = 0;  // not zeroed in AliDetector
     fHits       = new TClonesArray("AliITShit", 1560);//not done in AliDetector
-    gAlice->AddHitList(fHits);  // Not done in AliDetector.
+    gAlice->GetMCApp()->AddHitList(fHits);  // Not done in AliDetector.
 
     fEuclidOut  = 0;
     fITSgeom    = 0;
index a89787f..b56125a 100644 (file)
@@ -30,6 +30,7 @@
 #include "AliITSFindClustersV2.h"
 #include "AliITSclusterV2.h"
 #include "AliITSgeom.h"
+#include "AliMC.h"
 
 ClassImp(AliITSFindClustersV2)
 
@@ -338,7 +339,7 @@ void AliITSFindClustersV2::Exec(const Option_t *opt){
            lab[3] = i;
            lad = lab[0];
            if(lad>=0){
-               part = (TParticle*) fAr->Particle(lad);
+               part = (TParticle*) fAr->GetMCApp()->Particle(lad);
                lad = -3;
                while(part->P() < 0.005){
                    if(part->GetFirstMother()<0){
@@ -346,7 +347,7 @@ void AliITSFindClustersV2::Exec(const Option_t *opt){
                        break;
                    } // end if part->GetFirstMother()<0
                    lad = part->GetFirstMother();
-                   part = (TParticle*) fAr->Particle(lad);
+                   part = (TParticle*) fAr->GetMCApp()->Particle(lad);
                } // end while part->P() < 0.005
                if(lab[1]<0) lab[1] = lad;
                else if(lab[2]<0) lab[2] = lad;
index 53be000..5c9ea1d 100644 (file)
@@ -69,6 +69,7 @@
 #include "AliITSRecPoint.h"
 #include "AliITSgeom.h"
 #include "AliITSmodule.h"
+#include "AliMC.h"
 
 ClassImp(AliITSRiemannFit)
 
@@ -258,7 +259,7 @@ void AliITSRiemannFit::InitPoints(Int_t ntracks,AliITS *ITS,
       if(track <0 ) continue;
       xcluster=recp->GetX();     // x on cluster
       zcluster=recp->GetZ();     // z on cluster
-      part   = (TParticle*) gAlice->Particle(track);    
+      part   = (TParticle*) gAlice->GetMCApp()->Particle(track);    
       part->ProductionVertex(OT);  // set the vertex 
       part->Momentum(PE);          // set the vertex momentum
       name      = part->GetName();
index a7cc77b..ca8f6f4 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliITSTrackerV1.h"
 #include "AliITSVertex.h"
 #include "AliITSPid.h"
+#include "AliMC.h"
 
 ClassImp(AliITSTrackerV1)
  //______________________________________________________________________
@@ -720,7 +721,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
            for(k=0; k<3; k++){  
                Int_t lpp=(Int_t)vecLabRef(k);
                if(lpp>=0) {
-                   TParticle *p=(TParticle*) gAlice->Particle(lpp);
+                   TParticle *p=(TParticle*) gAlice->GetMCApp()->Particle(lpp);
                    Int_t pcode=p->GetPdgCode();
                    if(pcode==11) vecLabRef(k)=p->GetFirstMother();
                } // end if
index 80df738..afa5d7e 100644 (file)
@@ -20,6 +20,7 @@
 #include <TClonesArray.h>
 #include "AliITSgeom.h"
 #include "AliITSdigit.h"
+#include "AliMC.h"
 
 ClassImp(AliITSclustererV2)
 
@@ -222,7 +223,7 @@ static void CheckLabels(Int_t lab[3]) {
   //------------------------------------------------------------
     Int_t label=lab[0];
     if (label>=0) {
-       TParticle *part=(TParticle*)gAlice->Particle(label);
+       TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
        label=-3;
        while (part->P() < 0.005) {
           Int_t m=part->GetFirstMother();
@@ -235,7 +236,7 @@ static void CheckLabels(Int_t lab[3]) {
              break;
           }
           label=m;
-          part=(TParticle*)gAlice->Particle(label);
+          part=(TParticle*)gAlice->GetMCApp()->Particle(label);
         }
         if      (lab[1]<0) lab[1]=label;
         else if (lab[2]<0) lab[2]=label;
index b298bea..55048bc 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliITS.h"
 #include "AliITSgeom.h"
 #include "AliITShit.h"
+#include "AliMC.h"
 
 
 ClassImp(AliITShit)
@@ -560,7 +561,7 @@ TParticle * AliITShit::GetParticle(){
 // this hit. From the TParticle all kinds of information about this 
 // particle can be found. See the TParticle class.
 ////////////////////////////////////////////////////////////////////////
-    return gAlice->Particle(GetTrack());
+    return gAlice->GetMCApp()->Particle(GetTrack());
 }  
 //----------------------------------------------------------------------
 void AliITShit::Print(ostream *os){
index e2ef835..ade8c99 100644 (file)
@@ -36,10 +36,10 @@ Int_t AliITStestV2(Int_t nev=5, Char_t SlowOrFast='s') {
       AliITSSDigits2Digits();
    }
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindClustersV2.C");
-   if (rc=AliITSFindClustersV2(nev,SlowOrFast)) return rc;
+   if (rc=AliITSFindClustersV2(SlowOrFast)) return rc;
 
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindTracksV2.C");
-   if (rc=AliITSFindTracksV2(nev)) return rc;
+   if (rc=AliITSFindTracksV2()) return rc;
 
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSComparisonV2.C");
    if (rc=AliITSComparisonV2()) return rc;
index 118733e..d84c967 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliITShit.h"
 #include "AliITSv5.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliITSv5)
  
@@ -801,6 +802,6 @@ void AliITSv5::StepManager(){
   hits[6]=gMC->Edep();
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
-  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
   return;
 }
index 27e3e6d..fc0510f 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliITShit.h"
 #include "AliITSv5asymm.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliITSv5asymm)
  
@@ -815,6 +816,6 @@ void AliITSv5asymm::StepManager(){
   hits[6]=gMC->Edep();
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
-  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
   return;
 }
index 76b180e..cc2c039 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliITShit.h"
 #include "AliITSv5symm.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliITSv5symm)
  
@@ -807,6 +808,6 @@ void AliITSv5symm::StepManager(){
   hits[6]=gMC->Edep();
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
-  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
   return;
 }
index 5a90b75..efaec5d 100644 (file)
@@ -72,6 +72,7 @@
 #include "AliITSsimulationSPD.h"
 #include "AliITSsimulationSSD.h"
 #include "AliITSvPPRasymm.h"
+#include "AliMC.h"
 
 
 ClassImp(AliITSvPPRasymm)
@@ -29197,7 +29198,7 @@ void AliITSvPPRasymm::StepManager(){
        copy = fTrackReferences->GetEntriesFast();
        TClonesArray &lTR = *fTrackReferences;
        // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->GetCurrentTrackNumber());
+       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
     if(!(this->IsActive())){
        return;
@@ -29286,7 +29287,7 @@ void AliITSvPPRasymm::StepManager(){
        return;
     } // end if IsEntering
     // Fill hit structure with this new hit.
-    new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,
+    new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
                                   gMC->Edep(),gMC->TrackTime(),position,
                                   position0,momentum);
     //
index 2f16ff4..5893b4d 100644 (file)
@@ -74,6 +74,7 @@
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliTrackReference.h"
+#include "AliMC.h"
 
 #define GEANTGEOMETRY kTRUE
 
@@ -5351,7 +5352,7 @@ void AliITSvPPRasymmFMD::StepManager(){
        copy = fTrackReferences->GetEntriesFast();
        TClonesArray &lTR = *fTrackReferences;
        // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->GetCurrentTrackNumber());
+       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
 
 
@@ -5439,7 +5440,7 @@ void AliITSvPPRasymmFMD::StepManager(){
        return;
     } // end if IsEntering
     // Fill hit structure with this new hit.
-    new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,
+    new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
                                   gMC->Edep(),gMC->TrackTime(),position,
                                   position0,momentum);
     //
index 7fa549a..583207e 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliITSClusterFinderSPD.h"
 #include "AliITSClusterFinderSDD.h"
 #include "AliITSClusterFinderSSD.h"
+#include "AliMC.h"
 
 
 ClassImp(AliITSvSPD02)
@@ -745,7 +746,7 @@ void AliITSvSPD02::StepManager(){
        copy = fTrackReferences->GetEntriesFast();
        TClonesArray &lTR = *fTrackReferences;
        // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->GetCurrentTrackNumber());
+       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
     if(!(this->IsActive())){
        return;
@@ -790,7 +791,7 @@ void AliITSvSPD02::StepManager(){
        return;
     } // end if IsEntering
     // Fill hit structure with this new hit only for non-entrerance hits.
-    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,
+    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
                                        gMC->Edep(),gMC->TrackTime(),position,
                                        position0,momentum);
     //
index cd062e6..bdde597 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliITShit.h"
 #include "AliITSvtest.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliITSvtest)
  
@@ -411,7 +412,7 @@ void AliITSvtest::StepManager(){
   hits[6]=gMC->Edep();
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
-  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
   return;
 }
 
index 85c7f59..308150d 100644 (file)
@@ -23,6 +23,7 @@
 #include "AliMUONRawCluster.h"
 #include "AliMUONClusterInput.h"
 #include "AliMUONPixel.h"
+#include "AliMC.h"
 
 // This function is used for fitting
 void fcn1(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
@@ -110,7 +111,7 @@ newev:
   AliLoader * gime  = rl->GetLoader("MUONLoader");
 
   if (!fReco) nparticles = rl->GetEvent(nev);
-  else nparticles = gAlice->GetNtrack();
+  else nparticles = gAlice->GetMCApp()->GetNtrack();
   cout << "nev         " << nev <<endl;
   cout << "nparticles  " << nparticles <<endl;
   if (nparticles <= 0) return;
index 1dc4250..8b8a663 100644 (file)
@@ -66,6 +66,7 @@
 #include "AliMUONResponse.h"
 #include "AliMUONChamber.h"
 #include "AliMUONConstants.h"
+#include "AliMC.h"
 // to manage the same zoom on both cathodes
 
 
@@ -638,7 +639,7 @@ void AliMUONDisplay::DrawTitle(Option_t *option)
                fChamber,
                fCathode);
        title->AddText(ptitle);
-       Int_t nparticles = gAlice->Particles()->GetEntriesFast();
+       Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
        sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
                nparticles, fHitsCuts,fClustersCuts);
        title->AddText(ptitle);
index f0a365f..e5b2521 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliLoader.h"
 #include "AliMUONTrackK.h" //AZ
 #include <TMatrixD.h> //AZ
+#include "AliMC.h"
 
 //************* Defaults parameters for reconstruction
 static const Double_t kDefaultMinBendingMomentum = 3.0;
@@ -1457,7 +1458,7 @@ void AliMUONEventReconstructor::EventDump(void)
             z, x, y, pX, pY, pZ, c);
   }
   // informations about generated particles
-  np = gAlice->GetNtrack();
+  np = gAlice->GetMCApp()->GetNtrack();
   printf(" **** number of generated particles: %d  \n", np);
   
 //    for (Int_t iPart = 0; iPart < np; iPart++) {
index 14fe22f..31ddc46 100644 (file)
@@ -61,6 +61,7 @@
 
 #include "AliMUONRecoEvent.h"
 #include "AliMUONRecoDisplay.h"
+#include "AliMC.h"
 
 ClassImp(AliMUONRecoDisplay)
 
@@ -183,7 +184,7 @@ void AliMUONRecoDisplay::MapEvent(Int_t nevent)
    for (Int_t track=0; track<ntracks; track++) {
       hit = (AliMUONHit *) pMUON->FirstHit(track);
       if (!hit) continue;
-      particle = gAlice->Particle(hit->Track());
+      particle = gAlice->GetMCApp()->Particle(hit->Track());
       if (IsReconstructible(track) && TMath::Abs(particle->GetPdgCode())==13) {
          gtrack = fEvGen->AddEmptyTrack();
         gtrack->SetSign(TMath::Sign((Int_t)1, -particle->GetPdgCode()));
index 0006652..6ce42ba 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliMUONv0.h"
 #include "AliMagF.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliMUONv0)
  
@@ -214,7 +215,7 @@ void AliMUONv0::StepManager()
       hits[13] = mom[2];                    // Pz
       hits[14] = gMC->TrackTime();          // time of flight
       new(lhits[fNhits++]) 
-         AliMUONHit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+         AliMUONHit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
 
   }
 //  if( gMC->IsTrackExiting()) gMC->StopTrack(); 
index 75ca009..1898696 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliMUONv1.h"
 #include "AliMagF.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliMUONv1)
  
@@ -1742,7 +1743,7 @@ void AliMUONv1::StepManager()
     
     
     // One hit per chamber
-    GetMUONData()->AddHit(fIshunt, gAlice->GetCurrentTrackNumber(), iChamber, ipart, 
+    GetMUONData()->AddHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), iChamber, ipart, 
                          fTrackPosition.X(), fTrackPosition.Y()+YAngleEffect, fTrackPosition.Z(), 0.0, 
                          fTrackMomentum.P(),theta, phi, fStepSum[idvol], fDestepSum[idvol],
                          fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z());
@@ -1903,7 +1904,7 @@ void AliMUONv1::StepManagerOld()
 //    new hit 
       
       new(lhits[fNhits++]) 
-         AliMUONHit(fIshunt, gAlice->GetCurrentTrackNumber(), vol,hits);
+         AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
       eloss = 0; 
       //
       // Check additional signal generation conditions 
index b89bf3f..d782b93 100644 (file)
@@ -31,6 +31,7 @@
 #include <TArrayI.h>
 #include <Riostream.h>
 #include <TSystem.h>
+#include <TVirtualMC.h>
 
 #include "AliMpFiles.h"
 #include "AliMpReader.h"
index b1b4127..1b221d9 100644 (file)
@@ -56,6 +56,7 @@
 // #include "AliPHOSRaw2Digits.h"
 //#include "AliPHOSCalibrationDB.h"
 #include "AliPHOSBeamTestEvent.h"
+#include "AliMC.h"
 
 ClassImp(AliPHOSGetter)
   
@@ -585,7 +586,7 @@ TParticle * AliPHOSGetter::Secondary(const TParticle* p, const Int_t index) cons
   if(p) {
   Int_t daughterIndex = p->GetDaughter(index-1) ; 
   AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
-  return  rl->GetAliRun()->Particle(daughterIndex) ; 
+  return  rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; 
   }
   else
     return 0 ;
index de16fc7..307533e 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliPHOSQAMeanChecker.h"
 #include "AliPHOSv1.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliPHOSv1)
 
@@ -94,7 +95,7 @@ AliPHOSv1::AliPHOSv1(const char *name, const char *title):
   // and the TreeD at the end of the event (branch is set in FinishEvent() ). 
   
   fHits= new TClonesArray("AliPHOSHit",1000) ;
-  gAlice->AddHitList(fHits) ; 
+  gAlice->GetMCApp()->AddHitList(fHits) ; 
 
   fNhits = 0 ;
 
@@ -280,7 +281,7 @@ void AliPHOSv1::StepManager(void)
   TLorentzVector pos      ;           // Lorentz vector of the track current position
   Int_t          copy     ;
 
-  Int_t tracknumber =  gAlice->GetCurrentTrackNumber() ; 
+  Int_t tracknumber =  gAlice->GetMCApp()->GetCurrentTrackNumber() ; 
   TString name      =  GetGeometry()->GetName() ; 
 
   Int_t moduleNumber ;
@@ -400,9 +401,9 @@ void AliPHOSv1::StepManager(void)
       gMC -> Gmtod (xyzte, xyzd, 1);    // transform coordinate from master to daughter system    
       if (xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2.+0.001){   //Entered close to forward surface  
        TParticle * part = 0 ; 
-       Int_t parent = gAlice->GetCurrentTrackNumber() ; 
+       Int_t parent = gAlice->GetMCApp()->GetCurrentTrackNumber() ; 
        while ( parent != -1 ) {
-         part = gAlice->Particle(parent) ; 
+         part = gAlice->GetMCApp()->Particle(parent) ; 
          part->SetBit(kKeepBit);
          parent = part->GetFirstMother() ; 
        }
@@ -438,17 +439,17 @@ void AliPHOSv1::StepManager(void)
       
       Int_t primary =-1 ;
       if(fIshunt == 1)
-        primary  =  gAlice->GetPrimary( gAlice->GetCurrentTrackNumber() ); 
+        primary  =  gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() ); 
       else if(fIshunt == 2){
-         primary = gAlice->GetCurrentTrackNumber() ;
-         TParticle * part = gAlice->Particle(primary) ;
+         primary = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
+         TParticle * part = gAlice->GetMCApp()->Particle(primary) ;
          while ( !part->TestBit(kKeepBit) ) {
            primary = part->GetFirstMother() ;
            if(primary == -1) break ; //there is a possibility that particle passed e.g. thermal isulator and hits a side 
                                      //surface of the crystal. In this case it may have no primary at all. 
                                      //We can not easily separate this case from the case when this is part of the shower, 
                                      //developed in the neighboring crystal.
-           part = gAlice->Particle(primary) ;
+           part = gAlice->GetMCApp()->Particle(primary) ;
          }
       }
 
index e698cfb..e8dc33e 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliPHOSImpact.h"
 #include "AliPHOSvImpacts.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliPHOSvImpacts)
 
@@ -191,8 +192,8 @@ void AliPHOSvImpacts::StepManager(void)
   TLorentzVector pos      ;           // Lorentz vector of the track current position
   Int_t          copy     ;
 
-  Int_t tracknumber =  gAlice->GetCurrentTrackNumber() ; 
-  Int_t primary     =  gAlice->GetPrimary( gAlice->GetCurrentTrackNumber() ); 
+  Int_t tracknumber =  gAlice->GetMCApp()->GetCurrentTrackNumber() ; 
+  Int_t primary     =  gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() ); 
   TString name      =  GetGeometry()->GetName() ; 
 
   // Add impact to EMC
index 9eacfe1..938b197 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliPMD.h"
 #include "AliPMDRecPoint.h"
 #include "AliRun.h"
+#include "AliMC.h"
   
 ClassImp(AliPMD)
  
@@ -77,7 +78,7 @@ AliPMD::AliPMD(const char *name, const char *title)
   // 
   // Allocate the array of hits
   fHits   = new TClonesArray("AliPMDhit",  405);
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
 
   fRecPoints  = new TClonesArray("AliPMDRecPoint",10000); 
   fNRecPoints = 0;
index abc9a1c..743a014 100644 (file)
@@ -32,6 +32,7 @@
 #include "AliPMDdigit.h"
 #include "AliPMDDigitizer.h"
 #include "AliPMDClustering.h"
+#include "AliMC.h"
 
 ClassImp(AliPMDDigitizer)
 //
@@ -150,7 +151,7 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
   Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
   printf("Number of Particles = %d \n", nparticles);
   fRunLoader->GetEvent(ievt);
-  Particles = gAlice->Particles();
+  Particles = gAlice->GetMCApp()->Particles();
   // ------------------------------------------------------- //
   // Pointer to specific detector hits.
   // Get pointers to Alice detectors and Hits containers
@@ -189,7 +190,7 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
 
              //  get kinematics of the particles
              
-             particle = gAlice->Particle(trackno);
+             particle = gAlice->GetMCApp()->Particle(trackno);
              trackpid  = particle->GetPdgCode();
 
              Int_t igatr = -999;
@@ -212,7 +213,7 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
              while((imo = mparticle->GetFirstMother()) >= 0)
                {
                  igen++;
-                 mparticle =  gAlice->Particle(imo);
+                 mparticle =  gAlice->GetMCApp()->Particle(imo);
                  id_mo = mparticle->GetPdgCode();
                  
                  vx = mparticle->Vx();
@@ -385,7 +386,7 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
   Int_t nparticles = fRunLoader->GetHeader()->GetNtrack();
   printf("Number of Particles = %d \n", nparticles);
   fRunLoader->GetEvent(ievt);
-  Particles = gAlice->Particles();
+  Particles = gAlice->GetMCApp()->Particles();
   // ------------------------------------------------------- //
   // Pointer to specific detector hits.
   // Get pointers to Alice detectors and Hits containers
@@ -429,7 +430,7 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
              
              //  get kinematics of the particles
              
-             particle = gAlice->Particle(trackno);
+             particle = gAlice->GetMCApp()->Particle(trackno);
              trackpid  = particle->GetPdgCode();
 
              Int_t igatr = -999;
@@ -452,7 +453,7 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
              while((imo = mparticle->GetFirstMother()) >= 0)
                {
                  igen++;
-                 mparticle =  gAlice->Particle(imo);
+                 mparticle =  gAlice->GetMCApp()->Particle(imo);
                  id_mo = mparticle->GetPdgCode();
                  
                  vx = mparticle->Vx();
index ffbbd8e..f478ea5 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliMagF.h" 
 #include "AliPMDv0.h"
 #include "AliRun.h"
+#include "AliMC.h"
  
 static Int_t   kdet, ncell_sm, ncell_hole;
 static Float_t zdist, zdist1;
@@ -998,7 +999,7 @@ void AliPMDv0::StepManager()
 
     gMC->Gdtom(center,hits,1);
     hits[3] = destep*1e9; //Number in eV
-    AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
   }
 }
 
index 20ccfc7..10109aa 100644 (file)
@@ -14,6 +14,9 @@
  **************************************************************************/
 /*
 $Log$
+Revision 1.29  2003/10/13 05:28:59  bnandi
+gaspmd[2] value changed 0.25->7.0 because of overlap
+
 Revision 1.28  2003/10/08 12:59:08  bnandi
 zpos is positive
 
@@ -55,6 +58,7 @@ June 2003
 #include "AliMagF.h" 
 #include "Riostream.h"
 #include <TVirtualMC.h>
+#include "AliMC.h"
  
 static Int_t     ncol_um1,ncol_um2, nrow_um1, nrow_um2;
 static Int_t     kdet;
@@ -887,7 +891,7 @@ void AliPMDv1::StepManager()
     
     gMC->Gdtom(center,hits,1);
     hits[3] = destep*1e9; //Number in eV
-    AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
 
   }
 }
index 549c6ca..22034ac 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliRun.h"
 #include "AliStack.h"
 #include "AliRunLoader.h"
+#include "AliMC.h"
 
 ClassImp(AliGenPythia)
 
@@ -615,9 +616,9 @@ void AliGenPythia::AdjustWeights()
 // Adjust the weights after generation of all events
 //
     TParticle *part;
-    Int_t ntrack=gAlice->GetNtrack();
+    Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
     for (Int_t i=0; i<ntrack; i++) {
-       part= gAlice->Particle(i);
+       part= gAlice->GetMCApp()->Particle(i);
        part->SetWeight(part->GetWeight()*fKineBias);
     }
 }
index c76cec7..c05f260 100644 (file)
@@ -26,6 +26,8 @@
 #include "AliRICHRecHit1D.h"
 #include <AliRun.h>
 #include <AliRunDigitizer.h>
+#include "AliMC.h"
+#include <TVirtualMC.h>
  
 ClassImp(AliRICHhit)
 //__________________________________________________________________________________________________
@@ -77,12 +79,12 @@ AliRICH::AliRICH(const char *name, const char *title)
   fpParam     =   new AliRICHParam;
   fChambers = 0;  CreateChambers();
 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
-  fHits=       0;     CreateHits();          gAlice->AddHitList(fHits);
+  fHits=       0;     CreateHits();          gAlice->GetMCApp()->AddHitList(fHits);
   fSdigits=    0;
   fDigitsNew=  0;
   fClusters=   0;
   
-  fCerenkovs=  0;     CreateCerenkovsOld();  gAlice->AddHitList(fCerenkovs);
+  fCerenkovs=  0;     CreateCerenkovsOld();  gAlice->GetMCApp()->AddHitList(fCerenkovs);
   fSpecials=   0;     CreateSpecialsOld();   
   fDchambers=  0;   //CreateDigitsOld();
   fRawClusters=0;   //CreateRawClustersOld();
@@ -997,8 +999,8 @@ void AliRICH::GenerateFeedbacks(Int_t iChamber,Float_t eloss)
     for(j=0;j<3;j++) pol[j]=e1[j]*TMath::Sin(phi)+e2[j]*TMath::Cos(phi);
     gMC->Gdtom(pol, pol, 2);
     Int_t outputNtracksStored;    
-    gAlice->PushTrack(1,                             //do not transport
-                     gAlice->GetCurrentTrackNumber(),//parent track 
+    gAlice->GetMCApp()->PushTrack(1,                 //do not transport
+                     gAlice->GetMCApp()->GetCurrentTrackNumber(),//parent track 
                      kFeedback,                      //PID
                     mom[0],mom[1],mom[2],mom[3],    //track momentum  
                      x4.X(),x4.Y(),x4.Z(),x4.T(),    //track origin 
index 698d0b3..d355522 100644 (file)
@@ -236,8 +236,8 @@ public:
   AliRICHChamber* C(Int_t iC)           const{return (AliRICHChamber*)fChambers->At(iC-1);}
   AliRICHParam*   Param()               const{return fpParam;}
   
-  AliRICHhit*     FirstHit(Int_t iTrkN)      {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);}                   //virtual
-  AliRICHhit*     NextHit()                  {return (AliRICHhit*)AliDetector::NextHit();}                         //virtual 
+  //  AliRICHhit*     FirstHit(Int_t iTrkN)      {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);}                   //virtual
+  //  AliRICHhit*     NextHit()                  {return (AliRICHhit*)AliDetector::NextHit();}                         //virtual 
   
           void    CreateChambers();         
           void    CreateMaterials(); //virtual
index 38a9534..4d67d34 100644 (file)
@@ -64,6 +64,7 @@
 #include "AliRICHDigit.h"
 #include "AliRICHRawCluster.h"
 #include "AliRICHRecHit1D.h"
+#include "AliMC.h"
 
 ClassImp(AliRICHDisplay)
     
@@ -611,7 +612,7 @@ void AliRICHDisplay::DrawTitle(Option_t *option)
        sprintf(ptitle,"Alice event: %d, Run:%d",
                gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
        title->AddText(ptitle);
-       Int_t nparticles = gAlice->Particles()->GetEntriesFast();
+       Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
        sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
                nparticles, fHitsCuts,fClustersCuts);
        title->AddText(ptitle);
@@ -981,7 +982,7 @@ void AliRICHDisplay::LoadHits(Int_t chamber)
            points = new AliRICHPoints(1);
            fPhits->AddAt(points,npoints);
             mHit = (AliRICHhit*)pRICHhits->UncheckedAt(hit);
-           TParticle *current = (TParticle*)gAlice->Particle(mHit->Track());
+           TParticle *current = (TParticle*)gAlice->GetMCApp()->Particle(mHit->Track());
            if (current->GetPdgCode() == 50000050) {
                points->SetMarkerColor(kBlue);
            } else if (current->GetPdgCode() == 50000051) {
index d902b39..c095a5b 100644 (file)
@@ -42,6 +42,7 @@
 #include "AliRICHSDigit.h"
 #include "AliRICHDigit.h"
 #include "AliRICHRawCluster.h"
+#include "AliMC.h"
 
 const Int_t kMaxNipx=400, kMaxNipy=800;
  
@@ -139,8 +140,8 @@ TParticle *AliRICHPoints::GetParticle() const
   //
   //   Returns pointer to particle index in AliRun::fParticles
   //
-  if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
-  return gAlice->Particle(fIndex);
+  if (fIndex < 0 || fIndex >= gAlice->GetMCApp()->GetNtrack()) return 0;
+  return gAlice->GetMCApp()->Particle(fIndex);
 }
 
 //_____________________________________________________________________________
@@ -251,7 +252,7 @@ void AliRICHPoints::ShowRing(Int_t highlight) {
        if (marker)
          marker->Draw();
       }
-      TParticle *p = gAlice->Particle(fIndex);
+      TParticle *p = gAlice->GetMCApp()->Particle(fIndex);
       printf("\nTrack index %d\n",fTrackIndex);
       printf("Particle ID %d\n",p->GetPdgCode());
       printf("Parent %d\n",p->GetFirstMother());
index 2acd070..9fe9f6f 100644 (file)
@@ -23,6 +23,7 @@
 #include "AliRICHResponseV0.h"
 #include "AliRun.h"
 #include "AliSegmentation.h"
+#include "AliMC.h"
 
 //___________________________________________
 ClassImp(AliRICHResponseV0)
@@ -201,7 +202,7 @@ Int_t AliRICHResponseV0::FeedBackPhotons(Float_t *source, Float_t qtot)
 
   //  Get weight of current particle
   TParticle *current = (TParticle*) 
-    (*gAlice->Particles())[gAlice->GetCurrentTrackNumber()];
+    (*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
     
   ifeed = Int_t(current->GetWeight()/100+0.5);
   ipart = gMC->TrackPid();
@@ -291,7 +292,7 @@ Int_t AliRICHResponseV0::FeedBackPhotons(Float_t *source, Float_t qtot)
     // Put photon on the stack and label it as feedback (51, 52) 
     ++sNfeed;
 
-    gAlice->PushTrack(Int_t(1), gAlice->GetCurrentTrackNumber(), Int_t(50000051),
+    gAlice->GetMCApp()->PushTrack(Int_t(1), gAlice->GetMCApp()->GetCurrentTrackNumber(), Int_t(50000051),
                     mom[0],mom[1],mom[2],mom[3],source[0],source[1],source[2],position[3],pol[0],pol[1],pol[2],
                     kPFeedBackPhoton, nt, 1.);
     
index 73004e2..dc8e0b2 100644 (file)
@@ -19,6 +19,7 @@
 #include "AliRICHConst.h" 
 #include <AliRun.h>
 #include <TLorentzVector.h>
+#include "AliMC.h"
 
 ClassImp(AliRICHv0)
 
@@ -45,7 +46,7 @@ void AliRICHv0::StepManager()
   Info("","event=%i hunt=%i tid=%i pid=%i(%s) m=%f q=%3.1f",
                             gMC->CurrentEvent(),
                             fIshunt,
-                            gAlice->GetCurrentTrackNumber(),
+                            gAlice->GetMCApp()->GetCurrentTrackNumber(),
                             gMC->TrackPid(),
                             sParticle,
                             gMC->TrackMass(),
index 9e9cb8b..6a2aa16 100644 (file)
@@ -24,6 +24,7 @@
 #include <AliConst.h>
 #include <AliPDG.h>
 #include <AliRun.h>
+#include <AliMC.h>
 
 ClassImp(AliRICHv1)    
 //______________________________________________________________________________
@@ -59,7 +60,7 @@ void AliRICHv1::StepManager()
   static Float_t eloss,  tlength;
   const  Float_t kBig=1.e10;
        
-  TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->GetCurrentTrackNumber()];
+  TParticle *current = (TParticle*)(*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
 
     
  
@@ -80,7 +81,7 @@ void AliRICHv1::StepManager()
           if(gMC->IsNewTrack()){//C+E+enter+FRE+new
             Int_t mother=current->GetFirstMother(); 
             ckovData[10]=mother;
-            ckovData[11]=gAlice->GetCurrentTrackNumber();
+            ckovData[11]=gAlice->GetMCApp()->GetCurrentTrackNumber();
             ckovData[12]=1;             //Media where photon was produced 1->Freon, 2->Quarz
             fCkovNumber++;
             fFreonProd=1;
@@ -234,7 +235,7 @@ void AliRICHv1::StepManager()
             coscerenkov = 0;
           ckovData[18]=TMath::ACos(coscerenkov);//Cerenkov angle
         }
-        AddHit(gAlice->GetCurrentTrackNumber(),vol,ckovData);//PHOTON HIT CF+CSI+DE
+        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);//PHOTON HIT CF+CSI+DE
         //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
       }//CF+CSI+DE
     }//CF+CSI
@@ -285,7 +286,7 @@ void AliRICHv1::StepManager()
           hits[8]= hits[8]+1;
           hits[9]= (Float_t) fNsdigits;
         }
-       AddHit(gAlice->GetCurrentTrackNumber(),vol,hits);//MIP HIT MIP+GAP+Exit
+       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);//MIP HIT MIP+GAP+Exit
        eloss = 0; 
       }/*MIP+GAP+Exit*/else if(Param()->SigGenCond(localPos[0], localPos[2])){//MIP+GAP+Spec
         Param()->SigGenInit(localPos[0], localPos[2]);
index 86cf48b..8df30ae 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliRICHRawCluster.h"
 #include "AliRICHDigit.h"
 #include "AliRICHRecHit1D.h"
+#include "AliMC.h"
 
 
 ClassImp(AliRICHv3)
@@ -112,7 +113,7 @@ void AliRICHv3::StepManager()
     const  Float_t kBig=1.e10;
        
     TClonesArray &lhits = *fHits;
-    TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->GetCurrentTrackNumber()];
+    TParticle *current = (TParticle*)(*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
 
  //if (current->Energy()>1)
    //{
@@ -163,7 +164,7 @@ void AliRICHv3::StepManager()
                      //printf("Second Mother:%d\n",current->GetSecondMother());
                      
                      ckovData[10] = mother;
-                     ckovData[11] = gAlice->GetCurrentTrackNumber();
+                     ckovData[11] = gAlice->GetMCApp()->GetCurrentTrackNumber();
                      ckovData[12] = 1;             //Media where photon was produced 1->Freon, 2->Quarz
                      //printf("Produced in FREO\n");
                      fCkovNumber++;
@@ -207,7 +208,7 @@ void AliRICHv3::StepManager()
                        if (ranf[0] > t) {
                          gMC->StopTrack();
                          ckovData[13] = 5;
-                         AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                         AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
                          //printf("Added One (1)!\n");
                          //printf("Lost one in grid\n");
                        }
@@ -237,7 +238,7 @@ void AliRICHv3::StepManager()
                            if (ranf[0] < t) {
                              gMC->StopTrack();
                              ckovData[13] = 6;
-                             AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                             AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
                                
                              //printf("Added One (2)!\n");
                              //printf("Lost by Fresnel\n");
@@ -285,7 +286,7 @@ void AliRICHv3::StepManager()
                        ckovData[13]=16;
                      }
                      gMC->StopTrack();
-                     AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                     AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
                      //printf("Added One (3)!\n");
                      //printf("Added cerenkov %d\n",fCkovNumber);
                    } //absorption question 
@@ -295,7 +296,7 @@ void AliRICHv3::StepManager()
                    else if (procs[i] == kPStop) {                 //is it below energy treshold?
                      ckovData[13]=21;
                      gMC->StopTrack();
-                     AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                     AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
                      //printf("Added One (4)!\n");
                    }   // energy treshold question         
                  }  //number of mechanisms cycle
@@ -421,8 +422,8 @@ void AliRICHv3::StepManager()
                      }
                    //if (sector != -1)
                    //{
-                   AddHit(gAlice->GetCurrentTrackNumber(),vol,ckovData);
-                   AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                   AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
+                   AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
                    //printf("Added One (5)!\n");
                    //}
                }
@@ -566,7 +567,7 @@ void AliRICHv3::StepManager()
                }
                
                //if(sector !=-1)
-               new(lhits[fNhits++]) AliRICHhit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
+               new(lhits[fNhits++]) AliRICHhit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
                eloss = 0; 
                //
                // Check additional signal generation conditions 
@@ -714,7 +715,7 @@ void AliRICHv3::DiagnosticsFE(Int_t evNumber1,Int_t evNumber2)
               Float_t PTfinal;
               Float_t PTvertex;
 
-             TParticle *current = gAlice->Particle(index);
+             TParticle *current = gAlice->GetMCApp()->Particle(index);
              
              //Float_t energy=current->Energy(); 
 
index b4cdac5..151c362 100755 (executable)
@@ -55,6 +55,7 @@
 #include "AliSTARThit.h"
 #include "AliSTARThitPhoton.h"
 #include "AliSTARTvertex.h"
+#include "AliMC.h"
 
 ClassImp(AliSTART)
 
@@ -84,10 +85,10 @@ AliSTART::AliSTART(const char *name, const char *title)
   //
   // Initialise Hit array
   fHits       = new TClonesArray("AliSTARThit",  405);
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
 
   fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
-  gAlice->AddHitList (fPhotons);
+  gAlice->GetMCApp()->AddHitList (fPhotons);
   
   fIshunt     =  1;
   fIdSens   =  0;
index 6954df9..1ec55b2 100755 (executable)
@@ -41,6 +41,7 @@
 #include "AliRun.h"
 #include "AliSTARThit.h"
 #include "AliSTARTv1.h"
+#include "AliMC.h"
 
 ClassImp(AliSTARTv1)
 
@@ -612,7 +613,7 @@ void AliSTARTv1::StepManager()
       Float_t de=gMC->Edep(); 
       edep=edep+de;
       hits[3]=edep*1e3;
-      new(lhits[fNhits++]) AliSTARThit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);      
+      new(lhits[fNhits++]) AliSTARThit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);      
     }
   }
 //---------------------------------------------------------------------
index 2188db9..39716f9 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliRun.h"
 #include "AliSTARThit.h"
 #include "AliSTARTv2.h"
+#include "AliMC.h"
 //#include "AliSTARThitPhoton.h"
 //#include "TGeant3.h"
 
@@ -372,7 +373,7 @@ void AliSTARTv2::StepManager()
           hitPhoton[4] = 1e9 * gMC->TrackTime();
           hitPhoton[5] = 1e9 * gMC->Etot();
           
-          AddHitPhoton (gAlice->GetCurrentTrackNumber(), vol, hitPhoton);
+          AddHitPhoton (gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hitPhoton);
        }
        gMC->StopTrack();
      }
@@ -436,7 +437,7 @@ void AliSTARTv2::StepManager()
       //        printf(" HITS on START Exit %f\n",hits[i]); } 
       //for (i=0; i<=1; i++) { printf("START vol %d\n",vol[i]);}
      
-      new(lhits[fNhits++]) AliSTARThit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);      
+      new(lhits[fNhits++]) AliSTARThit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);      
     }
   }
 
index bea7d3b..7e90fda 100644 (file)
@@ -48,6 +48,7 @@
 #include "AliPoints.h"
 #include "AliLoader.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 
 // Static variables for the hit iterator routines
@@ -288,7 +289,7 @@ void AliDetector::LoadPoints(Int_t)
 //    Error("LoadPoints","nhits == 0. Name is %s",GetName());
     return;
    }
-  Int_t tracks = gAlice->GetNtrack();
+  Int_t tracks = gAlice->GetMCApp()->GetNtrack();
   if (fPoints == 0) fPoints = new TObjArray(tracks);
   AliHit *ahit;
   //
index c6c8760..47fd86b 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliStack.h"
 #include "TGeometry.h"
 #include "TParticle.h"
+#include "AliMC.h"
 
 static const Float_t kptcutmax  = 2;
 static const Float_t ketacutmax = 1.5;
@@ -369,7 +370,7 @@ void AliDisplay::ShowTrack(Int_t idx)
 //       fPad->Modified();
         //         TClonesArray *particles=gAlice->Particles();
         //         TParticle *p = (TParticle*)particles->UncheckedAt(idx);
-        TParticle *p = gAlice->Particle(idx);
+        TParticle *p = gAlice->GetMCApp()->Particle(idx);
          printf("\nTrack index %d\n",idx);
          printf("Particle ID %d\n",p->GetPdgCode());
          printf("Parent %d\n",p->GetFirstMother());
@@ -646,7 +647,7 @@ void AliDisplay::DrawTitle(Option_t *option)
       char ptitle[100];
       sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
       title->AddText(ptitle);
-      Int_t nparticles = gAlice->Particles()->GetEntriesFast();
+      Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
       sprintf(ptitle,"Nparticles = %d  Nhits = %d",nparticles, fHitsCuts);
       title->AddText(ptitle);
    } else {
@@ -809,7 +810,7 @@ void AliDisplay::LoadPoints()
    gAlice->ResetPoints();
    TIter next(gAlice->Modules());
    AliModule *module;
-   Int_t ntracks = gAlice->GetNtrack();
+   Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
 
    while((module = (AliModule*)next())) 
     {
@@ -825,14 +826,14 @@ void AliDisplay::LoadPoints()
       for (Int_t track=0; track<fNTracksToDisplay;track++) 
        {
         gAlice->ResetHits();
-        Int_t nev = nprim-1-gAlice->GetPrimary(fTracksToDisplay[track]);
+        Int_t nev = nprim-1-gAlice->GetMCApp()->GetPrimary(fTracksToDisplay[track]);
         while((module = (AliModule*)next())) 
          {
           AliDetector* detector = dynamic_cast<AliDetector*>(module);
           if(detector)
            {
             detector->TreeH()->GetEvent(nev);
-            module->LoadPoints(nprim-1-gAlice->GetPrimary(fTracksToDisplay[track]));
+            module->LoadPoints(nprim-1-gAlice->GetMCApp()->GetPrimary(fTracksToDisplay[track]));
            }
          }
         next.Reset();
index 654cfeb..8a3887e 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliGenerator.h"
 #include "AliRun.h"
 #include "AliStack.h"
+#include "AliMC.h"
 
 ClassImp(AliGenerator)
 
@@ -80,7 +81,8 @@ AliGenerator::AliGenerator():
     if (gAlice) {
        if (gAlice->GetDebug()>0)
            printf("\n AliGenerator Default Constructor\n\n");
-       gAlice->SetGenerator(this);
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
     }
 
     SetThetaRange(); ResetBit(kThetaRange);
@@ -136,7 +138,8 @@ AliGenerator::AliGenerator(Int_t npart):
     if (gAlice) {
        if (gAlice->GetDebug()>0)
            printf("\n AliGenerator Constructor initializing number of particles \n\n");
-       gAlice->SetGenerator(this);
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
     }
     
     SetThetaRange(); ResetBit(kThetaRange);
@@ -402,7 +405,7 @@ void  AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
     fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
                      mech, ntr, weight, is);
   else 
-    gAlice->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
+    gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
                      mech, ntr, weight, is);
 }
 
@@ -421,7 +424,7 @@ void  AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
      fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                       polx, poly, polz, mech, ntr, weight, is);
   else 
-     gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+     gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                         polx, poly, polz, mech, ntr, weight, is);
 }
 
@@ -435,7 +438,7 @@ void AliGenerator:: KeepTrack(Int_t itrack)
   if (fStack)
      fStack->KeepTrack(itrack);
   else 
-     gAlice->KeepTrack(itrack);
+     gAlice->GetMCApp()->KeepTrack(itrack);
    
 }
 
@@ -448,7 +451,7 @@ void AliGenerator:: SetHighWaterMark(Int_t nt)
   if (fStack)
      fStack->SetHighWaterMark(nt);
   else 
-     gAlice->SetHighWaterMark(nt);
+     gAlice->GetMCApp()->SetHighWaterMark(nt);
    
 }
 void AliGenerator::FinishRun()
index 9517767..02cb1ce 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "AliHit.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliHit)
 
@@ -52,8 +53,8 @@ AliHit::AliHit(Int_t shunt, Int_t track):
   // Standard constructor
   //
   if(shunt == 1) {
-    int primary = gAlice->GetPrimary(track);
-    gAlice->Particle(primary)->SetBit(kKeepBit);
+    int primary = gAlice->GetMCApp()->GetPrimary(track);
+    gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
     fTrack=primary;
   } 
 
@@ -67,7 +68,7 @@ AliHit::AliHit(Int_t shunt, Int_t track):
     Int_t parent=track;
     while (1) {
       current=parent;
-      part = gAlice->Particle(current);
+      part = gAlice->GetMCApp()->Particle(current);
       parent=part->GetFirstMother();    
       if(parent<0 || part->TestBit(kKeepBit))
        break;
@@ -77,6 +78,6 @@ AliHit::AliHit(Int_t shunt, Int_t track):
 
   else {
     fTrack=track;
-    gAlice->FlagTrack(fTrack);
+    gAlice->GetMCApp()->FlagTrack(fTrack);
   }
 }
index 4e84871..5282b61 100644 (file)
 #include "TH2.h"
 #include "TMath.h"
 #include "TString.h"
+#include "TVirtualMC.h"
 
 #include "AliConst.h"
 #include "AliDebugVolume.h"
 #include "AliLego.h"
 #include "AliLegoGenerator.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliLego)
 
@@ -220,7 +222,7 @@ void AliLego::BeginEvent()
     fStepsForward    = 0;
     fStepsBackward   = 0;                
     fErrorCondition  = 0;
-    if (gAlice->GetCurrentTrackNumber() == 0) fStepBack = 0;
+    if (gAlice->GetMCApp()->GetCurrentTrackNumber() == 0) fStepBack = 0;
   }
 }
 
@@ -349,7 +351,7 @@ void AliLego::StepManager()
           orig[1] =  vect[1];     
           orig[2] =  vect[2];
           
-          gAlice->PushTrack(1, gAlice->GetCurrentTrackNumber(), 
+          gAlice->GetMCApp()->PushTrack(1, gAlice->GetMCApp()->GetCurrentTrackNumber(), 
                            0, pmom, orig, polar, 0., kPNoProcess, ntr);
         } // debug
         
index 9bb7a81..3fd56ab 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliLegoGenerator.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliLegoGenerator)
 
@@ -125,7 +126,7 @@ void AliLegoGenerator::Generate()
    
    Float_t polar[3]={0.,0.,0.};
    Int_t ntr;
-   gAlice->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
+   gAlice->GetMCApp()->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
    
 }
 
index 4dc1489..ca803d5 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliLegoGeneratorEta.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliLegoGeneratorEta)
 
@@ -81,6 +82,6 @@ void AliLegoGeneratorEta::Generate()
    
    Float_t polar[3]={0.,0.,0.};
    Int_t ntr;
-   gAlice->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
+   gAlice->GetMCApp()->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
    
 }
index 3c4be20..e8ea037 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliLegoGeneratorPhiZ.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliLegoGeneratorPhiZ)
 
@@ -78,6 +79,6 @@ void AliLegoGeneratorPhiZ::Generate()
    
    Float_t polar[3]={0.,0.,0.};
    Int_t ntr;
-   gAlice->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
+   gAlice->GetMCApp()->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
    
 }
index 80da302..740c56c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliLegoGeneratorXYZ.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliLegoGeneratorXYZ)
 
@@ -128,7 +129,7 @@ void AliLegoGeneratorXYZ::Generate()
    
    Float_t polar[3]={0.,0.,0.};
    Int_t ntr;
-   gAlice->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
+   gAlice->GetMCApp()->PushTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
    
 }
 
diff --git a/STEER/AliMC.cxx b/STEER/AliMC.cxx
new file mode 100644 (file)
index 0000000..c331790
--- /dev/null
@@ -0,0 +1,982 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+#include <TBrowser.h>
+#include <TStopwatch.h>
+#include <TSystem.h>
+#include <TVirtualMC.h>
+#include "AliDetector.h"
+#include "AliGenerator.h"
+#include "AliHeader.h"
+#include "AliLego.h"
+#include "AliMC.h"
+#include "AliMCQA.h"
+#include "AliRun.h"
+#include "AliStack.h"
+#include "AliTrackReference.h"
+
+
+ClassImp(AliMC)
+
+//_______________________________________________________________________
+AliMC::AliMC() :
+  fGenerator(0),
+  fEventEnergy(0),
+  fSummEnergy(0),
+  fSum2Energy(0),
+  fTrRmax(1.e10),
+  fTrZmax(1.e10),
+  fImedia(0),
+  fTransParName("\0"),
+  fMCQA(0),
+  fHitLists(0),
+  fTrackReferences(0)
+
+{
+}
+
+//_______________________________________________________________________
+AliMC::AliMC(const char *name, const char *title) :
+  TVirtualMCApplication(name, title),
+  fGenerator(0),
+  fEventEnergy(0),
+  fSummEnergy(0),
+  fSum2Energy(0),
+  fTrRmax(1.e10),
+  fTrZmax(1.e10),
+  fImedia(new TArrayI(1000)),
+  fTransParName("\0"),
+  fMCQA(0),
+  fHitLists(new TList()),
+  fTrackReferences(new TClonesArray("AliTrackReference", 100))
+{
+
+  // Set transport parameters
+  SetTransPar();
+
+  // Prepare the tracking medium lists
+  for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99;
+
+}
+
+//_______________________________________________________________________
+AliMC::AliMC(const AliMC &mc) :
+  TVirtualMCApplication(mc),
+  fGenerator(0),
+  fEventEnergy(0),
+  fSummEnergy(0),
+  fSum2Energy(0),
+  fTrRmax(1.e10),
+  fTrZmax(1.e10),
+  fImedia(0),
+  fTransParName("\0"),
+  fMCQA(0),
+  fHitLists(0),
+  fTrackReferences(0)
+{
+  //
+  // Copy constructor for AliRun
+  //
+  mc.Copy(*this);
+}
+
+//_______________________________________________________________________
+AliMC::~AliMC()
+{
+  delete fGenerator;
+  delete fImedia;
+  delete fMCQA;
+  delete fHitLists;
+  // Delete track references
+  if (fTrackReferences) {
+    fTrackReferences->Delete();
+    delete fTrackReferences;
+    fTrackReferences     = 0;
+  }
+
+}
+
+//_______________________________________________________________________
+void AliMC::Copy(AliMC &) const
+{
+  Fatal("Copy","Not implemented!\n");
+}
+
+//_______________________________________________________________________
+void  AliMC::ConstructGeometry() 
+{
+  //
+  // Create modules, materials, geometry
+  //
+
+    TStopwatch stw;
+    TIter next(gAlice->Modules());
+    AliModule *detector;
+    if (GetDebug()) Info("ConstructGeometry","Geometry creation:");
+    while((detector = dynamic_cast<AliModule*>(next()))) {
+      stw.Start();
+      // Initialise detector materials and geometry
+      detector->CreateMaterials();
+      detector->CreateGeometry();
+      printf("%10s R:%.2fs C:%.2fs\n",
+             detector->GetName(),stw.RealTime(),stw.CpuTime());
+    }
+}
+
+//_______________________________________________________________________
+void  AliMC::InitGeometry()
+{ 
+  //
+  // Initialize detectors and display geometry
+  //
+
+   printf("Initialisation:\n");
+    TStopwatch stw;
+    TIter next(gAlice->Modules());
+    AliModule *detector;
+    while((detector = dynamic_cast<AliModule*>(next()))) {
+      stw.Start();
+      // Initialise detector and display geometry
+      detector->Init();
+      detector->BuildGeometry();
+      printf("%10s R:%.2fs C:%.2fs\n",
+            detector->GetName(),stw.RealTime(),stw.CpuTime());
+    }
+}
+
+//_______________________________________________________________________
+void  AliMC::GeneratePrimaries()
+{ 
+  //
+  // Generate primary particles and fill them in the stack.
+  //
+
+  Generator()->Generate();
+}
+
+//_______________________________________________________________________
+void AliMC::SetGenerator(AliGenerator *generator)
+{
+  //
+  // Load the event generator
+  //
+  if(!fGenerator) fGenerator = generator;
+}
+
+//_______________________________________________________________________
+void AliMC::ResetGenerator(AliGenerator *generator)
+{
+  //
+  // Load the event generator
+  //
+  if(fGenerator)
+    if(generator)
+      Warning("ResetGenerator","Replacing generator %s with %s\n",
+             fGenerator->GetName(),generator->GetName());
+    else
+      Warning("ResetGenerator","Replacing generator %s with NULL\n",
+             fGenerator->GetName());
+  fGenerator = generator;
+}
+
+//_______________________________________________________________________
+void AliMC::FinishRun()
+{
+  // Clean generator information
+  if (GetDebug()) Info("FinishRun"," fGenerator->FinishRun()");
+  fGenerator->FinishRun();
+
+  //Output energy summary tables
+  if (GetDebug()) Info("FinishRun"," EnergySummary()");
+  EnergySummary();
+
+}
+
+//_______________________________________________________________________
+void AliMC::BeginPrimary()
+{
+  //
+  // Called  at the beginning of each primary track
+  //
+  
+  // Reset Hits info
+  ResetHits();
+  ResetTrackReferences();
+
+}
+
+//_______________________________________________________________________
+void AliMC::PreTrack()
+{
+     TObjArray &dets = *gAlice->Modules();
+     AliModule *module;
+
+     for(Int_t i=0; i<=gAlice->GetNdets(); i++)
+       if((module = dynamic_cast<AliModule*>(dets[i])))
+        module->PreTrack();
+
+     fMCQA->PreTrack();
+}
+
+//_______________________________________________________________________
+void AliMC::Stepping() 
+{
+  //
+  // Called at every step during transport
+  //
+
+  Int_t id = DetFromMate(gMC->GetMedium());
+  if (id < 0) return;
+
+  //
+  // --- If lego option, do it and leave 
+  if (gAlice->Lego())
+    gAlice->Lego()->StepManager();
+  else {
+    Int_t copy;
+    //Update energy deposition tables
+    AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
+  
+    //Call the appropriate stepping routine;
+    AliModule *det = dynamic_cast<AliModule*>(gAlice->Modules()->At(id));
+    if(det && det->StepManagerIsEnabled()) {
+      fMCQA->StepManager(id);
+      det->StepManager();
+    }
+  }
+}
+
+//_______________________________________________________________________
+void AliMC::EnergySummary()
+{
+  //
+  // Print summary of deposited energy
+  //
+
+  Int_t ndep=0;
+  Float_t edtot=0;
+  Float_t ed, ed2;
+  Int_t kn, i, left, j, id;
+  const Float_t kzero=0;
+  Int_t ievent=gAlice->GetRunLoader()->GetHeader()->GetEvent()+1;
+  //
+  // Energy loss information
+  if(ievent) {
+    printf("***************** Energy Loss Information per event (GEV) *****************\n");
+    for(kn=1;kn<fEventEnergy.GetSize();kn++) {
+      ed=fSummEnergy[kn];
+      if(ed>0) {
+       fEventEnergy[ndep]=kn;
+       if(ievent>1) {
+         ed=ed/ievent;
+         ed2=fSum2Energy[kn];
+         ed2=ed2/ievent;
+         ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
+       } else 
+         ed2=99;
+       fSummEnergy[ndep]=ed;
+       fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero));
+       edtot+=ed;
+       ndep++;
+      }
+    }
+    for(kn=0;kn<(ndep-1)/3+1;kn++) {
+      left=ndep-kn*3;
+      for(i=0;i<(3<left?3:left);i++) {
+       j=kn*3+i;
+        id=Int_t (fEventEnergy[j]+0.1);
+       printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
+      }
+      printf("\n");
+    }
+    //
+    // Relative energy loss in different detectors
+    printf("******************** Relative Energy Loss per event ********************\n");
+    printf("Total energy loss per event %10.3f GeV\n",edtot);
+    for(kn=0;kn<(ndep-1)/5+1;kn++) {
+      left=ndep-kn*5;
+      for(i=0;i<(5<left?5:left);i++) {
+       j=kn*5+i;
+        id=Int_t (fEventEnergy[j]+0.1);
+       printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
+      }
+      printf("\n");
+    }
+    for(kn=0;kn<75;kn++) printf("*"); 
+    printf("\n");
+  }
+  //
+  // Reset the TArray's
+  //  fEventEnergy.Set(0);
+  //  fSummEnergy.Set(0);
+  //  fSum2Energy.Set(0);
+}
+
+//_____________________________________________________________________________
+void AliMC::BeginEvent()
+{
+  //
+  // Clean-up previous event
+  // Energy scores
+  if (GetDebug()) 
+   {
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+     Info("BeginEvent","          BEGINNING EVENT               ");
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+   }
+    
+    AliRunLoader *runloader=gAlice->GetRunLoader();
+
+  /*******************************/    
+  /*   Clean after eventual      */
+  /*   previous event            */
+  /*******************************/    
+
+  
+  //Set the next event in Run Loader -> Cleans trees (TreeK and all trees in detectors),
+  gAlice->SetEventNrInRun(gAlice->GetEventNrInRun()+1);
+  runloader->SetEventNumber(gAlice->GetEventNrInRun());// sets new files, cleans the previous event stuff, if necessary, etc.,  
+  if (GetDebug()) Info("BeginEvent","EventNr is %d",gAlice->GetEventNrInRun());
+     
+  fEventEnergy.Reset();  
+    // Clean detector information
+  
+  if (runloader->Stack())
+    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 (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 
+                                     //stack pointer is not going to change from event to event
+                        //since it bellobgs to header and is obtained via RunLoader
+  //
+  //  Reset all Detectors & kinematics & make/reset trees
+  //
+    
+  runloader->GetHeader()->Reset(gAlice->GetRunNumber(),gAlice->GetEvNumber(),
+    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 (GetDebug()) Info("BeginEvent","  ResetHits()");
+  ResetHits();
+  if (GetDebug()) Info("BeginEvent","  fRunLoader->MakeTree(H)");
+  runloader->MakeTree("H");
+
+  //
+  if(gAlice->Lego()) 
+   {
+    gAlice->Lego()->BeginEvent();
+    return;
+   }
+
+  //create new branches and SetAdresses
+  TIter next(gAlice->Modules());
+  AliModule *detector;
+  while((detector = (AliModule*)next()))
+   {
+    if (GetDebug()) Info("BeginEvent","  %s->MakeBranch(H)",detector->GetName());
+    detector->MakeBranch("H"); 
+    if (GetDebug()) Info("BeginEvent","  %s->MakeBranchTR()",detector->GetName());
+    detector->MakeBranchTR();
+    if (GetDebug()) Info("BeginEvent","  %s->SetTreeAddress()",detector->GetName());
+    detector->SetTreeAddress();
+   }
+}
+
+//_______________________________________________________________________
+void AliMC::ResetHits()
+{
+  //
+  //  Reset all Detectors hits
+  //
+  TIter next(gAlice->Modules());
+  AliModule *detector;
+  while((detector = dynamic_cast<AliModule*>(next()))) {
+     detector->ResetHits();
+  }
+}
+
+//_______________________________________________________________________
+void AliMC::PostTrack()
+{
+     TObjArray &dets = *gAlice->Modules();
+     AliModule *module;
+
+     for(Int_t i=0; i<=gAlice->GetNdets(); i++)
+       if((module = dynamic_cast<AliModule*>(dets[i])))
+        module->PostTrack();
+}
+
+//_______________________________________________________________________
+void AliMC::FinishPrimary()
+{
+  //
+  // Called  at the end of each primary track
+  //
+  AliRunLoader *runloader=gAlice->GetRunLoader();
+  //  static Int_t count=0;
+  //  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();
+  }
+
+  // Write out track references if any
+  if (runloader->TreeTR()) runloader->TreeTR()->Fill();
+}
+
+//_______________________________________________________________________
+void AliMC::FinishEvent()
+{
+  //
+  // Called at the end of the event.
+  //
+  
+  //
+  if(gAlice->Lego()) gAlice->Lego()->FinishEvent();
+
+  TIter next(gAlice->Modules());
+  AliModule *detector;
+  while((detector = dynamic_cast<AliModule*>(next()))) {
+    detector->FinishEvent();
+  }
+
+  //Update the energy deposit tables
+  Int_t i;
+  for(i=0;i<fEventEnergy.GetSize();i++) 
+   {
+    fSummEnergy[i]+=fEventEnergy[i];
+    fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
+   }
+
+  AliRunLoader *runloader=gAlice->GetRunLoader();
+
+  AliHeader* header = runloader->GetHeader();
+  AliStack* stack = runloader->Stack();
+  if ( (header == 0x0) || (stack == 0x0) )
+   {//check if we got header and stack. If not cry and exit aliroot
+    Fatal("AliRun","Can not get the stack or header from LOADER");
+    return;//never reached
+   }  
+  // Update Header information 
+  header->SetNprimary(stack->GetNprimary());
+  header->SetNtrack(stack->GetNtrack());  
+
+  
+  // Write out the kinematics
+  stack->FinishEvent();
+   
+  // Write out the event Header information
+  TTree* treeE = runloader->TreeE();
+  if (treeE) 
+   {
+      header->SetStack(stack);
+      treeE->Fill();
+   }
+  else
+   {
+    Error("FinishEvent","Can not get TreeE from RL");
+   }
+  
+  runloader->WriteKinematics("OVERWRITE");
+  runloader->WriteTrackRefs("OVERWRITE");
+  runloader->WriteHits("OVERWRITE");
+
+  if (GetDebug()) 
+   { 
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+     Info("FinishEvent","          FINISHING EVENT               ");
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+   }
+}
+
+//_______________________________________________________________________
+void AliMC::Field(const Double_t* x, Double_t* b) const
+{
+    gAlice->Field(x,b);
+}
+    
+//_______________________________________________________________________
+void AliMC::Init()
+{
+
+   //=================Create Materials and geometry
+   gMC->Init();
+   gMC->DefineParticles();  //Create standard MC particles
+
+   //Read the cuts for all materials
+   ReadTransPar();
+   //Build the special IMEDIA table
+   MediaTable();
+
+   //Compute cross-sections
+   gMC->BuildPhysics();
+   
+   //Write Geometry object to current file.
+   gAlice->GetRunLoader()->WriteGeometry();
+
+   //Initialise geometry deposition table
+   fEventEnergy.Set(gMC->NofVolumes()+1);
+   fSummEnergy.Set(gMC->NofVolumes()+1);
+   fSum2Energy.Set(gMC->NofVolumes()+1);
+
+   //
+   fMCQA = new AliMCQA(gAlice->GetNdets());
+
+   // Register MC in configuration 
+   AliConfig::Instance()->Add(gMC);
+
+}
+
+//_______________________________________________________________________
+void AliMC::MediaTable()
+{
+  //
+  // Built media table to get from the media number to
+  // the detector id
+  //
+
+  Int_t kz, nz, idt, lz, i, k, ind;
+  //  Int_t ibeg;
+  TObjArray &dets = *gAlice->Detectors();
+  AliModule *det;
+  Int_t ndets=gAlice->GetNdets();
+  //
+  // For all detectors
+  for (kz=0;kz<ndets;kz++) {
+    // If detector is defined
+    if((det=dynamic_cast<AliModule*>(dets[kz]))) {
+        TArrayI &idtmed = *(det->GetIdtmed()); 
+        for(nz=0;nz<100;nz++) {
+       // Find max and min material number
+       if((idt=idtmed[nz])) {
+         det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
+         det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
+       }
+      }
+      if(det->LoMedium() > det->HiMedium()) {
+       det->LoMedium() = 0;
+       det->HiMedium() = 0;
+      } else {
+       if(det->HiMedium() > fImedia->GetSize()) {
+         Error("MediaTable","Increase fImedia from %d to %d",
+               fImedia->GetSize(),det->HiMedium());
+         return;
+       }
+       // Tag all materials in rage as belonging to detector kz
+       for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
+         (*fImedia)[lz]=kz;
+       }
+      }
+    }
+  }
+  //
+  // Print summary table
+  printf(" Traking media ranges:\n");
+  for(i=0;i<(ndets-1)/6+1;i++) {
+    for(k=0;k< (6<ndets-i*6?6:ndets-i*6);k++) {
+      ind=i*6+k;
+      det=dynamic_cast<AliModule*>(dets[ind]);
+      if(det)
+       printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
+              det->HiMedium());
+      else
+       printf(" %6s: %3d -> %3d;","NULL",0,0);
+    }
+    printf("\n");
+  }
+}
+
+//_______________________________________________________________________
+void AliMC::ReadTransPar()
+{
+  //
+  // Read filename to set the transport parameters
+  //
+
+
+  const Int_t kncuts=10;
+  const Int_t knflags=11;
+  const Int_t knpars=kncuts+knflags;
+  const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
+                              "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
+                              "BREM","COMP","DCAY","DRAY","HADR","LOSS",
+                              "MULS","PAIR","PHOT","RAYL"};
+  char line[256];
+  char detName[7];
+  char* filtmp;
+  Float_t cut[kncuts];
+  Int_t flag[knflags];
+  Int_t i, itmed, iret, ktmed, kz;
+  FILE *lun;
+  //
+  // See whether the file is there
+  filtmp=gSystem->ExpandPathName(fTransParName.Data());
+  lun=fopen(filtmp,"r");
+  delete [] filtmp;
+  if(!lun) {
+    Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
+    return;
+  }
+  //
+  if(fDebug) {
+    printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
+    printf(" *%59s\n","*");
+    printf(" *       Please check carefully what you are doing!%10s\n","*");
+    printf(" *%59s\n","*");
+  }
+  //
+  while(1) {
+    // Initialise cuts and flags
+    for(i=0;i<kncuts;i++) cut[i]=-99;
+    for(i=0;i<knflags;i++) flag[i]=-99;
+    itmed=0;
+    for(i=0;i<256;i++) line[i]='\0';
+    // Read up to the end of line excluded
+    iret=fscanf(lun,"%[^\n]",line);
+    if(iret<0) {
+      //End of file
+      fclose(lun);
+      if(fDebug){
+       printf(" *%59s\n","*");
+       printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
+      }
+      return;
+    }
+    // Read the end of line
+    fscanf(lun,"%*c");
+    if(!iret) continue;
+    if(line[0]=='*') continue;
+    // Read the numbers
+    iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d",
+               detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
+               &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
+               &flag[8],&flag[9],&flag[10]);
+    if(!iret) continue;
+    if(iret<0) {
+      //reading error
+      Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
+      continue;
+    }
+    // Check that the module exist
+    AliModule *mod = gAlice->GetModule(detName);
+    if(mod) {
+      // Get the array of media numbers
+      TArrayI &idtmed = *mod->GetIdtmed();
+      // Check that the tracking medium code is valid
+      if(0<=itmed && itmed < 100) {
+       ktmed=idtmed[itmed];
+       if(!ktmed) {
+         Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
+         continue;
+       }
+       // Set energy thresholds
+       for(kz=0;kz<kncuts;kz++) {
+         if(cut[kz]>=0) {
+           if(fDebug) printf(" *  %-6s set to %10.3E for tracking medium code %4d for %s\n",
+                  kpars[kz],cut[kz],itmed,mod->GetName());
+           gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
+         }
+       }
+       // Set transport mechanisms
+       for(kz=0;kz<knflags;kz++) {
+         if(flag[kz]>=0) {
+           if(fDebug) printf(" *  %-6s set to %10d for tracking medium code %4d for %s\n",
+                  kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
+           gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
+         }
+       }
+      } else {
+       Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
+       continue;
+      }
+    } else {
+      if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
+      continue;
+    }
+  }
+}
+
+//_______________________________________________________________________
+void AliMC::SetTransPar(const char *filename)
+{
+  //
+  // Sets the file name for transport parameters
+  //
+  fTransParName = filename;
+}
+
+//_______________________________________________________________________
+void AliMC::Browse(TBrowser *b)
+{
+  //
+  // Called when the item "Run" is clicked on the left pane
+  // of the Root browser.
+  // It displays the Root Trees and all detectors.
+  //
+  //detectors are in folders anyway
+  b->Add(fMCQA,"AliMCQA");
+}
+
+//PH
+//_______________________________________________________________________
+void AliMC::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
+{
+  //
+  //  Add a hit to detector id
+  //
+  TObjArray &dets = *gAlice->Modules();
+  if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
+}
+
+//_______________________________________________________________________
+void AliMC::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
+{
+  //
+  // Add digit to detector id
+  //
+  TObjArray &dets = *gAlice->Modules();
+  if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
+}
+
+//_______________________________________________________________________
+Int_t AliMC::GetCurrentTrackNumber() const {
+  //
+  // Returns current track
+  //
+  return gAlice->GetRunLoader()->Stack()->GetCurrentTrackNumber();
+}
+
+//_______________________________________________________________________
+void AliMC::DumpPart (Int_t i) const
+{
+  //
+  // Dumps particle i in the stack
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+   if (runloader->Stack())
+    runloader->Stack()->DumpPart(i);
+}
+
+//_______________________________________________________________________
+void AliMC::DumpPStack () const
+{
+  //
+  // Dumps the particle stack
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+   if (runloader->Stack())
+    runloader->Stack()->DumpPStack();
+}
+
+//_______________________________________________________________________
+Int_t AliMC::GetNtrack() const {
+  //
+  // Returns number of tracks in stack
+  //
+  Int_t ntracks = -1;
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+   if (runloader->Stack())
+     ntracks = runloader->Stack()->GetNtrack();
+   return ntracks;
+}
+
+//_______________________________________________________________________
+Int_t AliMC::GetPrimary(Int_t track) const
+{
+  //
+  // return number of primary that has generated track
+  //
+  Int_t nprimary = -999;
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader->Stack())
+    nprimary = runloader->Stack()->GetPrimary(track);
+  return nprimary;
+}
+//_______________________________________________________________________
+TParticle* AliMC::Particle(Int_t i) const
+{
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+   if (runloader->Stack())
+    return runloader->Stack()->Particle(i);
+  return 0x0;   
+}
+
+//_______________________________________________________________________
+TObjArray* AliMC::Particles() const {
+  //
+  // Returns pointer to Particles array
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+   if (runloader->Stack())
+    return runloader->Stack()->Particles();
+  return 0x0;
+}
+
+//_______________________________________________________________________
+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)
+{ 
+// Delegate to stack
+//
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
+                                   mech, ntr, weight, is);
+}
+
+//_______________________________________________________________________
+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)
+{ 
+  // Delegate to stack
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+                                   polx, poly, polz, mech, ntr, weight, is);
+}
+
+//_______________________________________________________________________
+void AliMC::SetHighWaterMark(const Int_t nt)
+{
+    //
+    // Set high water mark for last track in event
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->SetHighWaterMark(nt);
+}
+
+//_______________________________________________________________________
+void AliMC::KeepTrack(const Int_t track)
+{ 
+  //
+  // Delegate to stack
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->KeepTrack(track);
+}
+//_______________________________________________________________________
+void AliMC::FlagTrack(Int_t track)
+{
+  // Delegate to stack
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->FlagTrack(track);
+}
+
+//_______________________________________________________________________
+void AliMC::SetCurrentTrack(Int_t track)
+{ 
+  //
+  // Set current track number
+  //
+  AliRunLoader * runloader = gAlice->GetRunLoader();
+  if (runloader)
+    if (runloader->Stack())
+      runloader->Stack()->SetCurrentTrack(track); 
+}
+
+//_______________________________________________________________________
+void  AliMC::AddTrackReference(Int_t label){
+  //
+  // add a trackrefernce to the list
+  if (!fTrackReferences) {
+    cerr<<"Container trackrefernce not active\n";
+    return;
+  }
+  Int_t nref = fTrackReferences->GetEntriesFast();
+  TClonesArray &lref = *fTrackReferences;
+  new(lref[nref]) AliTrackReference(label);
+}
+
+
+
+//_______________________________________________________________________
+void AliMC::ResetTrackReferences()
+{
+  //
+  //  Reset all  references
+  //
+  if (fTrackReferences)   fTrackReferences->Clear();
+
+  TIter next(gAlice->Modules());
+  AliModule *detector;
+  while((detector = dynamic_cast<AliModule*>(next()))) {
+     detector->ResetTrackReferences();
+  }
+}
+
+void AliMC::RemapTrackReferencesIDs(Int_t *map)
+{
+  // 
+  // Remapping track reference
+  // Called at finish primary
+  //
+  if (!fTrackReferences) return;
+  for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
+    AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
+    if (ref) {
+      Int_t newID = map[ref->GetTrack()];
+      if (newID>=0) ref->SetTrack(newID);
+      else {
+        //ref->SetTrack(-1);
+        ref->SetBit(kNotDeleted,kFALSE);
+        fTrackReferences->RemoveAt(i);  
+      }      
+    }
+  }
+  fTrackReferences->Compress();
+}
diff --git a/STEER/AliMC.h b/STEER/AliMC.h
new file mode 100644 (file)
index 0000000..9281814
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef ALIMC_H
+#define ALIMC_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#include <TArrayF.h>
+#include <TArrayI.h>
+#include <TVirtualMCApplication.h>
+
+class AliGenerator;
+class AliMCQA;
+
+class AliMC : public TVirtualMCApplication {
+public:
+    AliMC();
+    AliMC(const char *name, const char *title);
+    AliMC(const AliMC &mc);
+    virtual ~AliMC();
+    
+    AliMC operator = (const AliMC &mc) 
+        {mc.Copy(*this); return *this;}
+
+//
+//  MC Application
+//
+   virtual  void  ConstructGeometry();
+   virtual  void  InitGeometry();     
+   virtual  void  GeneratePrimaries();
+   virtual  void  BeginEvent();
+   virtual  void  BeginPrimary();
+   virtual  void  PreTrack();
+   virtual  void  Stepping();         
+   virtual  void  PostTrack();
+   virtual  void  FinishPrimary();
+   virtual  void  FinishEvent();
+   virtual  Double_t  TrackingZmax() const {return fTrZmax;}
+   virtual  Double_t  TrackingRmax() const {return fTrRmax;}
+   virtual  void Field(const Double_t* x, Double_t* b) const;
+   virtual  Int_t   DetFromMate(Int_t i) const { return (*fImedia)[i];}
+//
+
+   virtual  AliGenerator* Generator() const {return fGenerator;}
+   virtual  void SetGenerator(AliGenerator *generator);
+   virtual  void ResetGenerator(AliGenerator *generator);
+
+//
+   virtual  void ReadTransPar();
+   virtual  void MediaTable();
+   virtual  void EnergySummary();
+   virtual  void FinishRun();
+   void          AddEnergyDeposit(Int_t id, Float_t edep) 
+                                       {fEventEnergy[id]+=edep;}
+   virtual  void  ResetHits();
+   virtual  void  TrackingLimits( Float_t rmax=1.e10, Float_t zmax=1.e10)
+    {fTrRmax=rmax; fTrZmax=zmax;}
+   Int_t          GetDebug() const {return fDebug;}
+   virtual  void  SetDebug(const Int_t level=0) {fDebug = level;}
+   virtual  void  Init();
+   virtual  void  SetTransPar(const char *filename="$(ALICE_ROOT)/data/galice.cuts");
+   virtual  void  Browse(TBrowser *b);
+   AliMCQA       *GetMCQA() const {return fMCQA;}
+   //PH
+   virtual  void  AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const;
+   virtual  void  AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const;
+   virtual  void  AddHitList(TCollection *hitList) {fHitLists->Add(hitList);}
+   Int_t          GetCurrentTrackNumber() const;
+   virtual  void  DumpPart (Int_t i) const;
+   virtual  void  DumpPStack () const;
+   TList*         GetHitLists() const {return fHitLists ;}
+   Int_t          GetNtrack() const;
+   virtual  Int_t GetPrimary(Int_t track) const;
+   TObjArray     *Particles() const;
+   TParticle     *Particle(Int_t i) const;
+   virtual  void  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 = 1, Int_t is = 0);
+   virtual  void  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=1,
+                          Int_t is = 0);
+   virtual  void  SetHighWaterMark(const Int_t nt);
+   
+   virtual  void  KeepTrack(const Int_t itra);
+   virtual  void  FlagTrack(Int_t track);
+   virtual  void  SetCurrentTrack(Int_t track);                           
+// Track reference related 
+   virtual void   AddTrackReference(Int_t label);
+   TClonesArray   *TrackReferences()   const {return fTrackReferences;}
+   virtual void   RemapTrackReferencesIDs(Int_t *map); //remaping track references MI
+   virtual void   ResetTrackReferences();
+   
+
+
+private:
+   void Copy (AliMC &mc) const;
+   AliGenerator  *fGenerator;         //  Generator used in the MC
+   TArrayF        fEventEnergy;       //! Energy deposit for current event
+   TArrayF        fSummEnergy;        //! Energy per event in each volume
+   TArrayF        fSum2Energy;        //! Energy squared per event in each volume
+   Float_t        fTrRmax;            //  Maximum radius for tracking
+   Float_t        fTrZmax;            //  Maximu z for tracking
+   Int_t          fDebug;             //  Debug flag
+   TArrayI       *fImedia;            //! Array of correspondence between media and detectors
+   TString        fTransParName;      //  Name of the transport parameters file
+   AliMCQA       *fMCQA;              //  Pointer to MC Quality assurance class
+   //PH
+   TList         *fHitLists;          //! Lists of hits to be remapped by PurifyKine
+  TClonesArray *fTrackReferences;     //!list of track references - for one primary track only -MI
+    
+    ClassDef(AliMC,1)
+};
+
+#endif
index 79886ab..68789c7 100644 (file)
 #include <TPad.h>
 #include <TPaveLabel.h>
 #include <TROOT.h>
+#include <TVirtualMC.h>
 
 #include "AliMCQA.h"
 #include "AliModule.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliMCQA)
 
@@ -147,9 +149,10 @@ AliMCQA::AliMCQA(Int_t ndets):
   //
   // Build list of volume names
   //
+  AliMC * mc = gAlice->GetMCApp();
   for(i=0;i<fNvolumes;++i) {
     AliModule *mod = dynamic_cast<AliModule*>
-      ((*gAlice->Modules())[gAlice->DetFromMate(gMC->VolId2Mate(i+1))]);
+      ((*gAlice->Modules())[mc->DetFromMate(gMC->VolId2Mate(i+1))]);
     (*fVolNames)[i]=new TNamed(gMC->VolName(i+1),mod->GetName());
   }
 
index 3e90897..edd106e 100644 (file)
@@ -39,6 +39,7 @@
 #include <TTree.h>
 #include <TSystem.h>
 #include <TDirectory.h>
+#include <TVirtualMC.h>
 
 #include "AliConfig.h"
 #include "AliLoader.h"
@@ -46,6 +47,7 @@
 #include "AliModule.h"
 #include "AliRun.h"
 #include "AliTrackReference.h"
+#include "AliMC.h"
 
 ClassImp(AliModule)
  
@@ -699,7 +701,7 @@ AliTrackReference* AliModule::FirstTrackReference(Int_t track)
    {
      AliRunLoader* rl = AliRunLoader::GetRunLoader();
 
-     rl->GetAliRun()->ResetTrackReferences();
+     rl->GetAliRun()->GetMCApp()->ResetTrackReferences();
      rl->TreeTR()->GetEvent(track);
      if (rl == 0x0)
        Fatal("FirstTrackReference","AliRunLoader not initialized. Can not proceed");
index 4212493..358986f 100644 (file)
@@ -35,6 +35,7 @@
 #include "AliDetector.h"
 #include "AliPoints.h"
 #include "AliRun.h"
+#include "AliMC.h"
  
 ClassImp(AliPoints)
 
@@ -174,8 +175,8 @@ TParticle *AliPoints::GetParticle() const
   //
   //   Returns pointer to particle index in AliRun::fParticles
   //
-  if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
-  else return gAlice->Particle(fIndex);
+  if (fIndex < 0 || fIndex >= gAlice->GetMCApp()->GetNtrack()) return 0;
+  else return gAlice->GetMCApp()->Particle(fIndex);
 }
 
 //_______________________________________________________________________
@@ -200,7 +201,7 @@ void AliPoints::Propagate()
   //  
   TIter next(gAlice->Detectors());
   AliDetector *detector;
-  while((detector = dynamic_cast<AliDetector*>(next()))) {
+  while((detector = (AliDetector*)(next()))) {
     if (!detector->IsActive()) continue;
     points = detector->Points();
     if (!points) continue;
index 053126f..fe45e36 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <Riostream.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <TBRIK.h> 
-#include <TBrowser.h>
 #include <TCint.h> 
-#include <TFile.h>
-#include <TFolder.h>
+#include <TDatabasePDG.h>
 #include <TGeometry.h>
-#include <TKey.h>
 #include <TNode.h>
-#include <TObjectTable.h>
-#include <TParticle.h>
 #include <TROOT.h>
-#include <TRandom.h>
 #include <TRandom3.h>
 #include <TSystem.h>
-#include <TTree.h>
+#include <TVector.h>
 #include <TVirtualMC.h>
-
-#include "AliConfig.h"
+// 
 #include "AliDetector.h"
 #include "AliDisplay.h"
-#include "AliGenEventHeader.h"
-#include "AliGenerator.h"
 #include "AliHeader.h"
-#include "AliHit.h"
 #include "AliLego.h"
 #include "AliLegoGenerator.h"
-#include "AliLoader.h"
-#include "AliMCQA.h"
+#include "AliMC.h"
 #include "AliMagFC.h"
 #include "AliMagFCM.h"
 #include "AliMagFDM.h"
 #include "AliPDG.h"
 #include "AliRun.h"
-#include "AliRunLoader.h"
 #include "AliStack.h"
-#include "AliTrackReference.h"
 
 AliRun *gAlice;
 
+
 ClassImp(AliRun)
 
 //_______________________________________________________________________
@@ -95,28 +78,18 @@ AliRun::AliRun():
   fDebug(0),
   fModules(0),
   fGeometry(0),
+  fMCApp(0),
   fDisplay(0),
   fTimer(),
   fField(0),
   fMC(0),
-  fImedia(0),
   fNdets(0),
-  fTrRmax(1.e10),
-  fTrZmax(1.e10),
-  fGenerator(0),
   fInitDone(kFALSE),
   fLego(0),
   fPDGDB(0),  //Particle factory object
-  fHitLists(0),
-  fEventEnergy(0),
-  fSummEnergy(0),
-  fSum2Energy(0),
   fConfigFunction("\0"),
   fRandom(0),
-  fMCQA(0),
-  fTransParName("\0"),
-  fRunLoader(0x0),
-  fTrackReferences(0)
+  fRunLoader(0x0)
 {
   //
   // Default constructor for AliRun
@@ -127,7 +100,7 @@ AliRun::AliRun():
 
 //_______________________________________________________________________
 AliRun::AliRun(const AliRun& arun):
-  TVirtualMCApplication(arun),
+  TNamed(arun),
   fRun(0),
   fEvent(0),
   fEventNrInRun(0),
@@ -135,27 +108,17 @@ AliRun::AliRun(const AliRun& arun):
   fDebug(0),
   fModules(0),
   fGeometry(0),
+  fMCApp(0),
   fDisplay(0),
   fTimer(),
   fField(0),
   fMC(0),
-  fImedia(0),
   fNdets(0),
-  fTrRmax(1.e10),
-  fTrZmax(1.e10),
-  fGenerator(0),
   fInitDone(kFALSE),
   fLego(0),
   fPDGDB(0),  //Particle factory object
-  fHitLists(0),
-  fEventEnergy(0),
-  fSummEnergy(0),
-  fSum2Energy(0),
   fConfigFunction("\0"),
   fRandom(0),
-  fMCQA(0),
-  fTransParName("\0"), 
-  fTrackReferences(new TClonesArray("AliTrackReference", 100)),
   fRunLoader(0x0)
 {
   //
@@ -166,7 +129,7 @@ AliRun::AliRun(const AliRun& arun):
 
 //_____________________________________________________________________________
 AliRun::AliRun(const char *name, const char *title):
-  TVirtualMCApplication(name,title),
+  TNamed(name,title),
   fRun(0),
   fEvent(0),
   fEventNrInRun(0),
@@ -174,26 +137,17 @@ AliRun::AliRun(const char *name, const char *title):
   fDebug(0),
   fModules(new TObjArray(77)), // Support list for the Detectors
   fGeometry(0),
+  fMCApp(0),
   fDisplay(0),
   fTimer(),
   fField(0),
   fMC(gMC),
-  fImedia(new TArrayI(1000)),
   fNdets(0),
-  fTrRmax(1.e10),
-  fTrZmax(1.e10),
-  fGenerator(0),
   fInitDone(kFALSE),
   fLego(0),
   fPDGDB(TDatabasePDG::Instance()),        //Particle factory object!
-  fHitLists(new TList()),                  // Create HitLists list
-  fEventEnergy(0),
-  fSummEnergy(0),
-  fSum2Energy(0),
   fConfigFunction("Config();"),
   fRandom(new TRandom3()),
-  fMCQA(0),
-  fTransParName("\0"),
   fRunLoader(0x0)
 {
   //
@@ -220,14 +174,9 @@ AliRun::AliRun(const char *name, const char *title):
   // Create default mag field
   SetField();
 
-  // Prepare the tracking medium lists
-  for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99;
-
   // Add particle list to configuration
   AliConfig::Instance()->Add(fPDGDB); 
 
-  // Set transport parameters
-  SetTransPar();
 }
 
 
@@ -250,30 +199,20 @@ AliRun::~AliRun()
        modfold->Remove(mod);
      }
    }
-   
-  delete fImedia;
+  
+  
   delete fField;
-  // delete fMC;
+  delete fMCApp;
   delete gMC; gMC=0;
   delete fGeometry;
   delete fDisplay;
-  delete fGenerator;
   delete fLego;
   if (fModules) {
     fModules->Delete();
     delete fModules;
   }
   
-  delete fHitLists;
   delete fPDGDB;
-  delete fMCQA;
-  // Delete track references
-  if (fTrackReferences) {
-    fTrackReferences->Delete();
-    delete fTrackReferences;
-    fTrackReferences     = 0;
-  }
-
 }
 
 //_______________________________________________________________________
@@ -283,38 +222,6 @@ void AliRun::Copy(AliRun &) const
 }
 
 //_______________________________________________________________________
-void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
-{
-  //
-  //  Add a hit to detector id
-  //
-  TObjArray &dets = *fModules;
-  if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
-}
-
-//_______________________________________________________________________
-void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
-{
-  //
-  // Add digit to detector id
-  //
-  TObjArray &dets = *fModules;
-  if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
-}
-
-//_______________________________________________________________________
-void AliRun::Browse(TBrowser *b)
-{
-  //
-  // Called when the item "Run" is clicked on the left pane
-  // of the Root browser.
-  // It displays the Root Trees and all detectors.
-  //
-  //detectors are in folders anyway
-  b->Add(fMCQA,"AliMCQA");
-}
-
-//_______________________________________________________________________
 void AliRun::Build()
 {
   //
@@ -348,33 +255,15 @@ void AliRun::CleanDetectors()
 }
 
 //_______________________________________________________________________
-Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) const
-{
-  //
-  // Return the distance from the mouse to the AliRun object
-  // Dummy routine
-  //
-  return 9999;
-}
-
-//_______________________________________________________________________
-void AliRun::DumpPart (Int_t i) const
+void AliRun::ResetHits() 
 {
-  //
-  // Dumps particle i in the stack
-  //
-   if (fRunLoader->Stack())
-    fRunLoader->Stack()->DumpPart(i);
+  fMCApp->ResetHits();
 }
 
 //_______________________________________________________________________
-void AliRun::DumpPStack () const
+AliGenerator* AliRun::Generator() const 
 {
-  //
-  // Dumps the particle stack
-  //
-   if (fRunLoader->Stack())
-    fRunLoader->Stack()->DumpPStack();
+  return fMCApp->Generator();
 }
 
 //_______________________________________________________________________
@@ -454,10 +343,6 @@ void AliRun::FinishRun()
     detector->FinishRun();
   }
   
-  //Output energy summary tables
-  if (GetDebug()) Info("FinishRun"," EnergySummary()");
-  EnergySummary();
-  
   if (GetDebug()) Info("FinishRun"," fRunLoader->WriteHeader(OVERWRITE)");
   fRunLoader->WriteHeader("OVERWRITE");
 
@@ -470,84 +355,9 @@ void AliRun::FinishRun()
   if (GetDebug()) Info("FinishRun"," fRunLoader->Stack()->FinishRun()");
   fRunLoader->Stack()->FinishRun();
 
-  // Clean detector information
-  if (GetDebug()) Info("FinishRun"," fGenerator->FinishRun()");
-  fGenerator->FinishRun();
-  fRunLoader->Synchronize();
-}
+  if(fMCApp) fMCApp->FinishRun();
 
-//_______________________________________________________________________
-void AliRun::FlagTrack(Int_t track)
-{
-  // Delegate to stack
-  //
-    fRunLoader->Stack()->FlagTrack(track);
-}
-//_______________________________________________________________________
-void AliRun::EnergySummary()
-{
-  //
-  // Print summary of deposited energy
-  //
-
-  Int_t ndep=0;
-  Float_t edtot=0;
-  Float_t ed, ed2;
-  Int_t kn, i, left, j, id;
-  const Float_t kzero=0;
-  Int_t ievent=fRunLoader->GetHeader()->GetEvent()+1;
-  //
-  // Energy loss information
-  if(ievent) {
-    printf("***************** Energy Loss Information per event (GEV) *****************\n");
-    for(kn=1;kn<fEventEnergy.GetSize();kn++) {
-      ed=fSummEnergy[kn];
-      if(ed>0) {
-       fEventEnergy[ndep]=kn;
-       if(ievent>1) {
-         ed=ed/ievent;
-         ed2=fSum2Energy[kn];
-         ed2=ed2/ievent;
-         ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
-       } else 
-         ed2=99;
-       fSummEnergy[ndep]=ed;
-       fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero));
-       edtot+=ed;
-       ndep++;
-      }
-    }
-    for(kn=0;kn<(ndep-1)/3+1;kn++) {
-      left=ndep-kn*3;
-      for(i=0;i<(3<left?3:left);i++) {
-       j=kn*3+i;
-        id=Int_t (fEventEnergy[j]+0.1);
-       printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
-      }
-      printf("\n");
-    }
-    //
-    // Relative energy loss in different detectors
-    printf("******************** Relative Energy Loss per event ********************\n");
-    printf("Total energy loss per event %10.3f GeV\n",edtot);
-    for(kn=0;kn<(ndep-1)/5+1;kn++) {
-      left=ndep-kn*5;
-      for(i=0;i<(5<left?5:left);i++) {
-       j=kn*5+i;
-        id=Int_t (fEventEnergy[j]+0.1);
-       printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
-      }
-      printf("\n");
-    }
-    for(kn=0;kn<75;kn++) printf("*"); 
-    printf("\n");
-  }
-  //
-  // Reset the TArray's
-  //  fEventEnergy.Set(0);
-  //  fSummEnergy.Set(0);
-  //  fSum2Energy.Set(0);
+  fRunLoader->Synchronize();
 }
 
 //_______________________________________________________________________
@@ -617,8 +427,8 @@ Int_t AliRun::GetEvent(Int_t event)
 /****   P R E    R E L O A D I N G    ****/
 /*****************************************/ 
 // Reset existing structures
-  ResetHits();
-  ResetTrackReferences();
+  fMCApp->ResetHits();
+  fMCApp->ResetTrackReferences();
   ResetDigits();
   ResetSDigits();
 
@@ -673,320 +483,12 @@ TGeometry *AliRun::GetGeometry()
 }
 
 //_______________________________________________________________________
-Int_t AliRun::GetPrimary(Int_t track) const
-{
-  //
-  // return number of primary that has generated track
-  //
-    return fRunLoader->Stack()->GetPrimary(track);
-}
-//_______________________________________________________________________
-void AliRun::MediaTable()
-{
-  //
-  // Built media table to get from the media number to
-  // the detector id
-  //
-
-  Int_t kz, nz, idt, lz, i, k, ind;
-  //  Int_t ibeg;
-  TObjArray &dets = *gAlice->Detectors();
-  AliModule *det;
-  //
-  // For all detectors
-  for (kz=0;kz<fNdets;kz++) {
-    // If detector is defined
-    if((det=dynamic_cast<AliModule*>(dets[kz]))) {
-        TArrayI &idtmed = *(det->GetIdtmed()); 
-        for(nz=0;nz<100;nz++) {
-       // Find max and min material number
-       if((idt=idtmed[nz])) {
-         det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
-         det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
-       }
-      }
-      if(det->LoMedium() > det->HiMedium()) {
-       det->LoMedium() = 0;
-       det->HiMedium() = 0;
-      } else {
-       if(det->HiMedium() > fImedia->GetSize()) {
-         Error("MediaTable","Increase fImedia from %d to %d",
-               fImedia->GetSize(),det->HiMedium());
-         return;
-       }
-       // Tag all materials in rage as belonging to detector kz
-       for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
-         (*fImedia)[lz]=kz;
-       }
-      }
-    }
-  }
-  //
-  // Print summary table
-  printf(" Traking media ranges:\n");
-  for(i=0;i<(fNdets-1)/6+1;i++) {
-    for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) {
-      ind=i*6+k;
-      det=dynamic_cast<AliModule*>(dets[ind]);
-      if(det)
-       printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
-              det->HiMedium());
-      else
-       printf(" %6s: %3d -> %3d;","NULL",0,0);
-    }
-    printf("\n");
-  }
-}
-
-//_______________________________________________________________________
-void AliRun::SetGenerator(AliGenerator *generator)
-{
-  //
-  // Load the event generator
-  //
-  if(!fGenerator) fGenerator = generator;
-}
-
-//_______________________________________________________________________
-void AliRun::ResetGenerator(AliGenerator *generator)
-{
-  //
-  // Load the event generator
-  //
-  if(fGenerator)
-    if(generator)
-      Warning("ResetGenerator","Replacing generator %s with %s\n",
-             fGenerator->GetName(),generator->GetName());
-    else
-      Warning("ResetGenerator","Replacing generator %s with NULL\n",
-             fGenerator->GetName());
-  fGenerator = generator;
-}
-
-//_______________________________________________________________________
-void AliRun::SetTransPar(const char *filename)
-{
-  //
-  // Sets the file name for transport parameters
-  //
-  fTransParName = filename;
-}
-
-//_______________________________________________________________________
 void AliRun::SetBaseFile(const char *filename)
 {
   fBaseFileName = filename;
 }
 
 //_______________________________________________________________________
-void AliRun::ReadTransPar()
-{
-  //
-  // Read filename to set the transport parameters
-  //
-
-
-  const Int_t kncuts=10;
-  const Int_t knflags=11;
-  const Int_t knpars=kncuts+knflags;
-  const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
-                              "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
-                              "BREM","COMP","DCAY","DRAY","HADR","LOSS",
-                              "MULS","PAIR","PHOT","RAYL"};
-  char line[256];
-  char detName[7];
-  char* filtmp;
-  Float_t cut[kncuts];
-  Int_t flag[knflags];
-  Int_t i, itmed, iret, ktmed, kz;
-  FILE *lun;
-  //
-  // See whether the file is there
-  filtmp=gSystem->ExpandPathName(fTransParName.Data());
-  lun=fopen(filtmp,"r");
-  delete [] filtmp;
-  if(!lun) {
-    Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
-    return;
-  }
-  //
-  if(fDebug) {
-    printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
-    printf(" *%59s\n","*");
-    printf(" *       Please check carefully what you are doing!%10s\n","*");
-    printf(" *%59s\n","*");
-  }
-  //
-  while(1) {
-    // Initialise cuts and flags
-    for(i=0;i<kncuts;i++) cut[i]=-99;
-    for(i=0;i<knflags;i++) flag[i]=-99;
-    itmed=0;
-    for(i=0;i<256;i++) line[i]='\0';
-    // Read up to the end of line excluded
-    iret=fscanf(lun,"%[^\n]",line);
-    if(iret<0) {
-      //End of file
-      fclose(lun);
-      if(fDebug){
-       printf(" *%59s\n","*");
-       printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
-      }
-      return;
-    }
-    // Read the end of line
-    fscanf(lun,"%*c");
-    if(!iret) continue;
-    if(line[0]=='*') continue;
-    // Read the numbers
-    iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d",
-               detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
-               &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
-               &flag[8],&flag[9],&flag[10]);
-    if(!iret) continue;
-    if(iret<0) {
-      //reading error
-      Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
-      continue;
-    }
-    // Check that the module exist
-    AliModule *mod = GetModule(detName);
-    if(mod) {
-      // Get the array of media numbers
-      TArrayI &idtmed = *mod->GetIdtmed();
-      // Check that the tracking medium code is valid
-      if(0<=itmed && itmed < 100) {
-       ktmed=idtmed[itmed];
-       if(!ktmed) {
-         Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
-         continue;
-       }
-       // Set energy thresholds
-       for(kz=0;kz<kncuts;kz++) {
-         if(cut[kz]>=0) {
-           if(fDebug) printf(" *  %-6s set to %10.3E for tracking medium code %4d for %s\n",
-                  kpars[kz],cut[kz],itmed,mod->GetName());
-           gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
-         }
-       }
-       // Set transport mechanisms
-       for(kz=0;kz<knflags;kz++) {
-         if(flag[kz]>=0) {
-           if(fDebug) printf(" *  %-6s set to %10d for tracking medium code %4d for %s\n",
-                  kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
-           gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
-         }
-       }
-      } else {
-       Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
-       continue;
-      }
-    } else {
-      if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
-      continue;
-    }
-  }
-}
-//_____________________________________________________________________________
-
-void AliRun::BeginEvent()
-{
-  //
-  // Clean-up previous event
-  // Energy scores
-  if (GetDebug()) 
-   {
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-     Info("BeginEvent","          BEGINNING EVENT               ");
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-     Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-   }
-    
-  /*******************************/    
-  /*   Clean after eventual      */
-  /*   previous event            */
-  /*******************************/    
-
-  
-  //Set the next event in Run Loader -> Cleans trees (TreeK and all trees in detectors),
-  fRunLoader->SetEventNumber(++fEventNrInRun);// sets new files, cleans the previous event stuff, if necessary, etc.,  
-  if (GetDebug()) Info("BeginEvent","EventNr is %d",fEventNrInRun);
-     
-  fEventEnergy.Reset();  
-    // Clean detector information
-  
-  if (fRunLoader->Stack())
-    fRunLoader->Stack()->Reset();//clean stack -> tree is unloaded
-  else
-    fRunLoader->MakeStack();//or make a new one
-    
-  if (GetDebug()) Info("BeginEvent","  fRunLoader->MakeTree(K)");
-  fRunLoader->MakeTree("K");
-  if (GetDebug()) Info("BeginEvent","  gMC->SetStack(fRunLoader->Stack())");
-  gMC->SetStack(fRunLoader->Stack());//Was in InitMC - but was moved here 
-                                     //because we don't have guarantee that 
-                                     //stack pointer is not going to change from event to event
-                        //since it bellobgs to header and is obtained via RunLoader
-  //
-  //  Reset all Detectors & kinematics & make/reset trees
-  //
-    
-  fRunLoader->GetHeader()->Reset(fRun,fEvent,fEventNrInRun);
-//  fRunLoader->WriteKinematics("OVERWRITE");  is there any reason to rewrite here since MakeTree does so
-
-  if (GetDebug()) Info("BeginEvent","  fRunLoader->MakeTrackRefsContainer()");
-  fRunLoader->MakeTrackRefsContainer();//for insurance
-
-  if (GetDebug()) Info("BeginEvent","  ResetHits()");
-  ResetHits();
-  if (GetDebug()) Info("BeginEvent","  fRunLoader->MakeTree(H)");
-  fRunLoader->MakeTree("H");
-
-  //
-  if(fLego) 
-   {
-    fLego->BeginEvent();
-    return;
-   }
-
-  //create new branches and SetAdresses
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = (AliModule*)next()))
-   {
-    if (GetDebug()) Info("BeginEvent","  %s->MakeBranch(H)",detector->GetName());
-    detector->MakeBranch("H"); 
-    if (GetDebug()) Info("BeginEvent","  %s->MakeBranchTR()",detector->GetName());
-    detector->MakeBranchTR();
-    if (GetDebug()) Info("BeginEvent","  %s->SetTreeAddress()",detector->GetName());
-    detector->SetTreeAddress();
-   }
-  // make branch for AliRun track References
-  TTree * treeTR = fRunLoader->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);
-  }
-  //
-}
-
-//_______________________________________________________________________
-TParticle* AliRun::Particle(Int_t i) const
-{
-  if (fRunLoader)
-   if (fRunLoader->Stack())
-    return fRunLoader->Stack()->Particle(i);
-  return 0x0;   
-}
-
-//_______________________________________________________________________
 void AliRun::ResetDigits()
 {
   //
@@ -1012,71 +514,6 @@ void AliRun::ResetSDigits()
   }
 }
 
-//_______________________________________________________________________
-void AliRun::ResetHits()
-{
-  //
-  //  Reset all Detectors hits
-  //
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-     detector->ResetHits();
-  }
-}
-//_______________________________________________________________________
-
-void  AliRun::AddTrackReference(Int_t label){
-  //
-  // add a trackrefernce to the list
-  if (!fTrackReferences) {
-    cerr<<"Container trackrefernce not active\n";
-    return;
-  }
-  Int_t nref = fTrackReferences->GetEntriesFast();
-  TClonesArray &lref = *fTrackReferences;
-  new(lref[nref]) AliTrackReference(label);
-}
-
-
-
-void AliRun::ResetTrackReferences()
-{
-  //
-  //  Reset all  references
-  //
-  if (fTrackReferences)   fTrackReferences->Clear();
-
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-     detector->ResetTrackReferences();
-  }
-}
-
-void AliRun::RemapTrackReferencesIDs(Int_t *map)
-{
-  // 
-  // Remapping track reference
-  // Called at finish primary
-  //
-  if (!fTrackReferences) return;
-  for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
-    AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
-    if (ref) {
-      Int_t newID = map[ref->GetTrack()];
-      if (newID>=0) ref->SetTrack(newID);
-      else {
-        //ref->SetTrack(-1);
-        ref->SetBit(kNotDeleted,kFALSE);
-        fTrackReferences->RemoveAt(i);  
-      }      
-    }
-  }
-  fTrackReferences->Compress();
-}
-
-
 
 //_______________________________________________________________________
 
@@ -1096,7 +533,7 @@ void AliRun::ResetPoints()
 void AliRun::InitMC(const char *setup)
 {
   //
-  // Initialize the Alice setup
+  // Initialize ALICE Simulation run
   //
   Announce();
 
@@ -1105,12 +542,11 @@ void AliRun::InitMC(const char *setup)
     return;
   }
     
+  fMCApp=new AliMC(GetName(),GetTitle());
+    
   gROOT->LoadMacro(setup);
   gInterpreter->ProcessLine(fConfigFunction.Data());
 
-  // Register MC in configuration 
-  AliConfig::Instance()->Add(gMC);
-
   InitLoaders();
 
   fRunLoader->MakeTree("E");
@@ -1121,24 +557,20 @@ void AliRun::InitMC(const char *setup)
   
   fRunLoader->CdGAFile();
 
-  gMC->DefineParticles();  //Create standard MC particles
   AliPDG::AddParticlesToPdgDataBase();  
 
-  TObject *objfirst, *objlast;
-
   fNdets = fModules->GetLast()+1;
 
   //
-  //=================Create Materials and geometry
-  gMC->Init();
 
   // Added also after in case of interactive initialisation of modules
   fNdets = fModules->GetLast()+1;
 
   TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) 
+  for(Int_t i=0; i<fNdets; ++i)
    {
+     TObject *objfirst, *objlast;
+     AliModule *detector=dynamic_cast<AliModule*>(fModules->At(i));
      objlast = gDirectory->GetList()->Last();
       
      // Add Detector histograms in Detector list of histograms
@@ -1150,25 +582,11 @@ void AliRun::InitMC(const char *setup)
         objfirst = gDirectory->GetList()->After(objfirst);
       }
    }
-   ReadTransPar(); //Read the cuts for all materials
-   
-   MediaTable(); //Build the special IMEDIA table
-   
-   //Initialise geometry deposition table
-   fEventEnergy.Set(gMC->NofVolumes()+1);
-   fSummEnergy.Set(gMC->NofVolumes()+1);
-   fSum2Energy.Set(gMC->NofVolumes()+1);
    
-   //Compute cross-sections
-   gMC->BuildPhysics();
-   
-   //Write Geometry object to current file.
-   fRunLoader->WriteGeometry();
+   fMCApp->Init();
    
    fInitDone = kTRUE;
 
-   fMCQA = new AliMCQA(fNdets);
-
    //
    // Save stuff at the beginning of the file to avoid file corruption
    Write();
@@ -1350,13 +768,14 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
 
   // check if initialisation has been done
   if (!fInitDone) InitMC(setup);
-  // Save current generator
-  AliGenerator *gen=Generator();
+  //Save current generator
+  AliGenerator *gen=fMCApp->Generator();
   // If runloader has been initialized, set the number of events per file to nc1 * nc2
   if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nc1 * nc2);
+
   // Set new generator
   if (!gener) gener  = new AliLegoGenerator();
-  ResetGenerator(gener);
+  fMCApp->ResetGenerator(gener);
   //
   // Configure Generator
   gener->SetRadiusRange(rmin, rmax);
@@ -1382,7 +801,7 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
   // End of this run, close files
   FinishRun();
   // Restore current generator
-  ResetGenerator(gen);
+  fMCApp->ResetGenerator(gen);
   // Delete Lego Object
   delete fLego; fLego=0;
 }
@@ -1397,281 +816,11 @@ void AliRun::SetConfigFunction(const char * config)
   fConfigFunction=config;
 }
 
-//_______________________________________________________________________
-void AliRun::SetCurrentTrack(Int_t track)
-{ 
-  //
-  // Set current track number
-  //
-    fRunLoader->Stack()->SetCurrentTrack(track); 
-}
-//_______________________________________________________________________
-void AliRun::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)
-{ 
-// Delegate to stack
-//
-    fRunLoader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
-                    mech, ntr, weight, is);
-}
-
-//_______________________________________________________________________
-void AliRun::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)
-{ 
-  // Delegate to stack
-  //
-  fRunLoader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
-                                polx, poly, polz, mech, ntr, weight, is);
-}
-
-//_______________________________________________________________________
-void AliRun::SetHighWaterMark(const Int_t nt)
-{
-    //
-    // Set high water mark for last track in event
-    fRunLoader->Stack()->SetHighWaterMark(nt);
-}
-
-//_______________________________________________________________________
-void AliRun::KeepTrack(const Int_t track)
-{ 
-  //
-  // Delegate to stack
-  //
-    fRunLoader->Stack()->KeepTrack(track);
-}
 // 
 // MC Application
 // 
 
 //_______________________________________________________________________
-void  AliRun::ConstructGeometry() 
-{
-  //
-  // Create modules, materials, geometry
-  //
-
-    TStopwatch stw;
-    TIter next(fModules);
-    AliModule *detector;
-    if (GetDebug()) Info("ConstructGeometry","Geometry creation:");
-    while((detector = dynamic_cast<AliModule*>(next()))) {
-      stw.Start();
-      // Initialise detector materials and geometry
-      detector->CreateMaterials();
-      detector->CreateGeometry();
-      printf("%10s R:%.2fs C:%.2fs\n",
-             detector->GetName(),stw.RealTime(),stw.CpuTime());
-    }
-}
-
-//_______________________________________________________________________
-void  AliRun::InitGeometry()
-{ 
-  //
-  // Initialize detectors and display geometry
-  //
-
-   printf("Initialisation:\n");
-    TStopwatch stw;
-    TIter next(fModules);
-    AliModule *detector;
-    while((detector = dynamic_cast<AliModule*>(next()))) {
-      stw.Start();
-      // Initialise detector and display geometry
-      detector->Init();
-      detector->BuildGeometry();
-      printf("%10s R:%.2fs C:%.2fs\n",
-            detector->GetName(),stw.RealTime(),stw.CpuTime());
-    }
-}
-//_______________________________________________________________________
-
-void  AliRun::GeneratePrimaries()
-{ 
-  //
-  // Generate primary particles and fill them in the stack.
-  //
-
-  Generator()->Generate();
-}
-//_______________________________________________________________________
-
-void AliRun::BeginPrimary()
-{
-  //
-  // Called  at the beginning of each primary track
-  //
-  
-  // Reset Hits info
-  gAlice->ResetHits();
-  gAlice->ResetTrackReferences();
-
-}
-
-//_______________________________________________________________________
-void AliRun::PreTrack()
-{
-     TObjArray &dets = *fModules;
-     AliModule *module;
-
-     for(Int_t i=0; i<=fNdets; i++)
-       if((module = dynamic_cast<AliModule*>(dets[i])))
-        module->PreTrack();
-
-     fMCQA->PreTrack();
-}
-
-//_______________________________________________________________________
-void AliRun::Stepping() 
-{
-  //
-  // Called at every step during transport
-  //
-
-  Int_t id = DetFromMate(gMC->GetMedium());
-  
-  if (id < 0) return;
-
-  //
-  // --- If lego option, do it and leave 
-  if (fLego)
-    fLego->StepManager();
-  else {
-    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*>(fModules->At(id));
-    if(det && det->StepManagerIsEnabled()) {
-      fMCQA->StepManager(id);
-      det->StepManager();
-    }
-  }
-}
-
-//_______________________________________________________________________
-void AliRun::PostTrack()
-{
-     TObjArray &dets = *fModules;
-     AliModule *module;
-
-     for(Int_t i=0; i<=fNdets; i++)
-       if((module = dynamic_cast<AliModule*>(dets[i])))
-        module->PostTrack();
-}
-
-//_______________________________________________________________________
-void AliRun::FinishPrimary()
-{
-  //
-  // Called  at the end of each primary track
-  //
-  
-  //  static Int_t count=0;
-  //  const Int_t times=10;
-  // This primary is finished, purify stack
-  fRunLoader->Stack()->PurifyKine();
-
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-    detector->FinishPrimary();
-    if(detector->GetLoader())
-     {
-       detector->GetLoader()->TreeH()->Fill();
-     }
-  }
-
-  // Write out track references if any
-  if (fRunLoader->TreeTR()) 
-   {
-    fRunLoader->TreeTR()->Fill();
-   }
-}
-
-//_______________________________________________________________________
-void AliRun::FinishEvent()
-{
-  //
-  // Called at the end of the event.
-  //
-  
-  //
-  if(fLego) fLego->FinishEvent();
-
-  TIter next(fModules);
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-    detector->FinishEvent();
-  }
-
-  //Update the energy deposit tables
-  Int_t i;
-  for(i=0;i<fEventEnergy.GetSize();i++) 
-   {
-    fSummEnergy[i]+=fEventEnergy[i];
-    fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
-   }
-
-  AliHeader* header = fRunLoader->GetHeader();
-  AliStack* stack = fRunLoader->Stack();
-  if ( (header == 0x0) || (stack == 0x0) )
-   {//check if we got header and stack. If not cry and exit aliroot
-    Fatal("AliRun","Can not get the stack or header from LOADER");
-    return;//never reached
-   }  
-  // Update Header information 
-  header->SetNprimary(stack->GetNprimary());
-  header->SetNtrack(stack->GetNtrack());  
-
-  
-  // Write out the kinematics
-  stack->FinishEvent();
-   
-  // Write out the event Header information
-  TTree* treeE = fRunLoader->TreeE();
-  if (treeE) 
-   {
-      header->SetStack(stack);
-      treeE->Fill();
-   }
-  else
-   {
-    Error("FinishEvent","Can not get TreeE from RL");
-   }
-  
-  fRunLoader->WriteKinematics("OVERWRITE");
-  fRunLoader->WriteTrackRefs("OVERWRITE");
-  fRunLoader->WriteHits("OVERWRITE");
-
-  if (GetDebug()) 
-   { 
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-     Info("FinishEvent","          FINISHING EVENT               ");
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-     Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-   }
-}
-
-//_______________________________________________________________________
 void AliRun::Field(const Double_t* x, Double_t *b) const
 {
    Float_t xfloat[3];
@@ -1711,34 +860,6 @@ void AliRun::Streamer(TBuffer &R__b)
 
 
 //_______________________________________________________________________
-Int_t AliRun::GetCurrentTrackNumber() const {
-  //
-  // Returns current track
-  //
-  return fRunLoader->Stack()->GetCurrentTrackNumber();
-}
-
-//_______________________________________________________________________
-Int_t AliRun::GetNtrack() const {
-  //
-  // Returns number of tracks in stack
-  //
-  return fRunLoader->Stack()->GetNtrack();
-}
-//_______________________________________________________________________
-
-//_______________________________________________________________________
-TObjArray* AliRun::Particles() const {
-  //
-  // Returns pointer to Particles array
-  //
-  if (fRunLoader)
-   if (fRunLoader->Stack())
-    return fRunLoader->Stack()->Particles();
-  return 0x0;
-}
-
-//___________________________________________________________________________
 
 //_______________________________________________________________________
 void AliRun::SetGenEventHeader(AliGenEventHeader* header)
index 0e9a68c..76135cb 100644 (file)
@@ -5,45 +5,29 @@
 
 /* $Id$ */
 
-#include <TArrayF.h>
-#include <TArrayI.h>
-#include <TClonesArray.h>
 #include <TMCProcess.h>
 #include <TStopwatch.h>
-#include <TVirtualMCApplication.h>
-#include <TVirtualMC.h>
 #include <TError.h>
 
-class TBranch;
-class TBrowser;
-class TDatabasePDG;
-class TFile;
 class TGeometry;
-class TList;
 class TParticle;
 class TRandom;
 class TTree;
 
 #include "AliRunLoader.h"
-class AliDetector;
 class AliDisplay;
 class AliGenEventHeader;
 class AliGenerator;
 class AliHeader;
 class AliLego;
 class AliLegoGenerator;
-class AliLegoGenerator;
-class AliMCQA;
+class AliMC;
 class AliMagF;
-class AliModule;
 class AliStack;
-class AliTrackReference;
-
 
 enum {kKeepBit=1, kDaughtersBit=2, kDoneBit=4};
 
-
-class AliRun : public TVirtualMCApplication {
+class AliRun : public TNamed {
 public:
    // Creators - distructors
    AliRun();
@@ -53,25 +37,14 @@ public:
 
    AliRun& operator = (const AliRun &arun) 
      {arun.Copy(*this); return (*this);}
-   virtual  void  AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const;
-   virtual  void  AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const;
-   virtual  void  AddHitList(TCollection *hitList) {fHitLists->Add(hitList);}
-   virtual  void  Browse(TBrowser *b);
    virtual  void  Build();
    virtual  void  BuildSimpleGeometry();
    virtual  void  CleanDetectors();
    TObjArray     *Detectors() const {return fModules;}
    TObjArray     *Modules() const {return fModules;}
-   Int_t          GetCurrentTrackNumber() const;
    AliDisplay    *Display() const { return fDisplay;}
-   virtual  Int_t DistancetoPrimitive(Int_t px, Int_t py) const;
-   virtual  void  DumpPart (Int_t i) const;
-   virtual  void  DumpPStack () const;
    virtual AliMagF *Field() const {return fField;}
    virtual  void  FinishRun();
-   virtual  void  FlagTrack(Int_t track);
-   void           AddEnergyDeposit(Int_t id, Float_t edep) 
-                                       {fEventEnergy[id]+=edep;}
    void           AddModule(AliModule* mod);
    Int_t          GetEvNumber() const;
    Int_t          GetRunNumber() const {return fRun;}
@@ -79,11 +52,10 @@ public:
    void           SetEventNrInRun(Int_t event) {fEventNrInRun=event;}
    Int_t          GetEventNrInRun() const {return fEventNrInRun;}
    Int_t          GetEventsPerRun() const {return fEventsPerRun;}
+   Int_t          GetNdets() const {return fNdets;}
    Int_t          GetDebug() const {return fDebug;}
    AliModule     *GetModule(const char *name) const;
-   TList*         GetHitLists() const {return fHitLists ;}
    AliDetector   *GetDetector(const char *name) const;
-   AliMCQA       *GetMCQA() const {return fMCQA;}
    Int_t          GetModuleID(const char *name) const;
    virtual  const char *GetBaseFile() const 
     {return fBaseFileName.Data();}
@@ -94,8 +66,7 @@ public:
     {return fConfigFunction.Data();}
    TGeometry     *GetGeometry();
    virtual  void  SetGenEventHeader(AliGenEventHeader* header);
-   Int_t          GetNtrack() const;
-   virtual  Int_t GetPrimary(Int_t track) const;
+   AliMC*         GetMCApp() const {return fMCApp;}
    virtual  void  Hits2Digits(const char *detector=0); 
    virtual  void  Hits2SDigits(const char *detector=0)   {Tree2Tree("S",detector);}
    virtual  void  SDigits2Digits(const char *detector=0) {Tree2Tree("D",detector);}
@@ -105,21 +76,10 @@ public:
    Bool_t         IsFolder() const {return kTRUE;}
    virtual AliLego* Lego() const {return fLego;}
 
-   TObjArray     *Particles() const;
-   TParticle     *Particle(Int_t i) const;
    virtual  void  ResetDigits();
    virtual  void  ResetSDigits();
-   virtual  void  ResetHits();
-// Track reference related 
-   virtual void        AddTrackReference(Int_t label);
-   TClonesArray   *TrackReferences()   const {return fTrackReferences;}
-   virtual void   RemapTrackReferencesIDs(Int_t *map); //remaping track references MI
-   virtual void   ResetTrackReferences();
-   
    virtual  void  ResetPoints();
-   virtual  void  SetTransPar(const char *filename="$(ALICE_ROOT)/data/galice.cuts");
    virtual  void  SetBaseFile(const char *filename="galice.root");
-   virtual  void  ReadTransPar();
    virtual  void  RunMC(Int_t nevent=1, const char *setup="Config.C");
    virtual  void  Run(Int_t nevent=1, const char *setup="Config.C") {RunMC(nevent,setup);}
    virtual  void  RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178,
@@ -127,48 +87,17 @@ public:
                           Float_t rmax=430,Float_t zmax=10000, AliLegoGenerator* gener=NULL);
    virtual  Bool_t IsLegoRun() const {return (fLego!=0);}
    virtual  void  RunReco(const char *detector=0, Int_t first = 0, Int_t last = 0);
-   virtual  void  SetCurrentTrack(Int_t track);                           
    virtual  void  SetDebug(const Int_t level=0) {fDebug = level;}
    virtual  void  SetDisplay(AliDisplay *display) {fDisplay = display;}
    virtual  void  SetField(Int_t type=2, Int_t version=1, Float_t scale=1, Float_t maxField=10, char*filename="$(ALICE_ROOT)/data/field01.dat");
    virtual  void  SetField(AliMagF* magField);
-   virtual  void  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 = 1, Int_t is = 0);
-   virtual  void  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=1,
-                          Int_t is = 0);
-   virtual  void  SetHighWaterMark(const Int_t nt);
-   
-   virtual  void  KeepTrack(const Int_t itra);
-   virtual  void  MediaTable();
-   virtual  void    TrackingLimits( Float_t rmax=1.e10, Float_t zmax=1.e10) {fTrRmax=rmax; fTrZmax=zmax;}
-   virtual  Int_t   DetFromMate(Int_t i) const { return (*fImedia)[i];}
-   virtual  AliGenerator* Generator() const {return fGenerator;}
-   virtual  void SetGenerator(AliGenerator *generator);
-   virtual  void ResetGenerator(AliGenerator *generator);
-   virtual  void EnergySummary();
    virtual  TDatabasePDG* PDGDB() const {return fPDGDB;}
    
-   // MC Application
-   //
-   virtual  void  ConstructGeometry();
-   virtual  void  InitGeometry();     
-   virtual  void  GeneratePrimaries();
-   virtual  void  BeginEvent();
-   virtual  void  BeginPrimary();
-   virtual  void  PreTrack();
-   virtual  void  Stepping();         
-   virtual  void  PostTrack();
-   virtual  void  FinishPrimary();
-   virtual  void  FinishEvent();
-   virtual  Double_t  TrackingZmax() const {return fTrZmax;}
-   virtual  Double_t  TrackingRmax() const {return fTrRmax;}
    virtual  void Field(const Double_t* x, Double_t* b) const;
+   
+   // Delegations
+   virtual  void  ResetHits();
+   virtual  AliGenerator* Generator() const;
 
    //
    // End of MC Application
@@ -206,29 +135,19 @@ protected:
   Int_t          fDebug;             //  Debug flag
   TObjArray     *fModules;           //  List of Detectors
   TGeometry     *fGeometry;          //  Pointer to geometry
+  AliMC         *fMCApp;             //  Pointer to virtual MC Application
   AliDisplay    *fDisplay;           //! Pointer to event display
   TStopwatch     fTimer;             //  Timer object
   AliMagF       *fField;             //  Magnetic Field Map
   TVirtualMC    *fMC;                //! Pointer to MonteCarlo object
-  TArrayI       *fImedia;            //! Array of correspondence between media and detectors
   Int_t          fNdets;             //  Number of detectors
-  Float_t        fTrRmax;            //  Maximum radius for tracking
-  Float_t        fTrZmax;            //  Maximu z for tracking
-  AliGenerator  *fGenerator;         //  Generator used in the MC
   Bool_t         fInitDone;          //! True when initialisation done
   AliLego       *fLego;              //! Pointer to aliLego object if it exists
   TDatabasePDG  *fPDGDB;             //  Particle factory object
-  TList         *fHitLists;          //! Lists of hits to be remapped by PurifyKine
-  TArrayF        fEventEnergy;       //! Energy deposit for current event
-  TArrayF        fSummEnergy;        //! Energy per event in each volume
-  TArrayF        fSum2Energy;        //! Energy squared per event in each volume
   TString        fConfigFunction;    //  Configuration file to be executed
   TRandom       *fRandom;            //  Pointer to the random number generator
-  AliMCQA       *fMCQA;              //  Pointer to MC Quality assurance class
-  TString        fTransParName;      //  Name of the transport parameters file
   TString        fBaseFileName;      //  Name of the base root file
 
-  TClonesArray *fTrackReferences;     //!list of track references - for one primary track only -MI
   AliRunLoader  *fRunLoader;         //!run getter - written as a separate object
 private:
   void Copy(AliRun &arun) const;
index 373e869..9ee1ed7 100644 (file)
@@ -32,6 +32,7 @@
 #include "AliHit.h"
 #include "AliModule.h"
 #include "AliRun.h"
+#include "AliMC.h"
 #include "AliRunLoader.h"
 #include "AliStack.h"
 
@@ -359,7 +360,7 @@ void AliStack::PurifyKine()
   }
   
   // Now loop on all registered hit lists
-  TList* hitLists = gAlice->GetHitLists();
+  TList* hitLists = gAlice->GetMCApp()->GetHitLists();
   TIter next(hitLists);
   TCollection *hitList;
   while((hitList = dynamic_cast<TCollection*>(next()))) {
@@ -383,7 +384,7 @@ void AliStack::PurifyKine()
      detector->RemapTrackReferencesIDs(map.GetArray());
    }
    //
-   gAlice->RemapTrackReferencesIDs(map.GetArray());
+   gAlice->GetMCApp()->RemapTrackReferencesIDs(map.GetArray());
 
    // Now the output bit, from fHgwmk to nkeep we write everything and we erase
    if(nkeep>fParticleFileMap.GetSize()) fParticleFileMap.Set(Int_t (nkeep*1.5));
index da0d742..bd6ad43 100644 (file)
@@ -74,6 +74,7 @@
 #pragma link C++ class  AliCollisionGeometry+;
 #pragma link C++ class  AliMemoryWatcher+;
 #pragma link C++ class  AliBarrelTrack+;
+#pragma link C++ class  AliMC+;
 #endif
 
 
index 365873c..b5e5cc6 100644 (file)
@@ -16,7 +16,8 @@ AliMergeCombi.cxx AliMagFMaps.cxx AliFieldMap.cxx \
 AliGausCorr.cxx AliTrackReference.cxx AliESD.cxx \
 AliTrackMap.cxx AliTrackMapper.cxx AliCollisionGeometry.cxx \
 AliMemoryWatcher.cxx AliBarrelTrack.cxx \
-AliESDtrack.cxx AliESDv0.cxx AliESDcascade.cxx AliESDvertex.cxx AliESDpid.cxx
+AliESDtrack.cxx AliESDv0.cxx AliESDcascade.cxx AliESDvertex.cxx AliESDpid.cxx \
+AliMC.cxx
 HDRS:= $(SRCS:.cxx=.h) 
 
 DHDR= STEERLinkDef.h
index 658d7c5..5d3e03b 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliFRAMEv0.h"
 #include "AliRun.h"
 #include "TSystem.h"
+#include <TVirtualMC.h>
  
 ClassImp(AliFRAMEv0)
  
index 0d1132e..7f1a568 100644 (file)
@@ -22,6 +22,7 @@
 //-------------------------------------------------------------------------
 
 #include <TSystem.h>
+#include <TVirtualMC.h>
 
 #include "AliFRAMEv1.h"
 #include "AliRun.h"
index ff8da63..e94d4d4 100644 (file)
 //------------------------------------------------------------------------
 
 #include <TSystem.h>
+#include <TVirtualMC.h>
 
 #include "AliFRAMEv2.h"
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliConst.h"
+#include "AliMC.h"
  
 ClassImp(AliFRAMEv2)
  
@@ -1351,7 +1353,7 @@ void AliFRAMEv2::StepManager()
   //
   // Add the reference track
   //
-  AddTrackReference(gAlice->GetCurrentTrackNumber());
+  AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
 }
 
   
index 9539331..ca2ffdf 100644 (file)
 // Author: A.Morsch
 //-------------------------------------------------------------------------
 
+#include <TVirtualMC.h>
+#include <TArrayI.h>
+
 #include "AliSHILv2.h"
-#include "AliRun.h"
 #include "AliConst.h"
 #include "AliALIFE.h"
 
index b69c8d3..d7ab57e 100644 (file)
 // Author: A.Morsch
 //-------------------------------------------------------------------------
 
+#include <TVirtualMC.h>
+#include <TArrayI.h>
+
 #include "AliSHILvF.h"
-#include "AliRun.h"
 #include "AliConst.h"
 #include "AliALIFE.h"
 
index 6f15f6e..53b7f73 100644 (file)
@@ -27,6 +27,7 @@
 #include "THerwig6.h"
 
 #include "Riostream.h"
+#include "AliMC.h"
 
 ClassImp(AliGenHerwig)
 
@@ -204,7 +205,7 @@ void AliGenHerwig::Generate()
                Float_t tof = kconv*iparticle->T();
                Int_t   iparent = (imo > -1) ? newPos[imo] : -1;
                Int_t   trackIt = (ks == 1) && fTrackIt;
-               gAlice->PushTrack(trackIt, iparent, kf,
+               gAlice->GetMCApp()->PushTrack(trackIt, iparent, kf,
                                 p[0], p[1], p[2], p[3],
                                 origin[0], origin[1], origin[2], 
                                 tof,
@@ -239,9 +240,9 @@ void AliGenHerwig::AdjustWeights()
 {
 // Adjust the weights after generation of all events
     TParticle *part;
-    Int_t ntrack=gAlice->GetNtrack();
+    Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
     for (Int_t i=0; i<ntrack; i++) {
-        part= gAlice->Particle(i);
+        part= gAlice->GetMCApp()->Particle(i);
         part->SetWeight(part->GetWeight()*fKineBias);
     }
 }
index e8fa2e4..666d28e 100644 (file)
@@ -69,6 +69,7 @@
 #include "AliTOFdigit.h"
 #include "AliTOFhit.h"
 #include "AliTOFhitT0.h"
+#include "AliMC.h"
  
 ClassImp(AliTOF)
  
@@ -120,8 +121,8 @@ AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
   if (gAlice==0) {
      Fatal("AliTOF","gAlice==0 !");
   }
-  if (gAlice->GetHitLists())
-     gAlice->AddHitList(fHits);
+  if (gAlice->GetMCApp()->GetHitLists())
+     gAlice->GetMCApp()->AddHitList(fHits);
   else Error("AliTOF","gAlice->GetHitLists()==0");
 
   fIshunt  = 0;
index e6d8170..39f36c0 100644 (file)
@@ -74,6 +74,7 @@
 #include "AliTOFv3.h"
 #include "AliTOFv4.h"
 #include "AliTOFv4T0.h"
+#include "AliMC.h"
 
 // #include "../TPC/AliTPC.h"
 // AliTPChit class or somewhere
@@ -1701,7 +1702,7 @@ void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits,
       ipart    = tofHit->GetTrack();
       if(ipart>=fMaxAllTracks) break;
       Float_t geantTime= tofHit->GetTof(); // it is given in [s]
-      particle = (TParticle*)gAlice->Particle(ipart);
+      particle = (TParticle*)gAlice->GetMCApp()->Particle(ipart);
 
       Int_t pdgCode=particle->GetPdgCode();
       // Only high momentum tracks (see fPBound value)
@@ -3020,7 +3021,7 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
     //Test
     if(PRINT) {
       if(iTOFpixel[ipart] && match!=3) {
-       particle = (TParticle*)gAlice->Particle(ipart);  //for V3.05
+       particle = (TParticle*)gAlice->GetMCApp()->Particle(ipart);  //for V3.05
 
        printf("          ipixel=%i (Sector=%i, Plate=%i, Strip=%i, Pixel=%i), fired by %i track\n",iTOFpixel[ipart],
                        pixelArray[iTOFpixel[ipart]-1].GetSector(),pixelArray[iTOFpixel[ipart]-1].GetPlate(),
@@ -3171,7 +3172,7 @@ void AliTOFReconstructioner::FillNtuple(Int_t ntracks, AliTOFTrack* trackArray,
     cout << "particle " << i << endl;
     cout << "total " << numberOfParticles << endl;
     */
-    TParticle *part = (TParticle *) gAlice->Particle(i);
+    TParticle *part = (TParticle *) gAlice->GetMCApp()->Particle(i);
     if(charge[PDGtoGeantCode(part->GetPdgCode())-1]) {
       icharge++;
       /*
index df1c0ea..cf939d5 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliTOFTrackV2.h"
 #include "AliTOFdigit.h"
 #include "AliTOFhitT0.h"
+#include "AliMC.h"
 
 ClassImp(AliTOFReconstructionerV2)
 
@@ -991,7 +992,7 @@ void AliTOFReconstructionerV2::Comparison(Int_t* rtIndex)
          if(ipart >= 80000) continue;
          if(rtIndex[ipart] < 0) continue; 
 
-        TParticle *part = gAlice->Particle(ipart);
+        TParticle *part = gAlice->GetMCApp()->Particle(ipart);
         
         // get first the pdg code
         Int_t pdgCode=part->GetPdgCode();
index 8707e0e..0be6089 100644 (file)
@@ -55,6 +55,7 @@
 #include "AliTOFv2.h"
 #include "AliTOFv3.h"
 #include "AliTOFv4.h"
+#include "AliMC.h"
 
 ClassImp(AliTOFSDigitizer)
 
@@ -272,7 +273,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
       gAlice->ResetHits();
       //PH      TH->GetEvent(track);
       tofHitsBranch->GetEvent(track);
-      particle = gAlice->Particle(track);
+      particle = gAlice->GetMCApp()->Particle(track);
       Int_t nhits = TOFhits->GetEntriesFast();
       // cleaning all hits of the same track in the same pad volume
       // it is a rare event, however it happens
index 3e29274..a4b0ea0 100644 (file)
@@ -86,6 +86,7 @@
 #include "AliTOFT0.h"
 #include "AliTOFhitT0.h"
 #include "AliTOFv4T0.h"
+#include "AliMC.h"
 
 ClassImp(AliTOFT0)
 
@@ -254,7 +255,7 @@ void AliTOFT0::Exec(Option_t *option)
       
       gAlice->ResetHits();
       TH->GetEvent(track);
-      particle = gAlice->Particle(track);
+      particle = gAlice->GetMCApp()->Particle(track);
       Int_t nhits = TOFhits->GetEntriesFast();
 
       for (Int_t hit = 0; hit < nhits; hit++)
@@ -266,7 +267,7 @@ void AliTOFT0::Exec(Option_t *option)
 
        if (ipart != ipartold){
          
-         particle = (TParticle*)gAlice->Particle(ipart);
+         particle = (TParticle*)gAlice->GetMCApp()->Particle(ipart);
          
          Float_t idealtime=tofHit->GetTof();
          //       Float_t time=idealtime;
index 847461d..1fec974 100644 (file)
@@ -57,6 +57,7 @@
 #include "AliRun.h"
 #include "AliTOFv0.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv0)
  
@@ -1052,7 +1053,7 @@ void AliTOFv0::StepManager()
     vol[3]= padx;
     vol[4]= padz;
 
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
 
index 5642e86..8e0b8ee 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliRun.h"
 #include "AliTOFv1.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv1)
  
@@ -1141,7 +1142,7 @@ void AliTOFv1::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
 
index f773826..549f7f1 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliRun.h"
 #include "AliTOFv2.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv2)
  
@@ -1153,6 +1154,6 @@ void AliTOFv2::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
index e50d38a..7dde1d8 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliRun.h"
 #include "AliTOFv2FHoles.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv2FHoles)
  
@@ -1171,6 +1172,6 @@ void AliTOFv2FHoles::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
index 589d27e..c7bf9dd 100644 (file)
@@ -57,6 +57,7 @@
 #include "AliRun.h"
 #include "AliTOFv3.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv3)
  
@@ -1140,6 +1141,6 @@ void AliTOFv3::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
index 1bafa73..93ae0ae 100644 (file)
@@ -58,6 +58,7 @@
 #include "AliRun.h"
 #include "AliTOFv4.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv4)
  
@@ -1140,6 +1141,6 @@ void AliTOFv4::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
index eb2927e..04155d6 100644 (file)
@@ -52,6 +52,7 @@
 #include "AliRun.h"
 #include "AliTOFv4T0.h"
 #include "AliTOFConstants.h" // AdC
+#include "AliMC.h"
  
 ClassImp(AliTOFv4T0)
  
@@ -1135,6 +1136,6 @@ void AliTOFv4T0::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddT0Hit(gAlice->GetCurrentTrackNumber(),vol, hits);
+    AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
index 9a1e1b2..8d55211 100644 (file)
@@ -74,6 +74,7 @@
 #include "AliTPCTrackHitsV2.h"
 #include "AliTPCcluster.h"
 #include "AliTrackReference.h"
+#include "AliMC.h"
 
 
 ClassImp(AliTPC) 
@@ -138,7 +139,7 @@ AliTPC::AliTPC(const char *name, const char *title)
   //
   // Initialise arrays of hits and digits 
   fHits     = new TClonesArray("AliTPChit",  176);
-  gAlice->AddHitList(fHits); 
+  gAlice->GetMCApp()->AddHitList(fHits); 
   fDigitsArray = 0;
   fClustersArray= 0;
   fDefaults = 0;
@@ -965,7 +966,7 @@ void AliTPC::Hits2Clusters(Int_t /*eventn*/)
         continue; 
        }
        ipart=tpcHit->Track();
-       particle=gAlice->Particle(ipart);
+       particle=gAlice->GetMCApp()->Particle(ipart);
        pl=particle->Pz();
        pt=particle->Pt();
        if(pt < 1.e-9) pt=1.e-9;
@@ -1082,7 +1083,7 @@ void AliTPC::Hits2ExactClustersSector(Int_t isec)
   SetTreeAddress();
 
   Stat_t ntracks = tH->GetEntries();
-  Int_t npart = gAlice->GetNtrack();
+  Int_t npart = gAlice->GetMCApp()->GetNtrack();
   //MI change
   TBranch * branch=0;
   if (fHitType>1) branch = tH->GetBranch("TPC2");
@@ -1119,7 +1120,7 @@ void AliTPC::Hits2ExactClustersSector(Int_t isec)
       }
 
       ipart=tpcHit->Track();
-      if (ipart<npart) particle=gAlice->Particle(ipart);
+      if (ipart<npart) particle=gAlice->GetMCApp()->Particle(ipart);
       
       //find row number
 
@@ -2529,12 +2530,12 @@ void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits)
   // add hit to the list  
   Int_t rtrack;
   if (fIshunt) {
-    int primary = gAlice->GetPrimary(track);
-    gAlice->Particle(primary)->SetBit(kKeepBit);
+    int primary = gAlice->GetMCApp()->GetPrimary(track);
+    gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
     rtrack=primary;
   } else {
     rtrack=track;
-    gAlice->FlagTrack(track);
+    gAlice->GetMCApp()->FlagTrack(track);
   }  
   //AliTPChit *hit = (AliTPChit*)fHits->UncheckedAt(fNhits-1);
   //if (hit->fTrack!=rtrack)
@@ -2709,7 +2710,7 @@ void AliTPC::LoadPoints2(Int_t)
   if (fHitType&2) nhits = fTrackHitsOld->GetEntriesFast();
   
   if (nhits == 0) return;
-  Int_t tracks = gAlice->GetNtrack();
+  Int_t tracks = gAlice->GetMCApp()->GetNtrack();
   if (fPoints == 0) fPoints = new TObjArray(tracks);
   AliHit *ahit;
   //
@@ -2784,7 +2785,7 @@ void AliTPC::LoadPoints3(Int_t)
   //
   Int_t nhits = fTrackHits->GetEntriesFast();
   if (nhits == 0) return;
-  Int_t tracks = gAlice->GetNtrack();
+  Int_t tracks = gAlice->GetMCApp()->GetNtrack();
   if (fPoints == 0) fPoints = new TObjArray(2*tracks);
   fPoints->Expand(2*tracks);
   AliHit *ahit;
index 3c06e0e..8428175 100644 (file)
@@ -78,6 +78,7 @@
 #include "AliTPCtrack.h"
 #include "AliTrackReference.h"
 #include "AliTPCtrackerParam.h"
+#include "AliMC.h"
 //-----------------------------
 
 Double_t RegFunc(Double_t *x,Double_t *par) {
@@ -305,7 +306,7 @@ Int_t AliTPCtrackerParam::BuildTPCtracks(const TFile *inp, TFile *out) {
 
     // loop on particles and store pdg codes
     for(Int_t l=0; l<nParticles; l++) {
-      Part        = (TParticle*)gAlice->Particle(l);
+      Part        = (TParticle*)gAlice->GetMCApp()->Particle(l);
       pdgCodes[l] = Part->GetPdgCode();
       ptkine[l]   = Part->Pt();
       pzkine[l]   = Part->Pz();
@@ -1197,7 +1198,7 @@ void AliTPCtrackerParam::CompareTPCtracks(
       geatree->GetEvent(j);
       
       label = geatrack->GetLabel();
-      Part = (TParticle*)gAlice->Particle(label);
+      Part = (TParticle*)gAlice->GetMCApp()->Particle(label);
       
       // use only injected tracks with fixed values of pT
       ptgener = Part->Pt();
index 538402f..a34dffc 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliTPCParamSR.h"
 #include "AliTPCv1.h"
 #include "TLorentzVector.h"
+#include "AliMC.h"
 
 ClassImp(AliTPCv1)
 
@@ -1768,7 +1769,7 @@ void AliTPCv1::StepManager()
         hits[3]=0.; // this hit has no energy loss
        // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
 
-        AddHit(gAlice->GetCurrentTrackNumber(), vol,hits); // M.I. 
+        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I. 
 
         gMC->TrackPosition(p);
         hits[0]=p[0];
@@ -1777,7 +1778,7 @@ void AliTPCv1::StepManager()
         hits[3]=0.; // this hit has no energy loss
         // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
 
-       AddHit(gAlice->GetCurrentTrackNumber(), vol,hits); // M.I. 
+       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I. 
 
       } 
 
@@ -1786,7 +1787,7 @@ void AliTPCv1::StepManager()
       hits[3]=1; //I'd like to have something positive here (I.Belikov)
       // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
 
-      AddHit(gAlice->GetCurrentTrackNumber(), vol,hits); // M.I. 
+      AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I. 
 
     }
 
index 432b38a..454617f 100644 (file)
@@ -43,6 +43,7 @@
 #include "AliTPCParamSR.h"
 #include "AliTPCTrackHitsV2.h"
 #include "AliTPCv2.h"
+#include "AliMC.h"
 
 ClassImp(AliTPCv2)
  
@@ -1858,7 +1859,7 @@ void AliTPCv2::StepManager()
   if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting()) &&
        ((id == fIdLSec) || (id == fIdUSec)) ) {
 
-    AddTrackReference(gAlice->GetCurrentTrackNumber());
+    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
   }
 
   if(id == fIdLSec){
@@ -1904,7 +1905,7 @@ void AliTPCv2::StepManager()
       hits[3]=0.; // this hit has no energy loss
       // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
 
-      AddHit(gAlice->GetCurrentTrackNumber(), vol,hits);  //MI change
+      AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  //MI change
 
     }
 
@@ -1915,7 +1916,7 @@ void AliTPCv2::StepManager()
      hits[3]=0.; // this hit has no energy loss
      // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
 
-     AddHit(gAlice->GetCurrentTrackNumber(), vol,hits);  //MI change    
+     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  //MI change    
 
   }
   else return;
@@ -1944,7 +1945,7 @@ void AliTPCv2::StepManager()
       Float_t precision =   (momentum>0.1) ? 0.002 :0.01;
       fTrackHits->SetHitPrecision(precision);
     }
-    AddHit(gAlice->GetCurrentTrackNumber(), vol,hits);  //MI change 
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  //MI change 
     
   } 
   
index 84fe72b..da2a485 100644 (file)
@@ -44,6 +44,7 @@
 #include "AliTPCParamSR.h"
 #include "AliTPCTrackHitsV2.h"
 #include "AliTPCv3.h"
+#include "AliMC.h"
 
 ClassImp(AliTPCv3)
 //_____________________________________________________________________________
@@ -1680,7 +1681,7 @@ void AliTPCv3::StepManager()
     
     // Add this hit
    
-    AddHit(gAlice->GetCurrentTrackNumber(), vol,hits);  //MI change
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  //MI change
     
   } 
   
index 3a8e4e5..a8fa23b 100644 (file)
@@ -55,6 +55,7 @@
 #include "AliTRDrecPoint.h"
 #include "AliTRDtrackHits.h"  
 #include "AliTrackReference.h"
+#include "AliMC.h"
 
 ClassImp(AliTRD)
  
@@ -118,7 +119,7 @@ AliTRD::AliTRD(const char *name, const char *title)
 
   // Allocate the hit array
   fHits           = new TClonesArray("AliTRDhit"     ,405);
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
 
   // Allocate the digits array
   fDigits         = 0;
@@ -844,7 +845,7 @@ void AliTRD::LoadPoints(Int_t )
   } 
   if (nhits == 0) return;
 
-  Int_t tracks = gAlice->GetNtrack();
+  Int_t tracks = gAlice->GetMCApp()->GetNtrack();
   if (fPoints == 0) fPoints = new TObjArray(tracks);
 
   AliTRDhit *ahit;
@@ -1292,13 +1293,13 @@ void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
   Int_t rtrack;
 
   if (fIshunt) {
-    Int_t primary = gAlice->GetPrimary(track);
-    gAlice->Particle(primary)->SetBit(kKeepBit);
+    Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
+    gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
     rtrack = primary;
   } 
   else {
     rtrack = track;
-    gAlice->FlagTrack(track);
+    gAlice->GetMCApp()->FlagTrack(track);
   }
 
   if ((fTrackHits) && (fHitType > 0)) {
index c50929c..d42e656 100644 (file)
@@ -42,6 +42,7 @@
 #include "AliTRDtrack.h"
 #include "AliTRDtracker.h"
 #include "AliTRDgeometry.h"
+#include "AliMC.h"
 
 ClassImp(AliTRDpid)
 
@@ -471,7 +472,7 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t)
       }
       if (accept) {
 
-        particle = gAlice->Particle(track0);
+        particle = gAlice->GetMCApp()->Particle(track0);
         if (particle->GetFirstMother() == -1) {
           switch (TMath::Abs(particle->GetPdgCode())) {
           case kPdgEl:
@@ -577,7 +578,7 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t, Int_t *pdg
 
       Int_t trackIndex = cluster->GetLabel(iTrack);
       if (trackIndex >= 0) {
-        particle = gAlice->Particle(trackIndex);
+        particle = gAlice->GetMCApp()->Particle(trackIndex);
         Int_t  pdgCode = particle->GetPdgCode(); 
         Bool_t newPart = kTRUE;
         for (iPart = 0; iPart < nPart; iPart++) {
index 1db2cd9..0879712 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "AliTRDsimpleGen.h"
 #include "AliTRDsimpleMC.h"
+#include "AliMC.h"
  
 ClassImp(AliTRDsimpleGen)
  
@@ -116,7 +117,7 @@ void AliTRDsimpleGen::NewParticle(Int_t ievent)
     Float_t vtx[3] = { 0.0 };
     Float_t pol[3] = { 0.0 };
     Int_t   ntr    = 0;
-    gAlice->PushTrack(0,-1,fPdg,mom,vtx,pol,0.0,kPPrimary,ntr);
+    gAlice->GetMCApp()->PushTrack(0,-1,fPdg,mom,vtx,pol,0.0,kPPrimary,ntr);
 
   }
 
index ffd45b4..79fdb6a 100644 (file)
@@ -31,6 +31,7 @@
 #include "AliTRDsimpleMC.h"
 #include "AliTRDv1.h"
 #include "AliTRDparameter.h"
+#include "AliMC.h"
  
 ClassImp(AliTRDsimpleMC)
  
@@ -202,7 +203,7 @@ void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
   fTrackY    = 0.0;
   fTrackZ    = 0.0;
 
-  gAlice->SetCurrentTrack(0);
+  gAlice->GetMCApp()->SetCurrentTrack(0);
 
 }
                                                                                 
index 1ec364a..06ffa3d 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliTRDgeometry.h"
 #include "AliTRDhit.h"
 #include "AliTRDv0.h"
+#include "AliMC.h"
 
 ClassImp(AliTRDv0)
   
@@ -176,7 +177,7 @@ void AliTRDv0::StepManager()
       pla = ((Int_t) idChamber % kNplan);
       det = fGeometry->GetDetector(pla,cha,sec);
 
-      AddHit(gAlice->GetCurrentTrackNumber(),det,hits,0,kTRUE);       
+      AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),det,hits,0,kTRUE);       
 
     }
 
index 6d2139e..f49669b 100644 (file)
@@ -44,6 +44,7 @@
 #include "AliTRDmatrix.h"
 #include "AliTRDsim.h"
 #include "AliTRDv1.h"
+#include "AliMC.h"
 
 ClassImp(AliTRDv1)
  
@@ -264,7 +265,7 @@ void AliTRDv1::CreateTRhit(Int_t det)
 
       // Add the hit to the array. TR photon hits are marked 
       // by negative charge
-      AddHit(gAlice->GetCurrentTrackNumber(),det,posHit,-q,kTRUE); 
+      AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),det,posHit,-q,kTRUE); 
 
     }
 
@@ -553,7 +554,7 @@ void AliTRDv1::StepManager()
          // momentum components of the particle
           if (gMC->IsTrackEntering() || gMC->IsTrackExiting()) {
             gMC->TrackMomentum(mom);
-            AddTrackReference(gAlice->GetCurrentTrackNumber());
+            AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
           }
 
           // Create the hits from TR photons
@@ -570,10 +571,10 @@ void AliTRDv1::StepManager()
 
        // Create a new dEdx hit
         if (drRegion) {
-          AddHit(gAlice->GetCurrentTrackNumber(),det,hits,qTot,kTRUE);       
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),det,hits,qTot,kTRUE);       
        }
         else {
-          AddHit(gAlice->GetCurrentTrackNumber(),det,hits,qTot,kFALSE);      
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),det,hits,qTot,kFALSE);      
        }
 
         // Calculate the maximum step size for the next tracking step
index a2ffdac..3d90610 100755 (executable)
@@ -33,6 +33,7 @@
 #include "AliVZEROLoader.h"
 #include "AliVZEROdigit.h"
 #include "AliVZEROhit.h"
+#include "AliMC.h"
 
 ClassImp(AliVZERO)
  
@@ -50,7 +51,7 @@ AliVZERO::AliVZERO(const char *name, const char *title)
   fHits         =  new TClonesArray("AliVZEROhit", 400);
   fDigits       =  new TClonesArray("AliVZEROdigit",400); 
    
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
 
   fThickness    =  4.1;   // total thickness of the V0R box
   fThickness1   =  0.7;   // thickness of the thickest cell (2.5 in version 0)
index f1c447c..db0e504 100755 (executable)
@@ -53,6 +53,7 @@
 #include "AliVZEROdigit.h"
 #include "AliVZEROhit.h"
 #include "AliVZEROv0.h"
+#include "AliMC.h"
 
 ClassImp(AliVZEROv0)
 
@@ -1493,7 +1494,7 @@ void AliVZEROv0::StepManager()
         hits[13] = mom[2];
         
 
-         AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         
         }
      
index 258bdee..1a20a6b 100755 (executable)
@@ -58,6 +58,7 @@
 #include "AliVZEROdigit.h"
 #include "AliVZEROhit.h"
 #include "AliVZEROv2.h"
+#include "AliMC.h"
 
 ClassImp(AliVZEROv2)
 
@@ -1052,7 +1053,7 @@ void AliVZEROv2::StepManager()
            hits[12] = mom[1];
            hits[13] = mom[2];
            
-           TParticle *par = gAlice->Particle(gAlice->GetCurrentTrackNumber());
+           TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
             hits[14] = par->Vx();
             hits[15] = par->Vy();
             hits[16] = par->Vz();
@@ -1067,7 +1068,7 @@ void AliVZEROv2::StepManager()
         hits[17] =   eloss;
         hits[18] = tlength;
         
-         AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
                 
         tlength  = 0.0;
         eloss    = 0.0; 
index 11e1ae2..06f094d 100644 (file)
@@ -27,6 +27,7 @@
 #include "AliConst.h"
 #include "AliGenZDC.h"
 #include "AliRun.h"
+#include "AliMC.h"
  
 ClassImp(AliGenZDC)
  
@@ -154,7 +155,7 @@ void AliGenZDC::Generate()
   }
       
   Float_t polar[3] = {0,0,0};
-  gAlice->PushTrack(fTrackIt,-1,fIpart,fPTrack,fOrigin.GetArray(),polar,0,
+  gAlice->GetMCApp()->PushTrack(fTrackIt,-1,fIpart,fPTrack,fOrigin.GetArray(),polar,0,
                   kPPrimary,nt);
   if(fDebugOpt == 1){
     printf("\n\n               Track momentum:\n");
index ef9f121..d5915bd 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliHeader.h"
 #include "AliLoader.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
  
 ClassImp(AliZDC)
@@ -93,7 +94,7 @@ AliZDC::AliZDC(const char *name, const char *title)
 
   // Allocate the hits array  
   fHits   = new TClonesArray("AliZDCHit",1000);
-  gAlice->AddHitList(fHits);
+  gAlice->GetMCApp()->AddHitList(fHits);
   // Allocate the merged hits array  
   fMergedHits = new TClonesArray("AliZDCMergedHit",1000);
 
@@ -135,7 +136,7 @@ void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
   
   if(fNhits==0){
       // First hit -> setting flag for primary or secondary particle
-      Int_t primary = gAlice->GetPrimary(track);     
+      Int_t primary = gAlice->GetMCApp()->GetPrimary(track);     
       if(track != primary){
         newquad->fSFlag = 1;  // SECONDARY particle entering the ZDC
       }
index bdc745f..7a17b80 100644 (file)
@@ -44,6 +44,7 @@
 #include "AliRun.h"
 #include "AliZDCHit.h"
 #include "AliZDCv1.h"
+#include "AliMC.h"
  
  
 ClassImp(AliZDCv1)
@@ -1253,7 +1254,7 @@ void AliZDCv1::StepManager()
 
 //       Int_t PcID = gMC->TrackPid();
 //       printf("Pc ID -> %d\n",PcID);
-       AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        
        if(fNoShower==1){
 //       fpDetected += 1;
@@ -1273,13 +1274,13 @@ void AliZDCv1::StepManager()
           hits[9] = ekin;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
         else{
           hits[9] = destep;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
 //      printf(" Dep. E = %f \n",hits[9]);
       }
@@ -1359,13 +1360,13 @@ void AliZDCv1::StepManager()
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
        else if((vol[0]==2)) {  // (2) ZP fibres
@@ -1378,13 +1379,13 @@ void AliZDCv1::StepManager()
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
        else if((vol[0]==3)) {  // (3) ZEM fibres
@@ -1410,7 +1411,7 @@ void AliZDCv1::StepManager()
         hits[7] = 0;   
         hits[8] = nphe;        //fLightPMC
         hits[9] = 0;
-        AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        }
      }
    }
index eb8eabd..8a9a4b9 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliRun.h"
 #include "AliZDCHit.h"
 #include "AliZDCv2.h"
+#include "AliMC.h"
  
  
 ClassImp(AliZDCv2)
@@ -1308,7 +1309,7 @@ void AliZDCv2::StepManager()
 
 //       Int_t PcID = gMC->TrackPid();
 //       printf("Pc ID -> %d\n",PcID);
-       AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        
        if(fNoShower==1){
          fpDetected += 1;
@@ -1328,13 +1329,13 @@ void AliZDCv2::StepManager()
           hits[9] = ekin;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
         else{
           hits[9] = destep;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
 //      printf(" Dep. E = %f \n",hits[9]);
       }
@@ -1416,13 +1417,13 @@ void AliZDCv2::StepManager()
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
        else if((vol[0]==2)) {  // (2) ZP fibres
@@ -1435,13 +1436,13 @@ void AliZDCv2::StepManager()
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
        else if((vol[0]==3)) {  // (3) ZEM fibres
@@ -1468,13 +1469,13 @@ void AliZDCv2::StepManager()
           hits[7] = 0;         
           hits[8] = nphe;      //fLightPMC (ZEM1)
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = nphe;      //fLightPMQ (ZEM2)
           hits[8] = 0;         
           hits[9] = 0;
-          AddHit(gAlice->GetCurrentTrackNumber(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        }
      }