]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMaker.h
- fixed wrong constant
[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 #include <AliHLTCaloConstantsHandler.h>
51
52 class TH2F;
53 class AliHLTPHOSSharedMemoryInterfacev2; // added by PTH
54 class AliHLTPHOSChannelDataHeaderStruct;
55 class AliHLTPHOSMapper;
56        
57 using namespace PhosHLTConst;
58
59 //class AliHLTPHOSDigitMaker : public AliHLTPHOSBase
60 class AliHLTPHOSDigitMaker : public AliHLTCaloConstantsHandler
61 {
62 public:
63
64   /** Constructor */
65   AliHLTPHOSDigitMaker();
66
67   /** Destructor */
68   virtual ~AliHLTPHOSDigitMaker();
69
70   /** Copy constructor */  
71   AliHLTPHOSDigitMaker(const AliHLTPHOSDigitMaker &) : 
72     AliHLTLogging(),
73     fShmPtr(0),
74     fDigitStructPtr(0),
75     fDigitHeaderPtr(0),
76     fDigitCount(0),
77     fOrdered(true),
78     fMapperPtr(0),
79     fDigitPtrArray(0),
80     fAvailableSize(0)
81   {
82     //Copy constructor not implemented
83   }
84   
85   /** Assignment */
86   AliHLTPHOSDigitMaker & operator = (const AliHLTPHOSDigitMaker)
87   {
88     //Assignment
89     return *this; 
90   }
91
92   /**
93    * Sets the pointer to the output
94    * @param the output pointer
95    */
96   void SetDigitHeaderPtr(AliHLTPHOSDigitHeaderStruct *digitHeaderPtr) 
97   { 
98     fDigitHeaderPtr = digitHeaderPtr;
99     fDigitStructPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(digitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct));
100   }
101
102   /**
103    * Set the global high gain conversion factory 
104    * @param factor is the conversion factor
105    */
106   void SetGlobalHighGainFactor(Float_t factor);
107
108   /**
109    * Set the global low gain conversion factory 
110    * @param factor is the conversion factor
111    */
112   void SetGlobalLowGainFactor(Float_t factor);
113
114   /**
115    * Make the digits for one event.
116    * @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
117    * @return the number of digits found
118    */
119   Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
120
121
122   /**
123    * Set the mask for dead channels
124    * @param badChannelHGHist is a pointer to a high gain bad channel histogram
125    * @param badChannelLGHist is a pointer to a low gain bad channel histogram
126    * @param qCut is the cut 
127    */
128   void SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut);
129
130   /**
131    * Set ordering of gains or not
132    */
133   void SetOrdered(bool val) { fOrdered = val; }
134
135   /**
136    * Reset the digit maker
137    */
138   void Reset() { fDigitCount = 0; }
139
140   /**
141    * Sort the digits and make internal links between them
142    */
143   void SortDigits();
144
145   /** 
146    * Compare two digits, used during the sorting
147    */
148   static Int_t CompareDigits(const void *dig0, const void *dig);
149
150   
151 private:
152
153   /**
154    * Add a new digit
155    * @param channelData is the channel data
156    * @param coordinates is the coordinates of the channel, including gain and module
157    * @return true if the digit is added correctly, false if out of buffer
158    */
159   bool AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
160   {
161     //    HLTError("Available size: %d", fAvailableSize);
162
163     if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
164       {
165         HLTError("Output buffer is full, stopping digit making.");
166         return false;
167       }
168
169
170
171     fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
172
173     fDigitStructPtr->fX = channelCoordinates[0];
174     fDigitStructPtr->fZ = channelCoordinates[1];
175
176     fDigitStructPtr->fID = fDigitStructPtr->fZ * NXCOLUMNSRCU + fDigitStructPtr->fX;
177
178     fDigitStructPtr->fLocX = localCoordinates[0];
179     fDigitStructPtr->fLocZ = localCoordinates[1];
180
181     if(channelCoordinates[2] == HIGHGAIN)
182       {
183         fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[channelCoordinates[0]][channelCoordinates[1]];
184         //      HLTError("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy);
185       }
186     else
187       {
188         fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[channelCoordinates[0]][channelCoordinates[1]];
189         //      HLTError("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy); 
190       }
191     fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
192     fDigitStructPtr->fCrazyness = channelData->fCrazyness;
193     fDigitStructPtr->fModule = channelCoordinates[3];
194
195     fDigitPtrArray[fDigitCount] = fDigitStructPtr;
196     fDigitCount++;
197     fDigitStructPtr++;
198     return true;
199   }
200
201   /** Pointer to shared memory interface */
202   AliHLTPHOSSharedMemoryInterfacev2* fShmPtr;                    //! transient
203
204   /** Pointer to the AliHLTPHOSDigitDataStruct */
205   AliHLTPHOSDigitDataStruct *fDigitStructPtr;                    //! transient
206
207   /** Pointer to the AliHLTPHOSDigitDataStruct */
208   AliHLTPHOSDigitHeaderStruct *fDigitHeaderPtr;                  //! transient
209
210   /** Digit count */
211   Int_t fDigitCount;                                             //COMMENT
212
213   /** Are the gains ordered? */
214   bool fOrdered;                                                 //COMMENT
215
216   /** Mapper */
217   AliHLTPHOSMapper* fMapperPtr;                                  //COMMENT
218
219   /** High gain energy conversion factors */
220   Float_t fHighGainFactors[NXCOLUMNSMOD][NZROWSMOD];         //COMMENT
221
222   /** Low gain energy conversion factors */
223   Float_t fLowGainFactors[NXCOLUMNSMOD][NZROWSMOD];          //COMMENT
224
225   /** Bad channel mask */
226   Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
227
228   /** Array of digit pointers */
229   AliHLTPHOSDigitDataStruct **fDigitPtrArray;               //COMMENT
230   
231   /** The available size of the output buffer */
232   AliHLTUInt32_t fAvailableSize;                            //COMMENT
233
234   ClassDef(AliHLTPHOSDigitMaker, 0); 
235
236 };
237
238
239 #endif
240