]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMaker.h
Small bug fixes (mainly in mapping) and some clean up
[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 "AliHLTPHOSConstants.h"
39 #include "AliHLTPHOSDigitDataStruct.h"
40 #include "AliHLTPHOSChannelDataStruct.h"
41
42 /**
43  * @class AliHLTPHOSDigitMaker
44  * Digit maker for PHOS HLT. Takes input from AliHLTPHOSRawAnalyzer, and 
45  * outputs a block of AliHLTPHOSDigitDataStruct container
46  * @ingroup alihlt_phos
47  */
48
49 class TH2F;
50 class AliHLTPHOSSharedMemoryInterfacev2; // added by PTH
51 class AliHLTPHOSChannelDataHeaderStruct;
52 class AliHLTPHOSMapper;
53        
54 using namespace PhosHLTConst;
55
56 class AliHLTPHOSDigitMaker : public AliHLTPHOSBase
57 {
58 public:
59
60   /** Constructor */
61   AliHLTPHOSDigitMaker();
62
63   /** Destructor */
64   virtual ~AliHLTPHOSDigitMaker();
65
66   /** Copy constructor */  
67   AliHLTPHOSDigitMaker(const AliHLTPHOSDigitMaker &) : 
68     AliHLTPHOSBase(),
69     fShmPtr(0),
70     fDigitStructPtr(0),
71     fDigitCount(0),
72     fOrdered(true),
73     fMapperPtr(0)
74   {
75     //Copy constructor not implemented
76   }
77   
78   /** Assignment */
79   AliHLTPHOSDigitMaker & operator = (const AliHLTPHOSDigitMaker)
80   {
81     //Assignment
82     return *this; 
83   }
84
85   /**
86    * Sets the pointer to the output
87    * @param the output pointer
88    */
89   void SetDigitDataPtr(AliHLTPHOSDigitDataStruct *digitDataPtr) 
90   { fDigitStructPtr = digitDataPtr; }
91
92   /**
93    * Set the global high gain conversion factory 
94    * @param factor is the conversion factor
95    */
96   void SetGlobalHighGainFactor(Float_t factor);
97
98   /**
99    * Set the global low gain conversion factory 
100    * @param factor is the conversion factor
101    */
102   void SetGlobalLowGainFactor(Float_t factor);
103
104   /**
105    * Make the digits for one event.
106    * @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
107    * @return the number of digits found
108    */
109   Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
110
111
112   /**
113    * Set the mask for dead channels
114    * @param badChannelHGHist is a pointer to a high gain bad channel histogram
115    * @param badChannelLGHist is a pointer to a low gain bad channel histogram
116    * @param qCut is the cut 
117    */
118   void SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut);
119
120   /**
121    * Set ordering of gains or not
122    */
123   void SetOrdered(bool val) { fOrdered = val; }
124   
125   void Reset() { fDigitCount = 0; }
126
127 private:
128
129   /**
130    * Add a new digit
131    * @param channelData is the channel data
132    * @param coordinates is the coordinates of the channel, including gain and module
133    */
134   void AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
135   {
136     fDigitStructPtr->fX = localCoordinates[0];
137     fDigitStructPtr->fZ = localCoordinates[1];
138     if(channelCoordinates[2] == HIGHGAIN)
139       {
140         fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[channelCoordinates[0]][channelCoordinates[1]];
141         //      printf("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy);
142       }
143     else
144       {
145         fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[channelCoordinates[0]][channelCoordinates[1]];
146         //      printf("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", channelCoordinates[0], channelCoordinates[1], channelData->fEnergy, fDigitStructPtr->fEnergy); 
147       }
148     fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
149     fDigitStructPtr->fCrazyness = channelData->fCrazyness;
150     fDigitStructPtr->fModule = channelCoordinates[3];
151     fDigitStructPtr++;
152   }
153
154   /** Pointer to shared memory interface */
155   AliHLTPHOSSharedMemoryInterfacev2* fShmPtr;                    //! transient
156
157   /** Pointer to the AliHLTPHOSDigitDataStruct */
158   AliHLTPHOSDigitDataStruct *fDigitStructPtr;                    //! transient
159
160   /** Digit count */
161   Int_t fDigitCount;                                             //COMMENT
162
163   /** Are the gains ordered? */
164   bool fOrdered;                                                 //COMMENT
165
166   /** Mapper */
167   AliHLTPHOSMapper* fMapperPtr;                                  //COMMENT
168
169   /** High gain energy conversion factors */
170   Float_t fHighGainFactors[NXCOLUMNSMOD][NZROWSMOD];         //COMMENT
171
172   /** Low gain energy conversion factors */
173   Float_t fLowGainFactors[NXCOLUMNSMOD][NZROWSMOD];          //COMMENT
174
175   /** Bad channel mask */
176   Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
177
178
179   ClassDef(AliHLTPHOSDigitMaker, 0); 
180
181 };
182
183
184 #endif
185