#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void thresh_effective(void) { TFile *f = new TFile("hd_root.root"); f->cd(); TTree *tree = (TTree*)gROOT->FindObject("tree"); TH1D *h_cut[4]; TH1D *h_not[4]; int colors[] = {kRed, kGreen, kMagenta, kBlue}; for(int ilayer=1; ilayer<=4; ilayer++){ //for(int ilayer=1; ilayer<=1; ilayer++){ char hname1[256]; char hname2[256]; sprintf(hname1, "Etot_layer%d_with_thresh", ilayer); sprintf(hname2, "Etot_layer%d_no_thresh", ilayer); TH1D *h1 = new TH1D(hname1, "", 100, 0.0, 200.0); TH1D *h2 = (TH1D*)h1->Clone(hname2); char str[256]; sprintf(str, "layer==%d && Etot>0.0", ilayer); TCut cut1(str); TCut cut2("tup>-100 && tdn>-100"); tree->Project(hname1, "Etot", cut1+cut2); tree->Project(hname2, "Etot", cut1); //tree->Project(hname1, "geometric_mean", cut1+cut2); //tree->Project(hname2, "geometric_mean", cut1); h1->SetLineColor(colors[ilayer-1]); h1->SetFillColor(colors[ilayer-1]); h1->SetFillStyle(3001); h2->SetLineColor(colors[ilayer-1]); h_cut[ilayer-1] = h1; h_not[ilayer-1] = h2; } // Make canvas and split it into 4 sections TCanvas *c1 = new TCanvas("c1", "", 600, 900); c1->Divide(1,4); // Loop over layers displaying each for(int ilayer=1; ilayer<=4; ilayer++){ cout<<"Drawing layer "<cd(ilayer); gPad->SetTicks(); gPad->SetGrid(); TH1D *h1 = h_cut[ilayer-1]; TH1D *h2 = h_not[ilayer-1]; double scale = 4.0*h2->Integral()/h1->Integral(); h1->GetYaxis()->SetRangeUser(10.0, scale*h1->GetMaximum()); gPad->SetLogy(); char title[256]; sprintf(title, "Energy deposition per cell layer %d", ilayer); h1->SetTitle(title); h1->SetStats(0); h1->SetXTitle("Energy deposited (MeV)"); h1->Draw(); h2->Draw("same"); cout<<"Done."<SaveAs("thresh_effective.png"); c1->SaveAs("thresh_effective.pdf"); }