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