]>
Commit | Line | Data |
---|---|---|
0e339ac7 | 1 | // $Id: AliHLTTRDTrackerV1Component.cxx 23618 2008-01-29 13:07:38Z hristov $ |
2 | ||
4de61263 | 3 | //************************************************************************** |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: * | |
8 | //* for The ALICE HLT 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 | //************************************************************************** | |
0e339ac7 | 18 | |
19 | /** @file AliHLTTRDTrackerV1Component.cxx | |
4de61263 | 20 | @author |
0e339ac7 | 21 | @date |
4de61263 | 22 | @brief A TRDTrackerV1 processing component for the HLT. |
23 | */ | |
0e339ac7 | 24 | |
25 | #if __GNUC__ >= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTTRDTrackerV1Component.h" | |
30 | #include "AliHLTTRDDefinitions.h" | |
d679dd6c | 31 | #include "AliHLTTRDCluster.h" |
32 | #include "AliHLTTRDTrack.h" | |
dc2e6604 | 33 | #include "AliHLTTRDUtils.h" |
0e339ac7 | 34 | |
35 | #include "TFile.h" | |
36 | #include "TChain.h" | |
37 | ||
886e8d3d | 38 | #include "AliGeomManager.h" |
0e339ac7 | 39 | #include "AliCDBManager.h" |
775f67d7 | 40 | #include "AliCDBStorage.h" |
b32b76cb | 41 | #include "AliCDBEntry.h" |
0e339ac7 | 42 | #include "AliESDEvent.h" |
f7a1cc68 | 43 | #include "AliMagF.h" |
0e339ac7 | 44 | #include "AliESDfriend.h" |
45 | ||
9aea5deb | 46 | #include "AliTRDcalibDB.h" |
0e339ac7 | 47 | #include "AliTRDReconstructor.h" |
48 | #include "AliTRDtrackerV1.h" | |
0e339ac7 | 49 | #include "AliTRDrecoParam.h" |
50 | ||
51 | #include <cstdlib> | |
52 | #include <cerrno> | |
53 | #include <string> | |
54 | ||
d679dd6c | 55 | #ifdef HAVE_VALGRIND_CALLGRIND_H |
56 | #include <valgrind/callgrind.h> | |
57 | #else | |
e3e5ac39 | 58 | #define CALLGRIND_START_INSTRUMENTATION do { } while (0) |
59 | #define CALLGRIND_STOP_INSTRUMENTATION do { } while (0) | |
d679dd6c | 60 | #endif |
0e339ac7 | 61 | |
18ada816 | 62 | ClassImp(AliHLTTRDTrackerV1Component) |
0e339ac7 | 63 | |
d679dd6c | 64 | AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component(): |
65 | AliHLTProcessor(), | |
775f67d7 | 66 | fOutputPercentage(100), // By default we copy to the output exactly what we got as input |
d679dd6c | 67 | fTracker(NULL), |
68 | fRecoParam(NULL), | |
775f67d7 | 69 | fReconstructor(NULL), |
b32b76cb | 70 | fESD(NULL), |
ff350753 | 71 | fClusterArray(NULL), |
b32b76cb | 72 | fRecoParamType(-1), |
73 | fNtimeBins(-1), | |
74 | fMagneticField(-1), | |
75 | fPIDmethod(1), | |
76 | fgeometryFileName(""), | |
77 | fieldStrength(-101), | |
93ce7d1b | 78 | fSlowTracking(kFALSE), |
79 | fOutputV1Tracks(kTRUE) | |
0e339ac7 | 80 | { |
81 | // Default constructor | |
82 | ||
0e339ac7 | 83 | } |
84 | ||
85 | AliHLTTRDTrackerV1Component::~AliHLTTRDTrackerV1Component() | |
86 | { | |
9aea5deb | 87 | // Destructor |
0e339ac7 | 88 | } |
89 | ||
90 | const char* AliHLTTRDTrackerV1Component::GetComponentID() | |
91 | { | |
92 | // Return the component ID const char * | |
93 | return "TRDTrackerV1"; // The ID of this component | |
94 | } | |
95 | ||
96 | void AliHLTTRDTrackerV1Component::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
97 | { | |
98 | // Get the list of input data | |
99 | list.clear(); // We do not have any requirements for our input data type(s). | |
93ce7d1b | 100 | list.push_back(AliHLTTRDDefinitions::fgkClusterDataType); |
0e339ac7 | 101 | } |
102 | ||
93ce7d1b | 103 | AliHLTComponentDataType AliHLTTRDTrackerV1Component::GetOutputDataType() |
0e339ac7 | 104 | { |
105 | // Get the output data type | |
93ce7d1b | 106 | return kAliHLTMultipleDataType; |
107 | } | |
108 | ||
109 | int AliHLTTRDTrackerV1Component::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
110 | { | |
111 | // Get the output data types | |
112 | tgtList.clear(); | |
113 | //tgtList.push_back(AliHLTTRDDefinitions::fgkTimeBinPropagationDataType); | |
114 | tgtList.push_back(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD); | |
115 | tgtList.push_back(AliHLTTRDDefinitions::fgkTRDSATracksDataType); | |
116 | return tgtList.size(); | |
0e339ac7 | 117 | } |
118 | ||
119 | void AliHLTTRDTrackerV1Component::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
120 | { | |
121 | // Get the output data size | |
122 | constBase = 0; | |
123 | inputMultiplier = ((double)fOutputPercentage)/100.0; | |
124 | } | |
125 | ||
126 | // Spawn function, return new instance of this class | |
127 | AliHLTComponent* AliHLTTRDTrackerV1Component::Spawn() | |
128 | { | |
0e339ac7 | 129 | return new AliHLTTRDTrackerV1Component; |
130 | }; | |
131 | ||
d679dd6c | 132 | |
0e339ac7 | 133 | int AliHLTTRDTrackerV1Component::DoInit( int argc, const char** argv ) |
134 | { | |
135 | // perform initialization. We check whether our relative output size is specified in the arguments. | |
b32b76cb | 136 | int iResult=0; |
18ada816 | 137 | |
b32b76cb | 138 | fReconstructor = new AliTRDReconstructor(); |
139 | HLTDebug("TRDReconstructor at 0x%x", fReconstructor); | |
0e339ac7 | 140 | |
b32b76cb | 141 | fESD = new AliESDEvent; |
142 | fESD->CreateStdContent(); | |
775f67d7 | 143 | |
b32b76cb | 144 | TString configuration=""; |
145 | TString argument=""; | |
146 | for (int i=0; i<argc && iResult>=0; i++) { | |
147 | argument=argv[i]; | |
148 | if (!configuration.IsNull()) configuration+=" "; | |
149 | configuration+=argument; | |
775f67d7 | 150 | } |
0e339ac7 | 151 | |
b32b76cb | 152 | if (!configuration.IsNull()) { |
153 | iResult=Configure(configuration.Data()); | |
154 | } else { | |
155 | iResult=Reconfigure(NULL, NULL); | |
f7a1cc68 | 156 | } |
18ada816 | 157 | |
4de61263 | 158 | if(iResult<0) return iResult; |
159 | ||
9aea5deb | 160 | fTracker = new AliTRDtrackerV1(); |
0e339ac7 | 161 | HLTDebug("TRDTracker at 0x%x", fTracker); |
775f67d7 | 162 | fTracker->SetReconstructor(fReconstructor); |
0e339ac7 | 163 | |
ff350753 | 164 | fClusterArray = new TClonesArray("AliTRDcluster"); // would be nice to allocate memory for all clusters here. |
165 | ||
b32b76cb | 166 | return iResult; |
0e339ac7 | 167 | } |
168 | ||
169 | int AliHLTTRDTrackerV1Component::DoDeinit() | |
170 | { | |
171 | // Deinitialization of the component | |
0e339ac7 | 172 | |
d679dd6c | 173 | fTracker->SetClustersOwner(kFALSE); |
0e339ac7 | 174 | delete fTracker; |
93ce7d1b | 175 | fTracker = NULL; |
ff350753 | 176 | |
177 | fClusterArray->Delete(); | |
178 | delete fClusterArray; | |
93ce7d1b | 179 | fClusterArray = NULL; |
9aea5deb | 180 | |
181 | // We need to set clusters in Reconstructor to null to prevent from | |
93ce7d1b | 182 | // double deleting, since we delete TClonesArray by ourself. |
9aea5deb | 183 | fReconstructor->SetClusters(0x0); |
0d66dbf5 | 184 | delete fReconstructor; |
93ce7d1b | 185 | fReconstructor = NULL; |
775f67d7 | 186 | delete fESD; |
93ce7d1b | 187 | fESD = NULL; |
886e8d3d | 188 | |
9aea5deb | 189 | AliTRDcalibDB::Terminate(); |
190 | ||
0e339ac7 | 191 | return 0; |
192 | } | |
193 | ||
d679dd6c | 194 | int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtData, |
195 | const AliHLTComponentBlockData* blocks, | |
196 | AliHLTComponent_TriggerData& /*trigData*/, | |
197 | AliHLTUInt8_t* outputPtr, | |
198 | AliHLTUInt32_t& size, | |
199 | vector<AliHLTComponent_BlockData>& outputBlocks ) | |
0e339ac7 | 200 | { |
201 | // Process an event | |
775f67d7 | 202 | |
203 | if (evtData.fEventID == 1) | |
204 | CALLGRIND_START_INSTRUMENTATION; | |
205 | ||
206 | HLTDebug("NofBlocks %i", evtData.fBlockCnt ); | |
dc2e6604 | 207 | |
775f67d7 | 208 | fESD->Reset(); |
209 | //fESD->SetMagneticField(fSolenoidBz); | |
210 | ||
d679dd6c | 211 | AliHLTUInt32_t totalSize = 0, offset = 0; |
0e339ac7 | 212 | |
d679dd6c | 213 | vector<AliHLTComponent_DataType> expectedDataTypes; |
214 | GetInputDataTypes(expectedDataTypes); | |
d679dd6c | 215 | for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ ) |
0e339ac7 | 216 | { |
d679dd6c | 217 | const AliHLTComponentBlockData &block = blocks[iBlock]; |
d679dd6c | 218 | AliHLTComponentDataType inputDataType = block.fDataType; |
219 | Bool_t correctDataType = kFALSE; | |
18ada816 | 220 | |
221 | for(UInt_t i = 0; i < expectedDataTypes.size(); i++){ | |
d679dd6c | 222 | if( expectedDataTypes.at(i) == inputDataType) |
223 | correctDataType = kTRUE; | |
18ada816 | 224 | } |
d679dd6c | 225 | if (!correctDataType) |
226 | { | |
227 | HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping", | |
228 | iBlock, evtData.fBlockCnt-1, | |
229 | evtData.fEventID, evtData.fEventID, | |
230 | DataType2Text(inputDataType).c_str()); | |
231 | continue; | |
232 | } | |
c702bc56 | 233 | else { |
18ada816 | 234 | HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s; Block Size: %i", |
235 | iBlock, evtData.fBlockCnt-1, | |
236 | evtData.fEventID, evtData.fEventID, | |
237 | DataType2Text(inputDataType).c_str(), | |
238 | block.fSize); | |
c702bc56 | 239 | } |
93ce7d1b | 240 | |
4de61263 | 241 | #ifndef NDEBUG |
242 | unsigned long constBase; | |
243 | double inputMultiplier; | |
244 | GetOutputDataSize(constBase,inputMultiplier); | |
245 | if(size<(constBase+block.fSize*inputMultiplier)){ | |
246 | HLTWarning("Memory Block given might be too small: %i < %i; Event %Lu", size, constBase+block.fSize*inputMultiplier, evtData.fEventID); | |
247 | } | |
248 | #endif | |
249 | ||
93ce7d1b | 250 | AliHLTTRDUtils::ReadClusters(fClusterArray, block.fPtr, block.fSize, &fNtimeBins); |
251 | HLTDebug("Reading number of time bins from input block. Changing number of timebins to %d", fNtimeBins); | |
252 | AliTRDtrackerV1::SetNTimeBins(fNtimeBins); | |
253 | ||
ff350753 | 254 | HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast()); |
255 | fTracker->LoadClusters(fClusterArray); | |
dc2e6604 | 256 | |
775f67d7 | 257 | fTracker->Clusters2Tracks(fESD); |
d679dd6c | 258 | |
775f67d7 | 259 | Int_t nTracks = fESD->GetNumberOfTracks(); |
dc2e6604 | 260 | HLTInfo("Number of tracks == %d ==", nTracks); |
d679dd6c | 261 | |
93ce7d1b | 262 | TClonesArray* trdTracks; |
263 | trdTracks = fTracker->GetListOfTracks(); | |
18ada816 | 264 | |
265 | if(nTracks>0){ | |
775f67d7 | 266 | HLTDebug("We have an output ESDEvent: 0x%x with %i tracks", fESD, nTracks); |
ff350753 | 267 | AliHLTUInt32_t addedSize = AliHLTTRDUtils::AddESDToOutput(fESD, outputPtr+offset); |
18ada816 | 268 | totalSize += addedSize; |
269 | ||
270 | // Fill block | |
271 | AliHLTComponentBlockData bd; | |
272 | FillBlockData( bd ); | |
273 | //bd.fPtr = outputPtr; | |
274 | bd.fOffset = offset; | |
275 | bd.fSize = addedSize; | |
ff350753 | 276 | bd.fSpecification = block.fSpecification; |
18ada816 | 277 | bd.fDataType = kAliHLTDataTypeTrack | kAliHLTDataOriginTRD; |
278 | outputBlocks.push_back( bd ); | |
93ce7d1b | 279 | HLTDebug("BD ptr 0x%x, offset %i, size %i, datav1Type %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), bd.fSpecification); |
18ada816 | 280 | offset = totalSize; |
281 | ||
93ce7d1b | 282 | if (fOutputV1Tracks && trdTracks){ |
18ada816 | 283 | HLTDebug("We have an output array: pointer to trdTracks = 0x%x, nbEntries = %i", trdTracks, trdTracks->GetEntriesFast()); |
284 | ||
93ce7d1b | 285 | addedSize = AliHLTTRDUtils::AddTracksToOutput(trdTracks, outputPtr+offset, fNtimeBins); |
18ada816 | 286 | totalSize += addedSize; |
287 | ||
288 | // Fill block | |
18ada816 | 289 | FillBlockData( bd ); |
290 | //bd.fPtr = outputPtr; | |
291 | bd.fOffset = offset; | |
292 | bd.fSize = addedSize; | |
ff350753 | 293 | bd.fSpecification = block.fSpecification; |
18ada816 | 294 | bd.fDataType = AliHLTTRDDefinitions::fgkTRDSATracksDataType; |
295 | outputBlocks.push_back( bd ); | |
93ce7d1b | 296 | HLTDebug("BD ptr 0x%x, offset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), bd.fSpecification); |
18ada816 | 297 | offset = totalSize; |
298 | } | |
c702bc56 | 299 | } |
300 | ||
d679dd6c | 301 | HLTDebug("totalSize: %i", totalSize); |
302 | ||
303 | // if ( totalSize > allocSize ) | |
304 | // { | |
305 | // HLTError("Too much data; Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", | |
306 | // totalSize, size ); | |
307 | // return EMSGSIZE; | |
308 | // } | |
309 | ||
310 | //here we are deleting clusters (but not the TClonesArray itself) | |
311 | fTracker->UnloadClusters(); | |
d679dd6c | 312 | AliTRDReconstructor::SetClusters(0x0); |
ff350753 | 313 | fClusterArray->Delete(); |
5a9a2eb5 | 314 | |
4de61263 | 315 | } |
d679dd6c | 316 | |
d679dd6c | 317 | size = totalSize; |
318 | HLTDebug("Event is done. size written to the output is %i", size); | |
d679dd6c | 319 | return 0; |
320 | } | |
b32b76cb | 321 | |
322 | int AliHLTTRDTrackerV1Component::Configure(const char* arguments){ | |
323 | int iResult=0; | |
324 | if (!arguments) return iResult; | |
325 | ||
326 | TString allArgs=arguments; | |
327 | TString argument; | |
328 | int bMissingParam=0; | |
329 | ||
330 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
331 | if (pTokens) { | |
332 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
333 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
334 | if (argument.IsNull()) continue; | |
335 | ||
4de61263 | 336 | if (argument.CompareTo("output_percentage")==0) { |
b32b76cb | 337 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; |
338 | HLTInfo("Setting output percentage to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
339 | fOutputPercentage=((TObjString*)pTokens->At(i))->GetString().Atoi(); | |
340 | continue; | |
341 | } | |
342 | else if (argument.CompareTo("-solenoidBz")==0) { | |
343 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
344 | fieldStrength=((TObjString*)pTokens->At(i))->GetString().Atof(); | |
345 | HLTInfo("Setting Magnetic field to %.1f KGauss", fieldStrength); | |
346 | continue; | |
347 | } | |
348 | else if (argument.CompareTo("-NTimeBins")==0) { | |
349 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
350 | HLTInfo("Setting number of time bins to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
351 | fNtimeBins=((TObjString*)pTokens->At(i))->GetString().Atoi(); | |
352 | continue; | |
353 | } | |
354 | else if (argument.CompareTo("-geometry")==0) { | |
355 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
356 | HLTInfo("Setting geometry to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
357 | fgeometryFileName=((TObjString*)pTokens->At(i))->GetString(); | |
358 | continue; | |
359 | } | |
93ce7d1b | 360 | else if (argument.CompareTo("-lowflux")==0) { |
b32b76cb | 361 | fRecoParamType = 0; |
362 | HLTInfo("Low flux reconstruction selected"); | |
363 | continue; | |
364 | } | |
93ce7d1b | 365 | else if (argument.CompareTo("-highflux")==0) { |
b32b76cb | 366 | fRecoParamType = 1; |
367 | HLTInfo("High flux reconstruction selected"); | |
368 | continue; | |
369 | } | |
93ce7d1b | 370 | else if (argument.CompareTo("-cosmics")==0) { |
b32b76cb | 371 | fRecoParamType = 2; |
372 | HLTInfo("Cosmics reconstruction selected"); | |
373 | continue; | |
374 | } | |
93ce7d1b | 375 | else if (argument.CompareTo("-magnetic_field_ON")==0) { |
b32b76cb | 376 | fMagneticField = 1; |
377 | HLTInfo("Reconstructon with magnetic field"); | |
378 | continue; | |
379 | } | |
93ce7d1b | 380 | else if (argument.CompareTo("-magnetic_field_OFF")==0) { |
b32b76cb | 381 | fMagneticField = 0; |
382 | HLTInfo("Reconstructon without magnetic field"); | |
383 | continue; | |
384 | } | |
93ce7d1b | 385 | else if (argument.CompareTo("-slowTracking")==0) { |
b32b76cb | 386 | fSlowTracking = kTRUE; |
387 | HLTInfo("Using slow tracking"); | |
388 | continue; | |
389 | } | |
93ce7d1b | 390 | else if (argument.CompareTo("-outputV1Tracks")==0) { |
391 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
392 | TString toCompareTo=((TObjString*)pTokens->At(i))->GetString(); | |
393 | if (toCompareTo.CompareTo("yes")==0){ | |
394 | HLTInfo("Setting OutputV1Tracks to: %s", toCompareTo.Data()); | |
395 | fOutputV1Tracks=kTRUE; | |
396 | } | |
397 | else if (toCompareTo.CompareTo("no")==0){ | |
398 | HLTInfo("Setting OutputV1Tracks to: %s", toCompareTo.Data()); | |
399 | fOutputV1Tracks=kFALSE; | |
400 | } | |
401 | else { | |
402 | HLTError("unknown argument for OutputV1Tracks: %s", toCompareTo.Data()); | |
403 | iResult=-EINVAL; | |
404 | break; | |
405 | } | |
406 | continue; | |
407 | } | |
b32b76cb | 408 | else if (argument.CompareTo("-PIDmethod")==0) { |
409 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
410 | TString toCompareTo=((TObjString*)pTokens->At(i))->GetString(); | |
411 | if (toCompareTo.CompareTo("LH")==0){ | |
412 | HLTInfo("Setting PID method to: %s", toCompareTo.Data()); | |
413 | fPIDmethod=0; | |
414 | } | |
415 | else if (toCompareTo.CompareTo("NN")==0){ | |
416 | HLTInfo("Setting PID method to: %s", toCompareTo.Data()); | |
417 | fPIDmethod=1; | |
418 | } | |
419 | else if (toCompareTo.CompareTo("TM")==0){ | |
420 | HLTInfo("Setting PID method to: %s", toCompareTo.Data()); | |
421 | fPIDmethod=2; | |
422 | } | |
423 | else { | |
424 | HLTError("unknown argument for PID method: %s", toCompareTo.Data()); | |
425 | iResult=-EINVAL; | |
426 | break; | |
427 | } | |
428 | continue; | |
429 | } | |
430 | ||
431 | else { | |
432 | HLTError("unknown argument: %s", argument.Data()); | |
433 | iResult=-EINVAL; | |
434 | break; | |
435 | } | |
436 | } | |
437 | delete pTokens; | |
438 | } | |
439 | if (bMissingParam) { | |
440 | HLTError("missing parameter for argument %s", argument.Data()); | |
441 | iResult=-EINVAL; | |
442 | } | |
443 | if(iResult>=0){ | |
b32b76cb | 444 | iResult=SetParams(); |
445 | } | |
446 | return iResult; | |
447 | } | |
448 | ||
449 | int AliHLTTRDTrackerV1Component::SetParams() | |
450 | { | |
451 | Int_t iResult=0; | |
452 | if(!AliCDBManager::Instance()->IsDefaultStorageSet()){ | |
4de61263 | 453 | HLTError("DefaultStorage is not set in CDBManager"); |
b32b76cb | 454 | return -EINVAL; |
455 | } | |
456 | if(AliCDBManager::Instance()->GetRun()<0){ | |
457 | HLTError("Run Number is not set in CDBManager"); | |
458 | return -EINVAL; | |
459 | } | |
460 | HLTInfo("CDB default storage: %s; RunNo: %i", (AliCDBManager::Instance()->GetDefaultStorage()->GetBaseFolder()).Data(), AliCDBManager::Instance()->GetRun()); | |
461 | ||
462 | if(!AliGeomManager::GetGeometry()){ | |
1eedaf94 | 463 | if(fgeometryFileName.CompareTo("")==0 || !TFile::Open(fgeometryFileName.Data())){ |
b32b76cb | 464 | HLTInfo("Loading standard geometry file"); |
465 | AliGeomManager::LoadGeometry(); | |
466 | }else{ | |
467 | HLTWarning("Loading NON-standard geometry file"); | |
468 | AliGeomManager::LoadGeometry(fgeometryFileName.Data()); | |
469 | } | |
470 | if(!AliGeomManager::GetGeometry()){ | |
4de61263 | 471 | HLTError("Could not load geometry"); |
b32b76cb | 472 | return -EINVAL; |
473 | } | |
474 | } | |
475 | else{ | |
476 | HLTInfo("Geometry Already Loaded!"); | |
477 | } | |
478 | ||
479 | if (fNtimeBins <= 0) | |
480 | { | |
481 | HLTError("Sorry. Tracker needs number of time bins. At the moment you have to provide it with -NTimeBins <value>. The simulation always had 24 and the real data 30. Take your pick. Make sure the information is correct. Ask offline to implement how to propagate this information into clusters/cluster tree."); | |
482 | return -EINVAL; | |
483 | } | |
484 | if (fNtimeBins < 24 || fNtimeBins > 30) | |
485 | { | |
486 | HLTWarning("The number of time bins seems to be strange = %d. But okay. Let's try it...", fNtimeBins); | |
487 | } | |
488 | if (fNtimeBins != 24) | |
489 | { | |
490 | HLTWarning("All PID methods eagerly await 24 time bins, so PID will NOT work!", fNtimeBins); | |
491 | } | |
492 | HLTDebug("Setting number of time bins of the tracker to: %i", fNtimeBins); | |
493 | AliTRDtrackerV1::SetNTimeBins(fNtimeBins); | |
494 | ||
495 | TString recoOptions="sa,sl_tr_0,!cw"; | |
496 | ||
497 | if(!fSlowTracking) | |
498 | recoOptions += ",hlt"; | |
499 | ||
500 | switch(fPIDmethod){ | |
501 | case 0: recoOptions += ",!nn"; break; | |
502 | case 1: recoOptions += ",nn"; break; | |
503 | case 2: recoOptions += ",!nn"; break; | |
504 | } | |
505 | ||
506 | if (fRecoParamType == 0) | |
507 | { | |
508 | HLTDebug("Low flux params init."); | |
509 | fRecoParam = AliTRDrecoParam::GetLowFluxParam(); | |
510 | } | |
511 | ||
512 | if (fRecoParamType == 1) | |
513 | { | |
514 | HLTDebug("High flux params init."); | |
515 | fRecoParam = AliTRDrecoParam::GetHighFluxParam(); | |
516 | } | |
517 | ||
518 | if (fRecoParamType == 2) | |
519 | { | |
520 | HLTDebug("Cosmic Test params init."); | |
521 | fRecoParam = AliTRDrecoParam::GetCosmicTestParam(); | |
522 | } | |
523 | ||
524 | if (fRecoParam == 0) | |
525 | { | |
526 | HLTError("No reco params initialized. Sniffing big trouble!"); | |
527 | return -EINVAL; | |
528 | } | |
529 | ||
530 | fReconstructor->SetRecoParam(fRecoParam); | |
531 | ||
532 | HLTDebug("Reconstructor options are: %s",recoOptions.Data()); | |
533 | fReconstructor->SetOption(recoOptions.Data()); | |
534 | ||
535 | if (fMagneticField >= 0) | |
536 | { | |
537 | HLTWarning("Setting magnetic field by hand!"); | |
538 | } | |
539 | if (!TGeoGlobalMagField::Instance()->IsLocked()) { | |
540 | AliMagF* field; | |
b32b76cb | 541 | if (fMagneticField == 0){ |
542 | // magnetic field OFF | |
543 | field = new AliMagF("Maps","Maps",2,0.,0., 10.,AliMagF::k5kGUniform); | |
544 | TGeoGlobalMagField::Instance()->SetField(field); | |
545 | HLTDebug("Magnetic field is OFF."); | |
546 | }else{ | |
547 | // magnetic field ON | |
548 | field = new AliMagF("Maps","Maps",2,1.,1., 10.,AliMagF::k5kG); | |
549 | TGeoGlobalMagField::Instance()->SetField(field); | |
550 | HLTDebug("Magnetic field is ON."); | |
551 | if( fMagneticField < 0 ) | |
552 | iResult=ReconfigureField(); | |
553 | } | |
554 | }else{ | |
555 | HLTError("Magnetic field is already set and locked, cannot redefine it." ); | |
556 | } | |
557 | return iResult; | |
558 | } | |
559 | ||
b32b76cb | 560 | int AliHLTTRDTrackerV1Component::ReconfigureField() |
561 | { | |
562 | int iResult=0; | |
563 | if(fieldStrength<-100){ | |
564 | const char* pathBField=kAliHLTCDBSolenoidBz; | |
565 | ||
566 | if (pathBField) { | |
567 | HLTInfo("reconfigure B-Field from entry %s", pathBField); | |
568 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/); | |
569 | if (pEntry) { | |
570 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
571 | if (pString) { | |
572 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
573 | TObjArray* pTokens=pString->GetString().Tokenize(" "); | |
574 | TString argument; | |
575 | int bMissingParam=0; | |
576 | if (pTokens) { | |
577 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
578 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
579 | if (argument.IsNull()) continue; | |
580 | ||
581 | if (argument.CompareTo("-solenoidBz")==0) { | |
582 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
583 | HLTDebug("Magnetic field in CDB: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
584 | fieldStrength=((TObjString*)pTokens->At(i))->GetString().Atof(); | |
585 | continue; | |
586 | } else { | |
587 | HLTError("unknown argument %s", argument.Data()); | |
588 | iResult=-EINVAL; | |
589 | break; | |
590 | } | |
591 | } | |
592 | delete pTokens; | |
593 | } | |
594 | } else { | |
595 | HLTError("configuration object \"%s\" has wrong type, required TObjString", pathBField); | |
596 | } | |
597 | } else { | |
598 | HLTError("cannot fetch object \"%s\" from CDB", pathBField); | |
599 | } | |
600 | } | |
601 | } | |
4de61263 | 602 | |
b32b76cb | 603 | if(fieldStrength>=-100){ |
604 | AliMagF* field = (AliMagF *) TGeoGlobalMagField::Instance()->GetField(); | |
4de61263 | 605 | HLTDebug("Magnetic field before change: %f KGauss", field->SolenoidField()); |
b32b76cb | 606 | field->SetFactorSol(1); |
607 | Double_t initialFieldStrengh=field->SolenoidField(); | |
b32b76cb | 608 | field->SetFactorSol(fieldStrength/initialFieldStrengh); |
4de61263 | 609 | HLTDebug("Magnetic field was changed to %f KGauss.", field->SolenoidField()); |
b32b76cb | 610 | } |
611 | return iResult; | |
612 | } | |
613 | ||
614 | int AliHLTTRDTrackerV1Component::Reconfigure(const char* cdbEntry, const char* chainId) | |
615 | { | |
616 | // see header file for class documentation | |
617 | ||
618 | int iResult=0; | |
619 | const char* path="HLT/ConfigTRD/TrackerV1Component"; | |
620 | const char* defaultNotify=""; | |
621 | if (cdbEntry) { | |
622 | path=cdbEntry; | |
623 | defaultNotify=" (default)"; | |
624 | } | |
625 | if (path) { | |
626 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
627 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
628 | if (pEntry) { | |
629 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
630 | if (pString) { | |
631 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
632 | iResult=Configure(pString->GetString().Data()); | |
633 | } else { | |
634 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
635 | } | |
636 | } else { | |
637 | HLTError("cannot fetch object \"%s\" from CDB", path); | |
638 | } | |
639 | } | |
640 | ||
641 | const char* pathBField=kAliHLTCDBSolenoidBz; | |
642 | ||
643 | if (pathBField) { | |
644 | HLTInfo("reconfigure B-Field from entry %s, chain id %s", pathBField,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
645 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/); | |
646 | if (pEntry) { | |
647 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
648 | if (pString) { | |
649 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
650 | iResult=Configure(pString->GetString().Data()); | |
651 | } else { | |
652 | HLTError("configuration object \"%s\" has wrong type, required TObjString", pathBField); | |
653 | } | |
654 | } else { | |
655 | HLTError("cannot fetch object \"%s\" from CDB", pathBField); | |
656 | } | |
657 | } | |
658 | ||
659 | return iResult; | |
660 | ||
661 | } | |
662 | ||
663 | int AliHLTTRDTrackerV1Component::ReadPreprocessorValues(const char* modules) | |
664 | { | |
665 | // see header file for class documentation | |
666 | ||
667 | int iResult = 0; | |
668 | TString str(modules); | |
669 | if(str.Contains("HLT") || str.Contains("TRD") || str.Contains("GRP")){ | |
670 | ||
671 | const char* pathBField=kAliHLTCDBSolenoidBz; | |
672 | if (pathBField) { | |
673 | ||
674 | HLTInfo("reconfigure B-Field from entry %s, modules %s", pathBField,(modules!=NULL && modules[0]!=0)?modules:"<none>"); | |
4de61263 | 675 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/); |
b32b76cb | 676 | |
4de61263 | 677 | // AliCDBPath path(pathBField); |
b32b76cb | 678 | |
4de61263 | 679 | // AliCDBStorage *stor = AliCDBManager::Instance()->GetDefaultStorage(); |
680 | // Int_t version = stor->GetLatestVersion(pathBField, GetRunNo()); | |
681 | // Int_t subVersion = stor->GetLatestSubVersion(pathBField, GetRunNo(), version); | |
682 | // AliCDBEntry *pEntry = stor->Get(path,GetRunNo(), version, subVersion); | |
b32b76cb | 683 | |
4de61263 | 684 | // HLTInfo("RunNo %d, Version %d, subversion %d", GetRunNo(), version, subVersion); |
b32b76cb | 685 | |
686 | if (pEntry) { | |
687 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
688 | if (pString) { | |
4de61263 | 689 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); |
b32b76cb | 690 | iResult=Configure(pString->GetString().Data()); |
691 | } else { | |
692 | HLTError("configuration object \"%s\" has wrong type, required TObjString", pathBField); | |
693 | } | |
694 | } else { | |
695 | HLTError("cannot fetch object \"%s\" from CDB", pathBField); | |
696 | } | |
697 | } | |
698 | } | |
699 | return iResult; | |
700 | } |