PandaRoot
PndPidMvaAssociatorTask.h
Go to the documentation of this file.
1 /* ************************************
2  * Author: M. Babai (M.Babai@rug.nl) *
3  * *
4  * pid classifier *
5  * *
6  * Created: 23-03-2010 *
7  * Modified: *
8  * *
9  * ************************************/
10 //#pragma once
11 #ifndef PID_MVA_ASSOCIATOR_H
12 #define PID_MVA_ASSOCIATOR_H
13 
14 // Standard C++ includes
15 #include <string>
16 #include <vector>
17 
18 // Root includes.
19 class TClonesArray;
20 
21 // PANDA and Fair includes.
22 #include "FairTask.h"
23 class FairRootManager;
24 class PndPidCandidate;
25 class PndPidProbability;
26 
27 // MVA headers
28 class PndMvaClassifier;
29 
30 // ========================================================================
32 typedef enum {
34  KNN = 1, // KNN methode
35  LVQ = 2, // LVQ
36  TMVA_MLP = 3, // Multi label TMVA ANN.
37  TMVA_BDT = 4 // Multi label TMVA BDT.
39 
40 // ========================================================================
41 class PndPidMvaAssociatorTask : public FairTask {
42  public:
47 
51  PndPidMvaAssociatorTask(char const *name);
52 
56  virtual ~PndPidMvaAssociatorTask();
57 
61  virtual void Exec(Option_t *option);
62 
66  virtual InitStatus Init();
67 
68  void Register();
69 
70  void Reset();
71 
72  inline void SetVerbose(Bool_t verb);
73 
77  virtual void SetParContainers();
78 
79  virtual void Finish();
80 
84  inline virtual void SetVarNames(std::vector<std::string> const &vNames);
85 
89  inline void SetClassNames(std::vector<std::string> const &clNames);
90 
95  inline void SetWeightFileName(std::string const &wFileName);
96 
101  inline void SetClassifier(Mva_MethodType const &methodT);
102 
107  void SetClassifier(std::string const &methodName);
108 
109  //______________ KNN- Classifier parameter _____________
113  inline void SetNumNeigh(size_t val);
114 
120  inline void SetKnnEventParams(float scFact, double weight);
121 
122  //=============== Private members.
123  private:
124  // Copy const.
126  // Assignment operator.
127  PndPidMvaAssociatorTask &operator=(PndPidMvaAssociatorTask const &other);
128 
134  void DoPidMatch(PndPidCandidate &pidcand, PndPidProbability &prob);
135 
136  std::vector<float> const *PrepareEvtVect(PndPidCandidate const &pidcand) const;
137 
138  FairRootManager *fManager;
139 
140  // Classifiers variables and functions
141  /* Set the default path where the weights are stored. */
142  void SetDefaultWeightsPath();
143 
145  std::vector<std::string> fVarNames;
146 
148  std::vector<std::string> fClassNames;
149 
151  std::string fWeightsFileName;
152 
154  size_t fNumNeigh;
155  float fScFact;
156  double fWeight;
157 
159  PndMvaClassifier *fClassifier;
160 
162  Mva_MethodType fMethodType;
163 
164  TClonesArray *fPidChargedCand;
165  TClonesArray *fPidChargedProb;
166  TClonesArray *fMCTrack;
167  // TClonesArray* fPidNeutralCand; //! PndPidCandidate TCA for neutral particles
168  // TClonesArray* fPidNeutralProb; //! PndPidProbability TCA for neutral particles
169  std::string fMethodName;
170 
171  ClassDef(PndPidMvaAssociatorTask, 0);
172 };
173 
174 inline void PndPidMvaAssociatorTask::SetVerbose(Bool_t verb)
175 {
176  fVerbose = verb;
177 };
178 
179 inline void PndPidMvaAssociatorTask::SetVarNames(std::vector<std::string> const &vNames)
180 {
181  fVarNames = vNames;
182 };
183 
184 inline void PndPidMvaAssociatorTask::SetClassNames(std::vector<std::string> const &clNames)
185 {
186  fClassNames = clNames;
187 };
188 
189 inline void PndPidMvaAssociatorTask::SetWeightFileName(std::string const &wFileName)
190 {
191  fWeightsFileName = wFileName;
192 };
193 
195 {
196  fNumNeigh = val;
197 };
198 
200 {
201  fMethodType = methodT;
202 };
203 
204 inline void PndPidMvaAssociatorTask::SetKnnEventParams(float scFact, double weight)
205 {
206  fScFact = scFact;
207  fWeight = weight;
208 };
209 #endif // End of interface definition (PndPidMvaAssociatorTask)
virtual ~PndPidMvaAssociatorTask()
virtual void SetParContainers()
Mva_MethodType
Method types for selecting which classifier to use.
void SetKnnEventParams(float scFact, double weight)
virtual void Finish()
virtual InitStatus Init()
virtual void Exec(Option_t *option)
void SetWeightFileName(std::string const &wFileName)
void SetClassifier(Mva_MethodType const &methodT)
void SetClassNames(std::vector< std::string > const &clNames)
virtual void SetVarNames(std::vector< std::string > const &vNames)