LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArMvaHelper Class Reference

LArMvaHelper class. More...

#include "LArMvaHelper.h"

Public Types

typedef MvaTypes::MvaFeature MvaFeature
 
typedef MvaTypes::MvaFeatureVector MvaFeatureVector
 
typedef std::map< std::string, double > DoubleMap
 
typedef MvaTypes::MvaFeatureMap MvaFeatureMap
 
typedef std::map< std::string, pandora::AlgorithmTool * > AlgorithmToolMap
 

Static Public Member Functions

template<typename TCONTAINER >
static pandora::StatusCode ProduceTrainingExample (const std::string &trainingOutputFile, const bool result, TCONTAINER &&featureContainer)
 Produce a training example with the given features and result. More...
 
template<typename TCONTAINER >
static pandora::StatusCode ProduceTrainingExample (const std::string &trainingOutputFile, const bool result, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
 Produce a training example with the given features and result - using a map. More...
 
template<typename TCONTAINER >
static bool Classify (const MvaInterface &classifier, TCONTAINER &&featureContainer)
 Use the trained classifier to predict the boolean class of an example. More...
 
template<typename TCONTAINER >
static bool Classify (const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
 Use the trained classifier to predict the boolean class of an example – using a map. More...
 
template<typename TCONTAINER >
static double CalculateClassificationScore (const MvaInterface &classifier, TCONTAINER &&featureContainer)
 Use the trained classifer to calculate the classification score of an example (>0 means boolean class true) More...
 
template<typename TCONTAINER >
static double CalculateProbability (const MvaInterface &classifier, TCONTAINER &&featureContainer)
 Use the trained mva to calculate a classification probability for an example. More...
 
template<typename TCONTAINER >
static double CalculateProbability (const MvaInterface &classifier, const pandora::StringVector &featureOrder, TCONTAINER &&featureContainer)
 Use the trained mva to calculate a classification probability for an example – using a map. More...
 
template<typename... Ts, typename... TARGS>
static MvaFeatureVector CalculateFeatures (const MvaFeatureToolVector< Ts... > &featureToolVector, TARGS &&...args)
 Calculate the features in a given feature tool vector. More...
 
template<typename... Ts, typename... TARGS>
static MvaFeatureMap CalculateFeatures (const pandora::StringVector &featureToolOrder, const MvaFeatureToolMap< Ts... > &featureToolMap, pandora::StringVector &featureOrder, TARGS &&...args)
 Calculate the features in a given feature tool map, and fill an MvaFeatureMap and vector with feature order. More...
 
template<typename T , typename... Ts, typename... TARGS>
static MvaFeatureVector CalculateFeaturesOfType (const MvaFeatureToolVector< Ts... > &featureToolVector, TARGS &&...args)
 Calculate the features of a given derived feature tool type in a feature tool vector. More...
 
template<typename... Ts>
static pandora::StatusCode AddFeatureToolToVector (pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector< Ts... > &featureToolVector)
 Add a feature tool to a vector of feature tools. More...
 
template<typename... Ts>
static pandora::StatusCode AddFeatureToolToMap (pandora::AlgorithmTool *const pFeatureTool, std::string pFeatureToolName, MvaFeatureToolMap< Ts... > &featureToolMap)
 Add a feature tool to a map of feature tools. More...
 
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 in PandoraSDK eventually as an overload to ProcessAlgorithmToolList. More...
 
template<typename TLIST , typename... TLISTS>
static MvaFeatureVector ConcatenateFeatureLists (TLIST &&featureList, TLISTS &&...featureLists)
 Recursively concatenate vectors of features. More...
 
static MvaFeatureVector ConcatenateFeatureLists ()
 Recursively concatenate vectors of features (terminating method) More...
 

Static Private Member Functions

static std::string GetTimestampString ()
 Get a timestamp string for this point in time. More...
 
template<typename TCONTAINER >
static pandora::StatusCode WriteFeaturesToFile (std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
 Write the features of the given lists to file. More...
 
template<typename TCONTAINER >
static pandora::StatusCode WriteFeaturesToFileImpl (std::ofstream &outfile, const std::string &delimiter, TCONTAINER &&featureContainer)
 Write the features of the given list to file (implementation method) More...
 

Detailed Description

LArMvaHelper class.

Definition at line 71 of file LArMvaHelper.h.

Member Typedef Documentation

typedef std::map<std::string, pandora::AlgorithmTool *> lar_content::LArMvaHelper::AlgorithmToolMap

Definition at line 79 of file LArMvaHelper.h.

typedef std::map<std::string, double> lar_content::LArMvaHelper::DoubleMap

Definition at line 76 of file LArMvaHelper.h.

Member Function Documentation

template<typename... Ts>
pandora::StatusCode lar_content::LArMvaHelper::AddFeatureToolToMap ( pandora::AlgorithmTool *const  pFeatureTool,
std::string  pFeatureToolName,
MvaFeatureToolMap< Ts... > &  featureToolMap 
)
static

Add a feature tool to a map of feature tools.

Parameters
pFeatureToolthe feature tool
pFeatureToolNamethe name of the feature tool
featureToolMapthe map to append
Returns
success

Definition at line 465 of file LArMvaHelper.h.

Referenced by lar_content::ElectronInitialRegionRefinementAlgorithm::ReadSettings(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

467 {
468  if (MvaFeatureTool<Ts...> *const pCastFeatureTool = dynamic_cast<MvaFeatureTool<Ts...> *const>(pFeatureTool))
469  {
470  featureToolMap[pFeatureToolName] = pCastFeatureTool;
471  return pandora::STATUS_CODE_SUCCESS;
472  }
473 
474  return pandora::STATUS_CODE_FAILURE;
475 }
template<typename... Ts>
pandora::StatusCode lar_content::LArMvaHelper::AddFeatureToolToVector ( pandora::AlgorithmTool *const  pFeatureTool,
MvaFeatureToolVector< Ts... > &  featureToolVector 
)
static

Add a feature tool to a vector of feature tools.

Parameters
pFeatureToolthe feature tool
featureToolVectorthe vector to append
Returns
success

Definition at line 451 of file LArMvaHelper.h.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::ReadSettings(), and lar_content::TrainedVertexSelectionAlgorithm::ReadSettings().

452 {
453  if (MvaFeatureTool<Ts...> *const pCastFeatureTool = dynamic_cast<MvaFeatureTool<Ts...> *const>(pFeatureTool))
454  {
455  featureToolVector.push_back(pCastFeatureTool);
456  return pandora::STATUS_CODE_SUCCESS;
457  }
458 
459  return pandora::STATUS_CODE_FAILURE;
460 }
template<typename TCONTAINER >
double lar_content::LArMvaHelper::CalculateClassificationScore ( const MvaInterface classifier,
TCONTAINER &&  featureContainer 
)
static

Use the trained classifer to calculate the classification score of an example (>0 means boolean class true)

Parameters
classifierthe classifier
featureContainerthe container of features
Returns
the classification score

Definition at line 361 of file LArMvaHelper.h.

References lar_content::MvaInterface::CalculateClassificationScore().

Referenced by lar_content::BdtBeamParticleIdTool::SliceFeatures::GetAdaBoostDecisionTreeScore().

362 {
363  return classifier.CalculateClassificationScore(featureContainer);
364 }
template<typename... Ts, typename... TARGS>
LArMvaHelper::MvaFeatureVector lar_content::LArMvaHelper::CalculateFeatures ( const MvaFeatureToolVector< Ts... > &  featureToolVector,
TARGS &&...  args 
)
static

Calculate the features in a given feature tool vector.

Parameters
featureToolVectorthe feature tool vector
argsarguments to pass to the tool
Returns
the vector of features

Definition at line 399 of file LArMvaHelper.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm(), and lar_content::ElectronInitialRegionRefinementAlgorithm::RefineShower().

400 {
401  LArMvaHelper::MvaFeatureVector featureVector;
402 
403  for (MvaFeatureTool<Ts...> *const pFeatureTool : featureToolVector)
404  pFeatureTool->Run(featureVector, std::forward<TARGS>(args)...);
405 
406  return featureVector;
407 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
template<typename... Ts, typename... TARGS>
LArMvaHelper::MvaFeatureMap lar_content::LArMvaHelper::CalculateFeatures ( const pandora::StringVector &  featureToolOrder,
const MvaFeatureToolMap< Ts... > &  featureToolMap,
pandora::StringVector &  featureOrder,
TARGS &&...  args 
)
static

Calculate the features in a given feature tool map, and fill an MvaFeatureMap and vector with feature order.

Parameters
featureToolOrdervector of strings of the ordered keys
featureToolMapthe feature tool map
featureOrdera vector that is to be filled with the order of features in the function
argsarguments to pass to the tool
Returns
the map of features

Definition at line 412 of file LArMvaHelper.h.

414 {
415  LArMvaHelper::MvaFeatureMap featureMap;
416 
417  for (auto const &pFeatureToolName : featureToolOrder)
418  {
419  if (featureToolMap.find(pFeatureToolName) == featureToolMap.end())
420  {
421  std::cout << "LArMvaHelper::CalculateFeatures "
422  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
423  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
424  }
425  featureToolMap.at(pFeatureToolName)->Run(featureMap, featureOrder, pFeatureToolName, std::forward<TARGS>(args)...);
426  }
427 
428  return featureMap;
429 }
MvaTypes::MvaFeatureMap MvaFeatureMap
Definition: LArMvaHelper.h:78
template<typename T , typename... Ts, typename... TARGS>
LArMvaHelper::MvaFeatureVector lar_content::LArMvaHelper::CalculateFeaturesOfType ( const MvaFeatureToolVector< Ts... > &  featureToolVector,
TARGS &&...  args 
)
static

Calculate the features of a given derived feature tool type in a feature tool vector.

Parameters
featureToolVectorthe feature tool vector
argsarguments to pass to the tool
Returns
the vector of features

Definition at line 434 of file LArMvaHelper.h.

435 {
436  using TD = typename std::decay<T>::type;
437  LArMvaHelper::MvaFeatureVector featureVector;
438 
439  for (MvaFeatureTool<Ts...> *const pFeatureTool : featureToolVector)
440  {
441  if (TD *const pCastFeatureTool = dynamic_cast<TD *const>(pFeatureTool))
442  pCastFeatureTool->Run(featureVector, std::forward<TARGS>(args)...);
443  }
444 
445  return featureVector;
446 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
template<typename TCONTAINER >
double lar_content::LArMvaHelper::CalculateProbability ( const MvaInterface classifier,
TCONTAINER &&  featureContainer 
)
static

Use the trained mva to calculate a classification probability for an example.

Parameters
classifierthe classifier
featureContainerthe container of features
Returns
the classification probability

Definition at line 369 of file LArMvaHelper.h.

References lar_content::MvaInterface::CalculateProbability().

Referenced by lar_content::NeutrinoIdTool< T >::SliceFeatures::GetNeutrinoProbability(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm().

370 {
371  return classifier.CalculateProbability(featureContainer);
372 }
template<typename TCONTAINER >
double lar_content::LArMvaHelper::CalculateProbability ( const MvaInterface classifier,
const pandora::StringVector &  featureOrder,
TCONTAINER &&  featureContainer 
)
static

Use the trained mva to calculate a classification probability for an example – using a map.

Parameters
classifierthe classifier
featureOrderthe vector of strings corresponding to ordered list of keys
featureContainerthe container of features
Returns
the classification probability

Definition at line 377 of file LArMvaHelper.h.

378 {
379  // Make a feature vector from the map and calculate the features
380  LArMvaHelper::MvaFeatureVector featureVector;
381 
382  for (auto const &pFeatureToolName : featureOrder)
383  {
384  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
385  {
386  std::cout << "LArMvaHelper::CalculateProbability "
387  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
388  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
389  }
390  featureVector.push_back(featureContainer.at(pFeatureToolName));
391  }
392 
393  return CalculateProbability(classifier, featureVector);
394 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
static double CalculateProbability(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained mva to calculate a classification probability for an example.
Definition: LArMvaHelper.h:369
template<typename TCONTAINER >
bool lar_content::LArMvaHelper::Classify ( const MvaInterface classifier,
TCONTAINER &&  featureContainer 
)
static

Use the trained classifier to predict the boolean class of an example.

Parameters
classifierthe classifier
featureContainerthe container of features
Returns
the predicted boolean class of the example

Definition at line 331 of file LArMvaHelper.h.

References lar_content::MvaInterface::Classify().

Referenced by lar_content::MvaVertexSelectionAlgorithm< T >::CompareVertices(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm().

332 {
333  return classifier.Classify(featureContainer);
334 }
template<typename TCONTAINER >
bool lar_content::LArMvaHelper::Classify ( const MvaInterface classifier,
const pandora::StringVector &  featureOrder,
TCONTAINER &&  featureContainer 
)
static

Use the trained classifier to predict the boolean class of an example – using a map.

Parameters
classifierthe classifier
featureOrderthe vector of strings corresponding to ordered list of keys
featureContainerthe container of features
Returns
the predicted boolean class of the example

Definition at line 339 of file LArMvaHelper.h.

340 {
341  // Make a feature vector from the map and calculate the features
342  LArMvaHelper::MvaFeatureVector featureVector;
343 
344  for (auto const &pFeatureToolName : featureOrder)
345  {
346  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
347  {
348  std::cout << "LArMvaHelper::Classify "
349  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
350  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
351  }
352  featureVector.push_back(featureContainer.at(pFeatureToolName));
353  }
354 
355  return Classify(classifier, featureVector);
356 }
static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifier to predict the boolean class of an example.
Definition: LArMvaHelper.h:331
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
template<typename TLIST , typename... TLISTS>
LArMvaHelper::MvaFeatureVector lar_content::LArMvaHelper::ConcatenateFeatureLists ( TLIST &&  featureList,
TLISTS &&...  featureLists 
)
static

Recursively concatenate vectors of features.

Parameters
featureLista list of features
featureListsoptional further lists of features
Returns
the concatenated vector of features

Definition at line 523 of file LArMvaHelper.h.

References value.

524 {
525  static_assert(std::is_same<typename std::decay<TLIST>::type, LArMvaHelper::MvaFeatureVector>::value,
526  "LArMvaHelper: Could not concatenate feature lists because one or more lists was not a vector of MvaFeatures");
527 
528  LArMvaHelper::MvaFeatureVector featureVector;
529 
530  for (const MvaFeature &feature : featureList)
531  featureVector.push_back(feature);
532 
533  LArMvaHelper::MvaFeatureVector newFeatureVector = ConcatenateFeatureLists(std::forward<TLISTS>(featureLists)...);
534  featureVector.insert(featureVector.end(), newFeatureVector.begin(), newFeatureVector.end());
535 
536  return featureVector;
537 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:74
double value
Definition: spectrum.C:18
static MvaFeatureVector ConcatenateFeatureLists()
Recursively concatenate vectors of features (terminating method)
Definition: LArMvaHelper.h:541
LArMvaHelper::MvaFeatureVector lar_content::LArMvaHelper::ConcatenateFeatureLists ( )
inlinestatic

Recursively concatenate vectors of features (terminating method)

Definition at line 541 of file LArMvaHelper.h.

Referenced by lar_content::MvaVertexSelectionAlgorithm< T >::CompareVertices(), and lar_content::TrainedVertexSelectionAlgorithm::ProduceTrainingExamples().

542 {
544 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
std::string lar_content::LArMvaHelper::GetTimestampString ( )
inlinestaticprivate

Get a timestamp string for this point in time.

Returns
a timestamp string

Definition at line 479 of file LArMvaHelper.h.

480 {
481  std::time_t timestampNow = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
482 
483  struct tm *pTimeInfo(NULL);
484  char buffer[80];
485 
486  pTimeInfo = localtime(&timestampNow);
487  strftime(buffer, 80, "%x_%X", pTimeInfo);
488 
489  std::string timeString(buffer);
490 
491  if (!timeString.empty() && timeString.back() == '\n') // last char is always a newline
492  timeString.pop_back();
493 
494  return timeString;
495 }
StatusCode lar_content::LArMvaHelper::ProcessAlgorithmToolListToMap ( const pandora::Algorithm &  algorithm,
const pandora::TiXmlHandle &  xmlHandle,
const std::string &  listName,
pandora::StringVector &  algorithToolNameVector,
AlgorithmToolMap algorithmToolMap 
)
static

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.

Parameters
algorithmthe parent algorithm calling this function
xmlHandlethe relevant xml handle
listNamethe name of the algorithm tool list
algorithmToolMapto receive the vector of addresses of the algorithm tool instances, but also keep the name

Definition at line 16 of file LArMvaHelper.cc.

Referenced by lar_content::ElectronInitialRegionRefinementAlgorithm::ReadSettings(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

18 {
19  // Fill a vector with names in the desired run order as well as the map
20 
21  if ("algorithm" != xmlHandle.ToNode()->ValueStr())
22  return STATUS_CODE_NOT_ALLOWED;
23 
24  const TiXmlHandle algorithmListHandle = TiXmlHandle(xmlHandle.FirstChild(listName).Element());
25 
26  for (TiXmlElement *pXmlElement = algorithmListHandle.FirstChild("tool").Element(); nullptr != pXmlElement;
27  pXmlElement = pXmlElement->NextSiblingElement("tool"))
28  {
29  AlgorithmTool *pAlgorithmTool(nullptr);
30  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateAlgorithmTool(algorithm, pXmlElement, pAlgorithmTool));
31  std::string toolName = pXmlElement->Attribute("type");
32  // If already exists, then make the second have the instance name attached
33  if (algorithmToolMap.find(toolName) != algorithmToolMap.end())
34  toolName += "_" + pAlgorithmTool->GetInstanceName();
35  algorithmToolMap[toolName] = pAlgorithmTool;
36  algorithmToolNameVector.push_back(toolName);
37  }
38 
39  return STATUS_CODE_SUCCESS;
40 }
template<typename TCONTAINER >
pandora::StatusCode lar_content::LArMvaHelper::ProduceTrainingExample ( const std::string &  trainingOutputFile,
const bool  result,
TCONTAINER &&  featureContainer 
)
static

Produce a training example with the given features and result.

Parameters
trainingOutputFilethe file to which to append the example
featureContainerthe container of features
Returns
success

Definition at line 285 of file LArMvaHelper.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm(), lar_content::TrainedVertexSelectionAlgorithm::ProduceTrainingExamples(), lar_content::ElectronInitialRegionRefinementAlgorithm::RefineShower(), lar_content::NeutrinoIdTool< T >::SelectOutputPfos(), and lar_content::BdtBeamParticleIdTool::SelectOutputPfos().

286 {
287  std::ofstream outfile;
288  outfile.open(trainingOutputFile, std::ios_base::app); // always append to the output file
289 
290  if (!outfile.is_open())
291  {
292  std::cout << "LArMvaHelper: could not open file for training examples at " << trainingOutputFile << std::endl;
293  return pandora::STATUS_CODE_FAILURE;
294  }
295 
296  std::string delimiter(",");
297  outfile << GetTimestampString() << delimiter;
298 
299  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, WriteFeaturesToFile(outfile, delimiter, featureContainer));
300  outfile << static_cast<int>(result) << '\n';
301 
302  return pandora::STATUS_CODE_SUCCESS;
303 }
static std::string GetTimestampString()
Get a timestamp string for this point in time.
Definition: LArMvaHelper.h:479
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:500
template<typename TCONTAINER >
pandora::StatusCode lar_content::LArMvaHelper::ProduceTrainingExample ( const std::string &  trainingOutputFile,
const bool  result,
const pandora::StringVector &  featureOrder,
TCONTAINER &&  featureContainer 
)
static

Produce a training example with the given features and result - using a map.

Parameters
trainingOutputFilethe file to which to append the example
featureOrderthe vector of strings corresponding to ordered list of keys
featureContainerthe container of features
Returns
success

Definition at line 308 of file LArMvaHelper.h.

310 {
311  // Make a feature vector from the map and calculate the features
312  LArMvaHelper::MvaFeatureVector featureVector;
313 
314  for (auto const &pFeatureToolName : featureOrder)
315  {
316  if (featureContainer.find(pFeatureToolName) == featureContainer.end())
317  {
318  std::cout << "LArMvaHelper::ProduceTrainingExample "
319  << "- Error: feature tool " << pFeatureToolName << " not found." << std::endl;
320  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
321  }
322  featureVector.push_back(featureContainer.at(pFeatureToolName));
323  }
324 
325  return ProduceTrainingExample(trainingOutputFile, result, featureVector);
326 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
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:285
template<typename TCONTAINER >
pandora::StatusCode lar_content::LArMvaHelper::WriteFeaturesToFile ( std::ofstream &  outfile,
const std::string &  delimiter,
TCONTAINER &&  featureContainer 
)
inlinestaticprivate

Write the features of the given lists to file.

Parameters
outfilethe std::ofstream object to use
delimiterthe delimiter string
featureContainera container of features to write
Returns
success

Definition at line 500 of file LArMvaHelper.h.

References value.

501 {
502  static_assert(std::is_same<typename std::decay<TCONTAINER>::type, LArMvaHelper::MvaFeatureVector>::value,
503  "LArMvaHelper: Could not write training set example because a passed parameter was not a vector of MvaFeatures");
504 
505  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, WriteFeaturesToFileImpl(outfile, delimiter, featureContainer));
506  return pandora::STATUS_CODE_SUCCESS;
507 }
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:512
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
double value
Definition: spectrum.C:18
template<typename TCONTAINER >
pandora::StatusCode lar_content::LArMvaHelper::WriteFeaturesToFileImpl ( std::ofstream &  outfile,
const std::string &  delimiter,
TCONTAINER &&  featureContainer 
)
staticprivate

Write the features of the given list to file (implementation method)

Parameters
outfilethe std::ofstream object to use
delimiterthe delimiter string
featureContainera container of features to write
Returns
success

Definition at line 512 of file LArMvaHelper.h.

513 {
514  for (const MvaFeature &feature : featureContainer)
515  outfile << feature.Get() << delimiter;
516 
517  return pandora::STATUS_CODE_SUCCESS;
518 }
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:74

The documentation for this class was generated from the following files: