]>
Commit | Line | Data |
---|---|---|
d255c404 | 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 | Double_t pos[3]; | |
93 | Double_t p[3]; | |
94 | Double_t tpcentrancepoint[3]; | |
95 | Double_t tpcexitpoint[3]; | |
96 | TBits sharemap; | |
97 | TBits clustermap; | |
98 | Int_t pTracks = 0; | |
99 | ||
100 | for (Int_t i = 0; i < 3; i++) { tpcentrancepoint[i] = 0.; tpcexitpoint[i] = 0; } | |
101 | ||
102 | // Get primary vertex | |
103 | const AliESDVertex *vtx = fESD->GetPrimaryVertex(); | |
104 | ||
105 | vtx->GetXYZ(pos); // position | |
106 | ||
107 | // Tracks (primary and orphan) | |
108 | Int_t nTracks = fAOD->GetNTracks(); | |
109 | ||
110 | printf("NUMBER OF AOD TRACKS %5d\n", nTracks); | |
111 | ||
112 | // Must start from scratch for each event | |
113 | fPWG2AODTracks->Delete(); | |
114 | fPWG2AODTracks->Expand(nTracks); | |
115 | TClonesArray &tPWG2AODTracks = *fPWG2AODTracks; | |
116 | ||
117 | // Loop over AOD tracks | |
118 | for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { | |
119 | AliAODTrack *aodTrack = fAOD->GetTrack(nTrack); | |
120 | Short_t trackId = aodTrack->GetID(); | |
121 | ||
122 | // Get the corresponding ESD track | |
123 | AliESDtrack *esdTrack = fESD->GetTrack(trackId); | |
124 | ||
125 | esdTrack->GetPxPyPz(p); | |
126 | ||
127 | if (fabs(p[0] - aodTrack->Px())>0.000000001) { | |
128 | printf("Got different momenta !!! %f %f\n", p[0], aodTrack->Px()); | |
129 | } | |
130 | ||
131 | sharemap = esdTrack->GetTPCSharedMap(); | |
132 | clustermap = esdTrack->GetTPCClusterMap(); | |
133 | ||
134 | esdTrack->GetInnerXYZ(tpcentrancepoint); | |
135 | tpcentrancepoint[2] -= pos[2]; | |
136 | ||
137 | esdTrack->GetOuterXYZ(tpcexitpoint); | |
138 | tpcexitpoint[2] -= pos[2]; | |
139 | ||
140 | // Add the PWG2 info into the AOD | |
141 | new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint, | |
142 | tpcexitpoint, | |
143 | sharemap, | |
144 | clustermap, | |
145 | aodTrack); | |
146 | } | |
147 | ||
148 | printf("PWG2=%d\n", fPWG2AODTracks->GetEntries()); | |
149 | ||
150 | return; | |
151 | } | |
152 |