]>
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 "AliVCluster.h" |
28 | #include "AliVEvent.h" | |
e6f3b167 | 29 | #include "AliGenPythiaEventHeader.h" |
b929303d | 30 | #include "AliPythiaInfo.h" |
f0134962 | 31 | #include "AliPythiaRndm.h" |
6deabc32 | 32 | ClassImp(AliJetEmbeddingFromGenTask) |
33 | ||
34 | //________________________________________________________________________ | |
35 | AliJetEmbeddingFromGenTask::AliJetEmbeddingFromGenTask() : | |
36 | AliJetModelBaseTask("AliJetEmbeddingFromGenTask"), | |
e6f3b167 | 37 | fGen(0), |
4d3b366f | 38 | fMassless(kFALSE), |
72978588 | 39 | fChargedOnly(kFALSE), |
8d2d2145 | 40 | fHistPt(0), |
72978588 | 41 | fHistEtaPhi(0), |
e6f3b167 | 42 | fHistTrials(0), |
43 | fHistXsection(0), | |
44 | fHistPtHard(0) | |
6deabc32 | 45 | { |
46 | // Default constructor. | |
47 | SetSuffix("EmbeddedFromGen"); | |
48 | } | |
49 | ||
50 | //________________________________________________________________________ | |
e6f3b167 | 51 | AliJetEmbeddingFromGenTask::AliJetEmbeddingFromGenTask(const char *name, Bool_t drawqa) : |
52 | AliJetModelBaseTask(name,drawqa), | |
53 | fGen(0), | |
4d3b366f | 54 | fMassless(kFALSE), |
72978588 | 55 | fChargedOnly(kFALSE), |
8d2d2145 | 56 | fHistPt(0), |
72978588 | 57 | fHistEtaPhi(0), |
e6f3b167 | 58 | fHistTrials(0), |
59 | fHistXsection(0), | |
60 | fHistPtHard(0) | |
6deabc32 | 61 | { |
62 | // Standard constructor. | |
63 | SetSuffix("EmbeddedFromGen"); | |
64 | } | |
65 | ||
66 | //________________________________________________________________________ | |
67 | AliJetEmbeddingFromGenTask::~AliJetEmbeddingFromGenTask() | |
68 | { | |
69 | // Destructor | |
70 | } | |
71 | ||
e6f3b167 | 72 | //________________________________________________________________________ |
73 | void AliJetEmbeddingFromGenTask::UserCreateOutputObjects() | |
74 | { | |
75 | // Create user output. | |
76 | ||
77 | if (!fQAhistos) | |
78 | return; | |
79 | ||
80 | AliJetModelBaseTask::UserCreateOutputObjects(); | |
81 | ||
8d2d2145 | 82 | fHistPt = new TH1F("fHistpt","fHistPt;#it{p}_{T};N",100,0.,100.); |
83 | fOutput->Add(fHistPt); | |
84 | ||
cfa7b4df | 85 | fHistEtaPhi = new TH2F("fHistEtapHI","fHistEtaPhi;#eta;#varphi",100,-3.,3.,100.,0.,TMath::TwoPi()); |
72978588 | 86 | fOutput->Add(fHistEtaPhi); |
87 | ||
e6f3b167 | 88 | fHistTrials = new TH1F("fHistTrials", "fHistTrials", 1, 0, 1); |
89 | fHistTrials->GetYaxis()->SetTitle("trials"); | |
90 | fOutput->Add(fHistTrials); | |
91 | ||
92 | fHistXsection = new TProfile("fHistXsection", "fHistXsection", 1, 0, 1); | |
93 | fHistXsection->GetYaxis()->SetTitle("xsection"); | |
94 | fOutput->Add(fHistXsection); | |
95 | ||
96 | fHistPtHard = new TH1F("fHistPtHard", "fHistPtHard", 500, 0., 500.); | |
97 | fHistPtHard->GetXaxis()->SetTitle("p_{T,hard} (GeV/c)"); | |
98 | fHistPtHard->GetYaxis()->SetTitle("counts"); | |
99 | fOutput->Add(fHistPtHard); | |
100 | ||
101 | PostData(1, fOutput); | |
102 | } | |
103 | ||
6deabc32 | 104 | //________________________________________________________________________ |
d63c8c07 | 105 | Bool_t AliJetEmbeddingFromGenTask::ExecOnce() |
6deabc32 | 106 | { |
bd2cf60a | 107 | // Exec only once. |
6deabc32 | 108 | |
bd2cf60a | 109 | if (!gAlice) { |
110 | new AliRun("gAlice","The ALICE Off-line Simulation Framework"); | |
111 | delete gRandom; | |
112 | gRandom = new TRandom3(0); | |
113 | } | |
114 | ||
115 | TFolder *folder = new TFolder(GetName(),GetName()); | |
116 | AliRunLoader *rl = new AliRunLoader(folder); | |
c2e16a2c | 117 | gAlice->SetRunLoader(rl); |
bd2cf60a | 118 | rl->MakeHeader(); |
119 | rl->MakeStack(); | |
120 | AliStack *stack = rl->Stack(); | |
121 | fGen->SetStack(stack); | |
122 | fGen->Init(); | |
123 | ||
806ada48 | 124 | if (!(InputEvent()->FindListObject(fTracksName))) { |
bd2cf60a | 125 | fOutTracks = new TClonesArray("AliPicoTrack", 1000); |
126 | fOutTracks->SetName(fTracksName); | |
884c6dab | 127 | InputEvent()->AddObject(fOutTracks); |
bd2cf60a | 128 | fNTracks = 0; |
6deabc32 | 129 | } |
cfa7b4df | 130 | |
b929303d | 131 | if(!fPythiaInfoName.IsNull()) { |
132 | if (!(InputEvent()->FindListObject(fPythiaInfoName))) { | |
133 | fPythiaInfo = new AliPythiaInfo("PythiaInfo"); | |
134 | fPythiaInfo->SetName(fPythiaInfoName); | |
135 | InputEvent()->AddObject(fPythiaInfo); | |
0187d9d1 | 136 | } |
cfa7b4df | 137 | } |
d63c8c07 | 138 | return kTRUE; |
6deabc32 | 139 | } |
140 | ||
141 | //________________________________________________________________________ | |
142 | void AliJetEmbeddingFromGenTask::Run() | |
143 | { | |
144 | // Embed particles. | |
145 | ||
bd2cf60a | 146 | if (fCopyArray) |
147 | CopyTracks(); | |
f0134962 | 148 | AliPythiaRndm::SetPythiaRandom(new TRandom3()); |
149 | AliPythiaRndm::GetPythiaRandom()->SetSeed(clock()+gSystem->GetPid()); | |
6deabc32 | 150 | AliStack *stack = fGen->GetStack(); |
bd2cf60a | 151 | stack->Reset(); |
152 | fGen->Generate(); | |
6deabc32 | 153 | const Int_t nprim = stack->GetNprimary(); |
243ce6d2 | 154 | // reject if partons are missing from stack for some reason |
155 | if(nprim < 8) return; | |
b929303d | 156 | if(fPythiaInfo) { |
0187d9d1 | 157 | TParticle *part6 = stack->Particle(6); |
158 | TParticle *part7 = stack->Particle(7); | |
159 | ||
b929303d | 160 | fPythiaInfo->SetPartonFlag6(TMath::Abs(part6->GetPdgCode())); |
161 | fPythiaInfo->SetPartonPt6(part6->Pt()); | |
162 | fPythiaInfo->SetPartonEta6(part6->Eta()); | |
163 | fPythiaInfo->SetPartonPhi6(part6->Phi()); | |
0187d9d1 | 164 | |
b929303d | 165 | fPythiaInfo->SetPartonFlag7(TMath::Abs(part7->GetPdgCode())); |
166 | fPythiaInfo->SetPartonPt7(part7->Pt()); | |
167 | fPythiaInfo->SetPartonEta7(part7->Eta()); | |
168 | fPythiaInfo->SetPartonPhi7(part7->Phi()); | |
0187d9d1 | 169 | } |
170 | ||
6deabc32 | 171 | for (Int_t i=0;i<nprim;++i) { |
bd2cf60a | 172 | if (!stack->IsPhysicalPrimary(i)) |
173 | continue; | |
6deabc32 | 174 | TParticle *part = stack->Particle(i); |
bd2cf60a | 175 | TParticlePDG *pdg = part->GetPDG(1); |
176 | if (!pdg) | |
177 | continue; | |
178 | Int_t c = (Int_t)(TMath::Abs(pdg->Charge())); | |
72978588 | 179 | if (fChargedOnly && c==0) continue; |
bd2cf60a | 180 | Double_t pt = part->Pt(); |
181 | Double_t eta = part->Eta(); | |
182 | Double_t phi = part->Phi(); | |
183 | if (eta<fEtaMin) | |
184 | continue; | |
185 | if (eta>fEtaMax) | |
186 | continue; | |
187 | if (phi<fPhiMin) | |
188 | continue; | |
189 | if (phi>fPhiMax) | |
190 | continue; | |
191 | if (pt<fPtMin) | |
192 | continue; | |
193 | if (pt>fPtMax) | |
194 | continue; | |
4d3b366f | 195 | Double_t mass = part->GetMass(); |
196 | if(fMassless) mass = 0.; | |
8d2d2145 | 197 | fHistPt->Fill(pt); |
72978588 | 198 | fHistEtaPhi->Fill(eta,phi); |
4d3b366f | 199 | AddTrack(pt, eta, phi,0,0,0,0,0,0,c,mass); |
6deabc32 | 200 | } |
e6f3b167 | 201 | |
202 | FillPythiaHistograms(); | |
203 | } | |
204 | ||
205 | //________________________________________________________________________ | |
206 | void AliJetEmbeddingFromGenTask::FillPythiaHistograms() { | |
207 | //Get PYTHIA info: pt-hard, x-section, trials | |
208 | ||
209 | if (!fQAhistos) | |
210 | return; | |
211 | ||
212 | AliRunLoader *rl = AliRunLoader::Instance(); | |
213 | AliGenPythiaEventHeader *genPH = dynamic_cast<AliGenPythiaEventHeader*>(rl->GetHeader()->GenEventHeader()); | |
214 | if(genPH) { | |
e6f3b167 | 215 | Float_t xsec = genPH->GetXsection(); |
216 | Int_t trials = genPH->Trials(); | |
217 | Float_t pthard = genPH->GetPtHard(); | |
b929303d | 218 | Float_t ptWeight=genPH->EventWeight(); |
219 | if(fPythiaInfo) fPythiaInfo->SetPythiaEventWeight(ptWeight); | |
e6f3b167 | 220 | fHistXsection->Fill(0.5,xsec); |
221 | fHistTrials->Fill(0.5,trials); | |
222 | fHistPtHard->Fill(pthard); | |
223 | } | |
6deabc32 | 224 | } |