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->…") | |||
| Line 1: | Line 1: | ||
| − | |||
| int VzDiffDoubleBump() | int VzDiffDoubleBump() | ||
| { | { | ||
| 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)"); | ||
Revision as of 18:20, 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");
 //clas12->Draw("GenPart.z - Event.z >> (120,-6,6)","sqrt(GenPart.x*GenPart.x+GenPart.y*GenPart.y)<0.05 && sqrt(GenPart.x*GenPart.x+GenPart.y*GenPart.y)>0.0 && GenPart.z = 0");                         
char cut[600]; char hist_title[600]; char file_title[600]; //float Zmin = 0; float Zmax= 0; float r = 0; c1 = new TCanvas();
//gStyle -> SetOptFit(1111); 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;
 //break;                                                                                                                                                                                                
       }
     //break;                                                                                                                                                                                            
   }
 //tree -> Project("h1","GenPart.z - Event.z","sqrt(GenPart.x*GenPart.x + GenPart.y*GenPart.y)>0.0 && sqrt(GenPart.x*GenPart.x + GenPart.y*GenPart.y)<0.05 && GenPart.z = 0");                           
return 1;
}