3 #ifndef ALIHLTVERTEXFINDERBASE_H
4 #define ALIHLTVERTEXFINDERBASE_H
5 /// This file is property of and copyright by the ALICE HLT Project
6 /// ALICE Experiment at CERN, All rights reserved.
7 /// See cxx source for full Copyright notice
9 /// @file AliHLTVertexFinderBase.h
10 /// @author Timur Pocheptsov
12 /// @brief Base class for vertex finder components
21 #include "AliHLTProcessor.h"
22 #include "AliHLTDataTypes.h"
23 #include "AliKFParticle.h"
26 //Auxiliary base class, used by primary and V0 vertex finders.
27 //It defines a nested type AliHLTTrackInfo and some
28 //functions to read tracks from input blocks -
29 //this is usefull for both vertexers.
30 //This class has to inherit AliHLTProcessor to be able
31 //to call member functions from AliHLTComponent.
32 //This class is not for end user, it's just a
33 //common base for vertex finders.
38 class AliHLTVertexFinderBase : public AliHLTProcessor
53 AliHLTTrackInfo(int id, const AliVTrack& track,
54 int pid, bool primUsed, double dev)
56 fParticle(track, pid),
62 //Check AliKFParticle parameters and covariance matrix.
63 bool IsKFFinite()const;
65 //Track ID taken from input track, just an index in some "collection".
68 AliKFParticle fParticle; //Corresponding to track KFParticle.
69 bool fPrimUsed; //Particle was used for primary vertex fit.
70 double fPrimDeviation; //Primary deviation.
73 //These data types are
74 //used in FillESD functions,
75 //they also used in vertex finders
76 //(v0 finder uses primary finder's block).
77 struct PrimaryFinderBlock
94 //Compiler-generated def ctor will call vector's def
95 //ctor for member, but still, compiler wants mem-init-list.
96 AliHLTVertexFinderBase() : fTrackInfos()
100 //Read tracks from AliESDEvent
102 //IMPORTANT: fTrackInfos is not
103 //cleared here before filling,
104 //tracks are appended to the end.
105 //A user (derived class)
106 //has to clear it, if needed.
107 void ReadESDTracks(int posPID, int negPID);
108 void ReadESDTracks(AliESDEvent* esd, int posPID, int negPID);
109 //Read HLT tracks produced by ITS
110 //or TPC (somewhere else?).
111 //IMPORTANT: fTrackInfos is not
112 //cleared here before filling,
113 //tracks are appended to the end.
114 void ReadHLTTracks(const AliHLTComponentDataType& blockType, int posPID, int negPID);
117 //Produce output for ESD collector from primary and v0 finders' outputs.
118 static void FillESD(AliESDEvent* esd, AliKFVertex* primVtx, const void* primData,
123 typedef std::vector<AliHLTTrackInfo> TrackInfoVector_t;
124 typedef TrackInfoVector_t::size_type VectorSize_t;
126 TrackInfoVector_t fTrackInfos;
128 ClassDef(AliHLTVertexFinderBase, 0);
131 namespace AliHLTUtility
134 //Small utility to automate command line parsing.
135 //Command line consists of commands and parameters.
136 //Currently, parameters can be of type int, double,
137 //bool (so, command with one parameter of built-in type)
138 //or CompoundType (this is for more complex
139 //expressions like -command param1 param2 param3).
140 //If SetParameter failes, it MUST throw std::runtime_error
141 //with description. CmdLineParser will convert this
142 //exception into negative integer and will compose
148 virtual ~CompoundType()
152 virtual unsigned SetParameter(unsigned argc, const char** argv, unsigned currPos) = 0;
155 //Parameter for a command. If the type is CompoundType, it's up to CompoundType
156 //to do all parsing. If it's int, double, bool - checks are done here:
157 //1. Check if parameter was set already (user specified the same command more than
158 // once - this is an error).
159 //2. Check if parameter for command was specified.
160 //3. Parameter has correct value: 0 or 1 for bool and
161 // for int or double non-empty constraint is satisfied
163 //Object of type Parameter holds a pointer to real object of type int, bool, double
164 //(or CompoundType) and this real objects are updated
165 //from command line parameters, using SetParameter function.
180 Parameter(int* i, Constraint c);
181 Parameter(double* d, Constraint c);
182 Parameter(CompoundType* cp);
184 //Returns number of argv elements processed, starting from
186 unsigned SetParameter(unsigned argc, const char** argv, unsigned currPos);
189 //If any constraint was set:
190 void CheckConstraint();
192 void SetConstraintChecker();
194 bool fWasSet; //Parameter was set already.
195 Constraint fConstraint; //Constraint on parameter.
197 bool* fBool; //Real object to set of type bool.
198 int* fInt; //Real object to set of type int.
199 double* fDouble; //Real object to set of type double.
200 CompoundType* fCompound; //"Object" to set of complex type.
202 void (*fConstraintChecker)(const Parameter& param); //Constraint checker.
204 static void CheckPositive(const Parameter& param);
205 static void CheckNonNegative(const Parameter& param);
208 //Compiler generated dtor, copy-ctor and copy-assignment operators are ok.
211 //CmdLineParser parses char** argv, which constains commands and
212 //options for these commands.
213 //Returns the number of processed argv elements.
219 CmdLineParser() : fParameters(), fIgnored(), fError()
223 void Add(const TString& cmd, bool* b);
224 void Add(const TString& cmd, int* i, Parameter::Constraint c = Parameter::none);
225 void Add(const TString& cmd, double* d, Parameter::Constraint c = Parameter::none);
226 void Add(const TString& cmd, CompoundType* ct);
228 //Skip -command nParams * params
229 void IgnoreCommand(const TString& cmd, unsigned nParams);
231 int Parse(unsigned argc, const char** argv, unsigned currPos);
233 const TString& GetError()const
240 typedef std::map<TString, Parameter> ParameterMap_t;
241 typedef ParameterMap_t::iterator MapIter_t;
242 typedef std::map<TString, unsigned> SkipMap_t;
243 typedef SkipMap_t::const_iterator SkipMapIter_t;
245 //Map of commands and it's parameters.
246 ParameterMap_t fParameters;
247 //These commands and its parameters (if any) will be skipped.
250 TString fError; //Error message describing parsing errors.