1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // This class is extracted from the AliRun class
19 // and contains all the MC-related functionality
20 // The number of dependencies has to be reduced...
21 // Author: F.Carminati
22 // Federico.Carminati@cern.ch
25 #include <TStopwatch.h>
27 #include <TVirtualMC.h>
29 #include "AliDetector.h"
30 #include "AliGenerator.h"
31 #include "AliHeader.h"
37 #include "AliTrackReference.h"
42 //_______________________________________________________________________
61 //_______________________________________________________________________
62 AliMC::AliMC(const char *name, const char *title) :
63 TVirtualMCApplication(name, title),
71 fImedia(new TArrayI(1000)),
74 fHitLists(new TList()),
75 fTrackReferences(new TClonesArray("AliTrackReference", 100))
78 // Set transport parameters
81 // Prepare the tracking medium lists
82 for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99;
86 //_______________________________________________________________________
87 AliMC::AliMC(const AliMC &mc) :
88 TVirtualMCApplication(mc),
103 // Copy constructor for AliRun
108 //_______________________________________________________________________
116 // Delete track references
117 if (fTrackReferences) {
118 fTrackReferences->Delete();
119 delete fTrackReferences;
120 fTrackReferences = 0;
125 //_______________________________________________________________________
126 void AliMC::Copy(AliMC &) const
128 //dummy Copy function
129 Fatal("Copy","Not implemented!\n");
132 //_______________________________________________________________________
133 void AliMC::ConstructGeometry()
136 // Create modules, materials, geometry
140 TIter next(gAlice->Modules());
142 if (GetDebug()) Info("ConstructGeometry","Geometry creation:");
143 while((detector = dynamic_cast<AliModule*>(next()))) {
145 // Initialise detector materials and geometry
146 detector->CreateMaterials();
147 detector->CreateGeometry();
148 printf("%10s R:%.2fs C:%.2fs\n",
149 detector->GetName(),stw.RealTime(),stw.CpuTime());
153 //_______________________________________________________________________
154 void AliMC::InitGeometry()
157 // Initialize detectors and display geometry
160 printf("Initialisation:\n");
162 TIter next(gAlice->Modules());
164 while((detector = dynamic_cast<AliModule*>(next()))) {
166 // Initialise detector and display geometry
168 detector->BuildGeometry();
169 printf("%10s R:%.2fs C:%.2fs\n",
170 detector->GetName(),stw.RealTime(),stw.CpuTime());
175 //_______________________________________________________________________
176 void AliMC::GeneratePrimaries()
179 // Generate primary particles and fill them in the stack.
182 Generator()->Generate();
185 //_______________________________________________________________________
186 void AliMC::SetGenerator(AliGenerator *generator)
189 // Load the event generator
191 if(!fGenerator) fGenerator = generator;
194 //_______________________________________________________________________
195 void AliMC::ResetGenerator(AliGenerator *generator)
198 // Load the event generator
202 Warning("ResetGenerator","Replacing generator %s with %s\n",
203 fGenerator->GetName(),generator->GetName());
205 Warning("ResetGenerator","Replacing generator %s with NULL\n",
206 fGenerator->GetName());
207 fGenerator = generator;
210 //_______________________________________________________________________
211 void AliMC::FinishRun()
213 // Clean generator information
214 if (GetDebug()) Info("FinishRun"," fGenerator->FinishRun()");
215 fGenerator->FinishRun();
217 //Output energy summary tables
218 if (GetDebug()) Info("FinishRun"," EnergySummary()");
223 //_______________________________________________________________________
224 void AliMC::BeginPrimary()
227 // Called at the beginning of each primary track
232 ResetTrackReferences();
236 //_______________________________________________________________________
237 void AliMC::PreTrack()
239 // Actions before the track's transport
240 TObjArray &dets = *gAlice->Modules();
243 for(Int_t i=0; i<=gAlice->GetNdets(); i++)
244 if((module = dynamic_cast<AliModule*>(dets[i])))
250 //_______________________________________________________________________
251 void AliMC::Stepping()
254 // Called at every step during transport
257 Int_t id = DetFromMate(gMC->GetMedium());
261 // --- If lego option, do it and leave
263 gAlice->Lego()->StepManager();
266 //Update energy deposition tables
267 AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
269 //Call the appropriate stepping routine;
270 AliModule *det = dynamic_cast<AliModule*>(gAlice->Modules()->At(id));
271 if(det && det->StepManagerIsEnabled()) {
272 fMCQA->StepManager(id);
278 //_______________________________________________________________________
279 void AliMC::EnergySummary()
282 // Print summary of deposited energy
288 Int_t kn, i, left, j, id;
289 const Float_t kzero=0;
290 Int_t ievent=gAlice->GetRunLoader()->GetHeader()->GetEvent()+1;
292 // Energy loss information
294 printf("***************** Energy Loss Information per event (GEV) *****************\n");
295 for(kn=1;kn<fEventEnergy.GetSize();kn++) {
298 fEventEnergy[ndep]=kn;
303 ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
306 fSummEnergy[ndep]=ed;
307 fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero));
312 for(kn=0;kn<(ndep-1)/3+1;kn++) {
314 for(i=0;i<(3<left?3:left);i++) {
316 id=Int_t (fEventEnergy[j]+0.1);
317 printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
322 // Relative energy loss in different detectors
323 printf("******************** Relative Energy Loss per event ********************\n");
324 printf("Total energy loss per event %10.3f GeV\n",edtot);
325 for(kn=0;kn<(ndep-1)/5+1;kn++) {
327 for(i=0;i<(5<left?5:left);i++) {
329 id=Int_t (fEventEnergy[j]+0.1);
330 printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
334 for(kn=0;kn<75;kn++) printf("*");
338 // Reset the TArray's
339 // fEventEnergy.Set(0);
340 // fSummEnergy.Set(0);
341 // fSum2Energy.Set(0);
344 //_____________________________________________________________________________
345 void AliMC::BeginEvent()
348 // Clean-up previous event
352 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
353 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
354 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
355 Info("BeginEvent"," BEGINNING EVENT ");
356 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
357 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
358 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
361 AliRunLoader *runloader=gAlice->GetRunLoader();
363 /*******************************/
364 /* Clean after eventual */
366 /*******************************/
369 //Set the next event in Run Loader -> Cleans trees (TreeK and all trees in detectors),
370 gAlice->SetEventNrInRun(gAlice->GetEventNrInRun()+1);
371 runloader->SetEventNumber(gAlice->GetEventNrInRun());// sets new files, cleans the previous event stuff, if necessary, etc.,
372 if (GetDebug()) Info("BeginEvent","EventNr is %d",gAlice->GetEventNrInRun());
374 fEventEnergy.Reset();
375 // Clean detector information
377 if (runloader->Stack())
378 runloader->Stack()->Reset();//clean stack -> tree is unloaded
380 runloader->MakeStack();//or make a new one
382 if(gAlice->Lego() == 0x0)
384 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(K)");
385 runloader->MakeTree("K");
388 if (GetDebug()) Info("BeginEvent"," gMC->SetStack(fRunLoader->Stack())");
389 gMC->SetStack(gAlice->GetRunLoader()->Stack());//Was in InitMC - but was moved here
390 //because we don't have guarantee that
391 //stack pointer is not going to change from event to event
392 //since it bellobgs to header and is obtained via RunLoader
394 // Reset all Detectors & kinematics & make/reset trees
397 runloader->GetHeader()->Reset(gAlice->GetRunNumber(),gAlice->GetEvNumber(),
398 gAlice->GetEventNrInRun());
399 // fRunLoader->WriteKinematics("OVERWRITE"); is there any reason to rewrite here since MakeTree does so
403 gAlice->Lego()->BeginEvent();
408 if (GetDebug()) Info("BeginEvent"," ResetHits()");
411 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(H)");
412 runloader->MakeTree("H");
414 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTrackRefsContainer()");
415 runloader->MakeTrackRefsContainer();//for insurance
418 //create new branches and SetAdresses
419 TIter next(gAlice->Modules());
421 while((detector = (AliModule*)next()))
423 if (GetDebug()) Info("BeginEvent"," %s->MakeBranch(H)",detector->GetName());
424 detector->MakeBranch("H");
425 if (GetDebug()) Info("BeginEvent"," %s->MakeBranchTR()",detector->GetName());
426 detector->MakeBranchTR();
427 if (GetDebug()) Info("BeginEvent"," %s->SetTreeAddress()",detector->GetName());
428 detector->SetTreeAddress();
432 //_______________________________________________________________________
433 void AliMC::ResetHits()
436 // Reset all Detectors hits
438 TIter next(gAlice->Modules());
440 while((detector = dynamic_cast<AliModule*>(next()))) {
441 detector->ResetHits();
445 //_______________________________________________________________________
446 void AliMC::PostTrack()
448 // Posts tracks for each module
449 TObjArray &dets = *gAlice->Modules();
452 for(Int_t i=0; i<=gAlice->GetNdets(); i++)
453 if((module = dynamic_cast<AliModule*>(dets[i])))
457 //_______________________________________________________________________
458 void AliMC::FinishPrimary()
461 // Called at the end of each primary track
463 AliRunLoader *runloader=gAlice->GetRunLoader();
464 // static Int_t count=0;
465 // const Int_t times=10;
466 // This primary is finished, purify stack
467 runloader->Stack()->PurifyKine();
469 TIter next(gAlice->Modules());
471 while((detector = dynamic_cast<AliModule*>(next()))) {
472 detector->FinishPrimary();
473 AliLoader* loader = detector->GetLoader();
476 TTree* treeH = loader->TreeH();
477 if (treeH) treeH->Fill(); //can be Lego run and treeH can not exist
481 // Write out track references if any
482 if (runloader->TreeTR()) runloader->TreeTR()->Fill();
485 //_______________________________________________________________________
486 void AliMC::FinishEvent()
489 // Called at the end of the event.
493 if(gAlice->Lego()) gAlice->Lego()->FinishEvent();
495 TIter next(gAlice->Modules());
497 while((detector = dynamic_cast<AliModule*>(next()))) {
498 detector->FinishEvent();
501 //Update the energy deposit tables
503 for(i=0;i<fEventEnergy.GetSize();i++)
505 fSummEnergy[i]+=fEventEnergy[i];
506 fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
509 AliRunLoader *runloader=gAlice->GetRunLoader();
511 AliHeader* header = runloader->GetHeader();
512 AliStack* stack = runloader->Stack();
513 if ( (header == 0x0) || (stack == 0x0) )
514 {//check if we got header and stack. If not cry and exit aliroot
515 Fatal("AliRun","Can not get the stack or header from LOADER");
516 return;//never reached
518 // Update Header information
519 header->SetNprimary(stack->GetNprimary());
520 header->SetNtrack(stack->GetNtrack());
523 // Write out the kinematics
524 stack->FinishEvent();
526 // Write out the event Header information
527 TTree* treeE = runloader->TreeE();
530 header->SetStack(stack);
535 Error("FinishEvent","Can not get TreeE from RL");
538 if(gAlice->Lego() == 0x0)
540 runloader->WriteKinematics("OVERWRITE");
541 runloader->WriteTrackRefs("OVERWRITE");
542 runloader->WriteHits("OVERWRITE");
547 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
548 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
549 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
550 Info("FinishEvent"," FINISHING EVENT ");
551 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
552 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
553 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
557 //_______________________________________________________________________
558 void AliMC::Field(const Double_t* x, Double_t* b) const
560 // Calculates field "b" at point "x"
564 //_______________________________________________________________________
569 //=================Create Materials and geometry
571 gMC->DefineParticles(); //Create standard MC particles
573 //Read the cuts for all materials
575 //Build the special IMEDIA table
578 //Compute cross-sections
581 //Write Geometry object to current file.
582 gAlice->GetRunLoader()->WriteGeometry();
584 //Initialise geometry deposition table
585 fEventEnergy.Set(gMC->NofVolumes()+1);
586 fSummEnergy.Set(gMC->NofVolumes()+1);
587 fSum2Energy.Set(gMC->NofVolumes()+1);
590 fMCQA = new AliMCQA(gAlice->GetNdets());
592 // Register MC in configuration
593 AliConfig::Instance()->Add(gMC);
597 //_______________________________________________________________________
598 void AliMC::MediaTable()
601 // Built media table to get from the media number to
605 Int_t kz, nz, idt, lz, i, k, ind;
607 TObjArray &dets = *gAlice->Detectors();
609 Int_t ndets=gAlice->GetNdets();
612 for (kz=0;kz<ndets;kz++) {
613 // If detector is defined
614 if((det=dynamic_cast<AliModule*>(dets[kz]))) {
615 TArrayI &idtmed = *(det->GetIdtmed());
616 for(nz=0;nz<100;nz++) {
617 // Find max and min material number
618 if((idt=idtmed[nz])) {
619 det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
620 det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
623 if(det->LoMedium() > det->HiMedium()) {
627 if(det->HiMedium() > fImedia->GetSize()) {
628 Error("MediaTable","Increase fImedia from %d to %d",
629 fImedia->GetSize(),det->HiMedium());
632 // Tag all materials in rage as belonging to detector kz
633 for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
640 // Print summary table
641 printf(" Traking media ranges:\n");
642 for(i=0;i<(ndets-1)/6+1;i++) {
643 for(k=0;k< (6<ndets-i*6?6:ndets-i*6);k++) {
645 det=dynamic_cast<AliModule*>(dets[ind]);
647 printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
650 printf(" %6s: %3d -> %3d;","NULL",0,0);
656 //_______________________________________________________________________
657 void AliMC::ReadTransPar()
660 // Read filename to set the transport parameters
664 const Int_t kncuts=10;
665 const Int_t knflags=11;
666 const Int_t knpars=kncuts+knflags;
667 const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
668 "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
669 "BREM","COMP","DCAY","DRAY","HADR","LOSS",
670 "MULS","PAIR","PHOT","RAYL"};
676 Int_t i, itmed, iret, ktmed, kz;
679 // See whether the file is there
680 filtmp=gSystem->ExpandPathName(fTransParName.Data());
681 lun=fopen(filtmp,"r");
684 Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
689 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
690 printf(" *%59s\n","*");
691 printf(" * Please check carefully what you are doing!%10s\n","*");
692 printf(" *%59s\n","*");
696 // Initialise cuts and flags
697 for(i=0;i<kncuts;i++) cut[i]=-99;
698 for(i=0;i<knflags;i++) flag[i]=-99;
700 for(i=0;i<256;i++) line[i]='\0';
701 // Read up to the end of line excluded
702 iret=fscanf(lun,"%[^\n]",line);
707 printf(" *%59s\n","*");
708 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
712 // Read the end of line
715 if(line[0]=='*') continue;
717 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",
718 detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
719 &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
720 &flag[8],&flag[9],&flag[10]);
724 Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
727 // Check that the module exist
728 AliModule *mod = gAlice->GetModule(detName);
730 // Get the array of media numbers
731 TArrayI &idtmed = *mod->GetIdtmed();
732 // Check that the tracking medium code is valid
733 if(0<=itmed && itmed < 100) {
736 Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
739 // Set energy thresholds
740 for(kz=0;kz<kncuts;kz++) {
742 if(fDebug) printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
743 kpars[kz],cut[kz],itmed,mod->GetName());
744 gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
747 // Set transport mechanisms
748 for(kz=0;kz<knflags;kz++) {
750 if(fDebug) printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
751 kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
752 gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
756 Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
760 if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
766 //_______________________________________________________________________
767 void AliMC::SetTransPar(const char *filename)
770 // Sets the file name for transport parameters
772 fTransParName = filename;
775 //_______________________________________________________________________
776 void AliMC::Browse(TBrowser *b)
779 // Called when the item "Run" is clicked on the left pane
780 // of the Root browser.
781 // It displays the Root Trees and all detectors.
783 //detectors are in folders anyway
784 b->Add(fMCQA,"AliMCQA");
788 //_______________________________________________________________________
789 void AliMC::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
792 // Add a hit to detector id
794 TObjArray &dets = *gAlice->Modules();
795 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
798 //_______________________________________________________________________
799 void AliMC::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
802 // Add digit to detector id
804 TObjArray &dets = *gAlice->Modules();
805 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
808 //_______________________________________________________________________
809 Int_t AliMC::GetCurrentTrackNumber() const {
811 // Returns current track
813 return gAlice->GetRunLoader()->Stack()->GetCurrentTrackNumber();
816 //_______________________________________________________________________
817 void AliMC::DumpPart (Int_t i) const
820 // Dumps particle i in the stack
822 AliRunLoader * runloader = gAlice->GetRunLoader();
823 if (runloader->Stack())
824 runloader->Stack()->DumpPart(i);
827 //_______________________________________________________________________
828 void AliMC::DumpPStack () const
831 // Dumps the particle stack
833 AliRunLoader * runloader = gAlice->GetRunLoader();
834 if (runloader->Stack())
835 runloader->Stack()->DumpPStack();
838 //_______________________________________________________________________
839 Int_t AliMC::GetNtrack() const {
841 // Returns number of tracks in stack
844 AliRunLoader * runloader = gAlice->GetRunLoader();
845 if (runloader->Stack())
846 ntracks = runloader->Stack()->GetNtrack();
850 //_______________________________________________________________________
851 Int_t AliMC::GetPrimary(Int_t track) const
854 // return number of primary that has generated track
856 Int_t nprimary = -999;
857 AliRunLoader * runloader = gAlice->GetRunLoader();
858 if (runloader->Stack())
859 nprimary = runloader->Stack()->GetPrimary(track);
863 //_______________________________________________________________________
864 TParticle* AliMC::Particle(Int_t i) const
866 // Returns the i-th particle from the stack taking into account
867 // the remaping done by PurifyKine
868 AliRunLoader * runloader = gAlice->GetRunLoader();
870 if (runloader->Stack())
871 return runloader->Stack()->Particle(i);
875 //_______________________________________________________________________
876 TObjArray* AliMC::Particles() const {
878 // Returns pointer to Particles array
880 AliRunLoader * runloader = gAlice->GetRunLoader();
882 if (runloader->Stack())
883 return runloader->Stack()->Particles();
887 //_______________________________________________________________________
888 void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
889 Float_t *vpos, Float_t *polar, Float_t tof,
890 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
894 AliRunLoader * runloader = gAlice->GetRunLoader();
896 if (runloader->Stack())
897 runloader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
898 mech, ntr, weight, is);
901 //_______________________________________________________________________
902 void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg,
903 Double_t px, Double_t py, Double_t pz, Double_t e,
904 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
905 Double_t polx, Double_t poly, Double_t polz,
906 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
910 AliRunLoader * runloader = gAlice->GetRunLoader();
912 if (runloader->Stack())
913 runloader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
914 polx, poly, polz, mech, ntr, weight, is);
917 //_______________________________________________________________________
918 void AliMC::SetHighWaterMark(const Int_t nt)
921 // Set high water mark for last track in event
922 AliRunLoader * runloader = gAlice->GetRunLoader();
924 if (runloader->Stack())
925 runloader->Stack()->SetHighWaterMark(nt);
928 //_______________________________________________________________________
929 void AliMC::KeepTrack(const Int_t track)
934 AliRunLoader * runloader = gAlice->GetRunLoader();
936 if (runloader->Stack())
937 runloader->Stack()->KeepTrack(track);
940 //_______________________________________________________________________
941 void AliMC::FlagTrack(Int_t track)
945 AliRunLoader * runloader = gAlice->GetRunLoader();
947 if (runloader->Stack())
948 runloader->Stack()->FlagTrack(track);
951 //_______________________________________________________________________
952 void AliMC::SetCurrentTrack(Int_t track)
955 // Set current track number
957 AliRunLoader * runloader = gAlice->GetRunLoader();
959 if (runloader->Stack())
960 runloader->Stack()->SetCurrentTrack(track);
963 //_______________________________________________________________________
964 void AliMC::AddTrackReference(Int_t label){
966 // add a trackrefernce to the list
967 if (!fTrackReferences) {
968 cerr<<"Container trackrefernce not active\n";
971 Int_t nref = fTrackReferences->GetEntriesFast();
972 TClonesArray &lref = *fTrackReferences;
973 new(lref[nref]) AliTrackReference(label);
978 //_______________________________________________________________________
979 void AliMC::ResetTrackReferences()
982 // Reset all references
984 if (fTrackReferences) fTrackReferences->Clear();
986 TIter next(gAlice->Modules());
988 while((detector = dynamic_cast<AliModule*>(next()))) {
989 detector->ResetTrackReferences();
993 void AliMC::RemapTrackReferencesIDs(Int_t *map)
996 // Remapping track reference
997 // Called at finish primary
999 if (!fTrackReferences) return;
1000 for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
1001 AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
1003 Int_t newID = map[ref->GetTrack()];
1004 if (newID>=0) ref->SetTrack(newID);
1006 //ref->SetTrack(-1);
1007 ref->SetBit(kNotDeleted,kFALSE);
1008 fTrackReferences->RemoveAt(i);
1012 fTrackReferences->Compress();