When Pt is bad defined (ex. no field), the multiple scattering effect is calculated...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterConverterComponent.cxx
CommitLineData
cdfe3c01 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: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 * for The ALICE HLT Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file AliHLTTPCClusterConverterComponent.cxx
20 @author Kalliopi Kanaki
21 @date
22 @brief The TPC cluster format conversion component.
23*/
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31#if __GNUC__>= 3
32using namespace std;
33#endif
34
35#include "AliHLTTPCClusterConverterComponent.h"
36#include "AliHLTTPCOfflineCluster.h"
37#include "AliTPCclusterMI.h"
38
39#include "AliHLTTPCClusterDataFormat.h"
40
41#include "AliHLTTPCTrackSegmentData.h"
42#include "AliHLTTPCTrackletDataFormat.h"
43
44#include "AliCDBEntry.h"
45#include "AliCDBManager.h"
46
47#include "AliHLTTPCMemHandler.h"
48#include "AliHLTTPCDefinitions.h"
49
50#include "TString.h"
51#include "TObjString.h"
52#include "TObjArray.h"
53//#include "AliHLTTPC.h"
54//#include <stdlib.h>
55//#include <cerrno>
56
57/** ROOT macro for the implementation of ROOT specific class methods */
58ClassImp(AliHLTTPCClusterConverterComponent)
59
60AliHLTTPCClusterConverterComponent::AliHLTTPCClusterConverterComponent()
61:
62fClusters(0),
63fTracks(0),
64fOffArray(0)
65{ // see header file for class documentation
66 // or
67 // refer to README to build package
68 // or
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70}
71
72AliHLTTPCClusterConverterComponent::~AliHLTTPCClusterConverterComponent(){
73 // see header file for class documentation
74}
75
76// Public functions to implement AliHLTComponent's interface.
77// These functions are required for the registration process
78
79const char* AliHLTTPCClusterConverterComponent::GetComponentID(){
80// see header file for class documentation
81 return "TPCClusterConverter";
82}
83
84void AliHLTTPCClusterConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
85// see header file for class documentation
86
87 list.clear();
88 list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
89}
90
91AliHLTComponentDataType AliHLTTPCClusterConverterComponent::GetOutputDataType(){
92// see header file for class documentation
93 return kAliHLTDataTypeTObject;
94}
95
96int AliHLTTPCClusterConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
97// see header file for class documentation
98
99 tgtList.clear();
100 tgtList.push_back(kAliHLTDataTypeTObject);
101 return tgtList.size();
102}
103
104void AliHLTTPCClusterConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
105// see header file for class documentation
106
107 constBase = 0;
108 inputMultiplier = 1;
109}
110
111AliHLTComponent* AliHLTTPCClusterConverterComponent::Spawn(){
112// see header file for class documentation
113 return new AliHLTTPCClusterConverterComponent;
114}
115
116
117int AliHLTTPCClusterConverterComponent::DoInit( int argc, const char** argv ){
118// see header file for class documentation
119
120 //Int_t i = 0;
121 //Char_t* cpErr;
122 int iResult = 0;
123
124 TString configuration = "";
125 TString argument = "";
126
127 for (int i=0; i<argc && iResult>=0; i++) {
128 argument=argv[i];
129 if (!configuration.IsNull()) configuration+=" ";
130 configuration+=argument;
131 }
132
133 if (!configuration.IsNull()) {
134 iResult=Configure(configuration.Data());
135 } else {
136 iResult=Reconfigure(NULL, NULL);
137 }
138
139
140// while ( i < argc ) {
141// if (!strcmp( argv[i], "-apply-noisemap")) {
142// fApplyNoiseMap = strtoul( argv[i+1], &cpErr ,0);
143//
144// if ( *cpErr ) {
145// HLTError("Cannot convert apply-noisemap specifier '%s'.", argv[i+1]);
146// return EINVAL;
147// }
148// i+=2;
149// continue;
150// }
151//
152// if (!strcmp( argv[i], "-plot-side-a")) {
153// fPlotSideA = strtoul( argv[i+1], &cpErr ,0);
154//
155// if ( *cpErr ) {
156// HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]);
157// return EINVAL;
158// }
159// i+=2;
160// continue;
161// }
162//
163// if (!strcmp( argv[i], "-plot-side-c")) {
164// fPlotSideC = strtoul( argv[i+1], &cpErr ,0);
165//
166// if ( *cpErr ) {
167// HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]);
168// return EINVAL;
169// }
170// i+=2;
171// continue;
172// }
173//
174// if (!strcmp( argv[i], "-reset-histograms")) {
175// fResetHistograms = strtoul( argv[i+1], &cpErr ,0);
176//
177// if ( *cpErr ) {
178// HLTError("Cannot convert reset-histograms specifier '%s'.", argv[i+1]);
179// return EINVAL;
180// }
181// i+=2;
182// continue;
183// }
184//
185// Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
186// return EINVAL;
187//
188// } // end while
189
190 return 0;
191} // end DoInit()
192
193int AliHLTTPCClusterConverterComponent::DoDeinit(){
194// see header file for class documentation
195 return 0;
196}
197
0e588049 198int AliHLTTPCClusterConverterComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/){
cdfe3c01 199// see header file for class documentation
200
201 //Logging(kHLTLogDebug, "HLT::TPCClusterConverter::DoEvent", "DoEvent", "DoEvent()");
202 HLTInfo("--- Entering DoEvent() in TPCClusterConverter ---");
203
204 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
205
206 Int_t numOfTotalTracks = 0;
207 Int_t numOfTotalSpacePoints = 0 ;
208 const AliHLTComponentBlockData *iter = NULL;
209
210
211 // ========== LOOP OVER CLUSTER DATA =====================//
212
213 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
214 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
215 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
216
217 const AliHLTTPCClusterData *clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
218 numOfTotalSpacePoints+= (Int_t)clusterData->fSpacePointCnt;
219
220 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
221
222 for(Int_t i=0; i<(Int_t)clusterData->fSpacePointCnt; i++){ fClusters.push_back(clusters[i]); }
223 }
224
225
226
227
228// // ========== LOOP OVER TRACKS =====================//
229//
230// for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock()){
231// AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
232// AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
233//
234// const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
235// numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
236//
237// AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
238//
239// for(int i=0;i<(Int_t)trackData->fTrackletCnt;i++){ fTracks.push_back(tracks[i]); }
240// }
241
242
243
244 // ========== LOOP OVER TRACK SEGMENTS =====================//
245
246 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock()){
247
248 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
249 evtData.fEventID, evtData.fEventID,
250 DataType2Text(iter->fDataType).c_str(),
251 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
252
253 if(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType && GetEventCount()<2){
254 HLTWarning("data type %s is depricated, use %s (fgkTrackSegmentsDataType)!",
255 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType).c_str(),
256 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
257 }
258
259 if(iter->fDataType != (AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC)) continue;
260
261 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){
262 HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkTrackSegmentsDataType"); continue;
263 } // endif
264
265 const AliHLTTPCTrackletData *trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
266 numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
267
268 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
269 for(Int_t i=0; i<(Int_t)trackData->fTrackletCnt; i++){ fTracks.push_back(tracks[i]); }
270
271 } // end of loop over track segments
272
273
274
275 // ========== TRIPLE LOOP FOR SETTING THE fUsed CLUSTERS =====================//
276
277 Int_t nClustersUsed = 0;
278 for(Int_t tr=0; tr<numOfTotalTracks; tr++){
279 Int_t nHits = fTracks[tr].fNPoints;
280 UInt_t *hitnum = fTracks[tr].fPointIDs;
281 //HLTInfo("Hits %d ", nHits);
282
283 for(Int_t h=0; h<nHits; h++){
284 UInt_t idTrack = hitnum[h];
285 Int_t sliceTrack = (idTrack>>25) & 0x7f;
286 Int_t partitionTrack = (idTrack>>22) & 0x7;
287 UInt_t posTrack = idTrack&0x3fffff;
288
289 fOffArray->Clear();
290 for(Int_t cl=0; cl<numOfTotalSpacePoints; cl++){
291 UInt_t idCluster = fClusters[cl].fID;
292 Int_t sliceCluster = (idCluster>>25) & 0x7f;
293 Int_t partitionCluster = (idCluster>>22) & 0x7;
294 UInt_t posCluster = idCluster&0x3fffff;
295
296
297 if(sliceCluster==sliceTrack && partitionCluster==partitionTrack && posCluster==posTrack){
298 fClusters[cl].fUsed = kTRUE;
299 fClusters[cl].fTrackN = tr;
300 nClustersUsed++;
301 fOffArray->Add(new AliHLTTPCOfflineCluster(fClusters[cl]));
302 } // end if
303 } // end for clusters
304 PushBack((TObject*)fOffArray, kAliHLTDataTypeTObject, 0);
305 } // end for hits
306 } // end for loop over track segments
307 return 0;
308} // end DoEvent()
309
310int AliHLTTPCClusterConverterComponent::Configure(const char* arguments){
311// see header file for class documentation
312
313 int iResult=0;
314 if (!arguments) return iResult;
315 HLTInfo("parsing configuration string \'%s\'", arguments);
316
317 TString allArgs=arguments;
318 TString argument;
319 int bMissingParam=0;
320
321 TObjArray* pTokens = allArgs.Tokenize(" ");
322 if (pTokens) {
323 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
324 argument=((TObjString*)pTokens->At(i))->GetString();
325 if (argument.IsNull()) continue;
326
327 if (argument.CompareTo("-apply-noisemap")==0) {
328 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
329 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
330
331 }
332 else if (argument.CompareTo("-plot-side-c")==0) {
333 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
334 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
335
336 }
337 else if (argument.CompareTo("-plot-side-a")==0) {
338 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
339 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
340
341 }
342 else {
343 HLTError("unknown argument %s", argument.Data());
344 iResult=-EINVAL;
345 break;
346 }
347 } // end for
348
349 delete pTokens;
350
351 } // end if pTokens
352
353 if (bMissingParam) {
354 HLTError("missing parameter for argument %s", argument.Data());
355 iResult=-EINVAL;
356 }
357 return iResult;
358}
359
360int AliHLTTPCClusterConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId){
361// see header file for class documentation
362
363 int iResult=0;
364 const char* path="HLT/ConfigTPC/ClusterConverterComponent";
365 const char* defaultNotify="";
366 if (cdbEntry) {
367 path=cdbEntry;
368 defaultNotify=" (default)";
369 }
370 if (path) {
371 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
372 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
373 if (pEntry) {
374 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
375 if (pString) {
376 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
377 iResult=Configure(pString->GetString().Data());
378 } else {
379 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
380 }
381 } else {
382 HLTError("can not fetch object \"%s\" from CDB", path);
383 }
384 }
385
386 return iResult;
387 }