]>
Commit | Line | Data |
---|---|---|
3435d75f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: ALICE Offline. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | //=========================================================================// | |
18 | // AliEbyE Analysis for Particle Ratio Fluctuation // | |
19 | // Deepika Rathee | Satyajit Jena // | |
20 | // drathee@cern.ch | sjena@cern.ch // | |
21 | // Dealing with Wide pT Addition (Test Only - not for use) | |
22 | //=========================================================================// | |
23 | ||
24 | #include "TChain.h" | |
25 | #include "TList.h" | |
26 | #include "TFile.h" | |
27 | #include "TTree.h" | |
28 | #include "TH1D.h" | |
29 | #include "TH2F.h" | |
30 | #include "TH3F.h" | |
31 | #include "TCanvas.h" | |
32 | #include "AliAnalysisTask.h" | |
33 | #include "AliAnalysisManager.h" | |
34 | #include "AliVEvent.h" | |
35 | #include "AliESD.h" | |
36 | #include "AliESDEvent.h" | |
37 | #include "AliAODEvent.h" | |
38 | #include "AliAODMCParticle.h" | |
39 | #include "AliAODMCHeader.h" | |
40 | #include "AliPIDResponse.h" | |
41 | #include "AliAODHeader.h" | |
42 | #include "AliAODpidUtil.h" | |
43 | #include "AliHelperPID.h" | |
44 | using std::endl; | |
45 | using std::cout; | |
46 | #include "AliEbyEPidTTask.h" | |
47 | ||
48 | ClassImp(AliEbyEPidTTask) | |
49 | ||
50 | //----------------------------------------------------------------------- | |
51 | AliEbyEPidTTask::AliEbyEPidTTask( const char *name ) : AliAnalysisTaskSE( name ), | |
52 | fThnList(NULL), | |
53 | isMC(kFALSE), | |
54 | fCentralityEstimator("V0M"), | |
55 | fAODtrackCutBit(128), | |
56 | fHelperPID(0x0), | |
57 | fEventCounter(NULL), | |
58 | fEventTree(NULL), | |
59 | isQA(kFALSE), | |
60 | fDebug(kFALSE), | |
61 | fRunNumber(0), | |
62 | fNumberOfTracks(8000), | |
63 | fNumberOfTracksM(8000), | |
64 | fFilterBit(99), | |
65 | fCentPercentile(-1), | |
66 | fVertexX(-99), | |
67 | fVertexY(-99), | |
68 | fVertexZ(-99) { | |
69 | /* | |
70 | fTrackPt[kTrack]; | |
71 | fTrackEta[kTrack]; | |
72 | fTrackPhi[kTrack]; | |
73 | fTrackPtM[kTrack]; | |
74 | fTrackEtaM[kTrack]; | |
75 | fTrackPhiM[kTrack]; | |
76 | fTrackCharge[kTrack]; | |
77 | fTrackPid[kTrack]; | |
78 | fTrackChargeM[kTrack]; | |
79 | fTrackPidM[kTrack]; | |
80 | */ | |
81 | ||
82 | DefineOutput(1, TList::Class()); //! Connect Outpput.... | |
83 | DefineOutput(2, TTree::Class()); //! Connect Outpput.... | |
84 | } | |
85 | ||
86 | AliEbyEPidTTask::~AliEbyEPidTTask() { | |
87 | //! Cleaning up | |
88 | if (fThnList) delete fThnList; | |
89 | if (fHelperPID) delete fHelperPID; | |
90 | // if (fEventTree) delete fEventTree; | |
91 | } | |
92 | ||
93 | //--------------------------------------------------------------------------------- | |
94 | void AliEbyEPidTTask::UserCreateOutputObjects() { | |
95 | fThnList = new TList(); | |
96 | fThnList->SetOwner(kTRUE); | |
97 | ||
be2d8a61 | 98 | fEventCounter = new TH1D("fEventCounter","EventCounter", 70, 0.5,70.5); |
3435d75f | 99 | fThnList->Add(fEventCounter); |
100 | ||
101 | TList *ll = (TList*)fHelperPID->GetOutputList(); | |
102 | for (Int_t ikey = 0; ikey < ll->GetEntries(); ikey++) { | |
103 | fThnList->Add(ll->At(ikey)); | |
104 | } | |
105 | ||
106 | fEventTree = new TTree("fEventTree","fEventTree"); | |
107 | ||
108 | fEventTree->Branch("fRunNumber", &fRunNumber, "fRunNumber/I"); | |
109 | fEventTree->Branch("fFilterBit", &fFilterBit, "fFilterBit/I"); | |
110 | fEventTree->Branch("fNumberOfTracks", &fNumberOfTracks,"fNumberOfTracks/I"); | |
111 | fEventTree->Branch("fCentPercentile", &fCentPercentile,"fCentPercentile/F"); | |
112 | ||
113 | fEventTree->Branch("fVertexX", &fVertexX, "fVertexX/F"); | |
114 | fEventTree->Branch("fVertexY", &fVertexY, "fVertexY/F"); | |
115 | fEventTree->Branch("fVertexZ", &fVertexZ, "fVertexZ/F"); | |
116 | ||
117 | fEventTree->Branch("fTrackPt", fTrackPt, "fTrackPt[fNumberOfTracks]/F"); | |
118 | fEventTree->Branch("fTrackPhi", fTrackPhi, "fTrackPhi[fNumberOfTracks]/F"); | |
119 | fEventTree->Branch("fTrackEta", fTrackEta, "fTrackEta[fNumberOfTracks]/F"); | |
120 | fEventTree->Branch("fTrackCharge", fTrackCharge, "fTrackCharge[fNumberOfTracks]/I"); | |
121 | fEventTree->Branch("fTrackPid", fTrackPid, "fTrackPid[fNumberOfTracks]/I"); | |
122 | ||
123 | if(isMC) { | |
124 | fEventTree->Branch("fNumberOfTracksM", &fNumberOfTracksM, "fNumberOfTracksM/I"); | |
125 | fEventTree->Branch("fTrackPtM", fTrackPtM, "fTrackPtM[fNumberOfTracksM]/F"); | |
126 | fEventTree->Branch("fTrackPhiM", fTrackPhiM, "fTrackPhiM[fNumberOfTracksM]/F"); | |
127 | fEventTree->Branch("fTrackEtaM", fTrackEtaM, "fTrackEtaM[fNumberOfTracksM]/F"); | |
128 | fEventTree->Branch("fTrackChargeM", fTrackChargeM, "fTrackChargeM[fNumberOfTracksM]/I"); | |
129 | fEventTree->Branch("fTrackPidM", fTrackPidM, "fTrackPidM[fNumberOfTracksM]/I"); | |
130 | } | |
131 | ||
132 | PostData(1, fThnList); | |
133 | PostData(2, fEventTree); | |
134 | } | |
135 | ||
136 | //---------------------------------------------------------------------------------- | |
137 | void AliEbyEPidTTask::UserExec( Option_t * ){ | |
138 | ||
139 | fEventCounter->Fill(1); | |
140 | ||
141 | AliAODEvent* event = dynamic_cast<AliAODEvent*>(InputEvent()); | |
142 | if (!event) { | |
143 | Printf("ERROR 01: AOD not found "); | |
144 | return; | |
145 | } | |
146 | ||
be2d8a61 | 147 | fEventCounter->Fill(2); |
148 | ||
3435d75f | 149 | Int_t gCent = -1; |
150 | Float_t gRefMul = -1; | |
151 | ||
152 | AliAODHeader *aodHeader = event->GetHeader(); | |
153 | gCent = (Int_t)aodHeader->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); | |
154 | gRefMul = aodHeader->GetRefMultiplicity(); | |
155 | if (gCent < 0 || gCent > 100) return; | |
be2d8a61 | 156 | fEventCounter->Fill(3); |
3435d75f | 157 | |
158 | const AliAODVertex *vertex = event->GetPrimaryVertex(); | |
159 | if(!vertex) return; | |
be2d8a61 | 160 | fEventCounter->Fill(4); |
3435d75f | 161 | Bool_t vtest = kFALSE; |
162 | Double32_t fCov[6]; | |
163 | vertex->GetCovarianceMatrix(fCov); | |
164 | if(vertex->GetNContributors() > 0) { | |
165 | if(fCov[5] != 0) { | |
166 | vtest = kTRUE; | |
167 | } | |
168 | } | |
169 | if(!vtest)return; | |
170 | ||
be2d8a61 | 171 | fEventCounter->Fill(5); |
172 | ||
3435d75f | 173 | AliCentrality *centrality = event->GetCentrality(); |
174 | if (centrality->GetQuality() != 0) return; | |
175 | ||
be2d8a61 | 176 | fEventCounter->Fill(6); |
177 | ||
3435d75f | 178 | fRunNumber = event->GetRunNumber(); |
179 | fFilterBit = fAODtrackCutBit; | |
180 | fCentPercentile = gCent; | |
181 | fVertexX = vertex->GetX(); | |
182 | fVertexY = vertex->GetY(); | |
183 | fVertexZ = vertex->GetZ(); | |
184 | ||
185 | Int_t iTracks = 0; | |
186 | for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) { | |
187 | AliAODTrack* track = dynamic_cast<AliAODTrack *>(event->GetTrack(itrk)); | |
be2d8a61 | 188 | fEventCounter->Fill(10); |
3435d75f | 189 | if (!track) continue; |
be2d8a61 | 190 | fEventCounter->Fill(11); |
3435d75f | 191 | if (!AcceptTrack(track)) continue; |
be2d8a61 | 192 | fEventCounter->Fill(12); |
3435d75f | 193 | Int_t a = fHelperPID->GetParticleSpecies((AliVTrack*) track,kTRUE); |
194 | if(a < 0 || a > 2) continue; | |
be2d8a61 | 195 | fEventCounter->Fill(13); |
3435d75f | 196 | Int_t icharge = track->Charge() > 0 ? 0 : 1; |
197 | ||
198 | // cout << icharge << " " << track->Charge() << endl; | |
199 | ||
200 | fTrackPt[iTracks] = (Float_t)track->Pt(); | |
201 | fTrackPhi[iTracks] = (Float_t)track->Phi(); | |
202 | fTrackEta[iTracks] = (Float_t)track->Eta(); | |
203 | fTrackCharge[iTracks] = icharge; | |
204 | fTrackPid[iTracks] = a; | |
205 | iTracks++; | |
206 | } | |
207 | fNumberOfTracks = iTracks; | |
208 | ||
209 | if(isMC) { | |
be2d8a61 | 210 | fEventCounter->Fill(21); |
3435d75f | 211 | TClonesArray *arrayMC= 0; |
212 | arrayMC = dynamic_cast<TClonesArray*> (event->GetList()->FindObject(AliAODMCParticle::StdBranchName())); | |
213 | if (!arrayMC) { | |
214 | Printf("Error: MC particles branch not found!\n"); | |
215 | return; | |
216 | } | |
be2d8a61 | 217 | fEventCounter->Fill(22); |
3435d75f | 218 | AliAODMCHeader *mcHdr=0; |
219 | mcHdr=(AliAODMCHeader*)event->GetList()->FindObject(AliAODMCHeader::StdBranchName()); | |
220 | if(!mcHdr) { | |
221 | Printf("MC header branch not found!\n"); | |
222 | return; | |
223 | } | |
be2d8a61 | 224 | |
225 | fEventCounter->Fill(23); | |
3435d75f | 226 | |
227 | Int_t nMC = arrayMC->GetEntries(); | |
228 | Int_t mTracks = 0; | |
229 | for (Int_t iMC = 0; iMC < nMC; iMC++) { | |
be2d8a61 | 230 | fEventCounter->Fill(24); |
3435d75f | 231 | AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC); |
232 | if(!AcceptMCTrack(partMC)) continue; | |
233 | ||
be2d8a61 | 234 | fEventCounter->Fill(25); |
3435d75f | 235 | Int_t a = partMC->GetPdgCode(); |
236 | ||
237 | // Int_t a = fHelperPID->GetMCParticleSpecie((AliVEvent*) event,(AliVTrack*)partMC,1); | |
238 | ||
239 | //if(a < 0 || a > 2) continue; | |
240 | Int_t icharge = a > 0 ? 0 : 1; | |
241 | ||
242 | // cout << a << " " << icharge << endl; | |
243 | ||
244 | fTrackPtM[mTracks] = (Float_t)partMC->Pt(); | |
245 | fTrackPhiM[mTracks] = (Float_t)partMC->Phi(); | |
246 | fTrackEtaM[mTracks] = (Float_t)partMC->Eta(); | |
247 | fTrackChargeM[mTracks] = icharge; | |
248 | fTrackPidM[mTracks] = a; | |
249 | ||
250 | mTracks++; | |
251 | } | |
be2d8a61 | 252 | fEventCounter->Fill(26); |
3435d75f | 253 | fNumberOfTracksM = mTracks; |
254 | } | |
255 | ||
be2d8a61 | 256 | fEventCounter->Fill(30); |
257 | fEventTree->Fill(); | |
3435d75f | 258 | |
259 | PostData(1, fThnList); | |
260 | PostData(2, fEventTree); | |
261 | } | |
262 | ||
263 | //___________________________________________________________ | |
264 | void AliEbyEPidTTask::Terminate( Option_t * ){ | |
265 | Info("AliEbyEPidTTask"," Task Successfully finished"); | |
266 | } | |
267 | ||
268 | //___________________________________________________________ | |
269 | Bool_t AliEbyEPidTTask::AcceptTrack(AliAODTrack *track) const { | |
270 | if(!track) return kFALSE; | |
271 | if (track->Charge() == 0 ) return kFALSE; | |
272 | if (!track->TestFilterBit(fAODtrackCutBit)) return kFALSE; | |
273 | return kTRUE; | |
274 | } | |
275 | ||
276 | ||
277 | //___________________________________________________________ | |
278 | Bool_t AliEbyEPidTTask::AcceptMCTrack(AliAODMCParticle *track) const { | |
279 | if(!track) return kFALSE; | |
280 | if(!track->IsPhysicalPrimary()) return kFALSE; | |
281 | if (track->Charge() == 0 ) return kFALSE; | |
282 | return kTRUE; | |
283 | } |