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