]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSDigitMaker.cxx
Script too start the PHOS HLT Online display
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMaker.cxx
CommitLineData
2374af72 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: Oystein Djuvsland *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 /**
16 * @file AliHLTPHOSClusterizer.cxx
17 * @author Oystein Djuvsland
18 * @date
d949e02e 19 * @brief Digit maker for PHOS HLT
2374af72 20 */
21
22
23// see header file for class documentation
24// or
25// refer to README to build package
26// or
27// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
209a4703 28
29#include "AliHLTPHOSDigitMaker.h"
30#include "AliHLTPHOSDigit.h"
31#include "AliHLTPHOSConstants.h"
32#include "AliHLTPHOSBaseline.h"
33#include "TTree.h"
34#include "TBranch.h"
35#include "TClonesArray.h"
36#include "TFile.h"
d949e02e 37#include "TH2F.h"
209a4703 38
39#include "AliHLTPHOSValidCellDataStruct.h"
40#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
209a4703 41#include "AliHLTPHOSDigitDataStruct.h"
42#include "AliHLTPHOSDigitContainerDataStruct.h"
14ff16ed 43#include "AliHLTPHOSSharedMemoryInterface.h" // added by PTH
2374af72 44
45ClassImp(AliHLTPHOSDigitMaker);
209a4703 46
47using namespace PhosHLTConst;
48
49AliHLTPHOSDigitMaker::AliHLTPHOSDigitMaker() :
50 AliHLTPHOSBase(),
51 fCellDataPtr(0),
d949e02e 52 fDigitContainerStructPtr(0),
209a4703 53 fDigitArrayPtr(0),
d949e02e 54 fDigitStructPtr(0),
55 fDigitCount(0)
209a4703 56{
2374af72 57 // See header file for documentation
b444d727 58 for(int x = 0; x < N_XCOLUMNS_MOD; x++)
25b7f84c 59 {
b444d727 60 for(int z = 0; z < N_ZROWS_MOD; z++)
25b7f84c 61 {
62 fHighGainFactors[x][z] = 0.005;
63 fLowGainFactors[x][z] = 0.08;
64 }
65 }
66
209a4703 67}
68
69AliHLTPHOSDigitMaker::~AliHLTPHOSDigitMaker()
70{
2374af72 71 //See header file for documentation
209a4703 72}
73
74Int_t
75AliHLTPHOSDigitMaker::MakeDigits(AliHLTPHOSRcuCellEnergyDataStruct* rcuData)
76{
2374af72 77 //See header file for documentation
25b7f84c 78
209a4703 79 Int_t j = 0;
d949e02e 80 Int_t xMod = -1;
81 Int_t zMod = -1;
209a4703 82 Float_t amplitude = 0;
d949e02e 83
b444d727 84 for(int x = 0; x < N_XCOLUMNS_RCU; x++)
14ff16ed 85 {
b444d727 86 for(int z = 0; z < N_ZROWS_RCU; z++)
14ff16ed 87 {
d949e02e 88 fCellDataPtr = &(rcuData->fValidData[x][z][HIGH_GAIN]);
89 xMod = x + rcuData->fRcuX * N_XCOLUMNS_RCU;
90 zMod = z + rcuData->fRcuZ * N_ZROWS_RCU;
91 amplitude = fCellDataPtr->fEnergy;
92 if(amplitude > fDigitThresholds[xMod][zMod][HIGH_GAIN] && amplitude < MAX_BIN_VALUE)
93 {
94 fDigitStructPtr = &(fDigitContainerStructPtr->fDigitDataStruct[j+fDigitCount]);
95 fDigitStructPtr->fX = xMod;
96 fDigitStructPtr->fZ = zMod;
97 fDigitStructPtr->fAmplitude = amplitude;
98 fDigitStructPtr->fEnergy = amplitude * fHighGainFactors[xMod][zMod];
d949e02e 99 //TODO: fix time
100 fDigitStructPtr->fTime = fCellDataPtr->fTime * 0.0000001;
101 fDigitStructPtr->fCrazyness = fCellDataPtr->fCrazyness;
25b7f84c 102 fDigitStructPtr->fModule = rcuData->fModuleID;
d949e02e 103 j++;
104 }
105 else if(amplitude >= MAX_BIN_VALUE)
106 {
107 fCellDataPtr = & (rcuData->fValidData[x][z][LOW_GAIN]);
108 amplitude = fCellDataPtr->fEnergy;
109 if(amplitude > fDigitThresholds[xMod][zMod][LOW_GAIN])
110 {
111 fDigitStructPtr = &(fDigitContainerStructPtr->fDigitDataStruct[j+fDigitCount]);
112 fDigitStructPtr->fX = xMod;
113 fDigitStructPtr->fZ = zMod;
114 fDigitStructPtr->fAmplitude = amplitude;
115 fDigitStructPtr->fEnergy = amplitude * fLowGainFactors[xMod][zMod];
116 //TODO: fix time
117 fDigitStructPtr->fTime = fCellDataPtr->fTime * 0.0000001;;
118 fDigitStructPtr->fCrazyness = fCellDataPtr->fCrazyness;
25b7f84c 119 fDigitStructPtr->fModule = rcuData->fModuleID;
d949e02e 120 j++;
121 }
122 }
14ff16ed 123 }
14ff16ed 124 }
d949e02e 125
14ff16ed 126 fDigitCount += j;
d949e02e 127 fDigitContainerStructPtr->fNDigits = fDigitCount;
14ff16ed 128 return fDigitCount;
129}
130
131
d949e02e 132void
133AliHLTPHOSDigitMaker::Reset()
134{
14ff16ed 135 //See header file for documentation
d949e02e 136 fDigitCount = 0;
209a4703 137}
14ff16ed 138
d949e02e 139void
140AliHLTPHOSDigitMaker::SetGlobalHighGainFactor(Float_t factor)
209a4703 141{
d949e02e 142 //See header file for documentation
b444d727 143 for(int x = 0; x < N_XCOLUMNS_MOD; x++)
d949e02e 144 {
b444d727 145 for(int z = 0; z < N_ZROWS_MOD; z++)
d949e02e 146 {
147 fHighGainFactors[x][z] = factor;
148 }
149 }
209a4703 150}
209a4703 151
152void
d949e02e 153AliHLTPHOSDigitMaker::SetGlobalLowGainFactor(Float_t factor)
154{
155 //See header file for documentation
b444d727 156 for(int x = 0; x < N_XCOLUMNS_MOD; x++)
d949e02e 157 {
b444d727 158 for(int z = 0; z < N_ZROWS_MOD; z++)
d949e02e 159 {
160 fLowGainFactors[x][z] = factor;
161 }
162 }
209a4703 163}
164
d949e02e 165void
166AliHLTPHOSDigitMaker::SetDigitThresholds(const char* filepath, Int_t nSigmas)
167{
168 //See header file for documentation
d949e02e 169 TFile *histFile = new TFile(filepath);
209a4703 170
d949e02e 171 TH2F *lgHist = (TH2F*)histFile->Get("RMSLGMapHist");
172 TH2F *hgHist = (TH2F*)histFile->Get("RMSHGMapHist");
209a4703 173
b444d727 174 for(int x = 0; x < N_XCOLUMNS_MOD; x++)
d949e02e 175 {
b444d727 176 for(int z = 0; z < N_ZROWS_MOD; z++)
d949e02e 177 {
178 fDigitThresholds[x][z][LOW_GAIN] = lgHist->GetBinContent(x, z) * nSigmas;
179 fDigitThresholds[x][z][HIGH_GAIN] = hgHist->GetBinContent(x, z) * nSigmas;
180 }
181 }
182}