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 Revision 1.52 2001/02/05 16:22:25 buncic
19 Added TreeS to GetEvent().
21 Revision 1.51 2001/02/02 15:16:20 morsch
22 SetHighWaterMark method added to mark last particle in event.
24 Revision 1.50 2001/01/27 10:32:00 hristov
25 Leave the loop when primaries are filled (I.Hrivnacova)
27 Revision 1.49 2001/01/26 19:58:48 hristov
28 Major upgrade of AliRoot code
30 Revision 1.48 2001/01/17 10:50:50 hristov
31 Corrections to destructors
33 Revision 1.47 2000/12/18 10:44:01 morsch
34 Possibility to set field map by passing pointer to objet of type AliMagF via
37 gAlice->SetField(new AliMagFCM("Map2", "$(ALICE_ROOT)/data/field01.dat",2,1.,10.));
39 Revision 1.46 2000/12/14 19:29:27 fca
40 galice.cuts was not read any more
42 Revision 1.45 2000/11/30 07:12:49 alibrary
43 Introducing new Rndm and QA classes
45 Revision 1.44 2000/10/26 13:58:59 morsch
46 Add possibility to choose the lego generator (of type AliGeneratorLego or derived) when running
47 RunLego(). Default is the base class AliGeneratorLego.
49 Revision 1.43 2000/10/09 09:43:17 fca
50 Special remapping of hits for TPC and TRD. End-of-primary action introduced
52 Revision 1.42 2000/10/02 21:28:14 fca
53 Removal of useless dependecies via forward declarations
55 Revision 1.41 2000/07/13 16:19:09 fca
56 Mainly coding conventions + some small bug fixes
58 Revision 1.40 2000/07/12 08:56:25 fca
59 Coding convention correction and warning removal
61 Revision 1.39 2000/07/11 18:24:59 fca
62 Coding convention corrections + few minor bug fixes
64 Revision 1.38 2000/06/20 13:05:45 fca
65 Writing down the TREE headers before job starts
67 Revision 1.37 2000/06/09 20:05:11 morsch
68 Introduce possibility to chose magnetic field version 3: AliMagFDM + field02.dat
70 Revision 1.36 2000/06/08 14:03:58 hristov
71 Only one initializer for a default argument
73 Revision 1.35 2000/06/07 10:13:14 hristov
74 Delete only existent objects.
76 Revision 1.34 2000/05/18 10:45:38 fca
77 Delete Particle Factory properly
79 Revision 1.33 2000/05/16 13:10:40 fca
80 New method IsNewTrack and fix for a problem in Father-Daughter relations
82 Revision 1.32 2000/04/27 10:38:21 fca
83 Correct termination of Lego Run and introduce Lego getter in AliRun
85 Revision 1.31 2000/04/26 10:17:32 fca
86 Changes in Lego for G4 compatibility
88 Revision 1.30 2000/04/18 19:11:40 fca
89 Introduce variable Config.C function signature
91 Revision 1.29 2000/04/07 11:12:34 fca
92 G4 compatibility changes
94 Revision 1.28 2000/04/05 06:51:06 fca
95 Workaround for an HP compiler problem
97 Revision 1.27 2000/03/22 18:08:07 fca
98 Rationalisation of the virtual MC interfaces
100 Revision 1.26 2000/03/22 13:42:26 fca
101 SetGenerator does not replace an existing generator, ResetGenerator does
103 Revision 1.25 2000/02/23 16:25:22 fca
104 AliVMC and AliGeant3 classes introduced
105 ReadEuclid moved from AliRun to AliModule
107 Revision 1.24 2000/01/19 17:17:20 fca
108 Introducing a list of lists of hits -- more hits allowed for detector now
110 Revision 1.23 1999/12/03 11:14:31 fca
111 Fixing previous wrong checking
113 Revision 1.21 1999/11/25 10:40:08 fca
114 Fixing daughters information also in primary tracks
116 Revision 1.20 1999/10/04 18:08:49 fca
117 Adding protection against inconsistent Euclid files
119 Revision 1.19 1999/09/29 07:50:40 fca
120 Introduction of the Copyright and cvs Log
124 ///////////////////////////////////////////////////////////////////////////////
126 // Control class for Alice C++ //
127 // Only one single instance of this class exists. //
128 // The object is created in main program aliroot //
129 // and is pointed by the global gAlice. //
131 // -Supports the list of all Alice Detectors (fModules). //
132 // -Supports the list of particles (fParticles). //
133 // -Supports the Trees. //
134 // -Supports the geometry. //
135 // -Supports the event display. //
138 <img src="picts/AliRunClass.gif">
143 <img src="picts/alirun.gif">
147 ///////////////////////////////////////////////////////////////////////////////
152 #include <iostream.h>
160 #include <TObjectTable.h>
162 #include <TGeometry.h>
164 #include "TBrowser.h"
166 #include "TParticle.h"
168 #include "AliDisplay.h"
171 #include "AliMagFC.h"
172 #include "AliMagFCM.h"
173 #include "AliMagFDM.h"
175 #include "TRandom3.h"
177 #include "AliGenerator.h"
178 #include "AliLegoGenerator.h"
180 #include "AliDetector.h"
184 static AliHeader *gAliHeader;
188 //_____________________________________________________________________________
192 // Default constructor for AliRun
217 fPDGDB = 0; //Particle factory object!
219 fConfigFunction = "\0";
222 fTransParName = "\0";
223 fBaseFileName = "\0";
225 fParticleMap = new TObjArray(10000);
228 //_____________________________________________________________________________
229 AliRun::AliRun(const char *name, const char *title)
233 // Constructor for the main processor.
234 // Creates the geometry
235 // Creates the list of Detectors.
236 // Creates the list of particles.
253 fConfigFunction = "Config();";
255 // Set random number generator
256 gRandom = fRandom = new TRandom3();
258 if (gSystem->Getenv("CONFIG_SEED")) {
259 gRandom->SetSeed((UInt_t)atoi(gSystem->Getenv("CONFIG_SEED")));
262 gROOT->GetListOfBrowsables()->Add(this,name);
264 // create the support list for the various Detectors
265 fModules = new TObjArray(77);
267 // Create the TNode geometry for the event display
269 BuildSimpleGeometry();
279 // Create the particle stack
280 fParticles = new TClonesArray("TParticle",1000);
284 // Create default mag field
289 // Prepare the tracking medium lists
290 fImedia = new TArrayI(1000);
291 for(i=0;i<1000;i++) (*fImedia)[i]=-99;
294 fPDGDB = TDatabasePDG::Instance(); //Particle factory object!
296 // Create HitLists list
297 fHitLists = new TList();
300 fBaseFileName = "\0";
302 fParticleMap = new TObjArray(10000);
306 //_____________________________________________________________________________
310 // Default AliRun destructor
330 fParticles->Delete();
338 //_____________________________________________________________________________
339 void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
342 // Add a hit to detector id
344 TObjArray &dets = *fModules;
345 if(dets[id]) ((AliModule*) dets[id])->AddHit(track,vol,hits);
348 //_____________________________________________________________________________
349 void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
352 // Add digit to detector id
354 TObjArray &dets = *fModules;
355 if(dets[id]) ((AliModule*) dets[id])->AddDigit(tracks,digits);
358 //_____________________________________________________________________________
359 void AliRun::Browse(TBrowser *b)
362 // Called when the item "Run" is clicked on the left pane
363 // of the Root browser.
364 // It displays the Root Trees and all detectors.
366 if (fTreeK) b->Add(fTreeK,fTreeK->GetName());
367 if (fTreeH) b->Add(fTreeH,fTreeH->GetName());
368 if (fTreeD) b->Add(fTreeD,fTreeD->GetName());
369 if (fTreeE) b->Add(fTreeE,fTreeE->GetName());
370 if (fTreeR) b->Add(fTreeR,fTreeR->GetName());
371 if (fTreeS) b->Add(fTreeS,fTreeS->GetName());
373 TIter next(fModules);
375 while((detector = (AliModule*)next())) {
376 b->Add(detector,detector->GetName());
378 b->Add(fMCQA,"AliMCQA");
381 //_____________________________________________________________________________
385 // Initialize Alice geometry
390 //_____________________________________________________________________________
391 void AliRun::BuildSimpleGeometry()
394 // Create a simple TNode geometry used by Root display engine
396 // Initialise geometry
398 fGeometry = new TGeometry("AliceGeom","Galice Geometry for Hits");
399 new TMaterial("void","Vacuum",0,0,0); //Everything is void
400 TBRIK *brik = new TBRIK("S_alice","alice volume","void",2000,2000,3000);
401 brik->SetVisibility(0);
402 new TNode("alice","alice","S_alice");
405 //_____________________________________________________________________________
406 void AliRun::CleanDetectors()
409 // Clean Detectors at the end of event
411 TIter next(fModules);
413 while((detector = (AliModule*)next())) {
414 detector->FinishEvent();
418 //_____________________________________________________________________________
419 void AliRun::CleanParents()
422 // Clean Particles stack.
423 // Set parent/daughter relations
425 TObjArray &particles = *fParticleMap;
428 for(i=0; i<fHgwmk+1; i++) {
429 part = (TParticle *)particles.At(i);
430 if(part) if(!part->TestBit(kDaughtersBit)) {
431 part->SetFirstDaughter(-1);
432 part->SetLastDaughter(-1);
437 //_____________________________________________________________________________
438 Int_t AliRun::DistancetoPrimitive(Int_t, Int_t)
441 // Return the distance from the mouse to the AliRun object
447 //_____________________________________________________________________________
448 void AliRun::DumpPart (Int_t i) const
451 // Dumps particle i in the stack
453 ((TParticle*) (*fParticleMap)[i])->Print();
456 //_____________________________________________________________________________
457 void AliRun::DumpPStack () const
460 // Dumps the particle stack
462 TObjArray &particles = *fParticleMap;
464 "\n\n=======================================================================\n");
465 for (Int_t i=0;i<fNtrack;i++)
467 printf("-> %d ",i); ((TParticle*) particles[i])->Print();
468 printf("--------------------------------------------------------------\n");
471 "\n=======================================================================\n\n");
474 void AliRun::SetField(AliMagF* magField)
476 // Set Magnetic Field Map
481 //_____________________________________________________________________________
482 void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
483 Float_t maxField, char* filename)
486 // Set magnetic field parameters
487 // type Magnetic field transport flag 0=no field, 2=helix, 3=Runge Kutta
488 // version Magnetic field map version (only 1 active now)
489 // scale Scale factor for the magnetic field
490 // maxField Maximum value for the magnetic field
493 // --- Sanity check on mag field flags
494 if(fField) delete fField;
496 fField = new AliMagFC("Map1"," ",type,scale,maxField);
497 } else if(version<=2) {
498 fField = new AliMagFCM("Map2-3",filename,type,scale,maxField);
500 } else if(version==3) {
501 fField = new AliMagFDM("Map4",filename,type,scale,maxField);
504 Warning("SetField","Invalid map %d\n",version);
508 //_____________________________________________________________________________
509 void AliRun::PreTrack()
511 TObjArray &dets = *fModules;
514 for(Int_t i=0; i<=fNdets; i++)
515 if((module = (AliModule*)dets[i]))
521 //_____________________________________________________________________________
522 void AliRun::PostTrack()
524 TObjArray &dets = *fModules;
527 for(Int_t i=0; i<=fNdets; i++)
528 if((module = (AliModule*)dets[i]))
532 //_____________________________________________________________________________
533 void AliRun::FinishPrimary()
536 // Called at the end of each primary track
539 // static Int_t count=0;
540 // const Int_t times=10;
541 // This primary is finished, purify stack
544 TIter next(fModules);
546 while((detector = (AliModule*)next())) {
547 detector->FinishPrimary();
550 // Write out hits if any
551 if (gAlice->TreeH()) {
552 gAlice->TreeH()->Fill();
559 // if(++count%times==1) gObjectTable->Print();
562 //_____________________________________________________________________________
563 void AliRun::FinishEvent()
566 // Called at the end of the event.
570 if(fLego) fLego->FinishEvent();
572 //Update the energy deposit tables
574 for(i=0;i<fEventEnergy.GetSize();i++) {
575 fSummEnergy[i]+=fEventEnergy[i];
576 fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
578 fEventEnergy.Reset();
580 // Clean detector information
583 // Write out the kinematics
587 Bool_t allFilled = kFALSE;
589 for(i=0; i<fHgwmk+1; ++i) if((part=fParticleMap->At(i))) {
590 fParticleBuffer = (TParticle*) part;
591 fParticleFileMap[i]= (Int_t) fTreeK->GetEntries();
593 (*fParticleMap)[i]=0;
595 // When all primaries were filled no particle!=0
596 // should be left => to be removed later.
597 if (allFilled) printf("Why != 0 part # %d?\n",i);
600 // // printf("Why = 0 part # %d?\n",i); => We know.
602 // we don't break now in order to be sure there is no
603 // particle !=0 left.
604 // To be removed later and replaced with break.
605 if(!allFilled) allFilled = kTRUE;
609 // Write out the digits
620 // Write out reconstructed clusters
625 // Write out the event Header information
626 if (fTreeE) fTreeE->Fill();
631 // Write Tree headers
632 if (fTreeK) fTreeK->Write(0,TObject::kOverwrite);
633 if (fTreeH) fTreeH->Write(0,TObject::kOverwrite);
634 if (fTreeD) fTreeD->Write(0,TObject::kOverwrite);
635 if (fTreeR) fTreeR->Write(0,TObject::kOverwrite);
636 if (fTreeS) fTreeS->Write(0,TObject::kOverwrite);
641 //_____________________________________________________________________________
642 void AliRun::FinishRun()
645 // Called at the end of the run.
649 if(fLego) fLego->FinishRun();
651 // Clean detector information
652 TIter next(fModules);
654 while((detector = (AliModule*)next())) {
655 detector->FinishRun();
658 //Output energy summary tables
661 TFile *file = fTreeE->GetCurrentFile();
665 fTreeE->Write(0,TObject::kOverwrite);
667 // Write AliRun info and all detectors parameters
670 // Clean tree information
672 delete fTreeK; fTreeK = 0;
675 delete fTreeH; fTreeH = 0;
678 delete fTreeD; fTreeD = 0;
681 delete fTreeR; fTreeR = 0;
684 delete fTreeE; fTreeE = 0;
691 //_____________________________________________________________________________
692 void AliRun::FlagTrack(Int_t track)
695 // Flags a track and all its family tree to be kept
702 particle=(TParticle*)fParticleMap->At(curr);
704 // If the particle is flagged the three from here upward is saved already
705 if(particle->TestBit(kKeepBit)) return;
707 // Save this particle
708 particle->SetBit(kKeepBit);
710 // Move to father if any
711 if((curr=particle->GetFirstMother())==-1) return;
715 //_____________________________________________________________________________
716 void AliRun::EnergySummary()
719 // Print summary of deposited energy
725 Int_t kn, i, left, j, id;
726 const Float_t kzero=0;
727 Int_t ievent=fHeader.GetEvent()+1;
729 // Energy loss information
731 printf("***************** Energy Loss Information per event (GEV) *****************\n");
732 for(kn=1;kn<fEventEnergy.GetSize();kn++) {
735 fEventEnergy[ndep]=kn;
740 ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
743 fSummEnergy[ndep]=ed;
744 fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,kzero));
749 for(kn=0;kn<(ndep-1)/3+1;kn++) {
751 for(i=0;i<(3<left?3:left);i++) {
753 id=Int_t (fEventEnergy[j]+0.1);
754 printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
759 // Relative energy loss in different detectors
760 printf("******************** Relative Energy Loss per event ********************\n");
761 printf("Total energy loss per event %10.3f GeV\n",edtot);
762 for(kn=0;kn<(ndep-1)/5+1;kn++) {
764 for(i=0;i<(5<left?5:left);i++) {
766 id=Int_t (fEventEnergy[j]+0.1);
767 printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
771 for(kn=0;kn<75;kn++) printf("*");
775 // Reset the TArray's
776 // fEventEnergy.Set(0);
777 // fSummEnergy.Set(0);
778 // fSum2Energy.Set(0);
781 //_____________________________________________________________________________
782 AliModule *AliRun::GetModule(const char *name) const
785 // Return pointer to detector from name
787 return (AliModule*)fModules->FindObject(name);
790 //_____________________________________________________________________________
791 AliDetector *AliRun::GetDetector(const char *name) const
794 // Return pointer to detector from name
796 return (AliDetector*)fModules->FindObject(name);
799 //_____________________________________________________________________________
800 Int_t AliRun::GetModuleID(const char *name) const
803 // Return galice internal detector identifier from name
806 TObject *mod=fModules->FindObject(name);
807 if(mod) i=fModules->IndexOf(mod);
811 //_____________________________________________________________________________
812 Int_t AliRun::GetEvent(Int_t event)
815 // Connect the Trees Kinematics and Hits for event # event
816 // Set branch addresses
819 // Reset existing structures
825 // Delete Trees already connected
826 if (fTreeK) delete fTreeK;
827 if (fTreeH) delete fTreeH;
828 if (fTreeD) delete fTreeD;
829 if (fTreeR) delete fTreeR;
830 if (fTreeS) delete fTreeS;
832 // Get header from file
833 if(fTreeE) fTreeE->GetEntry(event);
834 else Error("GetEvent","Cannot file Header Tree\n");
835 TFile *file = fTreeE->GetCurrentFile();
839 // Get Kine Tree from file
841 sprintf(treeName,"TreeK%d",event);
842 fTreeK = (TTree*)gDirectory->Get(treeName);
843 if (fTreeK) fTreeK->SetBranchAddress("Particles", &fParticleBuffer);
844 else Error("GetEvent","cannot find Kine Tree for event:%d\n",event);
845 // Create the particle stack
846 if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
847 // Build the pointer list
849 fParticleMap->Clear();
850 fParticleMap->Expand(fTreeK->GetEntries());
852 fParticleMap = new TObjArray(fTreeK->GetEntries());
856 // Get Hits Tree header from file
857 sprintf(treeName,"TreeH%d",event);
858 fTreeH = (TTree*)gDirectory->Get(treeName);
860 Error("GetEvent","cannot find Hits Tree for event:%d\n",event);
865 // Get Digits Tree header from file
866 sprintf(treeName,"TreeD%d",event);
867 fTreeD = (TTree*)gDirectory->Get(treeName);
869 // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
874 // Get SDigits Tree header from file
875 sprintf(treeName,"TreeS%d",event);
876 fTreeS = (TTree*)gDirectory->Get(treeName);
878 // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event);
883 // Get Reconstruct Tree header from file
884 sprintf(treeName,"TreeR%d",event);
885 fTreeR = (TTree*)gDirectory->Get(treeName);
887 // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event);
892 // Set Trees branch addresses
893 TIter next(fModules);
895 while((detector = (AliModule*)next())) {
896 detector->SetTreeAddress();
899 fNtrack = Int_t (fTreeK->GetEntries());
903 //_____________________________________________________________________________
904 TGeometry *AliRun::GetGeometry()
907 // Import Alice geometry from current file
908 // Return pointer to geometry object
910 if (!fGeometry) fGeometry = (TGeometry*)gDirectory->Get("AliceGeom");
912 // Unlink and relink nodes in detectors
913 // This is bad and there must be a better way...
916 TIter next(fModules);
918 while((detector = (AliModule*)next())) {
919 TList *dnodes=detector->Nodes();
922 for ( j=0; j<dnodes->GetSize(); j++) {
923 node = (TNode*) dnodes->At(j);
924 node1 = fGeometry->GetNode(node->GetName());
925 dnodes->Remove(node);
926 dnodes->AddAt(node1,j);
932 //_____________________________________________________________________________
933 void AliRun::GetNextTrack(Int_t &mtrack, Int_t &ipart, Float_t *pmom,
934 Float_t &e, Float_t *vpos, Float_t *polar,
938 // Return next track from stack of particles
943 for(Int_t i=fNtrack-1; i>=0; i--) {
944 track=(TParticle*) fParticleMap->At(i);
945 if(track) if(!track->TestBit(kDoneBit)) {
947 // The track exists and has not yet been processed
949 ipart=track->GetPdgCode();
957 track->GetPolarisation(pol);
962 track->SetBit(kDoneBit);
968 // stop and start timer when we start a primary track
969 Int_t nprimaries = fHeader.GetNprimary();
970 if (fCurrent >= nprimaries) return;
971 if (fCurrent < nprimaries-1) {
973 track=(TParticle*) fParticleMap->At(fCurrent+1);
974 // track->SetProcessTime(fTimer.CpuTime());
979 //_____________________________________________________________________________
980 Int_t AliRun::GetPrimary(Int_t track) const
983 // return number of primary that has generated track
991 part = (TParticle *)fParticleMap->At(current);
992 parent=part->GetFirstMother();
993 if(parent<0) return current;
997 //_____________________________________________________________________________
998 void AliRun::InitMC(const char *setup)
1001 // Initialize the Alice setup
1005 Warning("Init","Cannot initialise AliRun twice!\n");
1009 OpenBaseFile("recreate");
1011 gROOT->LoadMacro(setup);
1012 gInterpreter->ProcessLine(fConfigFunction.Data());
1015 gMC->DefineParticles(); //Create standard MC particles
1017 TObject *objfirst, *objlast;
1019 fNdets = fModules->GetLast()+1;
1022 //=================Create Materials and geometry
1025 // Added also after in case of interactive initialisation of modules
1026 fNdets = fModules->GetLast()+1;
1028 TIter next(fModules);
1029 AliModule *detector;
1030 while((detector = (AliModule*)next())) {
1031 detector->SetTreeAddress();
1032 objlast = gDirectory->GetList()->Last();
1034 // Add Detector histograms in Detector list of histograms
1035 if (objlast) objfirst = gDirectory->GetList()->After(objlast);
1036 else objfirst = gDirectory->GetList()->First();
1038 detector->Histograms()->Add(objfirst);
1039 objfirst = gDirectory->GetList()->After(objfirst);
1042 ReadTransPar(); //Read the cuts for all materials
1044 MediaTable(); //Build the special IMEDIA table
1046 //Initialise geometry deposition table
1047 fEventEnergy.Set(gMC->NofVolumes()+1);
1048 fSummEnergy.Set(gMC->NofVolumes()+1);
1049 fSum2Energy.Set(gMC->NofVolumes()+1);
1051 //Compute cross-sections
1052 gMC->BuildPhysics();
1054 //Write Geometry object to current file.
1059 fMCQA = new AliMCQA(fNdets);
1062 // Save stuff at the beginning of the file to avoid file corruption
1066 //_____________________________________________________________________________
1067 void AliRun::MediaTable()
1070 // Built media table to get from the media number to
1073 Int_t kz, nz, idt, lz, i, k, ind;
1075 TObjArray &dets = *gAlice->Detectors();
1078 // For all detectors
1079 for (kz=0;kz<fNdets;kz++) {
1080 // If detector is defined
1081 if((det=(AliModule*) dets[kz])) {
1082 TArrayI &idtmed = *(det->GetIdtmed());
1083 for(nz=0;nz<100;nz++) {
1084 // Find max and min material number
1085 if((idt=idtmed[nz])) {
1086 det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
1087 det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
1090 if(det->LoMedium() > det->HiMedium()) {
1091 det->LoMedium() = 0;
1092 det->HiMedium() = 0;
1094 if(det->HiMedium() > fImedia->GetSize()) {
1095 Error("MediaTable","Increase fImedia from %d to %d",
1096 fImedia->GetSize(),det->HiMedium());
1099 // Tag all materials in rage as belonging to detector kz
1100 for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
1107 // Print summary table
1108 printf(" Traking media ranges:\n");
1109 for(i=0;i<(fNdets-1)/6+1;i++) {
1110 for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) {
1112 det=(AliModule*)dets[ind];
1114 printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
1117 printf(" %6s: %3d -> %3d;","NULL",0,0);
1123 //____________________________________________________________________________
1124 void AliRun::SetGenerator(AliGenerator *generator)
1127 // Load the event generator
1129 if(!fGenerator) fGenerator = generator;
1132 //____________________________________________________________________________
1133 void AliRun::ResetGenerator(AliGenerator *generator)
1136 // Load the event generator
1140 Warning("ResetGenerator","Replacing generator %s with %s\n",
1141 fGenerator->GetName(),generator->GetName());
1143 Warning("ResetGenerator","Replacing generator %s with NULL\n",
1144 fGenerator->GetName());
1145 fGenerator = generator;
1148 //____________________________________________________________________________
1149 void AliRun::SetTransPar(char *filename)
1151 fTransParName = filename;
1154 //____________________________________________________________________________
1155 void AliRun::SetBaseFile(char *filename)
1157 fBaseFileName = *filename;
1160 //____________________________________________________________________________
1161 void AliRun::OpenBaseFile(const char *option)
1163 if(!strlen(fBaseFileName.Data())) {
1164 const char *filename;
1165 if ((filename=gSystem->Getenv("CONFIG_FILE"))) {
1166 fBaseFileName=filename;
1168 fBaseFileName="galice.root";
1171 TFile *rootfile = new TFile(fBaseFileName.Data(),option);
1172 rootfile->SetCompressionLevel(2);
1175 //____________________________________________________________________________
1176 void AliRun::ReadTransPar()
1179 // Read filename to set the transport parameters
1183 const Int_t kncuts=10;
1184 const Int_t knflags=11;
1185 const Int_t knpars=kncuts+knflags;
1186 const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
1187 "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
1188 "BREM","COMP","DCAY","DRAY","HADR","LOSS",
1189 "MULS","PAIR","PHOT","RAYL"};
1193 Float_t cut[kncuts];
1194 Int_t flag[knflags];
1195 Int_t i, itmed, iret, ktmed, kz;
1198 // See whether the file is there
1199 filtmp=gSystem->ExpandPathName(fTransParName.Data());
1200 lun=fopen(filtmp,"r");
1203 Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
1207 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
1208 printf(" *%59s\n","*");
1209 printf(" * Please check carefully what you are doing!%10s\n","*");
1210 printf(" *%59s\n","*");
1213 // Initialise cuts and flags
1214 for(i=0;i<kncuts;i++) cut[i]=-99;
1215 for(i=0;i<knflags;i++) flag[i]=-99;
1217 for(i=0;i<256;i++) line[i]='\0';
1218 // Read up to the end of line excluded
1219 iret=fscanf(lun,"%[^\n]",line);
1223 printf(" *%59s\n","*");
1224 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
1227 // Read the end of line
1230 if(line[0]=='*') continue;
1232 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",
1233 detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
1234 &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
1235 &flag[8],&flag[9],&flag[10]);
1239 Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
1242 // Check that the module exist
1243 AliModule *mod = GetModule(detName);
1245 // Get the array of media numbers
1246 TArrayI &idtmed = *mod->GetIdtmed();
1247 // Check that the tracking medium code is valid
1248 if(0<=itmed && itmed < 100) {
1249 ktmed=idtmed[itmed];
1251 Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
1254 // Set energy thresholds
1255 for(kz=0;kz<kncuts;kz++) {
1257 printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
1258 kpars[kz],cut[kz],itmed,mod->GetName());
1259 gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
1262 // Set transport mechanisms
1263 for(kz=0;kz<knflags;kz++) {
1265 printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
1266 kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
1267 gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
1271 Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
1275 Warning("ReadTransPar","Module %s not present\n",detName);
1281 //_____________________________________________________________________________
1282 void AliRun::MakeBranchInTree(TTree *tree, const char* name, void* address, Int_t size, char *file)
1285 printf("* MakeBranch * Making Branch %s \n",name);
1287 TBranch *branch = tree->Branch(name,address,size);
1290 TDirectory *cwd = gDirectory;
1291 branch->SetFile(file);
1292 TIter next( branch->GetListOfBranches());
1293 while ((branch=(TBranch*)next())) {
1294 branch->SetFile(file);
1297 printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
1302 //_____________________________________________________________________________
1303 void AliRun::MakeBranchInTree(TTree *tree, const char* name, const char *classname, void* address, Int_t size, Int_t splitlevel, char *file)
1305 TDirectory *cwd = gDirectory;
1306 TBranch *branch = tree->Branch(name,classname,address,size,splitlevel);
1308 printf("* MakeBranch * Making Branch %s \n",name);
1310 branch->SetFile(file);
1311 TIter next( branch->GetListOfBranches());
1312 while ((branch=(TBranch*)next())) {
1313 branch->SetFile(file);
1316 printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
1320 //_____________________________________________________________________________
1321 void AliRun::MakeTree(Option_t *option, char *file)
1324 // Create the ROOT trees
1325 // Loop on all detectors to create the Root branch (if any)
1331 char *oK = strstr(option,"K");
1332 char *oH = strstr(option,"H");
1333 char *oE = strstr(option,"E");
1334 char *oD = strstr(option,"D");
1335 char *oR = strstr(option,"R");
1336 char *oS = strstr(option,"S");
1339 if (oK && !fTreeK) {
1340 sprintf(hname,"TreeK%d",fEvent);
1341 fTreeK = new TTree(hname,"Kinematics");
1342 // Create a branch for particles
1343 MakeBranchInTree(fTreeK,
1344 "Particles", "TParticle", &fParticleBuffer, 4000, 1, file) ;
1347 if (oH && !fTreeH) {
1348 sprintf(hname,"TreeH%d",fEvent);
1349 fTreeH = new TTree(hname,"Hits");
1350 fTreeH->SetAutoSave(1000000000); //no autosave
1353 if (oD && !fTreeD) {
1354 sprintf(hname,"TreeD%d",fEvent);
1355 fTreeD = new TTree(hname,"Digits");
1358 if (oS && !fTreeS) {
1359 sprintf(hname,"TreeS%d",fEvent);
1360 fTreeS = new TTree(hname,"SDigits");
1363 if (oR && !fTreeR) {
1364 sprintf(hname,"TreeR%d",fEvent);
1365 fTreeR = new TTree(hname,"Reconstruction");
1368 if (oE && !fTreeE) {
1369 fTreeE = new TTree("TE","Header");
1370 // Create a branch for Header
1371 MakeBranchInTree(fTreeE,
1372 "Header", "AliHeader", &gAliHeader, 4000, 1, file) ;
1377 // Create a branch for hits/digits for each detector
1378 // Each branch is a TClonesArray. Each data member of the Hits classes
1379 // will be in turn a subbranch of the detector master branch
1380 TIter next(fModules);
1381 AliModule *detector;
1382 while((detector = (AliModule*)next())) {
1383 if (oH || oR) detector->MakeBranch(option,file);
1387 //_____________________________________________________________________________
1388 Int_t AliRun::PurifyKine(Int_t lastSavedTrack, Int_t nofTracks)
1391 // PurifyKine with external parameters
1393 fHgwmk = lastSavedTrack;
1394 fNtrack = nofTracks;
1399 //_____________________________________________________________________________
1400 TParticle* AliRun::Particle(Int_t i)
1402 if(!(*fParticleMap)[i]) {
1403 Int_t nentries = fParticles->GetEntries();
1404 fTreeK->GetEntry(fParticleFileMap[i]);
1405 new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1406 fParticleMap->AddAt((*fParticles)[nentries],i);
1408 return (TParticle *) (*fParticleMap)[i];
1411 //_____________________________________________________________________________
1412 void AliRun::PurifyKine()
1415 // Compress kinematic tree keeping only flagged particles
1416 // and renaming the particle id's in all the hits
1418 // TClonesArray &particles = *fParticles;
1419 TObjArray &particles = *fParticleMap;
1420 int nkeep=fHgwmk+1, parent, i;
1421 TParticle *part, *father;
1422 TArrayI map(particles.GetLast()+1);
1424 // Save in Header total number of tracks before compression
1425 fHeader.SetNtrack(fHeader.GetNtrack()+fNtrack-fHgwmk);
1427 // If no tracks generated return now
1428 if(fHgwmk+1 == fNtrack) return;
1430 Int_t toshrink = fNtrack-fHgwmk-1;
1432 // First pass, invalid Daughter information
1433 for(i=0; i<fNtrack; i++) {
1434 // Preset map, to be removed later
1435 if(i<=fHgwmk) map[i]=i ;
1438 // particles.UncheckedAt(i)->ResetBit(kDaughtersBit);
1439 if((part=(TParticle*) particles.At(i))) part->ResetBit(kDaughtersBit);
1442 // Invalid daughter information for the parent of the first particle
1443 // generated. This may or may not be the current primary according to
1444 // whether decays have been recorded among the primaries
1445 part = (TParticle *)particles.At(fHgwmk+1);
1446 particles.At(part->GetFirstMother())->ResetBit(kDaughtersBit);
1447 // Second pass, build map between old and new numbering
1448 for(i=fHgwmk+1; i<fNtrack; i++) {
1449 if(particles.At(i)->TestBit(kKeepBit)) {
1451 // This particle has to be kept
1453 // If old and new are different, have to move the pointer
1454 if(i!=nkeep) particles[nkeep]=particles.At(i);
1455 part = (TParticle*) particles.At(nkeep);
1457 // as the parent is always *before*, it must be already
1458 // in place. This is what we are checking anyway!
1459 if((parent=part->GetFirstMother())>fHgwmk)
1460 if(map[parent]==-99) Fatal("PurifyKine","map[%d] = -99!\n",parent);
1461 else part->SetFirstMother(map[parent]);
1467 // Fix daughters information
1468 for (i=fHgwmk+1; i<nkeep; i++) {
1469 part = (TParticle *)particles.At(i);
1470 parent = part->GetFirstMother();
1472 father = (TParticle *)particles.At(parent);
1473 if(father->TestBit(kDaughtersBit)) {
1475 if(i<father->GetFirstDaughter()) father->SetFirstDaughter(i);
1476 if(i>father->GetLastDaughter()) father->SetLastDaughter(i);
1478 // Initialise daughters info for first pass
1479 father->SetFirstDaughter(i);
1480 father->SetLastDaughter(i);
1481 father->SetBit(kDaughtersBit);
1486 // Now loop on all registered hit lists
1487 TIter next(fHitLists);
1488 TCollection *hitList;
1489 while((hitList = (TCollection*)next())) {
1490 TIter nexthit(hitList);
1492 while((hit = (AliHit*)nexthit())) {
1493 hit->SetTrack(map[hit->GetTrack()]);
1498 // This for detectors which have a special mapping mechanism
1499 // for hits, such as TPC and TRD
1502 TIter nextmod(fModules);
1503 AliModule *detector;
1504 while((detector = (AliModule*)nextmod())) {
1505 detector->RemapTrackHitIDs(map.GetArray());
1508 // Now the output bit, from fHgwmk to nkeep we write everything and we erase
1509 if(nkeep>fParticleFileMap.GetSize()) fParticleFileMap.Set(Int_t (nkeep*1.5));
1512 for (i=fHgwmk+1; i<nkeep; ++i) {
1513 fParticleBuffer = (TParticle*) particles.At(i);
1514 fParticleFileMap[i]=(Int_t) fTreeK->GetEntries();
1519 for (i=nkeep; i<fNtrack; ++i) particles[i]=0;
1521 fLoadPoint-=toshrink;
1522 for(i=fLoadPoint; i<fLoadPoint+toshrink; ++i) fParticles->RemoveAt(i);
1529 //_____________________________________________________________________________
1530 void AliRun::BeginEvent()
1533 // Reset all Detectors & kinematics & trees
1540 fLego->BeginEvent();
1550 // Initialise event header
1551 fHeader.Reset(fRun,fEvent);
1555 sprintf(hname,"TreeK%d",fEvent);
1556 fTreeK->SetName(hname);
1560 sprintf(hname,"TreeH%d",fEvent);
1561 fTreeH->SetName(hname);
1565 sprintf(hname,"TreeD%d",fEvent);
1566 fTreeD->SetName(hname);
1570 sprintf(hname,"TreeS%d",fEvent);
1571 fTreeS->SetName(hname);
1575 sprintf(hname,"TreeR%d",fEvent);
1576 fTreeR->SetName(hname);
1579 //_____________________________________________________________________________
1580 void AliRun::ResetDigits()
1583 // Reset all Detectors digits
1585 TIter next(fModules);
1586 AliModule *detector;
1587 while((detector = (AliModule*)next())) {
1588 detector->ResetDigits();
1592 //_____________________________________________________________________________
1593 void AliRun::ResetSDigits()
1596 // Reset all Detectors digits
1598 TIter next(fModules);
1599 AliModule *detector;
1600 while((detector = (AliModule*)next())) {
1601 detector->ResetSDigits();
1605 //_____________________________________________________________________________
1606 void AliRun::ResetHits()
1609 // Reset all Detectors hits
1611 TIter next(fModules);
1612 AliModule *detector;
1613 while((detector = (AliModule*)next())) {
1614 detector->ResetHits();
1618 //_____________________________________________________________________________
1619 void AliRun::ResetPoints()
1622 // Reset all Detectors points
1624 TIter next(fModules);
1625 AliModule *detector;
1626 while((detector = (AliModule*)next())) {
1627 detector->ResetPoints();
1631 //_____________________________________________________________________________
1632 void AliRun::RunMC(Int_t nevent, const char *setup)
1635 // Main function to be called to process a galice run
1637 // Root > gAlice.Run();
1638 // a positive number of events will cause the finish routine
1642 // check if initialisation has been done
1643 if (!fInitDone) InitMC(setup);
1645 // Create the Root Tree with one branch per detector
1647 if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
1649 MakeTree("K","Kine.root");
1650 MakeTree("H","Hits.root");
1651 MakeTree("R","Reco.root");
1656 gMC->ProcessRun(nevent);
1658 // End of this run, close files
1659 if(nevent>0) FinishRun();
1662 //_____________________________________________________________________________
1664 void AliRun::Hits2Digits(const char *selected)
1666 Hits2SDigits(selected);
1667 SDigits2Digits(selected);
1670 //_____________________________________________________________________________
1672 void AliRun::Hits2SDigits(const char *selected)
1675 // Main function to be called to convert hits to digits.
1677 gAlice->GetEvent(0);
1679 TObjArray *detectors = gAlice->Detectors();
1681 TIter next(detectors);
1683 AliDetector *detector;
1685 TDirectory *cwd = gDirectory;
1689 while((detector = (AliDetector*)next())) {
1691 if (strcmp(detector->GetName(),selected)) continue;
1693 if (detector->IsActive()){
1694 if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
1696 cout << "Processing " << detector->GetName() << "..." << endl;
1697 char * outFile = new char[strlen (detector->GetName())+18];
1698 sprintf(outFile,"SDigits.%s.root",detector->GetName());
1699 detector->MakeBranch("S",outFile);
1702 detector->MakeBranch("S");
1705 detector->Hits2SDigits();
1710 //_____________________________________________________________________________
1712 void AliRun::SDigits2Digits(const char *selected)
1715 // Main function to be called to convert hits to digits.
1717 gAlice->GetEvent(0);
1719 TObjArray *detectors = gAlice->Detectors();
1721 TIter next(detectors);
1723 AliDetector *detector;
1725 TDirectory *cwd = gDirectory;
1729 while((detector = (AliDetector*)next())) {
1731 if (strcmp(detector->GetName(),selected)) continue;
1733 if (detector->IsActive()){
1734 if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
1736 cout << "Processing " << detector->GetName() << "..." << endl;
1737 char * outFile = new char[strlen (detector->GetName())+16];
1738 sprintf(outFile,"Digits.%s.root",detector->GetName());
1739 detector->MakeBranch("D",outFile);
1742 detector->MakeBranch("D");
1745 detector->SDigits2Digits();
1750 //_____________________________________________________________________________
1751 void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
1752 Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max,
1753 Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener)
1756 // Generates lego plots of:
1757 // - radiation length map phi vs theta
1758 // - radiation length map phi vs eta
1759 // - interaction length map
1760 // - g/cm2 length map
1762 // ntheta bins in theta, eta
1763 // themin minimum angle in theta (degrees)
1764 // themax maximum angle in theta (degrees)
1766 // phimin minimum angle in phi (degrees)
1767 // phimax maximum angle in phi (degrees)
1768 // rmin minimum radius
1769 // rmax maximum radius
1772 // The number of events generated = ntheta*nphi
1773 // run input parameters in macro setup (default="Config.C")
1775 // Use macro "lego.C" to visualize the 3 lego plots in spherical coordinates
1778 <img src="picts/AliRunLego1.gif">
1783 <img src="picts/AliRunLego2.gif">
1788 <img src="picts/AliRunLego3.gif">
1793 // check if initialisation has been done
1794 if (!fInitDone) InitMC(setup);
1795 //Save current generator
1796 AliGenerator *gen=Generator();
1798 // Set new generator
1799 if (!gener) gener = new AliLegoGenerator();
1800 ResetGenerator(gener);
1802 // Configure Generator
1803 gener->SetRadiusRange(rmin, rmax);
1804 gener->SetZMax(zmax);
1805 gener->SetCoor1Range(nc1, c1min, c1max);
1806 gener->SetCoor2Range(nc2, c2min, c2max);
1809 //Create Lego object
1810 fLego = new AliLego("lego",gener);
1812 //Prepare MC for Lego Run
1817 gMC->ProcessRun(nc1*nc2+1);
1819 // Create only the Root event Tree
1822 // End of this run, close files
1824 // Restore current generator
1825 ResetGenerator(gen);
1826 // Delete Lego Object
1827 delete fLego; fLego=0;
1830 //_____________________________________________________________________________
1831 void AliRun::SetConfigFunction(const char * config)
1834 // Set the signature of the function contained in Config.C to configure
1837 fConfigFunction=config;
1840 //_____________________________________________________________________________
1841 void AliRun::SetCurrentTrack(Int_t track)
1844 // Set current track number
1849 //_____________________________________________________________________________
1850 void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
1851 Float_t *vpos, Float_t *polar, Float_t tof,
1852 AliMCProcess mech, Int_t &ntr, Float_t weight)
1855 // Load a track on the stack
1857 // done 0 if the track has to be transported
1859 // parent identifier of the parent track. -1 for a primary
1860 // pdg particle code
1861 // pmom momentum GeV/c
1863 // polar polarisation
1864 // tof time of flight in seconds
1865 // mecha production mechanism
1866 // ntr on output the number of the track stored
1868 TClonesArray &particles = *fParticles;
1869 TParticle *particle;
1871 const Int_t kfirstdaughter=-1;
1872 const Int_t klastdaughter=-1;
1874 // const Float_t tlife=0;
1877 // Here we get the static mass
1878 // For MC is ok, but a more sophisticated method could be necessary
1879 // if the calculated mass is required
1880 // also, this method is potentially dangerous if the mass
1881 // used in the MC is not the same of the PDG database
1883 mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
1884 Float_t e=TMath::Sqrt(mass*mass+pmom[0]*pmom[0]+
1885 pmom[1]*pmom[1]+pmom[2]*pmom[2]);
1887 //printf("Loading particle %s mass %f ene %f No %d ip %d pos %f %f %f mom %f %f %f kS %d m %s\n",
1888 //pname,mass,e,fNtrack,pdg,vpos[0],vpos[1],vpos[2],pmom[0],pmom[1],pmom[2],kS,mecha);
1890 particle=new(particles[fLoadPoint++]) TParticle(pdg,kS,parent,-1,kfirstdaughter,
1891 klastdaughter,pmom[0],pmom[1],pmom[2],
1892 e,vpos[0],vpos[1],vpos[2],tof);
1893 particle->SetPolarisation(TVector3(polar[0],polar[1],polar[2]));
1894 particle->SetWeight(weight);
1895 particle->SetUniqueID(mech);
1896 if(!done) particle->SetBit(kDoneBit);
1897 // Declare that the daughter information is valid
1898 particle->SetBit(kDaughtersBit);
1899 // Add the particle to the stack
1900 fParticleMap->AddAtAndExpand(particle,fNtrack);
1903 particle=(TParticle*) fParticleMap->At(parent);
1904 particle->SetLastDaughter(fNtrack);
1905 if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
1908 // This is a primary track. Set high water mark for this event
1911 // Set also number if primary tracks
1912 fHeader.SetNprimary(fHgwmk+1);
1913 fHeader.SetNtrack(fHgwmk+1);
1919 // Here we get the static mass
1920 // For MC is ok, but a more sophisticated method could be necessary
1921 // if the calculated mass is required
1922 // also, this method is potentially dangerous if the mass
1923 // used in the MC is not the same of the PDG database
1925 Float_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
1926 Float_t e=TMath::Sqrt(mass*mass+pmom[0]*pmom[0]+
1927 pmom[1]*pmom[1]+pmom[2]*pmom[2]);
1929 SetTrack(done, parent, pdg, pmom[0], pmom[1], pmom[2], e,
1930 vpos[0], vpos[1], vpos[2], tof, polar[0],polar[1],polar[2],
1935 //_____________________________________________________________________________
1936 void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg,
1937 Double_t px, Double_t py, Double_t pz, Double_t e,
1938 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
1939 Double_t polx, Double_t poly, Double_t polz,
1940 AliMCProcess mech, Int_t &ntr, Float_t weight=1)
1943 // Load a track on the stack
1945 // done 0 if the track has to be transported
1947 // parent identifier of the parent track. -1 for a primary
1948 // pdg particle code
1949 // kS generation status code
1950 // px, py, pz momentum GeV/c
1951 // vx, vy, vz position
1952 // polar polarisation
1953 // tof time of flight in seconds
1954 // mech production mechanism
1955 // ntr on output the number of the track stored
1957 // New method interface:
1958 // arguments were changed to be in correspondence with TParticle
1960 // Note: the energy is not calculated from the static mass but
1961 // it is passed by argument e.
1963 TClonesArray &particles = *fParticles;
1966 const Int_t kFirstDaughter=-1;
1967 const Int_t kLastDaughter=-1;
1970 = new(particles[fLoadPoint++]) TParticle(pdg, kS, parent, -1,
1971 kFirstDaughter, kLastDaughter,
1972 px, py, pz, e, vx, vy, vz, tof);
1974 particle->SetPolarisation(polx, poly, polz);
1975 particle->SetWeight(weight);
1976 particle->SetUniqueID(mech);
1978 if(!done) particle->SetBit(kDoneBit);
1980 // Declare that the daughter information is valid
1981 particle->SetBit(kDaughtersBit);
1982 // Add the particle to the stack
1983 fParticleMap->AddAtAndExpand(particle,fNtrack);
1986 particle=(TParticle*) fParticleMap->At(parent);
1987 particle->SetLastDaughter(fNtrack);
1988 if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
1991 // This is a primary track. Set high water mark for this event
1994 // Set also number if primary tracks
1995 fHeader.SetNprimary(fHgwmk+1);
1996 fHeader.SetNtrack(fHgwmk+1);
2001 //_____________________________________________________________________________
2002 void AliRun::SetHighWaterMark(const Int_t nt)
2005 // Set high water mark for last track in event
2008 // Set also number if primary tracks
2009 fHeader.SetNprimary(fHgwmk+1);
2010 fHeader.SetNtrack(fHgwmk+1);
2013 //_____________________________________________________________________________
2014 void AliRun::KeepTrack(const Int_t track)
2017 // flags a track to be kept
2019 fParticleMap->At(track)->SetBit(kKeepBit);
2022 //_____________________________________________________________________________
2023 void AliRun::StepManager(Int_t id)
2026 // Called at every step during transport
2030 // --- If lego option, do it and leave
2032 fLego->StepManager();
2035 //Update energy deposition tables
2036 AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
2038 //Call the appropriate stepping routine;
2039 AliModule *det = (AliModule*)fModules->At(id);
2041 fMCQA->StepManager(id);
2047 //_____________________________________________________________________________
2048 void AliRun::Streamer(TBuffer &R__b)
2050 // Stream an object of class AliRun.
2052 if (R__b.IsReading()) {
2053 if (!gAlice) gAlice = this;
2055 AliRun::Class()->ReadBuffer(R__b, this);
2057 gROOT->GetListOfBrowsables()->Add(this,"Run");
2059 fTreeE = (TTree*)gDirectory->Get("TE");
2060 if (fTreeE) fTreeE->SetBranchAddress("Header", &gAliHeader);
2061 else Error("Streamer","cannot find Header Tree\n");
2062 fTreeE->GetEntry(0);
2066 AliRun::Class()->WriteBuffer(R__b, this);