void ProduceTree(double measure, opt_binary_region root, unordered_map<vector<string>, opt_binary_region, hasher>& known, unordered_map<vector<string>, double, hasher>& Tree, deque<binary_region >& b_r_Partition,  double OPTerV, bool flag_rand){
		
		pair<int, int> OnePartition;
		double Precise2 = pow(0.5, 30); 

		unordered_map<vector<string>, opt_binary_region, hasher>::iterator itr = known.find(root.code);
		int partdf = itr->second.postpart;
		if( partdf==-1 || (!flag_rand && itr->second.postrou > 0.5) || (flag_rand && rand_double()<itr->second.postrou) ){ 
			double density = measure/itr->second.area();
			Tree[root.code] = density;
			if(root.area() > OPTerV-Precise2) {
				binary_region b_r_region;
				b_r_region.dim = root.dim;
				b_r_region.code =  root.code;
				b_r_region.samples =  root.samples;
				b_r_region.ranges =  root.ranges;
				b_r_Partition.push_back(b_r_region);
				
			}
			return;
		}
		if(root.area() < OPTerV*2.0-Precise2 && root.area() > OPTerV-Precise2 ){
			binary_region b_r_region;
			b_r_region.dim = root.dim;
			b_r_region.code =  root.code;
			b_r_region.samples =  root.samples;
			b_r_region.ranges =  root.ranges;
			b_r_Partition.push_back(b_r_region);
		}


		opt_binary_region son1, son2;
		son1 = root;
		son2 = root;
		double middle = (root.ranges[partdf].first + root.ranges[partdf].second)/2;
		son1.ranges[partdf].second = son2.ranges[partdf].first = middle;
		son1.code[partdf] = son1.code[partdf]+"0";
		son2.code[partdf] = son2.code[partdf]+"1";
		
		PtsInReg2sons(son1,son2, root.samples, son1.samples, son2.samples);

		
		int num1 = (int)son1.samples.data.size();
		int num2 = (int)son2.samples.data.size();

		ProduceTree(measure * (num1+0.5) /(num1+num2+1), son1, known, Tree, b_r_Partition,OPTerV, flag_rand);
		
		ProduceTree(measure * (num2+0.5) /(num1+num2+1), son2,  known, Tree, b_r_Partition, OPTerV, flag_rand);
		return;
}
Esempio n. 2
0
void RunTest(const char* name, int numentries, int BufferSize) {
   char title[200];
   sprintf(title, "%d events, 10 branches, 10 floats in brunch, Basket size = %d", numentries, BufferSize*sizeof(Float_t)*10);

   TH1D* histoRes = new TH1D(name, title, 10, 0.5, 10.5);
   histoRes->GetXaxis()->SetTitle("Number of active branches");
   histoRes->GetYaxis()->SetTitle("Real time (s)");
   histoRes->SetDirectory(0);
   histoRes->SetStats(kFALSE);
   ProduceTree("TreeFile.root","TestTree", numentries, 0, 10, 10, BufferSize);

   Float_t RealTime, CpuTime;
    
   for(int ActiveBranches=1;ActiveBranches<=10;ActiveBranches++) {
      ReadDummyTree();
      cout << "Buffer size = " << BufferSize*sizeof(Float_t)*10 << " ActiveBranches = " << ActiveBranches << endl;
      MakeDelay(10);
      TestTree("TreeFile.root","TestTree", 10, 10, ActiveBranches, &RealTime, &CpuTime);
      histoRes->SetBinContent(ActiveBranches, RealTime);
   } 
   
   TCanvas* c1 = new TCanvas(TString(name)+"_canvas", title);
   histoRes->Draw();
   c1->SaveAs(TString(name)+".gif");
}
Esempio n. 3
0
void ProduceDummyTree() {
   const int RAMSIZE = 2048;
   
   // file size is double of memory size
   int numentries = RAMSIZE * 2500 * 2;  

   ProduceTree("DummyFile.root","DummyTree", numentries, 0, 10, 10, 1000);
}