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
22 #include "AliHLTProcessor.h"
23 #include "AliHLTGlobalTrackMatcherComponent.h"
24 #include "AliHLTGlobalTrackMatcher.h"
25 #include "TObjArray.h"
26 #include "AliESDEvent.h"
27 #include "AliESDtrack.h"
28 #include "AliHLTGlobalBarrelTrack.h"
29 #include "AliHLTCaloClusterDataStruct.h"
30 #include "AliHLTCaloClusterReader.h"
31 #include "AliCDBEntry.h"
32 #include "AliCDBManager.h"
33 #include "TGeoManager.h"
34 #include "TRefArray.h"
40 /** ROOT macro for the implementation of ROOT specific class methods */
41 AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
43 ClassImp(AliHLTGlobalTrackMatcherComponent);
45 AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
46 fOCDBEntry("HLT/ConfigHLT/GlobalTrackMatcher"), //TODO
47 fMethod(1), //Method 1(PbPb) 2(pp)
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
64 // see header file for class documentation
70 delete fClusterReader;
71 fClusterReader = NULL;
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
78 const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
80 // see header file for class documentation
81 return "TrackMatcher";
84 void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
86 // see header file for class documentation
88 list.push_back( kAliHLTDataTypeTrack );
89 list.push_back( kAliHLTDataTypeCaloCluster );
92 AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
94 // see header file for class documentation
95 return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
98 void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
100 // see header file for class documentation
101 // XXX TODO: Find more realistic values.
106 AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
108 // see header file for class documentation
109 return new AliHLTGlobalTrackMatcherComponent;
112 int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
114 Int_t iResult=ConfigureFromCDBTObjString(fOCDBEntry); //MARCEL
115 // configure from the command line parameters if specified
116 if (iResult>=0 && argc>0) {
117 iResult=ConfigureFromArgumentString(argc, argv);
118 HLTImportant("Extrapolation Method from argument string: %d", fMethod);
119 } else if ( iResult >=0 ) {
120 HLTImportant("Extrapolation Method from OCDB database entry: %d", fMethod);
124 //BALLE TODO, use command line values to initialise matching vaules
126 // Int_t iResult = argc;
130 HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
134 fClusterReader = new AliHLTCaloClusterReader();
138 HLTError("Magnetic field not properly set, current value: %d", fBz);
142 fTrackMatcher = new AliHLTGlobalTrackMatcher();
147 fTrackArray = new TObjArray();
148 fTrackArray->SetOwner(kFALSE);
152 AliCDBPath path("GRP","Geometry","Data");
153 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
156 gGeoManager = (TGeoManager*)pEntry->GetObject();
160 HLTError("can not fetch object \"%s\" from CDB",path.GetPath().Data());
168 int AliHLTGlobalTrackMatcherComponent::DoDeinit()
170 // see header file for class documentation
174 delete fTrackMatcher;
175 fTrackMatcher = NULL;
178 delete fClusterReader;
179 fClusterReader = NULL;
187 int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
190 //See header file for documentation
193 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
196 if(!IsDataEvent()){//marcel test
197 return 0;//marcel test
202 //Loop over TPC blocks
203 //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
205 fTrackArray->Clear();
206 vector<AliHLTGlobalBarrelTrack> tracks;
208 for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
210 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
211 for(UInt_t it = 0; it < tracks.size(); it++) {
212 AliHLTGlobalBarrelTrack track = tracks.at(it);
213 fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
216 HLTWarning("Converting tracks to vector failed");
219 // //Push the TPC block on, without any changes
220 //PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
224 AliHLTCaloClusterDataStruct * caloClusterStruct;
225 //Get the PHOS Clusters
226 vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
228 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) {
229 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
230 fClusterReader->SetMemory(caloClusterHeader);
231 if ( (caloClusterHeader->fNClusters) < 0) {
232 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
235 phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
236 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
237 phosClustersVector.push_back(caloClusterStruct);
242 //Get the EMCAL Clusters
243 vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
244 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
245 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
246 fClusterReader->SetMemory(caloClusterHeader);
247 // HLTInfo("\n EMCAL: estou aqui");//marcel
248 if ( (caloClusterHeader->fNClusters) < 0) {
249 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
252 emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
253 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
254 emcalClustersVector.push_back(caloClusterStruct);
259 iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz,fMethod); //With Method String
263 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
264 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
267 fTrackArray->Clear();
272 int AliHLTGlobalTrackMatcherComponent::ScanConfigurationArgument(int argc, const char** argv) {
273 // see header file for class documentation
274 if (argc<=0) return 0;
276 TString argument=argv[i];
279 if (argument.CompareTo("-method")==0) {
280 if (++i>=argc) return -EPROTO;
282 fMethod=argument.Atoi(); //
290 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
292 // Int_t iResult = 1;
296 // int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
298 // Int_t iResult = 1;
302 int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
303 // configure from the specified antry or the default one
304 const char* entry=cdbEntry;
305 if (!entry || entry[0]==0) entry=fOCDBEntry;
307 return ConfigureFromCDBTObjString(entry);
310 void AliHLTGlobalTrackMatcherComponent::GetOCDBObjectDescription( TMap* const targetMap) {
312 // Get a list of OCDB object description.
313 if (!targetMap) return;
314 targetMap->Add(new TObjString(fOCDBEntry),
315 new TObjString(Form("Track-Matcher Method OCDB object") )