NTagTMVAVariables

class NTagTMVAVariables

Public Functions

NTagTMVAVariables(Verbosity verbose = pDEFAULT)

Constructor of NTagTMVAVariables.

Calls NTagTMVAVariables::Clear to make rooms for the input variables to use in TMVA classification.

Parameters

verbose – #Verbosity.

void Clear()

Sets all map values to default.

This function also serves as a custom list of variables to put into the TMVA. If you are adding another variable, make sure to put NTagTMVAVariables::PushBack somewhere in NTagEventInfo to save it during the event processing. iVariableMap, fVariableMap, iEventVectorMap, and fEventVectorMap are set to default. (0 for non-vector members, a new vector for vector members.)

std::vector<std::string> Keys()

Returns a vector of all variable names (keys).

void AddVariablesToReader(TMVA::Reader *reader)

Adds all variables declared in NTagTMVAVariables::Clear to a TMVA reader.

Parameters

reader – A TMVA reader to add variables.

void SetBranchAddressToTree(TTree *tree)

Sets branch address of variables to a tree.

Parameters

tree – A tree to set branch address.

void MakeBranchesToTree(TTree *tree)

Make branches of the variables to a tree.

Parameters

tree – A tree to make branches.

void SetVariablesForCaptureCandidate(int iCandidate)

Sets VariableMap[variable] = EventVectorMap[variable][iCandidate].

Parameters

iCandidate – The index of a capture candidate. (0 < iCandidate < NTagEventInfo::nCandidates)

void DumpCurrentVariables()

Dump the keys and values of iVariableMap and and fVariableMap to the output stream.

int GetNumberOfCandidates()

Returns the number of candidates saved in this class.

Returns

The size of a vector (key: “NHits”) held by iEventVectorMap.

template<typename T>
inline void PushBack(std::string key, T value)

Type-independent std::vector.push_back replacement.

Pushes value back to the event vector map. Typename must be specified to determine whether value should be pushed back to iEventVectorMap or fEventVectorMap.

Parameters
  • key – Name of a variable.

  • value – A value to push back.

template<typename T>
inline T Get(std::string key)

Gets the value of a given key.

Parameters

key – Name of a variable.

Returns

The value of key in a variable map. Typename must be specified to determine whether key should be looked up in iVariableMap or fVariableMap.

template<typename T>
inline T Get(std::string key, int iCandidate)

Gets the variable value of a specific capture candidate.

Parameters
  • key – Name of a variable.

  • iCandidate – The index of the capture candidate.

Returns

The iCandidate-th element of the vector of key. Typename must be specified to determine whether key should be taken from iEventVectorMap or fEventVectorMap.

inline std::vector<float> *GetVector(std::string key)

Gets float vector of key.

Parameters

key – Name of a variable.

Returns

The float vector of key from fEventVectorMap.

template<typename T>
inline void Set(std::string key, T var)

Sets the key value of iVariableMap or fVariableMap as var.

Parameters
  • key – Feature variable name.

  • var – Feature variable value.

void FillVectorMap()

Pushes back variables from variable maps to the corresponding vectors in event vector maps.

inline bool IsTMVAVariable(std::string key)

Checks if a key is a input feature variable to TMVA NN.

Parameters

key – Feature variable name.

Returns

true if key is in fVariableMap, otherwise false.

inline void SetCaptureType(int id)

Sets candidate capture type NTagTMVAVariables::captureType.

Parameters

id – Capture type (0: Bkg, 1: H, 2: Gd) of a candidate.

Private Members

IVarMap iVariableMap

A map from a character key to an integer variable.

IVecMap iEventVectorMap

A map from a character key to a vector of integer variables.

FVarMap fVariableMap

A map from a character key to a float variable.

FVecMap fEventVectorMap

A map from a character key to a vector of float variables.

int captureType

This variable is a spectator variable that is input to TMVA.