64 fHasNegativeEventWeights(
kFALSE),
81 for (
Int_t treeIdx = 0; treeIdx < treeNum; treeIdx++) {
113 for (
Int_t treeIdx = 0; treeIdx < treeNum; treeIdx++) {
132 for (std::vector< std::map< TString, Results* > >::iterator it =
fResults.begin(); it !=
fResults.end(); it++) {
133 for (std::map< TString, Results* >::iterator itMap = (*it).begin(); itMap != (*it).end(); itMap++) {
134 delete itMap->second;
173 catch (std::out_of_range excpt) {
175 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"No " << (type==0?
"training":(type==1?
"testing":
"_unknown_type_"))
176 <<
" events for class " << (ci==
NULL?
"_no_name_known_":ci->
GetName()) <<
" (index # "<<classNumber<<
")" 177 <<
" available. Check if all class names are spelled correctly and if events are" 178 <<
" passing the selection cuts." <<
Endl;
181 Log() << kFATAL <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"ERROR/CAUGHT : DataSet/GetNClassEvents, .. unknown error" <<
Endl;
271 const std::map< TString, Results* >& resultsForType =
fResults[t];
272 std::map< TString, Results* >::const_iterator it = resultsForType.find(resultsName);
273 if (it!=resultsForType.end()) {
285 switch(analysistype) {
305 fResults[t][resultsName] = newresults;
323 Log()<<kFATAL<<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"you asked for an Treetype (training/testing/...)" 324 <<
" whose index " << type <<
" does not exist " <<
Endl;
326 std::map< TString, Results* >& resultsForType =
fResults[
UInt_t(type)];
327 std::map< TString, Results* >::iterator it = resultsForType.find(resultsName);
328 if (it!=resultsForType.end()) {
329 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
" Delete Results previous existing result:" << resultsName
330 <<
" of type " << type <<
Endl;
332 resultsForType.erase(it->first);
335 Log() << kINFO <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"could not fine Result class of " << resultsName
336 <<
" of type " << type <<
" which I should have deleted" <<
Endl;
436 std::vector< std::pair< Float_t, Long64_t >* > evtList;
437 std::vector< std::pair< Float_t, Long64_t >* >::iterator it;
451 if (fraction > 0.999999 || fraction < 0.0000001) {
467 for (
Long64_t ievt=0; ievt<nEvts; ievt++) {
468 std::pair<Float_t,Long64_t> p(1.0,ievt);
488 <<
"no random generator present for creating a random/importance sampling (initialized?)" <<
Endl;
494 std::vector< std::pair< Float_t, Long64_t > > evtList;
495 std::vector< std::pair< Float_t, Long64_t > >::iterator evtListIt;
504 for (evtListIt = evtList.begin(); evtListIt != evtList.end(); evtListIt++) {
505 sumWeights += (*evtListIt).first;
507 evtListIt = evtList.begin();
510 std::vector< Float_t > rnds;
516 rnds.push_back( pos );
520 std::sort(rnds.begin(),rnds.end());
523 std::vector< Float_t >::iterator rndsIt = rnds.begin();
524 Float_t runningSum = 0.000000001;
525 for (evtListIt = evtList.begin(); evtListIt != evtList.end();) {
526 runningSum += (*evtListIt).first;
527 if (runningSum >= (*rndsIt)) {
529 evtListIt = evtList.erase( evtListIt );
532 if (rndsIt == rnds.end() )
break;
552 if (evtNumber >= 0) {
556 for (
Long64_t iEvt = start; iEvt <= stop; iEvt++ ){
558 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"event number (" << iEvt
559 <<
") larger than number of sampled events (" 567 if (weight > 1.0 ) weight = 1.0;
619 tree->
Branch(
"classID", &cls,
"classID/I" );
620 tree->
Branch(
"className", className,
"className/C" );
628 tree->
Branch( (*itVars).GetInternalName(), &varVals[
n], (*itVars).GetInternalName()+
TString(
"/F") );
633 for (std::vector<VariableInfo>::const_iterator itTgts =
fdsi->
GetTargetInfos().begin();
636 tree->
Branch( (*itTgts).GetInternalName(), &tgtVals[
n], (*itTgts).GetInternalName()+
TString(
"/F") );
644 tree->
Branch( (*itVis).GetInternalName(), &visVals[
n], (*itVis).GetInternalName()+
TString(
"/F") );
648 tree->
Branch(
"weight", &weight,
"weight/F" );
652 for (std::map< TString, Results* >::iterator itMethod =
fResults.at(t).begin();
653 itMethod !=
fResults.at(t).end(); itMethod++) {
661 tree->
Branch( itMethod->first, &(metVals[n][0]), itMethod->first +
"/F" );
667 if (iCls > 0) leafList.
Append(
":" );
671 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"itMethod->first " << itMethod->first <<
" LEAFLIST: " 672 << leafList <<
" itMethod->second " << itMethod->second << Endl;
673 tree->
Branch( itMethod->first, (metVals[n]), leafList );
679 if (iTgt > 0) leafList.
Append(
":" );
684 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"itMethod->first " << itMethod->first <<
" LEAFLIST: " 685 << leafList <<
" itMethod->second " << itMethod->second << Endl;
686 tree->
Branch( itMethod->first, (metVals[n]), leafList );
689 Log() << kWARNING <<
Form(
"Dataset[%s] : ",
fdsi->
GetName()) <<
"Unknown analysis type for result found when writing TestTree." << Endl;
712 for (std::map<TString, Results*>::iterator itMethod =
fResults.at(t).begin();
713 itMethod !=
fResults.at(t).end(); itMethod++) {
714 Results* results = itMethod->second;
716 const std::vector< Float_t >& vals = results->operator[](iEvt);
720 metVals[
n][0] = vals[0];
726 metVals[
n][nCls] = val;
733 metVals[
n][nTgts] = val;
743 <<
"Created tree '" << tree->
GetName() <<
"' with " << tree->
GetEntries() <<
" events" << Endl <<
Endl;
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
UInt_t GetNVariables() const
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)
Class that is the base-class for a vector of result.
Long64_t fTrainingBlockSize
std::vector< std::vector< std::pair< Float_t, Long64_t > > > fSamplingSelected
const TString & GetInternalName() const
void AddEvent(Event *, Types::ETreeType)
add event to event list after which the event is owned by the dataset
std::vector< VariableInfo > & GetSpectatorInfos()
virtual Double_t Rndm()
Machine independent random number generator.
std::vector< std::vector< std::pair< Float_t, Long64_t > > > fSamplingEventList
std::vector< std::vector< Event * > > fEventCollection
void CreateSampling() const
create an event sampling (random or importance sampling)
virtual Int_t Fill()
Fill all branches.
TRandom3 * fSamplingRandom
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
void SetTreeType(Types::ETreeType type)
std::vector< Char_t > fBlockBelongToTraining
void ClearNClassEvents(Int_t type)
UInt_t GetNClasses() const
Long64_t GetNEvtBkgdTrain()
return number of background training events in dataset
Class that contains all the information of a class.
UInt_t TreeIndex(Types::ETreeType type) const
UInt_t GetNSpectators() const
access the number of targets through the datasetinfo
The TNamed class is the base class for all named ROOT classes.
virtual ~DataSet()
destructor
TTree * GetTree(Types::ETreeType type)
create the test/trainings tree with all the variables, the weights, the classes, the targets...
Types::ETreeType GetCurrentType() const
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
Class that contains all the data information.
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
std::vector< VariableInfo > & GetTargetInfos()
Bool_t fHasNegativeEventWeights
UInt_t GetNTargets() const
accessor to the number of targets
void MoveTrainingBlock(Int_t blockInd, Types::ETreeType dest, Bool_t applyChanges=kTRUE)
move training block
void ApplyTrainingSetDivision()
apply division of data set
Float_t GetTarget(UInt_t itgt) const
UInt_t GetNTargets() const
Results * GetResults(const TString &, Types::ETreeType type, Types::EAnalysisType analysistype)
std::vector< std::vector< Long64_t > > fClassEvents
Long64_t GetNEvtSigTest()
return number of signal test events in dataset
ClassInfo * GetClassInfo(Int_t clNum) const
VariableInfo & GetTargetInfo(Int_t i)
void DeleteResults(const TString &, Types::ETreeType type, Types::EAnalysisType analysistype)
delete the results stored for this particular Method instance.
UInt_t GetNSpectators() const
accessor to the number of spectators
char * Form(const char *fmt,...)
void DivideTrainingSet(UInt_t blockNum)
divide training set
void DestroyCollection(Types::ETreeType type, Bool_t deleteEvents)
destroys the event collection (events + vector)
UInt_t GetNSpectators(bool all=kTRUE) const
Long64_t GetNEvtBkgdTest()
return number of background test events in dataset
UInt_t GetNVariables() const
accessor to the number of variables
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
void IncrementNClassEvents(Int_t type, UInt_t classNumber)
std::vector< Char_t > fSampling
void EventResult(Bool_t successful, Long64_t evtNumber=-1)
increase the importance sampling weight of the event when not successful and decrease it when success...
std::vector< Float_t > fSamplingWeight
Long64_t fCurrentEventIdx
UInt_t fCurrentTreeIdx
[train/test/...][method-identifier]
Long64_t GetNEvtSigTrain()
return number of signal training events in dataset
MsgLogger & Log() const
message logger
Class which takes the results of a multiclass classification.
void SetCurrentType(Types::ETreeType type) const
void SetEventCollection(std::vector< Event *> *, Types::ETreeType, Bool_t deleteEvents=true)
Sets the event collection (by DataSetFactory)
std::vector< Int_t > fSamplingNEvents
virtual const char * GetName() const
Returns name of object.
virtual Long64_t GetEntries() const
Long64_t GetNClassEvents(Int_t type, UInt_t classNumber)
ostringstream derivative to redirect and format output
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
#define dest(otri, vertexptr)
Class that is the base-class for a vector of result.
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
A TTree object has a header with a name and a title.
UInt_t GetNTargets() const
access the number of targets through the datasetinfo
Float_t GetSpectator(UInt_t ivar) const
return spectator content
void InitSampling(Float_t fraction, Float_t weight, UInt_t seed=0)
initialize random or importance sampling
const Event * GetEvent() const
std::vector< VariableInfo > & GetVariableInfos()
Class that is the base-class for a vector of result.
std::vector< std::map< TString, Results *> > fResults