Possibility to set a different file for treeS (or D or R) more than once per aliroot...
[u/mrichter/AliRoot.git] / STEER / AliRun.h
aee8290b 1#ifndef ALIRUN_H
2#define ALIRUN_H
3da30618 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6/* $Id$ */
94de3818 8class TBrowser;
9class TList;
10class TTree;
02a02c36 11class TBranch;
94de3818 12class TGeometry;
13class TDatabasePDG;
65fb704d 14class TRandom;
2ab0c725 15class TParticle;
7a16e9cc 16class TFile;
94de3818 17#include <TArrayI.h>
65fb704d 18#include "TClonesArray.h"
94de3818 19#include <TArrayF.h>
fe4da5cc 20#include <TStopwatch.h>
65fb704d 21#include "TNamed.h"
1578254f 22
94de3818 23class AliDetector;
24class AliModule;
25class AliMagF;
26class AliMC;
27class AliLego;
28class AliDisplay;
0a520a66 29class AliLegoGenerator;
9e1a0ddb 30class AliHeader;
65fb704d 31class AliGenerator;
32class AliLegoGenerator;
33#include "AliMCProcess.h"
2ab0c725 34class AliMCQA;
9e1a0ddb 35class AliStack;
42f33748 36class AliGenEventHeader;
9e1a0ddb 37
fe4da5cc 38
aee8290b 39enum {kKeepBit=1, kDaughtersBit=2, kDoneBit=4};
1578254f 40
fe4da5cc 41
42class AliRun : public TNamed {
fe4da5cc 43public:
44 // Creators - distructors
45 AliRun();
46 AliRun(const char *name, const char *title);
47 virtual ~AliRun();
49 virtual void AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const;
50 virtual void AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const;
1cedd08a 51 virtual void AddHitList(TCollection *hitList) {fHitLists->Add(hitList);}
fe4da5cc 52 virtual void Browse(TBrowser *b);
53 virtual void Build();
54 virtual void BuildSimpleGeometry();
55 virtual void CleanDetectors();
8494b010 56 TObjArray *Detectors() const {return fModules;}
57 TObjArray *Modules() const {return fModules;}
9e1a0ddb 58 Int_t CurrentTrack() const;
fe4da5cc 59 AliDisplay *Display() { return fDisplay;}
60 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
94de3818 61 virtual void DumpPart (Int_t i) const;
62 virtual void DumpPStack () const;
fe4da5cc 63 virtual AliMagF *Field() const {return fField;}
65fb704d 64 virtual void PreTrack();
65 virtual void PostTrack();
fe4da5cc 66 virtual void FinishPrimary();
9e1a0ddb 67 virtual void BeginPrimary();
fe4da5cc 68 virtual void FinishEvent();
69 virtual void FinishRun();
70 virtual void FlagTrack(Int_t track);
875c717b 71 void AddEnergyDeposit(Int_t id, Float_t edep)
72 {fEventEnergy[id]+=edep;}
fe4da5cc 73 Int_t GetEvNumber() const {return fEvent;}
74 Int_t GetRunNumber() const {return fRun;}
8494b010 75 void SetRunNumber(Int_t run) {fRun=run;}
eef4b160 76 void SetEventNrInRun(Int_t event) {fEventNrInRun=event;}
77 Int_t GetEventNrInRun() const {return fEventNrInRun;}
6df200c3 78 Int_t GetEventsPerRun() const {return fEventsPerRun;}
fe4da5cc 79 Int_t GetDebug() const {return fDebug;}
94de3818 80 AliModule *GetModule(const char *name) const;
9e1a0ddb 81 TList* GetHitLists() const {return fHitLists ;}
94de3818 82 AliDetector *GetDetector(const char *name) const;
65fb704d 83 AliMCQA *GetMCQA() const {return fMCQA;}
94de3818 84 Int_t GetModuleID(const char *name) const;
39de14fb 85 virtual const char *GetBaseFile() const
86 {return fBaseFileName.Data();}
fe4da5cc 87 virtual Int_t GetEvent(Int_t event);
45189757 88 virtual void SetEvent(Int_t event) {fEvent=event;}
94de3818 89 virtual void SetConfigFunction(const char * config="Config();");
45189757 90 virtual const char *GetConfigFunction() const
91 {return fConfigFunction.Data();}
fe4da5cc 92 TGeometry *GetGeometry();
9e1a0ddb 93 AliHeader* GetHeader() {return fHeader;}
42f33748 94 virtual void SetGenEventHeader(AliGenEventHeader* header);
45189757 95 virtual void GetNextTrack(Int_t &mtrack, Int_t &ipart, Float_t *pmom,
96 Float_t &e, Float_t *vpos, Float_t *polar,
97 Float_t &tof);
9e1a0ddb 98 Int_t GetNtrack() const;
99 virtual Int_t GetPrimary(Int_t track) const;
d47c658f 100 virtual void Hits2Digits(const char *detector=0);
101 virtual void Hits2SDigits(const char *detector=0) {Tree2Tree("S",detector);}
102 virtual void SDigits2Digits(const char *detector=0) {Tree2Tree("D",detector);}
103 virtual void Digits2Reco(const char *detector=0) {Tree2Tree("R",detector);}
875c717b 104 virtual void InitMC(const char *setup="Config.C");
105 virtual void Init(const char *setup="Config.C") {InitMC(setup);}
b21a3d1a 106 Bool_t IsFolder() const {return kTRUE;}
838edcaf 107 virtual AliLego* Lego() const {return fLego;}
9e1a0ddb 108 virtual void MakeTree(Option_t *option="KH", const char *file = 0);
7a16e9cc 109 void MakeTree(Option_t *option, TFile *file);
2ab0c725 110
9e1a0ddb 111 TObjArray *Particles();
2ab0c725 112 TParticle *Particle(Int_t i);
dffd31ef 113 virtual void BeginEvent();
fe4da5cc 114 virtual void ResetDigits();
2ab0c725 115 virtual void ResetSDigits();
fe4da5cc 116 virtual void ResetHits();
aab9c8d5 117 virtual void ResetTrackReferences();
fe4da5cc 118 virtual void ResetPoints();
119 virtual void SetTransPar(char *filename="$(ALICE_ROOT)/data/galice.cuts");
2ab0c725 120 virtual void SetBaseFile(char *filename="galice.root");
65fb704d 121 virtual void ReadTransPar();
875c717b 122 virtual void RunMC(Int_t nevent=1, const char *setup="Config.C");
123 virtual void Run(Int_t nevent=1, const char *setup="Config.C")
124 {RunMC(nevent,setup);}
dea76e7a 125 virtual void RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178,
126 Int_t nc2=60,Float_t c2min=0,Float_t c2max=360,Float_t rmin=0,
0a520a66 127 Float_t rmax=430,Float_t zmax=10000, AliLegoGenerator* gener=NULL);
dffd31ef 128 virtual Bool_t IsLegoRun() const {return (fLego!=0);}
7f6f9ab2 129 virtual void RunReco(const char *detector=0, Int_t first = 0, Int_t last = 0);
fe4da5cc 130 virtual void SetCurrentTrack(Int_t track);
9e1a0ddb 131 virtual void SetDebug(const Int_t level=0) {fDebug = level;}
fe4da5cc 132 virtual void SetDisplay(AliDisplay *display) {fDisplay = display;}
875c717b 133 virtual void StepManager(Int_t id);
fe4da5cc 134 virtual void SetField(Int_t type=2, Int_t version=1, Float_t scale=1, Float_t maxField=10, char*filename="$(ALICE_ROOT)/data/field01.dat");
d8408e76 135 virtual void SetField(AliMagF* magField);
1578254f 136 virtual void SetTrack(Int_t done, Int_t parent, Int_t pdg,
47c8bcbe 137 Float_t *pmom, Float_t *vpos, Float_t *polar,
138 Float_t tof, AliMCProcess mech, Int_t &ntr,
139 Float_t weight = 1, Int_t is = 0);
89bbad6f 140 virtual void SetTrack(Int_t done, Int_t parent, Int_t pdg,
47c8bcbe 141 Double_t px, Double_t py, Double_t pz, Double_t e,
142 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
143 Double_t polx, Double_t poly, Double_t polz,
144 AliMCProcess mech, Int_t &ntr, Float_t weight=1,
145 Int_t is = 0);
caaac55b 146 virtual void SetHighWaterMark(const Int_t nt);
4d69d91e 147
148 virtual void KeepTrack(const Int_t itra);
fe4da5cc 149 virtual void MediaTable();
150 virtual Float_t TrackingZmax() const {return fTrZmax;}
151 virtual Float_t TrackingRmax() const {return fTrRmax;}
152 virtual void TrackingLimits( Float_t rmax=1.e10, Float_t zmax=1.e10) {fTrRmax=rmax; fTrZmax=zmax;}
94de3818 153 virtual Int_t DetFromMate(Int_t i) const { return (*fImedia)[i];}
154 virtual AliGenerator* Generator() const {return fGenerator;}
fe4da5cc 155 virtual void SetGenerator(AliGenerator *generator);
ee1dd322 156 virtual void ResetGenerator(AliGenerator *generator);
fe4da5cc 157 virtual void EnergySummary();
94de3818 158 virtual TDatabasePDG* PDGDB() const {return fPDGDB;}
fe4da5cc 159
7a16e9cc 160 TFile* InitTreeFile(Option_t *option, TString fileName);
161 TString GetTreeDFileName() const {return fTreeDFileName;}
162 TString GetTreeSFileName() const {return fTreeSFileName;}
163 TString GetTreeRFileName() const {return fTreeRFileName;}
164 void SetTreeDFileName(TString fileName){fTreeDFileName=fileName;}
165 void SetTreeSFileName(TString fileName){fTreeSFileName=fileName;}
166 void SetTreeRFileName(TString fileName){fTreeRFileName=fileName;}
167 TFile* GetTreeDFile() const {return fTreeDFile;}
168 TFile* GetTreeSFile() const {return fTreeSFile;}
169 TFile* GetTreeRFile() const {return fTreeRFile;}
0592d1ca 170 void AliRun::PrintTreeFile();
7a16e9cc 171
875c717b 172
fe4da5cc 173 TTree *TreeD() {return fTreeD;}
2ab0c725 174 TTree *TreeS() {return fTreeS;}
fe4da5cc 175 TTree *TreeE() {return fTreeE;}
176 TTree *TreeH() {return fTreeH;}
aab9c8d5 177 TTree *TreeTR() {return fTreeTR;}
9e1a0ddb 178 TTree *TreeK() ;
fe4da5cc 179 TTree *TreeR() {return fTreeR;}
9e1a0ddb 181 AliStack *Stack() {return fStack;}
aee8290b 183protected:
0592d1ca 184 void CloseTreeFile(Option_t *option);
9e1a0ddb 185 virtual void Tree2Tree(Option_t *option, const char *detector=0);
7a16e9cc 186 TFile* InitFile(TString fileName="");
2ab0c725 187 Int_t fRun; //! Current run number
188 Int_t fEvent; //! Current event number (from 1)
eef4b160 189 Int_t fEventNrInRun; //! Current unique event number in run
6df200c3 190 Int_t fEventsPerRun; // Number of events per run
2ab0c725 191 Int_t fDebug; // Debug flag
9e1a0ddb 192 AliHeader *fHeader; // Header information
2ab0c725 193 TTree *fTreeD; //! Pointer to Tree for Digits
194 TTree *fTreeS; //! Pointer to Tree for SDigits
2ab0c725 195 TTree *fTreeH; //! Pointer to Tree for Hits
aab9c8d5 196 TTree *fTreeTR; //! Pointer to Tree for TrackRefernces
2ab0c725 197 TTree *fTreeE; //! Pointer to Tree for Header
198 TTree *fTreeR; //! Pointer to Tree for Reconstructed Objects
199 TObjArray *fModules; // List of Detectors
2ab0c725 200 TGeometry *fGeometry; // Pointer to geometry
201 AliDisplay *fDisplay; //! Pointer to event display
202 TStopwatch fTimer; // Timer object
203 AliMagF *fField; // Magnetic Field Map
204 AliMC *fMC; //! Pointer to MonteCarlo object
205 TArrayI *fImedia; //! Array of correspondence between media and detectors
206 Int_t fNdets; // Number of detectors
207 Float_t fTrRmax; // Maximum radius for tracking
208 Float_t fTrZmax; // Maximu z for tracking
209 AliGenerator *fGenerator; // Generator used in the MC
210 Bool_t fInitDone; //! True when initialisation done
211 AliLego *fLego; //! Pointer to aliLego object if it exists
212 TDatabasePDG *fPDGDB; // Particle factory object
213 TList *fHitLists; //! Lists of hits to be remapped by PurifyKine
214 TArrayF fEventEnergy; //! Energy deposit for current event
215 TArrayF fSummEnergy; //! Energy per event in each volume
216 TArrayF fSum2Energy; //! Energy squared per event in each volume
217 TString fConfigFunction; // Configuration file to be executed
218 TRandom *fRandom; // Pointer to the random number generator
219 AliMCQA *fMCQA; // Pointer to MC Quality assurance class
220 TString fTransParName; // Name of the transport parameters file
221 TString fBaseFileName; // Name of the base root file
c0f4be09 222 AliStack* fStack; //! Particle Stack
7a16e9cc 223 TString fTreeDFileName; //! name of the file with TreeD
224 TFile* fTreeDFile; //! file with TreeD
225 TString fTreeSFileName; //! name of the file with TreeS
226 TFile* fTreeSFile; //! file with TreeS
227 TString fTreeRFileName; //! name of the file with TreeR
228 TFile* fTreeRFile; //! file with TreeR
ef42d733 229private:
02a02c36 231 AliRun(const AliRun &right)
9e1a0ddb 232 {}
233 AliRun& operator = (const AliRun &) {return *this;}
7a16e9cc 234 ClassDef(AliRun,6) //Supervisor class for all Alice detectors
fe4da5cc 235};
75a25b1b 237R__EXTERN AliRun *gAlice;
fe4da5cc 238