1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TDatabasePDG.h>
5 #include <TLorentzVector.h>
8 #include <TClonesArray.h>
17 #include <TPythia6Decayer.h>
18 #include <TPaveStats.h>
45 gSystem->Load(
"libEGPythia6.so");
49 TPythia6Decayer* pdec=TPythia6Decayer::Instance();
50 if(fDecayTableFileName.CompareTo(
"")!=0){
51 if(fDecayTableFileName.Contains(
"ALICE_PHYSICS")){
52 gSystem->Exec(Form(
"cp %s .",fDecayTableFileName.Data()));
53 fDecayTableFileName.ReplaceAll(
"$ALICE_PHYSICS/../src/PWGHF/vertexingHF/macros/",
"./");
55 pdec->SetDecayTableFile(fDecayTableFileName.Data());
56 pdec->ReadDecayTable();
64 TString outFileName=
"Acceptance_Toy_";
70 outFileName.Append(
"D0Kpi_");
76 outFileName.Append(
"DplusKpipi_");
82 outFileName.Append(
"DStarD0pi_");
88 outFileName.Append(
"DsKKpi_");
94 outFileName.Append(
"LcpKpi_");
100 outFileName.Append(
"LcK0Sp_");
102 printf(
"ERROR: Wrong decay selected\n");
106 else outFileName.Append(
"yfidPtDep_");
109 TDatabasePDG* db=TDatabasePDG::Instance();
111 TClonesArray *array =
new TClonesArray(
"TParticle",100);
113 TH2D* hPtVsYGen=
new TH2D(
"hPtVsYGen",
"",400,0.,40.,20.,-1.,1.);
114 hPtVsYGen->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
115 hPtVsYGen->GetYaxis()->SetTitle(
"y");
116 TH2D* hPtVsYGenLimAcc=
new TH2D(
"hPtVsYGenLimAcc",
"",400,0.,40.,20.,-1.,1.);
117 hPtVsYGenLimAcc->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
118 hPtVsYGenLimAcc->GetYaxis()->SetTitle(
"y");
119 TH2D* hPtVsYGenAcc=
new TH2D(
"hPtVsYGenAcc",
"",400,0.,40.,20.,-1.,1.);
120 hPtVsYGenAcc->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
121 hPtVsYGenAcc->GetYaxis()->SetTitle(
"y");
125 funcPt=
new TF1(
"fFONLL",
"[0]*x/TMath::Power((1+TMath::Power(x/[1],[3])),[2])",0.,40.);
126 funcPt->SetParameters(0.322643,2.96275,2.30301,2.5);
127 outFileName.Append(
"FONLL7ptshape.root");
129 funcPt=
new TF1(
"fFONLL",
"[0]*x/TMath::Power((1+TMath::Power(x/[1],[3])),[2])",0.,40.);
130 funcPt->SetParameters(0.302879,2.9750,3.68139,1.68855);
131 outFileName.Append(
"FONLL5ptshape.root");
133 funcPt=
new TF1(
"fFONLL",
"[0]*x/TMath::Power((1+TMath::Power(x/[1],[3])),[2])",0.,40.);
134 funcPt->SetParameters(0.322643,1.94635,1.40463,2.5);
135 outFileName.Append(
"PYTHIA7ptshape.root");
137 funcPt=
new TF1(
"fFlat",
"pol0",0.,40.);
138 funcPt->SetParameter(0,1.);
139 outFileName.Append(
"flatpt.root");
141 TRandom3* gener=
new TRandom3(0);
144 if(itry%10000==0) printf(
"Event %d\n",itry);
145 Float_t ptD=funcPt->GetRandom();
146 Float_t phiD=gener->Rndm()*2*TMath::Pi();
147 Float_t yD=gener->Rndm()*2.-1.;
148 Float_t px=ptD*TMath::Cos(phiD);
149 Float_t py=ptD*TMath::Sin(phiD);
150 Float_t mt=TMath::Sqrt(massD*massD+ptD*ptD);
152 Float_t E=TMath::Sqrt(massD*massD+px*px+py*py+pz*pz);
154 TLorentzVector* vec=
new TLorentzVector(px,py,pz,E);
155 pdec->Decay(pdgCode,vec);
157 Int_t nentries = pdec->ImportParticles(array);
158 TParticle* dmes=(TParticle*)array->At(0);
159 Int_t nDaughters=dmes->GetNDaughters();
163 Int_t nProtonsInAcc=0;
168 Bool_t isOk=
CountPKpi(array,nentries,nPions,nKaons,nProtons,nPionsInAcc,nKaonsInAcc,nProtonsInAcc);
171 if(nPions==nPionDau && nKaons==nKaonDau && nProtons==nProtonDau){
172 hPtVsYGen->Fill(ptD,yD);
173 if(TMath::Abs(yD)<0.5){
174 hPtVsYGenLimAcc->Fill(ptD,yD);
177 if(nPionsInAcc==nPionDau && nKaonsInAcc==nKaonDau && nProtonsInAcc==nProtonDau){
178 hPtVsYGenAcc->Fill(ptD,yD);
186 TH1D* hPtGenAcc=(
TH1D*)hPtVsYGenAcc->ProjectionX(
"hPtGenAcc");
187 hPtGenAcc->GetYaxis()->SetTitle(
"Entries");
188 TH1D* hPtGenLimAcc=(
TH1D*)hPtVsYGenLimAcc->ProjectionX(
"hPtGenLimAcc");
189 hPtGenLimAcc->GetYaxis()->SetTitle(
"Entries");
191 hPtGenLimAcc->Sumw2();
192 TH1D* hAccVsPt=(
TH1D*)hPtGenAcc->Clone(
"hAccVsPt");
193 hAccVsPt->Divide(hPtGenAcc,hPtGenLimAcc,1,1,
"B");
194 hAccVsPt->GetYaxis()->SetTitle(
"Acceptance");
195 hAccVsPt->SetStats(0);
197 TCanvas* c2d=
new TCanvas(
"c2d",
"Pt vs y",1200,600);
200 hPtVsYGen->Draw(
"colz");
202 hPtVsYGenLimAcc->Draw(
"colz");
204 hPtVsYGenAcc->Draw(
"colz");
206 TCanvas* c1d=
new TCanvas(
"c1d",
"Acceptance",1200,600);
209 hPtGenLimAcc->Draw(
"");
210 Double_t ymax=1.2*TMath::Max(hPtGenLimAcc->GetMaximum(),hPtGenAcc->GetMaximum());
211 hPtGenLimAcc->SetMaximum(ymax);
213 TPaveStats *st1=(TPaveStats*)hPtGenLimAcc->GetListOfFunctions()->FindObject(
"stats");
216 hPtGenAcc->SetLineColor(kRed+1);
217 hPtGenAcc->Draw(
"sames");
219 TPaveStats *st2=(TPaveStats*)hPtGenAcc->GetListOfFunctions()->FindObject(
"stats");
222 st2->SetTextColor(hPtGenAcc->GetLineColor());
228 TFile* outfil=
new TFile(outFileName.Data(),
"recreate");
230 hPtVsYGenLimAcc->Write();
231 hPtVsYGenAcc->Write();
232 hPtGenLimAcc->Write();
249 if (TMath::Abs(y) > 0.8)
return kFALSE;
251 Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
252 Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
253 if (y < minFiducialY || y > maxFiducialY)
return kFALSE;
262 TParticle* dmes=(TParticle*)array->At(0);
266 for(
int j=0; j<nentries; j++){
267 TParticle * o = (TParticle*)array->At(j);
268 Int_t pdgdau=TMath::Abs(o->GetPdgCode());
271 if(
fDebugLevel>0) printf(
"K0 dacaying into K0L\n");
274 Float_t ptdau=TMath::Sqrt(o->Px()*o->Px()+o->Py()*o->Py());
289 if(pdgdau==211) nPionsInAcc++;
290 if(pdgdau==321) nKaonsInAcc++;
294 if(TMath::Abs(sumPx-dmes->Px())>0.001 ||
295 TMath::Abs(sumPy-dmes->Py())>0.001 ||
296 TMath::Abs(sumPz-dmes->Pz())>0.001){
297 printf(
"Momentum conservation violation\n");
308 TParticle* dmes=(TParticle*)array->At(0);
313 for(
int j=0; j<nentries; j++){
314 TParticle * o = (TParticle*)array->At(j);
315 Int_t pdgdau=TMath::Abs(o->GetPdgCode());
318 if(
fDebugLevel>0) printf(
"K0 dacaying into K0L\n");
321 Float_t ptdau=TMath::Sqrt(o->Px()*o->Px()+o->Py()*o->Py());
342 if(pdgdau==211) nPionsInAcc++;
343 if(pdgdau==321) nKaonsInAcc++;
344 if(pdgdau==2212) nProtonsInAcc++;
348 if(TMath::Abs(sumPx-dmes->Px())>0.001 ||
349 TMath::Abs(sumPy-dmes->Py())>0.001 ||
350 TMath::Abs(sumPz-dmes->Pz())>0.001){
351 printf(
"Momentum conservation violation\n");
Bool_t CountKpi(TClonesArray *array, Int_t nentries, Int_t &nPions, Int_t &nKaons, Int_t &nPionsInAcc, Int_t &nKaonsInAcc)
TString fDecayTableFileName
Bool_t CountPKpi(TClonesArray *array, Int_t nentries, Int_t &nPions, Int_t &nKaons, Int_t &nProtons, Int_t &nPionsInAcc, Int_t &nKaonsInAcc, Int_t &nProtonsInAcc)
Bool_t IsInFiducialAcceptance(Double_t pt, Double_t y)