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 #include "AliDigitizer.h"
8 #include "AliRunLoader.h"
9 #include "AliMUONLoader.h"
10 #include "AliMUONTransientDigit.h"
12 #include "AliMUONData.h"
14 class AliRunDigitizer;
15 class AliMUONHitMapA1;
18 class AliMUONDigitizer : public AliDigitizer
22 /* Default constructor initializes all the internal pointers to NULL.
26 /* Constructor initialises all the internal pointers to NULL and
27 sets this digitizers manager to the one specified.
29 AliMUONDigitizer(AliRunDigitizer * manager);
31 // The Init method does nothing.
32 // All initialization happens in Exec at the moment.
33 virtual Bool_t Init();
35 // Override the TTask Exec method.
36 virtual void Exec(Option_t* option = 0);
38 Int_t GetDebug() const {return fDebug;} // Get debug level.
39 void SetDebug(Int_t level){fDebug = level;} // Set debug level.
43 // Parses the option string given to the Exec method.
44 virtual void ParseOptions(Option_t* options);
46 /* Digitizers inheriting from AliMUONDigitizer should implement this abstract method
47 so that TransientDigit objects are generated and put onto the fTDList.
48 The method would be implemented as some loop over the input stream. The data can be
49 fetched from the muondata pointer. To add to the fTDList once should use code similar
52 TObject* source_object; // Assume the object from which the transient digit
53 // is created is already initialized at this point.
54 AliMUONTransientDigit* td = new AliMUONTransientDigit();
55 // Initialize the transient digit.
58 // The following line of code is required to have working digitisers that want
59 // to store information about which digits were created from which hits.
60 OnCreateTransientDigit(td, source_object);
62 AddOrUpdateTransientDigit(td); // Adds to the fTDList preventing duplicates.
64 virtual void GenerateTransientDigits() = 0;
66 // Loops over the fTDList of transient digits to write them to the output stream.
67 virtual void CreateDigits();
69 /* Inheriting digitizers should implement this method to prepare the muondata
70 object before GenerateTransientDigits() is called.
71 If the initialization was successful then kTRUE should be returned otherwise
72 kFALSE should be returned.
74 virtual Bool_t InitInputData(AliMUONLoader* muonloader) = 0;
76 /* This method should be overridden to undo/cleanup what was done in the
77 InitInputData method call.
79 virtual void CleanupInputData(AliMUONLoader* muonloader) = 0;
81 /* Inheriting digitizers should implement this method to prepare the muondata
82 object before CreateDigits() is called.
83 If the initialization was successful then kTRUE should be returned otherwise
84 kFALSE should be returned.
86 virtual Bool_t InitOutputData(AliMUONLoader* muonloader) = 0;
88 /* When all the data is added to the muondata object and the trees need to be
89 filled then this method is called by CreateDigits().
92 should go into this method.
94 virtual void FillOutputData() = 0;
96 /* This method should be overridden to undo/cleanup what was done in the
97 InitOutputData method call.
99 virtual void CleanupOutputData(AliMUONLoader* muonloader) = 0;
101 /* This is called by CreateDigits when it wants the Signal value that will be written
102 to the output stream. Inheriting digitizers can override this to apply some kind
103 of detector response.
105 virtual Int_t GetSignalFrom(AliMUONTransientDigit* td) = 0;
107 /* Should be overridden by inheriting digitizers such that this method adds the digits
110 virtual void AddDigit(Int_t chamber, Int_t tracks[kMAXTRACKS], Int_t charges[kMAXTRACKS], Int_t digits[6]) = 0;
112 /* Should be called by GenerateTransientDigits() when a new transient digit is generated
113 form a source object from the input stream. The source object could be an AliMUONHit
114 or AliMUONSDigit for example.
116 virtual void OnCreateTransientDigit(AliMUONTransientDigit* digit, TObject* source_object);
118 /* Called by AddDigit(AliMUONTransientDigit*, Int_t) when transient digit is added to the
119 muondata object ready for writing to the data trees.
121 virtual void OnWriteTransientDigit(AliMUONTransientDigit* digit);
123 // Wrapper method for AddDigit(Int_t, Int_t[kMAXTRACKS], Int_t[kMAXTRACKS], Int_t[6])
124 void AddDigit(AliMUONTransientDigit* td, Int_t response_charge);
126 // Creates a new fTDList object, and creates and fills the fHitMap arrays.
127 // Note: this method assumes the array pointers are NULL when calling this method.
130 // Frees the memory allocated for fTDList and the fHitMap arrays.
131 void CleanupArrays();
133 /* Gets the run loader and muon loader pointers from the given folder name. If an error
134 occurred then kFALSE is returned else kTRUE on success.
136 Bool_t FetchLoaders(const char* foldername, AliRunLoader*& runloader, AliMUONLoader*& muonloader);
138 /* Gets the gAlice, and MUON module pointers from the specified run loader. If an error
139 occurred then kFALSE is returned else kTRUE on success.
141 Bool_t FetchGlobalPointers(AliRunLoader* runloader);
143 // Adds the transient digit uniquely to the fTDList.
144 void AddOrUpdateTransientDigit(AliMUONTransientDigit* mTD);
146 // Updates a TransientDigit in fTDList
147 void UpdateTransientDigit(AliMUONTransientDigit * mTD);
149 // Adds the new TransientDigit to fTDList
150 void AddTransientDigit(AliMUONTransientDigit * mTD);
152 // Verify that a TransientDigit already exists.
153 Bool_t ExistTransientDigit(AliMUONTransientDigit * mTD);
155 // Sorts the 3 most significant tracks.
156 void SortTracks(Int_t *tracks, Int_t *charges, Int_t ntr);
159 AliRunLoader* runloader; //! Global run loader.
160 AliMUONLoader* gime; //! MUON specific loader.
161 AliMUON* pMUON; //! Pointer to MUON module.
162 AliMUONData* muondata; //! muon data interface
164 AliMUONHitMapA1 **fHitMap; //! pointer to array of pointers to hitmaps
165 TObjArray *fTDList; //! list of AliMUONTransientDigits
166 Int_t fTDCounter; //! nr. of AliMUONTransientDigit
167 Int_t fMask; //! mask dependent on input file
168 Bool_t fSignal; //! kTRUE if signal file is processed
172 Int_t fDebug; //! Debug level.
174 ClassDef(AliMUONDigitizer, 1) // MUON merging/digitization