Hello Rooters,
I am trying to put two histos into an overlay on a canvas. They are both 3D, and things are getting a little flakey, but it is the best way to visualize my data set. In one histo, I have my main sample, and the second histo (drawn in red) are the events that get cut from the main sample. Because they are in a separate histo, the cut events are drawn with HUGE cubes compared to the main sample (cube size indicates number of events in 3d bin). Sample code is below, where the main sample cubes all have 20 events, cut sample has 1 event per cube. I want the single event cubes to be smaller than the 20 events, but no matter what I do, they are always the same size!
Am I doing something wrong? Please try the test code with “.x test.cpp(A)”, where A=1., 1000., 0., -1., etc. Nothing happens, you get the same plot every time.
void test(double maxToSet=0.){
TH3F *h1=new TH3F("h1","main sample",10,0.,10.,10,0.,10.,10,0.,10.);
for (int i=0; i<20; ++i) {
h1->Fill(2.,3.,3.);
h1->Fill(2.,7.,3.);
h1->Fill(2.,3.,5.);
}
h1->Fill(2.0,1.0,1.0); // a little bin for contrast! Red bins should be this size.
TH3F *h2=new TH3F("h2","cut sample",10,0.,10.,10,0.,10.,10,0.,10.);
h2->Fill(8.,3.,3.);
h2->Fill(8.,7.,3.);
h2->SetMarkerColor(2);
if (maxToSet>0.0){
cout<<"Setting max to "<<maxToSet<<" from "<<h2->GetMaximum();
h2->SetMaximum(maxToSet);
cout<<" and now it is "<<h2->GetMaximum()<<endl;
}
if (maxToSet<0.0){
cout<<"Setting max to "<<h1->GetMaximum()<<" from "<<h2->GetMaximum();
h2->SetMaximum(h1->GetMaximum());
cout<<" and now it is "<<h2->GetMaximum()<<endl;
}
TCanvas *c1=new TCanvas("c1","c1",600.,600.);
h1->Draw("box fb bb");
h2->Draw("same box fb bb ");
}
I’m using ROOT 5.34/34 in Windows.
- John