21 #ifndef ALIKFPARTICLETEST_H
22 #define ALIKFPARTICLETEST_H
27 #include "AliAnalysisTaskRL.h"
52 #include "Riostream.h"
56 #include "TParticle.h"
61 #include "AliTracker.h"
63 #include "TDatabasePDG.h"
64 #include "AliKFParticle.h"
65 #include "AliKFVertex.h"
75 DefineInput(0, TChain::Class());
77 DefineOutput(0, TObjArray::Class());
83 printf(
" ConnectInputData of task %s\n", GetName());
85 char ** address = (
char **)GetBranchAddress(0,
"ESD");
86 if (address)
fESD = (AliESD*)(*address);
89 SetBranchAddress(0,
"ESD", &
fESD);
97 printf(
" CreateOutputObjects of task %s\n", GetName());
99 if ( !gROOT->IsBatch() )
fCanvas =
new TCanvas();
123 if ( gROOT->IsBatch() )
return;
125 const Int_t histoPDG [4]= {22,310,3122,421};
126 const Char_t* histoName[4]= {
"#gamma",
"K^{0}_{s}",
"#Lambda",
"D^{0}"};
133 for(
Int_t i=0; i<4; i++ ){
134 histoText[i].SetTextColor(kBlue);
140 for(
Int_t i=0; i<4; i++ ){
141 Double_t mass = TDatabasePDG::Instance()->GetParticle(histoPDG[i])->Mass();
145 for(
Int_t j=bin; j<bin+10; j++ )
146 if( max<fHistoMassSignal->GetBinContent(j) ) max =
fHistoMassSignal->GetBinContent(j);
147 if(max>0) histoText[i].DrawLatex( mass+.05, max, histoName[i] );
155 static Int_t iEvent = 0;
156 if( ++iEvent%100 ==0 ) cout<<
"Event "<<iEvent<<endl;
160 Long64_t ientry = tinput->GetReadEntry();
161 if (AliAnalysisTaskRL::GetEntry(ientry) == kFALSE) {
162 printf(
"Couldn't get event from the runLoader\n");
168 AliKFParticle::SetField( Bz );
170 if (ientry==0) Notify ();
176 AliDebug(AliLog::kError,
"Stack not available");
185 AliKFParticle fParticle;
192 Int_t nESDTracks=
fESD->GetNumberOfTracks();
193 if( nESDTracks>1000 ) nESDTracks=1000;
195 TESDTrackInfo ESDTrackInfo[1000];
199 for (
Int_t iTr=0; iTr<nESDTracks; iTr++)
201 TESDTrackInfo &info = ESDTrackInfo[iTr];
203 info.fPrimUsedFlag = 0;
205 info.mcMotherID = -1;
209 AliESDtrack *pTrack =
fESD->GetTrack(iTr);
210 if( !pTrack )
continue;
211 if (pTrack->GetKinkIndex(0)>0)
continue;
212 if ( !( pTrack->GetStatus()&AliESDtrack::kITSrefit ) )
continue;
214 if( pTrack->GetITSclusters(indi) <5 )
continue;
215 Int_t PDG = ( pTrack->Get1Pt() <0 ) ?321 :211;
219 Int_t mcID = TMath::Abs(pTrack->GetLabel());
220 TParticle * part = stack->Particle(TMath::Abs(mcID));
222 info.mcPDG = part->GetPdgCode();
224 if( mcID>=0 ) info.mcMotherID = part->GetFirstMother();
230 info.fParticle = AliKFParticle( *pTrack, PDG );
238 const AliKFParticle * vSelected[1000];
243 for(
Int_t i = 0; i<nESDTracks; i++){
244 if(ESDTrackInfo[i].fOK ){
245 vSelected[nSelected] = &(ESDTrackInfo[i].fParticle);
246 vIndex[nSelected] = i;
250 primVtx.ConstructPrimaryVertex( vSelected, nSelected, vFlag, 3. );
251 for(
Int_t i = 0; i<nSelected; i++){
252 if( vFlag[i] ) ESDTrackInfo[vIndex[i]].fPrimUsedFlag = 1;
254 if( primVtx.GetNDF() <1 )
return;
259 for(
Int_t iTr = 0; iTr<nESDTracks; iTr++ ){
261 TESDTrackInfo &info = ESDTrackInfo[iTr];
262 if( !info.fOK )
continue;
264 for(
Int_t jTr = iTr+1; jTr<nESDTracks; jTr++ ){
265 TESDTrackInfo &jnfo = ESDTrackInfo[jTr];
266 if( !jnfo.fOK )
continue;
270 if( info.fParticle.GetQ() == jnfo.fParticle.GetQ() )
continue;
274 AliKFParticle V0( info.fParticle, jnfo.fParticle );
278 if( V0.GetNDF()<1 )
continue;
279 if( TMath::Sqrt(TMath::Abs(V0.GetChi2()/V0.GetNDF())) >3. )
continue;
283 AliKFVertex primVtxCopy = primVtx;
285 if( info.fPrimUsedFlag ) primVtxCopy -= info.fParticle;
286 if( jnfo.fPrimUsedFlag ) primVtxCopy -= jnfo.fParticle;
290 if( V0.GetDeviationFromVertex( primVtxCopy ) >3. )
continue;
298 V0.SetProductionVertex( primVtxCopy );
302 if( TMath::Sqrt( TMath::Abs(V0.GetChi2()/V0.GetNDF()) >3. ))
continue;
307 if( V0.GetDecayLength( length, sigmaLength ) )
continue;
311 if( length <3.*sigmaLength )
continue;
316 if( V0.GetMass( mass, sigmaMass ) )
continue;
321 if( info.mcMotherID==jnfo.mcMotherID && info.mcMotherID>=0 ){
322 TParticle *mother = stack->Particle(info.mcMotherID);
323 if( mother && TMath::Abs(mother->GetPdgCode())!=21 ){
324 if( mother->GetNDaughters()==2 ){
327 cout<<
"PDG V0,pi,pj, ndaughters, mc mass, reco mass = "<<mother->GetPdgCode()<<
","<<info.mcPDG<<
","<<jnfo.mcPDG<<
", "
328 << mother->GetNDaughters()<<
", "<<mother->GetMass()<<
", "<<mass<<endl;
333 if( iEvent %1000 == 0 || (iEvent ==200))
DrawV0();
virtual void Terminate(Option_t *)
virtual void CreateOutputObjects()
AliKFParticleTest(const char *name)
virtual void Exec(Option_t *option)
virtual ~AliKFParticleTest()
virtual void ConnectInputData(Option_t *)
TObjArray * fOutputContainer
THStack * GetStack(TCollection *c, const char *name, Bool_t verb=true)