3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT 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 AliHLTGlobalOfflineVertexerComponent.cxx
20 // @author Matthias Richter
22 // @brief Component wrapping the offline vertexer
23 // @ingroup alihlt_global
29 #include "AliHLTGlobalOfflineVertexerComponent.h"
30 #include "AliESDEvent.h"
31 #include "AliESDtrack.h"
32 #include "AliVertexerTracks.h"
33 #include "AliESDVertex.h"
34 #include "AliGRPRecoParam.h"
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTGlobalOfflineVertexerComponent)
41 AliHLTGlobalOfflineVertexerComponent::AliHLTGlobalOfflineVertexerComponent()
44 , fBenchmark("GlobalOfflineVertexer")
46 // The component subscribes to the HLT ESD and calculates the vertex
47 // using the offline vertexer.
49 // see header file for class documentation
51 // refer to README to build package
53 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
55 // NOTE: all helper classes should be instantiated in DoInit()
58 AliHLTGlobalOfflineVertexerComponent::~AliHLTGlobalOfflineVertexerComponent()
62 // NOTE: implement proper cleanup in DoDeinit()
65 const char* AliHLTGlobalOfflineVertexerComponent::GetComponentID()
67 // component property: id
68 return "GlobalOfflineVertexer";
71 void AliHLTGlobalOfflineVertexerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
73 // component property: list of input data types
74 list.push_back(kAliHLTDataTypeESDObject);
77 AliHLTComponentDataType AliHLTGlobalOfflineVertexerComponent::GetOutputDataType()
79 // component property: output data type
80 return kAliHLTAnyDataType;
83 void AliHLTGlobalOfflineVertexerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
85 // component property: output size estimator
87 inputMultiplier = 1.0;
90 void AliHLTGlobalOfflineVertexerComponent::GetOCDBObjectDescription( TMap* const targetMap)
92 // Get a list of OCDB object description.
93 // The list of objects is provided in a TMap
94 // - key: complete OCDB path, e.g. GRP/GRP/Data
95 // - value: short description why the object is needed
96 // Key and value objects created inside this class go into ownership of
98 if (!targetMap) return;
99 // targetMap->Add(new TObjString("HLT/ConfigHLT/GlobalOfflineVertexer"),
100 // new TObjString("configuration object"));
101 targetMap->Add(new TObjString("GRP/GRP/Data"),
102 new TObjString("GRP object"));
105 AliHLTComponent* AliHLTGlobalOfflineVertexerComponent::Spawn()
107 // Spawn function, return new class instance
108 return new AliHLTGlobalOfflineVertexerComponent;
111 int AliHLTGlobalOfflineVertexerComponent::DoInit( int argc, const char** argv )
113 // see header file for class documentation
116 // init stage 1: default values for all data members
118 // init stage 2: read configuration object
119 // ScanConfigurationArgument() needs to be implemented
120 TString cdbPath="HLT/ConfigHLT/";
121 cdbPath+=GetComponentID();
123 // TODO: activate later when the object has been copied to the
125 //iResult=ConfigureFromCDBTObjString(cdbPath);
127 // init stage 3: read the component arguments
129 iResult=ConfigureFromArgumentString(argc, argv);
133 // implement the component initialization
134 fVertexer=new AliVertexerTracks;
136 fVertexer->SetFieldkG(GetBz());
138 // initialize for TPC + ITS primary vertex
139 fVertexer->SetITSMode();
140 fVertexer->SetConstraintOff();
141 // get cuts for vertexer from AliGRPRecoParam
142 AliGRPRecoParam *grpRecoParam=NULL;
143 TObject* obj=LoadAndExtractOCDBObject("GRP/Calib/RecoParam");
144 if (obj) grpRecoParam=dynamic_cast<AliGRPRecoParam*>(obj);
146 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
147 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
148 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
149 fVertexer->SetCuts(cutsVertexer);
150 delete [] cutsVertexer; cutsVertexer = NULL;
152 // to run on HLT events we do not require ITS refit
153 fVertexer->SetITSrefitNotRequired();
161 fBenchmark.SetTimer(0,"total");
166 int AliHLTGlobalOfflineVertexerComponent::ScanConfigurationArgument(int /*argc*/, const char** /*argv*/)
168 // Scan configuration arguments
169 // Return the number of processed arguments
170 // -EPROTO if argument format error (e.g. number expected but not found)
172 // The AliHLTComponent base class implements a parsing loop for argument strings and
173 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
174 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
179 int AliHLTGlobalOfflineVertexerComponent::DoDeinit()
181 // component cleanup, delete all instances of helper classes here
182 if (fVertexer) delete fVertexer;
188 int AliHLTGlobalOfflineVertexerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
189 AliHLTComponentTriggerData& /*trigData*/)
191 // event processing function
194 // check if this is a data event, there are a couple of special events
195 // which should be ignored for normal processing
196 if (!fVertexer) return -ENODEV;
197 if (!IsDataEvent()) return 0;
199 fBenchmark.StartNewEvent();
202 for (const TObject* obj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent");
203 obj; obj = GetNextInputObject()) {
205 // input objects are not supposed to be changed by the component, so they
206 // are defined const. However, the implementation of AliESDEvent does not
207 // support this and we need the const_cast
208 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
210 esd->GetStdContent();
211 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
212 AliESDtrack* track = esd->GetTrack(i);
213 // TODO: this is just a quick hack, the vertexer requires kITSrefit and
215 // the HLT reconstruction needs to be adapted according to that requirement
216 // we have to check which flag needs to be set at what stage
217 track->SetStatus(AliESDtrack::kITSrefit);
219 AliESDVertex* vertex=fVertexer->FindPrimaryVertex(esd);
221 AliInfoClass("Offline Vertexer using the HLT ESD:");
223 iResult = PushBack( vertex, kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
230 AliInfoClass( fBenchmark.GetStatistics() );
235 int AliHLTGlobalOfflineVertexerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
237 // reconfigure the component from the specified CDB entry, or default CDB entry
238 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
243 int AliHLTGlobalOfflineVertexerComponent::ReadPreprocessorValues(const char* modules)
245 // read the preprocessor values for the detectors in the modules list
247 TString detectors(modules!=NULL?modules:"");
248 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());