1 /**************************************************************************
2 * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliHFAfterBurner introduces a v2 modulation in MC for
19 // the D mesons v2 analysis with event plane method
20 // Authors: Giacomo Ortona, ortona@to.infn.it
22 /////////////////////////////////////////////////////////////
26 #include <TDatabasePDG.h>
30 #include <AliAODEvent.h>
31 #include <AliAODMCParticle.h>
32 #include "AliAODRecoDecay.h"
33 #include "AliAODRecoDecayHF.h"
34 #include "AliHFAfterBurner.h"
36 ClassImp(AliHFAfterBurner)
38 //________________________________________________
39 AliHFAfterBurner::AliHFAfterBurner():
49 //________________________________________________
50 AliHFAfterBurner::AliHFAfterBurner(Int_t decChannel):
54 fPrecisionNewton(0.0005),
55 fDecChannel(decChannel),
60 //______________________________________________________________________________
61 AliHFAfterBurner::AliHFAfterBurner(const AliHFAfterBurner &source):
63 fSigv2(source.fSigv2),
64 fBkgv2(source.fBkgv2),
65 fUseNewton(source.fUseNewton),
66 fPrecisionNewton(source.fPrecisionNewton),
67 fDecChannel(source.fDecChannel),
68 fSignal(source.fSignal)
72 //______________________________________________________________________________
73 AliHFAfterBurner &AliHFAfterBurner::operator=(const AliHFAfterBurner &source)
76 if(&source == this) return *this;
78 TObject::operator=(source);
79 fSigv2 = source.fSigv2;
81 fUseNewton=source.fUseNewton;
82 fPrecisionNewton=source.fPrecisionNewton;
83 fDecChannel=source.fDecChannel;
84 fSignal=source.fSignal;
87 //______________________________________________________________________________
88 AliHFAfterBurner::~AliHFAfterBurner(){
91 //______________________________________________________________________________
92 Double_t AliHFAfterBurner::GetNewAngle(AliAODRecoDecayHF *d,TClonesArray *mcArray){
93 // modify the phi angle of teh tracks
103 pdgdaughters=new Int_t[3];
104 pdgdaughters[0]=211;//pi
105 pdgdaughters[1]=321;//K
106 pdgdaughters[2]=211;//pi
112 pdgdaughters=new Int_t[2];
113 pdgdaughters[0]=211;//pi
114 pdgdaughters[1]=321;//K
120 pdgdaughters=new Int_t[3];
121 pdgdaughters[1]=211;//pi
122 pdgdaughters[0]=321;//K
123 pdgdaughters[2]=211;//pi (soft?)
126 lab = d->MatchToMC(pdgmother,mcArray,nProngs,pdgdaughters);
130 phi=GetPhi(d->Phi(),fSigv2);
132 else {//phi=NewtonMethodv2(phi,fBkgv2,eventplane);
135 //const Int_t nProngs=d->GetNProngs();
136 Float_t phidau[nProngs];
137 for(Int_t ipr=0;ipr<nProngs;ipr++){
138 phidau[ipr]=(Float_t)d->PhiProng(ipr);
139 //AliAODTrack *trk = (AliAODTrack*)d->GetDaughter(ipr);
140 Int_t labdau=(Int_t)d->GetProngID(ipr);
141 if(labdau<0)continue;
142 AliAODMCParticle *mcpart= (AliAODMCParticle*)mcArray->At(labdau);
144 Int_t laborig=TMath::Abs(CheckOrigin(mcpart,mcArray));
145 if(laborig>=0){//charm
146 mcpart= (AliAODMCParticle*)mcArray->At(laborig);
147 if(mcpart)phidau[ipr]=GetPhi(mcpart->Phi(),fSigv2);
149 phidau[ipr]=GetPhi(phidau[ipr],fBkgv2);
153 for(Int_t ipr=0;ipr<nProngs;ipr++){
154 py+=d->PtProng(ipr)*TMath::Sin(phidau[ipr]);
155 px+=d->PtProng(ipr)*TMath::Cos(phidau[ipr]);
157 phi=TMath::Pi()+TMath::ATan2(-py,-px);
159 return GetPhi02Pi(phi);
161 //______________________________________________________________________________
162 Double_t AliHFAfterBurner::GetPhi(Double_t phi,Float_t v2){
163 // modifies the phi angle to after-burn the given v2
164 Double_t evplane = fEventPlane;
166 return NewtonMethodv2(phi,v2);
168 return phi-v2*TMath::Sin(2*(phi-evplane));
171 //______________________________________________________________________________
172 Double_t AliHFAfterBurner::NewtonMethodv2(Double_t phi,Double_t v2,Double_t phi0){
173 // modifies the phi angle to after-burn the given v2 using newton method
174 Double_t eventplane = fEventPlane;
175 Double_t phi1 = phi-(phi+v2*TMath::Sin(2.*(phi-eventplane))-phi0)/(1.+2.*v2*TMath::Cos(2.*(phi-eventplane)));
176 if(TMath::Abs(phi/phi1-1.)<fPrecisionNewton){
179 return NewtonMethodv2(phi1,v2,phi0);
182 //______________________________________________________________________________
183 void AliHFAfterBurner::SetMCv2(Float_t v2sig,Float_t v2bkg){
185 if(v2sig>=0)fSigv2=v2sig;
186 if(v2bkg>=0)fBkgv2=v2bkg;
188 //______________________________________________________________________________
189 Int_t AliHFAfterBurner::CheckOrigin(const AliAODMCParticle* mcPart,TClonesArray *arrayMC)const{
192 // checking whether the mother of the particle is a charm
194 Float_t charmmother=kFALSE;
197 mother = mcPart->GetMother();
201 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
203 pdgGranma = mcGranma->GetPdgCode();
204 Int_t abspdgGranma = TMath::Abs(pdgGranma);
205 if ((abspdgGranma > 400 && abspdgGranma < 500) || (abspdgGranma > 4000 && abspdgGranma < 5000)) {
208 mother = mcGranma->GetMother();
210 if(!charmmother)mother=-1;
213 //________________________________________________________________________
214 Float_t AliHFAfterBurner::GetPhi02Pi(Float_t phi){
215 // get phi angle in the range 0 - 2*pi
218 result=result+2.*TMath::Pi();
220 while(result>TMath::Pi()*2.){
221 result=result-2.*TMath::Pi();
225 //________________________________________________________________________
226 void AliHFAfterBurner::SetDecChannel(Int_t decch){
227 // set the decay channel
229 AliWarning("Invalid decay channel");
234 //________________________________________________________________________
235 void AliHFAfterBurner::SetEventPlaneMethod(Int_t method){
236 //Only Random EP supported by now, feature to generate EP from histos to be added
240 //________________________________________________________________________
241 void AliHFAfterBurner::SetEventPlane(){
242 //Only Random EP supported by now, feature to generate EP from histos to be added
243 TRandom3 *g = new TRandom3(0);
244 fEventPlane=g->Rndm()*TMath::Pi();