void makeHistos() { // open a root file TFile * file = new TFile("histo.root","recreate"); // Create some histograms. TH1F *total = new TH1F("total","This is the total distribution",100,-4,4); TH1F *main = new TH1F("main","Main contributor",100,-4,4); TH1F *s1 = new TH1F("s1","This is the first signal",100,-4,4); TH1F *s2 = new TH1F("s2","This is the second signal",100,-4,4); //opzioni grafiche istogrammi total->SetMarkerStyle(21); total->SetMarkerSize(0.7); main->SetFillColor(16); s1->SetFillColor(42); s2->SetFillColor(46); // start benchmarking execution time gBenchmark->Start("makeHistos"); // Fill histograms randomly gRandom->SetSeed(); // setting the initial seed const Float_t weight = 1.; Float_t xs1, xs2, xmain; for ( Int_t i=0; i<10000; i++) { xmain = gRandom->Gaus(-1,1.5); xs1 = gRandom->Gaus(-0.5,0.5); xs2 = gRandom->Landau(1,0.15); //filling istogrammi main->Fill(xmain); s1->Fill(xs1,weight); // entries "pesate" s2->Fill(xs2,weight); // entries "pesate" //istogramma della distribuzione globale total->Fill(xmain); total->Fill(xs1,weight); total->Fill(xs2,weight); } //stop benchmarking execution time gBenchmark->Stop("makeHistos"); gBenchmark->Print("makeHistos"); gBenchmark->Reset(); // write histos to the ROOT file main->Write(); s1->Write(); s2->Write(); total->Write(); // close the file file->Close(); }