7 _averageBinWidth(getDimension()),
11 WELCOME_LOG <<
"Hello from the HyperBinning() Constructor";
66 if (
getLimits().inVolume(coords) == 0)
return -1;
76 int volumeNumber = -1;
80 if (inVol == 1) { volumeNumber = i;
break; }
83 if (volumeNumber == -1)
return -1;
91 int primaryVolumeNumber = -1;
93 for (
int i = 0; i < nPrimVols; i++){
96 if (inVol == 1) { primaryVolumeNumber = thisVolNum;
break; }
99 int volumeNumber = -1;
105 ERROR_LOG <<
"This primary volume has NO links. Not what I expect!!" << std::endl;
125 bool printInfo =
false;
127 INFO_LOG <<
"Since this is a large (>2x10^6) disk resident HyperBinning, I'm going to give you information on this HyperBinning::getBinNum(const HyperPointSet& coords)" << std::endl;
132 int nCoords = coords.
size();
134 INFO_LOG <<
"Sorting " << nCoords <<
" HyperPoints into bins" << std::endl;
141 std::vector<int> binNumberSet(nCoords, -2);
142 std::vector< std::vector<int> > linkedVolsSet(nCoords, std::vector<int>() );
144 for (
unsigned i = 0; i < linkedVolsSet.size(); i++){
145 linkedVolsSet.at(i).reserve(2);
156 INFO_LOG <<
"I'm looping over all " << nPrimVols <<
" primary volumes, and seeing what events fall into each" << std::endl;
159 for (
int voli = 0; voli < nPrimVols; voli++){
165 for (
int i = 0; i < nCoords; i++){
167 if ( linkedVolsSet.at(i).size() != 0 )
continue;
170 linkedVolsSet.at(i).push_back(volNum);
180 for (
int i = 0; i < nCoords; i++){
182 if (linkedVolsSet.at(i).size() == 0){
183 binNumberSet.at(i) = -1;
204 INFO_LOG <<
"I'm now looping over all " << nVolumes <<
" volumes, and seeing what events fall into each." << std::endl;
205 INFO_LOG <<
"This could take a while with " << nCoords <<
" so I'll give you a handy loading bar." << std::endl;
210 for (
int voli = 0; voli < nVolumes; voli++){
218 bool anyLinks = (links.size() != 0);
220 for (
int i = 0; i < nCoords; i++){
222 int& binNum = binNumberSet[i];
225 if (binNum >= -1)
continue;
228 std::vector<int>& linkedVols = linkedVolsSet.at(i);
229 int nLinkedVols = linkedVols.size();
233 if (nLinkedVols != 0){
235 for (
int j = 0; j < nLinkedVols; j++){
236 if (linkedVols.at(j) == voli) {doCheck =
true;
break;}
240 if (doCheck ==
false)
continue;
244 if (anyLinks ==
false){
259 for (
int i = 0; i < nCoords; i++){
261 if (binNumberSet.at(i) == -2){
262 binNumberSet.at(i) = -1;
283 bool printInfo =
false;
285 INFO_LOG <<
"Since this is a large (>2x10^6) disk resident HyperBinning, I'm going to give you information on this HyperBinning::getBinNum(const HyperPointSet& coords)" << std::endl;
289 int nCoords = coords.
size();
292 INFO_LOG <<
"Sorting " << nCoords <<
" HyperPoints into bins" << std::endl;
299 std::vector<int> binNumberSet(nCoords, -1);
300 std::vector< std::vector<int> > binsInVol(nVolumes, std::vector<int>() );
309 INFO_LOG <<
"I'm looping over all " << nPrimVols <<
" primary volumes, and seeing what events fall into each" << std::endl;
312 for (
int voli = 0; voli < nPrimVols; voli++){
318 for (
int i = 0; i < nCoords; i++){
321 binsInVol.at(volNum).push_back(i);
329 INFO_LOG <<
"I'm now looping over all " << nVolumes <<
" volumes, and seeing what events fall into each." << std::endl;
330 INFO_LOG <<
"This could take a while with " << nCoords <<
" so I'll give you a handy loading bar." << std::endl;
335 for (
int voli = 0; voli < nVolumes; voli++){
341 int nBinsInVol = binsInVol.at(voli).size();
343 if (nBinsInVol == 0)
continue;
347 int numLinks = links.size();
349 for (
int i = 0; i < nBinsInVol; i++){
351 int coordNum = binsInVol.at(voli).at(i);
360 for (
int j = 0; j < numLinks; j++){
361 binsInVol.at(links.at(j)).
push_back(coordNum);
382 for (
int i = 0; i < nPrimVols; i++){
403 int volumeNumber = -1;
406 for (
unsigned i = 0; i < linkedVolumes.size(); i++){
407 int daughBinNum = linkedVolumes.at(i);
409 if (inVol == 1) { volumeNumber = daughBinNum;
break; }
412 if (volumeNumber == -1) {
413 ERROR_LOG <<
"The trail of linked bins has gone cold!";
486 _binNum = std::vector<int>(nVolumes, -1);
490 INFO_LOG <<
"Since this is a large (>2x10^6) disk resident HyperBinning, I'm going to give you information on this cache update." << std::endl;
491 INFO_LOG <<
"I'm currently updating the bin numbering that lets me quickly associate volumes to bins and vice versa..." << std::endl;
521 INFO_LOG <<
"Finished!" << std::endl;
544 INFO_LOG <<
"Since this is a large (>2x10^6) disk resident HyperBinning, I'm going to give you information on this cache update." << std::endl;
545 INFO_LOG <<
"I'm currently updating the average bin width by looping over all bin volumes" << std::endl;
553 for (
int j = 0; j < dim; j++) {
556 averageWidth.
at(j) += (max - min);
575 for (
int d = 0; d < dim; d++){
585 INFO_LOG <<
"Since this is a large (>2x10^6) disk resident HyperBinning, I'm going to give you information on this cache update." << std::endl;
586 INFO_LOG <<
"I'm currently determining the limits of this histogram by looping over all bin volumes" << std::endl;
591 for (
int d = 0; d < dim; d++){
603 for (
int d = 0; d < dim; d++){
644 ERROR_LOG <<
"You can only merge a HyperBinning with another HyperBinning" << std::endl;
648 const HyperBinning& otherHyperBinning = dynamic_cast<const HyperBinning&>(other);
658 for (
int i = 0; i < nVolumesOther; i++){
663 for (
unsigned int j = 0; j < linkedVolumes.size(); j++){
664 linkedVolumes.at(j) += nVolumes;
672 for (
int i = 0; i < nPrimaryBinsOther; i++){
674 primaryVolumeNumber += nVolumes;
694 ERROR_LOG <<
"Invalid tree in HyperBinning::getDimension(TTree* tree)" << std::endl;
698 TString branchName =
"lowCorner_0";
701 while ( tree->GetListOfBranches()->FindObject(branchName) != 0 ){
703 branchName =
"lowCorner_";
708 ERROR_LOG <<
"I cannot find any branches in the tree that indicate a HyperBinning is stored here" << std::endl;
721 tree->Branch(
"binNumber", binNumber);
722 tree->Branch(
"linkedBins",
"vector<int>" ,linkedBins);
724 TString lowCornerName =
"lowCorner_"; lowCornerName += i;
725 TString highCornerName =
"highCorner_"; highCornerName += i;
726 tree->Branch(lowCornerName, lowCorner + i);
727 tree->Branch(highCornerName, highCorner + i);
736 for(
int i = 0; i < hyperVolume.
size(); i++){
740 for (
int dim = 0; dim <
getDimension(); dim++) lowCorner [dim] = lowCornerVect .at(dim);
741 for (
int dim = 0; dim <
getDimension(); dim++) highCorner[dim] = highCornerVect.
at(dim);
751 TTree* tree =
new TTree(
"PrimaryVolumeNumbers",
"PrimaryVolumeNumbers");
754 ERROR_LOG <<
"Could not open TTree in HyperBinningMemRes::save()";
759 int volumeNumber = -1;
761 tree->Branch(
"volumeNumber", &volumeNumber);
766 for(
int i = 0; i < nPrimVols; i++ ){
779 TFile* file =
new TFile(
filename,
"RECREATE");
782 ERROR_LOG <<
"Could not open TFile in HyperBinningMemRes::save(" <<
filename <<
")";
799 TTree* tree =
new TTree(
"HyperBinning",
"HyperBinning");
802 ERROR_LOG <<
"Could not open TTree in HyperBinningMemRes::save()";
810 std::vector<int>* linkedBins =
new std::vector<int>();
813 createBranches(tree, &binNumber, lowCorner, highCorner, &linkedBins);
832 std::vector<int> primaryVolumeNumbers;
834 primaryVolumeNumbers.reserve(nPrimVols);
836 for (
int i = 0; i < nPrimVols; i++){
839 return primaryVolumeNumbers;
848 GOODBYE_LOG <<
"Goodbye from the HyperBinning() Constructor";
virtual bool isDiskResident() const
virtual TString filename() const
bool isPrimaryVolume(int volumeNumber) const
HyperBinning()
The only constructor.
CachedVar< std::vector< int > > _hyperVolumeNumFromBinNum
void saveHyperVolumeToTree(TTree *tree, double *lowCorner, double *highCorner, const HyperVolume &hyperVolume) const
int getHyperBinningDimFromTree(TTree *tree)
virtual void mergeBinnings(const BinningBase &other)
int followBinLinks(const HyperPoint &coords, int binNumber) const
virtual bool addHyperVolume(const HyperVolume &hyperVolume, std::vector< int > linkedVolumes=std::vector< int >(0, 0))=0
double getMin(int dimension) const
void updateMinMax() const
virtual void reserveCapacity(int nElements)
virtual HyperVolume getHyperVolume(int volumeNumber) const =0
bool inVolume(const HyperPoint &coords) const
virtual std::vector< int > getLinkedHyperVolumes(int volumeNumber) const =0
virtual int getNumHyperVolumes() const =0
TString getBinningType() const
virtual void addPrimaryVolumeNumber(int volumeNumber)=0
virtual void setDimension(int dimension)
virtual std::vector< int > getPrimaryVolumeNumbers() const
virtual HyperPoint getAverageBinWidth() const
virtual HyperVolume getBinHyperVolume(int binNumber) const
const HyperPoint & at(int i) const
void createBranches(TTree *tree, int *binNumber, double *lowCorner, double *highCorner, std::vector< int > **linkedBins) const
CachedVar< std::vector< int > > _binNum
virtual void save() const
void setBinningType(TString binningType)
void savePrimaryVolumeNumbers() const
const HyperPoint & getHighCorner() const
void updateAverageBinWidth() const
virtual HyperCuboid getLimits() const
const int & getDimension() const
std::vector< int > getBinNumAlt(const HyperPointSet &coords) const
virtual int getNumPrimaryVolumes() const =0
CachedVar< HyperCuboid > _minmax
const double & at(int i) const
const HyperPoint & getLowCorner() const
unsigned int size() const
virtual int getNumBins() const
int getHyperVolumeNumber(int binNumber) const
virtual int getPrimaryVolumeNumber(int i) const =0
CachedVar< HyperPoint > _averageBinWidth
virtual void setDimension(int dim)
void updateBinNumbering() const
int getBinNum(int volumeNumber) const
void push_back(T &t, const typename T::value_type &a, const typename T::value_type &b, const typename T::value_type &c, const typename T::value_type &d)
const HyperCuboid & getHyperCuboid(int i) const
double getMax(int dimension) const