10 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
22 TFile *
mcf =
new TFile(
"/private/huagen/simdata/Lmd_MC_BD_DPM_elastic_6.2_1.9mrad_5M_1.root");
24 TTree *
tree1 = (TTree*)mcf->Get(
"pndsim");
25 TClonesArray *
mc_array =
new TClonesArray(
"PndSdsMCPoint");
26 tree1->SetBranchAddress(
"LMDPoint",&mc_array);
28 TClonesArray *
mc_track =
new TClonesArray(
"PndMCTrack");
29 tree1->SetBranchAddress(
"MCTrack",&mc_track);
31 TFile *
rcf =
new TFile(
"/private/huagen/simdata/Lmd_Reco_BD_DPM_elastic_6.2_1.9mrad_5M_1.root");
33 TTree *
tree2 = (TTree*)rcf->Get(
"pndsim");
34 TClonesArray *
hit_array =
new TClonesArray(
"PndSdsHit");
35 tree2->SetBranchAddress(
"LMDHitsStrip",&hit_array);
38 TH1F *
mcTheta =
new TH1F(
"MCHit theta",
"Theta fitted by MCHits",300, 0.001, 0.01);
39 TH1F *
rcTheta =
new TH1F(
"Reco theta",
"Theta determined by RecoHits",300, 0.001, 0.01);
41 TH1F *
refTheta =
new TH1F(
"MCTrue theta",
"The track theta set in Generator",300, 0.001, 0.01);
43 TH1F *
dTheta =
new TH1F(
"FirstMCHit-MCTrue",
"delta theta between FirstMCHit and MCTrue",300,-0.003,0.003);
44 TH1F *
dTheta0 =
new TH1F(
"RecoHit-MCTrue",
"delta theta between RecoHit and MCTrue theta",300, -0.003,0.003);
46 TH1F *
dTheta2 =
new TH1F(
"MCHit-MCTrue",
"",300, -0.003,0.003);
47 TH1F *
dTheta3 =
new TH1F(
"RecoHit-MCHit",
"delta theta between RecoHit and MCHit",300, -0.003,0.003);
49 TF1 *
trackFit =
new TF1(
"trackFit",
"pol1",-40,40);
60 for(
int i =0;
i<nEvents&&
i<tree1->GetEntriesFast();
i++)
64 cout<<
"the Event No is "<<
i<<endl;
66 if(hit_array->GetEntriesFast()==4)
68 for (
int j=0; j<hit_array->GetEntriesFast();j++)
70 if(hit_array->GetEntriesFast()!=mc_array->GetEntriesFast())
continue;
81 cout<<
"the mcX, mcY, mcZ are "<<mcX<<
","<<
mcY<<
","<<
mcZ<<endl;
84 cout<<
"the rcX, rcY, rcZ are "<<vecrc.x()<<
","<<vecrc.Y()<<
","<<vecrc.Z()<<endl;
85 Int_t iTrack = point->GetTrackID();
92 cout<<
"the track theta is "<<trackthe<<endl;
96 mc_z[j]=vecmc.Z()-1110;
97 r_mc[j]=
TMath::Sqrt(mc_x[j]*mc_x[j]+mc_y[j]*mc_y[j]);
98 std::cout<<
"the r_mc[j] is "<<r_mc[j]<<std::endl;
99 std::cout<<
"the mc_z[j] is "<<mc_z[j]<<std::endl;
105 rc_z[j]=vecrc.Z()-1110;
106 r_rc[j]=
TMath::Sqrt(rc_x[j]*rc_x[j]+rc_y[j]*rc_y[j]);
107 std::cout<<
"the r_rc[j] is "<<r_rc[j]<<std::endl;
108 std::cout<<
"the rc_z[j] is "<<rc_z[j]<<std::endl;
111 double tempmc =
TMath::Sqrt(mc_x[0]*mc_x[0]+mc_y[0]*mc_y[0]);
112 mcfirstthe = TMath::ATan(tempmc/(mc_z[0]+1110));
113 cout<<
"the first hit theta is "<<mcfirstthe<<endl;
117 TGraphErrors *
mctrack =
new TGraphErrors(4,mc_z,r_mc,z_mc_err,r_mc_err);
118 mctrack->Fit(
"trackFit",
"ONF");
119 mctheta=TMath::ATan(trackFit->GetParameter(1));
120 cout<<
"the mc fit theta is "<<mctheta<<endl;
122 TGraphErrors *rctrack =
new TGraphErrors(4,rc_z,r_rc,z_rc_err,r_rc_err);
123 rctrack->Fit(
"trackFit",
"ONF");
124 rctheta=TMath::ATan(trackFit->GetParameter(1));
125 cout<<
"the rc fit theta is "<<rctheta<<endl;
133 rcTheta->Fill(rctheta);
134 mcTheta->Fill(mctheta);
135 refTheta->Fill(trackthe);
137 dTheta0->Fill(dthe0);
138 dTheta2->Fill(dthe2);
139 dTheta3->Fill(dthe3);
140 dTheta->Fill(dtheta);
147 TF1 *
total =
new TF1(
"total",
"gaus",-0.06,0.06);
148 total->SetLineColor(kRed);
149 total->SetLineWidth(1);
151 TCanvas *
can1 =
new TCanvas(
"Theta",
"MC,RC,Track theta",0,0,800, 800);
155 can1->cd(1); mcTheta->DrawCopy();
156 can1->cd(2); rcTheta->DrawCopy();
157 can1->cd(3); refTheta->DrawCopy();
160 TCanvas *
can2 =
new TCanvas(
"Delta theat",
"MC,RC,Track",0,0,800, 800);
163 can2->cd(1); dTheta0->DrawCopy(); dTheta0->Fit(
"total",
"R");
165 can2->cd(2); dTheta2->DrawCopy(); dTheta2->Fit(
"total",
"R");
166 can2->cd(3); dTheta3->DrawCopy(); dTheta3->Fit(
"total",
"R");
167 can2->cd(4); dTheta ->DrawCopy(); dTheta->Fit(
"total",
"R");
173 cout<<
"the macro finished successfully"<<endl;
174 cout<<
"the real time is "<<rtime<<
" and CPU time is "<<ctime<<endl;
TVector3 GetPosition() const
static T Sqrt(const T &x)
TVector3 GetMomentum() const
TVector3 GetPositionOut() const
TVector3 GetPosition() const
Int_t GetMotherID() const