]>
Commit | Line | Data |
---|---|---|
f9228736 | 1 | //------------------------------------------------------------------------- |
2 | // Task for the Analysis Framework | |
3 | // Updates the an already created AOD with the PWG2 information taken from | |
4 | // the ESD. | |
5 | // - Puts the per-track information into the AliPWG2AODTrack container, | |
6 | // together with the link to the original AliAODTrack | |
7 | // | |
8 | // Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch | |
9 | //------------------------------------------------------------------------- | |
10 | #include <TChain.h> | |
11 | #include <TFile.h> | |
12 | #include <TList.h> | |
13 | ||
14 | #include "AliAnalysisTaskPWG2AODUpdate.h" | |
15 | #include "AliAnalysisManager.h" | |
16 | #include "AliESDEvent.h" | |
17 | #include "AliAODEvent.h" | |
18 | #include "AliESDtrack.h" | |
19 | #include "AliESDVertex.h" | |
20 | #include "AliLog.h" | |
21 | #include "AliPWG2AODTrack.h" | |
22 | ||
23 | ClassImp(AliAnalysisTaskPWG2AODUpdate) | |
24 | ||
25 | //////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | AliAnalysisTaskPWG2AODUpdate::AliAnalysisTaskPWG2AODUpdate(): | |
28 | fESD(0x0), | |
29 | fAOD(0x0), | |
30 | fPWG2AODTracks(0x0) | |
31 | { | |
32 | // Default constructor | |
33 | } | |
34 | ||
35 | AliAnalysisTaskPWG2AODUpdate::AliAnalysisTaskPWG2AODUpdate(const char* name): | |
36 | AliAnalysisTaskSE(name), | |
37 | fESD(0x0), | |
38 | fAOD(0x0), | |
39 | fPWG2AODTracks(0x0) | |
40 | { | |
41 | // Default constructor | |
42 | DefineInput (0, TChain::Class()); | |
43 | DefineOutput(0, TTree::Class()); | |
44 | } | |
45 | ||
46 | AliAnalysisTaskPWG2AODUpdate::AliAnalysisTaskPWG2AODUpdate(const AliAnalysisTaskPWG2AODUpdate &task): | |
47 | AliAnalysisTaskSE(), | |
48 | fESD(0x0), | |
49 | fAOD(0x0), | |
50 | fPWG2AODTracks(0x0) | |
51 | { | |
52 | // Copy | |
53 | fESD = task.fESD; | |
54 | fAOD = task.fAOD; | |
55 | fPWG2AODTracks = task.fPWG2AODTracks; | |
56 | } | |
57 | ||
58 | AliAnalysisTaskPWG2AODUpdate& AliAnalysisTaskPWG2AODUpdate::operator=(const AliAnalysisTaskPWG2AODUpdate &task) | |
59 | { | |
60 | // Assignment | |
61 | if (&task == this) return *this; | |
62 | TTask::operator=(task); | |
63 | ||
64 | fESD = task.fESD; | |
65 | fAOD = task.fAOD; | |
66 | fPWG2AODTracks = task.fPWG2AODTracks; | |
67 | ||
68 | return *this; | |
69 | } | |
70 | ||
71 | void AliAnalysisTaskPWG2AODUpdate::UserCreateOutputObjects() | |
72 | { | |
73 | // Get links to input and output containters | |
74 | fAOD = AODEvent(); | |
75 | ||
76 | fPWG2AODTracks = new TClonesArray("AliPWG2AODTrack", 0); | |
77 | const char *name = "pwg2aodtracks"; | |
78 | fPWG2AODTracks->SetName(name); | |
79 | ||
80 | AddAODBranch("TClonesArray", &fPWG2AODTracks); | |
81 | } | |
82 | ||
83 | void AliAnalysisTaskPWG2AODUpdate::UserExec(Option_t */*option*/) | |
84 | { | |
85 | // Execute analysis for current event | |
86 | // | |
87 | fESD = dynamic_cast<AliESDEvent *> (InputEvent()); | |
88 | if (!fESD) { printf ("No input ESD !!! Not adding PWG2 information\n"); } | |
89 | fAOD = AODEvent(); | |
90 | if (!fAOD) { printf ("No output AOD !!! Not adding PWG2 information\n"); } | |
91 | ||
92 | if ((!fESD) || (!fAOD)) return; | |
93 | ||
94 | Double_t pos[3]; | |
95 | Double_t p[3]; | |
96 | Double_t tpcentrancepoint[3]; | |
97 | Double_t tpcexitpoint[3]; | |
98 | TBits sharemap; | |
99 | TBits clustermap; | |
100 | Int_t pTracks = 0; | |
101 | ||
102 | for (Int_t i = 0; i < 3; i++) { tpcentrancepoint[i] = 0.; tpcexitpoint[i] = 0; } | |
103 | ||
104 | // Get primary vertex | |
105 | const AliESDVertex *vtx = fESD->GetPrimaryVertex(); | |
106 | ||
107 | vtx->GetXYZ(pos); // position | |
108 | ||
109 | // Tracks (primary and orphan) | |
110 | Int_t nTracks = fAOD->GetNTracks(); | |
111 | ||
112 | printf("NUMBER OF AOD TRACKS %5d\n", nTracks); | |
113 | ||
114 | // Must start from scratch for each event | |
115 | fPWG2AODTracks->Delete(); | |
116 | fPWG2AODTracks->Expand(nTracks); | |
117 | TClonesArray &tPWG2AODTracks = *fPWG2AODTracks; | |
118 | ||
119 | // Loop over AOD tracks | |
120 | for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { | |
121 | AliAODTrack *aodTrack = fAOD->GetTrack(nTrack); | |
122 | Short_t trackId = aodTrack->GetID(); | |
123 | ||
124 | // Get the corresponding ESD track | |
125 | AliESDtrack *esdTrack = fESD->GetTrack(trackId); | |
126 | ||
127 | esdTrack->GetPxPyPz(p); | |
128 | ||
129 | if (TMath::Abs(p[0] - aodTrack->Px())>0.000000001) { | |
130 | printf("Got different momenta !!! %f %f\n", p[0], aodTrack->Px()); | |
131 | } | |
132 | ||
133 | sharemap = esdTrack->GetTPCSharedMap(); | |
134 | clustermap = esdTrack->GetTPCClusterMap(); | |
135 | ||
136 | esdTrack->GetInnerXYZ(tpcentrancepoint); | |
137 | tpcentrancepoint[2] -= pos[2]; | |
138 | ||
139 | esdTrack->GetOuterXYZ(tpcexitpoint); | |
140 | tpcexitpoint[2] -= pos[2]; | |
141 | ||
142 | // Add the PWG2 info into the AOD | |
143 | new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint, | |
144 | tpcexitpoint, | |
145 | sharemap, | |
146 | clustermap, | |
147 | aodTrack); | |
148 | } | |
149 | ||
150 | printf("PWG2=%d\n", fPWG2AODTracks->GetEntries()); | |
151 | ||
152 | return; | |
153 | } | |
154 |