1 // $Id: AliHLTTRDTrackerV1Component.cxx 23618 2008-01-29 13:07:38Z hristov $
3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * for The ALICE Off-line Project. *
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 **************************************************************************/
19 /** @file AliHLTTRDTrackerV1Component.cxx
20 @author Timm Steinbeck, Matthias Richter
22 @brief A TRDTrackerV1 processing component for the HLT. */
28 #include "AliHLTTRDTrackerV1Component.h"
29 #include "AliHLTTRDDefinitions.h"
34 #include "AliCDBManager.h"
35 #include "AliESDEvent.h"
36 #include "AliMagFMaps.h"
37 #include "AliESDfriend.h"
39 #include "AliTRDReconstructor.h"
40 #include "AliTRDtrackerV1.h"
41 #include "AliTRDcluster.h"
42 #include "AliTRDrecoParam.h"
48 // this is a global object used for automatic component registration, do not use this
49 AliHLTTRDTrackerV1Component gAliHLTTRDTrackerV1Component;
51 ClassImp(AliHLTTRDTrackerV1Component);
53 AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component()
55 , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
56 , fStrorageDBpath("local://$ALICE_ROOT")
59 , fGeometryFileName("")
65 // Default constructor
67 fGeometryFileName = getenv("ALICE_ROOT");
68 fGeometryFileName += "/HLT/TRD/geometry.root";
71 AliHLTTRDTrackerV1Component::~AliHLTTRDTrackerV1Component()
76 const char* AliHLTTRDTrackerV1Component::GetComponentID()
78 // Return the component ID const char *
79 return "TRDTrackerV1"; // The ID of this component
82 void AliHLTTRDTrackerV1Component::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
84 // Get the list of input data
85 list.clear(); // We do not have any requirements for our input data type(s).
86 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
89 AliHLTComponent_DataType AliHLTTRDTrackerV1Component::GetOutputDataType()
91 // Get the output data type
92 return AliHLTTRDDefinitions::fgkClusterDataType;
95 void AliHLTTRDTrackerV1Component::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
97 // Get the output data size
99 inputMultiplier = ((double)fOutputPercentage)/100.0;
102 // Spawn function, return new instance of this class
103 AliHLTComponent* AliHLTTRDTrackerV1Component::Spawn()
105 // Spawn function, return new instance of this class
106 return new AliHLTTRDTrackerV1Component;
109 int AliHLTTRDTrackerV1Component::DoInit( int argc, const char** argv )
111 // perform initialization. We check whether our relative output size is specified in the arguments.
112 fOutputPercentage = 100;
116 Int_t iRecoParamType = -1; // default will be the low flux
117 Int_t iNtimeBins = -1; // number of time bins for the tracker to use
118 Int_t iMagneticField = -1; // magnetic field: 0==OFF and 1==ON
122 Logging( kHLTLogDebug, "HLT::TRDTrackerV1::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
123 if ( !strcmp( argv[i], "output_percentage" ) )
127 Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "Missing Argument", "Missing output_percentage parameter");
130 Logging( kHLTLogDebug, "HLT::TRDTrackerV1::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
131 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
134 Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
137 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
142 if ( !strcmp( argv[i], "-NTimeBins" ) )
146 HLTError("Missing -NTimeBins parameter");
149 HLTDebug("Arguments", "argv[%d+1] == %s", i, argv[i+1] );
150 iNtimeBins = strtoul( argv[i+1], &cpErr, 0 );
153 HLTError("Wrong Argument. Cannot convert -NTimeBins parameter '%s'", argv[i+1] );
160 if ( strcmp( argv[i], "-cdb" ) == 0)
164 Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "Missing Argument", "Missing -cdb argument");
167 fStrorageDBpath = argv[i+1];
168 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoInit", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );
173 if ( strcmp( argv[i], "-geometry" ) == 0)
177 Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "Missing Argument", "Missing -geometry argument");
180 fGeometryFileName = argv[i+1];
181 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoInit", "GeomFile storage set", "GeomFile storage is %s",
182 fGeometryFileName.c_str() );
187 // the flux parametrizations
188 if ( strcmp( argv[i], "-lowflux" ) == 0)
191 HLTDebug("Low flux reco selected.");
196 if ( strcmp( argv[i], "-highflux" ) == 0)
199 HLTDebug("Low flux reco selected.");
204 if ( strcmp( argv[i], "-magnetic_field_ON" ) == 0)
211 if ( strcmp( argv[i], "-magnetic_field_OFF" ) == 0)
218 Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
222 // THE "REAL" INIT COMES HERE
223 // offline condition data base
224 fCDB = AliCDBManager::Instance();
227 Logging(kHLTLogError, "HLT::TRDCalibration::DoInit", "Could not get CDB instance", "fCDB 0x%x", fCDB);
232 fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
233 fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
234 Logging(kHLTLogDebug, "HLT::TRDCalibration::DoInit", "CDB instance", "fCDB 0x%x", fCDB);
237 // check if the N of time bins make sense
240 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.");
244 if (iNtimeBins < 24 || iNtimeBins > 30)
246 HLTWarning("The number of time bins seems to be strange = %d. But okay. Let's try it...", iNtimeBins);
249 HLTDebug("The number of time bins = %d.", iNtimeBins);
250 AliTRDtrackerV1::SetNTimeBins(iNtimeBins);
252 // !!!! THIS IS IMPORTANT
253 // init alifield map - temporarly via parameter - should come from a DB or DCS ?
255 if (iMagneticField < 0)
258 HLTWarning("No magnetic field switch stated. Use -magnetic_field_ON or -magnetic_field_OFF flag. Defaulting to OFF = NO MAGNETIC FIELD");
261 if (iMagneticField == 0)
263 // magnetic field OFF
264 fField = new AliMagFMaps("Maps","Maps", 2, 0., 10., 1);
265 HLTDebug("Magnetic field is OFF.");
268 if (iMagneticField == 1)
271 fField = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1);
272 HLTDebug("Magnetic field is ON.");
277 HLTError("Unable to init the field. Trouble at this point.");
281 // kTRUE sets the map uniform
282 AliTracker::SetFieldMap(fField,kTRUE);
284 // reconstruction parameters
285 if (iRecoParamType < 0 || iRecoParamType > 1)
287 HLTWarning("No reco param selected. Use -lowflux or -highflux flag. Defaulting to low flux.");
291 if (iRecoParamType == 0)
293 fRecoParam = AliTRDrecoParam::GetLowFluxParam();
294 HLTDebug("Low flux params init.");
297 if (iRecoParamType == 1)
299 fRecoParam = AliTRDrecoParam::GetHighFluxParam();
300 HLTDebug("High flux params init.");
305 HLTError("No reco params initialized. Sniffing big trouble!");
309 // this is important in case we want to ::PropagateBack - see the TrackerV1.cxx
310 fRecoParam->SetSeeding(kTRUE);
311 // no debug stream -> no debug files! on HLT
312 fRecoParam->SetStreamLevel(0);
314 AliTRDReconstructor::SetRecoParam(fRecoParam);
317 // for some unknown at this point reason (30th of April 2008)
318 // the TrackerV1 initializes new TRDgeometry in the constructor
321 // fGeometryFile = TFile::Open(fGeometryFileName.c_str());
322 // if (fGeometryFile)
324 // fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry");
325 // // for the old tracker we would do this:
326 // fTracker = new AliTRDtracker(fGeometryFile);
330 // Logging(kHLTLogError, "HLT::TRDTrackerV1::DoInit", "fGeometryFile", "Unable to open file. FATAL!");
334 // create the tracker
335 fTracker = new AliTRDtrackerV1();
336 HLTDebug("TRDTracker at 0x%x", fTracker);
340 HLTError("Unable to create the tracker!");
341 // do we want a smarter return value here? probably yes
342 // answering your own questions is stupid but maybe helpful... ;)
349 int AliHLTTRDTrackerV1Component::DoDeinit()
351 // Deinitialization of the component
361 fGeometryFile->Close();
362 delete fGeometryFile;
369 int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData & evtData,
370 AliHLTComponentTriggerData & trigData )
374 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
375 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
377 AliHLTUInt32_t dBlockSpecification = 0;
379 //implement a usage of the following
380 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
381 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
382 // void *triggerData = trigData.fData;
383 Logging( kHLTLogDebug, "HLT::TRDTrackerV1::DoEvent", "Trigger data received",
384 "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
386 AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType );
389 dBlockSpecification = dblock->fSpecification;
393 Logging( kHLTLogWarning, "HLT::TRDTrackerV1::DoEvent", "DATAIN", "First Input Block not found! 0x%x", dblock);
399 TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce);
400 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "1stBLOCK", "Pointer = 0x%x", tobjin);
402 TTree *clusterTree = (TTree*)tobjin;
405 Logging( kHLTLogWarning, "HLT::TRDTrackerV1::DoEvent", "DATAIN", "First Input Block not a tree! 0x%x", tobjin);
409 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "1stBLOCK", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
415 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "CLUSTERS", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
416 Int_t iNentries = clusterTree->GetEntries();
417 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "COUNT", "N of tree entries = %d", iNentries);
418 fTracker->LoadClusters(clusterTree);
422 Logging( kHLTLogError, "HLT::TRDTrackerV1::DoEvent", "CLUSTERS", "Tree Pointer = 0x%x", clusterTree);
425 tobjin = (TObject *)GetNextInputObject( ibForce );
426 Logging( kHLTLogInfo, "HLT::TRDTrackerV1::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
427 clusterTree = (TTree*)tobjin;
430 // maybe it is not so smart to create it each event? clear is enough ?
431 AliESDEvent *esd = new AliESDEvent();
432 esd->CreateStdContent();
434 fTracker->Clusters2Tracks(esd);
436 //fTracker->PropagateBack(esd);
438 //here transport the esd tracks further
439 Int_t nTracks = esd->GetNumberOfTracks();
440 Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
441 HLTInfo("Number of tracks %d Number of TRD tracks %d", nTracks, nTRDTracks);
443 PushBack(esd, AliHLTTRDDefinitions::fgkTRDSAEsdDataType);
445 // extract the friend ?
446 // AliESDfriend *esdFriend = new AliESDfriend();
447 // esd->GetESDfriend(esdFriend);
448 // PushBack(esdFriend, AliHLTTRDDefinitions::fgkTRDSAEsdDataType);
451 //HLTInfo("now deleting");
455 fTracker->UnloadClusters();
457 HLTDebug("Event done.");
461 ///////////////////////////////
463 consider transporting TRD tracks only as they might have signigicantly smaller size... on the other hand you will need to prodece ESDs at some point...
465 // this is for ESDtrack
466 // for (Int_t it = 0; it < nTracks; it++)
468 // AliESDtrack* track = esd->GetTrack(it);
469 // HLTInfo("Track %d 0x%x Pt %1.2f", it, track, track->Pt());
470 // //PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType, ++dBlockSpecification);
471 // PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType);
474 // one can do similar things with the TRDtrack
475 esd->GetNumberOfTrdTracks();
478 AliESDTrdTrack *trdtrack = esd->GetTrdTrack(i)