]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliRunDigitizer.h
Manager class for merging/digitization
[u/mrichter/AliRoot.git] / STEER / AliRunDigitizer.h
1 #ifndef ALIRUNDIGITIZER_H
2 #define ALIRUNDIGITIZER_H
3 /* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////////////////////////////
9 //
10 //  Manager Class for Merging/Digitization   
11 //                  
12 //  Author: Jiri Chudoba (CERN)
13 //
14 ////////////////////////////////////////////////////////////////////////
15
16 // --- ROOT system ---
17 #include "TNamed.h"
18 #include "TObjString.h"
19 #include "TArrayI.h"
20 #include "TClonesArray.h"
21 #include "TTree.h"
22 #include "TParticle.h"
23
24 #define MAXDETECTORS 20
25 #define MAXFILESTOMERGE  4
26
27 // --- AliRoot header files ---
28
29 class AliDigitizer;
30
31 class AliRunDigitizer: public TNamed {
32
33 public:
34   AliRunDigitizer();
35   virtual ~AliRunDigitizer();
36   void      AddDigitizer(AliDigitizer *digitizer);
37   void      SetOutputFile(TString fn) {fOutputFileName = fn;}
38   TString   GetOutputFile() {return fOutputFileName;}
39   void      SetOutputDir(TString dn) {fOutputDirName = dn;}
40   TString   GetOutputDir() {return fOutputDirName;}
41   void      SetFirstOutputEventNr(Int_t i) {fEvent = i;}
42   void      SetNrOfEventsToWrite(Int_t i) {fNrOfEventsToWrite = i;}
43   void      SetCopyTreesFromInput(Int_t i) {fCopyTreesFromInput = i;}
44   Int_t     GetCopyTreesFromInput() {return fCopyTreesFromInput;}
45   Int_t     GetOutputEventNr() {return fEvent;}
46   Bool_t    SetInput(char* inputFileString);
47   void      SetCombinationFileName(TString fn) {fCombinationFileName = fn;} 
48   TString   GetCombinationFileName() {return fCombinationFileName;}
49   void      SetCombinationType(Int_t i) {fCombinationType = i;}
50   Int_t     GetCombinationType() const {return fCombinationType;}
51   void      PrintCombination();   // debug method
52   Int_t     GetNinputs() const {return fNinputs;}
53   Int_t     GetMask(Int_t i) const {return fkMASK[i];}
54   TTree*    GetInputTreeS(Int_t i) const {return fArrayTreeS[i];}
55   TTree*    GetInputTreeH(Int_t i) const {return fArrayTreeH[i];}
56   TTree*    GetInputTreeTPCS(Int_t i) const {return fArrayTreeTPCS[i];}
57   Int_t     GetNextMask(Int_t i) const;
58   TTree*    GetNextTreeH(TTree *) const;
59   TTree*    GetNextTreeS(TTree *) const;
60   TTree*    GetNextTreeTPCS(TTree *) const;
61   TTree*    GetTreeD() const {return fTreeD;}
62   void      Digitize();
63
64 // Nr of particles in all input files for a given event
65 //     (as numbered in the output file)
66   Int_t GetNParticles(Int_t event);
67
68 // Nr of particles in input file input for a given event
69 //     (as numbered in this input file)
70   Int_t GetNParticles(Int_t event, Int_t input);
71
72 // return pointer to an int array with input event numbers which were
73 // merged in the output event event
74   Int_t* GetInputEventNumbers(Int_t event);
75
76 // return an event number of an eventInput from input file input
77 // which was merged to create output event event
78   Int_t GetInputEventNumber(Int_t event, Int_t input);
79   
80 // return pointer to particle with index i (index with mask)
81   TParticle* GetParticle(Int_t i, Int_t event);
82
83 // return pointer to particle with index i in the input file input
84 // (index without mask)
85   TParticle* GetParticle(Int_t i, Int_t input, Int_t event);
86
87   
88   Int_t     GetDebug() const {return fDebug;}
89   void      SetDebug(Int_t level) {fDebug = level;}
90   
91 private:
92   AliDigitizer *    fDigitizers[MAXDETECTORS];  //! pointers to registered
93                                                 //  digitizers
94 // the constant 20 corresponds to  MAXDETECTORS = 20 - could be done better
95   Int_t             fNDigitizers;         //! nr. of registered digitizers
96   Int_t             fkMASK[MAXFILESTOMERGE];  //! masks for track ids from
97                                               //  different source files
98   Int_t             fkMASKSTEP;           // step to increase MASK for
99                                           // each input file
100   TString           fOutputFileName;      // output file name
101   TString           fOutputDirName;       // output dir name
102   TFile *           fOutput;              //! pointer to the output file
103   Int_t             fEvent;               // output event nr.
104   Int_t             fNrOfEventsToWrite;   // Nr of events to write
105   Int_t             fNrOfEventsWritten;   // Nr of events written
106   Int_t             fCopyTreesFromInput;  // from which input file the trees
107                                           // should be copied, -1 for no copies
108   TTree *           fTreeD;               //! output TreeD
109   Int_t             fNinputs;             // nr of input files
110   TClonesArray *    fInputFileNames;      // input files names
111   TClonesArray *    fInputFiles;          //! pointers to file handles
112   TTree *           fArrayTreeS[MAXFILESTOMERGE];   //! array with p. to TreeS
113   TTree *           fArrayTreeTPCS[MAXFILESTOMERGE];   //! array with p. to TreeD_75x40_100x60_x (TPC Sdigits)
114   TTree *           fArrayTreeH[MAXFILESTOMERGE];   //! array with p. to TreeH
115   Int_t             fMinNEvents;          // min nr. of events found in inputs
116   TArrayI           fCombination;         //! combination of events from
117   Int_t             fCombinationType;     // defines the algorithm how
118                                           // to generated combination
119   TString           fCombinationFileName; // fn with combinations (used
120                                           // with type 2 of comb.)
121   Bool_t            MakeCombination();    // create next combination
122   void              ConnectInputTrees();
123   Bool_t            InitGlobal();
124   Bool_t            InitOutputGlobal();
125   void              InitPerEvent();
126   void              FinishPerEvent();
127   void              FinishGlobal();
128   Int_t             fDebug;                //! specifies debug level, 0 is min
129   
130   TFile* ConnectInputFile(Int_t input);    // open input file with index input
131
132   ClassDef(AliRunDigitizer,1)
133 };
134
135 #endif // ALIRUNDIGITIZER_H