]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitizer.h
Code revision:
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizer.h
1 #ifndef ALIMUONDIGITIZER_H
2 #define ALIMUONDIGITIZER_H
3 /* Copyright(c) 1998-2001, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7 // Revision of includes 07/05/2004
8
9 #include "AliDigitizer.h"
10 #include "AliMUONDigit.h"
11
12 class AliRunDigitizer;
13 class AliRunLoader;
14 class AliMUONHitMapA1;
15 class AliMUON;
16 class AliMUONData;
17 class AliMUONLoader;
18 class AliMUONTransientDigit;
19
20 class AliMUONDigitizer : public AliDigitizer
21 {
22 public:
23
24         /* Default constructor initializes all the internal pointers to NULL.
25          */
26         AliMUONDigitizer();
27         
28         /* Constructor initialises all the internal pointers to NULL and
29            sets this digitizers manager to the one specified.
30          */
31         AliMUONDigitizer(AliRunDigitizer * manager);
32
33         // Destructor
34         virtual ~AliMUONDigitizer();
35
36         // The Init method does nothing.
37         // All initialization happens in Exec at the moment.  
38         virtual Bool_t Init();
39
40         // Override the TTask Exec method.
41         virtual void Exec(Option_t* option = 0);
42
43         Int_t GetDebug() const {return fDebug;}       // Get debug level.
44         void SetDebug(Int_t level){fDebug = level;}   // Set debug level.    
45
46 protected:
47         AliMUONDigitizer(const AliMUONDigitizer& rhs);
48         AliMUONDigitizer& operator=(const AliMUONDigitizer& rhs);
49
50
51         // Parses the option string given to the Exec method.
52         virtual void ParseOptions(Option_t* options);
53
54         /* Digitizers inheriting from AliMUONDigitizer should implement this abstract method 
55            so that TransientDigit objects are generated and put onto the fTDList.
56            The method would be implemented as some loop over the input stream. The data can be
57            fetched from the fMUONData pointer. To add to the fTDList once should use code similar
58            to the following:
59            
60              TObject* source_object;  // Assume the object from which the transient digit
61                                       // is created is already initialized at this point.
62              AliMUONTransientDigit* td = new AliMUONTransientDigit();
63              // Initialize the transient digit.
64              // ...
65              
66              // The following line of code is required to have working digitisers that want
67              // to store information about which digits were created from which hits. 
68              OnCreateTransientDigit(td, source_object);
69              
70              AddOrUpdateTransientDigit(td);  // Adds to the fTDList preventing duplicates.
71          */
72         virtual void GenerateTransientDigits() = 0;
73         
74         // Loops over the fTDList of transient digits to write them to the output stream.
75         virtual void CreateDigits();
76
77         /* Inheriting digitizers should implement this method to prepare the fMUONData
78            object before GenerateTransientDigits() is called. 
79            If the initialization was successful then kTRUE should be returned otherwise
80            kFALSE should be returned. 
81          */
82         virtual Bool_t InitInputData(AliMUONLoader* muonloader) = 0;
83         
84         /* This method should be overridden to undo/cleanup what was done in the 
85            InitInputData method call.
86          */
87         virtual void CleanupInputData(AliMUONLoader* muonloader) = 0;
88
89         /* Inheriting digitizers should implement this method to prepare the fMUONData
90            object before CreateDigits() is called.
91            If the initialization was successful then kTRUE should be returned otherwise
92            kFALSE should be returned. 
93          */
94         virtual Bool_t InitOutputData(AliMUONLoader* muonloader) = 0;
95
96         /* When all the data is added to the fMUONData object and the trees need to be
97            filled then this method is called by CreateDigits(). 
98            Thus code like
99                fMUONData->Fill("D")
100            should go into this method.
101          */
102         virtual void FillOutputData() = 0;
103         
104         /* This method should be overridden to undo/cleanup what was done in the 
105            InitOutputData method call.
106          */
107         virtual void CleanupOutputData(AliMUONLoader* muonloader) = 0;
108
109         /* This is called by CreateDigits when it wants the Signal value that will be written
110            to the output stream. Inheriting digitizers can override this to apply some kind 
111            of detector response.
112          */
113         virtual Int_t GetSignalFrom(AliMUONTransientDigit* td) = 0;
114
115         /* Should be overridden by inheriting digitizers such that this method adds the digits
116            to the correct tree. 
117          */
118         virtual void AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6]) = 0;
119
120         /* Should be called by GenerateTransientDigits() when a new transient digit is generated
121            form a source object from the input stream. The source object could be an AliMUONHit
122            or AliMUONSDigit for example.
123          */ 
124         virtual void OnCreateTransientDigit(AliMUONTransientDigit* /*digit*/, TObject* /*source_object*/);
125
126         /* Called by AddDigit(AliMUONTransientDigit*, Int_t) when transient digit is added to the 
127            fMUONData object ready for writing to the data trees.
128          */ 
129         virtual void OnWriteTransientDigit(AliMUONTransientDigit* digit);
130         
131         // Wrapper method for AddDigit(Int_t, Int_t[kMAXTRACKS], Int_t[kMAXTRACKS], Int_t[6])
132         void AddDigit(AliMUONTransientDigit* td, Int_t responseCharge);
133
134         // Creates a new fTDList object, and creates and fills the fHitMap arrays.
135         // Note: this method assumes the array pointers are NULL when calling this method.
136         void InitArrays();
137         
138         // Frees the memory allocated for fTDList and the fHitMap arrays.
139         void CleanupArrays();
140
141         /* Gets the run loader and muon loader pointers from the given folder name. If an error 
142            occurred then kFALSE is returned else kTRUE on success. 
143          */
144         Bool_t FetchLoaders(const char* foldername, AliRunLoader*& runloader, AliMUONLoader*& muonloader);
145
146         /* Gets the gAlice, and MUON module pointers from the specified run loader. If an error 
147            occurred then kFALSE is returned else kTRUE on success. 
148          */
149         Bool_t FetchGlobalPointers(AliRunLoader* runloader);
150
151         // Adds the transient digit uniquely to the fTDList.
152         void AddOrUpdateTransientDigit(AliMUONTransientDigit* mTD);
153         
154         // Updates a TransientDigit in fTDList
155         void UpdateTransientDigit(AliMUONTransientDigit * mTD);
156         
157         // Adds the new TransientDigit to fTDList
158         void AddTransientDigit(AliMUONTransientDigit * mTD);
159
160         // Verify that a TransientDigit already exists.
161         Bool_t ExistTransientDigit(AliMUONTransientDigit * mTD); 
162
163         // Sorts the 3 most significant tracks.    
164         void SortTracks(Int_t *tracks, Int_t *charges, Int_t ntr) const;
165
166
167         AliRunLoader* fRunLoader;        //! Global run loader.
168         AliMUONLoader* fGime;            //! MUON specific loader.
169         AliMUON* fMUON;                 //! Pointer to MUON module.
170         AliMUONData* fMUONData;          //! muon data interface
171
172         AliMUONHitMapA1 **fHitMap;      //! pointer to array of pointers to hitmaps
173         TObjArray *fTDList;             //! list of AliMUONTransientDigits
174         Int_t fTDCounter;               //! nr. of AliMUONTransientDigit
175         Int_t fMask;                    //! mask dependent on input file
176         Bool_t fSignal;                 //! kTRUE if signal file is processed 
177
178 private:
179
180         Int_t fDebug;                   //! Debug level.
181
182         ClassDef(AliMUONDigitizer, 1)   // MUON merging/digitization
183 };    
184 #endif