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