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