File indexing completed on 2025-01-18 10:10:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef ROOT_TMVA_Event
0032 #define ROOT_TMVA_Event
0033
0034 #include <iosfwd>
0035 #include <vector>
0036
0037 #include "Rtypes.h"
0038 #include "TMVA/Types.h"
0039
0040 #include "TObject.h"
0041
0042
0043 class TCut;
0044
0045 namespace TMVA {
0046
0047 class Event;
0048
0049 std::ostream& operator<<( std::ostream& os, const Event& event );
0050
0051 class Event:public TObject {
0052
0053 friend std::ostream& operator<<( std::ostream& os, const Event& event );
0054
0055 public:
0056
0057
0058 Event();
0059 Event( const Event& );
0060 explicit Event( const std::vector<Float_t>& values,
0061 const std::vector<Float_t>& targetValues,
0062 const std::vector<Float_t>& spectatorValues,
0063 UInt_t theClass = 0, Double_t weight = 1.0, Double_t boostweight = 1.0 );
0064 explicit Event( const std::vector<Float_t>& values,
0065 const std::vector<Float_t>& targetValues,
0066 UInt_t theClass = 0, Double_t weight = 1.0, Double_t boostweight = 1.0 );
0067 explicit Event( const std::vector<Float_t>&,
0068 UInt_t theClass, Double_t weight = 1.0, Double_t boostweight = 1.0 );
0069 explicit Event( const std::vector<Float_t*>*&, UInt_t nvar );
0070
0071 ~Event();
0072
0073
0074
0075
0076
0077 Event& operator=( const Event& ) = default;
0078
0079
0080 Bool_t IsDynamic() const {return fDynamic; }
0081
0082
0083 Double_t GetWeight() const;
0084 Double_t GetOriginalWeight() const { return fWeight; }
0085 Double_t GetBoostWeight() const { return TMath::Max(Double_t(0.0001),fBoostWeight); }
0086 UInt_t GetClass() const { return fClass; }
0087
0088 UInt_t GetNVariables() const;
0089 UInt_t GetNTargets() const;
0090 UInt_t GetNSpectators() const;
0091
0092 Float_t GetValue( UInt_t ivar) const;
0093 Float_t GetValueFast(UInt_t ivar) const { return fDynamic ? *(*fValuesDynamic)[ivar] : fValues[ivar]; }
0094 std::vector<Float_t>& GetValues()
0095 {
0096
0097
0098 return const_cast<std::vector<Float_t>&>( static_cast<const Event&>(*this).GetValues() );
0099 }
0100 const std::vector<Float_t>& GetValues() const;
0101
0102 Float_t GetTarget( UInt_t itgt ) const { return fTargets.at(itgt); }
0103 std::vector<Float_t>& GetTargets() { return fTargets; }
0104 const std::vector<Float_t>& GetTargets() const { return fTargets; }
0105
0106 Float_t GetSpectator( UInt_t ivar) const;
0107 std::vector<Float_t>& GetSpectators() { return fSpectators; }
0108 const std::vector<Float_t>& GetSpectators() const { return fSpectators; }
0109
0110 void SetWeight ( Double_t w ) { fWeight=w; }
0111 void SetBoostWeight ( Double_t w ) const { fDoNotBoost ? fDoNotBoost = kFALSE : fBoostWeight=w; }
0112 void ScaleBoostWeight ( Double_t s ) const { fDoNotBoost ? fDoNotBoost = kFALSE : fBoostWeight *= s; }
0113 void SetClass ( UInt_t t ) { fClass=t; }
0114 void SetVal ( UInt_t ivar, Float_t val );
0115 void SetTarget ( UInt_t itgt, Float_t value );
0116 void SetSpectator ( UInt_t ivar, Float_t value );
0117 void SetVariableArrangement( std::vector<UInt_t>* const m ) const;
0118
0119 void SetSpectatorTypes(const std::vector<char> &types) { fSpectatorTypes = types; }
0120
0121 void SetDoNotBoost () const { fDoNotBoost = kTRUE; }
0122 static void ClearDynamicVariables() {}
0123
0124 void CopyVarValues( const Event& other );
0125 using TObject::Print;
0126 void Print ( std::ostream & o ) const;
0127
0128 static void SetIsTraining(Bool_t);
0129 static void SetIgnoreNegWeightsInTraining(Bool_t);
0130
0131 private:
0132
0133 static Bool_t fgIsTraining;
0134 static Bool_t fgIgnoreNegWeightsInTraining;
0135
0136
0137 mutable std::vector<Float_t> fValues;
0138
0139 mutable std::vector<Float_t> fValuesRearranged;
0140 mutable std::vector<Float_t*> *fValuesDynamic;
0141 std::vector<Float_t> fTargets;
0142 mutable std::vector<Float_t> fSpectators;
0143 mutable std::vector<UInt_t> fVariableArrangement;
0144 std::vector<char> fSpectatorTypes;
0145
0146 UInt_t fClass;
0147 Double_t fWeight;
0148 mutable Double_t fBoostWeight;
0149 Bool_t fDynamic;
0150 mutable Bool_t fDoNotBoost;
0151 public:
0152
0153 ClassDef(Event,1);
0154
0155 };
0156 }
0157
0158 #endif