Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
makePlot_track_pscan.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file makePlot_track_pscan.C
1 int
3 {
4  gStyle->SetOptStat(0);
5 
6  TCut cut_primary( "gtrackID==1" );
7  TCut cut_eta( "abs( (-1*log( tan( atan2( sqrt(px*px+py*py), pz ) / 2.0 ) )) - (-1*log( tan( atan2( sqrt(gpx*gpx+gpy*gpy), gpz ) / 2.0 ) ) ) ) < 1 ");
8  TCut cut_p( "abs( sqrt(px*px+py*py+pz*pz) - sqrt(gpx*gpx+gpy*gpy+gpz*gpz) ) < 1" );
9 
10  vector< string > suffixes;
11  suffixes.push_back( "muon_10GeV_-2.5Eta" );
12  suffixes.push_back( "muon_11GeV_-2.5Eta" );
13  suffixes.push_back( "muon_12GeV_-2.5Eta" );
14  suffixes.push_back( "muon_13GeV_-2.5Eta" );
15  suffixes.push_back( "muon_14GeV_-2.5Eta" );
16  suffixes.push_back( "muon_15GeV_-2.5Eta" );
17  suffixes.push_back( "muon_16GeV_-2.5Eta" );
18  suffixes.push_back( "muon_17GeV_-2.5Eta" );
19  suffixes.push_back( "muon_18GeV_-2.5Eta" );
20  suffixes.push_back( "muon_19GeV_-2.5Eta" );
21  suffixes.push_back( "muon_1GeV_-2.5Eta" );
22  suffixes.push_back( "muon_20GeV_-2.5Eta" );
23  suffixes.push_back( "muon_21GeV_-2.5Eta" );
24  suffixes.push_back( "muon_22GeV_-2.5Eta" );
25  suffixes.push_back( "muon_23GeV_-2.5Eta" );
26  suffixes.push_back( "muon_24GeV_-2.5Eta" );
27  suffixes.push_back( "muon_25GeV_-2.5Eta" );
28  suffixes.push_back( "muon_26GeV_-2.5Eta" );
29  suffixes.push_back( "muon_27GeV_-2.5Eta" );
30  suffixes.push_back( "muon_28GeV_-2.5Eta" );
31  suffixes.push_back( "muon_29GeV_-2.5Eta" );
32  suffixes.push_back( "muon_2GeV_-2.5Eta" );
33  suffixes.push_back( "muon_30GeV_-2.5Eta" );
34  suffixes.push_back( "muon_3GeV_-2.5Eta" );
35  suffixes.push_back( "muon_4GeV_-2.5Eta" );
36  suffixes.push_back( "muon_5GeV_-2.5Eta" );
37  suffixes.push_back( "muon_6GeV_-2.5Eta" );
38  suffixes.push_back( "muon_7GeV_-2.5Eta" );
39  suffixes.push_back( "muon_8GeV_-2.5Eta" );
40  suffixes.push_back( "muon_9GeV_-2.5Eta" );
41 
42  TString base("../../data/data_trackeval_pscan/eval_track_fastsim_");
43 
44  vector< float > v_ptrue;
45  vector< float > v_deltap_sigma;
46  vector< float > v_deltap_over_p_sigma;
47 
48  for ( unsigned i = 0; i < suffixes.size(); i++ )
49  {
50  TString file = base;
51  file.Append( suffixes.at(i) );
52  file.Append(".root");
53 
54  TFile* fin = new TFile(file, "OPEN");
55  TTree *tin = (TTree*)fin->Get("tracks");
56 
57  TH1F* h_delta = new TH1F( "h_delta", "", 200, -1, 1 );
58  TH1F* h_delta_rel = new TH1F( "h_delta_rel", "", 200, -1, 1 );
59  TH1F* h_ptrue = new TH1F( "h_ptrue", "", 31, -0.5, 30 );
60 
61  tin->Draw("( sqrt(px*px+py*py+pz*pz) - sqrt(gpx*gpx+gpy*gpy+gpz*gpz) ) >> h_delta", cut_primary );
62  tin->Draw("( sqrt(px*px+py*py+pz*pz) - sqrt(gpx*gpx+gpy*gpy+gpz*gpz) ) / sqrt(gpx*gpx+gpy*gpy+gpz*gpz) >> h_delta_rel", cut_primary );
63  tin->Draw("sqrt(gpx*gpx+gpy*gpy+gpz*gpz) >> h_ptrue", cut_primary );
64 
65  v_ptrue.push_back( h_ptrue->GetMean() );
66  v_deltap_sigma.push_back( h_delta->GetRMS() );
67  v_deltap_over_p_sigma.push_back( h_delta_rel->GetRMS() );
68  }
69 
70  TGraphErrors *g1 = new TGraphErrors( v_ptrue.size(), &(v_ptrue[0]), &(v_deltap_over_p_sigma[0]) );
71 
72  TCanvas *c1 = new TCanvas();
73 
74  TH1F* hframe = new TH1F("hframe","",31,-0.5,30.5);
75  hframe->GetXaxis()->SetTitle("p_{true} (GeV)");
76  hframe->GetYaxis()->SetTitle("#sigma ( ( p_{reco} - p_{true} ) / p_{true} )");
77  hframe->GetYaxis()->SetRangeUser(0,0.15);
78  hframe->Draw();
79  g1->Draw("Psame");
80 
81 // TCanvas *c3 = new TCanvas();
82 // chain.Draw("( sqrt(px*px+py*py+pz*pz) - sqrt(gpx*gpx+gpy*gpy+gpz*gpz) ) / sqrt(gpx*gpx+gpy*gpy+gpz*gpz) : sqrt(gpx*gpx+gpy*gpy+gpz*gpz) >> h3(31, -0.5, 30.5, 50, -0.5, 0.5)", cut_primary, "colz");
83 // h3->GetXaxis()->SetTitle("#p_{true}");
84 // h3->GetYaxis()->SetTitle("( p_{reco} - p_{true} ) / p_{true}");
85 // c3->Print("plots/track_pscan_c3.eps");
86 
87  return 1;
88 }