1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: Svein Lindal <svein.lindal@gmail.com> *
6 //* for The ALICE HLT Project. *
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 //**************************************************************************
17 /** @file AliHLTGlobalTrackMatcherComponent.cxx
19 @brief Component to match TPC tracks to Calo Clusters
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"
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
40 ClassImp(AliHLTGlobalTrackMatcherComponent);
42 AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
49 // see header file for class documentation
51 // refer to README to build package
53 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
59 // see header file for class documentation
65 delete fClusterReader;
66 fClusterReader = NULL;
71 // Public functions to implement AliHLTComponent's interface.
72 // These functions are required for the registration process
73 const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
75 // see header file for class documentation
76 return "TrackMatcher";
79 void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
81 // see header file for class documentation
83 list.push_back( kAliHLTDataTypeTrack );
84 list.push_back( kAliHLTDataTypeCaloCluster );
87 AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
89 // see header file for class documentation
90 return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
93 void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
95 // see header file for class documentation
96 // XXX TODO: Find more realistic values.
101 AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
103 // see header file for class documentation
104 return new AliHLTGlobalTrackMatcherComponent;
107 int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
110 //BALLE TODO, use command line values to initialise matching vaules
112 Int_t iResult = argc;
115 HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
119 fClusterReader = new AliHLTCaloClusterReader();
123 HLTError("Magnetic field not properly set, current value: %d", fBz);
127 fTrackMatcher = new AliHLTGlobalTrackMatcher();
132 fTrackArray = new TObjArray();
133 fTrackArray->SetOwner(kFALSE);
139 int AliHLTGlobalTrackMatcherComponent::DoDeinit()
141 // see header file for class documentation
145 delete fTrackMatcher;
146 fTrackMatcher = NULL;
149 delete fClusterReader;
150 fClusterReader = NULL;
158 int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
161 //See header file for documentation
164 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
170 //Loop over TPC blocks
171 //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
173 fTrackArray->Clear();
174 vector<AliHLTGlobalBarrelTrack> tracks;
176 for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
178 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
179 for(UInt_t it = 0; it < tracks.size(); it++)
181 AliHLTGlobalBarrelTrack track = tracks.at(it);
182 fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
187 HLTWarning("Converting tracks to vector failed");
190 // //Push the TPC block on, without any changes
191 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
195 AliHLTCaloClusterDataStruct * caloClusterStruct;
196 //Get the PHOS Clusters
197 vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
199 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock())
201 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
202 fClusterReader->SetMemory(caloClusterHeader);
204 if ( (caloClusterHeader->fNClusters) < 0)
206 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
210 phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
211 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
212 phosClustersVector.push_back(caloClusterStruct);
218 //Get the EMCAL Clusters
219 vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
220 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
221 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
222 fClusterReader->SetMemory(caloClusterHeader);
223 if ( (caloClusterHeader->fNClusters) < 0)
225 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
229 emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
231 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0 )
233 emcalClustersVector.push_back(caloClusterStruct);
239 iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz);
242 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock())
244 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
247 fTrackArray->Clear();
251 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
253 // Int_t iResult = 1;
257 // int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
259 // Int_t iResult = 1;