Logo ROOT   6.14/05
Reference Guide
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
30 Volume for BinarySearchTree
31 
32 volume element: variable space between upper and lower bonds of
33 nvar-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 
47 TMVA::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 
56 TMVA::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 /// destructor
134 
136 {
137  // delete volume boundaries only if owned by the volume
138  if (fOwnerShip) this->Delete();
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// delete array of volume bondaries
143 
145 {
146  if (NULL != fLower) { delete fLower; fLower = NULL; }
147  if (NULL != fUpper) { delete fUpper; fUpper = NULL; }
148 }
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 /// "scale" the volume by multiplying each upper and lower boundary by "f"
152 
154 {
155  gTools().Scale(*fLower,f);
156  gTools().Scale(*fUpper,f);
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// "scale" the volume by symmetrically blowing up the interval in each dimension
161 
163 {
164  for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
165  Double_t lo = 0.5*((*fLower)[ivar]*(1.0 + f) + (*fUpper)[ivar]*(1.0 - f));
166  Double_t up = 0.5*((*fLower)[ivar]*(1.0 - f) + (*fUpper)[ivar]*(1.0 + f));
167  (*fLower)[ivar] = lo;
168  (*fUpper)[ivar] = up;
169  }
170 }
171 
172 ////////////////////////////////////////////////////////////////////////////////
173 /// printout of the volume boundaries
174 
175 void TMVA::Volume::Print( void ) const
176 {
177  MsgLogger fLogger( "Volume" );
178  for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
179  fLogger << kINFO << "... Volume: var: " << ivar << "\t(fLower, fUpper) = ("
180  << (*fLower)[ivar] << "\t " << (*fUpper)[ivar] <<")"<< Endl;
181  }
182 }
183 
std::vector< Double_t > * fLower
Definition: Volume.h:73
void Delete(void)
delete array of volume bondaries
Definition: Volume.cxx:144
void Scale(std::vector< Double_t > &, Double_t)
scales double vector
Definition: Tools.cxx:531
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
float Float_t
Definition: RtypesCore.h:53
std::vector< Double_t > * fUpper
Definition: Volume.h:74
void ScaleInterval(Double_t f)
"scale" the volume by symmetrically blowing up the interval in each dimension
Definition: Volume.cxx:162
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
Volume for BinarySearchTree.
Definition: Volume.h:48
virtual ~Volume(void)
destructor
Definition: Volume.cxx:135
Bool_t fOwnerShip
Definition: Volume.h:78
void Print(void) const
printout of the volume boundaries
Definition: Volume.cxx:175
void Scale(Double_t f)
"scale" the volume by multiplying each upper and lower boundary by "f"
Definition: Volume.cxx:153
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
unsigned int UInt_t
Definition: RtypesCore.h:42
Tools & gTools()
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
auto * l
Definition: textangle.C:4
const Bool_t kTRUE
Definition: RtypesCore.h:87