5 /**************************************************************************
6 * This file is property of and copyright by the ALICE HLT Project *
7 * All rights reserved. *
9 * Primary Authors: Oystein Djuvsland *
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
23 * Class makes digits from information from raw data
25 * @file AliHLTPHOSDigitMaker.h
26 * @author Oystein Djuvsland
28 * @brief Digit maker for PHOS HLT
31 // see below for class documentation
33 // refer to README to build package
35 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
37 //#include "AliHLTPHOSBase.h"
38 #include "AliHLTPHOSConstant.h"
39 #include "AliHLTPHOSDigitDataStruct.h"
40 #include "AliHLTPHOSChannelDataStruct.h"
41 #include "AliHLTDataTypes.h"
42 #include "AliHLTLogging.h"
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
50 #include <AliHLTCaloConstantsHandler.h>
53 class AliHLTPHOSSharedMemoryInterfacev2; // added by PTH
54 class AliHLTPHOSChannelDataHeaderStruct;
55 class AliHLTPHOSMapper;
57 using namespace PhosHLTConst;
59 //class AliHLTPHOSDigitMaker : public AliHLTPHOSBase
60 class AliHLTPHOSDigitMaker : public AliHLTCaloConstantsHandler
65 AliHLTPHOSDigitMaker();
68 virtual ~AliHLTPHOSDigitMaker();
70 /** Copy constructor */
71 AliHLTPHOSDigitMaker(const AliHLTPHOSDigitMaker &) :
82 //Copy constructor not implemented
86 AliHLTPHOSDigitMaker & operator = (const AliHLTPHOSDigitMaker)
93 * Sets the pointer to the output
94 * @param the output pointer
96 void SetDigitHeaderPtr(AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
98 fDigitHeaderPtr = digitHeaderPtr;
99 fDigitStructPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(digitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct));
103 * Set the global high gain conversion factory
104 * @param factor is the conversion factor
106 void SetGlobalHighGainFactor(Float_t factor);
109 * Set the global low gain conversion factory
110 * @param factor is the conversion factor
112 void SetGlobalLowGainFactor(Float_t factor);
115 * Make the digits for one event.
116 * @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
117 * @return the number of digits found
119 Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
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
128 void SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut);
131 * Set ordering of gains or not
133 void SetOrdered(bool val) { fOrdered = val; }
136 * Reset the digit maker
138 void Reset() { fDigitCount = 0; }
141 * Sort the digits and make internal links between them
146 * Compare two digits, used during the sorting
148 static Int_t CompareDigits(const void *dig0, const void *dig);
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
159 bool AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
161 // HLTError("Available size: %d", fAvailableSize);
163 if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
165 HLTError("Output buffer is full, stopping digit making.");
171 fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
173 fDigitStructPtr->fX = channelCoordinates[0];
174 fDigitStructPtr->fZ = channelCoordinates[1];
176 fDigitStructPtr->fID = fDigitStructPtr->fZ * NXCOLUMNSRCU + fDigitStructPtr->fX;
178 fDigitStructPtr->fLocX = localCoordinates[0];
179 fDigitStructPtr->fLocZ = localCoordinates[1];
181 if(channelCoordinates[2] == HIGHGAIN)
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);
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);
191 fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
192 fDigitStructPtr->fCrazyness = channelData->fCrazyness;
193 fDigitStructPtr->fModule = channelCoordinates[3];
195 fDigitPtrArray[fDigitCount] = fDigitStructPtr;
201 /** Pointer to shared memory interface */
202 AliHLTPHOSSharedMemoryInterfacev2* fShmPtr; //! transient
204 /** Pointer to the AliHLTPHOSDigitDataStruct */
205 AliHLTPHOSDigitDataStruct *fDigitStructPtr; //! transient
207 /** Pointer to the AliHLTPHOSDigitDataStruct */
208 AliHLTPHOSDigitHeaderStruct *fDigitHeaderPtr; //! transient
211 Int_t fDigitCount; //COMMENT
213 /** Are the gains ordered? */
214 bool fOrdered; //COMMENT
217 AliHLTPHOSMapper* fMapperPtr; //COMMENT
219 /** High gain energy conversion factors */
220 Float_t fHighGainFactors[NXCOLUMNSMOD][NZROWSMOD]; //COMMENT
222 /** Low gain energy conversion factors */
223 Float_t fLowGainFactors[NXCOLUMNSMOD][NZROWSMOD]; //COMMENT
225 /** Bad channel mask */
226 Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
228 /** Array of digit pointers */
229 AliHLTPHOSDigitDataStruct **fDigitPtrArray; //COMMENT
231 /** The available size of the output buffer */
232 AliHLTUInt32_t fAvailableSize; //COMMENT
234 ClassDef(AliHLTPHOSDigitMaker, 0);