-//_____________________________________________________________________________
-void AliRun::GetNextTrack(Int_t &mtrack, Int_t &ipart, Float_t *pmom,
- Float_t &e, Float_t *vpos, Float_t *polar,
- Float_t &tof)
-{
- //
- // Return next track from stack of particles
- //
- TVector3 pol;
- fCurrent=-1;
- TParticle *track;
- for(Int_t i=fNtrack-1; i>=0; i--) {
- track=(TParticle*) fParticles->UncheckedAt(i);
- if(!track->TestBit(Done_Bit)) {
- //
- // The track has not yet been processed
- fCurrent=i;
- ipart=track->GetPdgCode();
- pmom[0]=track->Px();
- pmom[1]=track->Py();
- pmom[2]=track->Pz();
- e =track->Energy();
- vpos[0]=track->Vx();
- vpos[1]=track->Vy();
- vpos[2]=track->Vz();
- track->GetPolarisation(pol);
- polar[0]=pol.X();
- polar[1]=pol.Y();
- polar[2]=pol.Z();
- tof=track->T();
- track->SetBit(Done_Bit);
- break;
- }
- }
- mtrack=fCurrent;
- //
- // stop and start timer when we start a primary track
- Int_t nprimaries = fHeader.GetNprimary();
- if (fCurrent >= nprimaries) return;
- if (fCurrent < nprimaries-1) {
- fTimer.Stop();
- track=(TParticle*) fParticles->UncheckedAt(fCurrent+1);
- // track->SetProcessTime(fTimer.CpuTime());
- }
- fTimer.Start();
-}
-
-//_____________________________________________________________________________
-Int_t AliRun::GetPrimary(Int_t track)
-{
- //
- // return number of primary that has generated track
- //
- int current, parent;
- TParticle *part;
- //
- parent=track;
- while (1) {
- current=parent;
- part = (TParticle *)fParticles->UncheckedAt(current);
- parent=part->GetFirstMother();
- if(parent<0) return current;
- }
-}
-
-//_____________________________________________________________________________
-void AliRun::InitMC(const char *setup)
-{
- //
- // Initialize the Alice setup
- //
-
- gROOT->LoadMacro(setup);
- gInterpreter->ProcessLine(fConfigFunction.Data());
-
- gMC->DefineParticles(); //Create standard MC particles
-
- TObject *objfirst, *objlast;
-
- fNdets = fModules->GetLast()+1;
-
- //
- //=================Create Materials and geometry
- gMC->Init();
-
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- detector->SetTreeAddress();
- objlast = gDirectory->GetList()->Last();
-
- // Add Detector histograms in Detector list of histograms
- if (objlast) objfirst = gDirectory->GetList()->After(objlast);
- else objfirst = gDirectory->GetList()->First();
- while (objfirst) {
- detector->Histograms()->Add(objfirst);
- objfirst = gDirectory->GetList()->After(objfirst);
- }
- }
- SetTransPar(); //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.
- fGeometry->Write();
-
- fInitDone = kTRUE;
-}
-
-//_____________________________________________________________________________
-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=(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=(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)