void example(){ gStyle->SetHistLineWidth(2); //create the tree TTree *tree = new TTree("exampleTree", "example"); TObjString string1; TObjString string2; TObjString string3; float parameter=0; tree->Branch("string1", &string1); tree->Branch("parameter", ¶meter, "parameter/F"); gRandom->SetSeed(1); //fill the tree randomly (but with a fixed seed) for (unsigned i=0; i<1000; i++){ if(gRandom->Rndm()<0.7) string1="case1"; else if (gRandom->Rndm()<0.5) string1="case2"; else if (gRandom->Rndm()<0.3) string1="case3"; else if(gRandom->Rndm()<0.05) string1="case4"; parameter=gRandom->Rndm(); tree->Fill(); } // draw the parameter tree->Draw("string1.String()>>h1"); // now redraw but with a cut - all bins should be less or equal tree->Draw("string1.String()>>h2", "parameter<0.5", "same"); //make the second histogram red TH1F *h2 = (TH1F*)gPad->GetListOfPrimitives()->FindObject("h2"); if(h2) h2->SetLineColor(2); //update gPad->Modified(); gPad->Update(); }