MINT2
HyperBinningAlgorithms.cpp
Go to the documentation of this file.
2 
6  _optionName(EMTPY),
7  _bool(false),
8  _int(0),
9  _double(0.0),
10  _hyperPoint(0),
11  _hyperPointSet(0),
12  _hyperName(0),
13  _hyperFunc(0)
14 {
15 
16 }
17 
21  AlgOption algOption;
22  algOption._optionName = EMTPY;
23  return algOption;
24 }
25 
30  AlgOption algOption;
31  algOption._optionName = START_DIM;
32  algOption._int = dim;
33  return algOption;
34 }
35 
38 AlgOption AlgOption::BinningDimensions (std::vector<int> dims){
39  AlgOption algOption;
40  algOption._optionName = BINNING_DIMS;
41  algOption._intvector = dims;
42  return algOption;
43 }
44 
48  AlgOption algOption;
49  algOption._optionName = RAND_SEED;
50  algOption._int = seed;
51  return algOption;
52 }
53 
57  AlgOption algOption;
58  algOption._optionName = MIN_BIN_WIDTH;
59  algOption._double = width;
60  return algOption;
61 }
62 
66  AlgOption algOption;
67  algOption._optionName = MIN_BIN_WIDTH;
68  algOption._hyperPoint = widths;
69  return algOption;
70 }
71 
75  AlgOption algOption;
76  algOption._optionName = MIN_BIN_CONTENT;
77  algOption._double = val;
78  return algOption;
79 }
80 
84  AlgOption algOption;
86  algOption._double = val;
87  return algOption;
88 }
89 
93  AlgOption algOption;
94  algOption._optionName = USE_WEIGHTS;
95  algOption._bool = val;
96  return algOption;
97 }
98 
103  AlgOption algOption;
104  algOption._optionName = USE_SHADOW_DATA;
105  algOption._hyperPointSet = &data;
106  return algOption;
107 }
108 
109 
113  AlgOption algOption;
114  algOption._optionName = DRAW_ALGORITHM;
115  algOption._string = path;
116  return algOption;
117 }
118 
122  AlgOption algOption;
123  algOption._optionName = AXIS_NAMES;
124  algOption._hyperName = name;
125  return algOption;
126 }
127 
130  AlgOption algOption;
131  algOption._optionName = FUNC;
132  algOption._hyperFunc = func;
133  return algOption;
134 }
135 
136 
138  AlgOption algOption;
139  algOption._optionName = GRID_MULTIPLIER;
140  algOption._int = val;
141  return algOption;
142 }
143 
145  AlgOption algOption;
146  algOption._optionName = GRID_MULTIPLIER;
147  algOption._hyperPoint = val;
148  return algOption;
149 }
150 
152  AlgOption algOption;
153  algOption._optionName = SNAP_TO_GRID;
154  algOption._bool = val;
155  return algOption;
156 }
157 
158 
160  AlgOption algOption;
161  algOption._optionName = NUM_BIN_PAIRS;
162  algOption._int = val;
163  return algOption;
164 }
165 
166 AlgOption AlgOption::PhaseBinEdges (std::vector<double> val){
167  AlgOption algOption;
168  algOption._optionName = PHASE_BIN_EDGES;
169  algOption._doublevector = val;
170  return algOption;
171 }
172 
174  AlgOption algOption;
175  algOption._optionName = START_BINNING;
176  algOption._hyperBinning = &val;
177  return algOption;
178 }
179 
180 
181 
185  return _optionName;
186 }
187 
191  return _bool;
192 }
193 
197  return _int;
198 }
199 
203  return _double;
204 }
205 
208 std::vector<int> AlgOption::getIntVectorOpt (){
209  return _intvector;
210 }
211 
215  return _string;
216 }
217 
218 
221 std::vector<double> AlgOption::getDoubleVectorOpt (){
222  return _doublevector;
223 }
224 
228  return _hyperPoint;
229 }
230 
234  if (_hyperPointSet == 0){
235  std::cout << "ERROR: No HyperPointSet hass been passed to AlgOption!" << std::endl;
236  return *(new HyperPointSet(0));
237  }
238  return *_hyperPointSet;
239 }
240 
242  return _hyperFunc;
243 }
244 
245 
249  return _hyperName;
250 }
251 
255  return _hyperBinning;
256 }
257 
258 
262  return _optionName == EMTPY;
263 }
264 
265 //Desctructor
267 
268 }
269 
270 
275 
276  for (unsigned i = 0; i < _algOptions.size(); i++) {
277  if (_algOptions.at(i).getOptionName() == name) return _algOptions.at(i);
278  }
279 
280  return AlgOption::Empty();
281 }
282 
286 
287  return getOpt(name).isEmpty() == 0;
288 
289 }
290 
294  _alg(algorithm)
295 {
296 
297 }
298 
301  _algOptions.push_back(option);
302 }
303 
307 
308  int dim = binningRange.getDimension();
309 
310  HyperBinningMaker* binnningMaker = 0;
311 
312  int startDimension = 0;
313 
315  startDimension = getOpt(AlgOption::START_DIM ).getIntOpt();
316 
317  int numPhaseBinPairs = 3;
319  numPhaseBinPairs = getOpt(AlgOption::NUM_BIN_PAIRS ).getIntOpt();
320 
321 
322 
323  //Chose the binning algorithm
324 
325  if (_alg == SMART ) {
326  binnningMaker = new HyperBinningMakerSmart(binningRange, points, startDimension);
327  }
328  if (_alg == MINT ) {
329  binnningMaker = new HyperBinningMakerMint(binningRange, points, startDimension);
330  }
331  if (_alg == MINT_SMART ) {
332  binnningMaker = new HyperBinningMakerMintSmart(binningRange, points, startDimension);
333  }
334  if (_alg == MINT_RANDOM ) {
335  binnningMaker = new HyperBinningMakerMintRandomise(binningRange, points);
336  }
337  if (_alg == SMART_RANDOM ) {
338  binnningMaker = new HyperBinningMakerSmartRandomise(binningRange, points);
339  }
340  if (_alg == LIKELIHOOD ) {
341  binnningMaker = new HyperBinningMakerLikelihood(binningRange, points);
342  }
343  if (_alg == SMART_LIKELIHOOD ) {
344  binnningMaker = new HyperBinningMakerSmartLikelihood(binningRange, points);
345  }
346  if (_alg == SMART_MULTI) {
347  binnningMaker = new HyperBinningMakerMultiSmart(binningRange, points, startDimension);
348  }
349  if (_alg == FUNC_PHASE) {
350  HyperBinningMakerPhaseBinning* phaseBinningMaker = new HyperBinningMakerPhaseBinning(binningRange, 0);
351  phaseBinningMaker->setNumBinPairs(numPhaseBinPairs);
352 
354  phaseBinningMaker->setBinEdges( getOpt(AlgOption::PHASE_BIN_EDGES ).getDoubleVectorOpt() );
355 
356  binnningMaker = dynamic_cast<HyperBinningMaker*>(phaseBinningMaker);
357  }
358  //Now set the options
359 
360 
362  binnningMaker->setSeed ( getOpt(AlgOption::RAND_SEED ).getIntOpt() );
363 
365  binnningMaker->useEventWeights( getOpt(AlgOption::USE_WEIGHTS).getBoolOpt() );
366 
368  binnningMaker->setBinningDimensions( getOpt(AlgOption::BINNING_DIMS).getIntVectorOpt() );
369 
370  if (optExist(AlgOption::FUNC ))
371  binnningMaker->setHyperFunction( getOpt(AlgOption::FUNC).getFuncOpt() );
372 
374  //can provide either a double or a HyperPoint here.
375 
377  double widthsB = getOpt(AlgOption::MIN_BIN_WIDTH).getDoubleOpt ();
378  if ( widthsA.getDimension() == 0 ) widthsA = HyperPoint(dim, widthsB);
379  binnningMaker->setMinimumEdgeLength(widthsA);
380  }
381 
383  binnningMaker->addShadowHyperPointSet( getOpt(AlgOption::USE_SHADOW_DATA).getHyperPointSetOpt() );
384 
386  binnningMaker->setMinimumBinContent( getOpt(AlgOption::MIN_BIN_CONTENT).getDoubleOpt() );
387 
389  binnningMaker->setShadowMinimumBinContent( getOpt(AlgOption::MIN_BIN_CONTENT).getDoubleOpt() );
390 
392  binnningMaker->drawAfterEachIteration( getOpt(AlgOption::DRAW_ALGORITHM).getStringOpt() );
393 
395  binnningMaker->setNames( getOpt(AlgOption::AXIS_NAMES).getHyperNameOpt() );
396 
398  binnningMaker->useSnapToGrid( getOpt(AlgOption::SNAP_TO_GRID).getBoolOpt() );
399  }
400 
402 
405 
406  if (valA.getDimension() != 0){
407  binnningMaker->setGridMultiplier(valA);
408  }
409  else{
410  binnningMaker->setGridMultiplier(valB);
411  }
412  }
413 
415  binnningMaker->updateFromExistingHyperBinning( *getOpt(AlgOption::START_BINNING).getHyperBinningOpt() );
416  }
417 
418  return binnningMaker;
419 
420 }
421 
425 
426 }
427 
428 
429 
430 
431 
432 
HyperName getHyperNameOpt()
static AlgOption GridMultiplier(int val)
static AlgOption SnapToGrid(bool val)
void addShadowHyperPointSet(const HyperPointSet &data)
void setShadowMinimumBinContent(double val)
void setBinningDimensions(std::vector< int > dims)
std::vector< double > _doublevector
HyperName _hyperName
HyperFunction * _hyperFunc
void addAlgOption(AlgOption option)
Add an AlgOption which is passed to the binning algortihm.
void setNames(HyperName names)
static AlgOption Empty()
std::vector< int > _intvector
std::vector< double > getDoubleVectorOpt()
static AlgOption AxisTitles(HyperName name)
void drawAfterEachIteration(TString path)
void setGridMultiplier(HyperPoint &multipliers)
static AlgOption RandomSeed(int seed)
static AlgOption MinBinWidth(double width)
void setMinimumEdgeLength(double val)
HyperPoint getHyperPointOpt()
static AlgOption StartBinning(const HyperBinning &binning)
void useSnapToGrid(bool val)
void updateFromExistingHyperBinning(const HyperBinning &binning)
static AlgOption DrawAlgorithm(TString path)
OptionName getOptionName()
static AlgOption MinBinContent(double val)
const int & getDimension() const
Definition: HyperCuboid.h:45
static AlgOption BinningDimensions(std::vector< int > dims)
HyperBinningMaker * getHyperBinningMaker(HyperCuboid binningRange, HyperPointSet points)
OptionName _optionName
static AlgOption UseWeights(bool val=true)
static AlgOption NumPhaseBinPairs(int val)
static AlgOption StartDimension(int dim)
const HyperBinning * _hyperBinning
const HyperPointSet & getHyperPointSetOpt()
AlgOption getOpt(AlgOption::OptionName name)
bool optExist(AlgOption::OptionName name)
std::vector< int > getIntVectorOpt()
void setHyperFunction(HyperFunction *fnc)
Set the HyperFunction - only used by some binning Algs.
const HyperBinning * getHyperBinningOpt()
void setBinEdges(std::vector< double > binEdges)
const HyperPointSet * _hyperPointSet
void setSeed(int seed)
static AlgOption UseFunction(HyperFunction *func)
Use this if you want to provide a HyperFunction.
static AlgOption PhaseBinEdges(std::vector< double > val)
void useEventWeights(bool val=true)
std::vector< AlgOption > _algOptions
static AlgOption MinShadowBinContent(double val)
int getDimension() const
Definition: HyperPoint.h:99
void setMinimumBinContent(double val)
HyperPoint _hyperPoint
static AlgOption UseShadowData(const HyperPointSet &data)
HyperFunction * getFuncOpt()