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