]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRcuDAComponent.cxx
Cosmetics and minor modifications
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuDAComponent.cxx
CommitLineData
64357c47 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
64357c47 17#include "AliPHOSRcuDA1.h"
18#include "AliHLTPHOSSharedMemoryInterface.h"
19#include "AliHLTPHOSRcuDAComponent.h"
20#include "AliHLTPHOSDefinitions.h"
21#include "AliHLTPHOSConstants.h"
22#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
23#include "TObjArray.h"
24
25//#include <iostream>
26
27/** @file AliHLTPHOSRcuDAComponent.cxx
28 @author Oystein Djuvsland
29 @date
30 @brief A module calibration component for PHOS HLT, using the PHOS DA's
31*/
32
33// see header file for class documentation
34// or
35// refer to README to build package
36// or
37// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
38
39using namespace PhosHLTConst;
40
41AliHLTPHOSRcuDAComponent gAliHLTPHOSRcuDAComponent;
42
43AliHLTPHOSRcuDAComponent::AliHLTPHOSRcuDAComponent() : AliHLTPHOSRcuProperties(),
44 AliHLTCalibrationProcessor(),
6e587e00 45 fPhosEventCount(0),
64357c47 46 fPHOSDAPtr(0),
47 fShmPtr(0)
48 // fTest(-2)
49{
50 fShmPtr = new AliHLTPHOSSharedMemoryInterface();
51}
52
53
6e587e00 54
64357c47 55AliHLTPHOSRcuDAComponent::~AliHLTPHOSRcuDAComponent()
56{
57 if(fShmPtr)
58 {
59 delete fShmPtr;
60 fShmPtr = 0;
61 }
62 if(fPHOSDAPtr)
63 {
64 delete fPHOSDAPtr;
65 fPHOSDAPtr = 0;
66 }
67}
68
69
70void AliHLTPHOSRcuDAComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
71{
72 list.clear();
73 list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
74}
75
76
77AliHLTComponentDataType AliHLTPHOSRcuDAComponent::GetOutputDataType()
78{
79 return AliHLTPHOSDefinitions::fgkEmcCalibDataType;
80}
81
82
83void AliHLTPHOSRcuDAComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
84{
85 constBase = 0;
86 inputMultiplier = 2;
87}
88
89
90AliHLTComponent*
91AliHLTPHOSRcuDAComponent::Spawn()
92{
93 return new AliHLTPHOSRcuDAComponent();
94}
95
96const char*
97AliHLTPHOSRcuDAComponent::GetComponentID()
98{
99 return "PhosRcuDAProcessor";
100}
101
102
103Int_t
104AliHLTPHOSRcuDAComponent::ScanArgument( Int_t argc, const char** argv)
105{
106 ScanArguments(argc, argv);
107 return 0;
108}
109
110
111Int_t AliHLTPHOSRcuDAComponent::InitCalibration()
112{
113 //CRAP PT just to get something working by 5 May 2008
114 const int tmpModule = 2;
115 fPHOSDAPtr = new AliPHOSRcuDA1(tmpModule ,GetRCUID());
116 return 0;
117}
118
119
120Int_t AliHLTPHOSRcuDAComponent::DeinitCalibration()
121{
122 AliHLTComponentEventData dummyEvtData;
123 AliHLTComponentTriggerData dummyTrgData;
124 ShipDataToFXS(dummyEvtData, dummyTrgData);
125
126
127 if(fShmPtr)
128 {
129 delete fShmPtr;
130 fShmPtr = 0;
131 }
132 if(fPHOSDAPtr)
133 {
134 delete fPHOSDAPtr;
135 fPHOSDAPtr = 0;
136 }
137 return 0;
138}
139
140
141
142Int_t AliHLTPHOSRcuDAComponent::ProcessCalibration(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
143{
144 fPhosEventCount ++;
145 const AliHLTComponentEventData eDta = evtData;
146 AliHLTComponentTriggerData tDta = trigData;
147
148 UInt_t specification = 0;
149 const AliHLTComponentBlockData* iter = 0;
150 iter = GetFirstInputBlock( AliHLTPHOSDefinitions::fgkCellEnergyDataType | kAliHLTDataOriginPHOS);
151
152 AliHLTPHOSRcuCellEnergyDataStruct* cellDataPtr = 0;
7ce40e5c 153 AliHLTPHOSValidCellDataStruct *currentChannel =0;
64357c47 154 Int_t xOffset = 0;
155 Int_t zOffset = 0;
156 Int_t module = -1;
157
158 Float_t energyArray[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];
159 Float_t timeArray[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];
160 ResetArrays(energyArray, timeArray);
161
162 while(iter != 0)
163 {
164 specification = specification|iter->fSpecification;
165 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
166 module = cellDataPtr->fModuleID;
167 xOffset = cellDataPtr->fRcuX*N_XCOLUMNS_RCU;
168 zOffset = cellDataPtr->fRcuZ*N_ZROWS_RCU;
169
7ce40e5c 170 while(currentChannel != 0)
64357c47 171 {
7ce40e5c 172 Int_t tmpZ = currentChannel->fZ;
173 Int_t tmpX = currentChannel->fX;
174 Int_t tmpGain = currentChannel->fGain;
175
176 energyArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fEnergy;
177 timeArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fTime;
64357c47 178 }
7ce40e5c 179
180// for(Int_t x = 0; x < N_XCOLUMNS_RCU; x++)
181// {
182// for(Int_t z = 0; z < N_ZROWS_RCU; z++)
183// {
184// for(Int_t gain = 0; gain < N_GAINS; gain++)
185// {
186// energyArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fEnergy;
187// timeArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fTime;
188// }
189// }
190// }
64357c47 191 iter = GetNextInputBlock();
192 }
193
194 fPHOSDAPtr->FillHistograms(energyArray, timeArray);
195
196 ResetArrays(energyArray, timeArray);
197
198 return 0;
199}
200
201
202Int_t
203AliHLTPHOSRcuDAComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ )
204{
205 Char_t filename[200];
206
207 for(int i=0; i < 200; i++)
208 {
209 filename[i] = 0;
210 }
211 const TObjArray *calibPtr = fPHOSDAPtr->GetHistoContainer();
212 sprintf(filename, "/home/perthi/hlt/rundir/test/outdata/%s.root", fPHOSDAPtr->GetName() );
213 TFile *outFile = new TFile(filename, "recreate");
214 calibPtr->Write();
215 outFile->Close();
216 PushToFXS( (TObject*)fPHOSDAPtr->GetHistoContainer(), "PHOS", filename);
217 cout << "Finnished pushing data to HLT FXS" << endl;
218 return 0;
219}
220
221
222void
223AliHLTPHOSRcuDAComponent::ResetArrays(Float_t e[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS], Float_t t[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS])
224{
225 for(Int_t x = 0; x < N_XCOLUMNS_RCU; x++)
226 {
227 for(Int_t z = 0; z < N_ZROWS_RCU; z++)
228 {
229 for(Int_t gain = 0; gain < N_GAINS; gain++)
230 {
231 e[x][z][gain] = 0;
232 t[x][z][gain] = 0;
233 }
234 }
235 }
236}