]>
Commit | Line | Data |
---|---|---|
e642ae99 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Jacek Otwinowski <J.Otwinowski@gsi.de> * | |
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 | /** @file AliHLTTPCOfflineCalibrationComponent.cxx | |
19 | @author Jacek Otwinowski <J.Otwinowski@gsi.de> | |
20 | @date | |
21 | @brief TPC calibration component | |
22 | */ | |
23 | ||
24 | #include "AliHLTTPCOfflineCalibrationComponent.h" | |
25 | #include "TString.h" | |
26 | #include "TObjArray.h" | |
27 | #include "TObjString.h" | |
28 | #include "AliTPCcalibAlign.h" | |
29 | #include "AliTPCcalibTracksGain.h" | |
30 | #include "AliTPCcalibTracks.h" | |
31 | #include "AliESDEvent.h" | |
32 | #include "AliESDfriend.h" | |
33 | #include "AliCDBManager.h" | |
34 | #include "AliTPCcalibDB.h" | |
35 | #include "AliTPCClusterParam.h" | |
36 | #include "AliTPCcalibTracksCuts.h" | |
37 | #include "AliTPCseed.h" | |
38 | #include "AliTPCcalibTracksCuts.h" | |
39 | #include "AliTPCClusterParam.h" | |
40 | #include "AliHLTTPCDefinitions.h" | |
41 | ||
42 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
43 | ClassImp(AliHLTTPCOfflineCalibrationComponent) | |
44 | ||
45 | AliHLTTPCOfflineCalibrationComponent::AliHLTTPCOfflineCalibrationComponent() : AliHLTCalibrationProcessor(), | |
46 | fEnableAnalysis(kTRUE), | |
47 | fClustParam(0), | |
48 | fTrackCuts(0), | |
49 | fTPCcalibAlign(0), | |
50 | fTPCcalibTracksGain(0), | |
51 | fTPCcalibTracks(0) | |
52 | { | |
53 | // see header file for class documentation | |
54 | // or | |
55 | // refer to README to build package | |
56 | // or | |
57 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
58 | } | |
59 | ||
60 | AliHLTTPCOfflineCalibrationComponent::~AliHLTTPCOfflineCalibrationComponent() | |
61 | { | |
62 | // see header file for class documentation | |
63 | } | |
64 | ||
65 | const char* AliHLTTPCOfflineCalibrationComponent::GetComponentID() | |
66 | { | |
67 | // see header file for class documentation | |
68 | return "TPCOfflineCalibration"; | |
69 | } | |
70 | ||
71 | void AliHLTTPCOfflineCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
72 | { | |
73 | // get input data type | |
74 | list.clear(); | |
0e442a0a | 75 | list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*TObjArray of seeds*/); |
e642ae99 | 76 | } |
77 | ||
78 | AliHLTComponentDataType AliHLTTPCOfflineCalibrationComponent::GetOutputDataType() | |
79 | { | |
80 | // return ouput data type | |
81 | return kAliHLTMultipleDataType; | |
82 | } | |
83 | ||
84 | ||
85 | int AliHLTTPCOfflineCalibrationComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
86 | { | |
87 | // create output data type | |
88 | tgtList.clear(); | |
89 | tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibAlignDataType); | |
90 | tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibTracksDataType); | |
91 | tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibTracksGainDataType); | |
92 | ||
93 | return tgtList.size(); | |
94 | } | |
95 | ||
96 | void AliHLTTPCOfflineCalibrationComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
97 | { | |
98 | // get output data size | |
99 | constBase = 30000000; | |
100 | inputMultiplier = 1; | |
101 | } | |
102 | ||
103 | AliHLTComponent* AliHLTTPCOfflineCalibrationComponent::Spawn() | |
104 | { | |
105 | // create instance of the component | |
106 | return new AliHLTTPCOfflineCalibrationComponent; | |
107 | } | |
108 | ||
109 | int AliHLTTPCOfflineCalibrationComponent::InitCalibration() | |
110 | { | |
111 | // init configuration | |
112 | ||
113 | HLTInfo("init calibration component"); | |
114 | int iResult=0; | |
115 | ||
116 | // | |
117 | // initialisation | |
118 | // | |
119 | ||
120 | // Init parameters and cuts | |
121 | fClustParam = AliTPCcalibDB::Instance()->GetClusterParam(); | |
122 | fTrackCuts = new AliTPCcalibTracksCuts(20, 0.4, 0.5, 0.13, 0.018); | |
123 | ||
124 | // Init calibration componenets | |
125 | fTPCcalibAlign = new AliTPCcalibAlign("TPCcalibAlign","TPCcalibAlign"); | |
126 | fTPCcalibTracksGain = new AliTPCcalibTracksGain("TPCcalibTracksGain","TPCcalibTracksGain",fTrackCuts); | |
127 | fTPCcalibTracks = new AliTPCcalibTracks("TPCcalibTracks","TPCcalibTracks",fClustParam,fTrackCuts); | |
128 | ||
129 | if (!fTrackCuts || !fClustParam || !fTPCcalibAlign || !fTPCcalibTracksGain || !fTPCcalibTracks) { | |
130 | HLTError("failed creating internal objects"); | |
131 | iResult=-ENOMEM; | |
132 | } | |
133 | ||
134 | return iResult; | |
135 | } | |
136 | ||
137 | Int_t AliHLTTPCOfflineCalibrationComponent::DeinitCalibration() | |
138 | { | |
139 | // deinit configuration | |
140 | if(fClustParam) delete fClustParam; fClustParam = 0; | |
141 | if(fTrackCuts) delete fTrackCuts; fTrackCuts = 0; | |
142 | ||
143 | if(fTPCcalibAlign) delete fTPCcalibAlign; fTPCcalibAlign = 0; | |
144 | if(fTPCcalibTracksGain) delete fTPCcalibTracksGain; fTPCcalibTracksGain = 0; | |
145 | if(fTPCcalibTracks) delete fTPCcalibTracks; fTPCcalibTracks = 0; | |
146 | ||
147 | return 0; | |
148 | } | |
149 | ||
150 | Int_t AliHLTTPCOfflineCalibrationComponent::ScanArgument(Int_t argc, const char** argv) | |
151 | { | |
152 | int iResult = 0; | |
153 | ||
154 | TString argument=""; | |
155 | TString configuration=""; | |
156 | int bMissingParam=0; | |
157 | for (int i=0; i<argc && iResult>=0; i++) { | |
158 | argument=argv[i]; | |
159 | if (argument.IsNull()) continue; | |
160 | ||
161 | } | |
162 | if (bMissingParam) { | |
163 | HLTError("missing parameter for argument %s", argument.Data()); | |
164 | iResult=-EINVAL; | |
165 | } | |
166 | ||
167 | if (iResult>=0 && !configuration.IsNull()) { | |
168 | iResult=Configure(configuration.Data()); | |
169 | } else { | |
170 | iResult=Reconfigure(NULL, NULL); | |
171 | } | |
172 | ||
173 | return iResult; | |
174 | } | |
175 | ||
176 | int AliHLTTPCOfflineCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
177 | { | |
178 | // calibration function | |
179 | HLTInfo("ProcessCalibration processing data"); | |
180 | ||
181 | int iResult=0; | |
0e442a0a | 182 | TObjArray *pSeedsArray=0; |
e642ae99 | 183 | int slice, patch; |
184 | ||
185 | // calculate specification | |
0e442a0a | 186 | const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); |
e642ae99 | 187 | if(!pBlock) { |
188 | HLTError("Cannot get first data block 0x%08x ",pBlock); | |
189 | iResult=-ENOMEM; return iResult; | |
190 | } | |
191 | int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification); | |
192 | int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification); | |
193 | int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification); | |
194 | int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification); | |
195 | ||
196 | if (fTPCcalibAlign && fTPCcalibTracksGain && fTPCcalibTracks) | |
197 | { | |
0e442a0a | 198 | // loop over input data blocks: TObjArray of TPCseed |
199 | for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC,"TObjArray",0); | |
e642ae99 | 200 | pObj !=0 && iResult>=0; |
201 | pObj = (TObject *)GetNextInputObject(0)) { | |
1726bb2d | 202 | |
0e442a0a | 203 | pSeedsArray = dynamic_cast<TObjArray*>(pObj); |
204 | if (!pSeedsArray) continue; | |
e642ae99 | 205 | |
206 | slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj)); | |
207 | patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj)); | |
208 | ||
209 | if(slice < minSlice) minSlice=slice; | |
210 | if(slice > maxSlice) maxSlice=slice; | |
211 | if(patch < minPatch) minPatch=patch; | |
212 | if(patch > maxPatch) maxPatch=patch; | |
213 | ||
e642ae99 | 214 | // get TPC seeds |
0e442a0a | 215 | Int_t nseed = pSeedsArray->GetEntriesFast(); |
216 | HLTInfo("Number TPC seeds %d",nseed); | |
217 | ||
218 | for(Int_t i=0; i<nseed; ++i) { | |
219 | AliTPCseed *seed = (AliTPCseed*)pSeedsArray->UncheckedAt(i); | |
220 | if(!seed) continue; | |
221 | HLTInfo("Process calibration on seed 0x%08x", seed); | |
222 | fTPCcalibAlign->Process(seed); | |
223 | fTPCcalibTracksGain->Process(seed); | |
224 | fTPCcalibTracks->Process(seed); | |
1726bb2d | 225 | } |
0e442a0a | 226 | |
e642ae99 | 227 | // calculate specification from the specification of input data blocks |
228 | AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(minSlice, maxSlice, minPatch, maxPatch); | |
229 | ||
230 | // send data | |
231 | PushBack((TObject*)fTPCcalibAlign,AliHLTTPCDefinitions::fgkOfflineCalibAlignDataType,iSpecification); | |
232 | PushBack((TObject*)fTPCcalibTracksGain,AliHLTTPCDefinitions::fgkOfflineCalibTracksGainDataType,iSpecification); | |
233 | PushBack((TObject*)fTPCcalibTracks,AliHLTTPCDefinitions::fgkOfflineCalibTracksDataType,iSpecification); | |
234 | ||
0e442a0a | 235 | // reset standard ESD content |
236 | pSeedsArray->Delete(); | |
237 | ||
e642ae99 | 238 | }// end loop over input objects |
239 | ||
240 | } else { | |
241 | HLTError("component not initialized"); | |
242 | iResult=-ENOMEM; | |
243 | } | |
244 | ||
245 | return iResult; | |
246 | } | |
247 | ||
248 | Int_t AliHLTTPCOfflineCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, | |
249 | AliHLTComponentTriggerData& /*trigData*/ ) { | |
250 | // see header file for class documentation | |
251 | if( fEnableAnalysis ) | |
252 | { | |
253 | fTPCcalibAlign->Analyze(); | |
254 | fTPCcalibTracksGain->Analyze(); | |
255 | fTPCcalibTracks->Analyze(); | |
256 | } | |
257 | PushToFXS((TObject*)fTPCcalibAlign, "TPC", "TPCcalibAlign") ; | |
258 | PushToFXS((TObject*)fTPCcalibTracksGain, "TPC", "TPCcalibTracksGain") ; | |
259 | PushToFXS((TObject*)fTPCcalibTracks, "TPC", "TPCcalibTracks") ; | |
260 | ||
261 | return 0; | |
262 | } | |
263 | ||
264 | int AliHLTTPCOfflineCalibrationComponent::Configure(const char* arguments) | |
265 | { | |
266 | // see header file for class documentation | |
267 | int iResult=0; | |
268 | if (!arguments) return iResult; | |
269 | ||
270 | TString allArgs=arguments; | |
271 | TString argument; | |
272 | int bMissingParam=0; | |
273 | ||
274 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
275 | if (pTokens) { | |
276 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
277 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
278 | if (argument.IsNull()) continue; | |
279 | ||
280 | if (argument.CompareTo("-something")==0) { | |
281 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
282 | ||
283 | } else { | |
284 | HLTError("unknown argument %s", argument.Data()); | |
285 | iResult=-EINVAL; | |
286 | break; | |
287 | } | |
288 | } | |
289 | delete pTokens; | |
290 | } | |
291 | if (bMissingParam) { | |
292 | HLTError("missing parameter for argument %s", argument.Data()); | |
293 | iResult=-EINVAL; | |
294 | } | |
295 | return iResult; | |
296 | } | |
297 | ||
298 | int AliHLTTPCOfflineCalibrationComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) | |
299 | { | |
300 | // see header file for class documentation | |
301 | int iResult=0; | |
302 | return iResult; | |
303 | } |