MINT2
HyperHistogram.cpp
Go to the documentation of this file.
1 #include "Mint/HyperHistogram.h"
4 
5 
10  HistogramBase(binning.getNumBins()),
11  _binning(binning.clone())
12 {
13  WELCOME_LOG << "Good day from the HyperHistogram() Constructor";
15 }
16 
49  const HyperCuboid& binningRange,
50  const HyperPointSet& points,
52  AlgOption opt0 ,
53  AlgOption opt1 ,
54  AlgOption opt2 ,
55  AlgOption opt3 ,
56  AlgOption opt4 ,
57  AlgOption opt5 ,
58  AlgOption opt6 ,
59  AlgOption opt7 ,
60  AlgOption opt8 ,
61  AlgOption opt9
62 ) :
63  HistogramBase(0),
64  HyperFunction(binningRange),
65  _binning(0)
66 {
67 
68  HyperBinningAlgorithms algSetup(alg);
69  algSetup.addAlgOption(opt0);
70  algSetup.addAlgOption(opt1);
71  algSetup.addAlgOption(opt2);
72  algSetup.addAlgOption(opt3);
73  algSetup.addAlgOption(opt4);
74  algSetup.addAlgOption(opt5);
75  algSetup.addAlgOption(opt6);
76  algSetup.addAlgOption(opt7);
77  algSetup.addAlgOption(opt8);
78  algSetup.addAlgOption(opt9);
79 
80  HyperBinningMaker* binnningMaker = algSetup.getHyperBinningMaker(binningRange, points);
81  binnningMaker->makeBinning();
82 
83  HyperHistogram* hist = binnningMaker->getHyperBinningHistogram();
84 
85  *this = *hist;
86  delete hist;
87  delete binnningMaker;
88 
89  //This inherets from a HyperFunction. Although non-essential, it's useful for
90  //the function to have some limits for it's domain.
92 
93 }
94 
96 
97  HistogramBase::operator=(other);
98  HyperFunction::operator=(other);
99 
100  _binning = other._binning->clone();
101  return *this;
102 
103 }
104 
105 
109 HyperHistogram::HyperHistogram(TString filename, TString option) :
110  HistogramBase(0),
111  _binning(0)
112 {
113  WELCOME_LOG << "Good day from the HyperHistogram() Constructor";
114 
115  if (option.Contains("Empty")){
116  loadEmpty(filename, option);
117  }
118  else{
119  load(filename, option);
120  }
121 
122  //This inherets from a HyperFunction. Although non-essential, it's useful for
123  //the function to have some limits for it's domain.
125 }
126 
131 HyperHistogram::HyperHistogram(std::vector<TString> filename) :
132  HistogramBase(0),
133  _binning(0)
134 {
135  WELCOME_LOG << "Good day from the HyperHistogram() Constructor";
136 
137  int nFiles = filename.size();
138  if (nFiles == 0){
139  ERROR_LOG << "The list of filenames you provided to HyperHistogram is empty" << std::endl;
140  }
141 
142  INFO_LOG << "Loading HyperHistogram at: " << filename.at(0) << std::endl;
143  load(filename.at(0), "MEMRES");
144 
145  for (int i = 1; i < nFiles; i++){
146  INFO_LOG << "Loading and merging HyperHistogram at: " << filename.at(i) << std::endl;
147  merge(filename.at(i));
148  }
149 
150  //This inherets from a HyperFunction. Although non-essential, it's useful for
151  //the function to have some limits for it's domain.
153 
154 }
155 
160 HyperHistogram::HyperHistogram(TString targetFilename, std::vector<TString> filename) :
161  HistogramBase(0),
162  _binning(0)
163 {
164 
165  WELCOME_LOG << "Good day from the HyperHistogram() Constructor";
166 
167  int nFiles = filename.size();
168  if (nFiles == 0){
169  ERROR_LOG << "The list of filenames you provided to HyperHistogram is empty" << std::endl;
170  }
171 
172  //Getting the binning type from the first file
173  TString binningType = getBinningType( filename.at(0) );
174 
175  INFO_LOG << "Creating HyperHistogram at: " << targetFilename << " with binning type " << binningType <<std::endl;
176  loadEmpty(targetFilename, "DISKRES", binningType );
177 
178  int nResBins = estimateCapacity(filename, binningType);
179  INFO_LOG << "I estimate there will be " << nResBins << " in total - resizing the Histogram accordingly" << std::endl;
180 
181  for (int i = 0; i < nFiles; i++){
182  INFO_LOG << "Loading and merging HyperHistogram at: " << filename.at(i) << std::endl;
183  merge(filename.at(i));
184  }
185 
186  //This inherets from a HyperFunction. Although non-essential, it's useful for
187  //the function to have some limits for it's domain.
188  setFuncLimits( getLimits() );
189 }
190 
191 
192 int HyperHistogram::estimateCapacity(std::vector<TString> filename, TString binningType){
193 
194  int nbins = 0;
195  int nvols = 0;
196 
197  for (unsigned i = 0; i < filename.size(); i++){
198  TFile* file = new TFile(filename.at(i), "READ");
199  if (file == 0){
200  ERROR_LOG << "HyperHistogram::estimateCapacity - " << filename.at(i) << " does not exist" << std::endl;
201  return 0;
202  }
203  TTree* hist = dynamic_cast<TTree*>( file->Get(binningType) );
204  TTree* base = dynamic_cast<TTree*>( file->Get("HistogramBase") );
205  if (hist == 0){
206  ERROR_LOG << "HyperHistogram::estimateCapacity - " << filename.at(i) << " does not contain tree " << binningType << std::endl;
207  return 0;
208  }
209  if (base == 0){
210  ERROR_LOG << "HyperHistogram::estimateCapacity - " << filename.at(i) << " does not contain tree HistogramBase" << std::endl;
211  return 0;
212  }
213  nbins += base->GetEntries();
214  nvols += hist->GetEntries();
215  file->Close();
216  }
217 
218  reserveCapacity(nbins);
219  _binning->reserveCapacity(nvols);
220 
221  return nbins;
222 
223 }
224 
225 
227  HistogramBase(other),
228  HyperFunction(other),
229  _binning( other._binning->clone() )
230 {
231 
232 }
233 
234 
239  HistogramBase(0),
240  _binning(0)
241 {
242  WELCOME_LOG << "Good day from the HyperHistogram() Constructor";
243 }
244 
245 
247  _binning->setNames(names);
248 }
252  return _binning->getNames();
253 }
262 int HyperHistogram::fill(const HyperPoint& coords, double weight){
263 
264  int binNumber = _binning->getBinNum(coords);
265  this->fillBase(binNumber, weight);
266  return binNumber;
267 }
268 
273 int HyperHistogram::fill(const HyperPoint& coords){
274 
275  int binNumber = _binning->getBinNum(coords);
276  this->fillBase(binNumber, coords.getWeight(0));
277  return binNumber;
278 }
279 
283 double HyperHistogram::getVal(const HyperPoint& point) const{
284 
285  int binNumber = _binning->getBinNum(point);
286  return this->getBinContent(binNumber);
287 
288 }
289 
293 std::vector<double> HyperHistogram::getVal(const HyperPointSet& points) const{
294 
295  int nPoints = points.size();
296 
297  std::vector<int> binNums = _binning->getBinNum(points);
298 
299  std::vector<double> conts(nPoints);
300 
301  for (int i = 0; i < nPoints; i++){
302  conts.at(i) = this->getBinContent( binNums.at(i) );
303  }
304 
305  return conts;
306 
307 }
308 
309 
310 
316 
317  for(unsigned i = 0; i < points.size(); i++){
318  fill(points.at(i), points.at(i).getWeight());
319  }
320 
321 }
322 
323 
328  return _binning->getLimits();
329 }
330 
331 
336 
337  //INFO_LOG << "Starting HyperHistogram::merge" <<std::endl;
338 
339  const HyperHistogram* histOther = dynamic_cast<const HyperHistogram*>(&other);
340 
341  if (histOther == 0){
342  ERROR_LOG << "The object passed to HyperHistogram::merge is not of type ";
343  ERROR_LOG << "HyperHistogram, so cannot merge";
344  return;
345  }
346 
347  _binning->mergeBinnings( histOther->getBinning() );
348  HistogramBase::merge( other );
349 
350  //I do this so that getLimits doesn't have to be
351  //called (which will update the cache). Will speed
352  //things up I hope
353 
355  HyperCuboid b = histOther->getFuncLimits();
356 
358  if (a.getDimension() != 0) vol.push_back(a);
359  if (b.getDimension() != 0) vol.push_back(b);
360 
361  setFuncLimits( vol.getLimits() );
362 
363  //INFO_LOG << "Ending HyperHistogram::merge" <<std::endl;
364 
365 
366 }
367 
371 void HyperHistogram::merge( TString filenameother ){
372 
373  HyperHistogram other(filenameother, "DISK");
374  merge( other );
375 
376 }
377 
378 
385 
386  int nbins = getNBins();
387 
388  for (int i = 0; i < nbins; i++){
390  double funcVal = func.getVal(binCenter);
391  setBinContent(i, funcVal);
392  setBinError (i, 0 );
393  }
394 
395 
396 }
397 
398 
399 
400 
404 
405 
406  if ( _binning->getBinningType() != "HyperBinning" ){
407  ERROR_LOG << "It is only possible to merge bins when using HyperBinning. Doing nothing." << std::endl;
408  return;
409  }
410 
411 
412 
413  const HyperBinning& hyperBinning = dynamic_cast<const HyperBinning&>( getBinning() );
414 
415  std::map<int, bool> volumeKept;
416  for (int i = 0; i < hyperBinning.getNumHyperVolumes(); i++){
417  volumeKept[i] = true;
418  }
419 
420  //Loop over all HyperVolumes and see if there are any linked bins.
421  //If there are, see if these linked bins are actually bins, and not
422  //just part of the binning hierarchy. If they are actually bins,
423  //See if they al have the same bin content. If they do, mark them
424  //to be removed.
425 
426  for (int i = 0; i < hyperBinning.getNumHyperVolumes(); i++){
427 
428  std::vector<int> linkedVols = hyperBinning.getLinkedHyperVolumes(i);
429  if (linkedVols.size() == 0) continue;
430 
431  bool linksLeadToBins = true;
432 
433  for (unsigned j = 0; j < linkedVols.size(); j++){
434  int volNum = linkedVols.at(j);
435  if (hyperBinning.getLinkedHyperVolumes(volNum).size() != 0){
436  linksLeadToBins = false;
437  break;
438  }
439  }
440 
441  if (linksLeadToBins == false) continue;
442 
443  double binCont0 = -99999.9;
444 
445  bool binsHaveSameContent = true;
446 
447  for (unsigned j = 0; j < linkedVols.size(); j++){
448  int volNum = linkedVols.at(j);
449  int binNum = hyperBinning.getBinNum(volNum);
450  double binContent = getBinContent(binNum);
451  if (j == 0) binCont0 = binContent;
452 
453  if (binContent != binCont0){
454  binsHaveSameContent = false;
455  break;
456  }
457 
458  }
459 
460  if (binsHaveSameContent == false) continue;
461 
462  for (unsigned j = 0; j < linkedVols.size(); j++){
463  int volNum = linkedVols.at(j);
464  volumeKept[volNum] = false;
465  }
466 
467 
468  }
469 
470  //Make a map of the old volume numbers to the new ones (once the removed bins have
471  //actually been removed).
472 
473  std::map<int, int> oldToNewVolumeNum;
474  int newVolNum = 0;
475 
476  for (int i = 0; i < hyperBinning.getNumHyperVolumes(); i++){
477  bool exists = volumeKept[i];
478 
479  if (exists == true){
480  oldToNewVolumeNum[i] = newVolNum;
481  newVolNum++;
482  }
483  else{
484  oldToNewVolumeNum[i] = -1;
485  }
486 
487  }
488 
489  volumeKept.clear();
490 
491  //Create a new HyperVolumeBinning with the bins removed
492  HyperBinning* binningNew;
493 
494 
495  if (hyperBinning.isDiskResident() == true){
496  binningNew = new HyperBinningDiskRes();
497  binningNew->load( hyperBinning.filename().ReplaceAll(".root", "_temp.root"), "RECREATE" );
498  }
499  else{
500  binningNew = new HyperBinningMemRes();
501  }
502 
503  INFO_LOG << "Created a new HyperBinning for the reduced binning" << std::endl;
504 
505  int count = 0;
506 
507  for (int i = 0; i < hyperBinning.getNumHyperVolumes(); i++){
508  HyperVolume vol = hyperBinning.getHyperVolume(i);
509 
510  int newVolNum = oldToNewVolumeNum[i];
511 
512  if (newVolNum == -1) continue;
513 
514  if (newVolNum != count){
515  ERROR_LOG << "Something has gone wrong in mergeBinsWithSameContent()" << std::endl;
516  }
517 
518 
519  std::vector<int> linkedVols = hyperBinning.getLinkedHyperVolumes( i );
520  std::vector<int> newLinkedVols;
521 
522  int nLinked = 0;
523  for (unsigned j = 0; j < linkedVols.size(); j++){
524  int linkVolNum = linkedVols.at(j);
525  int newLinkVolNum = oldToNewVolumeNum[linkVolNum];
526 
527  if (newLinkVolNum != -1){
528  newLinkedVols.push_back(newLinkVolNum);
529  nLinked++;
530  }
531 
532 
533  }
534 
535  binningNew->addHyperVolume(vol, newLinkedVols);
536 
537 
538  if (nLinked == 1){
539  INFO_LOG << "This should never be one" << std::endl;
540  }
541 
542  count++;
543  }
544 
545 
546  std::vector<int> primVolNums = hyperBinning.getPrimaryVolumeNumbers();
547 
548  for (unsigned i = 0; i < primVolNums.size(); i++){
549  int oldVolNum = primVolNums.at(i);
550  int newVolNum = oldToNewVolumeNum[oldVolNum];
551  binningNew->addPrimaryVolumeNumber(newVolNum);
552  }
553 
554  oldToNewVolumeNum.clear();
555 
556  INFO_LOG << "Filled the new binning with reduced bins" << std::endl;
557 
558 
559  HyperHistogram newHist(*binningNew);
560 
561  INFO_LOG << "Made a new hitogram which will clone the binning" << std::endl;
562 
563  newHist.setContentsFromFunc(*this);
564 
565  INFO_LOG << "You have managed to remove " << hyperBinning.getNumBins() - binningNew->getNumBins() << " bins with the same content" << std::endl;
566 
567  bool moreBinsToMerge = false;
568  if ( hyperBinning.getNumBins() - binningNew->getNumBins() > 0 ) moreBinsToMerge = true;
569 
570  if (hyperBinning.isDiskResident() == true){
571  TString filenm = hyperBinning.filename();
572  delete _binning;
573  _binning = 0;
574  newHist.save( filenm );
575 
576  load(filenm, "DISK");
577  }
578  else{
579  *this = newHist;
580  }
581 
582  delete binningNew;
583 
584  if (moreBinsToMerge) this->mergeBinsWithSameContent();
585 
586 }
587 
594 void HyperHistogram::draw(TString path, TString options){
595 
596  if (_binning->getDimension() == 1){
597  HyperBinningPainter1D painter(this);
598  painter.draw(path, options);
599  }
600  else if (_binning->getDimension() == 2){
601 
602  HyperBinningPainter2D painter(this);
603  painter.draw(path, options);
604  }
605  else{
606  HyperBinningPainter painter(this);
607  painter.draw(path, options);
608  }
609 
610 }
611 
616 void HyperHistogram::drawDensity(TString path, TString options){
617 
618  if (_binning->getDimension() == 1){
619  HyperBinningPainter1D painter(this);
620  painter.useDensity(true);
621  painter.draw(path, options);
622  }
623  else if (_binning->getDimension() == 2){
624  HyperBinningPainter2D painter(this);
625  painter.useDensity(true);
626  painter.draw(path, options);
627  }
628  else{
629  HyperBinningPainter painter(this);
630  painter.useDensity(true);
631  painter.draw(path, options);
632  }
633 
634 }
635 
636 
637 
642 
643  for(int i = 0; i < _binning->getNumBins(); i++){
644  INFO_LOG << "Bin Content " << i << ": " << _binContents[i] << " SumW2: " << _sumW2[i];
646  }
647 
648  INFO_LOG << "Overflow: " << _binContents[_nBins] << std::endl;
649 
650 }
651 
652 
656 void HyperHistogram::project(TH1D* histogram, const HyperCuboid& cuboid, double content, int dimension) const{
657 
658  double hyperLowEdge = cuboid.getLowCorner() .at(dimension);
659  double hyperHighEdge = cuboid.getHighCorner().at(dimension);
660  double totWidth = hyperHighEdge - hyperLowEdge;
661  int lowBin = histogram->GetXaxis()->FindFixBin(hyperLowEdge);
662  int highBin = histogram->GetXaxis()->FindFixBin(hyperHighEdge);
663 
664  if (lowBin==highBin) histogram->Fill(hyperLowEdge, content);
665  else{
666 
667  //first deal with the highest and lowest bin as there will be a fractional overlap with the HyperCuboid
668 
669  double widthInLowBin = histogram->GetXaxis()->GetBinUpEdge(lowBin) - hyperLowEdge;
670  double widthInHighBin = hyperHighEdge - histogram->GetXaxis()->GetBinLowEdge(highBin);
671  double eventsInLowBin = (widthInLowBin /totWidth)*content;
672  double eventsInHighBin = (widthInHighBin/totWidth)*content;
673  histogram->Fill(hyperLowEdge , eventsInLowBin);
674  histogram->Fill(hyperHighEdge, eventsInHighBin);
675 
676  //now do the bins in the middle
677 
678  for(int bin = (lowBin + 1); bin <= (highBin - 1); bin++){
679  double lowEdge = histogram->GetXaxis()->GetBinLowEdge(bin);
680  double highEdge = histogram->GetXaxis()->GetBinUpEdge (bin);
681  double events = ((highEdge - lowEdge)/totWidth)*content;
682  histogram->Fill( histogram->GetXaxis()->GetBinCenter(bin) , events);
683  }
684 
685  }
686 
687 }
688 
692 void HyperHistogram::project(TH1D* histogram, const HyperVolume& hyperVolume, double content, int dimension) const{
693 
694  double volume = hyperVolume.volume();
695  for(int i = 0; i < hyperVolume.size(); i++){
696  const HyperCuboid& cuboid = hyperVolume.getHyperCuboid(i);
697  double cuboidVolume = cuboid.volume();
698  double cuboidContent = (content*cuboidVolume)/volume;
699  project(histogram, cuboid, cuboidContent, dimension);
700  }
701 
702 }
703 
704 
706 
707  if (_binning == 0){
708  ERROR_LOG << "HyperHistogram::getDimension - cannot get dimension, binning not set." << std::endl;
709  return 0;
710  }
711  return _binning->getDimension();
712 
713 }
714 
715 
722 HyperHistogram HyperHistogram::slice(std::vector<int> sliceDims, const HyperPoint& slicePoint) const{
723 
724  HyperBinningMemRes temp;
725 
726  std::vector<double> binContents;
727  std::vector<double> binErrors ;
728 
729  //Loop over all the bins and slice them. If the slice doesn't
730  //pass through the bin volume, the returned volume with have dimesnion 0.
731  //In these cases, skip the bin as it will not show up in the slice.
732 
733  for (int i = 0; i < getNBins(); i++){
734 
736 
737  HyperVolume slicedVol = vol.slice(slicePoint, sliceDims);
738 
739  if (slicedVol.size() == 0) continue;
740 
741  temp.addHyperVolume(slicedVol);
742 
743  binContents.push_back( getBinContent(i) );
744  binErrors .push_back( getBinError (i) );
745  }
746 
747  //Set the bin contents and errors
748 
749  HyperHistogram slicedHist(temp);
750 
751  for (unsigned i = 0; i < binContents.size(); i++){
752  slicedHist.setBinContent(i, binContents.at(i) );
753  slicedHist.setBinError (i, binErrors .at(i) );
754  }
755 
756  //Set the names and the min/max from this histogram
757 
758  slicedHist.setNames( getNames().slice(sliceDims) );
759 
760  slicedHist.setMin( getMin() );
761  slicedHist.setMax( getMax() );
762 
763  return slicedHist;
764 
765 }
766 
767 
768 std::vector<HyperHistogram> HyperHistogram::slice(std::vector<int> sliceDims, const HyperPointSet& slicePoints) const{
769 
770  int nSlices = slicePoints.size();
771 
772  std::vector< HyperBinningMemRes > slicedBinnings(nSlices, HyperBinningMemRes() );
773  std::vector< std::vector<double> > binContents (nSlices, std::vector<double>(0, 0.0) );
774  std::vector< std::vector<double> > binErrors (nSlices, std::vector<double>(0, 0.0) );
775 
776  //Loop over all the bins and slice them. If the slice doesn't
777  //pass through the bin volume, the returned volume with have dimesnion 0.
778  //In these cases, skip the bin as it will not show up in the slice.
779 
780  for (int i = 0; i < getNBins(); i++){
781 
783  double content = getBinContent(i);
784  double error = getBinContent(i);
785 
786  for (int sli = 0; sli < nSlices; sli++){
787  HyperVolume slicedVol = vol.slice( slicePoints.at(sli), sliceDims);
788 
789  if (slicedVol.size() == 0) continue;
790 
791  slicedBinnings.at(sli).addHyperVolume( slicedVol );
792  binContents .at(sli).push_back ( content );
793  binErrors .at(sli).push_back ( error );
794  }
795 
796  }
797 
798  //Set the bin contents and errors
799  //Set the names and the min/max from this histogram
800 
801  std::vector< HyperHistogram > slicedHist;
802  slicedHist.reserve(nSlices);
803 
804  for (int sli = 0; sli < nSlices; sli++){
805 
806  slicedHist.push_back( HyperHistogram( slicedBinnings.at(sli) ) );
807 
808  int nBins = binContents.at(sli).size();
809  for (int bin = 0; bin < nBins; bin++){
810  slicedHist.at(sli).setBinContent(bin, binContents.at(sli).at(bin) );
811  slicedHist.at(sli).setBinError (bin, binErrors .at(sli).at(bin) );
812  }
813 
814  slicedHist.at(sli).setNames( getNames().slice(sliceDims) );
815  slicedHist.at(sli).setMin ( getMin() );
816  slicedHist.at(sli).setMax ( getMax() );
817  }
818 
819  return slicedHist;
820 
821 }
822 
823 
824 
825 void HyperHistogram::draw2DSlice(TString path, int sliceDimX, int sliceDimY, const HyperPoint& slicePoint, TString options) const{
826 
827  std::vector<int > sliceDims;
828 
829  for (int i = 0; i < slicePoint.getDimension(); i++){
830  if (i == sliceDimX) continue;
831  if (i == sliceDimY) continue;
832  sliceDims.push_back( i );
833  }
834 
835  HyperHistogram sliceHist = slice( sliceDims, slicePoint );
836  sliceHist.draw(path, options);
837 
838 }
839 
840 void HyperHistogram::drawRandom2DSlice(TString path, TRandom* random, TString options) const{
841 
842  int dim = getDimension();
843 
844  if (dim < 3){
845  ERROR_LOG << "Why would you take a 2D slice of something with less than 3 dim." << std::endl;
846  return;
847  }
848 
849  int slicedimx = random->Integer(dim);
850  int slicedimy = random->Integer(dim);
851  while( slicedimx == slicedimy ){
852  slicedimy = random->Integer(dim);
853  }
854 
855  HyperPoint slicepoint = getLimits().getRandomPoint(random);
856 
857  draw2DSlice(path, slicedimx, slicedimy, slicepoint, options);
858 
859 }
860 
861 void HyperHistogram::draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint& slicePoint, TString options) const{
862 
863  std::vector<int > _sliceDims;
864 
865  for (int i = 0; i < slicePoint.getDimension(); i++){
866  if (i == sliceDimX) continue;
867  if (i == sliceDimY) continue;
868  _sliceDims.push_back( i );
869  }
870 
871  HyperPointSet slicePoints(getDimension());
872 
873 
874  HyperPoint slicePointCp(slicePoint);
875 
876  double min = _binning->getMin(sliceSetDim);
877  double max = _binning->getMax(sliceSetDim);
878  double width = (max - min)/double(nSlices);
879 
880  std::vector<TString> paths;
881 
882  for (int i = 0; i < nSlices; i++){
883  double val = min + width*(i + 0.5);
884  slicePointCp.at(sliceSetDim) = val;
885 
886  slicePoints.push_back(slicePointCp);
887 
888  TString uniquePath = path;
889  uniquePath += "_sliceNum";
890  uniquePath += i;
891 
892  paths.push_back(uniquePath);
893 
894  }
895 
896  std::vector<HyperHistogram> hists = slice(_sliceDims, slicePoints);
897 
898  for (unsigned i = 0; i < hists.size(); i++){
899  hists.at(i).draw(paths.at(i), options);
900  }
901 
902 }
903 
904 void HyperHistogram::draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int nSlices, const HyperPoint& slicePoint, TString options) const{
905 
906  //Get the slice dimesnions from the given dimensions
907  std::vector<int > sliceDims;
908 
909  for (int i = 0; i < slicePoint.getDimension(); i++){
910  if (i == sliceDimX) continue;
911  if (i == sliceDimY) continue;
912  sliceDims.push_back( i );
913  }
914 
915  //Fill a HyperPointSet with slice points, and create a name for each in paths
916  HyperPointSet slicePoints(getDimension());
917  std::vector<TString> paths;
918 
919  //Loop over each slice dimesion - will take nSlices along each of these
920  for (unsigned j = 0; j < sliceDims.size(); j++){
921 
922  HyperPoint slicePointCp(slicePoint);
923 
924  int sliceSetDim = sliceDims.at(j);
925 
926  double min = _binning->getMin(sliceSetDim);
927  double max = _binning->getMax(sliceSetDim);
928  double width = (max - min)/double(nSlices);
929 
930  TString pathj = path;
931  pathj += "_scanDim";
932  pathj += sliceSetDim;
933 
934  for (int i = 0; i < nSlices; i++){
935  double val = min + width*(i + 0.5);
936  slicePointCp.at(sliceSetDim) = val;
937 
938  slicePoints.push_back(slicePointCp);
939 
940  TString uniquePath = pathj;
941  uniquePath += "_sliceNum";
942  uniquePath += i;
943 
944  paths.push_back(uniquePath);
945 
946  }
947 
948  }
949 
950 
951 
952  std::vector<HyperHistogram> hists = slice(sliceDims, slicePoints);
953 
954  for (unsigned i = 0; i < hists.size(); i++){
955  hists.at(i).draw(paths.at(i), options);
956  }
957 
958 
959 
960 
961 }
962 
963 void HyperHistogram::draw2DSliceSet(TString path, int nSlices, const HyperPoint& slicePoint, TString options) const{
964 
965 
966 
967  for (int i = 0; i < slicePoint.getDimension(); i++){
968  for (int j = 0; j < slicePoint.getDimension(); j++){
969 
970  if (i >= j) continue;
971 
972  TString thsPath = path;
973  thsPath += "_";
974  thsPath += i;
975  thsPath += "vs";
976  thsPath += j;
977 
978  draw2DSliceSet(thsPath, i, j, nSlices, slicePoint, options);
979  }
980  }
981 
982 
983 }
984 
985 
989 TH1D HyperHistogram::project(int dim, int bins, TString name) const{
990 
991  double lowEdge = _binning->getMin(dim);
992  double highEdge = _binning->getMax(dim);
993 
994  TH1D projection(name, name, bins, lowEdge, highEdge);
995  projection.GetXaxis()->SetTitle(_binning->getNames().at(dim));
996 
997  for(int i = 0; i < _binning->getNumBins(); i++){
998  project(&projection, _binning->getBinHyperVolume(i), this->getBinContent(i), dim);
999  }
1000 
1001  for (int i = 1; i <= projection.GetNbinsX(); i++){
1002  projection.SetBinError(i, 0.0);
1003  }
1004 
1005  return projection;
1006 
1007 }
1008 
1012 void HyperHistogram::drawProjection(TString path, int dim, int bins) const{
1013 
1014  TH1D projection = project(dim, bins);
1015  RootPlotter1D plotter(&projection, 300, 300);
1016  plotter.setMin(0.0);
1017  plotter.plot(path);
1018 
1019 }
1020 
1024 void HyperHistogram::drawAllProjections(TString path, int bins) const{
1025 
1026  for(int i = 0; i < _binning->getDimension(); i++){
1027  TString thisPath = path + "_"; thisPath += i;
1028  drawProjection(thisPath, i, bins);
1029  }
1030 
1031 }
1032 
1036 void HyperHistogram::compareProjection (TString path, int dim, const HyperHistogram& other, int bins) const{
1037  TH1D projection = project(dim, bins);
1038  TH1D projectionOther = other.project(dim, bins, "projection2");
1039  RootPlotter1D plotter(&projection, 300, 300);
1040  plotter.add(&projectionOther);
1041  plotter.setMin(0.0);
1042  plotter.plotWithRatio(path);
1043 }
1044 
1048 void HyperHistogram::compareAllProjections(TString path, const HyperHistogram& other, int bins) const{
1049  for(int i = 0; i < _binning->getDimension(); i++){
1050  TString thisPath = path + "_"; thisPath += i;
1051  compareProjection(thisPath, i, other, bins);
1052  }
1053 }
1054 
1058 void HyperHistogram::save(TString filename){
1059 
1060  TFile* file = new TFile(filename, "RECREATE");
1061 
1062  if (file == 0){
1063  ERROR_LOG << "Could not open TFile in HyperHistogram::save(" << filename << ")";
1064  return;
1065  }
1066 
1067  //save the bin contents
1068  this->saveBase();
1069  //save the binning
1070  _binning->save();
1071 
1072  file->Write();
1073  file->Close();
1074 
1075 }
1076 
1080 void HyperHistogram::saveToTxtFile(TString filename, bool incError) const{
1081 
1082  if ( _binning->getBinningType() != "HyperBinning" ){
1083  ERROR_LOG << "It is only possible to saveToTxtFile when using HyperBinning. Doing nothing." << std::endl;
1084  return;
1085  }
1086 
1087  const HyperBinning& hyperBinning = dynamic_cast<const HyperBinning&>( getBinning() );
1088 
1089  int nVolumes = hyperBinning.getNumHyperVolumes();
1090 
1091  std::ofstream myfile;
1092  myfile.open (filename);
1093 
1094  int widthForVolNum = ceil(log10(nVolumes)) + 2;
1095 
1096  for (int i = 0; i < nVolumes; i++ ){
1097  HyperVolume vol = hyperBinning.getHyperVolume(i);
1098  HyperCuboid cube = vol.getHyperCuboid(0);
1099  int binNumber = hyperBinning.getBinNum(i);
1100  double content = -1.0;
1101  double error = -1.0;
1102 
1103  bool isPrimary = hyperBinning.isPrimaryVolume(i);
1104  bool isBin = false;
1105 
1106  std::vector<int> linkedBins = hyperBinning.getLinkedHyperVolumes(i);
1107 
1108  if (binNumber != -1){
1109  content = getBinContent(binNumber);
1110  error = getBinError (binNumber);
1111  isBin = true;
1112  }
1113 
1114  myfile << std::setw(widthForVolNum) << std::left << i;
1115 
1116  TString binType = "";
1117  if (isPrimary ) myfile << "P";
1118  //if (!isPrimary) myfile << "L";
1119  if (isBin ) myfile << "B";
1120  if (!isBin ) myfile << "V";
1121 
1122  myfile << std::setw(4) << std::left << binType;
1123 
1124 
1125  int width = vol.getDimension()*10 + 10;
1126 
1127  myfile << std::setw(width) << std::left << cube.getLowCorner() << std::setw(width) << std::left << cube.getHighCorner();
1128 
1129  if (isBin){
1130  myfile << std::setw(10) << std::left << content;
1131  if (incError) myfile << std::setw(10) << std::left << error;
1132  }
1133 
1134  if (!isBin){
1135  for (unsigned j = 0; j < linkedBins.size(); j++){
1136  myfile << std::setw(10) << std::left << linkedBins.at(j);
1137  }
1138  }
1139 
1140  myfile << std::endl;
1141  }
1142 
1143  myfile.close();
1144 
1145 
1146 }
1147 
1148 void HyperHistogram::saveToTxtFileNoLinks(TString filename, bool incError) const{
1149 
1150  if ( _binning->getBinningType() != "HyperBinning" ){
1151  ERROR_LOG << "It is only possible to saveToTxtFile when using HyperBinning. Doing nothing." << std::endl;
1152  return;
1153  }
1154 
1155  const HyperBinning& hyperBinning = dynamic_cast<const HyperBinning&>( getBinning() );
1156 
1157  int nBins = hyperBinning.getNumBins();
1158 
1159  std::ofstream myfile;
1160  myfile.open (filename);
1161 
1162  for (int i = 0; i < nBins; i++ ){
1163  HyperVolume vol = hyperBinning.getBinHyperVolume(i);
1164  HyperCuboid cube = vol.getHyperCuboid(0);
1165  double content = getBinContent(i);
1166  double error = getBinError (i);
1167 
1168  int width = vol.getDimension()*10 + 10;
1169 
1170  myfile << std::setw(width) << std::left << cube.getLowCorner() << " " << std::setw(width) << std::left << cube.getHighCorner();
1171  myfile << " ";
1172  myfile << std::setw(10) << std::left << content;
1173  if (incError) myfile << std::setw(10) << std::left << error;
1174 
1175  myfile << std::endl;
1176  }
1177 
1178  myfile.close();
1179 
1180 
1181 }
1182 
1183 
1187 TString HyperHistogram::getBinningType(TString filename){
1188 
1189  TFile* file = new TFile(filename, "READ");
1190 
1191  if (file == 0){
1192  ERROR_LOG << "Could not open TFile in HyperBinning::load(" << filename << ")";
1193  return "";
1194  }
1195 
1196  TTree* tree = (TTree*)file->Get("HyperBinning");
1197 
1198  if (tree != 0){
1199  file->Close();
1200  return "HyperBinning";
1201  }
1202 
1203  file->Close();
1204  return "";
1205 
1206 }
1207 
1211 void HyperHistogram::load(TString filename, TString option){
1212 
1213  //If loading from a file, we first need to figure out what
1214  //type of binning is saved in that file.
1215 
1216  TString binningType = getBinningType(filename);
1217 
1218  if (binningType.Contains("HyperBinning")){
1219 
1220  if (_binning != 0) {
1221  delete _binning;
1222  _binning = 0;
1223  }
1224 
1225  if (option.Contains("DISK")) _binning = new HyperBinningDiskRes();
1226  else{
1227  _binning = new HyperBinningMemRes();
1228  }
1229 
1230  }
1231 
1232  if (binningType == ""){
1233  ERROR_LOG << "HyperHistogram::load - I could not find any binning scheme in this file" << std::endl;
1234  }
1235 
1236  _binning->load(filename, "READ");
1237  this->loadBase(filename);
1238 
1239 }
1240 
1241 void HyperHistogram::loadEmpty(TString filename, TString option, TString binningType){
1242 
1243  if (binningType.Contains("HyperBinning")){
1244 
1245  if (option.Contains("DISK")) _binning = new HyperBinningDiskRes();
1246  else{
1247  _binning = new HyperBinningMemRes();
1248  }
1249 
1250  }
1251  if (binningType == ""){
1252  ERROR_LOG << "HyperHistogram::loadEmpty - I could not find any binning scheme in this file" << std::endl;
1253  }
1254 
1255  _binning->load(filename, "RECREATE");
1256  this->resetBinContents(0);
1257 
1258 }
1262 double HyperHistogram::getBinVolume(int bin) const{
1263  return _binning->getBinHyperVolume(bin).volume();
1264 }
1265 
1270 
1271  bool diskResidentBinning = 0;
1272  TString filename = "";
1273 
1274  if (_binning != 0){
1275  diskResidentBinning = _binning->isDiskResident();
1276  filename = _binning->filename();
1277  delete _binning;
1278  _binning = 0;
1279  }
1280 
1281  if (diskResidentBinning){
1282 
1283  TFile *file = new TFile(filename, "update");
1284  std::string object_to_remove="HistogramBase";
1285  gDirectory->Delete(object_to_remove.c_str());
1286 
1287  saveBase();
1288 
1289  file->Close();
1290  }
1291 
1292  GOODBYE_LOG << "Goodbye from the HyperHistogram() Constructor";
1293 }
1294 
1295 
1296 /*
1297 void HyperHistogram::printOptimisationStatistics(){
1298 
1299  INFO_LOG << "With no optimisation we would perform " << _nIntegrationsWOtrick << " integrations";
1300  INFO_LOG << "In fact we only performed " << _nIntegrationsWtrick << " integrations";
1301  INFO_LOG << "This used approximately " << (_nIntegrationsWtrick/_nIntegrationsWOtrick)*100.0 << "% of time";
1302 
1303 }
1304 
1305 HyperPoint HyperHistogram::findAdaptiveSigma(const HyperPoint& point, const HyperPoint& sigmas) const{
1306 
1307  int nBins = _binning->getNumBins();
1308  int dim = _binning->getDimension();
1309 
1310  HyperPoint binWidthSum(dim, 0.0);
1311  double weightSum = 0.0;
1312 
1313  HyperPointSet points = makePointsAtGaussianExtremes(point, sigmas, 3.0);
1314  std::vector<int> binNumbers = _binning->getBinNumsContainingPoints(points);
1315  int nSelectedBins = binNumbers.size();
1316 
1317  _nIntegrationsWtrick += nSelectedBins;
1318  _nIntegrationsWOtrick += nBins;
1319 
1320 
1321  for (int i = 0; i < nSelectedBins; i++){
1322  double integral = intgrateGaussianOverBin(point, sigmas, binNumbers.at(i));
1323  HyperPoint width(dim, 0.0);
1324  for (int j = 0; j < dim; j++) width.at(j) = _binning->getBinHyperVolume(binNumbers.at(i)).getMax(j) - _binning->getBinHyperVolume(binNumbers.at(i)).getMin(j);
1325  width = width*integral;
1326  binWidthSum = binWidthSum + width;
1327  weightSum += integral;
1328  }
1329 
1330  double dimensionalityScale = pow(1.4, dim) - 1.0;
1331 
1332  //makes the ratio of weights between 1.0 and 2.0 sigma approximatly equal.
1333  //I hope this means the 'smoothing' is approximatly the same for any dimensonality.
1334 
1335  return binWidthSum/(weightSum*dimensionalityScale);
1336 
1337 }
1338 
1339 double HyperHistogram::adaptiveGaussianKernal(const HyperPoint& point, double smoothing ) const{
1340 
1341  int dim = point.getDimension();
1342 
1343  double dimensionalityScale = pow(1.4, dim) - 1.0;
1344  HyperPoint initalSigma = _binning->getAverageBinWidth()*(1.0/dimensionalityScale);
1345 
1346  //initalSigma.print();
1347 
1348  HyperPoint sigma = findAdaptiveSigma(point, initalSigma );
1349  sigma = sigma * smoothing;
1350 
1351  //sigma.print();
1352 
1353  return gaussianKernal(point, sigma );
1354 
1355 
1356 }
1357 
1358 
1359 double HyperHistogram::intgrateGaussianOverHyperCuboid(const HyperPoint& mean, const HyperPoint& sigmas, const HyperCuboid& cuboid) const{
1360 
1361  double multiInt = 1.0;
1362 
1363 
1364  for (int i = 0; i < cuboid.getDimension(); i++){
1365 
1366  double i_lowEdge = cuboid.getLowCorner ().at(i);
1367  double i_highEdge = cuboid.getHighCorner().at(i);
1368  double i_mean = mean .at(i);
1369  double i_sigma = sigmas.at(i);
1370 
1371  double low = (i_lowEdge - i_mean)/i_sigma;
1372  double high = (i_highEdge - i_mean)/i_sigma;
1373 
1374  if (high < -3.0 || low > 3.0) return 0.0;
1375 
1376  double integralHigh = TMath::Freq(high);
1377  double integralLow = TMath::Freq(low );
1378 
1379  multiInt *= (integralHigh - integralLow);
1380 
1381  }
1382 
1383  return multiInt;
1384 
1385 }
1386 
1387 double HyperHistogram::intgrateGaussianOverHyperVolume(const HyperPoint& point, const HyperPoint& sigmas, const HyperVolume& volume) const{
1388 
1389  double nCuboids = volume.getHyperCuboids().size();
1390 
1391  double multiInt = 0.0;
1392 
1393  for (int i = 0; i < nCuboids; i++){
1394  multiInt += intgrateGaussianOverHyperCuboid(point, sigmas, volume.getHyperCuboid(i));
1395  }
1396 
1397  return multiInt;
1398 
1399 }
1400 
1401 double HyperHistogram::intgrateGaussianOverBin(const HyperPoint& point, const HyperPoint& sigmas, int bin) const{
1402 
1403  return intgrateGaussianOverHyperVolume( point, sigmas, _binning->getBinHyperVolume(bin) );
1404 }
1405 
1406 HyperPointSet HyperHistogram::makePointsAtGaussianExtremes(const HyperPoint& mean, const HyperPoint& widths, double numSigma) const{
1407 
1408  int dim = mean.getDimension();
1409  HyperPointSet points(dim);
1410 
1411  for (int i = 0; i < dim; i++){
1412 
1413  double max = _binning->getMax(i);
1414  double min = _binning->getMin(i);
1415 
1416  double sigma = widths.at(i);
1417 
1418  HyperPoint low (mean);
1419  HyperPoint high(mean);
1420  low .at(i) -= sigma*numSigma;
1421  high.at(i) += sigma*numSigma;
1422 
1423  if (low .at(i) < min) low .at(i) = min + (max-min)*0.00001;
1424  if (high.at(i) > max) high.at(i) = max - (max-min)*0.00001;
1425 
1426  points.push_back(low );
1427  points.push_back(high);
1428  }
1429 
1430  return points;
1431 
1432 }
1433 
1434 double HyperHistogram::gaussianKernal(const HyperPoint& point, const HyperPoint& sigmas) const{
1435 
1436  int nBins = _binning->getNumBins();
1437 
1438  HyperPointSet points = makePointsAtGaussianExtremes(point, sigmas, 3.0);
1439  std::vector<int> binNumbers = _binning->getBinNumsContainingPoints(points);
1440  int nSelectedBins = binNumbers.size();
1441 
1442  _nIntegrationsWtrick += nSelectedBins;
1443  _nIntegrationsWOtrick += nBins;
1444  //std::cout << "Total of " << nBins << " nbins, but have selected only " << nSelectedBins << " for kernal." << std::endl;
1445 
1446  double sumW = 0.0;
1447  double sum = 0.0;
1448 
1449  for (int i = 0; i < nSelectedBins; i++){
1450  double integral = intgrateGaussianOverBin( point, sigmas, binNumbers.at(i) );
1451  double val = getBinContent(binNumbers.at(i));
1452  sumW += integral;
1453  sum += val*integral;
1454  }
1455 
1456  if (sumW == 0.0) {
1457  std::cout << "Sum of integrals is :" << sumW << std::endl;
1458  std::cout << "POINT: "; point.print();
1459  std::cout << "SIGMA: "; sigmas.print();
1460  }
1461  return sum/sumW;
1462 
1463 }
1464 
1465 std::vector<int> HyperHistogram::findNHighestContributingKernalBins(const HyperPoint& point, const HyperPoint& sigmas, int n) const{
1466 
1467  int nBins = _binning->getNumBins();
1468 
1469  double* integrals = new double [nBins];
1470  int * index = new int [nBins];
1471 
1472  for (int i = 0; i < nBins; i++){
1473  double integral = intgrateGaussianOverBin(point, sigmas, i);
1474  integrals[i] = integral;
1475  index [i] = i;
1476  }
1477 
1478  TMath::Sort(nBins, integrals, index, true);
1479 
1480  std::vector<int> nearest;
1481 
1482  for (int i = 0; i < n; i++){
1483  nearest.push_back( index[i] );
1484  }
1485 
1486  delete integrals;
1487  delete index;
1488 
1489  return nearest;
1490 
1491 }
1492 
1493 void HyperHistogram::reweightDatasetWithAdaptiveGaussianKernal(HyperPointSet& points, double smoothing) const{
1494 
1495  int npoints = points.size();
1496 
1497  for (int i = 0; i < npoints; i++){
1498 
1499  //SAM::printInterationStatus(i, npoints);
1500 
1501  HyperPoint& point = points.at(i);
1502 
1503  double val = this->adaptiveGaussianKernal(point, smoothing);
1504 
1505  int nW = point.numWeights();
1506 
1507  for (int w = 0; w < nW; w++){
1508  double oldW = point.getWeight(w);
1509  double newW = oldW*val;
1510  point.setWeight(w, newW);
1511  }
1512 
1513  if (nW == 0) point.addWeight(val);
1514 
1515 
1516 
1517  }
1518 
1519 }
1520 
1521 */
1522 
1523 
void loadBase(TString filename)
virtual bool isDiskResident() const
Definition: BinningBase.cpp:54
double getMax(int dimension) const
Definition: BinningBase.cpp:46
virtual TString filename() const
Definition: BinningBase.cpp:57
bool isPrimaryVolume(int volumeNumber) const
virtual void draw(TString path="", TString option="")
int getDimension() const
double getBinError(int bin) const
int getNBins() const
Definition: HistogramBase.h:63
void setNames(HyperName names)
Definition: BinningBase.cpp:21
virtual void load(TString filename, TString option="READ")=0
HyperName getNames() const
Definition: BinningBase.cpp:25
virtual void mergeBinnings(const BinningBase &other)=0
HyperPoint getRandomPoint(TRandom *random=gRandom) const
void loadEmpty(TString filename, TString option="MEMRES READ", TString binningType="HyperBinning")
void draw(TString path, TString options="")
#define INFO_LOG
void drawDensity(TString path, TString options="")
virtual bool addHyperVolume(const HyperVolume &hyperVolume, std::vector< int > linkedVolumes=std::vector< int >(0, 0))=0
double getMin(int dimension) const
Definition: BinningBase.cpp:42
virtual BinningBase * clone() const =0
const HyperCuboid & at(int i) const
Definition: HyperVolume.h:55
virtual void merge(const HistogramBase &other)
int size() const
Definition: HyperVolume.h:60
std::vector< double > _binContents
Definition: HistogramBase.h:35
bool exists(const string &fname)
virtual void merge(const HistogramBase &other)
void push_back(const HyperCuboid &hyperCuboid)
void addAlgOption(AlgOption option)
Add an AlgOption which is passed to the binning algortihm.
virtual HyperVolume getHyperVolume(int volumeNumber) const =0
virtual void load(TString filename, TString option="READ")=0
void setBinError(int bin, double val)
std::vector< double > _sumW2
Definition: HistogramBase.h:36
#define ERROR_LOG
void setMin(double min)
Definition: HistogramBase.h:90
double volume() const
virtual std::vector< int > getLinkedHyperVolumes(int volumeNumber) const =0
double getBinContent(int bin) const
virtual int getNumHyperVolumes() const =0
TString getBinningType() const
Definition: BinningBase.cpp:50
void mergeBinsWithSameContent()
void setBinContent(int bin, double val)
virtual void draw(TString path="", TString option="")
double getMin() const
void draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint &slicePoint, TString options="") const
virtual void addPrimaryVolumeNumber(int volumeNumber)=0
void fillBase(int binNum, double weight)
virtual std::vector< int > getPrimaryVolumeNumbers() const
virtual int getNumBins() const =0
void plotWithRatio(TString plotDirectory, TString plotOptions="", TPad *pad=0)
void drawRandom2DSlice(TString path, TRandom *random=gRandom, TString options="") const
const int & getDimension() const
Definition: HyperCuboid.h:45
HyperHistogram * getHyperBinningHistogram() const
void drawProjection(TString path, int dim=0, int bins=100) const
HyperBinningMaker * getHyperBinningMaker(HyperCuboid binningRange, HyperPointSet points)
virtual HyperVolume getBinHyperVolume(int binNumber) const
void setMax(double max)
Definition: HistogramBase.h:91
const HyperPoint & at(int i) const
virtual int getBinNum(const HyperPoint &coords) const =0
void setMin(double min)
Definition: Plotter.h:153
void useDensity(bool val)
void draw2DSlice(TString path, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, TString options="") const
virtual void save(TString filename) const =0
const int & getDimension() const
Definition: HyperVolume.h:44
double getMax() const
void resetBinContents(int nBins)
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
virtual void draw(TString path="", TString option="")
HyperHistogram & operator=(const HyperHistogram &other)
void drawAllProjections(TString path, int bins) const
void setNames(HyperName names)
virtual void plot(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)
BinningBase * _binning
void printFull() const
virtual void makeBinning()=0
const TString & at(int dim) const
Definition: HyperName.h:50
int fill(const HyperPoint &coords, double weight)
#define GOODBYE_LOG
void reserveCapacity(int nElements)
const int & getDimension() const
Definition: BinningBase.cpp:30
double volume() const
void print(std::ostream &os=std::cout, int endline=1) const
Definition: HyperCuboid.cpp:99
HyperCuboid getLimits() const
virtual double getVal(const HyperPoint &point) const =0
const double & at(int i) const
Definition: HyperPoint.cpp:433
void setContentsFromFunc(const HyperFunction &func)
void project(TH1D *histogram, const HyperCuboid &cuboid, double content, int dimension) const
virtual double getVal(const HyperPoint &point) const
virtual void reserveCapacity(int nElements)
Definition: BinningBase.cpp:61
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
int estimateCapacity(std::vector< TString > filename, TString binningType)
unsigned int size() const
#define WELCOME_LOG
void add(TObject *histogram)
Definition: Plotter.cpp:122
virtual int getNumBins() const
virtual ~HyperHistogram()
const BinningBase & getBinning() const
double getWeight(int i=0) const
Definition: Weights.cpp:40
void setFuncLimits(const HyperCuboid &limits)
const HyperCuboid & getFuncLimits() const
Definition: HyperFunction.h:44
HyperVolume slice(const HyperPoint &coords, std::vector< int > dims) const
void save(TString filename)
int getBinNum(int volumeNumber) const
void compareProjection(TString path, int dim, const HyperHistogram &other, int bins=100) const
void load(TString filename, TString option="MEMRES READ")
virtual double getBinVolume(int bin) const
HyperName getNames() const
const HyperCuboid & getHyperCuboid(int i) const
Definition: HyperVolume.h:54
void saveToTxtFileNoLinks(TString filename, bool incError=true) const
int getDimension() const
Definition: HyperPoint.h:99
HyperPoint getAverageCenter() const
virtual HyperCuboid getLimits() const =0
void compareAllProjections(TString path, const HyperHistogram &other, int bins=100) const
TString getBinningType(TString filename)
virtual bool addHyperVolume(const HyperVolume &hyperVolume, std::vector< int > linkedVolumes=std::vector< int >(0, 0))
void push_back(const HyperPoint &point)
virtual HyperVolume getBinHyperVolume(int binNumber) const =0
HyperHistogram slice(std::vector< int > sliceDims, const HyperPoint &slicePoint) const
void saveToTxtFile(TString filename, bool incError=true) const