]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMaker.h
Fixing comments
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMaker.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4
5 /**************************************************************************
6  * This file is property of and copyright by the ALICE HLT Project        *
7  * All rights reserved.                                                   *
8  *                                                                        *
9  * Primary Authors: Oystein Djuvsland                                     *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19 #ifndef ALIHLTPHOSDIGITMAKER_H
20 #define ALIHLTPHOSDIGITMAKER_H
21
22 /**
23  * Class makes digits from information from raw data
24  *
25  * @file   AliHLTPHOSDigitMaker.h
26  * @author Oystein Djuvsland
27  * @date
28  * @brief  Digit maker for PHOS HLT
29  */
30
31 // see below for class documentation
32 // or
33 // refer to README to build package
34 // or
35 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
36
37 //#include "AliHLTPHOSBase.h"
38 #include "AliHLTPHOSConstant.h"
39 #include "AliHLTPHOSDigitDataStruct.h"
40 #include "AliHLTPHOSChannelDataStruct.h"
41 #include "AliHLTDataTypes.h"
42 #include "AliHLTLogging.h"
43
44 /**
45  * @class AliHLTPHOSDigitMaker
46  * Digit maker for PHOS HLT. Takes input from AliHLTPHOSRawAnalyzer, and 
47  * outputs a block of AliHLTPHOSDigitDataStruct container
48  * @ingroup alihlt_phos
49  */
50
51 class TH2F;
52 class AliHLTPHOSSharedMemoryInterfacev2; // added by PTH
53 class AliHLTPHOSChannelDataHeaderStruct;
54 class AliHLTPHOSMapper;
55        
56 using namespace PhosHLTConst;
57
58 //class AliHLTPHOSDigitMaker : public AliHLTPHOSBase
59 class AliHLTPHOSDigitMaker : public AliHLTLogging
60 {
61 public:
62
63   /** Constructor */
64   AliHLTPHOSDigitMaker();
65
66   /** Destructor */
67   virtual ~AliHLTPHOSDigitMaker();
68
69   /** Copy constructor */  
70   AliHLTPHOSDigitMaker(const AliHLTPHOSDigitMaker &) : 
71     AliHLTLogging(),
72     fShmPtr(0),
73     fDigitStructPtr(0),
74     fDigitHeaderPtr(0),
75     fDigitCount(0),
76     fOrdered(true),
77     fMapperPtr(0),
78     fDigitPtrArray(0),
79     fAvailableSize(0)
80   {
81     //Copy constructor not implemented
82   }
83   
84   /** Assignment */
85   AliHLTPHOSDigitMaker & operator = (const AliHLTPHOSDigitMaker)
86   {
87     //Assignment
88     return *this; 
89   }
90
91   /**
92    * Sets the pointer to the output
93    * @param the output pointer
94    */
95   void SetDigitHeaderPtr(AliHLTPHOSDigitHeaderStruct *digitHeaderPtr) 
96   { 
97     fDigitHeaderPtr = digitHeaderPtr;
98     fDigitStructPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(digitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct));
99   }
100
101   /**
102    * Set the global high gain conversion factory 
103    * @param factor is the conversion factor
104    */
105   void SetGlobalHighGainFactor(Float_t factor);
106
107   /**
108    * Set the global low gain conversion factory 
109    * @param factor is the conversion factor
110    */
111   void SetGlobalLowGainFactor(Float_t factor);
112
113   /**
114    * Make the digits for one event.
115    * @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
116    * @return the number of digits found
117    */
118   Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
119
120
121   /**
122    * Set the mask for dead channels
123    * @param badChannelHGHist is a pointer to a high gain bad channel histogram
124    * @param badChannelLGHist is a pointer to a low gain bad channel histogram
125    * @param qCut is the cut 
126    */
127   void SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut);
128
129   /**
130    * Set ordering of gains or not
131    */
132   void SetOrdered(bool val) { fOrdered = val; }
133
134   /**
135    * Reset the digit maker
136    */
137   void Reset() { fDigitCount = 0; }
138
139   /**
140    * Sort the digits and make internal links between them
141    */
142   void SortDigits();
143
144   /** 
145    * Compare two digits, used during the sorting
146    */
147   static Int_t CompareDigits(const void *dig0, const void *dig);
148
149   
150 private:
151
152   /**
153    * Add a new digit
154    * @param channelData is the channel data
155    * @param coordinates is the coordinates of the channel, including gain and module
156    * @return true if the digit is added correctly, false if out of buffer
157    */
158   bool AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
159   {
160     //    HLTError("Available size: %d", fAvailableSize);
161
162     if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
163       {
164         HLTError("Output buffer is full, stopping digit making.");
165         return false;
166       }
167
168
169
170     fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
171
172     fDigitStructPtr->fX = channelCoordinates[0];
173     fDigitStructPtr->fZ = channelCoordinates[1];
174
175     fDigitStructPtr->fID = fDigitStructPtr->fZ * NXCOLUMNSRCU + fDigitStructPtr->fX;
176
177     fDigitStructPtr->fLocX = localCoordinates[0];
178     fDigitStructPtr->fLocZ = localCoordinates[1];
179
180     if(channelCoordinates[2] == HIGHGAIN)
181       {
182         fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[channelCoordinates[0]][channelCoordinates[1]];
183         //      HLTError("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy);
184       }
185     else
186       {
187         fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[channelCoordinates[0]][channelCoordinates[1]];
188         //      HLTError("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy); 
189       }
190     fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
191     fDigitStructPtr->fCrazyness = channelData->fCrazyness;
192     fDigitStructPtr->fModule = channelCoordinates[3];
193
194     fDigitPtrArray[fDigitCount] = fDigitStructPtr;
195     fDigitCount++;
196     fDigitStructPtr++;
197     return true;
198   }
199
200   /** Pointer to shared memory interface */
201   AliHLTPHOSSharedMemoryInterfacev2* fShmPtr;                    //! transient
202
203   /** Pointer to the AliHLTPHOSDigitDataStruct */
204   AliHLTPHOSDigitDataStruct *fDigitStructPtr;                    //! transient
205
206   /** Pointer to the AliHLTPHOSDigitDataStruct */
207   AliHLTPHOSDigitHeaderStruct *fDigitHeaderPtr;                  //! transient
208
209   /** Digit count */
210   Int_t fDigitCount;                                             //COMMENT
211
212   /** Are the gains ordered? */
213   bool fOrdered;                                                 //COMMENT
214
215   /** Mapper */
216   AliHLTPHOSMapper* fMapperPtr;                                  //COMMENT
217
218   /** High gain energy conversion factors */
219   Float_t fHighGainFactors[NXCOLUMNSMOD][NZROWSMOD];         //COMMENT
220
221   /** Low gain energy conversion factors */
222   Float_t fLowGainFactors[NXCOLUMNSMOD][NZROWSMOD];          //COMMENT
223
224   /** Bad channel mask */
225   Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
226
227   /** Array of digit pointers */
228   AliHLTPHOSDigitDataStruct **fDigitPtrArray;               //COMMENT
229   
230   /** The available size of the output buffer */
231   AliHLTUInt32_t fAvailableSize;                            //COMMENT
232
233   ClassDef(AliHLTPHOSDigitMaker, 0); 
234
235 };
236
237
238 #endif
239