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++) {
180 AliHLTGlobalBarrelTrack track = tracks.at(it);
181 fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
184 HLTWarning("Converting tracks to vector failed");
187 // //Push the TPC block on, without any changes
188 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
192 AliHLTCaloClusterDataStruct * caloClusterStruct;
193 //Get the PHOS Clusters
194 vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
196 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) {
197 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
198 fClusterReader->SetMemory(caloClusterHeader);
199 if ( (caloClusterHeader->fNClusters) < 0) {
200 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
203 phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
204 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
205 phosClustersVector.push_back(caloClusterStruct);
211 //Get the EMCAL Clusters
212 vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
213 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
214 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
215 fClusterReader->SetMemory(caloClusterHeader);
216 if ( (caloClusterHeader->fNClusters) < 0) {
217 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
220 emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
221 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
222 emcalClustersVector.push_back(caloClusterStruct);
227 iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz);
230 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
231 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
234 fTrackArray->Clear();
239 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
241 // Int_t iResult = 1;
245 // int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
247 // Int_t iResult = 1;