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