]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalTrackMatcherComponent.cxx
Added check that nClusters > 0
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalTrackMatcherComponent.cxx
CommitLineData
2a24cbbe 1//**************************************************************************
2//* This file is property of and copyright by the ALICE HLT Project *
3//* ALICE Experiment at CERN, All rights reserved. *
4//* *
5//* Primary Authors: Svein Lindal <svein.lindal@gmail.com> *
6//* for The ALICE HLT Project. *
7//* *
8//* Permission to use, copy, modify and distribute this software and its *
9//* documentation strictly for non-commercial purposes is hereby granted *
10//* without fee, provided that the above copyright notice appears in all *
11//* copies and that both the copyright notice and this permission notice *
12//* appear in the supporting documentation. The authors make no claims *
13//* about the suitability of this software for any purpose. It is *
14//* provided "as is" without express or implied warranty. *
15//**************************************************************************
16
17/** @file AliHLTGlobalTrackMatcherComponent.cxx
18 @author Svein Lindal
19 @brief Component to match TPC tracks to Calo Clusters
20*/
21
22#if __GNUC__>= 3
23using namespace std;
24#endif
25
26#include "AliHLTProcessor.h"
27#include "AliHLTGlobalTrackMatcherComponent.h"
28#include "AliHLTGlobalTrackMatcher.h"
29#include "TObjArray.h"
30#include "AliESDEvent.h"
31#include "AliESDtrack.h"
32#include "AliHLTGlobalBarrelTrack.h"
33#include "AliHLTCaloClusterDataStruct.h"
34#include "AliHLTCaloClusterReader.h"
35
36
37/** ROOT macro for the implementation of ROOT specific class methods */
38AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
39
40ClassImp(AliHLTGlobalTrackMatcherComponent);
41
42AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
43 fTrackMatcher(NULL),
44 fNEvents(0),
45 fBz(-9999999),
46 fClusterReader(NULL)
47{
48 // see header file for class documentation
49 // or
50 // refer to README to build package
51 // or
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53
54}
55
56AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
57{
58 // see header file for class documentation
59 if(fTrackMatcher)
60 delete fTrackMatcher;
61 fTrackMatcher = NULL;
62
63 if(fClusterReader)
64 delete fClusterReader;
65 fClusterReader = NULL;
66
67}
68
69
70// Public functions to implement AliHLTComponent's interface.
71// These functions are required for the registration process
72const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
73{
74 // see header file for class documentation
75 return "TrackMatcher";
76}
77
78void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
79{
80 // see header file for class documentation
81 list.clear();
82 list.push_back( kAliHLTDataTypeTrack );
83 list.push_back( kAliHLTDataTypeCaloCluster );
84}
85
86AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
87{
88 // see header file for class documentation
89 return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
90}
91
92void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
93{
94 // see header file for class documentation
95 // XXX TODO: Find more realistic values.
96 constBase = 80000;
97 inputMultiplier = 0;
98}
99
100AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
101{
102 // see header file for class documentation
103 return new AliHLTGlobalTrackMatcherComponent;
104}
105
106int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
107{
108
109 //BALLE TODO, use command line values to initialise matching vaules
110 // init
111 Int_t iResult = argc;
112
113 if(argc > 0){
114 HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
115 }
116
117 fClusterReader = new AliHLTCaloClusterReader();
118
119 fBz = GetBz();
120 if(fBz == -999999) {
121 HLTError("Magnetic field not properly set, current value: %d", fBz);
122 }
123
124 fTrackMatcher = new AliHLTGlobalTrackMatcher();
125
126 fNEvents = 0;
127
128 return iResult;
129}
130
131int AliHLTGlobalTrackMatcherComponent::DoDeinit()
132{
133 // see header file for class documentation
134 Int_t iResult = 1;
135
136 if(fTrackMatcher)
137 delete fTrackMatcher;
138 fTrackMatcher = NULL;
139
140 if(fClusterReader)
141 delete fClusterReader;
142 fClusterReader = NULL;
143
144
145 fNEvents = 0;
146
147 return iResult;
148}
149
150int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
151{
152
153 //See header file for documentation
154 Int_t iResult = 0;
155
156 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
157 return 0;
158
159
160 fNEvents++;
161
162 //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
163 TObjArray * trackArray = new TObjArray();
164 trackArray->SetOwner(kFALSE);
165 vector<AliHLTGlobalBarrelTrack> tracks;
166
167 for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
168
169 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
170
171 for(UInt_t it = 0; it < tracks.size(); it++) {
172 AliHLTGlobalBarrelTrack track = tracks.at(it);
173 HLTInfo("track ID %d", track.TrackID());
174 trackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
175 }
176 } else {
177 HLTWarning("Converting tracks to vector failed");
178 }
179
180 //Push the TPC block on, without any changes
181 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
182
183 }
184
185 //Vector to contain the phos clusters
186 vector<AliHLTCaloClusterDataStruct *> phosClustersVector;
187 AliHLTCaloClusterDataStruct * caloClusterStructPtr;
188
189 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
190 AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
191 fClusterReader->SetMemory(caloClusterHeaderPtr);
192
193 //BALLE, TODO, make it able to do EMCAL as well!!!
194 phosClustersVector.resize((Int_t) (caloClusterHeaderPtr->fNClusters));
195
196 Int_t nClusters = 0;
197 while((caloClusterStructPtr = fClusterReader->NextCluster()) != 0) {
198 //BALLE stil just phos
199 phosClustersVector[nClusters++] = caloClusterStructPtr;
200 }
201
202 iResult = fTrackMatcher->Match(trackArray, phosClustersVector, fBz);
203 if(iResult <0) {
204 HLTWarning("Error in track matcher");
205 }
206
207 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
208 }
209
210 //BALLE TODO phos only !!!!
211
212 delete trackArray;
213 return iResult;
214
215}
216
217// int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
218// {
219// Int_t iResult = 1;
220// return iResult;
221// }
222
223// int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
224// {
225// Int_t iResult = 1;
226// return iResult;
227// }