]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalTrackMatcherComponent.cxx
FindFASTJET
[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
2a24cbbe 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"
15b0637e 31#include "AliCDBEntry.h"
32#include "AliCDBManager.h"
33#include "TGeoManager.h"
9d967c45 34#include "TRefArray.h"
35#include "TString.h"
36#include "TMap.h"
2a24cbbe 37
a7f38894 38using namespace std;
39
2a24cbbe 40/** ROOT macro for the implementation of ROOT specific class methods */
41AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
42
43ClassImp(AliHLTGlobalTrackMatcherComponent);
44
45AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
9d967c45 46 fOCDBEntry("HLT/ConfigHLT/GlobalTrackMatcher"), //TODO
47 fMethod(1), //Method 1(PbPb) 2(pp)
2a24cbbe 48 fTrackMatcher(NULL),
49 fNEvents(0),
50 fBz(-9999999),
70cad768 51 fClusterReader(NULL),
52 fTrackArray(NULL)
2a24cbbe 53{
54 // see header file for class documentation
55 // or
56 // refer to README to build package
57 // or
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59
60}
61
62AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
63{
64 // see header file for class documentation
65 if(fTrackMatcher)
66 delete fTrackMatcher;
67 fTrackMatcher = NULL;
68
69 if(fClusterReader)
70 delete fClusterReader;
71 fClusterReader = NULL;
72
73}
74
75
76// Public functions to implement AliHLTComponent's interface.
77// These functions are required for the registration process
78const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
79{
80 // see header file for class documentation
81 return "TrackMatcher";
82}
83
84void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
85{
86 // see header file for class documentation
87 list.clear();
88 list.push_back( kAliHLTDataTypeTrack );
89 list.push_back( kAliHLTDataTypeCaloCluster );
90}
91
92AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
93{
94 // see header file for class documentation
95 return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
96}
97
98void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
99{
100 // see header file for class documentation
101 // XXX TODO: Find more realistic values.
102 constBase = 80000;
c92e3ef0 103 inputMultiplier = 1;
2a24cbbe 104}
105
106AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
107{
108 // see header file for class documentation
109 return new AliHLTGlobalTrackMatcherComponent;
110}
111
a46c7ba5 112int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
113{
9d967c45 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);
121 }
122
123
2a24cbbe 124 //BALLE TODO, use command line values to initialise matching vaules
a46c7ba5 125 // init
9d967c45 126// Int_t iResult = argc;
127// iResult = argc;
05ae9ad4 128
a46c7ba5 129 if(argc > 0){
130 HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
2a24cbbe 131 }
132
05ae9ad4 133 if(!fClusterReader)
134 fClusterReader = new AliHLTCaloClusterReader();
a46c7ba5 135
05ae9ad4 136 fBz = GetBz();
137 if(fBz == -999999) {
138 HLTError("Magnetic field not properly set, current value: %d", fBz);
05ae9ad4 139 }
70cad768 140
a46c7ba5 141 if(!fTrackMatcher)
142 fTrackMatcher = new AliHLTGlobalTrackMatcher();
05ae9ad4 143
a46c7ba5 144 fNEvents = 0;
145
146 if(!fTrackArray){
147 fTrackArray = new TObjArray();
148 fTrackArray->SetOwner(kFALSE);
149 }
9d967c45 150
15b0637e 151 //*** GeoManager ***
152 AliCDBPath path("GRP","Geometry","Data");
153 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
154 if (pEntry) {
155 if(!gGeoManager) {
156 gGeoManager = (TGeoManager*)pEntry->GetObject();
157 }
158 }
159 else {
160 HLTError("can not fetch object \"%s\" from CDB",path.GetPath().Data());
161 }
162 // ****
9d967c45 163
a46c7ba5 164
165 return iResult;
166}
2a24cbbe 167
a46c7ba5 168int AliHLTGlobalTrackMatcherComponent::DoDeinit()
169{
2a24cbbe 170 // see header file for class documentation
171 Int_t iResult = 1;
172
173 if(fTrackMatcher)
174 delete fTrackMatcher;
175 fTrackMatcher = NULL;
176
177 if(fClusterReader)
178 delete fClusterReader;
179 fClusterReader = NULL;
180
181
a46c7ba5 182 fNEvents = 0;
183
2a24cbbe 184 return iResult;
185}
186
a46c7ba5 187int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
188{
2a24cbbe 189
190 //See header file for documentation
191 Int_t iResult = 0;
192
193 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
194 return 0;
9d967c45 195
196 if(!IsDataEvent()){//marcel test
197 return 0;//marcel test
198 }//marcel test
a46c7ba5 199
200 fNEvents++;
201
202 //Loop over TPC blocks
203 //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
9d967c45 204
a46c7ba5 205 fTrackArray->Clear();
206 vector<AliHLTGlobalBarrelTrack> tracks;
70cad768 207
a46c7ba5 208 for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
209
210 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
e5b4e619 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))));
214 }
215 } else {
216 HLTWarning("Converting tracks to vector failed");
217 }
05ae9ad4 218
a46c7ba5 219 // //Push the TPC block on, without any changes
c830cd50 220 //PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
a46c7ba5 221
222 }
9d967c45 223
ec54c698 224 AliHLTCaloClusterDataStruct * caloClusterStruct;
225 //Get the PHOS Clusters
226 vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
227
e5b4e619 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));
233 continue;
234 } else {
235 phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
236 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
237 phosClustersVector.push_back(caloClusterStruct);
238 }
a46c7ba5 239 }
e5b4e619 240 }
ec54c698 241
9d967c45 242 //Get the EMCAL Clusters
ec54c698 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);
9d967c45 247// HLTInfo("\n EMCAL: estou aqui");//marcel
e5b4e619 248 if ( (caloClusterHeader->fNClusters) < 0) {
249 HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
250 continue;
251 } else {
252 emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
253 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
254 emcalClustersVector.push_back(caloClusterStruct);
ec54c698 255 }
e5b4e619 256 }
ec54c698 257 }
9d967c45 258
259 iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz,fMethod); //With Method String
260
2a24cbbe 261
ec54c698 262 //Push the blocks on
e5b4e619 263 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
264 PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
9d967c45 265 }
e5b4e619 266
9d967c45 267 fTrackArray->Clear();
268
a46c7ba5 269 return iResult;
2a24cbbe 270}
271
9d967c45 272int AliHLTGlobalTrackMatcherComponent::ScanConfigurationArgument(int argc, const char** argv) {
273 // see header file for class documentation
274 if (argc<=0) return 0;
275 int i=0;
276 TString argument=argv[i];
277
278 // -maxpt
279 if (argument.CompareTo("-method")==0) {
280 if (++i>=argc) return -EPROTO;
281 argument=argv[i];
d6b5dbb4 282 fMethod=argument.Atoi(); //
9d967c45 283 return 2;
284 }
285
286// unknown argument
287 return -EINVAL;
288}
289
2a24cbbe 290// int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
291// {
292// Int_t iResult = 1;
293// return iResult;
294// }
295
296// int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
297// {
298// Int_t iResult = 1;
299// return iResult;
300// }
9d967c45 301
302int 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;
306
307 return ConfigureFromCDBTObjString(entry);
308}
309
310void AliHLTGlobalTrackMatcherComponent::GetOCDBObjectDescription( TMap* const targetMap) {
311
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") )
316 );
317}
318
319