StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Plot_Embed.C
1 
2 
4 // $Id: Plot_Embed.C,v 1.1 2007/04/27 15:03:04 cristina Exp $
5 // owner: Cristina
6 //
7 // What it does: This Macro reads two diferent scanned files and compare them. It takes the 3D histogram (nch,pt, nfit)
8 // and makes the projection on the z-axis (nfit) and give a 1D plot for Nfit for both files
9 // with extension .gif - When running this macro, include 2 bins for Pt:pt1 and pt2, check the location for the imput files and where
10 // the output will be saved
11 //Plot created are: Dca, Nfit, EnergyLoss, Efficiecy, Delta_Vertex (X, Y, Z), reference multilicity
12 //
14 
15 
16 
17 #ifndef __CINT__
18 #include "TROOT.h"
19 #include "TSystem.h"
20 #include <iostream.h>
21 #include "TH1.h"
22 #include "TH2.h"
23 #include "TH3.h"
24 #include "TFile.h"
25 #include "TTree.h"
26 #include "TChain.h"
27 #include "TTreeHelper.h"
28 #endif
29 
30 void plot_Nfit(float pt1 = 0.2, float pt2 = 2.0, int nch1 = 0, int nch2 = 1000, Int_t id=6){
31 
32 gROOT->LoadMacro("~/mymacros/Utility.C");
33 gROOT->LoadMacro("~/mymacros/UtilityHist.C");
34 gStyle->SetOptStat(0);
35 gStyle->SetOptDate(0);
36 //gStyle->SetOptTitle(0);
37 gStyle->SetOptFit(0);
38 
39 char* oFile1 = "~/outputs/Phi/out_scan_embed_mc_Phi1.root";
40 char* oFile2 = "~/outputs/out_scan_embed_mc_KMinus.root";
41 
42 //Opening file 1
43  f1 = new TFile(oFile1);
44 
45  TH3D* hDca = hMcDca->Clone(); hDca->SetName("hDca");
46  TH3D* hNfit = hNfit3->Clone();hNfit->SetName("hNfit");
47  TH2F* dEdx_ep = (TH2F *) ((TH2F *) f1->Get("dEdx"))->Clone();
48 
49  //Opening file 2
50 
51 f2 = new TFile(oFile2);
52 
53  TH3D* hDcaR = hMcDcaR->Clone();hDcaR->SetName("hDcaR");
54  TH3D* hNfit = hNfit3->Clone();hNfit->SetName("hNfit");
55  TH2F* dEdx_pi = (TH2F *) ((TH2F *) f2->Get("dEdx"))->Clone();
56 
57  // --------------------------------------Plotting DCA-----------------------
58 
59  TCanvas *c= new TCanvas("c","DCA",400, 400);
60 
61  c->SetGridx(0);
62  c->SetGridy(0);
63  c->SetLeftMargin(0.15);
64  c->SetRightMargin(0.05);
65  c->cd;
66 
67 //Bins for Multiplicity - for oFile1
68  TH1D *hX = (TH1D*)hDca->Project3D("X");
69  Int_t bin_nch1 = hX->FindBin(nch1);
70  Int_t bin_nch2 = hX->FindBin(nch2);
71 
72 //Bins for Pt - for oFile1
73  TH1D *hY = (TH1D*)hDca->Project3D("Y");
74  Int_t bin_pt1 = hY->FindBin(pt1);
75  Int_t bin_pt2 = hY->FindBin(pt2);
76 
77 //ProjectionZ (DCA) for oFile1 is done in nch bins and pt bins found above
78 
79  TH1D *hDca1 =(TH1D*) hDca->ProjectionZ("hDca1",bin_nch1, bin_nch2, bin_pt1, bin_pt2);
80 
81  hDca1->SetLineColor(2);// Data in Red - eplus
82  hDca1->SetXTitle("Dca (cm)");
83  hDca1->SetYTitle("Counts");
84  hDca1->GetYaxis()->SetTitleOffset(1.8);
85  hDca1->GetYaxis()->SetDecimals();
86 
87 
88  float mscale = hDca->GetMaximum();
89 
90 
91 //Bins for Multiplicity - for oFile2
92  TH1D *hX_r = (TH1D*)hDcaR->Project3D("X");
93  Int_t bin_nch1_r = hX_r->FindBin(nch1);
94  Int_t bin_nch2_r = hX_r->FindBin(nch2);
95 
96 //Bins for Pt - for oFile2
97  TH1D *hY_r = (TH1D*)hDcaR->Project3D("Y");
98  Int_t bin_pt1_r = hY_r->FindBin(pt1);
99  Int_t bin_pt2_r = hY_r->FindBin(pt2);
100 
101 //ProjectionZ (DCA) for oFile2
102 
103  TH1D *hDca1_r=(TH1D*)hDcaR->ProjectionZ("hDca1_r",bin_nch1_r, bin_nch2_r, bin_pt1_r, bin_pt2_r);
104 
105  Double_t Sum_Real = hDca1_r->GetSum();
106  Double_t Sum_MC = hDca1->GetSum();
107  hDca1_r->Scale(1./Sum_Real); //Scaling Data
108  hDca1->Scale(1./Sum_MC);
109 
110  hDca1->Draw();
111  hDca1_r->Draw("same")
112 
113  //-----------------------------------Plotting Nfit-------------------------------------
114 
115 
116  TCanvas *c1= new TCanvas("c1","NFIT",400, 400);
117  c1->SetGridx(0);
118  c1->SetGridy(0);
119  c1->SetLeftMargin(0.15);
120  c1->SetRightMargin(0.05);
121  c1->cd;
122 
123 
124  //Bins for Multiplicity - oFile 1
125  TH1D *hX = (TH1D*)hNfit->Project3D("X");
126  Int_t multL = hX->FindBin(nch1);
127  Int_t multH = hX->FindBin(nch2);
128 
129 
130 // Bins for Pt - oFile 1
131  TH1D *hY = (TH1D*)hNfit->Project3D("Y");
132  Int_t bin_pt1 = hY->FindBin(pt1);
133  Int_t bin_pt2 = hY->FindBin(pt2);
134 
135 
136 // Projection Z(Nfit) for oFile 1
137  TH1D *hNfitz =(TH1D*) hNfit->ProjectionZ("hNfitz",multL, multH, bin_pt1, bin_pt2);
138 
139  hNfitz->SetLineColor(2);
140  hNfitz->SetXTitle("Nfit");
141  hNfitz->SetYTitle("Counts");
142  hNfitz->GetYaxis()->SetDecimals();
143  hNfitz->GetYaxis()->SetTitleOffset(1.7);
144 
145  Double_t Sum_MC= hNfitz->GetSum();
146 
147 
148 //Bins for Multiplicity - oFile 2
149 
150  TH1D *hX_r = (TH1D*) hNfitR->Project3D("X");
151  Int_t multLr = hX_r->FindBin(nch1);
152  Int_t multHr = hX_r->FindBin(nch2);
153 
154 
155 //Bins for Pt - oFile 2
156  TH1D *hY_r = (TH1D*)hNfitR->Project3D("Y");
157  Int_t bin_pt1_r = hY_r->FindBin(pt1);
158  Int_t bin_pt2_r = hY_r->FindBin(pt2);
159 
160 // Projection Z(Nfit) for oFile 2
161 
162  TH1D *hNfitz_r = (TH1D*)hNfitR->ProjectionZ("hNfitz_r",multLr, multHr, bin_pt1_r, bin_pt2_r);
163 
164  Double_t sum_Real = hNfitz_r->GetSum();
165  hNfitz_r->Scale(1./sum_Real); //Scaling real Data
166  hNfitz->Scale(1./Sum_MC); //Scaling MC Data
167 
168  //------------------- Plotting Global Variables-----------------------------
169  // Delta Vertex position (dvx, dvY, dvZ and vx_vy)
170 
171  TCanvas *c2= new TCanvas("c2","Delta Vertex Position",400, 400);
172  c2->SetGridx(0);
173  c2->SetGridy(0);
174  c2->cd;
175 
176  v_xy->Draw();
177 
178 
179  TCanvas *c3= new TCanvas("c3","Delta Vertex Position",400, 400);
180  c3->SetGridx(0);
181  c3->SetGridy(0);
182  c3->SetLeftMargin(0.15);
183  c3->SetRightMargin(0.05);
184  c3->cd;
185  c3->Divide(3,1);
186 
187  c3_1->cd(); //3 plots in the same canvas
188  dvx->Draw();
189 
190  c3_2->cd()
191  dvy->Draw();
192 
193  c3_3->cd()
194  dvz->Draw();
195 
196  //--------------Plotting Reference Multiplicity---------------------------
197 
198  TCanvas *c4= new TCanvas("c4","Reference Multiplicity",400, 400);
199  c4->SetGridx(0);
200  c4->SetGridy(0);
201  c4->cd;
202 
203  hMult ->Fill(*nPos + *nNeg); // coming from MuDst ??
204  hMult->Draw();
205 
206  //----------------------Energy Loss------------------
207  //For Primary Tracks
208 
209  TCanvas *c5= new TCanvas("c5","Energy Loss",400, 400);
210  c5->SetGridx(0);
211  c5->SetGridy(0);
212  c5->cd;
213 
214  hPtM_E_Pr ->Fill(PtPrMatched[itr],PtPrMatched[itr]-PtMcMatched[itr]);
215  hPtM_E_Pr ->SetLineColor(9);
216  hPtM_E_Pr ->Draw();
217 
218  //For Global Tracks
219  TCanvas *c6= new TCanvas("c6","Energy Loss",400, 400);
220  c6->SetGridx(0);
221  c6->SetGridy(0);
222  c6->cd;
223 
224  hPtM_E_Gl -> Fill (PtPrGlobal[itr],PtPrGlobal[itr]-PtMcGlobal[itr]);
225  hPtM_E_Gl -> SetLineColor(8);
226  hPtM_E_Gl -> Draw();
227 
228  //-------------------------Efficiency--------------------------
229 
230  TCanvas *c7= new TCanvas("c7","Energy Loss",400, 400);
231  c7->SetGridx(0);
232  c7->SetGridy(0);
233  c7->cd;
234 
235  //for Primary / Embedded_MC
236 
237 
238  //for Global / Embedded_MC
239 
240  //-------------------------MIPS----------------------
241 
242  TCanvas *c8= new TCanvas("c8","Energy Loss",400, 400);
243  c8->SetGridx(0);
244  c8->SetGridy(0);
245  c8->Divide(2,1);
246  c8_1->cd();
247 
248  dEdx_ep->SetMarkerColor(2);//E-plus
249  //dEdx_ep->Draw();
250  dEdx_pi->ProfileX();
251  //dEdx_pi->Draw("same");//Pi
252  dEdx_pi->SetXTitle("Momentum P (GeV/c)");
253  dEdx_pi->SetYTitle("dE/dx");
254  c8->cd;
255 
256 
257  //Bins for Pt - Pion
258  TH1D *dEdx_pi_x = (TH1D*)dEdx_pi->ProjectionX();
259  Int_t bin_pt1_r = dEdx_pi_x->FindBin(pt1);
260  Int_t bin_pt2_r = dEdx_pi_x->FindBin(pt2);
261 
262  //ProjectionY (dEdx) - Pion
263 
264  TH1D *dEdx_pi_y = (TH1D*)dEdx_pi->ProjectionY("py",bin_pt1_r, bin_pt2_r);
265  dEdx_pi_y->SetAxisRange(0.,4.,"X");
266  dEdx_pi_y->SetXTitle("dE / dx");
267 
268  // Gaussian Fit for Pion Data
269 
270  Double_t par[6];
271  g1 = new TF1("g1","gaus",0.8.,1.6);
272  g2 = new TF1("g2","gaus",1.7,1.9.);
273  PiFitPiE2 = new TF1("PiFitPiE2","([0]/[2]*exp(-0.5*pow((x-[1])/[2],2))+[3]/[5]*exp(-0.5*pow((x-[4])/[5],2)))/sqrt(6.283)");//Fitting pi Data with 2 Gaussians
274 
275  PiFitPiE2->SetRange(0.0,4.0);
276  dEdx_pi_y->Fit(g1,"R");
277  dEdx_pi_y->Fit(g2,"R");
278 
279  g1->GetParameters(&par[0]);
280  g2->GetParameters(&par[3]);
281 
282  PiFitPiE2->SetParameters(par);
283  PiFitPiE2->SetLineWidth(2);
284  PiFitPiE2->SetLineColor(3);
285  dEdx_pi_y->Fit(PiFitPiE2,"R");
286  keyLine(.5,.7,"dEdx Pi",1);
287 
288 
289  //----------------PROJECTION Y DATA-----------------------------------------
290 
291  c8_2->cd();
292 
293  //Bins for Pt -EPlus
294 
295  TH1D *dEdx_ep_x = (TH1D*)dEdx_ep->ProjectionX();
296  Int_t bin_pt1 = dEdx_ep_x->FindBin(pt1);
297  Int_t bin_pt2 = dEdx_ep_x->FindBin(pt2);
298 
299 //ProjectionY (dEdx) - EPlus
300 
301  TH1D *dEdx_ep_y = (TH1D*)dEdx_ep->ProjectionY("py1",bin_pt1, bin_pt2);
302  dEdx_ep_y->SetAxisRange(0.,4.,"X");
303  dEdx_ep_y->Draw();
304 
305 // Gaussian Fit for ME_plus Data
306 
307  g6 = new TF1("g6","gaus",.6,4.);
308  g6->SetLineWidth(2);
309  g6->SetLineColor(2);
310  dEdx_ep_y->Fit(g6,"R");
311  Double_t Mean = g6->GetParameters(&par[2]);
312 
313  cout<< "Mean is : "<<Mean<<endl;
314  keyLine(.5,.8,"dEdx EPlus",2);
315  keyLine(.5, .6, "Mean Value : Mean",2) ;
316 
317  cout<<"bin_pt1_r"<<bin_pt1_r<<endl;
318  cout<<"bin_pt2_r"<<bin_pt2_r<<endl;
319  cout<<"bin_pt1"<<bin_pt1<<endl;
320  cout<<"bin_pt2"<<bin_pt2<<endl;
321 
322 
323  //------------------------------------------------------------------------
324 char title[100], gif[100];
325 
326  sprintf(gif,"~/Plots/dedx_%.2fpT%.2f_%d.jpg",pt1,pt2);
327 
328 dEdx_ep_y->SetTitle(title);
329 dEdx_pi_y->SetTitle(title);
330 dEdx_ep_y->Draw();
331 
332 
333  hDca1->SetTitle(title);
334  hDca->Write();
335  hNfit->Write();
336  hMult->Write();
337 return;
338 }
virtual TObject * Clone(const char *newname="") const
the custom implementation fo the TObject::Clone
Definition: TDataSet.cxx:308