]>
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 | //----------------------------------------------------------------------- | |
17 | // Example of task (running locally, on AliEn and CAF), | |
18 | // which provides standard way of calculating acceptance and efficiency | |
19 | // between different steps of the procedure. | |
20 | // The ouptut of the task is a AliCFContainer from which the efficiencies | |
21 | // can be calculated | |
22 | //----------------------------------------------------------------------- | |
23 | // Author : Marta Verweij - UU | |
24 | //----------------------------------------------------------------------- | |
25 | ||
26 | ||
67ebd013 | 27 | #ifndef ALIPWG4HIGHPTSPECTRA_CXX |
28 | #define ALIPWG4HIGHPTSPECTRA_CXX | |
fdceab34 | 29 | |
30 | #include "AliPWG4HighPtSpectra.h" | |
31 | ||
67ebd013 | 32 | #include "TVector3.h" |
33 | #include <iostream> | |
34 | #include "TH1.h" | |
35 | #include "TH2.h" | |
36 | #include "TH3.h" | |
b4691ee7 | 37 | #include "TProfile.h" |
67ebd013 | 38 | #include "TList.h" |
39 | #include "TChain.h" | |
b4691ee7 | 40 | #include "TKey.h" |
41 | #include "TSystem.h" | |
42 | #include "TFile.h" | |
67ebd013 | 43 | |
44 | #include "AliAnalysisManager.h" | |
45 | #include "AliESDInputHandler.h" | |
46 | #include "AliESDtrack.h" | |
47 | #include "AliESDtrackCuts.h" | |
48 | #include "AliExternalTrackParam.h" | |
65e8ecdd | 49 | |
67ebd013 | 50 | #include "AliLog.h" |
51 | ||
fdceab34 | 52 | #include "AliStack.h" |
53 | #include "TParticle.h" | |
fdceab34 | 54 | #include "AliMCEvent.h" |
55 | #include "AliMCEventHandler.h" | |
fdceab34 | 56 | #include "AliCFContainer.h" |
b4691ee7 | 57 | #include "AliGenPythiaEventHeader.h" |
58 | #include "AliGenCocktailEventHeader.h" | |
67ebd013 | 59 | //#include "$ALICE_ROOT/PWG4/JetTasks/AliAnalysisHelperJetTasks.h" |
60 | ||
61 | //#include <iostream> | |
fdceab34 | 62 | using namespace std; //required for resolving the 'cout' symbol |
63 | ||
64 | ClassImp(AliPWG4HighPtSpectra) | |
65 | ||
66 | //__________________________________________________________________________ | |
67 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra() : AliAnalysisTask("AliPWG4HighPtSpectra", ""), | |
68 | fReadAODData(0), | |
67ebd013 | 69 | fCFManagerPos(0x0), |
70 | fCFManagerNeg(0x0), | |
fdceab34 | 71 | fESD(0), |
72 | fTrackCuts(0), | |
1f329128 | 73 | fTrackCutsTPConly(0), |
b4691ee7 | 74 | fAvgTrials(1), |
fdceab34 | 75 | fHistList(0), |
b5cc0c6d | 76 | fNEventAll(0), |
b4691ee7 | 77 | fNEventSel(0), |
cb76764e | 78 | fNEventReject(0), |
b4691ee7 | 79 | fh1Xsec(0), |
80 | fh1Trials(0), | |
81 | fh1PtHard(0), | |
82 | fh1PtHardTrials(0) | |
fdceab34 | 83 | { |
84 | // | |
85 | //Default ctor | |
86 | // | |
87 | } | |
88 | //___________________________________________________________________________ | |
89 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const Char_t* name) : | |
90 | AliAnalysisTask(name,""), | |
91 | fReadAODData(0), | |
67ebd013 | 92 | fCFManagerPos(0x0), |
93 | fCFManagerNeg(0x0), | |
fdceab34 | 94 | fESD(0), |
67ebd013 | 95 | fTrackCuts(), |
1f329128 | 96 | fTrackCutsTPConly(0), |
b4691ee7 | 97 | fAvgTrials(1), |
fdceab34 | 98 | fHistList(0), |
b5cc0c6d | 99 | fNEventAll(0), |
b4691ee7 | 100 | fNEventSel(0), |
cb76764e | 101 | fNEventReject(0), |
b4691ee7 | 102 | fh1Xsec(0), |
103 | fh1Trials(0), | |
104 | fh1PtHard(0), | |
105 | fh1PtHardTrials(0) | |
fdceab34 | 106 | { |
107 | // | |
108 | // Constructor. Initialization of Inputs and Outputs | |
109 | // | |
f51451be | 110 | AliDebug(2,Form("AliPWG4HighPtSpectra Calling Constructor")); |
fdceab34 | 111 | // Input slot #0 works with a TChain ESD |
112 | DefineInput(0, TChain::Class()); | |
e5abcde9 | 113 | // Output slot #0 writes into a TList |
fdceab34 | 114 | DefineOutput(0,TList::Class()); |
e5abcde9 | 115 | // Output slot #1, #2 writes into a AliCFContainer |
fdceab34 | 116 | DefineOutput(1,AliCFContainer::Class()); |
67ebd013 | 117 | DefineOutput(2,AliCFContainer::Class()); |
e5abcde9 | 118 | // Output slot #3 writes into a AliESDtrackCuts |
119 | DefineOutput(3, AliESDtrackCuts::Class()); | |
1f329128 | 120 | DefineOutput(4, AliESDtrackCuts::Class()); |
e5abcde9 | 121 | } |
122 | ||
123 | //________________________________________________________________________ | |
124 | void AliPWG4HighPtSpectra::LocalInit() | |
125 | { | |
126 | // | |
127 | // Only called once at beginning | |
128 | // | |
129 | PostData(3,fTrackCuts); | |
1f329128 | 130 | PostData(4,fTrackCutsTPConly); |
fdceab34 | 131 | } |
132 | ||
fdceab34 | 133 | //________________________________________________________________________ |
134 | void AliPWG4HighPtSpectra::ConnectInputData(Option_t *) | |
135 | { | |
136 | // Connect ESD here | |
137 | // Called once | |
df943115 | 138 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::ConnectInputData \n")); |
fdceab34 | 139 | |
140 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
141 | if (!tree) { | |
df943115 | 142 | AliDebug(2,Form("ERROR: Could not read chain from input slot 0")); |
fdceab34 | 143 | } else { |
144 | ||
145 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
146 | ||
147 | if (!esdH) { | |
df943115 | 148 | AliDebug(2,Form("ERROR: Could not get ESDInputHandler")); |
67ebd013 | 149 | } else { |
fdceab34 | 150 | fESD = esdH->GetEvent(); |
67ebd013 | 151 | } |
fdceab34 | 152 | } |
67ebd013 | 153 | |
fdceab34 | 154 | } |
155 | //_________________________________________________ | |
67ebd013 | 156 | void AliPWG4HighPtSpectra::Exec(Option_t *) |
fdceab34 | 157 | { |
158 | // | |
159 | // Main loop function | |
160 | // | |
df943115 | 161 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n")); |
fdceab34 | 162 | |
b5cc0c6d | 163 | // All events without selection |
164 | fNEventAll->Fill(0.); | |
165 | ||
fdceab34 | 166 | if (!fESD) { |
df943115 | 167 | AliDebug(2,Form("ERROR: fESD not available")); |
cb76764e | 168 | fNEventReject->Fill("noESD",1); |
67ebd013 | 169 | PostData(0,fHistList); |
170 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
171 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
fdceab34 | 172 | return; |
173 | } | |
174 | ||
bfd58011 | 175 | UInt_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); |
176 | if(!(isSelected&AliVEvent::kMB)) { //Select collison candidates | |
b5cc0c6d | 177 | AliDebug(2,Form(" Trigger Selection: event REJECTED ... ")); |
cb76764e | 178 | fNEventReject->Fill("Trigger",1); |
cd9a6fa2 | 179 | PostData(0,fHistList); |
67ebd013 | 180 | PostData(1,fCFManagerPos->GetParticleContainer()); |
181 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
b5cc0c6d | 182 | return; |
67ebd013 | 183 | } |
b5cc0c6d | 184 | |
fdceab34 | 185 | // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler |
186 | // This handler can return the current MC event | |
67ebd013 | 187 | |
188 | AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
67ebd013 | 189 | |
0cc50ca6 | 190 | AliStack* stack = 0x0; |
191 | AliMCEvent* mcEvent = 0x0; | |
67ebd013 | 192 | |
0cc50ca6 | 193 | if(eventHandler) { |
194 | mcEvent = eventHandler->MCEvent(); | |
195 | if (!mcEvent) { | |
196 | AliDebug(2,Form("ERROR: Could not retrieve MC event")); | |
cb76764e | 197 | fNEventReject->Fill("noMCEvent",1); |
67ebd013 | 198 | PostData(0,fHistList); |
199 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
75946d5d | 200 | PostData(2,fCFManagerNeg->GetParticleContainer()); |
b1cd0099 | 201 | return; |
0cc50ca6 | 202 | } |
203 | ||
204 | AliDebug(2,Form("MC particles: %d", mcEvent->GetNumberOfTracks())); | |
205 | ||
206 | stack = mcEvent->Stack(); //Particles Stack | |
207 | ||
208 | AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack())); | |
fdceab34 | 209 | } |
b4691ee7 | 210 | |
211 | //___ get MC information __________________________________________________________________ | |
212 | ||
213 | Double_t ptHard = 0.; | |
214 | Double_t nTrials = 1; // trials for MC trigger weight for real data | |
215 | ||
216 | if(mcEvent){ | |
217 | AliGenPythiaEventHeader* pythiaGenHeader = GetPythiaEventHeader(mcEvent); | |
cb76764e | 218 | if(pythiaGenHeader){ |
219 | nTrials = pythiaGenHeader->Trials(); | |
220 | ptHard = pythiaGenHeader->GetPtHard(); | |
221 | ||
222 | fh1PtHard->Fill(ptHard); | |
223 | fh1PtHardTrials->Fill(ptHard,nTrials); | |
224 | ||
225 | fh1Trials->Fill("#sum{ntrials}",fAvgTrials); | |
b4691ee7 | 226 | } |
227 | } | |
0cc50ca6 | 228 | |
fdceab34 | 229 | const AliESDVertex *vtx = fESD->GetPrimaryVertex(); |
67ebd013 | 230 | AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors())); |
fdceab34 | 231 | // Need vertex cut |
75946d5d | 232 | TString vtxName(vtx->GetName()); |
233 | if(vtx->GetNContributors() < 2 || (vtxName.Contains("TPCVertex")) ) { | |
234 | // SPD vertex | |
235 | vtx = fESD->GetPrimaryVertexSPD(); | |
236 | if(vtx->GetNContributors()<2) { | |
237 | vtx = 0x0; | |
cb76764e | 238 | fNEventReject->Fill("noVTX",1); |
75946d5d | 239 | // Post output data |
240 | PostData(0,fHistList); | |
241 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
242 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
243 | return; | |
244 | } | |
cd9a6fa2 | 245 | } |
67ebd013 | 246 | |
b5cc0c6d | 247 | double primVtx[3]; |
248 | vtx->GetXYZ(primVtx); | |
67ebd013 | 249 | if(TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2]>10.)){ |
cb76764e | 250 | fNEventReject->Fill("ZVTX>10",1); |
cd9a6fa2 | 251 | PostData(0,fHistList); |
67ebd013 | 252 | PostData(1,fCFManagerPos->GetParticleContainer()); |
253 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
254 | return; | |
255 | } | |
256 | ||
257 | if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2){ | |
cb76764e | 258 | fNEventReject->Fill("NTracks<2",1); |
67ebd013 | 259 | // Post output data |
260 | PostData(0,fHistList); | |
261 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
262 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
cd9a6fa2 | 263 | return; |
264 | } | |
fdceab34 | 265 | Int_t nTracks = fESD->GetNumberOfTracks(); |
266 | AliDebug(2,Form("nTracks %d", nTracks)); | |
fdceab34 | 267 | |
67ebd013 | 268 | if(!fTrackCuts) { |
cb76764e | 269 | fNEventReject->Fill("noTrackCuts",1); |
67ebd013 | 270 | // Post output data |
271 | PostData(0,fHistList); | |
272 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
273 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
274 | return; | |
275 | } | |
276 | ||
b5cc0c6d | 277 | // Selected events for analysis |
278 | fNEventSel->Fill(0.); | |
67ebd013 | 279 | |
280 | ||
ec555a3c | 281 | Double_t containerInputRec[3] = {0.,0.,0.}; |
282 | Double_t containerInputTPConly[3] = {0.,0.,0.}; | |
283 | Double_t containerInputMC[3] = {0.,0.,0.}; | |
284 | Double_t containerInputRecMC[3] = {0.,0.,0.}; | |
285 | Double_t containerInputTPConlyMC[3] = {0.,0.,0.}; | |
286 | ||
fdceab34 | 287 | //Now go to rec level |
288 | for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) | |
289 | { | |
290 | if(!fESD->GetTrack(iTrack) ) continue; | |
291 | AliESDtrack* track = fESD->GetTrack(iTrack); | |
292 | if(!(AliExternalTrackParam *)track->GetTPCInnerParam()) continue; | |
293 | AliExternalTrackParam *trackTPC = (AliExternalTrackParam *)track->GetTPCInnerParam(); | |
294 | if(!track || !trackTPC) continue; | |
295 | ||
fdceab34 | 296 | //fill the container |
297 | containerInputRec[0] = track->Pt(); | |
67ebd013 | 298 | containerInputRec[1] = track->Phi(); |
299 | containerInputRec[2] = track->Eta(); | |
ec555a3c | 300 | |
1f329128 | 301 | //Store TPC Inner Params for TPConly tracks |
fdceab34 | 302 | containerInputTPConly[0] = trackTPC->Pt(); |
67ebd013 | 303 | containerInputTPConly[1] = trackTPC->Phi(); |
304 | containerInputTPConly[2] = trackTPC->Eta(); | |
0cc50ca6 | 305 | |
1f329128 | 306 | AliESDtrack* trackTPCESD = fTrackCutsTPConly->GetTPCOnlyTrack(fESD, iTrack); |
307 | if(trackTPCESD) { | |
308 | if (fTrackCutsTPConly->AcceptTrack(trackTPCESD)) { | |
309 | if(trackTPC->GetSign()>0.) fCFManagerPos->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly); | |
310 | if(trackTPC->GetSign()<0.) fCFManagerNeg->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly); | |
ec555a3c | 311 | |
312 | //Only fill the MC containers if MC information is available | |
313 | if(eventHandler) { | |
314 | Int_t label = TMath::Abs(track->GetLabel()); | |
315 | TParticle *particle = stack->Particle(label) ; | |
316 | if(!particle) continue; | |
317 | ||
318 | containerInputTPConlyMC[0] = particle->Pt(); | |
319 | containerInputTPConlyMC[1] = particle->Phi(); | |
320 | containerInputTPConlyMC[2] = particle->Eta(); | |
321 | ||
322 | //Container with primaries | |
323 | if(stack->IsPhysicalPrimary(label)) { | |
324 | if(particle->GetPDG()->Charge()>0.) { | |
325 | fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedTPCOnlyMC); | |
326 | } | |
327 | if(particle->GetPDG()->Charge()<0.) { | |
328 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedTPCOnlyMC); | |
329 | } | |
330 | } | |
331 | } | |
332 | ||
67ebd013 | 333 | } |
1f329128 | 334 | } |
335 | ||
336 | if (fTrackCuts->AcceptTrack(track)) { | |
337 | if(track->GetSign()>0.) fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); | |
338 | if(track->GetSign()<0.) fCFManagerNeg->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); | |
339 | ||
67ebd013 | 340 | |
1f329128 | 341 | //Only fill the MC containers if MC information is available |
0cc50ca6 | 342 | if(eventHandler) { |
343 | Int_t label = TMath::Abs(track->GetLabel()); | |
344 | TParticle *particle = stack->Particle(label) ; | |
345 | if(!particle) continue; | |
65e8ecdd | 346 | |
ec555a3c | 347 | containerInputRecMC[0] = particle->Pt(); |
348 | containerInputRecMC[1] = particle->Phi(); | |
349 | containerInputRecMC[2] = particle->Eta(); | |
67ebd013 | 350 | |
1f329128 | 351 | //Container with primaries |
352 | if(stack->IsPhysicalPrimary(label)) { | |
353 | if(particle->GetPDG()->Charge()>0.) { | |
ec555a3c | 354 | fCFManagerPos->GetParticleContainer()->Fill(containerInputRecMC,kStepReconstructedMC); |
1f329128 | 355 | } |
356 | if(particle->GetPDG()->Charge()<0.) { | |
ec555a3c | 357 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputRecMC,kStepReconstructedMC); |
1f329128 | 358 | } |
67ebd013 | 359 | } |
360 | ||
1f329128 | 361 | //Container with secondaries |
0cc50ca6 | 362 | if (!stack->IsPhysicalPrimary(label) ) { |
67ebd013 | 363 | if(particle->GetPDG()->Charge()>0.) { |
364 | fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries); | |
365 | } | |
366 | if(particle->GetPDG()->Charge()<0.) { | |
367 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries); | |
368 | } | |
0cc50ca6 | 369 | } |
370 | } | |
67ebd013 | 371 | |
1f329128 | 372 | }//trackCuts |
60829498 | 373 | |
374 | delete trackTPCESD; | |
1f329128 | 375 | }//track loop |
67ebd013 | 376 | |
fdceab34 | 377 | |
65e8ecdd | 378 | //Fill MC containters if particles are findable |
0cc50ca6 | 379 | if(eventHandler) { |
1f329128 | 380 | for(int iPart = 1; iPart<(mcEvent->GetNumberOfPrimaries()); iPart++)//stack->GetNprimary(); |
0cc50ca6 | 381 | { |
382 | AliMCParticle *mcPart = (AliMCParticle*)mcEvent->GetTrack(iPart); | |
383 | if(!mcPart) continue; | |
0cc50ca6 | 384 | //fill the container |
385 | containerInputMC[0] = mcPart->Pt(); | |
67ebd013 | 386 | containerInputMC[1] = mcPart->Phi(); |
387 | containerInputMC[2] = mcPart->Eta(); | |
67ebd013 | 388 | |
1f329128 | 389 | if(stack->IsPhysicalPrimary(iPart)) { |
9b58297c | 390 | if(mcPart->Charge()>0. && fCFManagerPos->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance); |
391 | if(mcPart->Charge()<0. && fCFManagerNeg->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance); | |
67ebd013 | 392 | } |
0cc50ca6 | 393 | } |
394 | } | |
67ebd013 | 395 | |
67ebd013 | 396 | PostData(0,fHistList); |
397 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
398 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
399 | ||
fdceab34 | 400 | } |
b4691ee7 | 401 | //________________________________________________________________________ |
402 | Bool_t AliPWG4HighPtSpectra::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){ | |
403 | // | |
404 | // get the cross section and the trails either from pyxsec.root or from pysec_hists.root | |
405 | // This is to called in Notify and should provide the path to the AOD/ESD file | |
406 | // Copied from AliAnalysisTaskJetSpectrum2 | |
407 | // | |
408 | ||
409 | TString file(currFile); | |
410 | fXsec = 0; | |
411 | fTrials = 1; | |
412 | ||
413 | if(file.Contains("root_archive.zip#")){ | |
414 | Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact); | |
415 | Ssiz_t pos = file.Index("#",1,pos1,TString::kExact); | |
416 | file.Replace(pos+1,20,""); | |
417 | } | |
418 | else { | |
419 | // not an archive take the basename.... | |
420 | file.ReplaceAll(gSystem->BaseName(file.Data()),""); | |
421 | } | |
cb76764e | 422 | // Printf("%s",file.Data()); |
b4691ee7 | 423 | |
424 | 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 | |
425 | if(!fxsec){ | |
426 | // next trial fetch the histgram file | |
427 | fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); | |
428 | if(!fxsec){ | |
429 | // not a severe condition but inciate that we have no information | |
430 | return kFALSE; | |
431 | } | |
432 | else{ | |
433 | // find the tlist we want to be independtent of the name so use the Tkey | |
434 | TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); | |
435 | if(!key){ | |
436 | fxsec->Close(); | |
437 | return kFALSE; | |
438 | } | |
439 | TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
440 | if(!list){ | |
441 | fxsec->Close(); | |
442 | return kFALSE; | |
443 | } | |
444 | fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1); | |
445 | fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1); | |
446 | fxsec->Close(); | |
447 | } | |
448 | } // no tree pyxsec.root | |
449 | else { | |
450 | TTree *xtree = (TTree*)fxsec->Get("Xsection"); | |
451 | if(!xtree){ | |
452 | fxsec->Close(); | |
453 | return kFALSE; | |
454 | } | |
455 | UInt_t ntrials = 0; | |
456 | Double_t xsection = 0; | |
457 | xtree->SetBranchAddress("xsection",&xsection); | |
458 | xtree->SetBranchAddress("ntrials",&ntrials); | |
459 | xtree->GetEntry(0); | |
460 | fTrials = ntrials; | |
461 | fXsec = xsection; | |
462 | fxsec->Close(); | |
463 | } | |
464 | return kTRUE; | |
465 | } | |
466 | //________________________________________________________________________ | |
467 | Bool_t AliPWG4HighPtSpectra::Notify() | |
468 | { | |
469 | // | |
470 | // Implemented Notify() to read the cross sections | |
471 | // and number of trials from pyxsec.root | |
472 | // Copied from AliAnalysisTaskJetSpectrum2 | |
473 | // | |
474 | ||
475 | TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree(); | |
476 | Float_t xsection = 0; | |
477 | Float_t ftrials = 1; | |
478 | ||
479 | fAvgTrials = 1; | |
480 | if(tree){ | |
481 | TFile *curfile = tree->GetCurrentFile(); | |
482 | if (!curfile) { | |
483 | Error("Notify","No current file"); | |
484 | return kFALSE; | |
485 | } | |
486 | if(!fh1Xsec||!fh1Trials){ | |
cb76764e | 487 | // Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__); |
b4691ee7 | 488 | return kFALSE; |
489 | } | |
490 | PythiaInfoFromFile(curfile->GetName(),xsection,ftrials); | |
491 | fh1Xsec->Fill("<#sigma>",xsection); | |
492 | // construct a poor man average trials | |
493 | Float_t nEntries = (Float_t)tree->GetTree()->GetEntries(); | |
494 | if(ftrials>=nEntries && nEntries>0.)fAvgTrials = ftrials/nEntries; | |
495 | } | |
496 | return kTRUE; | |
497 | } | |
498 | ||
499 | //________________________________________________________________________ | |
500 | AliGenPythiaEventHeader* AliPWG4HighPtSpectra::GetPythiaEventHeader(AliMCEvent *mcEvent){ | |
501 | ||
502 | if(!mcEvent)return 0; | |
503 | AliGenEventHeader* genHeader = mcEvent->GenEventHeader(); | |
504 | AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader); | |
505 | if(!pythiaGenHeader){ | |
506 | // cocktail ?? | |
507 | AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader); | |
508 | ||
509 | if (!genCocktailHeader) { | |
cb76764e | 510 | // AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Unknown header type (not Pythia or Cocktail)"); |
b4691ee7 | 511 | // AliWarning(Form("%s %d: Unknown header type (not Pythia or Cocktail)",(char*)__FILE__,__LINE__)); |
512 | return 0; | |
513 | } | |
514 | TList* headerList = genCocktailHeader->GetHeaders(); | |
515 | for (Int_t i=0; i<headerList->GetEntries(); i++) { | |
516 | pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i)); | |
517 | if (pythiaGenHeader) | |
518 | break; | |
519 | } | |
520 | if(!pythiaGenHeader){ | |
521 | AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Pythia event header not found"); | |
522 | return 0; | |
523 | } | |
524 | } | |
525 | return pythiaGenHeader; | |
526 | ||
527 | } | |
fdceab34 | 528 | |
529 | ||
530 | //___________________________________________________________________________ | |
531 | void AliPWG4HighPtSpectra::Terminate(Option_t*) | |
532 | { | |
533 | // The Terminate() function is the last function to be called during | |
534 | // a query. It always runs on the client, it can be used to present | |
535 | // the results graphically or save the results to file. | |
9b58297c | 536 | |
fdceab34 | 537 | } |
538 | ||
fdceab34 | 539 | //___________________________________________________________________________ |
540 | void AliPWG4HighPtSpectra::CreateOutputObjects() { | |
541 | //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED | |
542 | //TO BE SET BEFORE THE EXECUTION OF THE TASK | |
543 | // | |
f51451be | 544 | AliDebug(2,Form("CreateOutputObjects CreateOutputObjects of task %s", GetName())); |
df943115 | 545 | |
67ebd013 | 546 | Bool_t oldStatus = TH1::AddDirectoryStatus(); |
547 | TH1::AddDirectory(kFALSE); | |
548 | ||
fdceab34 | 549 | //slot #1 |
b5cc0c6d | 550 | OpenFile(0); |
551 | fHistList = new TList(); | |
b4691ee7 | 552 | fHistList->SetOwner(kTRUE); |
b5cc0c6d | 553 | fNEventAll = new TH1F("fNEventAll","NEventAll",1,-0.5,0.5); |
554 | fHistList->Add(fNEventAll); | |
555 | fNEventSel = new TH1F("fNEventSel","NEvent Selected for analysis",1,-0.5,0.5); | |
556 | fHistList->Add(fNEventSel); | |
fdceab34 | 557 | |
cb76764e | 558 | fNEventReject = new TH1F("fNEventReject","Reason events are rejectected for analysis",20,0,20); |
559 | fHistList->Add(fNEventReject); | |
560 | ||
b4691ee7 | 561 | fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1); |
562 | fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>"); | |
563 | fHistList->Add(fh1Xsec); | |
564 | ||
565 | fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1); | |
566 | fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}"); | |
567 | fHistList->Add(fh1Trials); | |
568 | ||
569 | fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",350,-.5,349.5); | |
570 | fHistList->Add(fh1PtHard); | |
571 | fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",350,-.5,349.5); | |
572 | fHistList->Add(fh1PtHardTrials); | |
573 | ||
67ebd013 | 574 | TH1::AddDirectory(oldStatus); |
575 | ||
fdceab34 | 576 | } |
577 | ||
578 | #endif |