1 |
jengbou |
1.1 |
#define NtupleSkim_cc
|
2 |
|
|
#include "NtupleSkim.h"
|
3 |
|
|
#include <TH2.h>
|
4 |
|
|
#include <TStyle.h>
|
5 |
|
|
#include <TCanvas.h>
|
6 |
|
|
#include <TMath.h>
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
TString fileName = "test.root";
|
10 |
|
|
|
11 |
|
|
void NtupleSkim::Book()
|
12 |
|
|
{
|
13 |
|
|
int NBin = 400;
|
14 |
|
|
double XMin = -1.;
|
15 |
|
|
double XMax = 1.;
|
16 |
|
|
int dzBin = 80;
|
17 |
|
|
double dzMin = -20;
|
18 |
|
|
double dzMax = 20;
|
19 |
|
|
|
20 |
|
|
int dxBin = 400;
|
21 |
|
|
double dxMin = -0.2;
|
22 |
|
|
double dxMax = 0.2;
|
23 |
|
|
|
24 |
|
|
int phiBin = 63;
|
25 |
|
|
double phiMin = -3.15;
|
26 |
|
|
double phiMax = 3.15;
|
27 |
|
|
|
28 |
|
|
int sigBin = 400;
|
29 |
|
|
double sigMin = 0.0;
|
30 |
|
|
double sigMax = 2.0;
|
31 |
|
|
|
32 |
|
|
h_d0 = new TH1D("d0","d_{0}",NBin,XMin,XMax);
|
33 |
|
|
h_d0->GetXaxis()->SetTitle("Track d_{0} (cm)");
|
34 |
|
|
h_sigmad0 = new TH1D("sigmad0","#sigma_{d_{0}}",sigBin,sigMin,sigMax);
|
35 |
|
|
h_sigmad0->GetXaxis()->SetTitle("#sigma_{d_{0}}");
|
36 |
|
|
h_d0bs = new TH1D("d0_bs","d_{0} use beam spot",NBin,XMin,XMax);
|
37 |
|
|
h_d0bs->GetXaxis()->SetTitle("Track d_{0}^{bs} (cm)");
|
38 |
|
|
h_z0 = new TH1D("z0","z_{0}",dzBin,dzMin,dzMax);
|
39 |
|
|
h_z0->GetXaxis()->SetTitle("Track z_{0} (cm)");
|
40 |
|
|
h_pt = new TH1D("trk_pt","Track p_{T}",500,0,50);
|
41 |
|
|
h_pt->GetXaxis()->SetTitle("Track p_{T} (GeV/c)");
|
42 |
|
|
h_normChi2 = new TH1D("Normalized_chi2","#chi^{2}/n_{dof}",100,0,20);
|
43 |
|
|
h_normChi2->GetXaxis()->SetTitle("#chi^{2}/n_{dof}");
|
44 |
|
|
h_nPixelHit = new TH1D("nPixelHit","Num of Pixel Hits",8,0,8);
|
45 |
|
|
h_nPixelHit->GetXaxis()->SetTitle("# hits");
|
46 |
|
|
h_nStripHit = new TH1D("nStripHit","Num of Strip Hits",30,0,30);
|
47 |
|
|
h_nStripHit->GetXaxis()->SetTitle("# hits");
|
48 |
|
|
h_d0_phi = new TProfile("d0_phi0","d_{0} vs. #phi_{0}",phiBin,phiMin,phiMax,dxMin,dxMax,"");
|
49 |
|
|
h_d0_phi->GetXaxis()->SetTitle("#phi_{0} (rad)");
|
50 |
|
|
h_d0_phi->GetYaxis()->SetTitle("d_{0} (cm)");
|
51 |
|
|
h_d0bs_phi = new TProfile("d0_phi0_bs","d0(beam spot) vs. #phi0",phiBin,phiMin,phiMax,-0.01,0.01,"");
|
52 |
|
|
h_d0bs_phi->GetXaxis()->SetTitle("#phi_{0} (rad)");
|
53 |
|
|
h_d0bs_phi->GetYaxis()->SetTitle("d_{0}^{bs} (cm)");
|
54 |
|
|
h_vx_dz = new TProfile("vx_dz","v_{x} vs. dz",dzBin,dzMin,dzMax,dxMin,dxMax,"");
|
55 |
|
|
h_vx_dz->GetXaxis()->SetTitle("dz (cm)");
|
56 |
|
|
h_vx_dz->GetYaxis()->SetTitle("v_{x} (cm)");
|
57 |
|
|
h_vy_dz = new TProfile("vy_dz","v_{y} vs. dz",dzBin,dzMin,dzMax,dxMin,dxMax,"");
|
58 |
|
|
h_vy_dz->GetXaxis()->SetTitle("dz (cm)");
|
59 |
|
|
h_vy_dz->GetYaxis()->SetTitle("v_{y} (cm)");
|
60 |
|
|
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
void NtupleSkim::Loop(int maxEvents)
|
64 |
|
|
{
|
65 |
|
|
// In a ROOT session, you can do:
|
66 |
|
|
// Root > .L NtupleSkim.C++
|
67 |
|
|
// Root > NtupleSkim *t = new NtupleSkim("DQMsource.root")
|
68 |
|
|
// Root > t->Book();
|
69 |
|
|
// Root > t->GetEntry(12); // Fill t data members with entry number 12
|
70 |
|
|
// Root > t->Show(); // Show values of entry 12
|
71 |
|
|
// Root > t->Show(16); // Read and show values of entry 16
|
72 |
|
|
// Root > t->Loop(); // Loop on all entries
|
73 |
|
|
//
|
74 |
|
|
|
75 |
|
|
// This is the loop skeleton where:
|
76 |
|
|
// jentry is the global entry number in the chain
|
77 |
|
|
// ientry is the entry number in the current Tree
|
78 |
|
|
// Note that the argument to GetEntry must be:
|
79 |
|
|
// jentry for TChain::GetEntry
|
80 |
|
|
// ientry for TTree::GetEntry and TBranch::GetEntry
|
81 |
|
|
//
|
82 |
|
|
// To read only selected branches, Insert statements like:
|
83 |
|
|
// METHOD1:
|
84 |
|
|
// fChain->SetBranchStatus("*",0); // disable all branches
|
85 |
|
|
// fChain->SetBranchStatus("branchname",1); // activate branchname
|
86 |
|
|
// METHOD2: replace line
|
87 |
|
|
// fChain->GetEntry(jentry); //read all branches
|
88 |
|
|
// by b_branchname->GetEntry(ientry); //read only this branch
|
89 |
|
|
// TH2F *hvxy = new TH2F("vxy","x vers. y vertex",100,-0.4,0.4,100,-0.4,0.4);
|
90 |
|
|
if (fChain == 0) return;
|
91 |
|
|
|
92 |
|
|
Long64_t nentries = fChain->GetEntriesFast();
|
93 |
|
|
|
94 |
|
|
Int_t nbytes = 0, nb = 0;
|
95 |
|
|
int theevent = 0;
|
96 |
|
|
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
97 |
|
|
Long64_t ientry = LoadTree(jentry);
|
98 |
|
|
if (ientry < 0) break;
|
99 |
|
|
nb = fChain->GetEntry(jentry);
|
100 |
|
|
nbytes += nb;
|
101 |
|
|
|
102 |
|
|
if (nPixelHit > 4 && nStripHit > 8) {
|
103 |
|
|
h_nPixelHit->Fill(nPixelHit);
|
104 |
|
|
h_nStripHit->Fill(nStripHit);
|
105 |
|
|
h_pt->Fill(pt);
|
106 |
|
|
h_d0->Fill(d0);
|
107 |
|
|
h_sigmad0->Fill(sigmad0);
|
108 |
|
|
h_d0bs->Fill(d0bs);
|
109 |
|
|
h_normChi2->Fill(normchi2);
|
110 |
|
|
h_z0->Fill(z0);
|
111 |
|
|
h_vx_dz->Fill(z0,vx);
|
112 |
|
|
h_vy_dz->Fill(z0,vy);
|
113 |
|
|
h_d0_phi->Fill(phi0,d0);
|
114 |
|
|
h_d0bs_phi->Fill(phi0,d0bs);
|
115 |
|
|
theevent++;
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
TFile *file0 = new TFile(fileName,"RECREATE");
|
120 |
|
|
h_d0->Write();
|
121 |
|
|
h_d0bs->Write();
|
122 |
|
|
h_z0->Write();
|
123 |
|
|
h_sigmad0->Write();
|
124 |
|
|
h_normChi2->Write();
|
125 |
|
|
h_nPixelHit->Write();
|
126 |
|
|
h_nStripHit->Write();
|
127 |
|
|
h_vx_dz->Write();
|
128 |
|
|
h_vy_dz->Write();
|
129 |
|
|
h_d0_phi->Write();
|
130 |
|
|
h_d0bs_phi->Write();
|
131 |
|
|
|
132 |
|
|
file0->cd();
|
133 |
|
|
file0->Close();
|
134 |
|
|
|
135 |
|
|
}
|