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
25 #include "AliHLTGlobalOfflineVertexerComponent.h"
26 #include "AliESDEvent.h"
27 #include "AliESDtrack.h"
28 #include "AliVertexerTracks.h"
29 #include "AliESDVertex.h"
30 #include "AliGRPRecoParam.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTGlobalOfflineVertexerComponent)
39 AliHLTGlobalOfflineVertexerComponent::AliHLTGlobalOfflineVertexerComponent()
42 , fBenchmark("GlobalOfflineVertexer")
44 // The component subscribes to the HLT ESD and calculates the vertex
45 // using the offline vertexer.
47 // see header file for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 // NOTE: all helper classes should be instantiated in DoInit()
56 AliHLTGlobalOfflineVertexerComponent::~AliHLTGlobalOfflineVertexerComponent()
60 // NOTE: implement proper cleanup in DoDeinit()
63 const char* AliHLTGlobalOfflineVertexerComponent::GetComponentID()
65 // component property: id
66 return "GlobalOfflineVertexer";
69 void AliHLTGlobalOfflineVertexerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
71 // component property: list of input data types
72 list.push_back(kAliHLTDataTypeESDObject);
75 AliHLTComponentDataType AliHLTGlobalOfflineVertexerComponent::GetOutputDataType()
77 // component property: output data type
78 return kAliHLTAnyDataType;
81 void AliHLTGlobalOfflineVertexerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
83 // component property: output size estimator
85 inputMultiplier = 1.0;
88 void AliHLTGlobalOfflineVertexerComponent::GetOCDBObjectDescription( TMap* const targetMap)
90 // Get a list of OCDB object description.
91 // The list of objects is provided in a TMap
92 // - key: complete OCDB path, e.g. GRP/GRP/Data
93 // - value: short description why the object is needed
94 // Key and value objects created inside this class go into ownership of
96 if (!targetMap) return;
97 // targetMap->Add(new TObjString("HLT/ConfigHLT/GlobalOfflineVertexer"),
98 // new TObjString("configuration object"));
99 targetMap->Add(new TObjString("GRP/GRP/Data"),
100 new TObjString("GRP object"));
103 AliHLTComponent* AliHLTGlobalOfflineVertexerComponent::Spawn()
105 // Spawn function, return new class instance
106 return new AliHLTGlobalOfflineVertexerComponent;
109 int AliHLTGlobalOfflineVertexerComponent::DoInit( int argc, const char** argv )
111 // see header file for class documentation
114 // init stage 1: default values for all data members
116 // init stage 2: read configuration object
117 // ScanConfigurationArgument() needs to be implemented
118 TString cdbPath="HLT/ConfigHLT/";
119 cdbPath+=GetComponentID();
121 // TODO: activate later when the object has been copied to the
123 //iResult=ConfigureFromCDBTObjString(cdbPath);
125 // init stage 3: read the component arguments
127 iResult=ConfigureFromArgumentString(argc, argv);
131 // implement the component initialization
132 fVertexer=new AliVertexerTracks;
134 fVertexer->SetFieldkG(GetBz());
136 // initialize for TPC + ITS primary vertex
137 fVertexer->SetITSMode();
138 fVertexer->SetConstraintOff();
139 // get cuts for vertexer from AliGRPRecoParam
140 AliGRPRecoParam *grpRecoParam=NULL;
141 TObject* obj=LoadAndExtractOCDBObject("GRP/Calib/RecoParam");
142 if (obj) grpRecoParam=dynamic_cast<AliGRPRecoParam*>(obj);
144 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
145 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
146 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer,nCutsVertexer);
147 fVertexer->SetCuts(cutsVertexer,nCutsVertexer);
148 delete [] cutsVertexer; cutsVertexer = NULL;
150 // to run on HLT events we do not require ITS refit
151 fVertexer->SetITSrefitNotRequired();
159 fBenchmark.SetTimer(0,"total");
164 int AliHLTGlobalOfflineVertexerComponent::ScanConfigurationArgument(int /*argc*/, const char** /*argv*/)
166 // Scan configuration arguments
167 // Return the number of processed arguments
168 // -EPROTO if argument format error (e.g. number expected but not found)
170 // The AliHLTComponent base class implements a parsing loop for argument strings and
171 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
172 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
177 int AliHLTGlobalOfflineVertexerComponent::DoDeinit()
179 // component cleanup, delete all instances of helper classes here
180 if (fVertexer) delete fVertexer;
186 int AliHLTGlobalOfflineVertexerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
187 AliHLTComponentTriggerData& /*trigData*/)
189 // event processing function
192 // check if this is a data event, there are a couple of special events
193 // which should be ignored for normal processing
194 if (!fVertexer) return -ENODEV;
195 if (!IsDataEvent()) return 0;
197 fBenchmark.StartNewEvent();
200 for (const TObject* obj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent");
201 obj; obj = GetNextInputObject()) {
203 // input objects are not supposed to be changed by the component, so they
204 // are defined const. However, the implementation of AliESDEvent does not
205 // support this and we need the const_cast
206 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
208 esd->GetStdContent();
209 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
210 AliESDtrack* track = esd->GetTrack(i);
211 // TODO: this is just a quick hack, the vertexer requires kITSrefit and
213 // the HLT reconstruction needs to be adapted according to that requirement
214 // we have to check which flag needs to be set at what stage
215 track->SetStatus(AliESDtrack::kITSrefit);
217 AliESDVertex* vertex=fVertexer->FindPrimaryVertex(esd);
219 AliInfoClass("Offline Vertexer using the HLT ESD:");
221 iResult = PushBack( vertex, kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
228 AliInfoClass( fBenchmark.GetStatistics() );
233 int AliHLTGlobalOfflineVertexerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
235 // reconfigure the component from the specified CDB entry, or default CDB entry
236 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
241 int AliHLTGlobalOfflineVertexerComponent::ReadPreprocessorValues(const char* modules)
243 // read the preprocessor values for the detectors in the modules list
245 TString detectors(modules!=NULL?modules:"");
246 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());