]>
Commit | Line | Data |
---|---|---|
027ebdf2 | 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 "AliEbyEPidTTaskMC.h" | |
47 | ||
48 | ClassImp(AliEbyEPidTTaskMC) | |
49 | ||
50 | //----------------------------------------------------------------------- | |
51 | AliEbyEPidTTaskMC::AliEbyEPidTTaskMC( 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), | |
027ebdf2 | 59 | fRunNumber(0), |
60 | fNumberOfTracks(8000), | |
61 | fNumberOfTracksM(8000), | |
62 | fFilterBit(99), | |
63 | fCentPercentile(-1), | |
64 | fVertexX(-99), | |
65 | fVertexY(-99), | |
66 | fVertexZ(-99) { | |
67 | /* | |
68 | fTrackPt[kTrack]; | |
69 | fTrackEta[kTrack]; | |
70 | fTrackPhi[kTrack]; | |
71 | fTrackPtM[kTrack]; | |
72 | fTrackEtaM[kTrack]; | |
73 | fTrackPhiM[kTrack]; | |
74 | fTrackCharge[kTrack]; | |
75 | fTrackPid[kTrack]; | |
76 | fTrackChargeM[kTrack]; | |
77 | fTrackPidM[kTrack]; | |
78 | */ | |
50c07b57 | 79 | DefineInput(0,TChain::Class()); |
80 | DefineOutput(1, TList::Class()); | |
81 | DefineOutput(2, TTree::Class()); | |
027ebdf2 | 82 | } |
83 | ||
84 | AliEbyEPidTTaskMC::~AliEbyEPidTTaskMC() { | |
85 | //! Cleaning up | |
50c07b57 | 86 | if (fThnList) delete fThnList; |
87 | if (fHelperPID) delete fHelperPID; | |
88 | if (fEventTree) delete fEventTree; | |
027ebdf2 | 89 | } |
90 | ||
91 | //--------------------------------------------------------------------------------- | |
92 | void AliEbyEPidTTaskMC::UserCreateOutputObjects() { | |
93 | fThnList = new TList(); | |
94 | fThnList->SetOwner(kTRUE); | |
95 | ||
96 | fEventCounter = new TH1D("fEventCounter","EventCounter", 70, 0.5,70.5); | |
97 | fThnList->Add(fEventCounter); | |
98 | ||
99 | TList *ll = (TList*)fHelperPID->GetOutputList(); | |
100 | for (Int_t ikey = 0; ikey < ll->GetEntries(); ikey++) { | |
101 | fThnList->Add(ll->At(ikey)); | |
102 | } | |
50c07b57 | 103 | TDirectory *owd = gDirectory; |
104 | OpenFile(1); | |
027ebdf2 | 105 | fEventTree = new TTree("fEventTree","fEventTree"); |
50c07b57 | 106 | owd->cd(); |
107 | ||
027ebdf2 | 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 | ||
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 | PostData(1, fThnList); | |
132 | PostData(2, fEventTree); | |
133 | } | |
134 | ||
135 | //---------------------------------------------------------------------------------- | |
136 | void AliEbyEPidTTaskMC::UserExec( Option_t * ){ | |
137 | ||
50c07b57 | 138 | fEventCounter->Fill(1); |
139 | ||
027ebdf2 | 140 | AliAODEvent* event = dynamic_cast<AliAODEvent*>(InputEvent()); |
141 | if (!event) { | |
142 | Printf("ERROR 01: AOD not found "); | |
143 | return; | |
144 | } | |
50c07b57 | 145 | |
027ebdf2 | 146 | fEventCounter->Fill(2); |
147 | ||
148 | Int_t gCent = -1; | |
149 | Float_t gRefMul = -1; | |
150 | ||
151 | AliAODHeader *aodHeader = event->GetHeader(); | |
152 | gCent = (Int_t)aodHeader->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); | |
153 | gRefMul = aodHeader->GetRefMultiplicity(); | |
154 | if (gCent < 0 || gCent > 100) return; | |
155 | fEventCounter->Fill(3); | |
156 | ||
157 | const AliAODVertex *vertex = event->GetPrimaryVertex(); | |
158 | if(!vertex) return; | |
159 | fEventCounter->Fill(4); | |
160 | Bool_t vtest = kFALSE; | |
161 | Double32_t fCov[6]; | |
162 | vertex->GetCovarianceMatrix(fCov); | |
163 | if(vertex->GetNContributors() > 0) { | |
164 | if(fCov[5] != 0) { | |
165 | vtest = kTRUE; | |
166 | } | |
167 | } | |
168 | if(!vtest)return; | |
169 | ||
170 | fEventCounter->Fill(5); | |
171 | ||
172 | AliCentrality *centrality = event->GetCentrality(); | |
173 | if (centrality->GetQuality() != 0) return; | |
174 | ||
175 | fEventCounter->Fill(6); | |
50c07b57 | 176 | |
027ebdf2 | 177 | fRunNumber = event->GetRunNumber(); |
178 | fFilterBit = fAODtrackCutBit; | |
179 | fCentPercentile = gCent; | |
180 | fVertexX = vertex->GetX(); | |
181 | fVertexY = vertex->GetY(); | |
182 | fVertexZ = vertex->GetZ(); | |
183 | ||
184 | Int_t iTracks = 0; | |
185 | for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) { | |
186 | AliAODTrack* track = dynamic_cast<AliAODTrack *>(event->GetTrack(itrk)); | |
187 | fEventCounter->Fill(10); | |
188 | if (!track) continue; | |
189 | fEventCounter->Fill(11); | |
190 | if (!AcceptTrack(track)) continue; | |
191 | fEventCounter->Fill(12); | |
192 | Int_t a = fHelperPID->GetParticleSpecies((AliVTrack*) track,kTRUE); | |
193 | if(a < 0 || a > 2) continue; | |
194 | fEventCounter->Fill(13); | |
195 | Int_t icharge = track->Charge() > 0 ? 0 : 1; | |
196 | ||
197 | // cout << icharge << " " << track->Charge() << endl; | |
198 | ||
199 | fTrackPt[iTracks] = (Float_t)track->Pt(); | |
200 | fTrackPhi[iTracks] = (Float_t)track->Phi(); | |
201 | fTrackEta[iTracks] = (Float_t)track->Eta(); | |
202 | fTrackCharge[iTracks] = icharge; | |
203 | fTrackPid[iTracks] = a; | |
204 | iTracks++; | |
205 | } | |
206 | fNumberOfTracks = iTracks; | |
207 | ||
208 | fEventCounter->Fill(21); | |
50c07b57 | 209 | |
210 | TClonesArray *arrayMC= 0; | |
211 | arrayMC = dynamic_cast<TClonesArray*> (event->GetList()->FindObject(AliAODMCParticle::StdBranchName())); | |
212 | if (!arrayMC) { | |
213 | Printf("Error: MC particles branch not found!\n"); | |
027ebdf2 | 214 | return; |
50c07b57 | 215 | } |
216 | fEventCounter->Fill(22); | |
217 | AliAODMCHeader *mcHdr=0; | |
218 | mcHdr=(AliAODMCHeader*)event->GetList()->FindObject(AliAODMCHeader::StdBranchName()); | |
219 | if(!mcHdr) { | |
027ebdf2 | 220 | Printf("MC header branch not found!\n"); |
221 | return; | |
50c07b57 | 222 | } |
223 | ||
224 | fEventCounter->Fill(23); | |
225 | ||
226 | ||
227 | Int_t mTracks = 0; | |
228 | ||
229 | Int_t nMC = arrayMC->GetEntries(); | |
230 | ||
231 | for (Int_t iMC = 0; iMC < nMC; iMC++) { | |
232 | //fEventCounter->Fill(24); | |
233 | AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC); | |
234 | // if(!partMC) continue; | |
235 | if(!AcceptMCTrack(partMC)) continue; | |
236 | // fEventCounter->Fill(25); | |
237 | Int_t a = partMC->GetPdgCode(); | |
238 | //Int_t a = 0; | |
239 | // Int_t a = fHelperPID->GetMCParticleSpecie((AliVEvent*) event,(AliVTrack*)partMC,1); | |
027ebdf2 | 240 | |
50c07b57 | 241 | //if(a < 0 || a > 2) continue; |
242 | Int_t icharge = a > 0 ? 0 : 1; | |
243 | // cout << a << " " << icharge << " " << iMC << " " << mTracks << endl; | |
027ebdf2 | 244 | |
50c07b57 | 245 | fTrackPtM[mTracks] = (Float_t)partMC->Pt(); |
246 | fTrackPhiM[mTracks] = (Float_t)partMC->Phi(); | |
247 | fTrackEtaM[mTracks] = (Float_t)partMC->Eta(); | |
248 | fTrackChargeM[mTracks] = icharge; | |
249 | fTrackPidM[mTracks] = a; | |
250 | mTracks++; | |
251 | } | |
252 | // cout << mTracks << " " << nMC << endl; | |
253 | fEventCounter->Fill(26); | |
254 | fNumberOfTracksM = mTracks; | |
027ebdf2 | 255 | |
256 | fEventCounter->Fill(30); | |
257 | fEventTree->Fill(); | |
258 | ||
259 | if(isMC) fEventCounter->Fill(46); | |
260 | else fEventCounter->Fill(48); | |
50c07b57 | 261 | |
027ebdf2 | 262 | PostData(1, fThnList); |
263 | PostData(2, fEventTree); | |
264 | } | |
265 | ||
266 | //___________________________________________________________ | |
267 | void AliEbyEPidTTaskMC::Terminate( Option_t * ){ | |
268 | Info("AliEbyEPidTTaskMC"," Task Successfully finished"); | |
269 | } | |
270 | ||
271 | //___________________________________________________________ | |
272 | Bool_t AliEbyEPidTTaskMC::AcceptTrack(AliAODTrack *track) const { | |
273 | if(!track) return kFALSE; | |
274 | if (track->Charge() == 0 ) return kFALSE; | |
275 | if (!track->TestFilterBit(fAODtrackCutBit)) return kFALSE; | |
50c07b57 | 276 | if (TMath::Abs(track->Eta()) > 3) return kFALSE; |
027ebdf2 | 277 | return kTRUE; |
278 | } | |
279 | ||
280 | ||
281 | //___________________________________________________________ | |
282 | Bool_t AliEbyEPidTTaskMC::AcceptMCTrack(AliAODMCParticle *track) const { | |
283 | if(!track) return kFALSE; | |
284 | if(!track->IsPhysicalPrimary()) return kFALSE; | |
285 | if (track->Charge() == 0 ) return kFALSE; | |
50c07b57 | 286 | if (TMath::Abs(track->Eta()) > 3) return kFALSE; |
027ebdf2 | 287 | return kTRUE; |
288 | } |