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
52 class AliHLTPHOSSharedMemoryInterfacev2; // added by PTH
53 class AliHLTPHOSChannelDataHeaderStruct;
54 class AliHLTPHOSMapper;
56 using namespace PhosHLTConst;
58 //class AliHLTPHOSDigitMaker : public AliHLTPHOSBase
59 class AliHLTPHOSDigitMaker : public AliHLTLogging
64 AliHLTPHOSDigitMaker();
67 virtual ~AliHLTPHOSDigitMaker();
69 /** Copy constructor */
70 AliHLTPHOSDigitMaker(const AliHLTPHOSDigitMaker &) :
81 //Copy constructor not implemented
85 AliHLTPHOSDigitMaker & operator = (const AliHLTPHOSDigitMaker)
92 * Sets the pointer to the output
93 * @param the output pointer
95 void SetDigitHeaderPtr(AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
97 fDigitHeaderPtr = digitHeaderPtr;
98 fDigitStructPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(digitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct));
102 * Set the global high gain conversion factory
103 * @param factor is the conversion factor
105 void SetGlobalHighGainFactor(Float_t factor);
108 * Set the global low gain conversion factory
109 * @param factor is the conversion factor
111 void SetGlobalLowGainFactor(Float_t factor);
114 * Make the digits for one event.
115 * @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
116 * @return the number of digits found
118 Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
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
127 void SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut);
130 * Set ordering of gains or not
132 void SetOrdered(bool val) { fOrdered = val; }
135 * Reset the digit maker
137 void Reset() { fDigitCount = 0; }
140 * Sort the digits and make internal links between them
145 * Compare two digits, used during the sorting
147 static Int_t CompareDigits(const void *dig0, const void *dig);
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
158 bool AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
160 // HLTError("Available size: %d", fAvailableSize);
162 if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
164 HLTError("Output buffer is full, stopping digit making.");
170 fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
172 fDigitStructPtr->fX = channelCoordinates[0];
173 fDigitStructPtr->fZ = channelCoordinates[1];
175 fDigitStructPtr->fID = fDigitStructPtr->fZ * NXCOLUMNSRCU + fDigitStructPtr->fX;
177 fDigitStructPtr->fLocX = localCoordinates[0];
178 fDigitStructPtr->fLocZ = localCoordinates[1];
180 if(channelCoordinates[2] == HIGHGAIN)
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);
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);
190 fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
191 fDigitStructPtr->fCrazyness = channelData->fCrazyness;
192 fDigitStructPtr->fModule = channelCoordinates[3];
194 fDigitPtrArray[fDigitCount] = fDigitStructPtr;
200 /** Pointer to shared memory interface */
201 AliHLTPHOSSharedMemoryInterfacev2* fShmPtr; //! transient
203 /** Pointer to the AliHLTPHOSDigitDataStruct */
204 AliHLTPHOSDigitDataStruct *fDigitStructPtr; //! transient
206 /** Pointer to the AliHLTPHOSDigitDataStruct */
207 AliHLTPHOSDigitHeaderStruct *fDigitHeaderPtr; //! transient
210 Int_t fDigitCount; //COMMENT
212 /** Are the gains ordered? */
213 bool fOrdered; //COMMENT
216 AliHLTPHOSMapper* fMapperPtr; //COMMENT
218 /** High gain energy conversion factors */
219 Float_t fHighGainFactors[NXCOLUMNSMOD][NZROWSMOD]; //COMMENT
221 /** Low gain energy conversion factors */
222 Float_t fLowGainFactors[NXCOLUMNSMOD][NZROWSMOD]; //COMMENT
224 /** Bad channel mask */
225 Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
227 /** Array of digit pointers */
228 AliHLTPHOSDigitDataStruct **fDigitPtrArray; //COMMENT
230 /** The available size of the output buffer */
231 AliHLTUInt32_t fAvailableSize; //COMMENT
233 ClassDef(AliHLTPHOSDigitMaker, 0);