1 R__LOAD_LIBRARY(libana_sim_dst)
9 void DrawTrueVar(TTree* tr, const
string varname, const
string title_x, const
int n_x, const
double x_lo, const
double x_hi);
13 void Fun4SimTree(const
char* fname="sim_tree.root", const
char* tname="tree")
15 TFile* file =
new TFile(fname);
16 TTree* tr = (TTree*)file->Get(tname);
17 gSystem->mkdir(
"result",
true);
18 c1 =
new TCanvas(
"c1",
"");
37 tr->Draw(
"n_dim_true");
38 c1->SaveAs(
"result/h1_true_n_dim.png");
40 const double PI = TMath::Pi();
41 DrawTrueVar(tr,
"dim_true.pdg_id" ,
"True dimuon PDG ID", 1000, 0, 0);
42 DrawTrueVar(tr,
"dim_true.mom.X()" ,
"True dimuon px (GeV)", 100, -5, 5);
43 DrawTrueVar(tr,
"dim_true.mom.Y()" ,
"True dimuon py (GeV)", 100, -5, 5);
44 DrawTrueVar(tr,
"dim_true.mom.Z()" ,
"True dimuon pz (GeV)", 100, 0, 100);
45 DrawTrueVar(tr,
"dim_true.mom.M()" ,
"True dimuon mass (GeV)", 100, 0, 5);
46 DrawTrueVar(tr,
"dim_true.mom.Eta()" ,
"True dimuon #eta", 110, 0, 11);
47 DrawTrueVar(tr,
"dim_true.mom.Phi()" ,
"True dimuon #phi", 100, -PI, PI);
48 DrawTrueVar(tr,
"dim_true.x1" ,
"True x1", 50, 0, 1);
49 DrawTrueVar(tr,
"dim_true.x2" ,
"True x2", 50, 0, 1);
50 DrawTrueVar(tr,
"dim_true.xF" ,
"True xF", 50, -1, 1);
51 DrawTrueVar(tr,
"dim_true.costh" ,
"True cos#theta", 50, -1, 1);
52 DrawTrueVar(tr,
"dim_true.phi" ,
"True #phi" , 50, -PI, PI);
57 tr->Draw(
"n_dim_reco");
58 c1->SaveAs(
"result/h1_reco_n_dim.png");
61 c1->SaveAs(
"result/h1_rec_stat.png");
63 tr->Draw(
"trig_bits",
"rec_stat==0");
64 c1->SaveAs(
"result/h1_trig_bits.png");
66 tr->Draw(
"dim_reco.mom.M()",
"rec_stat==0");
67 c1->SaveAs(
"result/h1_dim_reco_mass.png");
69 tr->Draw(
"dim_reco.x1",
"rec_stat==0");
70 c1->SaveAs(
"result/h1_dim_reco_x1.png");
72 tr->Draw(
"dim_reco.x2",
"rec_stat==0");
73 c1->SaveAs(
"result/h1_dim_reco_x2.png");
79 DrawTrueVar(tr,
"dim_true.mom_pos.X()",
"True px (GeV) of mu+", 100, -5, 5);
80 DrawTrueVar(tr,
"dim_true.mom_pos.Y()",
"True py (GeV) of mu+", 100, -5, 5);
81 DrawTrueVar(tr,
"dim_true.mom_pos.Z()",
"True pz (GeV) of mu+", 100, 0, 100);
82 DrawTrueVar(tr,
"dim_true.mom_neg.X()",
"True px (GeV) of mu-", 100, -5, 5);
83 DrawTrueVar(tr,
"dim_true.mom_neg.Y()",
"True py (GeV) of mu-", 100, -5, 5);
84 DrawTrueVar(tr,
"dim_true.mom_neg.Z()",
"True pz (GeV) of mu-", 100, 0, 100);
87 TH1* h1_all =
new TH1D(
"h1_all",
"", 100, -1, 1);
88 TH1* h1_rec =
new TH1D(
"h1_rec",
"", 100, -1, 1);
89 tr->Project(
"h1_all",
"(dim_true.mom_pos.Z() - dim_true.mom_neg.Z())/(dim_true.mom_pos.Z() + dim_true.mom_neg.Z())");
90 tr->Project(
"h1_rec",
"(dim_true.mom_pos.Z() - dim_true.mom_neg.Z())/(dim_true.mom_pos.Z() + dim_true.mom_neg.Z())",
"rec_stat==0");
91 hs =
new THStack(
"hs",
"J/#psi GMC;gpz+gpz (GeV) of tracks;N of tracks");
94 h1_rec->SetLineColor(kRed);
96 c1->SaveAs(
"result/h1_trk_true_pz_asym.png");
99 void DrawTrueVar(TTree* tr,
const string varname,
const string title_x,
const int n_x,
const double x_lo,
const double x_hi)
101 TH1* h1_all =
new TH1D(
"h1_all",
"", n_x, x_lo, x_hi);
102 TH1* h1_rec =
new TH1D(
"h1_rec",
"", n_x, x_lo, x_hi);
103 tr->Project(
"h1_all", varname.c_str());
104 tr->Project(
"h1_rec", varname.c_str(),
"rec_stat==0");
107 oss <<
"J/#psi GMC;" << title_x <<
";Yield";
108 THStack hs(
"hs", oss.str().c_str());
111 h1_rec->SetLineColor(kRed);
116 for (string::const_iterator it = varname.begin(); it != varname.end(); it++) {
118 case '.':
case '*':
case '/': oss <<
'_';
break;
119 case '(':
case ')':
case ' ':
break;
124 c1->SaveAs(oss.str().c_str());
132 gStyle->SetOptFit(
true);
133 TH1* h1_costh =
new TH1D(
"h1_costh",
"", 100, -1, 1);
134 tr->Project(
"h1_costh",
"dim_true.costh");
135 TF1* f1 =
new TF1(
"f1",
"[0]*(1 + [1]*pow(x,2))", -0.8, 0.8);
136 h1_costh->Fit(f1,
"REM");
137 c1->SaveAs(
"result/h1_costh_fit.png");
144 typedef map<int, int> IntCount_t;
147 tr->SetBranchAddress(
"dim_true", &list_dim);
149 int n_ent = tr->GetEntries();
150 cout <<
"AnaEvents(): n = " << n_ent << endl;
151 for (
int i_ent = 0; i_ent < n_ent; i_ent++) {
152 if ((i_ent+1) % (n_ent/10) == 0) cout <<
" " << 100*(i_ent+1)/n_ent <<
"%" << flush;
154 for (DimuonList::iterator it = list_dim->begin(); it != list_dim->end(); it++) {
157 if (id_cnt.find(pdg_id) == id_cnt.end()) id_cnt[pdg_id] = 1;
158 else id_cnt[pdg_id]++;
162 for (IntCount_t::iterator it = id_cnt.begin(); it != id_cnt.end(); it++) {
163 cout << setw(10) << it->first <<
" " << setw(10) << it->second << endl;
void FitCosTheta(TTree *tr)
void Fun4SimTree(const char *fname="sim_tree.root", const char *tname="tree")
void DrawTrueVar(TTree *tr, const string varname, const string title_x, const int n_x, const double x_lo, const double x_hi)
std::vector< DimuonData > DimuonList
void DrawTrkTrueKin(TTree *tr)
void DrawDimRecoKin(TTree *tr)
void DrawDimTrueKin(TTree *tr)
void AnaEvents(TTree *tr)