Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Volume.cxx
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : Volume *
8 * Web : http://tmva.sourceforge.net *
9 * *
10 * Description: *
11 * Implementation (see header file for description) *
12 * *
13 * Authors (alphabetical): *
14 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15 * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
16 * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
17 * *
18 * Copyright (c) 2005: *
19 * CERN, Switzerland *
20 * U. of Victoria, Canada *
21 * MPI-K Heidelberg, Germany *
22 * *
23 * Redistribution and use in source and binary forms, with or without *
24 * modification, are permitted according to the terms listed in LICENSE *
25 * (http://tmva.sourceforge.net/LICENSE) *
26 **********************************************************************************/
27
28/*! \class TMVA::Volume
29\ingroup TMVA
30Volume for BinarySearchTree
31
32volume element: variable space between upper and lower bonds of
33nvar-dimensional variable space
34*/
35
36#include "TMVA/Volume.h"
37
38#include "TMVA/MsgLogger.h"
39#include "TMVA/Tools.h"
40#include "TMVA/Types.h"
41
42#include <stdexcept>
43
44////////////////////////////////////////////////////////////////////////////////
45/// constructor specifying the volume by std::vectors of doubles
46
47TMVA::Volume::Volume( std::vector<Double_t>* l, std::vector<Double_t>* u )
48 : fLower( l ),
49 fUpper( u ),
50 fOwnerShip (kFALSE){
51 }
52
53////////////////////////////////////////////////////////////////////////////////
54/// constructor specifying the volume by std::vectors of floats
55
56TMVA::Volume::Volume( std::vector<Float_t>* l, std::vector<Float_t>* u )
57{
58 fLower = new std::vector<Double_t>( l->size() );
59 fUpper = new std::vector<Double_t>( u->size() );
60 fOwnerShip = kTRUE;
61
62 for (UInt_t ivar=0; ivar<l->size(); ivar++) {
63 (*fLower)[ivar] = Double_t((*l)[ivar]);
64 (*fUpper)[ivar] = Double_t((*u)[ivar]);
65 }
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// constructor specifying the volume by c-style arrays of doubles
70
72{
73 fLower = new std::vector<Double_t>( nvar );
74 fUpper = new std::vector<Double_t>( nvar );
75 fOwnerShip = kTRUE;
76
77 for (int ivar=0; ivar<nvar; ivar++) {
78 (*fLower)[ivar] = l[ivar];
79 (*fUpper)[ivar] = u[ivar];
80 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// constructor specifying the volume by c-style arrays of floats
85
87{
88 fLower = new std::vector<Double_t>( nvar );
89 fUpper = new std::vector<Double_t>( nvar );
90 fOwnerShip = kTRUE;
91
92 for (int ivar=0; ivar<nvar; ivar++) {
93 (*fLower)[ivar] = Double_t(l[ivar]);
94 (*fUpper)[ivar] = Double_t(u[ivar]);
95 }
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// simple constructors for 1 dimensional values (double)
100
102{
103 fLower = new std::vector<Double_t>(1);
104 fUpper = new std::vector<Double_t>(1);
105 fOwnerShip = kTRUE;
106 (*fLower)[0] = l;
107 (*fUpper)[0] = u;
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// simple constructors for 1 dimensional values (float)
112
114{
115 fLower = new std::vector<Double_t>(1);
116 fUpper = new std::vector<Double_t>(1);
117 fOwnerShip = kTRUE;
118 (*fLower)[0] = Double_t(l);
119 (*fUpper)[0] = Double_t(u);
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// copy constructor
124
126{
127 fLower = new std::vector<Double_t>( *V.fLower );
128 fUpper = new std::vector<Double_t>( *V.fUpper );
129 fOwnerShip = kTRUE;
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// assignment operator
134
136{
137 if (fOwnerShip) {
138 if (fLower) delete fLower;
139 if (fUpper) delete fUpper;
140 fLower = new std::vector<Double_t>( *V.fLower );
141 fUpper = new std::vector<Double_t>( *V.fUpper );
142 }
143 else {
144 fLower = V.fLower;
145 fUpper = V.fUpper;
146 }
147 return *this;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// destructor
152
154{
155 // delete volume boundaries only if owned by the volume
156 if (fOwnerShip) this->Delete();
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// delete array of volume bondaries
161
163{
164 if (NULL != fLower) { delete fLower; fLower = NULL; }
165 if (NULL != fUpper) { delete fUpper; fUpper = NULL; }
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// "scale" the volume by multiplying each upper and lower boundary by "f"
170
172{
173 gTools().Scale(*fLower,f);
174 gTools().Scale(*fUpper,f);
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// "scale" the volume by symmetrically blowing up the interval in each dimension
179
181{
182 for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
183 Double_t lo = 0.5*((*fLower)[ivar]*(1.0 + f) + (*fUpper)[ivar]*(1.0 - f));
184 Double_t up = 0.5*((*fLower)[ivar]*(1.0 - f) + (*fUpper)[ivar]*(1.0 + f));
185 (*fLower)[ivar] = lo;
186 (*fUpper)[ivar] = up;
187 }
188}
189
190////////////////////////////////////////////////////////////////////////////////
191/// printout of the volume boundaries
192
193void TMVA::Volume::Print( void ) const
194{
195 MsgLogger fLogger( "Volume" );
196 for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
197 fLogger << kINFO << "... Volume: var: " << ivar << "\t(fLower, fUpper) = ("
198 << (*fLower)[ivar] << "\t " << (*fUpper)[ivar] <<")"<< Endl;
199 }
200}
201
#define f(i)
Definition RSha256.hxx:104
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
ostringstream derivative to redirect and format output
Definition MsgLogger.h:59
void Scale(std::vector< Double_t > &, Double_t)
scales double vector
Definition Tools.cxx:531
Volume for BinarySearchTree.
Definition Volume.h:47
void Print(void) const
printout of the volume boundaries
Definition Volume.cxx:193
void Scale(Double_t f)
"scale" the volume by multiplying each upper and lower boundary by "f"
Definition Volume.cxx:171
Volume & operator=(const Volume &)
assignment operator
Definition Volume.cxx:135
Volume(std::vector< Float_t > *l, std::vector< Float_t > *u=0)
constructor specifying the volume by std::vectors of floats
Definition Volume.cxx:56
void ScaleInterval(Double_t f)
"scale" the volume by symmetrically blowing up the interval in each dimension
Definition Volume.cxx:180
std::vector< Double_t > * fLower
Definition Volume.h:75
void Delete(void)
delete array of volume bondaries
Definition Volume.cxx:162
std::vector< Double_t > * fUpper
Definition Volume.h:76
virtual ~Volume(void)
destructor
Definition Volume.cxx:153
Tools & gTools()
MsgLogger & Endl(MsgLogger &ml)
Definition MsgLogger.h:158
auto * l
Definition textangle.C:4