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 */
7 // Revision of includes 07/05/2004
10 /// \class AliMUONDigitizer
11 /// \brief Class for MUON merging/digitization
13 #include "AliDigitizer.h"
14 #include "AliMUONDigit.h"
16 class AliRunDigitizer;
18 class AliMUONHitMapA1;
22 class AliMUONTransientDigit;
24 static const Int_t kMAXTRACKS=10;
26 class AliMUONDigitizer : public AliDigitizer
30 /* Default constructor initializes all the internal pointers to NULL.
34 /* Constructor initialises all the internal pointers to NULL and
35 sets this digitizers manager to the one specified.
37 AliMUONDigitizer(AliRunDigitizer * manager);
40 virtual ~AliMUONDigitizer();
42 // The Init method does nothing.
43 // All initialization happens in Exec at the moment.
44 virtual Bool_t Init();
46 // Override the TTask Exec method.
47 virtual void Exec(Option_t* option = 0);
50 /* Digitizers inheriting from AliMUONDigitizer should implement this abstract method
51 so that TransientDigit objects are generated and put onto the fTDList.
52 The method would be implemented as some loop over the input stream. The data can be
53 fetched from the fMUONData pointer. To add to the fTDList once should use code similar
56 TObject* source_object; // Assume the object from which the transient digit
57 // is created is already initialized at this point.
58 AliMUONTransientDigit* td = new AliMUONTransientDigit();
59 // Initialize the transient digit.
62 // The following line of code is required to have working digitisers that want
63 // to store information about which digits were created from which hits.
64 OnCreateTransientDigit(td, source_object);
66 AddOrUpdateTransientDigit(td); // Adds to the fTDList preventing duplicates.
68 virtual void GenerateTransientDigits() = 0;
70 // Loops over the fTDList of transient digits to write them to the output stream.
71 virtual void CreateDigits();
73 /* Inheriting digitizers should implement this method to prepare the fMUONData
74 object before GenerateTransientDigits() is called.
75 If the initialization was successful then kTRUE should be returned otherwise
76 kFALSE should be returned.
78 virtual Bool_t InitInputData(AliMUONLoader* muonloader) = 0;
80 /* This method should be overridden to undo/cleanup what was done in the
81 InitInputData method call.
83 virtual void CleanupInputData(AliMUONLoader* muonloader) = 0;
85 /* Inheriting digitizers should implement this method to prepare the fMUONData
86 object before CreateDigits() is called.
87 If the initialization was successful then kTRUE should be returned otherwise
88 kFALSE should be returned.
90 virtual Bool_t InitOutputData(AliMUONLoader* muonloader) = 0;
92 /* When all the data is added to the fMUONData object and the trees need to be
93 filled then this method is called by CreateDigits().
96 should go into this method.
98 virtual void FillOutputData() = 0;
100 /* This method should be overridden to undo/cleanup what was done in the
101 InitOutputData method call.
103 virtual void CleanupOutputData(AliMUONLoader* muonloader) = 0;
105 /* This is called by CreateDigits when it wants the Signal value that will be written
106 to the output stream. Inheriting digitizers can override this to apply some kind
107 of detector response.
109 virtual Int_t GetSignalFrom(AliMUONTransientDigit* td) = 0;
111 /* Should be overridden by inheriting digitizers such that this method adds the digits
114 virtual void AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[7]) = 0;
116 /* Should be called by GenerateTransientDigits() when a new transient digit is generated
117 form a source object from the input stream. The source object could be an AliMUONHit
118 or AliMUONSDigit for example.
120 virtual void OnCreateTransientDigit(AliMUONTransientDigit* /*digit*/, TObject* /*source_object*/);
122 /* Called by AddDigit(AliMUONTransientDigit*, Int_t) when transient digit is added to the
123 fMUONData object ready for writing to the data trees.
125 virtual void OnWriteTransientDigit(AliMUONTransientDigit* digit);
127 // Wrapper method for AddDigit(Int_t, Int_t[kMAXTRACKS], Int_t[kMAXTRACKS], Int_t[6])
128 void AddDigit(AliMUONTransientDigit* td, Int_t responseCharge, Int_t digitindex);
130 // Creates a new fTDList object, and creates and fills the fHitMap arrays.
131 // Note: this method assumes the array pointers are NULL when calling this method.
134 // Frees the memory allocated for fTDList and the fHitMap arrays.
135 void CleanupArrays();
137 /* Gets the run loader and muon loader pointers from the given folder name. If an error
138 occurred then kFALSE is returned else kTRUE on success.
140 Bool_t FetchLoaders(const char* foldername, AliRunLoader*& runloader, AliMUONLoader*& muonloader);
142 /* Gets the gAlice, and MUON module pointers from the specified run loader. If an error
143 occurred then kFALSE is returned else kTRUE on success.
145 Bool_t FetchGlobalPointers(AliRunLoader* runloader);
147 // Adds the transient digit uniquely to the fTDList.
148 void AddOrUpdateTransientDigit(AliMUONTransientDigit* mTD);
150 // Updates a TransientDigit in fTDList
151 void UpdateTransientDigit(AliMUONTransientDigit * mTD);
153 // Adds the new TransientDigit to fTDList
154 void AddTransientDigit(AliMUONTransientDigit * mTD);
156 // Verify that a TransientDigit already exists.
157 Bool_t ExistTransientDigit(AliMUONTransientDigit * mTD);
159 // Sorts the 3 most significant tracks.
160 void SortTracks(Int_t *tracks, Int_t *charges, Int_t ntr) const;
163 virtual void CreateTrigger() = 0;
164 virtual void CleanupTriggerArrays() = 0;
165 virtual void FillTriggerOutput() = 0;
166 virtual void AddDigitTrigger(
167 Int_t chamber, Int_t tracks[kMAXTRACKS],
168 Int_t charges[kMAXTRACKS], Int_t digits[6],
169 Int_t digitindex ) = 0;
171 AliRunLoader* fRunLoader; //!< Global run loader.
172 AliMUONLoader* fGime; //!< MUON specific loader.
173 AliMUON* fMUON; //!< Pointer to MUON module.
174 AliMUONData* fMUONData; //!< muon data interface
176 AliMUONHitMapA1 **fHitMap; //!< pointer to array of pointers to hitmaps
177 TObjArray *fTDList; //!< list of AliMUONTransientDigits
178 Int_t fTDCounter; //!< nr. of AliMUONTransientDigit
179 Int_t fMask; //!< mask dependent on input file
180 Bool_t fSignal; //!< kTRUE if signal file is processed
181 Int_t fSegmentation; //!< segmentation type 1=old, 2=new;
182 Int_t fNDetElemId[1500]; //!< detection element number array
186 AliMUONDigitizer(const AliMUONDigitizer& rhs);
187 AliMUONDigitizer& operator=(const AliMUONDigitizer& rhs);
189 ClassDef(AliMUONDigitizer, 1) // MUON merging/digitization