]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRcuDAComponent.cxx
Script too start the PHOS HLT Online display
[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;
153 Int_t xOffset = 0;
154 Int_t zOffset = 0;
155 Int_t module = -1;
156
157 Float_t energyArray[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];
158 Float_t timeArray[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];
159 ResetArrays(energyArray, timeArray);
160
161 while(iter != 0)
162 {
163 specification = specification|iter->fSpecification;
164 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
165 module = cellDataPtr->fModuleID;
166 xOffset = cellDataPtr->fRcuX*N_XCOLUMNS_RCU;
167 zOffset = cellDataPtr->fRcuZ*N_ZROWS_RCU;
168
169 for(Int_t x = 0; x < N_XCOLUMNS_RCU; x++)
170 {
171 for(Int_t z = 0; z < N_ZROWS_RCU; z++)
172 {
173 for(Int_t gain = 0; gain < N_GAINS; gain++)
174 {
175 energyArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fEnergy;
176 timeArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fTime;
177 }
178 }
179 }
180 iter = GetNextInputBlock();
181 }
182
183 fPHOSDAPtr->FillHistograms(energyArray, timeArray);
184
185 ResetArrays(energyArray, timeArray);
186
187 return 0;
188}
189
190
191Int_t
192AliHLTPHOSRcuDAComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ )
193{
194 Char_t filename[200];
195
196 for(int i=0; i < 200; i++)
197 {
198 filename[i] = 0;
199 }
200 const TObjArray *calibPtr = fPHOSDAPtr->GetHistoContainer();
201 sprintf(filename, "/home/perthi/hlt/rundir/test/outdata/%s.root", fPHOSDAPtr->GetName() );
202 TFile *outFile = new TFile(filename, "recreate");
203 calibPtr->Write();
204 outFile->Close();
205 PushToFXS( (TObject*)fPHOSDAPtr->GetHistoContainer(), "PHOS", filename);
206 cout << "Finnished pushing data to HLT FXS" << endl;
207 return 0;
208}
209
210
211void
212AliHLTPHOSRcuDAComponent::ResetArrays(Float_t e[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS], Float_t t[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS])
213{
214 for(Int_t x = 0; x < N_XCOLUMNS_RCU; x++)
215 {
216 for(Int_t z = 0; z < N_ZROWS_RCU; z++)
217 {
218 for(Int_t gain = 0; gain < N_GAINS; gain++)
219 {
220 e[x][z][gain] = 0;
221 t[x][z][gain] = 0;
222 }
223 }
224 }
225}