Difference between revisions of "Code For Histograms Below"
Jump to navigation
Jump to search
(Created page with " int VzDiffDoubleBump() { TFile *file = new TFile("eg12_sol_75k_2cm_XYRaster_6cm_ZRaster_30DegRot_rec_cat.root"); TTree *tree = (TTree*) file->Get("clas12"); //clas12->…") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
int VzDiffDoubleBump() | int VzDiffDoubleBump() | ||
{ | { | ||
Line 8: | Line 7: | ||
− | + | ||
char cut[600]; | char cut[600]; | ||
char hist_title[600]; | char hist_title[600]; | ||
char file_title[600]; | char file_title[600]; | ||
− | + | ||
float Zmax= 0; | float Zmax= 0; | ||
float r = 0; | float r = 0; | ||
c1 = new TCanvas(); | c1 = new TCanvas(); | ||
− | + | ||
gROOT -> SetBatch(1); | gROOT -> SetBatch(1); | ||
Line 34: | Line 33: | ||
TH1F *h1 = new TH1F("h1","h1",120,-6,6); | TH1F *h1 = new TH1F("h1","h1",120,-6,6); | ||
− | + | tree -> Project("h1","GenPart.z - Event.z",cut); | |
− | |||
h1->GetXaxis()->SetTitle("GenPart.x - Event.x (cm)"); | h1->GetXaxis()->SetTitle("GenPart.x - Event.x (cm)"); | ||
Line 53: | Line 51: | ||
delete h1; | delete h1; | ||
− | + | ||
} | } | ||
− | + | ||
} | } | ||
− | + | ||
Latest revision as of 19:26, 7 October 2016
int VzDiffDoubleBump() {
TFile *file = new TFile("eg12_sol_75k_2cm_XYRaster_6cm_ZRaster_30DegRot_rec_cat.root"); TTree *tree = (TTree*) file->Get("clas12");
char cut[600]; char hist_title[600]; char file_title[600]; float Zmax= 0; float r = 0; c1 = new TCanvas();
gROOT -> SetBatch(1);
for(float Zmin = -3.0;Zmin<3.0;Zmin +=0.25) { for(float r = 0; r<1.0;r+=0.1) { Zmax = Zmin + 0.25;
sprintf(cut,"sqrt(GenPart.x*GenPart.x + GenPart.y*GenPart.y)>%.2f && sqrt(GenPart.x*GenPart.x + GenPart.y*GenPart.y)<%.2f && GenPart.z > %.2f && GenPart.z<%.2f",r,r+0.1,Zmin,Zmax);
sprintf(hist_title,"Vz Difference, %.2f<R<%.2f , %.2f < Z < %.2f",r,r+0.1,Zmin,Zmax);
sprintf(file_title,"VzDiff_%.2f<R<%.2f_%.2f<Z<%.2f.png",r,r+0.1,Zmin,Zmax);
TH1F *h1 = new TH1F("h1","h1",120,-6,6); tree -> Project("h1","GenPart.z - Event.z",cut);
h1->GetXaxis()->SetTitle("GenPart.x - Event.x (cm)");
h1 -> GetYaxis() -> SetTitle("Counts");
h1 -> GetYaxis() -> SetTitleOffset(1.5); h1 -> Fit("gaus"); cout << cut << endl; h1 -> Draw();
h1 -> SetTitle(hist_title); gStyle -> SetOptFit(1111); c1 -> SaveAs(file_title);
delete h1; } }
return 1;
}