]>
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" | |
35 | ||
36 | ||
37 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
38 | AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent; | |
39 | ||
40 | ClassImp(AliHLTGlobalTrackMatcherComponent); | |
41 | ||
42 | AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() : | |
43 | fTrackMatcher(NULL), | |
44 | fNEvents(0), | |
45 | fBz(-9999999), | |
70cad768 | 46 | fClusterReader(NULL), |
47 | fTrackArray(NULL) | |
2a24cbbe | 48 | { |
49 | // see header file for class documentation | |
50 | // or | |
51 | // refer to README to build package | |
52 | // or | |
53 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
54 | ||
55 | } | |
56 | ||
57 | AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent() | |
58 | { | |
59 | // see header file for class documentation | |
60 | if(fTrackMatcher) | |
61 | delete fTrackMatcher; | |
62 | fTrackMatcher = NULL; | |
63 | ||
64 | if(fClusterReader) | |
65 | delete fClusterReader; | |
66 | fClusterReader = NULL; | |
67 | ||
68 | } | |
69 | ||
70 | ||
71 | // Public functions to implement AliHLTComponent's interface. | |
72 | // These functions are required for the registration process | |
73 | const char* AliHLTGlobalTrackMatcherComponent::GetComponentID() | |
74 | { | |
75 | // see header file for class documentation | |
76 | return "TrackMatcher"; | |
77 | } | |
78 | ||
79 | void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
80 | { | |
81 | // see header file for class documentation | |
82 | list.clear(); | |
83 | list.push_back( kAliHLTDataTypeTrack ); | |
84 | list.push_back( kAliHLTDataTypeCaloCluster ); | |
85 | } | |
86 | ||
87 | AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType() | |
88 | { | |
89 | // see header file for class documentation | |
90 | return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny; | |
91 | } | |
92 | ||
93 | void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
94 | { | |
95 | // see header file for class documentation | |
96 | // XXX TODO: Find more realistic values. | |
97 | constBase = 80000; | |
98 | inputMultiplier = 0; | |
99 | } | |
100 | ||
101 | AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn() | |
102 | { | |
103 | // see header file for class documentation | |
104 | return new AliHLTGlobalTrackMatcherComponent; | |
105 | } | |
106 | ||
107 | int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv ) | |
108 | { | |
109 | ||
110 | //BALLE TODO, use command line values to initialise matching vaules | |
111 | // init | |
112 | Int_t iResult = argc; | |
113 | ||
114 | if(argc > 0){ | |
115 | HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]); | |
116 | } | |
117 | ||
70cad768 | 118 | if(!fClusterReader) |
119 | fClusterReader = new AliHLTCaloClusterReader(); | |
2a24cbbe | 120 | |
121 | fBz = GetBz(); | |
122 | if(fBz == -999999) { | |
123 | HLTError("Magnetic field not properly set, current value: %d", fBz); | |
124 | } | |
125 | ||
70cad768 | 126 | if(!fTrackMatcher) |
127 | fTrackMatcher = new AliHLTGlobalTrackMatcher(); | |
2a24cbbe | 128 | |
129 | fNEvents = 0; | |
130 | ||
70cad768 | 131 | if(!fTrackArray){ |
132 | fTrackArray = new TObjArray(); | |
133 | fTrackArray->SetOwner(kFALSE); | |
134 | } | |
135 | ||
2a24cbbe | 136 | return iResult; |
137 | } | |
138 | ||
139 | int AliHLTGlobalTrackMatcherComponent::DoDeinit() | |
140 | { | |
141 | // see header file for class documentation | |
142 | Int_t iResult = 1; | |
143 | ||
144 | if(fTrackMatcher) | |
145 | delete fTrackMatcher; | |
146 | fTrackMatcher = NULL; | |
147 | ||
148 | if(fClusterReader) | |
149 | delete fClusterReader; | |
150 | fClusterReader = NULL; | |
151 | ||
152 | ||
153 | fNEvents = 0; | |
154 | ||
155 | return iResult; | |
156 | } | |
157 | ||
158 | int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
159 | { | |
160 | ||
161 | //See header file for documentation | |
162 | Int_t iResult = 0; | |
163 | ||
164 | if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) | |
165 | return 0; | |
166 | ||
167 | ||
168 | fNEvents++; | |
70cad768 | 169 | |
170 | //Loop over TPC blocks | |
2a24cbbe | 171 | //BALLE TODO check that the tracks in the TObjArray are fine over several blocks |
70cad768 | 172 | |
173 | fTrackArray->Clear(); | |
174 | vector<AliHLTGlobalBarrelTrack> tracks; | |
175 | ||
176 | for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
177 | ||
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)))); | |
182 | } | |
183 | } else { | |
184 | HLTWarning("Converting tracks to vector failed"); | |
185 | } | |
2a24cbbe | 186 | |
70cad768 | 187 | // //Push the TPC block on, without any changes |
188 | PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification); | |
2a24cbbe | 189 | |
70cad768 | 190 | } |
2a24cbbe | 191 | |
70cad768 | 192 | //Get the clusters |
193 | AliHLTCaloClusterDataStruct * caloClusterStruct; | |
194 | vector<AliHLTCaloClusterDataStruct*> phosClustersVector; | |
2a24cbbe | 195 | |
70cad768 | 196 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) { |
197 | AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr); | |
198 | fClusterReader->SetMemory(caloClusterHeader); | |
199 | ||
200 | if ( (caloClusterHeader->fNClusters) < 0) { | |
201 | HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters)); | |
23af1553 | 202 | return -1; |
70cad768 | 203 | } else { |
70cad768 | 204 | |
205 | //BALLE, TODO, make it able to do EMCAL as well!!! | |
206 | phosClustersVector.resize((int) (caloClusterHeader->fNClusters)); | |
207 | Int_t nClusters = 0; | |
70cad768 | 208 | while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) { |
70cad768 | 209 | //BALLE stil just phos |
210 | phosClustersVector[nClusters++] = caloClusterStruct; | |
211 | } | |
212 | ||
213 | iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, fBz); | |
214 | } | |
215 | ||
216 | if(iResult <0) { | |
74085fad | 217 | //HLTWarning("Error in track matcher"); |
70cad768 | 218 | } |
e0cde76d | 219 | PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification); |
220 | //PushBack(pBlock->fPtr, pBlock->fSize, kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny ); | |
2a24cbbe | 221 | } |
222 | ||
70cad768 | 223 | |
224 | fTrackArray->Clear(); | |
225 | //BALLE TODO phos only !!!! | |
226 | ||
227 | return iResult; | |
2a24cbbe | 228 | |
229 | } | |
230 | ||
231 | // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments) | |
232 | // { | |
233 | // Int_t iResult = 1; | |
234 | // return iResult; | |
235 | // } | |
236 | ||
237 | // int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
238 | // { | |
239 | // Int_t iResult = 1; | |
240 | // return iResult; | |
241 | // } |