]>
Commit | Line | Data |
---|---|---|
fdceab34 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
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 | //----------------------------------------------------------------------- | |
2b553e6f | 17 | // Efficiency between different steps of the procedure. |
fdceab34 | 18 | // The ouptut of the task is a AliCFContainer from which the efficiencies |
19 | // can be calculated | |
20 | //----------------------------------------------------------------------- | |
21 | // Author : Marta Verweij - UU | |
22 | //----------------------------------------------------------------------- | |
23 | ||
24 | ||
67ebd013 | 25 | #ifndef ALIPWG4HIGHPTSPECTRA_CXX |
26 | #define ALIPWG4HIGHPTSPECTRA_CXX | |
fdceab34 | 27 | |
28 | #include "AliPWG4HighPtSpectra.h" | |
29 | ||
67ebd013 | 30 | #include "TVector3.h" |
31 | #include <iostream> | |
32 | #include "TH1.h" | |
33 | #include "TH2.h" | |
34 | #include "TH3.h" | |
b4691ee7 | 35 | #include "TProfile.h" |
67ebd013 | 36 | #include "TList.h" |
37 | #include "TChain.h" | |
b4691ee7 | 38 | #include "TKey.h" |
39 | #include "TSystem.h" | |
40 | #include "TFile.h" | |
67ebd013 | 41 | |
42 | #include "AliAnalysisManager.h" | |
43 | #include "AliESDInputHandler.h" | |
44 | #include "AliESDtrack.h" | |
45 | #include "AliESDtrackCuts.h" | |
46 | #include "AliExternalTrackParam.h" | |
2b553e6f | 47 | #include "AliCentrality.h" |
65e8ecdd | 48 | |
67ebd013 | 49 | #include "AliLog.h" |
50 | ||
fdceab34 | 51 | #include "AliStack.h" |
52 | #include "TParticle.h" | |
fdceab34 | 53 | #include "AliMCEvent.h" |
54 | #include "AliMCEventHandler.h" | |
fdceab34 | 55 | #include "AliCFContainer.h" |
b4691ee7 | 56 | #include "AliGenPythiaEventHeader.h" |
57 | #include "AliGenCocktailEventHeader.h" | |
67ebd013 | 58 | //#include "$ALICE_ROOT/PWG4/JetTasks/AliAnalysisHelperJetTasks.h" |
59 | ||
60 | //#include <iostream> | |
fdceab34 | 61 | using namespace std; //required for resolving the 'cout' symbol |
62 | ||
63 | ClassImp(AliPWG4HighPtSpectra) | |
64 | ||
65 | //__________________________________________________________________________ | |
66 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra() : AliAnalysisTask("AliPWG4HighPtSpectra", ""), | |
67 | fReadAODData(0), | |
67ebd013 | 68 | fCFManagerPos(0x0), |
69 | fCFManagerNeg(0x0), | |
cce400da | 70 | fESD(0x0), |
71 | fMC(0x0), | |
72 | fStack(0x0), | |
34fc6450 | 73 | fVtx(0x0), |
5d87a047 | 74 | fTriggerMask(AliVEvent::kMB), |
2b553e6f | 75 | fIsPbPb(0), |
76 | fCentClass(10), | |
34fc6450 | 77 | fTrackType(0), |
cce400da | 78 | fTrackCuts(0x0), |
327d12da | 79 | fTrackCutsReject(0x0), |
dae7dd67 | 80 | fSigmaConstrainedMax(100.), |
b4691ee7 | 81 | fAvgTrials(1), |
fdceab34 | 82 | fHistList(0), |
b5cc0c6d | 83 | fNEventAll(0), |
b4691ee7 | 84 | fNEventSel(0), |
cb76764e | 85 | fNEventReject(0), |
2b553e6f | 86 | fh1Centrality(0x0), |
b4691ee7 | 87 | fh1Xsec(0), |
88 | fh1Trials(0), | |
89 | fh1PtHard(0), | |
a337a5a9 | 90 | fh1PtHardTrials(0), |
91 | fPtRelUncertainty1PtPrim(0x0), | |
92 | fPtRelUncertainty1PtSec(0x0) | |
fdceab34 | 93 | { |
94 | // | |
95 | //Default ctor | |
96 | // | |
97 | } | |
98 | //___________________________________________________________________________ | |
99 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const Char_t* name) : | |
100 | AliAnalysisTask(name,""), | |
101 | fReadAODData(0), | |
67ebd013 | 102 | fCFManagerPos(0x0), |
103 | fCFManagerNeg(0x0), | |
cce400da | 104 | fESD(0x0), |
105 | fMC(0x0), | |
106 | fStack(0x0), | |
34fc6450 | 107 | fVtx(0x0), |
5d87a047 | 108 | fTriggerMask(AliVEvent::kMB), |
2b553e6f | 109 | fIsPbPb(0), |
110 | fCentClass(10), | |
34fc6450 | 111 | fTrackType(0), |
cce400da | 112 | fTrackCuts(0x0), |
327d12da | 113 | fTrackCutsReject(0x0), |
dae7dd67 | 114 | fSigmaConstrainedMax(100.), |
b4691ee7 | 115 | fAvgTrials(1), |
fdceab34 | 116 | fHistList(0), |
b5cc0c6d | 117 | fNEventAll(0), |
b4691ee7 | 118 | fNEventSel(0), |
cb76764e | 119 | fNEventReject(0), |
2b553e6f | 120 | fh1Centrality(0x0), |
b4691ee7 | 121 | fh1Xsec(0), |
122 | fh1Trials(0), | |
123 | fh1PtHard(0), | |
a337a5a9 | 124 | fh1PtHardTrials(0), |
125 | fPtRelUncertainty1PtPrim(0x0), | |
126 | fPtRelUncertainty1PtSec(0x0) | |
fdceab34 | 127 | { |
128 | // | |
129 | // Constructor. Initialization of Inputs and Outputs | |
130 | // | |
f51451be | 131 | AliDebug(2,Form("AliPWG4HighPtSpectra Calling Constructor")); |
fdceab34 | 132 | // Input slot #0 works with a TChain ESD |
133 | DefineInput(0, TChain::Class()); | |
e5abcde9 | 134 | // Output slot #0 writes into a TList |
fdceab34 | 135 | DefineOutput(0,TList::Class()); |
e5abcde9 | 136 | // Output slot #1, #2 writes into a AliCFContainer |
fdceab34 | 137 | DefineOutput(1,AliCFContainer::Class()); |
67ebd013 | 138 | DefineOutput(2,AliCFContainer::Class()); |
e5abcde9 | 139 | // Output slot #3 writes into a AliESDtrackCuts |
140 | DefineOutput(3, AliESDtrackCuts::Class()); | |
1f329128 | 141 | DefineOutput(4, AliESDtrackCuts::Class()); |
e5abcde9 | 142 | } |
143 | ||
144 | //________________________________________________________________________ | |
145 | void AliPWG4HighPtSpectra::LocalInit() | |
146 | { | |
147 | // | |
148 | // Only called once at beginning | |
149 | // | |
150 | PostData(3,fTrackCuts); | |
fdceab34 | 151 | } |
152 | ||
fdceab34 | 153 | //________________________________________________________________________ |
154 | void AliPWG4HighPtSpectra::ConnectInputData(Option_t *) | |
155 | { | |
156 | // Connect ESD here | |
157 | // Called once | |
df943115 | 158 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::ConnectInputData \n")); |
fdceab34 | 159 | |
160 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
161 | if (!tree) { | |
cce400da | 162 | AliDebug(2,Form( "ERROR: Could not read chain from input slot 0 \n")); |
163 | return; | |
fdceab34 | 164 | } |
cce400da | 165 | |
166 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
167 | ||
168 | if (!esdH) { | |
169 | AliDebug(2,Form("ERROR: Could not get ESDInputHandler")); | |
170 | return; | |
171 | } else | |
172 | fESD = esdH->GetEvent(); | |
67ebd013 | 173 | |
cce400da | 174 | AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
175 | if (!eventHandler) { | |
176 | AliDebug(2,Form( "ERROR: Could not retrieve MC event handler \n")); | |
177 | } | |
178 | else | |
179 | fMC = eventHandler->MCEvent(); | |
180 | ||
fdceab34 | 181 | } |
cce400da | 182 | |
183 | //________________________________________________________________________ | |
184 | Bool_t AliPWG4HighPtSpectra::SelectEvent() { | |
fdceab34 | 185 | // |
cce400da | 186 | // Decide if event should be selected for analysis |
fdceab34 | 187 | // |
fdceab34 | 188 | |
cce400da | 189 | // Checks following requirements: |
190 | // - fESD available | |
191 | // - trigger info from AliPhysicsSelection | |
192 | // - number of reconstructed tracks > 1 | |
193 | // - primary vertex reconstructed | |
194 | // - z-vertex < 10 cm | |
195 | ||
196 | Bool_t selectEvent = kTRUE; | |
b5cc0c6d | 197 | |
cce400da | 198 | //fESD object available? |
fdceab34 | 199 | if (!fESD) { |
cce400da | 200 | AliDebug(2,Form("ERROR: fInputEvent not available\n")); |
cb76764e | 201 | fNEventReject->Fill("noESD",1); |
cce400da | 202 | selectEvent = kFALSE; |
203 | return selectEvent; | |
fdceab34 | 204 | } |
205 | ||
cce400da | 206 | //Trigger |
bfd58011 | 207 | UInt_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); |
5d87a047 | 208 | if(fTriggerMask != AliVEvent::kAny && !(isSelected&fTriggerMask)) { //Select collison candidates |
b5cc0c6d | 209 | AliDebug(2,Form(" Trigger Selection: event REJECTED ... ")); |
cb76764e | 210 | fNEventReject->Fill("Trigger",1); |
cce400da | 211 | selectEvent = kFALSE; |
212 | return selectEvent; | |
67ebd013 | 213 | } |
b5cc0c6d | 214 | |
cce400da | 215 | //Check if number of reconstructed tracks is larger than 1 |
216 | if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2) { | |
217 | fNEventReject->Fill("NTracks<2",1); | |
218 | selectEvent = kFALSE; | |
219 | return selectEvent; | |
fdceab34 | 220 | } |
b4691ee7 | 221 | |
cce400da | 222 | //Check if vertex is reconstructed |
34fc6450 | 223 | fVtx = fESD->GetPrimaryVertexSPD(); |
224 | ||
225 | if(!fVtx) { | |
226 | fNEventReject->Fill("noVTX",1); | |
227 | selectEvent = kFALSE; | |
228 | return selectEvent; | |
229 | } | |
230 | ||
231 | if(!fVtx->GetStatus()) { | |
232 | fNEventReject->Fill("VtxStatus",1); | |
233 | selectEvent = kFALSE; | |
234 | return selectEvent; | |
235 | } | |
236 | ||
fdceab34 | 237 | // Need vertex cut |
34fc6450 | 238 | // TString vtxName(fVtx->GetName()); |
239 | if(fVtx->GetNContributors()<2) { | |
240 | fNEventReject->Fill("NCont<2",1); | |
241 | selectEvent = kFALSE; | |
242 | return selectEvent; | |
cd9a6fa2 | 243 | } |
cce400da | 244 | |
245 | //Check if z-vertex < 10 cm | |
b5cc0c6d | 246 | double primVtx[3]; |
34fc6450 | 247 | fVtx->GetXYZ(primVtx); |
67ebd013 | 248 | if(TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2]>10.)){ |
cb76764e | 249 | fNEventReject->Fill("ZVTX>10",1); |
cce400da | 250 | selectEvent = kFALSE; |
251 | return selectEvent; | |
67ebd013 | 252 | } |
cce400da | 253 | |
2b553e6f | 254 | //Centrality selection should only be done in case of PbPb |
255 | if(IsPbPb()) { | |
256 | Float_t cent = 0.; | |
257 | if(fCentClass!=CalculateCentrality(fESD) && fCentClass!=10) { | |
258 | fNEventReject->Fill("cent",1); | |
259 | selectEvent = kFALSE; | |
260 | return selectEvent; | |
261 | } | |
262 | else { | |
263 | if(dynamic_cast<AliESDEvent*>(fESD)->GetCentrality()) { | |
264 | cent = dynamic_cast<AliESDEvent*>(fESD)->GetCentrality()->GetCentralityPercentile("V0M"); | |
265 | } | |
266 | if(cent>90.) { | |
267 | fNEventReject->Fill("cent>90",1); | |
268 | selectEvent = kFALSE; | |
269 | return selectEvent; | |
270 | } | |
271 | fh1Centrality->Fill(cent); | |
272 | } | |
273 | } | |
274 | ||
cce400da | 275 | return selectEvent; |
276 | ||
277 | } | |
278 | ||
2b553e6f | 279 | //________________________________________________________________________ |
280 | Int_t AliPWG4HighPtSpectra::CalculateCentrality(AliESDEvent *esd){ | |
281 | ||
282 | ||
283 | Float_t cent = 999; | |
284 | ||
285 | if(esd){ | |
286 | if(esd->GetCentrality()){ | |
287 | cent = esd->GetCentrality()->GetCentralityPercentile("V0M"); | |
288 | } | |
289 | } | |
290 | ||
b1041e3b | 291 | if(cent<0) return 5; |
2b553e6f | 292 | if(cent>80)return 4; |
293 | if(cent>50)return 3; | |
294 | if(cent>30)return 2; | |
295 | if(cent>10)return 1; | |
296 | return 0; | |
297 | ||
298 | } | |
299 | ||
cce400da | 300 | //_________________________________________________ |
301 | void AliPWG4HighPtSpectra::Exec(Option_t *) | |
302 | { | |
303 | // | |
304 | // Main loop function | |
305 | // | |
306 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n")); | |
307 | ||
308 | // All events without selection | |
309 | fNEventAll->Fill(0.); | |
310 | ||
311 | if(!SelectEvent()) { | |
67ebd013 | 312 | // Post output data |
313 | PostData(0,fHistList); | |
314 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
315 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
cd9a6fa2 | 316 | return; |
317 | } | |
cce400da | 318 | |
319 | //MCEvent available? | |
320 | //if yes: get stack | |
321 | if(fMC) { | |
322 | AliDebug(2,Form("MC particles: %d", fMC->GetNumberOfTracks())); | |
323 | fStack = fMC->Stack(); //Particles Stack | |
324 | AliDebug(2,Form("MC particles stack: %d", fStack->GetNtrack())); | |
325 | } | |
326 | ||
fdceab34 | 327 | Int_t nTracks = fESD->GetNumberOfTracks(); |
328 | AliDebug(2,Form("nTracks %d", nTracks)); | |
fdceab34 | 329 | |
67ebd013 | 330 | if(!fTrackCuts) { |
cb76764e | 331 | fNEventReject->Fill("noTrackCuts",1); |
67ebd013 | 332 | // Post output data |
333 | PostData(0,fHistList); | |
334 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
335 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
336 | return; | |
337 | } | |
338 | ||
b5cc0c6d | 339 | // Selected events for analysis |
340 | fNEventSel->Fill(0.); | |
67ebd013 | 341 | |
dae7dd67 | 342 | const Int_t nvar = 4; |
67ebd013 | 343 | |
dae7dd67 | 344 | Double_t containerInputRec[nvar] = {0.,0.,0.,0.}; |
345 | Double_t containerInputMC[nvar] = {0.,0.,0.,0.}; | |
346 | Double_t containerInputRecMC[nvar] = {0.,0.,0.,0.}; //reconstructed yield as function of MC variable | |
ec555a3c | 347 | |
fdceab34 | 348 | //Now go to rec level |
349 | for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) | |
350 | { | |
2b553e6f | 351 | //Get track for analysis |
352 | AliESDtrack *track = 0x0; | |
353 | AliESDtrack *esdtrack = fESD->GetTrack(iTrack); | |
354 | if(!esdtrack) continue; | |
355 | ||
8da84c2c | 356 | if(fTrackType==1) { |
2b553e6f | 357 | track = AliESDtrackCuts::GetTPCOnlyTrack(fESD,esdtrack->GetID()); |
8da84c2c | 358 | if(!track) continue; |
359 | } | |
2b553e6f | 360 | else if(fTrackType==2) { |
361 | track = AliESDtrackCuts::GetTPCOnlyTrack(fESD,esdtrack->GetID()); | |
362 | if(!track) continue; | |
363 | ||
364 | AliExternalTrackParam exParam; | |
365 | Bool_t relate = track->RelateToVertexTPC(fVtx,fESD->GetMagneticField(),kVeryBig,&exParam); | |
366 | if( !relate ) { | |
367 | delete track; | |
34fc6450 | 368 | continue; |
369 | } | |
2b553e6f | 370 | track->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance()); |
bcd60a94 | 371 | } |
d3a3f33d | 372 | else if(fTrackType==7) { |
373 | //use global constrained track | |
42881dab | 374 | track = new AliESDtrack(*esdtrack); |
375 | // track = esdtrack; | |
031aac8e | 376 | // track->Set(esdtrack->GetConstrainedParam()->GetX(),esdtrack->GetConstrainedParam()->GetAlpha(),esdtrack->GetConstrainedParam()->GetParameter(),esdtrack->GetConstrainedParam()->GetCovariance()); |
d3a3f33d | 377 | |
378 | } | |
bcd60a94 | 379 | else |
2b553e6f | 380 | track = esdtrack; |
bcd60a94 | 381 | |
83ff93cd | 382 | if(!track) continue; |
2b553e6f | 383 | |
384 | if(fTrackType==2) { | |
385 | //Cut on chi2 of constrained fit | |
386 | if(track->GetConstrainedChi2TPC() > fSigmaConstrainedMax*fSigmaConstrainedMax) { | |
387 | delete track; | |
388 | continue; | |
389 | } | |
390 | } | |
fdceab34 | 391 | |
1f329128 | 392 | if (fTrackCuts->AcceptTrack(track)) { |
031aac8e | 393 | |
394 | if(fTrackType==7) { | |
327d12da | 395 | if(fTrackCutsReject ) { |
42881dab | 396 | if(fTrackCutsReject->AcceptTrack(track) ) { |
397 | if(track) delete track; | |
327d12da | 398 | continue; |
42881dab | 399 | } |
327d12da | 400 | } |
401 | ||
031aac8e | 402 | if(esdtrack->GetConstrainedParam()) |
403 | track->Set(esdtrack->GetConstrainedParam()->GetX(),esdtrack->GetConstrainedParam()->GetAlpha(),esdtrack->GetConstrainedParam()->GetParameter(),esdtrack->GetConstrainedParam()->GetCovariance()); | |
031aac8e | 404 | } |
405 | ||
406 | //fill the container | |
407 | containerInputRec[0] = track->Pt(); | |
408 | containerInputRec[1] = track->Phi(); | |
409 | containerInputRec[2] = track->Eta(); | |
dae7dd67 | 410 | containerInputRec[3] = track->GetTPCNclsIter1(); |
031aac8e | 411 | |
1f329128 | 412 | if(track->GetSign()>0.) fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); |
413 | if(track->GetSign()<0.) fCFManagerNeg->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); | |
414 | ||
67ebd013 | 415 | |
1f329128 | 416 | //Only fill the MC containers if MC information is available |
cce400da | 417 | if(fMC) { |
0cc50ca6 | 418 | Int_t label = TMath::Abs(track->GetLabel()); |
5d87a047 | 419 | if(label>fStack->GetNtrack()) { |
420 | if(fTrackType==1 || fTrackType==2 || fTrackType==7) | |
421 | delete track; | |
422 | continue; | |
423 | } | |
cce400da | 424 | TParticle *particle = fStack->Particle(label) ; |
bcd60a94 | 425 | if(!particle) { |
42881dab | 426 | if(fTrackType==1 || fTrackType==2 || fTrackType==7) |
2b553e6f | 427 | delete track; |
bcd60a94 | 428 | continue; |
429 | } | |
ec555a3c | 430 | containerInputRecMC[0] = particle->Pt(); |
431 | containerInputRecMC[1] = particle->Phi(); | |
432 | containerInputRecMC[2] = particle->Eta(); | |
dae7dd67 | 433 | containerInputRecMC[3] = track->GetTPCNclsIter1(); |
67ebd013 | 434 | |
1f329128 | 435 | //Container with primaries |
cce400da | 436 | if(fStack->IsPhysicalPrimary(label)) { |
1f329128 | 437 | if(particle->GetPDG()->Charge()>0.) { |
ec555a3c | 438 | fCFManagerPos->GetParticleContainer()->Fill(containerInputRecMC,kStepReconstructedMC); |
1f329128 | 439 | } |
440 | if(particle->GetPDG()->Charge()<0.) { | |
ec555a3c | 441 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputRecMC,kStepReconstructedMC); |
1f329128 | 442 | } |
a337a5a9 | 443 | |
444 | //Fill pT resolution plots for primaries | |
b8f6bad5 | 445 | fPtRelUncertainty1PtPrim->Fill(containerInputRec[0],containerInputRec[0]*TMath::Sqrt(track->GetSigma1Pt2())); |
a337a5a9 | 446 | |
67ebd013 | 447 | } |
448 | ||
1f329128 | 449 | //Container with secondaries |
cce400da | 450 | if (!fStack->IsPhysicalPrimary(label) ) { |
67ebd013 | 451 | if(particle->GetPDG()->Charge()>0.) { |
aa3ba8d2 | 452 | fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepSecondaries); |
67ebd013 | 453 | } |
454 | if(particle->GetPDG()->Charge()<0.) { | |
aa3ba8d2 | 455 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepSecondaries); |
67ebd013 | 456 | } |
a337a5a9 | 457 | //Fill pT resolution plots for primaries |
b8f6bad5 | 458 | fPtRelUncertainty1PtSec->Fill(containerInputRec[0],containerInputRec[0]*TMath::Sqrt(track->GetSigma1Pt2())); |
0cc50ca6 | 459 | } |
460 | } | |
67ebd013 | 461 | |
2b553e6f | 462 | }//trackCuts global tracks |
60829498 | 463 | |
42881dab | 464 | if(fTrackType==1 || fTrackType==2 || fTrackType==7) { |
465 | if(track) delete track; | |
466 | } | |
1f329128 | 467 | }//track loop |
67ebd013 | 468 | |
fdceab34 | 469 | |
a337a5a9 | 470 | //Fill MC containers if particles are findable |
cce400da | 471 | if(fMC) { |
472 | for(int iPart = 1; iPart<(fMC->GetNumberOfPrimaries()); iPart++) { | |
473 | AliMCParticle *mcPart = (AliMCParticle*)fMC->GetTrack(iPart); | |
474 | if(!mcPart) continue; | |
4f6d2d78 | 475 | |
476 | Int_t pdg = mcPart->PdgCode(); | |
477 | ||
478 | // select charged pions, protons, kaons , electrons, muons | |
479 | if(TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == | |
480 | 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13){ | |
481 | ||
482 | //fill the container | |
483 | containerInputMC[0] = mcPart->Pt(); | |
484 | containerInputMC[1] = mcPart->Phi(); | |
485 | containerInputMC[2] = mcPart->Eta(); | |
486 | // AliESDtrack *esdtrack = fESD->GetTrack(mcPart->GetLabel()); | |
487 | containerInputMC[3] = 159.; | |
488 | ||
489 | if(fStack->IsPhysicalPrimary(iPart)) { | |
490 | if(mcPart->Charge()>0. && fCFManagerPos->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance); | |
491 | if(mcPart->Charge()<0. && fCFManagerNeg->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance); | |
492 | } | |
0cc50ca6 | 493 | } |
cce400da | 494 | } |
0cc50ca6 | 495 | } |
67ebd013 | 496 | |
67ebd013 | 497 | PostData(0,fHistList); |
498 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
499 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
500 | ||
fdceab34 | 501 | } |
b4691ee7 | 502 | //________________________________________________________________________ |
503 | Bool_t AliPWG4HighPtSpectra::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){ | |
504 | // | |
505 | // get the cross section and the trails either from pyxsec.root or from pysec_hists.root | |
506 | // This is to called in Notify and should provide the path to the AOD/ESD file | |
507 | // Copied from AliAnalysisTaskJetSpectrum2 | |
508 | // | |
509 | ||
510 | TString file(currFile); | |
511 | fXsec = 0; | |
512 | fTrials = 1; | |
513 | ||
514 | if(file.Contains("root_archive.zip#")){ | |
515 | Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact); | |
516 | Ssiz_t pos = file.Index("#",1,pos1,TString::kExact); | |
517 | file.Replace(pos+1,20,""); | |
518 | } | |
519 | else { | |
520 | // not an archive take the basename.... | |
521 | file.ReplaceAll(gSystem->BaseName(file.Data()),""); | |
522 | } | |
cb76764e | 523 | // Printf("%s",file.Data()); |
b4691ee7 | 524 | |
525 | TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); // problem that we cannot really test the existance of a file in a archive so we have to lvie with open error message from root | |
526 | if(!fxsec){ | |
527 | // next trial fetch the histgram file | |
528 | fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); | |
529 | if(!fxsec){ | |
530 | // not a severe condition but inciate that we have no information | |
531 | return kFALSE; | |
532 | } | |
533 | else{ | |
534 | // find the tlist we want to be independtent of the name so use the Tkey | |
535 | TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); | |
536 | if(!key){ | |
537 | fxsec->Close(); | |
538 | return kFALSE; | |
539 | } | |
540 | TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
541 | if(!list){ | |
542 | fxsec->Close(); | |
543 | return kFALSE; | |
544 | } | |
545 | fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1); | |
546 | fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1); | |
547 | fxsec->Close(); | |
548 | } | |
549 | } // no tree pyxsec.root | |
550 | else { | |
551 | TTree *xtree = (TTree*)fxsec->Get("Xsection"); | |
552 | if(!xtree){ | |
553 | fxsec->Close(); | |
554 | return kFALSE; | |
555 | } | |
556 | UInt_t ntrials = 0; | |
557 | Double_t xsection = 0; | |
558 | xtree->SetBranchAddress("xsection",&xsection); | |
559 | xtree->SetBranchAddress("ntrials",&ntrials); | |
560 | xtree->GetEntry(0); | |
561 | fTrials = ntrials; | |
562 | fXsec = xsection; | |
563 | fxsec->Close(); | |
564 | } | |
565 | return kTRUE; | |
566 | } | |
567 | //________________________________________________________________________ | |
568 | Bool_t AliPWG4HighPtSpectra::Notify() | |
569 | { | |
570 | // | |
571 | // Implemented Notify() to read the cross sections | |
572 | // and number of trials from pyxsec.root | |
573 | // Copied from AliAnalysisTaskJetSpectrum2 | |
574 | // | |
575 | ||
576 | TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree(); | |
577 | Float_t xsection = 0; | |
578 | Float_t ftrials = 1; | |
579 | ||
b4691ee7 | 580 | if(tree){ |
581 | TFile *curfile = tree->GetCurrentFile(); | |
582 | if (!curfile) { | |
583 | Error("Notify","No current file"); | |
584 | return kFALSE; | |
585 | } | |
586 | if(!fh1Xsec||!fh1Trials){ | |
cb76764e | 587 | // Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__); |
b4691ee7 | 588 | return kFALSE; |
589 | } | |
adf3920d | 590 | PythiaInfoFromFile(curfile->GetName(),xsection,ftrials); |
b4691ee7 | 591 | fh1Xsec->Fill("<#sigma>",xsection); |
adf3920d | 592 | fh1Trials->Fill("#sum{ntrials}",ftrials); |
593 | } | |
b4691ee7 | 594 | return kTRUE; |
595 | } | |
596 | ||
597 | //________________________________________________________________________ | |
598 | AliGenPythiaEventHeader* AliPWG4HighPtSpectra::GetPythiaEventHeader(AliMCEvent *mcEvent){ | |
599 | ||
600 | if(!mcEvent)return 0; | |
601 | AliGenEventHeader* genHeader = mcEvent->GenEventHeader(); | |
602 | AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader); | |
603 | if(!pythiaGenHeader){ | |
604 | // cocktail ?? | |
605 | AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader); | |
606 | ||
607 | if (!genCocktailHeader) { | |
cb76764e | 608 | // AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Unknown header type (not Pythia or Cocktail)"); |
b4691ee7 | 609 | // AliWarning(Form("%s %d: Unknown header type (not Pythia or Cocktail)",(char*)__FILE__,__LINE__)); |
610 | return 0; | |
611 | } | |
612 | TList* headerList = genCocktailHeader->GetHeaders(); | |
613 | for (Int_t i=0; i<headerList->GetEntries(); i++) { | |
614 | pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i)); | |
615 | if (pythiaGenHeader) | |
616 | break; | |
617 | } | |
618 | if(!pythiaGenHeader){ | |
619 | AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Pythia event header not found"); | |
620 | return 0; | |
621 | } | |
622 | } | |
623 | return pythiaGenHeader; | |
624 | ||
625 | } | |
fdceab34 | 626 | |
627 | ||
628 | //___________________________________________________________________________ | |
629 | void AliPWG4HighPtSpectra::Terminate(Option_t*) | |
630 | { | |
631 | // The Terminate() function is the last function to be called during | |
632 | // a query. It always runs on the client, it can be used to present | |
633 | // the results graphically or save the results to file. | |
9b58297c | 634 | |
fdceab34 | 635 | } |
636 | ||
fdceab34 | 637 | //___________________________________________________________________________ |
638 | void AliPWG4HighPtSpectra::CreateOutputObjects() { | |
639 | //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED | |
640 | //TO BE SET BEFORE THE EXECUTION OF THE TASK | |
641 | // | |
f51451be | 642 | AliDebug(2,Form("CreateOutputObjects CreateOutputObjects of task %s", GetName())); |
df943115 | 643 | |
67ebd013 | 644 | Bool_t oldStatus = TH1::AddDirectoryStatus(); |
645 | TH1::AddDirectory(kFALSE); | |
646 | ||
fdceab34 | 647 | //slot #1 |
b5cc0c6d | 648 | OpenFile(0); |
649 | fHistList = new TList(); | |
b4691ee7 | 650 | fHistList->SetOwner(kTRUE); |
b5cc0c6d | 651 | fNEventAll = new TH1F("fNEventAll","NEventAll",1,-0.5,0.5); |
652 | fHistList->Add(fNEventAll); | |
653 | fNEventSel = new TH1F("fNEventSel","NEvent Selected for analysis",1,-0.5,0.5); | |
654 | fHistList->Add(fNEventSel); | |
fdceab34 | 655 | |
cb76764e | 656 | fNEventReject = new TH1F("fNEventReject","Reason events are rejectected for analysis",20,0,20); |
2b553e6f | 657 | //Set labels |
658 | fNEventReject->Fill("noESD",0); | |
659 | fNEventReject->Fill("Trigger",0); | |
660 | fNEventReject->Fill("NTracks<2",0); | |
661 | fNEventReject->Fill("noVTX",0); | |
662 | fNEventReject->Fill("VtxStatus",0); | |
663 | fNEventReject->Fill("NCont<2",0); | |
664 | fNEventReject->Fill("ZVTX>10",0); | |
665 | fNEventReject->Fill("cent",0); | |
666 | fNEventReject->Fill("cent>90",0); | |
cb76764e | 667 | fHistList->Add(fNEventReject); |
668 | ||
2b553e6f | 669 | fh1Centrality = new TH1F("fh1Centrality","fh1Centrality; Centrality %",100,0,100); |
670 | fHistList->Add(fh1Centrality); | |
671 | ||
b4691ee7 | 672 | fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1); |
673 | fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>"); | |
674 | fHistList->Add(fh1Xsec); | |
675 | ||
676 | fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1); | |
677 | fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}"); | |
678 | fHistList->Add(fh1Trials); | |
679 | ||
680 | fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",350,-.5,349.5); | |
681 | fHistList->Add(fh1PtHard); | |
682 | fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",350,-.5,349.5); | |
683 | fHistList->Add(fh1PtHardTrials); | |
684 | ||
a337a5a9 | 685 | Int_t fgkNPtBins = 100; |
686 | Float_t kMinPt = 0.; | |
687 | Float_t kMaxPt = 100.; | |
688 | Double_t *binsPt = new Double_t[fgkNPtBins+1]; | |
689 | for(Int_t i=0; i<=fgkNPtBins; i++) binsPt[i]=(Double_t)kMinPt + (kMaxPt-kMinPt)/fgkNPtBins*(Double_t)i ; | |
690 | ||
691 | Int_t fgkNRel1PtUncertaintyBins=50; | |
692 | Float_t fgkRel1PtUncertaintyMin = 0.; | |
693 | Float_t fgkRel1PtUncertaintyMax = 1.; | |
694 | ||
695 | Double_t *binsRel1PtUncertainty=new Double_t[fgkNRel1PtUncertaintyBins+1]; | |
696 | for(Int_t i=0; i<=fgkNRel1PtUncertaintyBins; i++) binsRel1PtUncertainty[i]=(Double_t)fgkRel1PtUncertaintyMin + (fgkRel1PtUncertaintyMax-fgkRel1PtUncertaintyMin)/fgkNRel1PtUncertaintyBins*(Double_t)i ; | |
697 | ||
698 | fPtRelUncertainty1PtPrim = new TH2F("fPtRelUncertainty1PtPrim","fPtRelUncertainty1PtPrim",fgkNPtBins,binsPt,fgkNRel1PtUncertaintyBins,binsRel1PtUncertainty); | |
699 | fHistList->Add(fPtRelUncertainty1PtPrim); | |
700 | ||
701 | fPtRelUncertainty1PtSec = new TH2F("fPtRelUncertainty1PtSec","fPtRelUncertainty1PtSec",fgkNPtBins,binsPt,fgkNRel1PtUncertaintyBins,binsRel1PtUncertainty); | |
702 | fHistList->Add(fPtRelUncertainty1PtSec); | |
703 | ||
67ebd013 | 704 | TH1::AddDirectory(oldStatus); |
705 | ||
11245558 | 706 | PostData(0,fHistList); |
707 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
708 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
709 | ||
a337a5a9 | 710 | if(binsPt) delete [] binsPt; |
711 | if(binsRel1PtUncertainty) delete [] binsRel1PtUncertainty; | |
712 | ||
fdceab34 | 713 | } |
714 | ||
715 | #endif |