Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PDEFoamEventDensity.cxx
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Tancredi Carli, Dominik Dannheim, Alexander Voigt
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Classes: PDEFoamEventDensity *
8 * *
9 * *
10 * Description: *
11 * The TFDSITR class provides an interface between the Binary search tree *
12 * and the PDEFoam object. In order to build-up the foam one needs to *
13 * calculate the density of events at a given point (sampling during *
14 * Foam build-up). The function PDEFoamEventDensity::Density() does *
15 * this job. It *
16 * uses a binary search tree, filled with training events, in order to *
17 * provide this density. *
18 * *
19 * Authors (alphabetical): *
20 * Tancredi Carli - CERN, Switzerland *
21 * Dominik Dannheim - CERN, Switzerland *
22 * S. Jadach - Institute of Nuclear Physics, Cracow, Poland *
23 * Alexander Voigt - TU Dresden, Germany *
24 * Peter Speckmayer - CERN, Switzerland *
25 * *
26 * Copyright (c) 2008, 2010: *
27 * CERN, Switzerland *
28 * MPI-K Heidelberg, Germany *
29 * *
30 * Redistribution and use in source and binary forms, with or without *
31 * modification, are permitted according to the terms listed in LICENSE *
32 * (see tmva/doc/LICENSE) *
33 **********************************************************************************/
34
35/*! \class TMVA::PDEFoamEventDensity
36\ingroup TMVA
37This is a concrete implementation of PDEFoam. Density(...)
38estimates the event (weight) density at a given phase-space point
39using range-searching.
40*/
41
43
46#include "TMVA/MsgLogger.h"
48#include "TMVA/Types.h"
49#include "TMVA/Volume.h"
50
51#include "Rtypes.h"
52
53#include <cmath>
54#include <vector>
55
56
57////////////////////////////////////////////////////////////////////////////////
58
62
63////////////////////////////////////////////////////////////////////////////////
64/// User constructor
65///
66/// Parameters:
67///
68/// - box - size of sampling box
69
74
75////////////////////////////////////////////////////////////////////////////////
76/// Copy constructor
77
82
83////////////////////////////////////////////////////////////////////////////////
84/// This function is needed during the foam buildup. It returns the
85/// event density within the range-searching volume (specified by
86/// fBox).
87///
88/// Parameters:
89///
90/// - xev - event vector (in [fXmin,fXmax]) to place the box at
91///
92/// - event_density - here the event density is stored
93///
94/// Returns:
95///
96/// Number of events (event weights), which were found in the
97/// range-searching volume at point 'xev', divided by the box
98/// volume.
99
101{
102 if (!fBst)
103 Log() << kFATAL << "<PDEFoamEventDensity::Density()> Binary tree not found!" << Endl;
104
105 //create volume around point to be found
106 std::vector<Double_t> lb(GetBox().size());
107 std::vector<Double_t> ub(GetBox().size());
108
109 // probevolume relative to hypercube with edge length 1:
110 const Double_t probevolume_inv = 1.0 / GetBoxVolume();
111
112 // set upper and lower bound for search volume
113 for (UInt_t idim = 0; idim < GetBox().size(); ++idim) {
114 lb[idim] = xev[idim] - GetBox().at(idim) / 2.0;
115 ub[idim] = xev[idim] + GetBox().at(idim) / 2.0;
116 }
117
118 TMVA::Volume volume(&lb, &ub); // volume to search in
119 std::vector<const TMVA::BinarySearchTreeNode*> nodes; // BST nodes found
120
121 // do range searching
122 const Double_t sumOfWeights = fBst->SearchVolume(&volume, &nodes);
123
124 // store density based on total number of events
125 event_density = nodes.size() * probevolume_inv;
126
127 // return: N_total(weighted) / cell_volume
128 return (sumOfWeights + 0.1) * probevolume_inv;
129}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
This is an abstract class, which provides an interface for a PDEFoam density estimator.
This is a concrete implementation of PDEFoam.
Double_t Density(std::vector< Double_t > &Xarg, Double_t &event_density) override
This function is needed during the foam buildup.
Volume for BinarySearchTree.
Definition Volume.h:47
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
MsgLogger & Endl(MsgLogger &ml)
Definition MsgLogger.h:148