]>
Commit | Line | Data |
---|---|---|
578adbef | 1 | // $Id$ |
2 | // | |
3 | // Class to select tracks in MC events. | |
4 | // | |
5 | // Author: S. Aiola | |
6 | ||
7 | #include "AliEmcalMCTrackSelector.h" | |
8 | ||
9 | #include <TClonesArray.h> | |
10 | ||
11 | #include "AliAnalysisManager.h" | |
12 | #include "AliVEvent.h" | |
13 | #include "AliMCEvent.h" | |
14 | #include "AliVParticle.h" | |
15 | #include "AliLog.h" | |
16 | ||
17 | ClassImp(AliEmcalMCTrackSelector) | |
18 | ||
19 | //________________________________________________________________________ | |
20 | AliEmcalMCTrackSelector::AliEmcalMCTrackSelector() : | |
21 | AliAnalysisTaskSE("AliEmcalMCTrackSelector"), | |
22 | fTracksOutName("PicoTracks"), | |
23 | fRejectNK(kFALSE), | |
24 | fChargedMC(kFALSE), | |
25 | fTracksOut(0) | |
26 | { | |
27 | // Constructor. | |
28 | } | |
29 | ||
30 | //________________________________________________________________________ | |
31 | AliEmcalMCTrackSelector::AliEmcalMCTrackSelector(const char *name) : | |
32 | AliAnalysisTaskSE(name), | |
33 | fTracksOutName("PicoTracks"), | |
34 | fRejectNK(kFALSE), | |
35 | fChargedMC(kFALSE), | |
36 | fTracksOut(0) | |
37 | { | |
38 | // Constructor. | |
39 | } | |
40 | ||
41 | //________________________________________________________________________ | |
42 | AliEmcalMCTrackSelector::~AliEmcalMCTrackSelector() | |
43 | { | |
44 | // Destructor. | |
45 | } | |
46 | ||
47 | //________________________________________________________________________ | |
48 | void AliEmcalMCTrackSelector::UserCreateOutputObjects() | |
49 | { | |
50 | // Create my user objects. | |
51 | ||
52 | fTracksOut = new TClonesArray("AliMCParticle"); | |
53 | fTracksOut->SetName(fTracksOutName); | |
54 | } | |
55 | ||
56 | //________________________________________________________________________ | |
57 | void AliEmcalMCTrackSelector::UserExec(Option_t *) | |
58 | { | |
59 | // Main loop, called for each event. | |
60 | ||
61 | AliMCEvent *mcevent = MCEvent(); | |
62 | AliVEvent *event = InputEvent(); | |
63 | ||
64 | if (!event) { | |
65 | AliError("Could not retrieve event! Returning"); | |
66 | return; | |
67 | } | |
68 | ||
69 | if (!mcevent) { | |
70 | AliError("Could not retrieve MC event! Returning"); | |
71 | return; | |
72 | } | |
73 | ||
74 | // add tracks to event if not yet there | |
71c1dd76 | 75 | fTracksOut->Delete(); |
578adbef | 76 | if (!(event->FindListObject(fTracksOutName))) { |
77 | event->AddObject(fTracksOut); | |
78 | } | |
79 | ||
80 | // clear container (normally a null operation as the event should clean it already) | |
81 | fTracksOut->Clear(); | |
82 | ||
83 | // loop over tracks | |
84 | const Int_t Ntracks = mcevent->GetNumberOfTracks(); | |
85 | for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) { | |
86 | ||
87 | if (!mcevent->IsPhysicalPrimary(iTracks)) | |
88 | continue; | |
89 | ||
90 | AliMCParticle* track = dynamic_cast<AliMCParticle*>(mcevent->GetTrack(iTracks)); | |
91 | ||
92 | if (!track) | |
93 | continue; | |
94 | ||
95 | if (TMath::Abs(track->Eta()) > 1) | |
96 | continue; | |
97 | ||
98 | Int_t pdgCode = track->PdgCode(); | |
99 | if (fRejectNK && (pdgCode == 130 || pdgCode == 2112)) continue; | |
100 | ||
101 | if (fChargedMC && track->Charge() == 0) continue; | |
102 | ||
103 | new ((*fTracksOut)[nacc]) AliMCParticle(track->Particle(), 0, track->Label()); | |
104 | ++nacc; | |
105 | } | |
106 | } |