All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArMvaHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/include/LArHelpers/LArMvaHelper.h
3  *
4  * @brief Header file for the lar mva helper class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_MVA_HELPER_H
9 #define LAR_MVA_HELPER_H 1
10 
12 
13 #include "Api/PandoraContentApi.h"
14 
15 #include "Helpers/XmlHelper.h"
16 
17 #include "Pandora/Algorithm.h"
18 #include "Pandora/AlgorithmTool.h"
19 #include "Pandora/PandoraInternal.h"
20 #include "Pandora/StatusCodes.h"
21 
22 #include <chrono>
23 #include <ctime>
24 #include <fstream>
25 
26 namespace lar_content
27 {
28 
29 /**
30  * @brief MvaFeatureTool class template
31  */
32 template <typename... Ts>
33 class MvaFeatureTool : public pandora::AlgorithmTool
34 {
35 public:
37  typedef std::map<std::string, MvaFeatureTool<Ts...> *> FeatureToolMap;
38 
39  /**
40  * @brief Default constructor.
41  */
42  MvaFeatureTool() = default;
43 
44  /**
45  * @brief Run the algorithm tool
46  *
47  * @param featureVector the vector of features to append
48  * @param args arguments to pass to the tool
49  */
50  virtual void Run(MvaTypes::MvaFeatureVector &featureVector, Ts... args) = 0;
51  virtual void Run(MvaTypes::MvaFeatureMap &featureMap, pandora::StringVector &featureOrder, const std::string &featureToolName, Ts... args)
52  {
53  return;
54  };
55 };
56 
57 template <typename... Ts>
59 
60 template <typename... Ts>
61 using MvaFeatureToolMap = std::map<std::string, MvaFeatureTool<Ts...> *>;
62 
63 //------------------------------------------------------------------------------------------------------------------------------------------
64 
65 /**
66  * @brief LArMvaHelper class
67  */
69 {
70 public:
73  typedef std::map<std::string, double> DoubleMap;
74 
76  typedef std::map<std::string, pandora::AlgorithmTool *> AlgorithmToolMap; // idea would be to put this in PandoraInternal.h at some point in PandoraSDK
77 
78  /**
79  * @brief Produce a training example with the given features and result
80  *
81  * @param trainingOutputFile the file to which to append the example
82  * @param featureContainer the container of features
83  *
84  * @return success
85  */
86  template <typename TCONTAINER>
87  static pandora::StatusCode ProduceTrainingExample(const std::string &trainingOutputFile, const bool result, TCONTAINER &&featureContainer);
88 
89  /**
90  * @brief Produce a training example with the given features and result - using a map
91  *
92  * @param trainingOutputFile the file to which to append the example
93  * @param featureOrder the vector of strings corresponding to ordered list of keys
94  * @param featureContainer the container of features
95  *
96  * @return success
97  */
98  template <typename TCONTAINER>
99  static pandora::StatusCode ProduceTrainingExample(
100  const std::string &trainingOutputFile, const bool result, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer);
101 
102  /**
103  * @brief Use the trained classifier to predict the boolean class of an example
104  *
105  * @param classifier the classifier
106  * @param featureContainer the container of features
107  *
108  * @return the predicted boolean class of the example
109  */
110  template <typename TCONTAINER>
111  static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer);
112 
113  /**
114  * @brief Use the trained classifier to predict the boolean class of an example -- using a map
115  *
116  * @param classifier the classifier
117  * @param featureOrder the vector of strings corresponding to ordered list of keys
118  * @param featureContainer the container of features
119  *
120  * @return the predicted boolean class of the example
121  */
122  template <typename TCONTAINER>
123  static bool Classify(const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer);
124 
125  /**
126  * @brief Use the trained classifer to calculate the classification score of an example (>0 means boolean class true)
127  *
128  * @param classifier the classifier
129  * @param featureContainer the container of features
130  *
131  * @return the classification score
132  */
133  template <typename TCONTAINER>
134  static double CalculateClassificationScore(const MvaInterface &classifier, TCONTAINER &&featureContainer);
135 
136  /**
137  * @brief Use the trained mva to calculate a classification probability for an example
138  *
139  * @param classifier the classifier
140  * @param featureContainer the container of features
141  *
142  * @return the classification probability
143  */
144  template <typename TCONTAINER>
145  static double CalculateProbability(const MvaInterface &classifier, TCONTAINER &&featureContainer);
146 
147  /**
148  * @brief Use the trained mva to calculate a classification probability for an example -- using a map
149  *
150  * @param classifier the classifier
151  * @param featureOrder the vector of strings corresponding to ordered list of keys
152  * @param featureContainer the container of features
153  *
154  * @return the classification probability
155  */
156  template <typename TCONTAINER>
157  static double CalculateProbability(const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer);
158 
159  /**
160  * @brief Calculate the features in a given feature tool vector
161  *
162  * @param featureToolVector the feature tool vector
163  * @param args arguments to pass to the tool
164  *
165  * @return the vector of features
166  */
167  template <typename... Ts, typename... TARGS>
168  static MvaFeatureVector CalculateFeatures(const MvaFeatureToolVector<Ts...> &featureToolVector, TARGS &&... args);
169 
170  /**
171  * @brief Calculate the features in a given feature tool map, and fill an MvaFeatureMap and vector with feature order
172  *
173  * @param featureToolOrder vector of strings of the ordered keys
174  * @param featureToolMap the feature tool map
175  * @param featureOrder a vector that is to be filled with the order of features in the function
176  * @param args arguments to pass to the tool
177  *
178  * @return the map of features
179  */
180  template <typename... Ts, typename... TARGS>
181  static MvaFeatureMap CalculateFeatures(const pandora::StringVector &featureToolOrder, const MvaFeatureToolMap<Ts...> &featureToolMap,
182  pandora::StringVector &featureOrder, TARGS &&... args);
183 
184  /**
185  * @brief Calculate the features of a given derived feature tool type in a feature tool vector
186  *
187  * @param featureToolVector the feature tool vector
188  * @param args arguments to pass to the tool
189  *
190  * @return the vector of features
191  */
192  template <typename T, typename... Ts, typename... TARGS>
193  static MvaFeatureVector CalculateFeaturesOfType(const MvaFeatureToolVector<Ts...> &featureToolVector, TARGS &&... args);
194 
195  /**
196  * @brief Add a feature tool to a vector of feature tools
197  *
198  * @param pFeatureTool the feature tool
199  * @param featureToolVector the vector to append
200  *
201  * @return success
202  */
203  template <typename... Ts>
204  static pandora::StatusCode AddFeatureToolToVector(pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector<Ts...> &featureToolVector);
205 
206  /**
207  * @brief Add a feature tool to a map of feature tools
208  *
209  * @param pFeatureTool the feature tool
210  * @param pFeatureToolName the name of the feature tool
211  * @param featureToolMap the map to append
212  *
213  * @return success
214  */
215  template <typename... Ts>
216  static pandora::StatusCode AddFeatureToolToMap(
217  pandora::AlgorithmTool *const pFeatureTool, std::string pFeatureToolName, MvaFeatureToolMap<Ts...> &featureToolMap);
218 
219  /**
220  * @brief Process a list of algorithms tools in an xml file, using a map. Idea is for this to go to XmlHelper in PandoraSDK eventually as an overload to ProcessAlgorithmToolList
221  *
222  * @param algorithm the parent algorithm calling this function
223  * @param xmlHandle the relevant xml handle
224  * @param listName the name of the algorithm tool list
225  * @param algorithmToolMap to receive the vector of addresses of the algorithm tool instances, but also keep the name
226  */
227  static pandora::StatusCode ProcessAlgorithmToolListToMap(const pandora::Algorithm &algorithm, const pandora::TiXmlHandle &xmlHandle,
228  const std::string &listName, pandora::StringVector &algorithToolNameVector, AlgorithmToolMap &algorithmToolMap);
229 
230  /**
231  * @brief Recursively concatenate vectors of features
232  *
233  * @param featureList a list of features
234  * @param featureLists optional further lists of features
235  *
236  * @return the concatenated vector of features
237  */
238  template <typename TLIST, typename... TLISTS>
239  static MvaFeatureVector ConcatenateFeatureLists(TLIST &&featureList, TLISTS &&... featureLists);
240 
241  /**
242  * @brief Recursively concatenate vectors of features (terminating method)
243  */
245 
246 private:
247  /**
248  * @brief Get a timestamp string for this point in time
249  *
250  * @return a timestamp string
251  */
252  static std::string GetTimestampString();
253 
254  /**
255  * @brief Write the features of the given lists to file
256  *
257  * @param outfile the std::ofstream object to use
258  * @param delimiter the delimiter string
259  * @param featureContainer a container of features to write
260  *
261  * @return success
262  */
263  template <typename TCONTAINER>
264  static pandora::StatusCode WriteFeaturesToFile(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer);
265 
266  /**
267  * @brief Write the features of the given list to file (implementation method)
268  *
269  * @param outfile the std::ofstream object to use
270  * @param delimiter the delimiter string
271  * @param featureContainer a container of features to write
272  *
273  * @return success
274  */
275  template <typename TCONTAINER>
276  static pandora::StatusCode WriteFeaturesToFileImpl(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer);
277 };
278 
279 //------------------------------------------------------------------------------------------------------------------------------------------
280 
281 template <typename TCONTAINER>
282 pandora::StatusCode LArMvaHelper::ProduceTrainingExample(const std::string &trainingOutputFile, const bool result, TCONTAINER &&featureContainer)
283 {
284  std::ofstream outfile;
285  outfile.open(trainingOutputFile, std::ios_base::app); // always append to the output file
286 
287  if (!outfile.is_open())
288  {
289  std::cout << "LArMvaHelper: could not open file for training examples at " << trainingOutputFile << std::endl;
290  return pandora::STATUS_CODE_FAILURE;
291  }
292 
293  std::string delimiter(",");
294  outfile << GetTimestampString() << delimiter;
295 
296  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, WriteFeaturesToFile(outfile, delimiter, featureContainer));
297  outfile << static_cast<int>(result) << '\n';
298 
299  return pandora::STATUS_CODE_SUCCESS;
300 }
301 
302 //------------------------------------------------------------------------------------------------------------------------------------------
303 
304 template <typename TCONTAINER>
306  const std::string &trainingOutputFile, const bool result, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
307 {
308  // Make a feature vector from the map and calculate the features
309  LArMvaHelper::MvaFeatureVector featureVector;
310 
311  for (auto const &pFeatureToolName : featureOrder)
312  {
313  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
314  {
315  std::cout << "LArMvaHelper::ProduceTrainingExample "
316  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
317  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
318  }
319  featureVector.push_back(featureContainer.at(pFeatureToolName));
320  }
321 
322  return ProduceTrainingExample(trainingOutputFile, result, featureVector);
323 }
324 
325 //------------------------------------------------------------------------------------------------------------------------------------------
326 
327 template <typename TCONTAINER>
328 bool LArMvaHelper::Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
329 {
330  return classifier.Classify(featureContainer);
331 }
332 
333 //------------------------------------------------------------------------------------------------------------------------------------------
334 
335 template <typename TCONTAINER>
336 bool LArMvaHelper::Classify(const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
337 {
338  // Make a feature vector from the map and calculate the features
339  LArMvaHelper::MvaFeatureVector featureVector;
340 
341  for (auto const &pFeatureToolName : featureOrder)
342  {
343  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
344  {
345  std::cout << "LArMvaHelper::Classify "
346  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
347  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
348  }
349  featureVector.push_back(featureContainer.at(pFeatureToolName));
350  }
351 
352  return Classify(classifier, featureVector);
353 }
354 
355 //------------------------------------------------------------------------------------------------------------------------------------------
356 
357 template <typename TCONTAINER>
358 double LArMvaHelper::CalculateClassificationScore(const MvaInterface &classifier, TCONTAINER &&featureContainer)
359 {
360  return classifier.CalculateClassificationScore(featureContainer);
361 }
362 
363 //------------------------------------------------------------------------------------------------------------------------------------------
364 
365 template <typename TCONTAINER>
366 double LArMvaHelper::CalculateProbability(const MvaInterface &classifier, TCONTAINER &&featureContainer)
367 {
368  return classifier.CalculateProbability(featureContainer);
369 }
370 
371 //------------------------------------------------------------------------------------------------------------------------------------------
372 
373 template <typename TCONTAINER>
374 double LArMvaHelper::CalculateProbability(const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
375 {
376  // Make a feature vector from the map and calculate the features
377  LArMvaHelper::MvaFeatureVector featureVector;
378 
379  for (auto const &pFeatureToolName : featureOrder)
380  {
381  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
382  {
383  std::cout << "LArMvaHelper::CalculateProbability "
384  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
385  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
386  }
387  featureVector.push_back(featureContainer.at(pFeatureToolName));
388  }
389 
390  return CalculateProbability(classifier, featureVector);
391 }
392 
393 //------------------------------------------------------------------------------------------------------------------------------------------
394 
395 template <typename... Ts, typename... TARGS>
397 {
398  LArMvaHelper::MvaFeatureVector featureVector;
399 
400  for (MvaFeatureTool<Ts...> *const pFeatureTool : featureToolVector)
401  pFeatureTool->Run(featureVector, std::forward<TARGS>(args)...);
402 
403  return featureVector;
404 }
405 
406 //------------------------------------------------------------------------------------------------------------------------------------------
407 
408 template <typename... Ts, typename... TARGS>
409 LArMvaHelper::MvaFeatureMap LArMvaHelper::CalculateFeatures(const pandora::StringVector &featureToolOrder,
410  const MvaFeatureToolMap<Ts...> &featureToolMap, pandora::StringVector &featureOrder, TARGS &&... args)
411 {
412  LArMvaHelper::MvaFeatureMap featureMap;
413 
414  for (auto const &pFeatureToolName : featureToolOrder)
415  {
416  if (featureToolMap.find(pFeatureToolName) == featureToolMap.end())
417  {
418  std::cout << "LArMvaHelper::CalculateFeatures "
419  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
420  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
421  }
422  featureToolMap.at(pFeatureToolName)->Run(featureMap, featureOrder, pFeatureToolName, std::forward<TARGS>(args)...);
423  }
424 
425  return featureMap;
426 }
427 
428 //------------------------------------------------------------------------------------------------------------------------------------------
429 
430 template <typename T, typename... Ts, typename... TARGS>
432 {
433  using TD = typename std::decay<T>::type;
434  LArMvaHelper::MvaFeatureVector featureVector;
435 
436  for (MvaFeatureTool<Ts...> *const pFeatureTool : featureToolVector)
437  {
438  if (TD *const pCastFeatureTool = dynamic_cast<TD *const>(pFeatureTool))
439  pCastFeatureTool->Run(featureVector, std::forward<TARGS>(args)...);
440  }
441 
442  return featureVector;
443 }
444 
445 //------------------------------------------------------------------------------------------------------------------------------------------
446 
447 template <typename... Ts>
448 pandora::StatusCode LArMvaHelper::AddFeatureToolToVector(pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector<Ts...> &featureToolVector)
449 {
450  if (MvaFeatureTool<Ts...> *const pCastFeatureTool = dynamic_cast<MvaFeatureTool<Ts...> *const>(pFeatureTool))
451  {
452  featureToolVector.push_back(pCastFeatureTool);
453  return pandora::STATUS_CODE_SUCCESS;
454  }
455 
456  return pandora::STATUS_CODE_FAILURE;
457 }
458 
459 //------------------------------------------------------------------------------------------------------------------------------------------
460 
461 template <typename... Ts>
463  pandora::AlgorithmTool *const pFeatureTool, std::string pFeatureToolName, MvaFeatureToolMap<Ts...> &featureToolMap)
464 {
465  if (MvaFeatureTool<Ts...> *const pCastFeatureTool = dynamic_cast<MvaFeatureTool<Ts...> *const>(pFeatureTool))
466  {
467  featureToolMap[pFeatureToolName] = pCastFeatureTool;
468  return pandora::STATUS_CODE_SUCCESS;
469  }
470 
471  return pandora::STATUS_CODE_FAILURE;
472 }
473 
474 //------------------------------------------------------------------------------------------------------------------------------------------
475 
477 {
478  std::time_t timestampNow = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
479 
480  struct tm *pTimeInfo(NULL);
481  char buffer[80];
482 
483  pTimeInfo = localtime(&timestampNow);
484  strftime(buffer, 80, "%x_%X", pTimeInfo);
485 
486  std::string timeString(buffer);
487 
488  if (!timeString.empty() && timeString.back() == '\n') // last char is always a newline
489  timeString.pop_back();
490 
491  return timeString;
492 }
493 
494 //------------------------------------------------------------------------------------------------------------------------------------------
495 
496 template <typename TCONTAINER>
497 inline pandora::StatusCode LArMvaHelper::WriteFeaturesToFile(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
498 {
499  static_assert(std::is_same<typename std::decay<TCONTAINER>::type, LArMvaHelper::MvaFeatureVector>::value,
500  "LArMvaHelper: Could not write training set example because a passed parameter was not a vector of MvaFeatures");
501 
502  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, WriteFeaturesToFileImpl(outfile, delimiter, featureContainer));
503  return pandora::STATUS_CODE_SUCCESS;
504 }
505 
506 //------------------------------------------------------------------------------------------------------------------------------------------
507 
508 template <typename TCONTAINER>
509 pandora::StatusCode LArMvaHelper::WriteFeaturesToFileImpl(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
510 {
511  for (const MvaFeature &feature : featureContainer)
512  outfile << feature.Get() << delimiter;
513 
514  return pandora::STATUS_CODE_SUCCESS;
515 }
516 
517 //------------------------------------------------------------------------------------------------------------------------------------------
518 
519 template <typename TLIST, typename... TLISTS>
520 LArMvaHelper::MvaFeatureVector LArMvaHelper::ConcatenateFeatureLists(TLIST &&featureList, TLISTS &&... featureLists)
521 {
522  static_assert(std::is_same<typename std::decay<TLIST>::type, LArMvaHelper::MvaFeatureVector>::value,
523  "LArMvaHelper: Could not concatenate feature lists because one or more lists was not a vector of MvaFeatures");
524 
525  LArMvaHelper::MvaFeatureVector featureVector;
526 
527  for (const MvaFeature &feature : featureList)
528  featureVector.push_back(feature);
529 
530  LArMvaHelper::MvaFeatureVector newFeatureVector = ConcatenateFeatureLists(std::forward<TLISTS>(featureLists)...);
531  featureVector.insert(featureVector.end(), newFeatureVector.begin(), newFeatureVector.end());
532 
533  return featureVector;
534 }
535 
536 //------------------------------------------------------------------------------------------------------------------------------------------
537 
539 {
541 }
542 
543 } // namespace lar_content
544 
545 #endif // #ifndef LAR_MVA_HELPER_H
static pandora::StatusCode WriteFeaturesToFileImpl(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
Write the features of the given list to file (implementation method)
Definition: LArMvaHelper.h:509
static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifier to predict the boolean class of an example.
Definition: LArMvaHelper.h:328
std::map< std::string, pandora::AlgorithmTool * > AlgorithmToolMap
Definition: LArMvaHelper.h:76
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:72
static pandora::StatusCode ProduceTrainingExample(const std::string &trainingOutputFile, const bool result, TCONTAINER &&featureContainer)
Produce a training example with the given features and result.
Definition: LArMvaHelper.h:282
MvaFeatureTool()=default
Default constructor.
virtual void Run(MvaTypes::MvaFeatureVector &featureVector, Ts...args)=0
Run the algorithm tool.
static MvaFeatureVector CalculateFeatures(const MvaFeatureToolVector< Ts...> &featureToolVector, TARGS &&...args)
Calculate the features in a given feature tool vector.
Definition: LArMvaHelper.h:396
virtual bool Classify(const MvaTypes::MvaFeatureVector &features) const =0
Classify the set of input features based on the trained model.
static std::string GetTimestampString()
Get a timestamp string for this point in time.
Definition: LArMvaHelper.h:476
MvaInterface class.
std::vector< MvaFeatureTool< Ts...> * > MvaFeatureToolVector
Definition: LArMvaHelper.h:58
MvaTypes::MvaFeatureMap MvaFeatureMap
Definition: LArMvaHelper.h:75
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:71
std::map< std::string, MvaFeatureTool< Ts...> * > FeatureToolMap
Definition: LArMvaHelper.h:37
static pandora::StatusCode WriteFeaturesToFile(std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
Write the features of the given lists to file.
Definition: LArMvaHelper.h:497
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
InitializedDouble class used to define mva features.
std::map< std::string, double > DoubleMap
Definition: LArMvaHelper.h:73
static pandora::StatusCode AddFeatureToolToVector(pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector< Ts...> &featureToolVector)
Add a feature tool to a vector of feature tools.
Definition: LArMvaHelper.h:448
std::map< std::string, MvaFeature > MvaFeatureMap
std::map< std::string, MvaFeatureTool< Ts...> * > MvaFeatureToolMap
Definition: LArMvaHelper.h:61
LArMvaHelper class.
Definition: LArMvaHelper.h:68
static pandora::StatusCode ProcessAlgorithmToolListToMap(const pandora::Algorithm &algorithm, const pandora::TiXmlHandle &xmlHandle, const std::string &listName, pandora::StringVector &algorithToolNameVector, AlgorithmToolMap &algorithmToolMap)
Process a list of algorithms tools in an xml file, using a map. Idea is for this to go to XmlHelper i...
Definition: LArMvaHelper.cc:16
static pandora::StatusCode AddFeatureToolToMap(pandora::AlgorithmTool *const pFeatureTool, std::string pFeatureToolName, MvaFeatureToolMap< Ts...> &featureToolMap)
Add a feature tool to a map of feature tools.
Definition: LArMvaHelper.h:462
virtual double CalculateProbability(const MvaTypes::MvaFeatureVector &features) const =0
Calculate the classification probability for a set of input features, based on the trained model...
std::vector< MvaFeatureTool< Ts...> * > FeatureToolVector
Definition: LArMvaHelper.h:36
static MvaFeatureVector CalculateFeaturesOfType(const MvaFeatureToolVector< Ts...> &featureToolVector, TARGS &&...args)
Calculate the features of a given derived feature tool type in a feature tool vector.
Definition: LArMvaHelper.h:431
static MvaFeatureVector ConcatenateFeatureLists()
Recursively concatenate vectors of features (terminating method)
Definition: LArMvaHelper.h:538
temporary value
virtual void Run(MvaTypes::MvaFeatureMap &featureMap, pandora::StringVector &featureOrder, const std::string &featureToolName, Ts...args)
Definition: LArMvaHelper.h:51
static double CalculateClassificationScore(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifer to calculate the classification score of an example (&gt;0 means boolean class...
Definition: LArMvaHelper.h:358
static double CalculateProbability(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained mva to calculate a classification probability for an example.
Definition: LArMvaHelper.h:366
MvaFeatureTool class template.
Definition: LArMvaHelper.h:33
virtual double CalculateClassificationScore(const MvaTypes::MvaFeatureVector &features) const =0
Calculate the classification score for a set of input features, based on the trained model...
std::vector< MvaFeature > MvaFeatureVector
BEGIN_PROLOG could also be cout
Header file for the lar multivariate analysis interface class.