1 #if !defined(__CINT__) || defined(__MAKECINT__)
8 #include <TDatabasePDG.h>
10 #include "AliRunLoader.h"
11 #include "AliHeader.h"
13 #include "AliAODEvent.h"
14 #include "AliAODHeader.h"
15 #include "AliAODVertex.h"
16 #include "AliAODTrack.h"
17 #include "AliAODCluster.h"
18 #include "AliGenAmpt.h"
22 // function declarations
23 void SetVertexType(TParticle *part, AliAODVertex *vertex);
24 void SetChargeAndPID(Int_t pdgCode, AliAODTrack *track);
25 Int_t LoopOverSecondaries(TParticle *mother);
26 void genAmptAOD(Int_t nEvents,
27 const char *outFileName = "AliAOD.root");
30 AliAODEvent *aod = NULL;
31 AliStack *stack = NULL;
48 Int_t nAntiProton = 0;
50 Int_t nAntiNeutron = 0;
58 // global arrays and pointers
61 Float_t *cov = NULL; // set to NULL because not provided
62 Float_t *pid = NULL; // set to NULL because not provided
63 AliAODVertex *primary = NULL;
64 AliAODVertex *secondary = NULL;
65 AliAODTrack *currTrack = NULL;
67 void genAmptAOD(Int_t nEvents,
68 const char *outFileName)
70 AliPDG::AddParticlesToPdgDataBase();
71 TDatabasePDG::Instance();
73 // create an AliAOD object
74 aod = new AliAODEvent();
75 aod->CreateStdContent();
78 TFile *outFile = TFile::Open(outFileName, "RECREATE");
81 TTree *aodTree = new TTree("aodTree", "AliAOD tree");
82 aodTree->Branch(aod->GetList());
85 TFolder *folder = new TFolder("myfolder","myfolder");
86 AliRunLoader* rl = new AliRunLoader(folder);
89 AliStack* stack = rl->Stack();
90 AliHeader* rheader = rl->GetHeader();
92 AliGenAmpt *genHi = new AliGenAmpt(-1);
93 genHi->SetEnergyCMS(2760);
94 genHi->SetReferenceFrame("CMS");
95 genHi->SetProjectile("A", 208, 82);
96 genHi->SetTarget ("A", 208, 82);
97 genHi->SetPtHardMin (5);
98 genHi->SetImpactParameterRange(12.,30);
99 genHi->SetJetQuenching(0); // enable jet quenching
100 genHi->SetShadowing(1); // enable shadowing
101 genHi->SetDecaysOff(1); // neutral pion and heavy particle decays switched off
102 genHi->SetSpectators(1); // track spectators
104 genHi->SetStack(stack);
106 // create events and fill them
107 for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) {
111 rheader->Reset(0,iEvent);
112 rheader->SetNprimary(stack->GetNprimary());
113 rheader->SetNtrack(stack->GetNtrack());
114 rheader->SetStack(stack);
115 stack->FinishEvent();
117 cout << "Event " << iEvent+1 << "/" << nEvents;
119 Int_t nTracks = stack->GetNtrack();
120 Int_t nPrims = stack->GetNprimary();
141 // Access to the header
142 AliAODHeader *header = aod->GetHeader();
144 Double_t emEnergy[2] = {-999., -999.};
147 *header = AliAODHeader(123456,
155 -999., // muon mag. field
157 -999., // ZDCN1Energy
158 -999., // ZDCP1Energy
159 -999., // ZDCN2Energy
160 -999., // ZDCP2Energy
161 emEnergy, // emEnergy
167 // Access to the AOD container of vertices
168 TClonesArray &vertices = *(aod->GetVertices());
175 // Access to the AOD container of tracks
176 TClonesArray &tracks = *(aod->GetTracks());
179 aod->ResetStd(nTracks, 1);
182 for (Int_t iTrack = 0; iTrack < nPrims; ++iTrack) {
184 TParticle *part = stack->Particle(iTrack);
186 //if (part->IsPrimary()) { // this will exclude 'funny' primaries, too
187 if (kTRUE) { // this won't
188 p[0] = part->Px(); p[1] = part->Py(); p[2] = part->Pz();
189 x[0] = part->Vx(); x[1] = part->Vy(); x[2] = part->Vz();
192 // add primary vertex
193 primary = new(vertices[jVertices++])
194 AliAODVertex(x, NULL, -999., NULL, AliAODVertex::kPrimary);
197 // add primary tracks
198 primary->AddDaughter(new(tracks[jTracks++]) AliAODTrack(0, // ID,
206 0, // no ITSClusterMap
209 kFALSE, // no fit performed
210 kFALSE, // no fit preformed
211 AliAODTrack::kPrimary));
212 currTrack = (AliAODTrack*)tracks.Last();
213 SetChargeAndPID(part->GetPdgCode(), currTrack);
214 if (currTrack->Charge() != -99) {
215 if (currTrack->Charge() > 0) {
217 } else if (currTrack->Charge() < 0) {
222 LoopOverSecondaries(part);
224 } // end of track loop
226 header->SetRefMultiplicityPos(nPos);
227 header->SetRefMultiplicityNeg(nNeg);
229 cout << ":: primaries: " << nPrims << " secondaries: " << tracks.GetEntriesFast()-nPrims <<
230 " (pos: " << nPos << ", neg: " << nNeg << "), vertices: " << vertices.GetEntriesFast() <<
231 " (kinks: " << jKinks << ", V0: " << jV0s << ", cascades: " << jCascades <<
232 ", multi: " << jMultis << ")" << endl;
234 // fill the tree for this event
236 } // end of event loop
238 aodTree->GetUserInfo()->Add(aod);
240 // write the tree to the specified file
241 outFile = aodTree->GetCurrentFile();
248 Int_t LoopOverSecondaries(TParticle *mother) {
250 if (mother->GetNDaughters() > 0) {
252 TClonesArray &vertices = *(aod->GetVertices());
253 TClonesArray &tracks = *(aod->GetTracks());
255 for (Int_t iDaughter = mother->GetFirstDaughter(); iDaughter <= mother->GetLastDaughter(); iDaughter++) {
256 TParticle *part = stack->Particle(iDaughter);
264 if (iDaughter == mother->GetFirstDaughter()) {
265 // add secondary vertex
266 secondary = new(vertices[jVertices++])
267 AliAODVertex(x, NULL, -999., tracks.Last(), AliAODVertex::kUndef);
269 SetVertexType(part, secondary);
272 // add secondary tracks
273 secondary->AddDaughter(new(tracks[jTracks++]) AliAODTrack(0, // ID
281 0, // no cluster map available
284 kFALSE, // no fit performed
285 kFALSE, // no fit performed
286 AliAODTrack::kSecondary));
288 currTrack = (AliAODTrack*)tracks.Last();
289 SetChargeAndPID(part->GetPdgCode(), currTrack);
290 if (currTrack->Charge() != -99) {
291 if (currTrack->Charge() > 0) {
293 } else if (currTrack->Charge() < 0) {
298 LoopOverSecondaries(part);
307 void SetChargeAndPID(Int_t pdgCode, AliAODTrack *track) {
309 Float_t PID[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
315 PID[AliAODTrack::kUnknown] = 1.;
321 track->SetCharge(-1);
322 PID[AliAODTrack::kElectron] = 1.;
328 track->SetCharge(+1);
329 PID[AliAODTrack::kElectron] = 1.;
335 track->SetCharge(-1);
336 PID[AliAODTrack::kMuon] = 1.;
342 track->SetCharge(+1);
343 PID[AliAODTrack::kMuon] = 1.;
350 PID[AliAODTrack::kUnknown] = 1.;
356 track->SetCharge(+1);
357 PID[AliAODTrack::kPion] = 1.;
363 track->SetCharge(-1);
364 PID[AliAODTrack::kPion] = 1.;
371 PID[AliAODTrack::kUnknown] = 1.;
377 track->SetCharge(+1);
378 PID[AliAODTrack::kKaon] = 1.;
384 track->SetCharge(-1);
385 PID[AliAODTrack::kKaon] = 1.;
392 PID[AliAODTrack::kUnknown] = 1.;
398 track->SetCharge(+1);
399 PID[AliAODTrack::kProton] = 1.;
404 case -2212: // anti-p
405 track->SetCharge(-1);
406 PID[AliAODTrack::kProton] = 1.;
413 PID[AliAODTrack::kUnknown] = 1.;
420 PID[AliAODTrack::kUnknown] = 1.;
425 case -311: // anti-K0
427 PID[AliAODTrack::kUnknown] = 1.;
434 PID[AliAODTrack::kUnknown] = 1.;
440 PID[AliAODTrack::kUnknown] = 1.;
445 track->SetCharge(+1);
446 PID[AliAODTrack::kUnknown] = 1.;
451 track->SetCharge(-1);
452 PID[AliAODTrack::kUnknown] = 1.;
457 track->SetCharge(-1);
458 PID[AliAODTrack::kUnknown] = 1.;
464 PID[AliAODTrack::kUnknown] = 1.;
469 track->SetCharge(-1);
470 PID[AliAODTrack::kUnknown] = 1.;
475 track->SetCharge(-1);
476 PID[AliAODTrack::kUnknown] = 1.;
482 PID[AliAODTrack::kUnknown] = 1.;
486 case -3122: // anti-Lambda
488 PID[AliAODTrack::kUnknown] = 1.;
492 case -3222: // anti-Sigma-
493 track->SetCharge(-1);
494 PID[AliAODTrack::kUnknown] = 1.;
498 case -3212: // anti-Sigma0
500 PID[AliAODTrack::kUnknown] = 1.;
504 case -3112: // anti-Sigma+
505 track->SetCharge(+1);
506 PID[AliAODTrack::kUnknown] = 1.;
510 case -3322: // anti-Xi0
512 PID[AliAODTrack::kUnknown] = 1.;
516 case -3312: // anti-Xi+
517 track->SetCharge(+1);
520 case -3334: // anti-Omega+
521 track->SetCharge(+1);
522 PID[AliAODTrack::kUnknown] = 1.;
527 track->SetCharge(+1);
528 PID[AliAODTrack::kUnknown] = 1.;
533 track->SetCharge(-1);
534 PID[AliAODTrack::kUnknown] = 1.;
540 PID[AliAODTrack::kUnknown] = 1.;
544 case -421: // anti-D0
546 PID[AliAODTrack::kUnknown] = 1.;
551 track->SetCharge(-99);
552 PID[AliAODTrack::kUnknown] = 1.;
560 void SetVertexType(TParticle *part, AliAODVertex *vertex) {
561 // this whole thing doesn't make much sense. but anyhow...
563 TParticle *mother = stack->Particle(part->GetFirstMother());
564 Int_t pdgMother = mother->GetPdgCode();
565 Int_t pdgPart = part->GetPdgCode();
568 if (mother->GetNDaughters() == 2) {
569 Int_t firstPdgCode = stack->Particle(mother->GetFirstDaughter())->GetPdgCode();
570 Int_t lastPdgCode = stack->Particle(mother->GetLastDaughter())->GetPdgCode();
572 if (!(pdgMother == 22 || pdgMother == 111 || pdgMother == 130 ||
573 TMath::Abs(pdgMother) == 2112 || pdgMother == 310 || pdgMother == 221 ||
574 TMath::Abs(pdgMother) == 3122 || TMath::Abs(pdgMother) == 3322 ||
575 pdgMother == -3212 || TMath::Abs(pdgMother) == 421 ||
576 TMath::Abs(pdgMother) == 311) // not neutral
577 && (((firstPdgCode == 22 || firstPdgCode == 111 || firstPdgCode == 130 ||
578 TMath::Abs(firstPdgCode) == 2112 || firstPdgCode == 310 ||
579 firstPdgCode == 221 || TMath::Abs(firstPdgCode) == 3122 ||
580 TMath::Abs(firstPdgCode) == 3322 || firstPdgCode == -3212 ||
581 TMath::Abs(firstPdgCode) == 421 || TMath::Abs(pdgMother) == 311) // neutral
582 && !(lastPdgCode == 22 || lastPdgCode == 111 || lastPdgCode == 130 ||
583 TMath::Abs(lastPdgCode) == 2112 || lastPdgCode == 310 ||
584 lastPdgCode == 221 || TMath::Abs(lastPdgCode) == 3122 ||
585 TMath::Abs(lastPdgCode) == 3322 || lastPdgCode == -3212 ||
586 TMath::Abs(lastPdgCode) == 421 || TMath::Abs(pdgMother) == 311)) // not neutral
587 || !((firstPdgCode == 22 || firstPdgCode == 111 || firstPdgCode == 130 ||
588 TMath::Abs(firstPdgCode) == 2112 || firstPdgCode == 310 ||
589 firstPdgCode == 221 || TMath::Abs(firstPdgCode) == 3122 ||
590 TMath::Abs(firstPdgCode) == 3322 || firstPdgCode == -3212 ||
591 TMath::Abs(firstPdgCode) == 421 || TMath::Abs(pdgMother) == 311) // not neutral
592 && (lastPdgCode == 22 || lastPdgCode == 111 || lastPdgCode == 130 ||
593 TMath::Abs(lastPdgCode) == 2112 || lastPdgCode == 310 ||
594 lastPdgCode == 221 || TMath::Abs(lastPdgCode) == 3122 ||
595 TMath::Abs(lastPdgCode) == 3322 || lastPdgCode == -3212 ||
596 TMath::Abs(lastPdgCode) == 421 || TMath::Abs(pdgMother) == 311)))) { // neutral
598 vertex->SetType(AliAODVertex::kKink);
604 else if (mother->GetNDaughters() == 2) {
605 Int_t firstPdgCode = stack->Particle(mother->GetFirstDaughter())->GetPdgCode();
606 Int_t lastPdgCode = stack->Particle(mother->GetLastDaughter())->GetPdgCode();
608 if ((pdgMother == 22 || pdgMother == 111 || pdgMother == 130 ||
609 TMath::Abs(pdgMother) == 2112 || pdgMother == 310 ||
610 pdgMother == 221 || TMath::Abs(pdgMother) == 3122 ||
611 TMath::Abs(pdgMother) == 3322 || pdgMother == -3212 ||
612 TMath::Abs(pdgMother) == 421 || TMath::Abs(pdgMother) == 311) // neutral
613 && !(lastPdgCode == 22 || lastPdgCode == 111 || lastPdgCode == 130 ||
614 TMath::Abs(lastPdgCode) == 2112 || lastPdgCode == 310 ||
615 lastPdgCode == 221 || TMath::Abs(lastPdgCode) == 3122 ||
616 TMath::Abs(lastPdgCode) == 3322 || lastPdgCode == -3212 ||
617 TMath::Abs(lastPdgCode) == 421 || TMath::Abs(pdgMother) == 311) // not neutral
618 && !(firstPdgCode == 22 || firstPdgCode == 111 || firstPdgCode == 130 ||
619 TMath::Abs(firstPdgCode) == 2112 || firstPdgCode == 310 ||
620 firstPdgCode == 221 || TMath::Abs(firstPdgCode) == 3122 ||
621 TMath::Abs(firstPdgCode) == 3322 || firstPdgCode == -3212 ||
622 TMath::Abs(firstPdgCode) == 421 || TMath::Abs(pdgMother) == 311)) { // not neutral
624 vertex->SetType(AliAODVertex::kV0);
630 else if (mother->GetNDaughters() == 2) {
631 Int_t firstPdgCode = stack->Particle(mother->GetFirstDaughter())->GetPdgCode();
632 Int_t lastPdgCode = stack->Particle(mother->GetLastDaughter())->GetPdgCode();
634 if ((TMath::Abs(pdgMother) == 3334 || TMath::Abs(pdgMother) == 3312 || TMath::Abs(pdgMother) == 3322) &&
635 (TMath::Abs(pdgPart) == 3122 || TMath::Abs(pdgPart) == 211 || TMath::Abs(pdgPart) == 321)
636 && ((!(firstPdgCode == 22 || firstPdgCode == 111 || firstPdgCode == 130 ||
637 TMath::Abs(firstPdgCode) == 2112 || firstPdgCode == 310 ||
638 firstPdgCode == 221 || TMath::Abs(firstPdgCode) == 3122 ||
639 TMath::Abs(firstPdgCode) == 3322 || firstPdgCode == -3212 ||
640 TMath::Abs(firstPdgCode) == 421 || TMath::Abs(pdgMother) == 311) // not neutral
641 && TMath::Abs(lastPdgCode) == 3122) // labmda or anti-lambda
642 || ((!(lastPdgCode == 22 || lastPdgCode == 111 || lastPdgCode == 130 ||
643 TMath::Abs(lastPdgCode) == 2112 || lastPdgCode == 310 ||
644 lastPdgCode == 221 || TMath::Abs(lastPdgCode) == 3122 ||
645 TMath::Abs(lastPdgCode) == 3322 || lastPdgCode == -3212 ||
646 TMath::Abs(lastPdgCode) == 421 || TMath::Abs(pdgMother) == 311) // not neutral
647 && TMath::Abs(firstPdgCode) == 3122)))) { // lambda or anti-lambda
648 vertex->SetType(AliAODVertex::kCascade);
654 else if (mother->GetNDaughters() > 2) {
656 vertex->SetType(AliAODVertex::kMulti);
661 vertex->SetType(AliAODVertex::kUndef);
664 // LocalWords: SetCharge