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