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"
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")
58 , fGeometryFileName("")
63 // Default constructor
65 fGeometryFileName = getenv("ALICE_ROOT");
66 fGeometryFileName += "/HLT/TRD/geometry.root";
69 AliHLTTRDTrackerComponent::~AliHLTTRDTrackerComponent()
74 const char* AliHLTTRDTrackerComponent::GetComponentID()
76 // Return the component ID const char *
77 return "TRDTracker"; // The ID of this component
80 void AliHLTTRDTrackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
82 // Get the list of input data
83 list.clear(); // We do not have any requirements for our input data type(s).
84 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
87 AliHLTComponent_DataType AliHLTTRDTrackerComponent::GetOutputDataType()
89 // Get the output data type
90 return AliHLTTRDDefinitions::fgkClusterDataType;
93 void AliHLTTRDTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
95 // Get the output data size
97 inputMultiplier = ((double)fOutputPercentage)/100.0;
100 // Spawn function, return new instance of this class
101 AliHLTComponent* AliHLTTRDTrackerComponent::Spawn()
103 // Spawn function, return new instance of this class
104 return new AliHLTTRDTrackerComponent;
107 int AliHLTTRDTrackerComponent::DoInit( int argc, const char** argv )
109 // perform initialization. We check whether our relative output size is specified in the arguments.
110 fOutputPercentage = 100;
115 HLTDebug("argv[%d] == %s", i, argv[i] );
116 if ( !strcmp( argv[i], "output_percentage" ) )
120 HLTError("Missing output_percentage parameter");
123 HLTDebug("Arguments", "argv[%d+1] == %s", i, argv[i+1] );
124 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
127 HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
130 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
135 if ( strcmp( argv[i], "-cdb" ) == 0)
139 HLTError("Missing -cdb argument");
142 fStrorageDBpath = argv[i+1];
143 HLTInfo("DB storage is %s", fStrorageDBpath.c_str() );
148 if ( strcmp( argv[i], "-geometry" ) == 0)
152 HLTError("Missing -geometry argument");
155 fGeometryFileName = argv[i+1];
156 HLTInfo("GeomFile storage is %s", fGeometryFileName.c_str() );
161 HLTError("Unknown option '%s'", argv[i] );
166 fCDB = AliCDBManager::Instance();
169 HLTError("Could not get CDB instance", "fCDB 0x%x", fCDB);
173 fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
174 fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
175 HLTDebug("fCDB 0x%x", fCDB);
178 fGeometryFile = TFile::Open(fGeometryFileName.c_str());
181 fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry");
182 //fTracker = new AliTRDtrackerHLT(fGeometryFile);
183 AliTRDrecoParam *fPars = AliTRDrecoParam::GetLowFluxParam();
184 //fPars->SetSeeding(kTRUE);
185 //fPars->SetStreamLevel(0);
186 AliTRDReconstructor reconstructor; reconstructor.SetRecoParam(fPars);
187 // write clusters [cw] = true
188 // track seeding (stand alone tracking) [sa] = true
189 // PID method in reconstruction (NN) [nn] = true
190 // write online tracklets [tw] = false
191 // drift gas [ar] = false
192 reconstructor.SetOption("cw,sa");
193 fTracker = new AliTRDtracker(fGeometryFile);
194 //fTracker = new AliTRDtracker(fGeometryFile);
198 HLTError("Unable to open file. FATAL!");
202 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
205 HLTError("Calibration Histos ::Instance failed");
210 calibra->Init2Dhistos();
216 int AliHLTTRDTrackerComponent::DoDeinit()
218 // Deinitialization of the component
225 fGeometryFile->Close();
226 delete fGeometryFile;
230 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
233 // should not write in here!
241 int AliHLTTRDTrackerComponent::DoEvent( const AliHLTComponentEventData & /*evtData*/,
242 AliHLTComponentTriggerData & /*trigData*/ )
246 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
247 HLTInfo("NofBlocks %lu", GetNumberOfInputBlocks() );
249 AliHLTUInt32_t dBlockSpecification = 0;
251 //implement a usage of the following
252 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
253 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
254 // void *triggerData = trigData.fData;
255 //HLTDebug("Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
257 AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType );
260 dBlockSpecification = dblock->fSpecification;
264 HLTWarning("First Input Block not found! 0x%x", dblock);
269 TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce);
270 HLTInfo("Pointer = 0x%x", tobjin);
272 TTree *clusterTree = (TTree*)tobjin;
275 HLTWarning("First Input Block not a tree! 0x%x", tobjin);
279 HLTInfo("Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
285 HLTInfo("Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
286 Int_t iNentries = clusterTree->GetEntries();
287 HLTInfo("N of tree entries = %d", iNentries);
288 fTracker->LoadClusters(clusterTree);
292 HLTError("Tree Pointer = 0x%x", clusterTree);
295 tobjin = (TObject *)GetNextInputObject( ibForce );
296 HLTInfo("Pointer = 0x%x", tobjin);
297 clusterTree = (TTree*)tobjin;
300 fTracker->SetAddTRDseeds();
302 AliESDfriend *esdFriend = new AliESDfriend();
304 AliESDEvent *esd = new AliESDEvent();
305 esd->CreateStdContent();
306 fTracker->PropagateBack(esd);
307 fTracker->RefitInward(esd);
308 fTracker->Clusters2Tracks(esd);
310 esd->GetESDfriend(esdFriend);
311 //here transport the esd tracks further
313 Int_t nTracks = esd->GetNumberOfTracks();
314 Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
315 HLTInfo( "Number of tracks %d Number of TRD tracks %d", nTracks, nTRDTracks);
318 for (Int_t it = 0; it < nTracks; it++)
320 AliESDtrack* track = esd->GetTrack(it);
321 HLTInfo("Track %d 0x%x Pt %1.2f", it, track, track->Pt());
322 PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType, ++dBlockSpecification);