//-*-mode:c++; mode:font-lock;-*- //Program to Test BuildIndex for Very large TTrees #include #include #include #include #include #include #include "TFile.h" #include "TROOT.h" #include "TObject.h" #include "TTree.h" #include "TBranch.h" #include "TTreeIndex.h" #include "TObject.h" #include "TRandom2.h" class KSRootPeData : public TObject // ******************************************************* // class to hold single pe's // ******************************************************* { public: KSRootPeData(); virtual ~KSRootPeData(); int fNx; // Grid coords (x,y) int fNy; double fTime; // Time of hit double fPhotonDl; // dl of photon double fPhotonDm; // dm of photon(dn can be recreated) int fSegmentID; // Segment identifier. double fX; // X position of hit in grid rectangle. double fY; // Y position of hit in grid rectangle. int fTrackType; // Type of emitting particle. int fLambda; // Wavelength of emmited photon(nm) double fEmissionAltitude;// emmison altitude ClassDef(KSRootPeData,1); }; const int kNumPeToMake=61000000; const int kNxNyMax=12000; int main(int argc, char** argv) { TRandom2* pran = new TRandom2(0); KSRootPeData* pfRootPe = new KSRootPeData(); TFile* pfTempTreeFile = (TFile*) new TFile("SortTempTreeFile.root", "RECREATE","Temoprary Sort ROOT file"); pfTempTreeFile->cd(); TTree* pfPeTree=new TTree("PeTree","Pe Tree"); pfPeTree->Branch("Pe","KSRootPeData",&pfRootPe,1000,0); //pfPeTree->Branch("Pe","KSRootPeData",&pfRootPe,1000,99); int nxmin=0; //If minimum is > 0 we don't care int nymin=0; int j=1000000; for(int i=0;ifNx=(int)(pran->Rndm(0)*2*kNxNyMax) - kNxNyMax; pfRootPe->fNy=(int)(pran->Rndm(0)*2*kNxNyMax) - kNxNyMax; if(pfRootPe->fNxfNx; } if(pfRootPe->fNyfNy; } pfPeTree->Fill(); if(i%j==0) { std::cout<<"i:"<Print(); int fNumEntries=pfPeTree->GetEntries(); std::cout<<"LargeTTreeTest: Number of PEs in tree: "<fNx + %i",nxoffset); char nyStr[80]; sprintf(nyStr,"Pe->fNy + %i",nyoffset); int fNumIndexes=pfPeTree->BuildIndex(nxStr,nyStr); //Ny varies fastest return 0; }