ROOT  6.06/09
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 #include <stdexcept>
29 
30 #include "TMVA/Volume.h"
31 #include "TMVA/Tools.h"
32 
33 #ifndef ROOT_TMVA_MsgLogger
34 #include "TMVA/MsgLogger.h"
35 #endif
36 
37 //_______________________________________________________________________
38 //
39 // Volume //
40 // //
41 // Volume for BinarySearchTree //
42 // //
43 // volume element: variable space beteen upper and lower bonds of //
44 // nvar-dimensional variable space //
45 //_______________________________________________________________________
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  // constructor specifying the volume by std::vectors of doubles
52 }
53 
54 TMVA::Volume::Volume( std::vector<Float_t>* l, std::vector<Float_t>* u )
55 {
56  // constructor specifying the volume by std::vectors of floats
57  fLower = new std::vector<Double_t>( l->size() );
58  fUpper = new std::vector<Double_t>( u->size() );
59  fOwnerShip = kTRUE;
60 
61  for (UInt_t ivar=0; ivar<l->size(); ivar++) {
62  (*fLower)[ivar] = Double_t((*l)[ivar]);
63  (*fUpper)[ivar] = Double_t((*u)[ivar]);
64  }
65 }
66 
68 {
69  // constructor specifiying the volume by c-style arrays of doubles
70  fLower = new std::vector<Double_t>( nvar );
71  fUpper = new std::vector<Double_t>( nvar );
72  fOwnerShip = kTRUE;
73 
74  for (int ivar=0; ivar<nvar; ivar++) {
75  (*fLower)[ivar] = l[ivar];
76  (*fUpper)[ivar] = u[ivar];
77  }
78 }
79 
81 {
82  // constructor specifiying the volume by c-style arrays of floats
83  fLower = new std::vector<Double_t>( nvar );
84  fUpper = new std::vector<Double_t>( nvar );
85  fOwnerShip = kTRUE;
86 
87  for (int ivar=0; ivar<nvar; ivar++) {
88  (*fLower)[ivar] = Double_t(l[ivar]);
89  (*fUpper)[ivar] = Double_t(u[ivar]);
90  }
91 }
92 
94 {
95  // simple constructors for 1 dimensional values (double)
96  fLower = new std::vector<Double_t>(1);
97  fUpper = new std::vector<Double_t>(1);
98  fOwnerShip = kTRUE;
99  (*fLower)[0] = l;
100  (*fUpper)[0] = u;
101 }
102 
104 {
105  // simple constructors for 1 dimensional values (float)
106  fLower = new std::vector<Double_t>(1);
107  fUpper = new std::vector<Double_t>(1);
108  fOwnerShip = kTRUE;
109  (*fLower)[0] = Double_t(l);
110  (*fUpper)[0] = Double_t(u);
111 }
112 
114 {
115  // copy constructor
116  fLower = new std::vector<Double_t>( *V.fLower );
117  fUpper = new std::vector<Double_t>( *V.fUpper );
118  fOwnerShip = kTRUE;
119 }
120 
122 {
123  // destructor
124  // delete volume boundaries only if owend by the volume
125  if (fOwnerShip) this->Delete();
126 }
127 
129 {
130  // delete array of volume bondaries
131  if (NULL != fLower) { delete fLower; fLower = NULL; }
132  if (NULL != fUpper) { delete fUpper; fUpper = NULL; }
133 }
134 
136 {
137  // "scale" the volume by multiplying each upper and lower boundary by "f"
138  gTools().Scale(*fLower,f);
139  gTools().Scale(*fUpper,f);
140 }
141 
143 {
144  // "scale" the volume by symmetrically blowing up the interval in each dimension
145  for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
146  Double_t lo = 0.5*((*fLower)[ivar]*(1.0 + f) + (*fUpper)[ivar]*(1.0 - f));
147  Double_t up = 0.5*((*fLower)[ivar]*(1.0 - f) + (*fUpper)[ivar]*(1.0 + f));
148  (*fLower)[ivar] = lo;
149  (*fUpper)[ivar] = up;
150  }
151 }
152 
153 void TMVA::Volume::Print( void ) const
154 {
155  // printout of the volume boundaries
156  MsgLogger fLogger( "Volume" );
157  for (UInt_t ivar=0; ivar<fLower->size(); ivar++) {
158  fLogger << kINFO << "... Volume: var: " << ivar << "\t(fLower, fUpper) = ("
159  << (*fLower)[ivar] << "\t " << (*fUpper)[ivar] <<")"<< Endl;
160  }
161 }
162 
std::vector< Double_t > * fLower
Definition: Volume.h:75
void Delete(void)
Definition: Volume.cxx:128
void Scale(std::vector< Double_t > &, Double_t)
scales double vector
Definition: Tools.cxx:528
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
float Float_t
Definition: RtypesCore.h:53
std::vector< Double_t > * fUpper
Definition: Volume.h:76
void ScaleInterval(Double_t f)
Definition: Volume.cxx:142
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
Tools & gTools()
Definition: Tools.cxx:79
virtual ~Volume(void)
Definition: Volume.cxx:121
void Scale(Double_t f)
Definition: Volume.cxx:135
Volume(std::vector< Float_t > *l, std::vector< Float_t > *u=0)
Definition: Volume.cxx:54
unsigned int UInt_t
Definition: RtypesCore.h:42
TLine * l
Definition: textangle.C:4
double f(double x)
double Double_t
Definition: RtypesCore.h:55
void Print(void) const
Definition: Volume.cxx:153
#define NULL
Definition: Rtypes.h:82
const Bool_t kTRUE
Definition: Rtypes.h:91