PandaRoot
PndPidMvaAssociatorTask.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* ************************************
14  * Author: M. Babai (M.Babai@rug.nl) *
15  * *
16  * pid classifier *
17  * *
18  * Created: 23-03-2010 *
19  * Modified: *
20  * *
21  * ************************************/
22 //#pragma once
23 #ifndef PID_MVA_ASSOCIATOR_H
24 #define PID_MVA_ASSOCIATOR_H
25 
26 // Standard C++ includes
27 #include <string>
28 #include <vector>
29 
30 // Root includes.
31 class TClonesArray;
32 
33 // PANDA and Fair includes.
34 #include "FairTask.h"
35 class FairRootManager;
36 class PndPidCandidate;
37 class PndPidProbability;
38 
39 // MVA headers
40 class PndMvaClassifier;
41 
42 // ========================================================================
44 typedef enum {
46  KNN = 1, // KNN methode
47  LVQ = 2, // LVQ
48  TMVA_MLP = 3, // Multi label TMVA ANN.
49  TMVA_BDT = 4 // Multi label TMVA BDT.
51 
52 // ========================================================================
53 class PndPidMvaAssociatorTask : public FairTask {
54  public:
59 
63  PndPidMvaAssociatorTask(char const *name);
64 
68  virtual ~PndPidMvaAssociatorTask();
69 
73  virtual void Exec(Option_t *option);
74 
78  virtual InitStatus Init();
79 
80  void Register();
81 
82  void Reset();
83 
84  inline void SetVerbose(Bool_t verb);
85 
89  virtual void SetParContainers();
90 
91  virtual void Finish();
92 
96  inline virtual void SetVarNames(std::vector<std::string> const &vNames);
97 
101  inline void SetClassNames(std::vector<std::string> const &clNames);
102 
107  inline void SetWeightFileName(std::string const &wFileName);
108 
113  inline void SetClassifier(Mva_MethodType const &methodT);
114 
119  void SetClassifier(std::string const &methodName);
120 
121  //______________ KNN- Classifier parameter _____________
125  inline void SetNumNeigh(size_t val);
126 
132  inline void SetKnnEventParams(float scFact, double weight);
133 
134  //=============== Private members.
135  private:
136  // Copy const.
138  // Assignment operator.
139  PndPidMvaAssociatorTask &operator=(PndPidMvaAssociatorTask const &other);
140 
146  void DoPidMatch(PndPidCandidate &pidcand, PndPidProbability &prob);
147 
148  std::vector<float> const *PrepareEvtVect(PndPidCandidate const &pidcand) const;
149 
150  FairRootManager *fManager;
151 
152  // Classifiers variables and functions
153  /* Set the default path where the weights are stored. */
154  void SetDefaultWeightsPath();
155 
157  std::vector<std::string> fVarNames;
158 
160  std::vector<std::string> fClassNames;
161 
163  std::string fWeightsFileName;
164 
166  size_t fNumNeigh;
167  float fScFact;
168  double fWeight;
169 
171  PndMvaClassifier *fClassifier;
172 
174  Mva_MethodType fMethodType;
175 
176  TClonesArray *fPidChargedCand;
177  TClonesArray *fPidChargedProb;
178  TClonesArray *fMCTrack;
179  // TClonesArray* fPidNeutralCand; //! PndPidCandidate TCA for neutral particles
180  // TClonesArray* fPidNeutralProb; //! PndPidProbability TCA for neutral particles
181  std::string fMethodName;
182 
183  ClassDef(PndPidMvaAssociatorTask, 0);
184 };
185 
186 inline void PndPidMvaAssociatorTask::SetVerbose(Bool_t verb)
187 {
188  fVerbose = verb;
189 };
190 
191 inline void PndPidMvaAssociatorTask::SetVarNames(std::vector<std::string> const &vNames)
192 {
193  fVarNames = vNames;
194 };
195 
196 inline void PndPidMvaAssociatorTask::SetClassNames(std::vector<std::string> const &clNames)
197 {
198  fClassNames = clNames;
199 };
200 
201 inline void PndPidMvaAssociatorTask::SetWeightFileName(std::string const &wFileName)
202 {
203  fWeightsFileName = wFileName;
204 };
205 
207 {
208  fNumNeigh = val;
209 };
210 
212 {
213  fMethodType = methodT;
214 };
215 
216 inline void PndPidMvaAssociatorTask::SetKnnEventParams(float scFact, double weight)
217 {
218  fScFact = scFact;
219  fWeight = weight;
220 };
221 #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)