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
26 #include <TStopwatch.h>
28 #include <TVirtualMC.h>
30 #include "AliDetector.h"
31 #include "AliGenerator.h"
32 #include "AliHeader.h"
38 #include "AliTrackReference.h"
43 //_______________________________________________________________________
62 //_______________________________________________________________________
63 AliMC::AliMC(const char *name, const char *title) :
64 TVirtualMCApplication(name, title),
72 fImedia(new TArrayI(1000)),
75 fHitLists(new TList()),
76 fTrackReferences(new TClonesArray("AliTrackReference", 100))
79 // Set transport parameters
82 // Prepare the tracking medium lists
83 for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99;
87 //_______________________________________________________________________
88 AliMC::AliMC(const AliMC &mc) :
89 TVirtualMCApplication(mc),
104 // Copy constructor for AliRun
109 //_______________________________________________________________________
117 // Delete track references
118 if (fTrackReferences) {
119 fTrackReferences->Delete();
120 delete fTrackReferences;
121 fTrackReferences = 0;
126 //_______________________________________________________________________
127 void AliMC::Copy(TObject &) const
129 //dummy Copy function
130 Fatal("Copy","Not implemented!\n");
133 //_______________________________________________________________________
134 void AliMC::ConstructGeometry()
137 // Create modules, materials, geometry
141 TIter next(gAlice->Modules());
143 if (GetDebug()) Info("ConstructGeometry","Geometry creation:");
144 while((detector = dynamic_cast<AliModule*>(next()))) {
146 // Initialise detector materials and geometry
147 detector->CreateMaterials();
148 detector->CreateGeometry();
149 printf("%10s R:%.2fs C:%.2fs\n",
150 detector->GetName(),stw.RealTime(),stw.CpuTime());
154 //_______________________________________________________________________
155 void AliMC::InitGeometry()
158 // Initialize detectors and display geometry
161 printf("Initialisation:\n");
163 TIter next(gAlice->Modules());
165 while((detector = dynamic_cast<AliModule*>(next()))) {
167 // Initialise detector and display geometry
169 detector->BuildGeometry();
170 printf("%10s R:%.2fs C:%.2fs\n",
171 detector->GetName(),stw.RealTime(),stw.CpuTime());
176 //_______________________________________________________________________
177 void AliMC::GeneratePrimaries()
180 // Generate primary particles and fill them in the stack.
183 Generator()->Generate();
186 //_______________________________________________________________________
187 void AliMC::SetGenerator(AliGenerator *generator)
190 // Load the event generator
192 if(!fGenerator) fGenerator = generator;
195 //_______________________________________________________________________
196 void AliMC::ResetGenerator(AliGenerator *generator)
199 // Load the event generator
203 Warning("ResetGenerator","Replacing generator %s with %s\n",
204 fGenerator->GetName(),generator->GetName());
206 Warning("ResetGenerator","Replacing generator %s with NULL\n",
207 fGenerator->GetName());
208 fGenerator = generator;
211 //_______________________________________________________________________
212 void AliMC::FinishRun()
214 // Clean generator information
215 if (GetDebug()) Info("FinishRun"," fGenerator->FinishRun()");
216 fGenerator->FinishRun();
218 //Output energy summary tables
220 Info("FinishRun"," EnergySummary()");
226 //_______________________________________________________________________
227 void AliMC::BeginPrimary()
230 // Called at the beginning of each primary track
235 ResetTrackReferences();
239 //_______________________________________________________________________
240 void AliMC::PreTrack()
242 // Actions before the track's transport
243 TObjArray &dets = *gAlice->Modules();
246 for(Int_t i=0; i<=gAlice->GetNdets(); i++)
247 if((module = dynamic_cast<AliModule*>(dets[i])))
253 //_______________________________________________________________________
254 void AliMC::Stepping()
257 // Called at every step during transport
260 Int_t id = DetFromMate(gMC->GetMedium());
264 // --- If lego option, do it and leave
266 gAlice->Lego()->StepManager();
269 //Update energy deposition tables
270 AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
272 // write tracke reference for track which is dissapearing - MI
273 if (gMC->IsTrackDisappeared()) {
274 if (gMC->Etot()>0.05) AddTrackReference(GetCurrentTrackNumber());
277 //Call the appropriate stepping routine;
278 AliModule *det = dynamic_cast<AliModule*>(gAlice->Modules()->At(id));
279 if(det && det->StepManagerIsEnabled()) {
280 fMCQA->StepManager(id);
286 //_______________________________________________________________________
287 void AliMC::EnergySummary()
290 // Print summary of deposited energy
296 Int_t kn, i, left, j, id;
297 const Float_t kzero=0;
298 Int_t ievent=gAlice->GetRunLoader()->GetHeader()->GetEvent()+1;
300 // Energy loss information
302 printf("***************** Energy Loss Information per event (GEV) *****************\n");
303 for(kn=1;kn<fEventEnergy.GetSize();kn++) {
306 fEventEnergy[ndep]=kn;
311 ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
314 fSummEnergy[ndep]=ed;
315 fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero));
320 for(kn=0;kn<(ndep-1)/3+1;kn++) {
322 for(i=0;i<(3<left?3:left);i++) {
324 id=Int_t (fEventEnergy[j]+0.1);
325 printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
330 // Relative energy loss in different detectors
331 printf("******************** Relative Energy Loss per event ********************\n");
332 printf("Total energy loss per event %10.3f GeV\n",edtot);
333 for(kn=0;kn<(ndep-1)/5+1;kn++) {
335 for(i=0;i<(5<left?5:left);i++) {
337 id=Int_t (fEventEnergy[j]+0.1);
338 printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
342 for(kn=0;kn<75;kn++) printf("*");
346 // Reset the TArray's
347 // fEventEnergy.Set(0);
348 // fSummEnergy.Set(0);
349 // fSum2Energy.Set(0);
352 //_____________________________________________________________________________
353 void AliMC::BeginEvent()
356 // Clean-up previous event
360 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
361 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
362 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
363 Info("BeginEvent"," BEGINNING EVENT ");
364 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
365 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
366 Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
369 AliRunLoader *runloader=gAlice->GetRunLoader();
371 /*******************************/
372 /* Clean after eventual */
374 /*******************************/
377 //Set the next event in Run Loader -> Cleans trees (TreeK and all trees in detectors),
378 gAlice->SetEventNrInRun(gAlice->GetEventNrInRun()+1);
379 runloader->SetEventNumber(gAlice->GetEventNrInRun());// sets new files, cleans the previous event stuff, if necessary, etc.,
380 if (GetDebug()) Info("BeginEvent","EventNr is %d",gAlice->GetEventNrInRun());
382 fEventEnergy.Reset();
383 // Clean detector information
385 if (runloader->Stack())
386 runloader->Stack()->Reset();//clean stack -> tree is unloaded
388 runloader->MakeStack();//or make a new one
390 if(gAlice->Lego() == 0x0)
392 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(K)");
393 runloader->MakeTree("K");
396 if (GetDebug()) Info("BeginEvent"," gMC->SetStack(fRunLoader->Stack())");
397 gMC->SetStack(gAlice->GetRunLoader()->Stack());//Was in InitMC - but was moved here
398 //because we don't have guarantee that
399 //stack pointer is not going to change from event to event
400 //since it bellobgs to header and is obtained via RunLoader
402 // Reset all Detectors & kinematics & make/reset trees
405 runloader->GetHeader()->Reset(gAlice->GetRunNumber(),gAlice->GetEvNumber(),
406 gAlice->GetEventNrInRun());
407 // fRunLoader->WriteKinematics("OVERWRITE"); is there any reason to rewrite here since MakeTree does so
411 gAlice->Lego()->BeginEvent();
416 if (GetDebug()) Info("BeginEvent"," ResetHits()");
419 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(H)");
420 runloader->MakeTree("H");
422 if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTrackRefsContainer()");
423 runloader->MakeTrackRefsContainer();//for insurance
426 //create new branches and SetAdresses
427 TIter next(gAlice->Modules());
429 while((detector = (AliModule*)next()))
431 if (GetDebug()) Info("BeginEvent"," %s->MakeBranch(H)",detector->GetName());
432 detector->MakeBranch("H");
433 if (GetDebug()) Info("BeginEvent"," %s->MakeBranchTR()",detector->GetName());
434 detector->MakeBranchTR();
435 if (GetDebug()) Info("BeginEvent"," %s->SetTreeAddress()",detector->GetName());
436 detector->SetTreeAddress();
438 // make branch for AliRun track References
439 TTree * treeTR = runloader->TreeTR();
441 // make branch for central track references
442 if (!fTrackReferences) fTrackReferences = new TClonesArray("AliTrackReference",0);
444 branch = treeTR->Branch("AliRun",&fTrackReferences);
445 branch->SetAddress(&fTrackReferences);
450 //_______________________________________________________________________
451 void AliMC::ResetHits()
454 // Reset all Detectors hits
456 TIter next(gAlice->Modules());
458 while((detector = dynamic_cast<AliModule*>(next()))) {
459 detector->ResetHits();
463 //_______________________________________________________________________
464 void AliMC::PostTrack()
466 // Posts tracks for each module
467 TObjArray &dets = *gAlice->Modules();
470 for(Int_t i=0; i<=gAlice->GetNdets(); i++)
471 if((module = dynamic_cast<AliModule*>(dets[i])))
475 //_______________________________________________________________________
476 void AliMC::FinishPrimary()
479 // Called at the end of each primary track
481 AliRunLoader *runloader=gAlice->GetRunLoader();
482 // static Int_t count=0;
483 // const Int_t times=10;
484 // This primary is finished, purify stack
485 #if ROOT_VERSION_CODE > 262152
486 if (!(gMC->SecondariesAreOrdered()))
487 runloader->Stack()->ReorderKine();
489 runloader->Stack()->PurifyKine();
491 TIter next(gAlice->Modules());
493 while((detector = dynamic_cast<AliModule*>(next()))) {
494 detector->FinishPrimary();
495 AliLoader* loader = detector->GetLoader();
498 TTree* treeH = loader->TreeH();
499 if (treeH) treeH->Fill(); //can be Lego run and treeH can not exist
503 // Write out track references if any
504 if (runloader->TreeTR()) runloader->TreeTR()->Fill();
507 //_______________________________________________________________________
508 void AliMC::FinishEvent()
511 // Called at the end of the event.
515 if(gAlice->Lego()) gAlice->Lego()->FinishEvent();
517 TIter next(gAlice->Modules());
519 while((detector = dynamic_cast<AliModule*>(next()))) {
520 detector->FinishEvent();
523 //Update the energy deposit tables
525 for(i=0;i<fEventEnergy.GetSize();i++)
527 fSummEnergy[i]+=fEventEnergy[i];
528 fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
531 AliRunLoader *runloader=gAlice->GetRunLoader();
533 AliHeader* header = runloader->GetHeader();
534 AliStack* stack = runloader->Stack();
535 if ( (header == 0x0) || (stack == 0x0) )
536 {//check if we got header and stack. If not cry and exit aliroot
537 Fatal("AliRun","Can not get the stack or header from LOADER");
538 return;//never reached
540 // Update Header information
541 header->SetNprimary(stack->GetNprimary());
542 header->SetNtrack(stack->GetNtrack());
545 // Write out the kinematics
546 stack->FinishEvent();
548 // Write out the event Header information
549 TTree* treeE = runloader->TreeE();
552 header->SetStack(stack);
557 Error("FinishEvent","Can not get TreeE from RL");
560 if(gAlice->Lego() == 0x0)
562 runloader->WriteKinematics("OVERWRITE");
563 runloader->WriteTrackRefs("OVERWRITE");
564 runloader->WriteHits("OVERWRITE");
569 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
570 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
571 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
572 Info("FinishEvent"," FINISHING EVENT ");
573 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
574 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
575 Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
579 //_______________________________________________________________________
580 void AliMC::Field(const Double_t* x, Double_t* b) const
582 // Calculates field "b" at point "x"
586 //_______________________________________________________________________
591 //=================Create Materials and geometry
593 //Read the cuts for all materials
595 //Build the special IMEDIA table
598 //Compute cross-sections
601 //Write Geometry object to current file.
602 gAlice->GetRunLoader()->WriteGeometry();
604 //Initialise geometry deposition table
605 fEventEnergy.Set(gMC->NofVolumes()+1);
606 fSummEnergy.Set(gMC->NofVolumes()+1);
607 fSum2Energy.Set(gMC->NofVolumes()+1);
610 fMCQA = new AliMCQA(gAlice->GetNdets());
612 // Register MC in configuration
613 AliConfig::Instance()->Add(gMC);
617 //_______________________________________________________________________
618 void AliMC::MediaTable()
621 // Built media table to get from the media number to
625 Int_t kz, nz, idt, lz, i, k, ind;
627 TObjArray &dets = *gAlice->Detectors();
629 Int_t ndets=gAlice->GetNdets();
632 for (kz=0;kz<ndets;kz++) {
633 // If detector is defined
634 if((det=dynamic_cast<AliModule*>(dets[kz]))) {
635 TArrayI &idtmed = *(det->GetIdtmed());
636 for(nz=0;nz<100;nz++) {
637 // Find max and min material number
638 if((idt=idtmed[nz])) {
639 det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
640 det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
643 if(det->LoMedium() > det->HiMedium()) {
647 if(det->HiMedium() > fImedia->GetSize()) {
648 Error("MediaTable","Increase fImedia from %d to %d",
649 fImedia->GetSize(),det->HiMedium());
652 // Tag all materials in rage as belonging to detector kz
653 for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
660 // Print summary table
661 printf(" Traking media ranges:\n");
662 for(i=0;i<(ndets-1)/6+1;i++) {
663 for(k=0;k< (6<ndets-i*6?6:ndets-i*6);k++) {
665 det=dynamic_cast<AliModule*>(dets[ind]);
667 printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
670 printf(" %6s: %3d -> %3d;","NULL",0,0);
676 //_______________________________________________________________________
677 void AliMC::ReadTransPar()
680 // Read filename to set the transport parameters
684 const Int_t kncuts=10;
685 const Int_t knflags=11;
686 const Int_t knpars=kncuts+knflags;
687 const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
688 "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
689 "BREM","COMP","DCAY","DRAY","HADR","LOSS",
690 "MULS","PAIR","PHOT","RAYL"};
696 Int_t i, itmed, iret, ktmed, kz;
699 // See whether the file is there
700 filtmp=gSystem->ExpandPathName(fTransParName.Data());
701 lun=fopen(filtmp,"r");
704 Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
709 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
710 printf(" *%59s\n","*");
711 printf(" * Please check carefully what you are doing!%10s\n","*");
712 printf(" *%59s\n","*");
716 // Initialise cuts and flags
717 for(i=0;i<kncuts;i++) cut[i]=-99;
718 for(i=0;i<knflags;i++) flag[i]=-99;
720 for(i=0;i<256;i++) line[i]='\0';
721 // Read up to the end of line excluded
722 iret=fscanf(lun,"%[^\n]",line);
727 printf(" *%59s\n","*");
728 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
732 // Read the end of line
735 if(line[0]=='*') continue;
737 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",
738 detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
739 &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
740 &flag[8],&flag[9],&flag[10]);
744 Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
747 // Check that the module exist
748 AliModule *mod = gAlice->GetModule(detName);
750 // Get the array of media numbers
751 TArrayI &idtmed = *mod->GetIdtmed();
752 // Check that the tracking medium code is valid
753 if(0<=itmed && itmed < 100) {
756 Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
759 // Set energy thresholds
760 for(kz=0;kz<kncuts;kz++) {
762 if(fDebug) printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
763 kpars[kz],cut[kz],itmed,mod->GetName());
764 gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
767 // Set transport mechanisms
768 for(kz=0;kz<knflags;kz++) {
770 if(fDebug) printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
771 kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
772 gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
776 Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
780 if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
786 //_______________________________________________________________________
787 void AliMC::SetTransPar(const char *filename)
790 // Sets the file name for transport parameters
792 fTransParName = filename;
795 //_______________________________________________________________________
796 void AliMC::Browse(TBrowser *b)
799 // Called when the item "Run" is clicked on the left pane
800 // of the Root browser.
801 // It displays the Root Trees and all detectors.
803 //detectors are in folders anyway
804 b->Add(fMCQA,"AliMCQA");
808 //_______________________________________________________________________
809 void AliMC::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
812 // Add a hit to detector id
814 TObjArray &dets = *gAlice->Modules();
815 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
818 //_______________________________________________________________________
819 void AliMC::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
822 // Add digit to detector id
824 TObjArray &dets = *gAlice->Modules();
825 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
828 //_______________________________________________________________________
829 Int_t AliMC::GetCurrentTrackNumber() const {
831 // Returns current track
833 return gAlice->GetRunLoader()->Stack()->GetCurrentTrackNumber();
836 //_______________________________________________________________________
837 void AliMC::DumpPart (Int_t i) const
840 // Dumps particle i in the stack
842 AliRunLoader * runloader = gAlice->GetRunLoader();
843 if (runloader->Stack())
844 runloader->Stack()->DumpPart(i);
847 //_______________________________________________________________________
848 void AliMC::DumpPStack () const
851 // Dumps the particle stack
853 AliRunLoader * runloader = gAlice->GetRunLoader();
854 if (runloader->Stack())
855 runloader->Stack()->DumpPStack();
858 //_______________________________________________________________________
859 Int_t AliMC::GetNtrack() const {
861 // Returns number of tracks in stack
864 AliRunLoader * runloader = gAlice->GetRunLoader();
865 if (runloader->Stack())
866 ntracks = runloader->Stack()->GetNtrack();
870 //_______________________________________________________________________
871 Int_t AliMC::GetPrimary(Int_t track) const
874 // return number of primary that has generated track
876 Int_t nprimary = -999;
877 AliRunLoader * runloader = gAlice->GetRunLoader();
878 if (runloader->Stack())
879 nprimary = runloader->Stack()->GetPrimary(track);
883 //_______________________________________________________________________
884 TParticle* AliMC::Particle(Int_t i) const
886 // Returns the i-th particle from the stack taking into account
887 // the remaping done by PurifyKine
888 AliRunLoader * runloader = gAlice->GetRunLoader();
890 if (runloader->Stack())
891 return runloader->Stack()->Particle(i);
895 //_______________________________________________________________________
896 TObjArray* AliMC::Particles() const {
898 // Returns pointer to Particles array
900 AliRunLoader * runloader = gAlice->GetRunLoader();
902 if (runloader->Stack())
903 return runloader->Stack()->Particles();
907 //_______________________________________________________________________
908 void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
909 Float_t *vpos, Float_t *polar, Float_t tof,
910 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) const
914 AliRunLoader * runloader = gAlice->GetRunLoader();
916 if (runloader->Stack())
917 runloader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
918 mech, ntr, weight, is);
921 //_______________________________________________________________________
922 void AliMC::PushTrack(Int_t done, Int_t parent, Int_t pdg,
923 Double_t px, Double_t py, Double_t pz, Double_t e,
924 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
925 Double_t polx, Double_t poly, Double_t polz,
926 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) const
930 AliRunLoader * runloader = gAlice->GetRunLoader();
932 if (runloader->Stack())
933 runloader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
934 polx, poly, polz, mech, ntr, weight, is);
937 //_______________________________________________________________________
938 void AliMC::SetHighWaterMark(Int_t nt) const
941 // Set high water mark for last track in event
942 AliRunLoader * runloader = gAlice->GetRunLoader();
944 if (runloader->Stack())
945 runloader->Stack()->SetHighWaterMark(nt);
948 //_______________________________________________________________________
949 void AliMC::KeepTrack(Int_t track) const
954 AliRunLoader * runloader = gAlice->GetRunLoader();
956 if (runloader->Stack())
957 runloader->Stack()->KeepTrack(track);
960 //_______________________________________________________________________
961 void AliMC::FlagTrack(Int_t track) const
965 AliRunLoader * runloader = gAlice->GetRunLoader();
967 if (runloader->Stack())
968 runloader->Stack()->FlagTrack(track);
971 //_______________________________________________________________________
972 void AliMC::SetCurrentTrack(Int_t track) const
975 // Set current track number
977 AliRunLoader * runloader = gAlice->GetRunLoader();
979 if (runloader->Stack())
980 runloader->Stack()->SetCurrentTrack(track);
983 //_______________________________________________________________________
984 void AliMC::AddTrackReference(Int_t label){
986 // add a trackrefernce to the list
987 if (!fTrackReferences) {
988 cerr<<"Container trackrefernce not active\n";
991 Int_t nref = fTrackReferences->GetEntriesFast();
992 TClonesArray &lref = *fTrackReferences;
993 new(lref[nref]) AliTrackReference(label);
998 //_______________________________________________________________________
999 void AliMC::ResetTrackReferences()
1002 // Reset all references
1004 if (fTrackReferences) fTrackReferences->Clear();
1006 TIter next(gAlice->Modules());
1007 AliModule *detector;
1008 while((detector = dynamic_cast<AliModule*>(next()))) {
1009 detector->ResetTrackReferences();
1013 void AliMC::RemapTrackReferencesIDs(Int_t *map)
1016 // Remapping track reference
1017 // Called at finish primary
1019 if (!fTrackReferences) return;
1020 for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
1021 AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
1023 Int_t newID = map[ref->GetTrack()];
1024 if (newID>=0) ref->SetTrack(newID);
1026 //ref->SetTrack(-1);
1027 ref->SetBit(kNotDeleted,kFALSE);
1028 fTrackReferences->RemoveAt(i);
1032 fTrackReferences->Compress();