1 // $Id: AliHLTEMCALTrackerComponent.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 AliHLTEMCALTrackerComponent.cxx
20 @author Timm Steinbeck, Matthias Richter
22 @brief A EMCALTracker processing component for the HLT. */
31 #include "AliHLTEMCALTrackerComponent.h"
32 #include "AliHLTEMCALDefinitions.h"
33 #include "AliCDBManager.h"
34 #include "AliEMCALTracker.h"
35 #include "AliEMCALReconstructor.h"
36 #include "AliESDEvent.h"
37 #include "AliMagFMaps.h"
38 #include "AliESDfriend.h"
44 // this is a global object used for automatic component registration, do not use this
45 AliHLTEMCALTrackerComponent gAliHLTEMCALTrackerComponent;
47 ClassImp(AliHLTEMCALTrackerComponent);
49 AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent()
51 , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
52 , fStrorageDBpath("local://$ALICE_ROOT")
55 , fGeometryFileName("")
59 , fInputFolder(new TFolder("EMCALtrackerFolder", "EMCALtrackerFolder"))
61 // Default constructor
62 fInputFolder->SetOwner(kTRUE);
64 fGeometryFileName = getenv("ALICE_ROOT");
65 fGeometryFileName += "/HLT/EMCAL/geometry.root";
68 AliHLTEMCALTrackerComponent::~AliHLTEMCALTrackerComponent()
75 const char* AliHLTEMCALTrackerComponent::GetComponentID()
77 // Return the component ID const char *
78 return "EMCALTracker"; // The ID of this component
81 void AliHLTEMCALTrackerComponent::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( AliHLTEMCALDefinitions::fgkClusterDataType );
88 AliHLTComponent_DataType AliHLTEMCALTrackerComponent::GetOutputDataType()
90 // Get the output data type
91 return AliHLTEMCALDefinitions::fgkEMCALESDDataType;
94 void AliHLTEMCALTrackerComponent::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* AliHLTEMCALTrackerComponent::Spawn()
104 // Spawn function, return new instance of this class
105 return new AliHLTEMCALTrackerComponent;
108 int AliHLTEMCALTrackerComponent::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::EMCALTracker::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
117 if ( !strcmp( argv[i], "output_percentage" ) )
121 Logging(kHLTLogError, "HLT::EMCALTracker::DoInit", "Missing Argument", "Missing output_percentage parameter");
124 Logging( kHLTLogDebug, "HLT::EMCALTracker::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
125 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
128 Logging(kHLTLogError, "HLT::EMCALTracker::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
131 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
136 if ( strcmp( argv[i], "-cdb" ) == 0)
140 Logging(kHLTLogError, "HLT::EMCALTracker::DoInit", "Missing Argument", "Missing -cdb argument");
143 fStrorageDBpath = argv[i+1];
144 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoInit", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );
149 if ( strcmp( argv[i], "-geometry" ) == 0)
153 Logging(kHLTLogError, "HLT::EMCALTracker::DoInit", "Missing Argument", "Missing -geometry argument");
156 fGeometryFileName = argv[i+1];
157 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoInit", "GeomFile storage set", "GeomFile storage is %s",
158 fGeometryFileName.c_str() );
163 Logging(kHLTLogError, "HLT::EMCALTracker::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::EMCALTracker::DoInit", "Field", "Unable to init the field");
174 fCDB = AliCDBManager::Instance();
177 Logging(kHLTLogError, "HLT::EMCALCalibration::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::EMCALCalibration::DoInit", "CDB instance", "fCDB 0x%x", fCDB);
186 fGeometryFile = TFile::Open(fGeometryFileName.c_str());
189 fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry");
190 fTracker = new AliEMCALTracker;
194 Logging(kHLTLogError, "HLT::EMCALTracker::DoInit", "fGeometryFile", "Unable to open file. FATAL!");
201 int AliHLTEMCALTrackerComponent::DoDeinit()
203 // Deinitialization of the component
213 fGeometryFile->Close();
214 delete fGeometryFile;
218 fInputFolder->Clear();
223 int AliHLTEMCALTrackerComponent::DoEvent( const AliHLTComponentEventData & evtData,
224 AliHLTComponentTriggerData & trigData )
228 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
229 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
231 AliHLTUInt32_t dBlockSpecification = 0;
233 //implement a usage of the following
234 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
235 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
236 // void *triggerData = trigData.fData;
237 Logging( kHLTLogDebug, "HLT::EMCALTracker::DoEvent", "Trigger data received",
238 "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
240 AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTEMCALDefinitions::fgkClusterDataType );
243 dBlockSpecification = dblock->fSpecification;
247 Logging( kHLTLogWarning, "HLT::EMCALTracker::DoEvent", "DATAIN", "First Input Block not found! 0x%x", dblock);
251 fInputFolder->Clear();
252 AliESDEvent *esd = 0; // we assume we receive this one from a global merger component
253 TTree *clusterTree = 0;
258 // here getfirstinput finds the first object with spec type..
259 // get the clusters tree
260 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkClusterDataType, "TTree", ibForce);
263 tobjin = (TObject *)GetNextInputObject( ibForce );
264 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
265 clusterTree = (TTree*)tobjin;
266 if (clusterTree != 0)
268 Int_t iNentries = clusterTree->GetEntries();
269 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoEvent", "COUNT", "N of tree entries = %d", iNentries);
270 fTracker->LoadClusters(clusterTree);
271 fInputFolder->Add(clusterTree);
275 // now get the ESD(s) - should in principle be only one...
276 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkESDDataType, "AliESDevent", ibForce);
279 esd = (AliESDEvent *)tobjin;
282 HLTInfo("Got ESDevent");
283 fInputFolder->Add(esd);
285 tobjin = (TObject *)GetNextInputObject( ibForce );
286 Logging( kHLTLogInfo, "HLT::EMCALTracker::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
287 clusterTree = (TTree*)tobjin;
290 esd = (AliESDEvent*)fInputFolder->FindObject("AliESDevent");
293 fTracker->PropagateBack(esd);
295 //here transport the esd tracks further
296 Int_t nTracks = esd->GetNumberOfTracks();
297 HLTInfo("Number of tracks %d", nTracks);
299 PushBack(esd, AliHLTEMCALDefinitions::fgkEMCALESDDataType);
303 HLTError("No ESD events received!");
306 fTracker->UnloadClusters();
307 fInputFolder->Clear();
309 HLTDebug("Event done.");