]>
Commit | Line | Data |
---|---|---|
6c3bc982 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
7 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
8 | * for The ALICE Off-line Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTTRDTrackerComponentV2.cxx | |
20 | @author Timm Steinbeck, Matthias Richter | |
21 | @date | |
22 | @brief A TRDTracker processing component for the HLT. */ | |
23 | ||
24 | #if __GNUC__ >= 3 | |
25 | using namespace std; | |
26 | #endif | |
27 | ||
28 | #include "TFile.h" | |
29 | ||
30 | #include "AliHLTTRDTrackerComponentV2.h" | |
31 | #include "AliHLTTRDDefinitions.h" | |
32 | #include "AliCDBManager.h" | |
33 | ||
34 | #include "AliTRDReconstructor.h" | |
35 | #include "AliESDEvent.h" | |
36 | #include "AliTRDtrackerHLT.h" | |
37 | #include "AliTRDtracker.h" | |
38 | #include "AliTRDCalibraFillHisto.h" | |
39 | #include "AliMagFMaps.h" | |
40 | #include "AliTRDcluster.h" | |
41 | #include "TChain.h" | |
42 | ||
43 | #include <cstdlib> | |
44 | #include <cerrno> | |
45 | #include <string> | |
46 | ||
47 | // this is a global object used for automatic component registration, do not use this | |
48 | AliHLTTRDTrackerComponentV2 gAliHLTTRDTrackerComponentV2; | |
49 | ||
50 | ClassImp(AliHLTTRDTrackerComponentV2); | |
51 | ||
52 | AliHLTTRDTrackerComponentV2::AliHLTTRDTrackerComponentV2() | |
53 | : AliHLTProcessor() | |
54 | , fOutputPercentage(100) // By default we copy to the output exactly what we got as input | |
55 | , fStrorageDBpath("local://$ALICE_ROOT") | |
56 | , fCDB(NULL) | |
57 | , fField(NULL) | |
58 | , fGeometryFileName("") | |
59 | , fGeometryFile(NULL) | |
60 | , fGeoManager(NULL) | |
61 | , fTracker(NULL) | |
62 | { | |
63 | // Default constructor | |
64 | fCDB = AliCDBManager::Instance(); | |
65 | //fCDB->SetDefaultStorage(fStrorageDBpath.c_str()); | |
66 | fCDB->SetRun(0); | |
67 | ||
68 | fGeometryFileName = getenv("ALICE_ROOT"); | |
69 | fGeometryFileName += "/HLT/TRD/geometry.root"; | |
70 | } | |
71 | ||
72 | AliHLTTRDTrackerComponentV2::~AliHLTTRDTrackerComponentV2() | |
73 | { | |
74 | // Destructor | |
75 | } | |
76 | ||
77 | const char* AliHLTTRDTrackerComponentV2::GetComponentID() | |
78 | { | |
79 | // Return the component ID const char * | |
80 | return "TRDTrackerV2"; // The ID of this component | |
81 | } | |
82 | ||
83 | void AliHLTTRDTrackerComponentV2::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
84 | { | |
85 | // Get the list of input data | |
86 | list.clear(); // We do not have any requirements for our input data type(s). | |
87 | list.push_back( AliHLTTRDDefinitions::fgkClusterDataType ); | |
88 | } | |
89 | ||
90 | AliHLTComponent_DataType AliHLTTRDTrackerComponentV2::GetOutputDataType() | |
91 | { | |
92 | // Get the output data type | |
93 | return AliHLTTRDDefinitions::fgkClusterDataType; | |
94 | } | |
95 | ||
96 | void AliHLTTRDTrackerComponentV2::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
97 | { | |
98 | // Get the output data size | |
99 | constBase = 0; | |
100 | inputMultiplier = ((double)fOutputPercentage)/100.0; | |
101 | } | |
102 | ||
103 | // Spawn function, return new instance of this class | |
104 | AliHLTComponent* AliHLTTRDTrackerComponentV2::Spawn() | |
105 | { | |
106 | // Spawn function, return new instance of this class | |
107 | return new AliHLTTRDTrackerComponentV2; | |
108 | }; | |
109 | ||
110 | int AliHLTTRDTrackerComponentV2::DoInit( int argc, const char** argv ) | |
111 | { | |
112 | // perform initialization. We check whether our relative output size is specified in the arguments. | |
113 | fOutputPercentage = 100; | |
114 | int i = 0; | |
115 | char* cpErr; | |
116 | while ( i < argc ) | |
117 | { | |
118 | Logging( kHLTLogDebug, "HLT::TRDTracker::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] ); | |
119 | if ( !strcmp( argv[i], "output_percentage" ) ) | |
120 | { | |
121 | if ( i+1>=argc ) | |
122 | { | |
123 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing output_percentage parameter"); | |
124 | return ENOTSUP; | |
125 | } | |
126 | Logging( kHLTLogDebug, "HLT::TRDTracker::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] ); | |
127 | fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 ); | |
128 | if ( *cpErr ) | |
129 | { | |
130 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] ); | |
131 | return EINVAL; | |
132 | } | |
133 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
134 | i += 2; | |
135 | continue; | |
136 | } | |
137 | ||
138 | if ( strcmp( argv[i], "-cdb" ) == 0) | |
139 | { | |
140 | if ( i+1 >= argc ) | |
141 | { | |
142 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing -cdb argument"); | |
143 | return ENOTSUP; | |
144 | } | |
145 | fStrorageDBpath = argv[i+1]; | |
146 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() ); | |
147 | fCDB->SetDefaultStorage(fStrorageDBpath.c_str()); | |
148 | i += 2; | |
149 | continue; | |
150 | } | |
151 | ||
152 | if ( strcmp( argv[i], "-geometry" ) == 0) | |
153 | { | |
154 | if ( i+1 >= argc ) | |
155 | { | |
156 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing -geometry argument"); | |
157 | return ENOTSUP; | |
158 | } | |
159 | fGeometryFileName = argv[i+1]; | |
160 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "GeomFile storage set", "GeomFile storage is %s", | |
161 | fGeometryFileName.c_str() ); | |
162 | i += 2; | |
163 | continue; | |
164 | } | |
165 | ||
166 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
167 | return EINVAL; | |
168 | } | |
169 | ||
170 | //init alifield map - temporarly fixed - should come from a DB | |
171 | fField = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1); | |
172 | if (fField) | |
173 | AliTracker::SetFieldMap(fField,1); | |
174 | else | |
175 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Field", "Unable to init the field"); | |
176 | ||
177 | fGeometryFile = TFile::Open(fGeometryFileName.c_str()); | |
178 | if (fGeometryFile) | |
179 | { | |
180 | fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry"); | |
181 | fTracker = new AliTRDtrackerHLT(fGeometryFile); | |
182 | //fTracker = new AliTRDtracker(fGeometryFile); | |
183 | } | |
184 | else | |
185 | { | |
186 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "fGeometryFile", "Unable to open file. FATAL!"); | |
187 | return -1; | |
188 | } | |
189 | ||
190 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); | |
191 | if (calibra == 0) | |
192 | { | |
193 | Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Calibration Histos", "::Instance failed"); | |
194 | return -1; | |
195 | } | |
196 | else | |
197 | { | |
198 | calibra->SetMITracking(kTRUE); | |
199 | calibra->Init2Dhistos(); | |
200 | } | |
201 | ||
202 | return 0; | |
203 | } | |
204 | ||
205 | int AliHLTTRDTrackerComponentV2::DoDeinit() | |
206 | { | |
207 | // Deinitialization of the component | |
208 | ||
209 | delete fField; | |
210 | fField = 0; | |
211 | ||
212 | delete fTracker; | |
213 | fTracker = 0; | |
214 | ||
215 | if (fGeometryFile) | |
216 | { | |
217 | fGeometryFile->Close(); | |
218 | delete fGeometryFile; | |
219 | fGeometryFile = 0; | |
220 | } | |
221 | ||
222 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); | |
223 | if (calibra) | |
224 | { | |
225 | // should not write in here! | |
226 | calibra->Write2d(); | |
227 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "before destroy"); | |
228 | calibra->Destroy(); | |
229 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "after destroy"); | |
230 | } | |
231 | ||
232 | return 0; | |
233 | } | |
234 | ||
235 | int AliHLTTRDTrackerComponentV2::DoEvent( const AliHLTComponentEventData & evtData, | |
236 | AliHLTComponentTriggerData & trigData ) | |
237 | { | |
238 | // Process an event | |
239 | ||
240 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage ); | |
241 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt ); | |
242 | ||
243 | AliHLTUInt32_t fDblock_Specification = 0; | |
244 | ||
245 | AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType ); | |
246 | if (dblock != 0) | |
247 | { | |
248 | fDblock_Specification = dblock->fSpecification; | |
249 | } | |
250 | else | |
251 | { | |
252 | Logging( kHLTLogWarning, "HLT::TRDTracker::DoEvent", "DATAIN", "First Input Block not found! 0x%x", dblock); | |
253 | return -1; | |
254 | } | |
255 | ||
256 | int ibForce = 0; | |
257 | TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce); | |
258 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x", tobjin); | |
259 | ||
260 | TTree *clusterTree = (TTree*)tobjin; | |
261 | if (!clusterTree) | |
262 | { | |
263 | Logging( kHLTLogWarning, "HLT::TRDTracker::DoEvent", "DATAIN", "First Input Block not a tree! 0x%x", tobjin); | |
264 | return -1; | |
265 | } | |
266 | ||
267 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName()); | |
268 | ||
269 | while (tobjin != 0) | |
270 | { | |
271 | if (clusterTree) | |
272 | { | |
273 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName()); | |
274 | Int_t iNentries = clusterTree->GetEntries(); | |
275 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "COUNT", "N of tree entries = %d", iNentries); | |
276 | fTracker->LoadClusters(clusterTree); | |
277 | } | |
278 | else | |
279 | { | |
280 | Logging( kHLTLogError, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Tree Pointer = 0x%x", clusterTree); | |
281 | } | |
282 | ||
283 | tobjin = (TObject *)GetNextInputObject( ibForce ); | |
284 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin); | |
285 | clusterTree = (TTree*)tobjin; | |
286 | } | |
287 | ||
288 | AliTRDReconstructor::SetSeedingOn(kTRUE); | |
289 | ||
290 | AliESDEvent *esd = new AliESDEvent(); | |
291 | esd->CreateStdContent(); | |
292 | //fTracker->MakeSeedsMI(3, 5, esd); | |
293 | fTracker->PropagateBack(esd); | |
294 | fTracker->RefitInward(esd); | |
295 | ||
296 | //here transport the esd tracks further | |
297 | //no receiver defined yet(!) | |
298 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "now deleting"); | |
299 | delete esd; | |
300 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete esd"); | |
301 | delete clusterTree; | |
302 | ||
303 | Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete clusterTree"); | |
304 | return 0; | |
305 | } |