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"
35 #include "AliCDBEntry.h"
36 #include "AliCDBManager.h"
37 #include "TGeoManager.h"
38 #include "TRefArray.h"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
45 ClassImp(AliHLTGlobalTrackMatcherComponent);
47 AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
48 fOCDBEntry("HLT/ConfigHLT/GlobalTrackMatcher"), //TODO
49 fMethod(1), //Method 1(PbPb) 2(pp)
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
64 AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
66 // see header file for class documentation
72 delete fClusterReader;
73 fClusterReader = NULL;
78 // Public functions to implement AliHLTComponent's interface.
79 // These functions are required for the registration process
80 const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
82 // see header file for class documentation
83 return "TrackMatcher";
86 void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
88 // see header file for class documentation
90 list.push_back( kAliHLTDataTypeTrack );
91 list.push_back( kAliHLTDataTypeCaloCluster );
94 AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
96 // see header file for class documentation
97 return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
100 void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
102 // see header file for class documentation
103 // XXX TODO: Find more realistic values.
108 AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
110 // see header file for class documentation
111 return new AliHLTGlobalTrackMatcherComponent;
114 int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
116 Int_t iResult=ConfigureFromCDBTObjString(fOCDBEntry); //MARCEL
117 // configure from the command line parameters if specified
118 if (iResult>=0 && argc>0) {
119 iResult=ConfigureFromArgumentString(argc, argv);
120 HLTImportant("Extrapolation Method from argument string: %d", fMethod);
121 } else if ( iResult >=0 ) {
122 HLTImportant("Extrapolation Method from OCDB database entry: %d", fMethod);
126 //BALLE TODO, use command line values to initialise matching vaules
128 // Int_t iResult = argc;
132 HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
136 fClusterReader = new AliHLTCaloClusterReader();
140 HLTError("Magnetic field not properly set, current value: %d", fBz);
144 fTrackMatcher = new AliHLTGlobalTrackMatcher();
149 fTrackArray = new TObjArray();
150 fTrackArray->SetOwner(kFALSE);
154 AliCDBPath path("GRP","Geometry","Data");
155 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
158 gGeoManager = (TGeoManager*)pEntry->GetObject();
162 HLTError("can not fetch object \"%s\" from CDB",path.GetPath().Data());
170 int AliHLTGlobalTrackMatcherComponent::DoDeinit()
172 // see header file for class documentation
176 delete fTrackMatcher;
177 fTrackMatcher = NULL;
180 delete fClusterReader;
181 fClusterReader = NULL;
189 int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
192 //See header file for documentation
195 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
198 if(!IsDataEvent()){//marcel test
199 return 0;//marcel test
204 //Loop over TPC blocks
205 //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
207 fTrackArray->Clear();
208 vector<AliHLTGlobalBarrelTrack> tracks;
210 for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
212 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
213 for(UInt_t it = 0; it < tracks.size(); it++) {
214 AliHLTGlobalBarrelTrack track = tracks.at(it);
215 fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
218 HLTWarning("Converting tracks to vector failed");
221 // //Push the TPC block on, without any changes
222 //PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
226 AliHLTCaloClusterDataStruct * caloClusterStruct;
227 //Get the PHOS Clusters
228 vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
230 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) {
231 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
232 fClusterReader->SetMemory(caloClusterHeader);
233 if ( (caloClusterHeader->fNClusters) < 0) {
234 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
237 phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
238 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
239 phosClustersVector.push_back(caloClusterStruct);
244 //Get the EMCAL Clusters
245 vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
246 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
247 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
248 fClusterReader->SetMemory(caloClusterHeader);
249 // HLTInfo("\n EMCAL: estou aqui");//marcel
250 if ( (caloClusterHeader->fNClusters) < 0) {
251 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
254 emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
255 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
256 emcalClustersVector.push_back(caloClusterStruct);
261 iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz,fMethod); //With Method String
265 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
266 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
269 fTrackArray->Clear();
274 int AliHLTGlobalTrackMatcherComponent::ScanConfigurationArgument(int argc, const char** argv) {
275 // see header file for class documentation
276 if (argc<=0) return 0;
278 TString argument=argv[i];
281 if (argument.CompareTo("-method")==0) {
282 if (++i>=argc) return -EPROTO;
284 fMethod=argument.Atoi(); //
292 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
294 // Int_t iResult = 1;
298 // int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
300 // Int_t iResult = 1;
304 int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
305 // configure from the specified antry or the default one
306 const char* entry=cdbEntry;
307 if (!entry || entry[0]==0) entry=fOCDBEntry;
309 return ConfigureFromCDBTObjString(entry);
312 void AliHLTGlobalTrackMatcherComponent::GetOCDBObjectDescription( TMap* const targetMap) {
314 // Get a list of OCDB object description.
315 if (!targetMap) return;
316 targetMap->Add(new TObjString(fOCDBEntry),
317 new TObjString(Form("Track-Matcher Method OCDB object") )