Small updates
[u/mrichter/AliRoot.git] / TPC / fastSimul / simul.C
CommitLineData
46a0eaea 1/*
2
3gROOT->LoadMacro("$ALICE_ROOT/TPC/fastSimul/AliTPCclusterFast.cxx+");
4.L $ALICE_ROOT/TPC/fastSimul/simul.C
5//Merge()
6
7TFile f("mergetrack.root");
8track = (AliTPCtrackFast*)f.Get("track");
9//
10// Draw debug stream
11//
12gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
13gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
14AliXRDPROOFtoolkit tool;
15TChain * chain = tool.MakeChain("track.txt","simulTrack",0,200000);
16chain->Lookup();
17 gProof->Exec("gSystem->Load(\"$ALICE_ROOT/TPC/fastSimul/AliTPCclusterFast_cxx.so\")",kFALSE);
18
19*/
20
21class THnSparse;
22
23void simul(Int_t npoints){
24 //
25 // simulation submit script
26 //
27 printf("Hallo world\n");
28 gRandom->SetSeed(0);
29 gROOT->LoadMacro("$ALICE_ROOT/TPC/fastSimul/AliTPCclusterFast.cxx+");
30 AliTPCclusterFast::fPRF = new TF1("fprf","gausn",-5,5);
31 AliTPCclusterFast::fTRF = new TF1("ftrf","gausn",-5,5);
32 AliTPCclusterFast::fPRF->SetParameters(1,0,0.5);
33 AliTPCclusterFast::fTRF->SetParameters(1,0,0.5);
34 //
35 AliTPCtrackFast::Simul("trackerSimul.root",npoints);
36}
37
38
39
40void Merge(){
41 //
42 //
43 //
44 TString objfile;
45 AliTPCtrackFast track0;
46 track0.MakeHisto();
47 AliTPCtrackFast *track1;
48 ifstream in;
49 Int_t counter=0;
50 in.open("track.txt");
51 while(in.good()) {
52 in >> objfile;
53 if (!objfile.Contains("root")) continue; // protection
54 TFile currentFile(objfile.Data());
55 printf("Open file:Counter\t%d\tMerging file %s\n",counter,objfile.Data());
56 track1=(AliTPCtrackFast)currentFile.Get("track");
57 if (!track1) continue;
58 track0.Add(*track1);
59 counter++;
60 }
61 TFile f("mergetrack.root","recreate");
62 track0.Write("track");
63 f.Close("");
64}
65
66
67
68void DrawDedxMC(THnSparse * hstat){
69 //
70 //
71 //
72 TH1 * hisMean[7];
73 TH1 * hisSigma[7];
74 TObjArray arr;
75 for (Int_t ifrac=0; ifrac<6; ifrac++){
76 Float_t frac = 0.5+0.1*Float_t(ifrac);
77 hstat->GetAxis(3)->SetRange(ifrac+1,ifrac+1);
78 hstat->GetAxis(2)->SetRangeUser(120,160);
79 TH2F * his = (TH2F*)hstat->Projection(0,1);
80 his->FitSlicesY(0,0,-1,0,"QNR",&arr);
81 delete his;
82 hisMean[ifrac] = (TH1*) arr.At(1)->Clone();
83 hisSigma[ifrac] = (TH1*) arr.At(2)->Clone();
84 arr.SetOwner(kTRUE); arr.Delete();
85 //
86 hisSigma[ifrac]->Divide(hisMean[ifrac]);
87 hisMean[ifrac]->SetMaximum(6);
88 hisMean[ifrac]->SetMinimum(0);
89 hisSigma[ifrac]->SetMaximum(0.07);
90 hisSigma[ifrac]->SetMinimum(0.03);
91 //
92 hisMean[ifrac]->SetDirectory(0);
93 hisSigma[ifrac]->SetDirectory(0);
94 hisMean[ifrac]->SetXTitle("N_{prim}");
95 hisSigma[ifrac]->SetXTitle("N_{prim}");
96 hisMean[ifrac]->SetYTitle("Q/N_{prim}");
97 hisSigma[ifrac]->SetYTitle("#sigma_{Q/N_{prim}}/(Q/N_{prim})");
98 hisMean[ifrac]->SetMarkerColor(kmicolors[ifrac+1]);
99 hisMean[ifrac]->SetMarkerStyle(kmimarkers[ifrac+1]);
100 hisSigma[ifrac]->SetMarkerColor(kmicolors[ifrac+1]);
101 hisSigma[ifrac]->SetMarkerStyle(kmimarkers[ifrac+1]);
102 }
103 TCanvas * c = new TCanvas(hstat->GetName(),hstat->GetName(),600,800);
104 TLegend *legend = new TLegend(0.55,0.70,0.95,0.95, hstat->GetName());
105 c->Divide(1,2);
106 for (Int_t ifrac=0; ifrac<6; ifrac++){
107 c->cd(1);
108 if (ifrac==0) hisMean[ifrac]->Draw();
109 legend->AddEntry(hisMean[ifrac],Form("%f",0.5+0.1*ifrac));
110 hisMean[ifrac]->Draw("same");
111 c->cd(2);
112 if (ifrac==0) hisSigma[ifrac]->Draw();
113 hisSigma[ifrac]->Draw("same");
114 }
115 c->Draw();
116 legend->Draw();
117 TString fname=hstat->GetName();
118 fname.ReplaceAll("/","_");
119 c->SaveAs(Form("pic/%s.eps",fname.Data()));
120 c->SaveAs(Form("pic/%s.gif",fname.Data()));
121 c->SaveAs(Form("pic/%s.root",fname.Data()));
122}
123
c9e8d4ec 124
125
126
127void DrawDedxN(THnSparse * hstat){
128 //
129 //
130 //
131 TH1 * hisMean[7];
132 TH1 * hisSigma[7];
133 TObjArray arr;
134 for (Int_t ifrac=0; ifrac<6; ifrac++){
135 Float_t frac = 0.5+0.1*Float_t(ifrac);
136 hstat->GetAxis(3)->SetRange(ifrac+1,ifrac+1);
137 hstat->GetAxis(2)->SetRangeUser(80,160);
138 hstat->GetAxis(1)->SetRangeUser(15,18);
139 TH2F * his = (TH2F*)hstat->Projection(0,2);
140 his->FitSlicesY(0,0,-1,0,"QNR",&arr);
141 delete his;
142 hisMean[ifrac] = (TH1*) arr.At(1)->Clone();
143 hisSigma[ifrac] = (TH1*) arr.At(2)->Clone();
144 arr.SetOwner(kTRUE); arr.Delete();
145 //
146 hisSigma[ifrac]->Divide(hisMean[ifrac]);
147 hisMean[ifrac]->SetMaximum(6);
148 hisMean[ifrac]->SetMinimum(0);
149 hisSigma[ifrac]->SetMaximum(0.07);
150 hisSigma[ifrac]->SetMinimum(0.03);
151 //
152 hisMean[ifrac]->SetDirectory(0);
153 hisSigma[ifrac]->SetDirectory(0);
154 hisMean[ifrac]->SetXTitle("N_{cl}");
155 hisSigma[ifrac]->SetXTitle("N_{cl}");
156 hisMean[ifrac]->SetYTitle("Q/N_{prim}");
157 hisSigma[ifrac]->SetYTitle("#sigma_{Q/N_{prim}}/(Q/N_{prim})");
158 hisMean[ifrac]->SetMarkerColor(kmicolors[ifrac+1]);
159 hisMean[ifrac]->SetMarkerStyle(kmimarkers[ifrac+1]);
160 hisSigma[ifrac]->SetMarkerColor(kmicolors[ifrac+1]);
161 hisSigma[ifrac]->SetMarkerStyle(kmimarkers[ifrac+1]);
162 }
163 TCanvas * c = new TCanvas(hstat->GetName(),hstat->GetName(),600,800);
164 TLegend *legend = new TLegend(0.55,0.70,0.95,0.95, hstat->GetName());
165 c->Divide(1,2);
166 for (Int_t ifrac=0; ifrac<6; ifrac++){
167 c->cd(1);
168 if (ifrac==0) hisMean[ifrac]->Draw();
169 legend->AddEntry(hisMean[ifrac],Form("%f",0.5+0.1*ifrac));
170 hisMean[ifrac]->Draw("same");
171 c->cd(2);
172 if (ifrac==0) hisSigma[ifrac]->Draw();
173 hisSigma[ifrac]->Draw("same");
174 }
175 c->Draw();
176 legend->Draw();
177 TString fname=hstat->GetName();
178 fname+="NCl";
179 fname.ReplaceAll("/","_");
180 c->SaveAs(Form("pic/%s.eps",fname.Data()));
181 c->SaveAs(Form("pic/%s.gif",fname.Data()));
182 c->SaveAs(Form("pic/%s.root",fname.Data()));
183}