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 AliHLTTRDTrackerComponent.cxx
20 @author Timm Steinbeck, Matthias Richter
22 @brief A TRDTracker processing component for the HLT. */
31 #include "AliHLTTRDTrackerComponent.h"
32 #include "AliHLTTRDDefinitions.h"
33 #include "AliCDBManager.h"
35 #include "AliTRDReconstructor.h"
36 #include "AliTRDrecoParam.h"
37 #include "AliESDEvent.h"
38 //#include "AliTRDtrackerHLT.h"
39 #include "AliTRDtracker.h"
40 #include "AliTRDCalibraFillHisto.h"
41 #include "AliMagFMaps.h"
42 #include "AliTRDcluster.h"
43 #include "AliESDfriend.h"
48 // this is a global object used for automatic component registration, do not use this
49 AliHLTTRDTrackerComponent gAliHLTTRDTrackerComponent;
51 ClassImp(AliHLTTRDTrackerComponent);
53 AliHLTTRDTrackerComponent::AliHLTTRDTrackerComponent()
55 , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
56 , fStrorageDBpath("local://$ALICE_ROOT")
59 , fGeometryFileName("")
64 // Default constructor
66 fGeometryFileName = getenv("ALICE_ROOT");
67 fGeometryFileName += "/HLT/TRD/geometry.root";
70 AliHLTTRDTrackerComponent::~AliHLTTRDTrackerComponent()
75 const char* AliHLTTRDTrackerComponent::GetComponentID()
77 // Return the component ID const char *
78 return "TRDTracker"; // The ID of this component
81 void AliHLTTRDTrackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
83 // Get the list of input data
84 list.clear(); // We do not have any requirements for our input data type(s).
85 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
88 AliHLTComponent_DataType AliHLTTRDTrackerComponent::GetOutputDataType()
90 // Get the output data type
91 return AliHLTTRDDefinitions::fgkClusterDataType;
94 void AliHLTTRDTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
96 // Get the output data size
98 inputMultiplier = ((double)fOutputPercentage)/100.0;
101 // Spawn function, return new instance of this class
102 AliHLTComponent* AliHLTTRDTrackerComponent::Spawn()
104 // Spawn function, return new instance of this class
105 return new AliHLTTRDTrackerComponent;
108 int AliHLTTRDTrackerComponent::DoInit( int argc, const char** argv )
110 // perform initialization. We check whether our relative output size is specified in the arguments.
111 fOutputPercentage = 100;
116 Logging( kHLTLogDebug, "HLT::TRDTracker::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
117 if ( !strcmp( argv[i], "output_percentage" ) )
121 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing output_percentage parameter");
124 Logging( kHLTLogDebug, "HLT::TRDTracker::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
125 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
128 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
131 Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
136 if ( strcmp( argv[i], "-cdb" ) == 0)
140 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing -cdb argument");
143 fStrorageDBpath = argv[i+1];
144 Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );
149 if ( strcmp( argv[i], "-geometry" ) == 0)
153 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Missing Argument", "Missing -geometry argument");
156 fGeometryFileName = argv[i+1];
157 Logging( kHLTLogInfo, "HLT::TRDTracker::DoInit", "GeomFile storage set", "GeomFile storage is %s",
158 fGeometryFileName.c_str() );
163 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
167 //init alifield map - temporarly fixed - should come from a DB
168 fField = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1);
170 AliTracker::SetFieldMap(fField,1);
172 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Field", "Unable to init the field");
174 fCDB = AliCDBManager::Instance();
177 Logging(kHLTLogError, "HLT::TRDCalibration::DoInit", "Could not get CDB instance", "fCDB 0x%x", fCDB);
181 fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
182 fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
183 Logging(kHLTLogDebug, "HLT::TRDCalibration::DoInit", "CDB instance", "fCDB 0x%x", fCDB);
186 fGeometryFile = TFile::Open(fGeometryFileName.c_str());
189 fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry");
190 //fTracker = new AliTRDtrackerHLT(fGeometryFile);
191 AliTRDrecoParam *fPars = AliTRDrecoParam::GetLowFluxParam();
192 fPars->SetSeeding(kTRUE);
193 fPars->SetStreamLevel(0);
194 AliTRDReconstructor reconstructor; reconstructor.SetRecoParam(fPars);
195 fTracker = new AliTRDtracker(fGeometryFile);
196 //fTracker = new AliTRDtracker(fGeometryFile);
200 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "fGeometryFile", "Unable to open file. FATAL!");
204 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
207 Logging(kHLTLogError, "HLT::TRDTracker::DoInit", "Calibration Histos", "::Instance failed");
212 calibra->Init2Dhistos();
218 int AliHLTTRDTrackerComponent::DoDeinit()
220 // Deinitialization of the component
230 fGeometryFile->Close();
231 delete fGeometryFile;
235 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
238 // should not write in here!
240 Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "before destroy");
242 Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "after destroy");
248 int AliHLTTRDTrackerComponent::DoEvent( const AliHLTComponentEventData & evtData,
249 AliHLTComponentTriggerData & trigData )
253 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
254 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
256 AliHLTUInt32_t dBlockSpecification = 0;
258 //implement a usage of the following
259 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
260 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
261 // void *triggerData = trigData.fData;
262 Logging( kHLTLogDebug, "HLT::TRDTracker::DoEvent", "Trigger data received",
263 "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
265 AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType );
268 dBlockSpecification = dblock->fSpecification;
272 Logging( kHLTLogWarning, "HLT::TRDTracker::DoEvent", "DATAIN", "First Input Block not found! 0x%x", dblock);
277 TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce);
278 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x", tobjin);
280 TTree *clusterTree = (TTree*)tobjin;
283 Logging( kHLTLogWarning, "HLT::TRDTracker::DoEvent", "DATAIN", "First Input Block not a tree! 0x%x", tobjin);
287 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
293 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
294 Int_t iNentries = clusterTree->GetEntries();
295 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "COUNT", "N of tree entries = %d", iNentries);
296 fTracker->LoadClusters(clusterTree);
300 Logging( kHLTLogError, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Tree Pointer = 0x%x", clusterTree);
303 tobjin = (TObject *)GetNextInputObject( ibForce );
304 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
305 clusterTree = (TTree*)tobjin;
308 fTracker->SetAddTRDseeds();
310 AliESDfriend *esdFriend = new AliESDfriend();
312 AliESDEvent *esd = new AliESDEvent();
313 esd->CreateStdContent();
314 fTracker->PropagateBack(esd);
315 fTracker->RefitInward(esd);
316 fTracker->Clusters2Tracks(esd);
318 esd->GetESDfriend(esdFriend);
319 //here transport the esd tracks further
321 Int_t nTracks = esd->GetNumberOfTracks();
322 Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
323 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Number of tracks %d Number of TRD tracks %d", nTracks, nTRDTracks);
325 // AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
326 // calibra->Init2Dhistostrack();
328 for (Int_t it = 0; it < nTracks; it++)
330 AliESDtrack* track = esd->GetTrack(it);
332 // Int_t nCalibObjects = 0;
334 // while (track->GetCalibObject(idx) != 0)
339 // Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Track 0x%x NcalibObjects %d", track, nCalibObjects);
341 Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Track %d 0x%x Pt %1.2f", it, track, track->Pt());
342 PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType, ++dBlockSpecification);
343 // if (calibra->GetMItracking())
345 // calibra->UpdateHistograms(track);
349 //PushBack(esd, AliHLTTRDDefinitions::fgkTRDSAEsdDataType, dBlockSpecification);
350 //PushBack(esdFriend, AliHLTTRDDefinitions::fgkTRDSAEsdDataType, dBlockSpecification);
352 //no receiver defined yet(!)
353 //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "now deleting");
357 //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete esd");
360 //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete clusterTree");