]>
Commit | Line | Data |
---|---|---|
8628b70c | 1 | // $Id$ |
6deabc32 | 2 | // |
3 | // Jet embedding task. | |
4 | // | |
5 | // Author: S.Aiola, C.Loizides | |
6 | ||
7 | #include "AliJetEmbeddingFromGenTask.h" | |
8 | ||
9 | #include <TClonesArray.h> | |
bd2cf60a | 10 | #include <TFolder.h> |
6deabc32 | 11 | #include <TLorentzVector.h> |
bd2cf60a | 12 | #include <TParticle.h> |
13 | #include <TParticlePDG.h> | |
6deabc32 | 14 | #include <TRandom3.h> |
e6f3b167 | 15 | #include <TProfile.h> |
6deabc32 | 16 | #include "AliAnalysisManager.h" |
17 | #include "AliEMCALDigit.h" | |
18 | #include "AliEMCALGeometry.h" | |
19 | #include "AliEMCALRecPoint.h" | |
20 | #include "AliGenerator.h" | |
bd2cf60a | 21 | #include "AliHeader.h" |
6deabc32 | 22 | #include "AliLog.h" |
23 | #include "AliPicoTrack.h" | |
bd2cf60a | 24 | #include "AliRun.h" |
25 | #include "AliRunLoader.h" | |
26 | #include "AliStack.h" | |
6deabc32 | 27 | #include "AliStack.h" |
28 | #include "AliVCluster.h" | |
29 | #include "AliVEvent.h" | |
e6f3b167 | 30 | #include "AliGenPythiaEventHeader.h" |
6deabc32 | 31 | |
32 | ClassImp(AliJetEmbeddingFromGenTask) | |
33 | ||
34 | //________________________________________________________________________ | |
35 | AliJetEmbeddingFromGenTask::AliJetEmbeddingFromGenTask() : | |
36 | AliJetModelBaseTask("AliJetEmbeddingFromGenTask"), | |
e6f3b167 | 37 | fGen(0), |
38 | fHistTrials(0), | |
39 | fHistXsection(0), | |
40 | fHistPtHard(0) | |
6deabc32 | 41 | { |
42 | // Default constructor. | |
43 | SetSuffix("EmbeddedFromGen"); | |
44 | } | |
45 | ||
46 | //________________________________________________________________________ | |
e6f3b167 | 47 | AliJetEmbeddingFromGenTask::AliJetEmbeddingFromGenTask(const char *name, Bool_t drawqa) : |
48 | AliJetModelBaseTask(name,drawqa), | |
49 | fGen(0), | |
50 | fHistTrials(0), | |
51 | fHistXsection(0), | |
52 | fHistPtHard(0) | |
6deabc32 | 53 | { |
54 | // Standard constructor. | |
55 | SetSuffix("EmbeddedFromGen"); | |
56 | } | |
57 | ||
58 | //________________________________________________________________________ | |
59 | AliJetEmbeddingFromGenTask::~AliJetEmbeddingFromGenTask() | |
60 | { | |
61 | // Destructor | |
62 | } | |
63 | ||
e6f3b167 | 64 | //________________________________________________________________________ |
65 | void AliJetEmbeddingFromGenTask::UserCreateOutputObjects() | |
66 | { | |
67 | // Create user output. | |
68 | ||
69 | if (!fQAhistos) | |
70 | return; | |
71 | ||
72 | AliJetModelBaseTask::UserCreateOutputObjects(); | |
73 | ||
74 | fHistTrials = new TH1F("fHistTrials", "fHistTrials", 1, 0, 1); | |
75 | fHistTrials->GetYaxis()->SetTitle("trials"); | |
76 | fOutput->Add(fHistTrials); | |
77 | ||
78 | fHistXsection = new TProfile("fHistXsection", "fHistXsection", 1, 0, 1); | |
79 | fHistXsection->GetYaxis()->SetTitle("xsection"); | |
80 | fOutput->Add(fHistXsection); | |
81 | ||
82 | fHistPtHard = new TH1F("fHistPtHard", "fHistPtHard", 500, 0., 500.); | |
83 | fHistPtHard->GetXaxis()->SetTitle("p_{T,hard} (GeV/c)"); | |
84 | fHistPtHard->GetYaxis()->SetTitle("counts"); | |
85 | fOutput->Add(fHistPtHard); | |
86 | ||
87 | PostData(1, fOutput); | |
88 | } | |
89 | ||
6deabc32 | 90 | //________________________________________________________________________ |
d63c8c07 | 91 | Bool_t AliJetEmbeddingFromGenTask::ExecOnce() |
6deabc32 | 92 | { |
bd2cf60a | 93 | // Exec only once. |
6deabc32 | 94 | |
bd2cf60a | 95 | if (!gAlice) { |
96 | new AliRun("gAlice","The ALICE Off-line Simulation Framework"); | |
97 | delete gRandom; | |
98 | gRandom = new TRandom3(0); | |
99 | } | |
100 | ||
101 | TFolder *folder = new TFolder(GetName(),GetName()); | |
102 | AliRunLoader *rl = new AliRunLoader(folder); | |
103 | rl->MakeHeader(); | |
104 | rl->MakeStack(); | |
105 | AliStack *stack = rl->Stack(); | |
106 | fGen->SetStack(stack); | |
107 | fGen->Init(); | |
108 | ||
806ada48 | 109 | if (!(InputEvent()->FindListObject(fTracksName))) { |
bd2cf60a | 110 | fOutTracks = new TClonesArray("AliPicoTrack", 1000); |
111 | fOutTracks->SetName(fTracksName); | |
884c6dab | 112 | InputEvent()->AddObject(fOutTracks); |
bd2cf60a | 113 | fNTracks = 0; |
6deabc32 | 114 | } |
806ada48 | 115 | |
d63c8c07 | 116 | return kTRUE; |
6deabc32 | 117 | } |
118 | ||
119 | //________________________________________________________________________ | |
120 | void AliJetEmbeddingFromGenTask::Run() | |
121 | { | |
122 | // Embed particles. | |
123 | ||
bd2cf60a | 124 | if (fCopyArray) |
125 | CopyTracks(); | |
6deabc32 | 126 | |
127 | AliStack *stack = fGen->GetStack(); | |
bd2cf60a | 128 | stack->Reset(); |
129 | fGen->Generate(); | |
6deabc32 | 130 | const Int_t nprim = stack->GetNprimary(); |
131 | for (Int_t i=0;i<nprim;++i) { | |
bd2cf60a | 132 | if (!stack->IsPhysicalPrimary(i)) |
133 | continue; | |
6deabc32 | 134 | TParticle *part = stack->Particle(i); |
bd2cf60a | 135 | TParticlePDG *pdg = part->GetPDG(1); |
136 | if (!pdg) | |
137 | continue; | |
138 | Int_t c = (Int_t)(TMath::Abs(pdg->Charge())); | |
139 | if (c==0) | |
140 | continue; | |
141 | Double_t pt = part->Pt(); | |
142 | Double_t eta = part->Eta(); | |
143 | Double_t phi = part->Phi(); | |
144 | if (eta<fEtaMin) | |
145 | continue; | |
146 | if (eta>fEtaMax) | |
147 | continue; | |
148 | if (phi<fPhiMin) | |
149 | continue; | |
150 | if (phi>fPhiMax) | |
151 | continue; | |
152 | if (pt<fPtMin) | |
153 | continue; | |
154 | if (pt>fPtMax) | |
155 | continue; | |
ef538617 | 156 | AddTrack(pt, eta, phi,0,0,0,0,0,0,c,part->GetMass()); |
6deabc32 | 157 | } |
e6f3b167 | 158 | |
159 | FillPythiaHistograms(); | |
160 | } | |
161 | ||
162 | //________________________________________________________________________ | |
163 | void AliJetEmbeddingFromGenTask::FillPythiaHistograms() { | |
164 | //Get PYTHIA info: pt-hard, x-section, trials | |
165 | ||
166 | if (!fQAhistos) | |
167 | return; | |
168 | ||
169 | AliRunLoader *rl = AliRunLoader::Instance(); | |
170 | AliGenPythiaEventHeader *genPH = dynamic_cast<AliGenPythiaEventHeader*>(rl->GetHeader()->GenEventHeader()); | |
171 | if(genPH) { | |
c10cf894 | 172 | // Printf("found pythia event header. pThard: %f Trials: %d xsec: %f",genPH->GetPtHard(),genPH->Trials(),genPH->GetXsection()); |
e6f3b167 | 173 | Float_t xsec = genPH->GetXsection(); |
174 | Int_t trials = genPH->Trials(); | |
175 | Float_t pthard = genPH->GetPtHard(); | |
176 | ||
177 | fHistXsection->Fill(0.5,xsec); | |
178 | fHistTrials->Fill(0.5,trials); | |
179 | fHistPtHard->Fill(pthard); | |
180 | } | |
6deabc32 | 181 | } |