ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/GeneratorMod.cc
Revision: 1.25
Committed: Sun Jan 25 22:45:47 2009 UTC (16 years, 3 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006a
Changes since 1.24: +4 -7 lines
Log Message:
fixing an issue for W/ZH decays

File Contents

# User Rev Content
1 ceballos 1.25 // $Id: GeneratorMod.cc,v 1.24 2009/01/23 08:50:04 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/GeneratorMod.h"
4     #include "MitCommon/MathTools/interface/MathUtils.h"
5 loizides 1.8 #include "MitPhysics/Init/interface/ModNames.h"
6 loizides 1.1 #include <TH1D.h>
7     #include <TH2D.h>
8    
9     using namespace mithep;
10    
11     ClassImp(mithep::GeneratorMod)
12    
13     //--------------------------------------------------------------------------------------------------
14 loizides 1.8 GeneratorMod::GeneratorMod(const char *name, const char *title) :
15 loizides 1.1 BaseMod(name,title),
16     fMCPartName(Names::gkMCPartBrn),
17 loizides 1.8 fMCLeptonsName(ModNames::gkMCLeptonsName),
18     fMCAllLeptonsName(ModNames::gkMCAllLeptonsName),
19     fMCTausName(ModNames::gkMCTausName),
20     fMCNeutrinosName(ModNames::gkMCNeutrinosName),
21     fMCQuarksName(ModNames::gkMCQuarksName),
22     fMCqqHsName(ModNames::gkMCqqHsName),
23     fMCBosonsName(ModNames::gkMCBosonsName),
24 ceballos 1.10 fMCPhotonsName(ModNames::gkMCPhotonsName),
25 ceballos 1.14 fPtLeptonMin(0.0),
26     fEtaLeptonMax(5.0),
27     fPtPhotonMin(0.0),
28 loizides 1.15 fEtaPhotonMax(5.0),
29     fParticles(0)
30 loizides 1.1 {
31     // Constructor.
32     }
33    
34     //--------------------------------------------------------------------------------------------------
35     void GeneratorMod::Process()
36     {
37 loizides 1.5 // Process entries of the tree.
38 loizides 1.1
39 loizides 1.5 // these arrays will be filled in the loop of particles
40 loizides 1.9 MCParticleOArr *GenLeptons = new MCParticleOArr;
41 loizides 1.13 GenLeptons->SetName(fMCLeptonsName);
42 loizides 1.9 MCParticleOArr *GenAllLeptons = new MCParticleOArr;
43 loizides 1.13 GenAllLeptons->SetName(fMCAllLeptonsName);
44 loizides 1.9 MCParticleOArr *GenTaus = new MCParticleOArr;
45 loizides 1.13 GenTaus->SetName(fMCTausName);
46     GenTaus->SetOwner(kTRUE);
47 loizides 1.9 MCParticleOArr *GenNeutrinos = new MCParticleOArr;
48 loizides 1.13 GenNeutrinos->SetName(fMCNeutrinosName);
49 loizides 1.9 MCParticleOArr *GenQuarks = new MCParticleOArr;
50 loizides 1.13 GenQuarks->SetName(fMCQuarksName);
51 loizides 1.9 MCParticleOArr *GenqqHs = new MCParticleOArr;
52 loizides 1.13 GenqqHs->SetName(fMCqqHsName);
53 loizides 1.9 MCParticleOArr *GenBosons = new MCParticleOArr;
54 loizides 1.13 GenBosons->SetName(fMCBosonsName);
55 ceballos 1.10 MCParticleOArr *GenPhotons = new MCParticleOArr;
56 loizides 1.13 GenPhotons->SetName(fMCPhotonsName);
57 loizides 1.1
58 loizides 1.5 // load MCParticle branch
59     LoadBranch(fMCPartName);
60    
61 loizides 1.6 Bool_t isqqH = kFALSE;
62 loizides 1.5 for (UInt_t i=0; i<fParticles->GetEntries(); ++i) {
63 loizides 1.7 const MCParticle *p = fParticles->At(i);
64 loizides 1.5
65     if (!p->IsGenerated()) continue;
66    
67     // muons/electrons from W/Z decays
68 loizides 1.7 if ((p->Is(MCParticle::kEl) || p->Is(MCParticle::kMu)) && p->Status() == 1) {
69 ceballos 1.14 if (p->Pt() > fPtLeptonMin && p->AbsEta() < fEtaLeptonMax) {
70 loizides 1.5 GenAllLeptons->Add(p);
71     }
72 loizides 1.6 Bool_t isGoodLepton = kFALSE;
73 loizides 1.7 const MCParticle *pm = p;
74 loizides 1.5 while (pm->HasMother() && isGoodLepton == kFALSE) {
75 loizides 1.21 if (pm->PdgId() == 92) // string reached, terminate loop
76     break;
77 loizides 1.7 if (pm->Mother()->Is(MCParticle::kZ) || pm->Mother()->Is(MCParticle::kW)) {
78 loizides 1.5 GenLeptons->Add(p);
79     isGoodLepton = kTRUE;
80 loizides 1.7 break;
81 loizides 1.8 } else if (pm->Mother()->Is(MCParticle::kPi0) || pm->Mother()->Is(MCParticle::kEta)) {
82 loizides 1.7 // this is fake, but it is a trick to get rid of these cases and abort the loop
83     break;
84     }
85     pm = pm->Mother();
86 loizides 1.1 }
87 loizides 1.5 }
88    
89 loizides 1.7 // hadronic taus
90     else if (p->Is(MCParticle::kTau) && p->Status() == 2) {
91     if (!p->HasDaughter(MCParticle::kEl) && !p->HasDaughter(MCParticle::kMu)) {
92     const MCParticle *tv = p->FindDaughter(MCParticle::kTauNu);
93     if (tv) {
94     MCParticle *pm_f = new MCParticle(*p);
95     pm_f->SetMom(p->Px()-tv->Px(), p->Py()-tv->Py(),
96     p->Pz()-tv->Pz(), p->E()-tv->E());
97     GenTaus->AddOwned(pm_f);
98     } else {
99 loizides 1.18 SendError(kWarning, "Process", "Could not find a tau neutrino!");
100 loizides 1.5 }
101 loizides 1.1 }
102 loizides 1.5 }
103 loizides 1.1
104 loizides 1.5 // neutrinos
105 loizides 1.7 else if (p->Status() == 1 && p->IsNeutrino()) {
106 loizides 1.5 GenNeutrinos->Add(p);
107     }
108 loizides 1.1
109 loizides 1.5 // quarks from W/Z decays or top particles
110 loizides 1.7 else if (p->IsQuark() && p->HasMother()) {
111     if (p->Mother()->Is(MCParticle::kZ) || p->Mother()->Is(MCParticle::kW) ||
112     p->Is(MCParticle::kTop) || p->Mother()->Is(MCParticle::kTop)) {
113 loizides 1.5 GenQuarks->Add(p);
114 loizides 1.1 }
115 loizides 1.5 }
116 loizides 1.1
117 loizides 1.5 // qqH, information about the forward jets
118 loizides 1.8 else if (isqqH == kFALSE && p->Is(MCParticle::kH)) {
119 loizides 1.5 isqqH = kTRUE;
120 loizides 1.17 const MCParticle *pq1 = fParticles->At(i-1);
121     const MCParticle *pq2 = fParticles->At(i-2);
122 loizides 1.7 if (!pq1 || !pq2) {
123     SendError(kWarning, "Process", "Could not find quark pair!");
124 loizides 1.8 } else if (pq1->IsQuark() && pq2->IsQuark() &&
125     pq1->HasMother() && pq2->HasMother() &&
126 ceballos 1.25 pq1->Mother() == pq2->Mother() &&
127     pq1->Mother() != p->Mother() &&
128     pq1->Mother() != p->Mother()) {
129 loizides 1.5 GenqqHs->Add(pq1);
130     GenqqHs->Add(pq2);
131 loizides 1.1 }
132 ceballos 1.23
133 loizides 1.7 if (p->Status() == 3)
134 loizides 1.24 GenBosons->Add(p); // take higgs boson in account here rather in next else if
135 loizides 1.5 }
136 loizides 1.1
137 loizides 1.5 // information about bosons: W, Z, h, Z', W', H0, A0, H+
138 loizides 1.7 else if (p->Status() == 3 &&
139     (p->Is(MCParticle::kZ) || p->Is(MCParticle::kW) || p->Is(MCParticle::kH) ||
140     p->Is(MCParticle::kZp) || p->Is(MCParticle::kZpp) ||
141     p->Is(MCParticle::kH0) || p->Is(MCParticle::kA0) || p->Is(MCParticle::kHp))) {
142 loizides 1.5 GenBosons->Add(p);
143 loizides 1.1 }
144 ceballos 1.10
145 ceballos 1.14 // photons
146 ceballos 1.10 else if (p->Status() == 1 && p->Is(MCParticle::kGamma) &&
147 ceballos 1.14 p->Pt() > fPtPhotonMin && p->AbsEta() < fEtaPhotonMax) {
148 ceballos 1.10 GenPhotons->Add(p);
149     }
150    
151 loizides 1.18 // W/Z -> lnu for Madgraph
152     if (p->IsParton() && p->NDaughters() == 2) {
153 ceballos 1.16 CompositeParticle *diBoson = new CompositeParticle();
154     diBoson->AddDaughter(p->Daughter(0));
155     diBoson->AddDaughter(p->Daughter(1));
156 loizides 1.18 if (p->HasDaughter(MCParticle::kMu) && p->HasDaughter(MCParticle::kMuNu)) {
157 loizides 1.20 if (GetFillHist())
158 loizides 1.18 hDVMass[0]->Fill(TMath::Min(diBoson->Mass(),199.999));
159 ceballos 1.16 GenLeptons->Add(p->FindDaughter(MCParticle::kMu));
160     }
161 loizides 1.18 else if (p->HasDaughter(MCParticle::kEl) && p->HasDaughter(MCParticle::kElNu)) {
162 loizides 1.20 if (GetFillHist())
163 loizides 1.18 hDVMass[1]->Fill(TMath::Min(diBoson->Mass(),199.999));
164 ceballos 1.16 GenLeptons->Add(p->FindDaughter(MCParticle::kEl));
165     }
166 loizides 1.18 else if (p->HasDaughter(MCParticle::kTau) && p->HasDaughter(MCParticle::kTauNu)) {
167 loizides 1.20 if (GetFillHist())
168 loizides 1.18 hDVMass[2]->Fill(TMath::Min(diBoson->Mass(),199.999));
169     const MCParticle *tau = p->FindDaughter(MCParticle::kTau);
170     if (tau->HasDaughter(MCParticle::kMu))
171     GenLeptons->Add(tau->FindDaughter(MCParticle::kMu));
172     if (tau->HasDaughter(MCParticle::kEl))
173     GenLeptons->Add(tau->FindDaughter(MCParticle::kEl));
174     }
175     else if (p->Daughter(0)->Is(MCParticle::kMu) && p->Daughter(1)->Is(MCParticle::kMu)) {
176 loizides 1.20 if (GetFillHist())
177 loizides 1.18 hDVMass[3]->Fill(TMath::Min(diBoson->Mass(),199.999));
178 ceballos 1.16 GenLeptons->Add(p->Daughter(0));
179     GenLeptons->Add(p->Daughter(1));
180     }
181 loizides 1.18 else if (p->Daughter(0)->Is(MCParticle::kEl) && p->Daughter(1)->Is(MCParticle::kEl)) {
182 loizides 1.20 if (GetFillHist())
183 loizides 1.18 hDVMass[4]->Fill(TMath::Min(diBoson->Mass(),199.999));
184 ceballos 1.16 GenLeptons->Add(p->Daughter(0));
185     GenLeptons->Add(p->Daughter(1));
186     }
187 loizides 1.18 else if (p->Daughter(0)->Is(MCParticle::kTau) && p->Daughter(1)->Is(MCParticle::kTau)) {
188 loizides 1.20 if (GetFillHist())
189 loizides 1.18 hDVMass[5]->Fill(TMath::Min(diBoson->Mass(),199.999));
190     const MCParticle *tau0 = p->Daughter(0);
191     if (tau0->HasDaughter(MCParticle::kMu))
192     GenLeptons->Add(tau0->FindDaughter(MCParticle::kMu));
193     if (tau0->HasDaughter(MCParticle::kEl))
194     GenLeptons->Add(tau0->FindDaughter(MCParticle::kEl));
195     const MCParticle *tau1 = p->Daughter(1);
196     if (tau1->HasDaughter(MCParticle::kMu))
197     GenLeptons->Add(tau1->FindDaughter(MCParticle::kMu));
198     if (tau1->HasDaughter(MCParticle::kEl))
199     GenLeptons->Add(tau1->FindDaughter(MCParticle::kEl));
200 ceballos 1.16 }
201     delete diBoson;
202     }
203    
204 loizides 1.18 // t -> lnu for Madgraph
205     if (p->Is(MCParticle::kTop)) {
206 ceballos 1.16 CompositeParticle *diBoson = new CompositeParticle();
207 loizides 1.18 if (p->HasDaughter(MCParticle::kMu) && p->HasDaughter(MCParticle::kMuNu)) {
208 ceballos 1.16 diBoson->AddDaughter(p->FindDaughter(MCParticle::kMu));
209     diBoson->AddDaughter(p->FindDaughter(MCParticle::kMuNu));
210 loizides 1.20 if (GetFillHist())
211 loizides 1.18 hDVMass[6]->Fill(TMath::Min(diBoson->Mass(),199.999));
212 ceballos 1.16 GenLeptons->Add(p->FindDaughter(MCParticle::kMu));
213     }
214 loizides 1.18 else if (p->HasDaughter(MCParticle::kEl) && p->HasDaughter(MCParticle::kElNu)) {
215 ceballos 1.16 diBoson->AddDaughter(p->FindDaughter(MCParticle::kEl));
216     diBoson->AddDaughter(p->FindDaughter(MCParticle::kElNu));
217 loizides 1.20 if (GetFillHist())
218 loizides 1.18 hDVMass[7]->Fill(TMath::Min(diBoson->Mass(),199.999));
219 ceballos 1.16 GenLeptons->Add(p->FindDaughter(MCParticle::kEl));
220     }
221 loizides 1.18 else if (p->HasDaughter(MCParticle::kTau) && p->HasDaughter(MCParticle::kTauNu)) {
222 ceballos 1.16 diBoson->AddDaughter(p->FindDaughter(MCParticle::kTau));
223     diBoson->AddDaughter(p->FindDaughter(MCParticle::kTauNu));
224 loizides 1.20 if (GetFillHist())
225 loizides 1.18 hDVMass[8]->Fill(TMath::Min(diBoson->Mass(),199.999));
226     const MCParticle *tau = p->FindDaughter(MCParticle::kTau);
227     if (tau->HasDaughter(MCParticle::kMu))
228     GenLeptons->Add(tau->FindDaughter(MCParticle::kMu));
229     if (tau->HasDaughter(MCParticle::kEl))
230     GenLeptons->Add(tau->FindDaughter(MCParticle::kEl));
231     }
232     else if (!p->HasDaughter(MCParticle::kW)) {
233     for(UInt_t nd=0; nd<p->NDaughters(); ++nd)
234     if (p->Daughter(nd)->IsNot(MCParticle::kBottom) &&
235     p->Daughter(nd)->IsNot(MCParticle::kGamma))
236     diBoson->AddDaughter(p->Daughter(nd));
237 loizides 1.20 if (GetFillHist())
238 loizides 1.18 hDVMass[9]->Fill(TMath::Min(diBoson->Mass(),199.999));
239 ceballos 1.16 }
240     delete diBoson;
241     }
242 loizides 1.5 }
243 loizides 1.1
244 loizides 1.19 // sort according to pt
245     GenLeptons->Sort();
246     GenAllLeptons->Sort();
247     GenTaus->Sort();
248     GenNeutrinos->Sort();
249     GenQuarks->Sort();
250     GenqqHs->Sort();
251     GenBosons->Sort();
252     GenPhotons->Sort();
253    
254 loizides 1.8 // add objects to this event for other modules to use
255 loizides 1.13 AddObjThisEvt(GenLeptons);
256     AddObjThisEvt(GenAllLeptons);
257     AddObjThisEvt(GenTaus);
258     AddObjThisEvt(GenNeutrinos);
259     AddObjThisEvt(GenQuarks);
260     AddObjThisEvt(GenqqHs);
261     AddObjThisEvt(GenBosons);
262     AddObjThisEvt(GenPhotons);
263 ceballos 1.16
264 loizides 1.5 // fill histograms if requested
265 loizides 1.20 if (GetFillHist()) {
266 loizides 1.5
267 loizides 1.6 // leptons
268 loizides 1.1 hDGenLeptons[0]->Fill(GenLeptons->GetEntries());
269 loizides 1.5 for(UInt_t i=0; i<GenLeptons->GetEntries(); i++) {
270 loizides 1.1 hDGenLeptons[1]->Fill(GenLeptons->At(i)->Pt());
271 loizides 1.5 hDGenLeptons[2]->Fill(TMath::Abs(GenLeptons->At(i)->Eta()));
272     hDGenLeptons[3]->Fill(GenLeptons->At(i)->PhiDeg());
273     for(UInt_t j=i+1; j<GenLeptons->GetEntries(); j++) {
274 loizides 1.1 CompositeParticle *dilepton = new CompositeParticle();
275     dilepton->AddDaughter(GenLeptons->At(i));
276     dilepton->AddDaughter(GenLeptons->At(j));
277     hDGenLeptons[4]->Fill(dilepton->Mass());
278     delete dilepton;
279     }
280 ceballos 1.22 }
281     // looking at events with two leptons
282     if (GenLeptons->GetEntries() == 2) {
283     hDGenLeptons[5]->Fill(TMath::Min(TMath::Max(TMath::Abs(GenLeptons->At(0)->Eta()),
284     TMath::Abs(GenLeptons->At(1)->Eta())),
285 loizides 1.5 4.999));
286 ceballos 1.22 hDGenLeptons[6]->Fill(TMath::Min(TMath::Min(TMath::Abs(GenLeptons->At(0)->Eta()),
287     TMath::Abs(GenLeptons->At(1)->Eta())),
288 loizides 1.5 4.999));
289 ceballos 1.22 if (TMath::Abs(GenLeptons->At(0)->Eta()) < 2.5 &&
290     TMath::Abs(GenLeptons->At(1)->Eta()) < 2.5) {
291     hDGenLeptons[7]->Fill(TMath::Min(GenLeptons->At(0)->Pt(),199.999));
292     if (GenLeptons->At(0)->Pt() > 20.0) {
293     hDGenLeptons[8]->Fill(TMath::Min(GenLeptons->At(1)->Pt(),199.999));
294     if (GenLeptons->At(1)->Pt() > 10.0) {
295 loizides 1.1 CompositeParticle *dilepton = new CompositeParticle();
296 ceballos 1.22 dilepton->AddDaughter(GenLeptons->At(0));
297     dilepton->AddDaughter(GenLeptons->At(1));
298 loizides 1.1 hDGenLeptons[9]->Fill(TMath::Min(dilepton->Mass(),999.999));
299 ceballos 1.22 if(dilepton->Mass() > 12.0){
300     hDGenLeptons[10]->Fill(MathUtils::DeltaPhi(GenLeptons->At(0)->Phi(),
301     GenLeptons->At(1)->Phi())
302     * 180./ TMath::Pi());
303     hDGenLeptons[11]->Fill(MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
304     GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi()));
305     }
306 loizides 1.1 delete dilepton;
307     }
308     }
309     }
310     }
311 ceballos 1.22 // looking at events with three leptons
312     if (GenLeptons->GetEntries() == 3) {
313     if (TMath::Abs(GenLeptons->At(0)->Eta()) < 2.5 &&
314     TMath::Abs(GenLeptons->At(1)->Eta()) < 2.5 &&
315     TMath::Abs(GenLeptons->At(2)->Eta()) < 2.5) {
316     hDGenLeptons[12]->Fill(TMath::Min(GenLeptons->At(0)->Pt(),199.999));
317     if (GenLeptons->At(0)->Pt() > 20.0) {
318     hDGenLeptons[13]->Fill(TMath::Min(GenLeptons->At(1)->Pt(),199.999));
319     hDGenLeptons[14]->Fill(TMath::Min(GenLeptons->At(2)->Pt(),199.999));
320     if (GenLeptons->At(1)->Pt() > 10.0 && GenLeptons->At(2)->Pt() > 10.0) {
321     CompositeParticle *dilepton01 = new CompositeParticle();
322     dilepton01->AddDaughter(GenLeptons->At(0));
323     dilepton01->AddDaughter(GenLeptons->At(1));
324     CompositeParticle *dilepton02 = new CompositeParticle();
325     dilepton02->AddDaughter(GenLeptons->At(0));
326     dilepton02->AddDaughter(GenLeptons->At(2));
327     CompositeParticle *dilepton12 = new CompositeParticle();
328     dilepton12->AddDaughter(GenLeptons->At(1));
329     dilepton12->AddDaughter(GenLeptons->At(2));
330     hDGenLeptons[15]->Fill(TMath::Min(dilepton01->Mass(),999.999));
331     hDGenLeptons[15]->Fill(TMath::Min(dilepton02->Mass(),999.999));
332     hDGenLeptons[15]->Fill(TMath::Min(dilepton12->Mass(),999.999));
333     CompositeParticle *trilepton = new CompositeParticle();
334     trilepton->AddDaughter(GenLeptons->At(0));
335     trilepton->AddDaughter(GenLeptons->At(1));
336     trilepton->AddDaughter(GenLeptons->At(2));
337     hDGenLeptons[16]->Fill(TMath::Min(trilepton->Mass(),999.999));
338     double deltaR[3] = {MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
339     GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi()),
340     MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
341     GenLeptons->At(2)->Eta(), GenLeptons->At(2)->Phi()),
342     MathUtils::DeltaR(GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi(),
343     GenLeptons->At(2)->Eta(), GenLeptons->At(2)->Phi())};
344     double deltaRMin = deltaR[0];
345     for(int i=1; i<3; i++) if(deltaRMin > deltaR[i]) deltaRMin = deltaR[i];
346     hDGenLeptons[17]->Fill(deltaRMin);
347    
348     delete dilepton01;
349     delete dilepton02;
350     delete dilepton12;
351     delete trilepton;
352     }
353     }
354     }
355     }
356     // looking at events with four leptons
357     if (GenLeptons->GetEntries() == 4) {
358     if (TMath::Abs(GenLeptons->At(0)->Eta()) < 2.5 &&
359     TMath::Abs(GenLeptons->At(1)->Eta()) < 2.5 &&
360     TMath::Abs(GenLeptons->At(2)->Eta()) < 2.5 &&
361     TMath::Abs(GenLeptons->At(3)->Eta()) < 2.5) {
362     hDGenLeptons[18]->Fill(TMath::Min(GenLeptons->At(0)->Pt(),199.999));
363     if (GenLeptons->At(0)->Pt() > 20.0) {
364     hDGenLeptons[19]->Fill(TMath::Min(GenLeptons->At(1)->Pt(),199.999));
365     hDGenLeptons[20]->Fill(TMath::Min(GenLeptons->At(2)->Pt(),199.999));
366     hDGenLeptons[21]->Fill(TMath::Min(GenLeptons->At(3)->Pt(),199.999));
367     if (GenLeptons->At(1)->Pt() > 10.0 && GenLeptons->At(2)->Pt() > 10.0 &&
368     GenLeptons->At(3)->Pt() > 10.0) {
369     CompositeParticle *dilepton01 = new CompositeParticle();
370     dilepton01->AddDaughter(GenLeptons->At(0));
371     dilepton01->AddDaughter(GenLeptons->At(1));
372     CompositeParticle *dilepton02 = new CompositeParticle();
373     dilepton02->AddDaughter(GenLeptons->At(0));
374     dilepton02->AddDaughter(GenLeptons->At(2));
375     CompositeParticle *dilepton03 = new CompositeParticle();
376     dilepton03->AddDaughter(GenLeptons->At(0));
377     dilepton03->AddDaughter(GenLeptons->At(3));
378     CompositeParticle *dilepton12 = new CompositeParticle();
379     dilepton12->AddDaughter(GenLeptons->At(1));
380     dilepton12->AddDaughter(GenLeptons->At(2));
381     CompositeParticle *dilepton13 = new CompositeParticle();
382     dilepton13->AddDaughter(GenLeptons->At(1));
383     dilepton13->AddDaughter(GenLeptons->At(3));
384     CompositeParticle *dilepton23 = new CompositeParticle();
385     dilepton23->AddDaughter(GenLeptons->At(2));
386     dilepton23->AddDaughter(GenLeptons->At(3));
387     hDGenLeptons[22]->Fill(TMath::Min(dilepton01->Mass(),999.999));
388     hDGenLeptons[22]->Fill(TMath::Min(dilepton02->Mass(),999.999));
389     hDGenLeptons[22]->Fill(TMath::Min(dilepton03->Mass(),999.999));
390     hDGenLeptons[22]->Fill(TMath::Min(dilepton12->Mass(),999.999));
391     hDGenLeptons[22]->Fill(TMath::Min(dilepton13->Mass(),999.999));
392     hDGenLeptons[22]->Fill(TMath::Min(dilepton23->Mass(),999.999));
393     CompositeParticle *fourlepton = new CompositeParticle();
394     fourlepton->AddDaughter(GenLeptons->At(0));
395     fourlepton->AddDaughter(GenLeptons->At(1));
396     fourlepton->AddDaughter(GenLeptons->At(2));
397     fourlepton->AddDaughter(GenLeptons->At(3));
398     hDGenLeptons[23]->Fill(TMath::Min(fourlepton->Mass(),999.999));
399     double deltaR[6] = {MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
400     GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi()),
401     MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
402     GenLeptons->At(2)->Eta(), GenLeptons->At(2)->Phi()),
403     MathUtils::DeltaR(GenLeptons->At(0)->Eta(), GenLeptons->At(0)->Phi(),
404     GenLeptons->At(3)->Eta(), GenLeptons->At(3)->Phi()),
405     MathUtils::DeltaR(GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi(),
406     GenLeptons->At(2)->Eta(), GenLeptons->At(2)->Phi()),
407     MathUtils::DeltaR(GenLeptons->At(1)->Eta(), GenLeptons->At(1)->Phi(),
408     GenLeptons->At(3)->Eta(), GenLeptons->At(3)->Phi()),
409     MathUtils::DeltaR(GenLeptons->At(2)->Eta(), GenLeptons->At(2)->Phi(),
410     GenLeptons->At(3)->Eta(), GenLeptons->At(3)->Phi())};
411     double deltaRMin = deltaR[0];
412     for(int i=1; i<6; i++) if(deltaRMin > deltaR[i]) deltaRMin = deltaR[i];
413     hDGenLeptons[24]->Fill(deltaRMin);
414    
415     delete dilepton01;
416     delete dilepton02;
417     delete dilepton03;
418     delete dilepton12;
419     delete dilepton13;
420     delete dilepton23;
421     delete fourlepton;
422     }
423     }
424     }
425     }
426 loizides 1.1
427 loizides 1.6 // all leptons
428 ceballos 1.3 hDGenAllLeptons[0]->Fill(GenAllLeptons->GetEntries());
429 loizides 1.5 for(UInt_t i=0; i<GenAllLeptons->GetEntries(); i++) {
430 ceballos 1.3 hDGenAllLeptons[1]->Fill(GenAllLeptons->At(i)->Pt());
431     hDGenAllLeptons[2]->Fill(GenAllLeptons->At(i)->Eta());
432 loizides 1.5 hDGenAllLeptons[3]->Fill(GenAllLeptons->At(i)->PhiDeg());
433 ceballos 1.3 }
434    
435 loizides 1.6 // taus
436 loizides 1.1 hDGenTaus[0]->Fill(GenTaus->GetEntries());
437 loizides 1.5 for(UInt_t i=0; i<GenTaus->GetEntries(); i++) {
438 loizides 1.1 hDGenTaus[1]->Fill(GenTaus->At(i)->Pt());
439     hDGenTaus[2]->Fill(GenTaus->At(i)->Eta());
440 loizides 1.5 hDGenTaus[3]->Fill(GenTaus->At(i)->PhiDeg());
441 loizides 1.1 }
442    
443 loizides 1.6 // neutrinos
444 loizides 1.1 hDGenNeutrinos[0]->Fill(GenNeutrinos->GetEntries());
445     CompositeParticle *neutrinoTotal = new CompositeParticle();
446 loizides 1.5 for(UInt_t i=0; i<GenNeutrinos->GetEntries(); i++) {
447     if (GenNeutrinos->At(i)->HasMother())
448 loizides 1.1 neutrinoTotal->AddDaughter(GenNeutrinos->At(i));
449     }
450 loizides 1.5 if (GenNeutrinos->GetEntries() > 0) {
451 loizides 1.1 hDGenNeutrinos[1]->Fill(neutrinoTotal->Pt());
452     hDGenNeutrinos[2]->Fill(neutrinoTotal->Eta());
453 loizides 1.5 hDGenNeutrinos[3]->Fill(neutrinoTotal->PhiDeg());
454 loizides 1.1 }
455     delete neutrinoTotal;
456    
457 loizides 1.6 // quarks
458 loizides 1.1 hDGenQuarks[0]->Fill(GenQuarks->GetEntries());
459 loizides 1.5 for(UInt_t i=0; i<GenQuarks->GetEntries(); i++) {
460     for(UInt_t j=i+1; j<GenQuarks->GetEntries(); j++) {
461 loizides 1.1 CompositeParticle *dijet = new CompositeParticle();
462     dijet->AddDaughter(GenQuarks->At(i));
463     dijet->AddDaughter(GenQuarks->At(j));
464     hDGenQuarks[1]->Fill(dijet->Pt());
465     hDGenQuarks[2]->Fill(dijet->Mass());
466 loizides 1.5 if (TMath::Abs(GenQuarks->At(i)->Eta()) < 2.5 &&
467     TMath::Abs(GenQuarks->At(j)->Eta()) < 2.5) {
468 loizides 1.1 hDGenQuarks[3]->Fill(dijet->Pt());
469     hDGenQuarks[4]->Fill(dijet->Mass());
470     }
471     delete dijet;
472     }
473 ceballos 1.2 // b quark info
474 loizides 1.5 if (GenQuarks->At(i)->AbsPdgId() == 5) {
475 ceballos 1.2 hDGenQuarks[5]->Fill(GenQuarks->At(i)->Pt());
476     hDGenQuarks[6]->Fill(GenQuarks->At(i)->Eta());
477     hDGenQuarks[7]->Fill(GenQuarks->At(i)->Phi());
478 ceballos 1.22 if (GenLeptons->GetEntries() >= 2 &&
479     GenLeptons->At(0)->Pt() > 20 &&
480     GenLeptons->At(1)->Pt() > 15) {
481     if (TMath::Abs(GenLeptons->At(0)->Eta()) < 2.5 &&
482     TMath::Abs(GenLeptons->At(1)->Eta()) < 2.5) {
483 ceballos 1.2 hDGenQuarks[8]->Fill(GenQuarks->At(i)->Pt());
484     hDGenQuarks[9]->Fill(GenQuarks->At(i)->Eta());
485     hDGenQuarks[10]->Fill(GenQuarks->At(i)->Phi());
486     }
487     }
488     }
489     // t quark info
490 loizides 1.5 else if (GenQuarks->At(i)->AbsPdgId() == 6) {
491 ceballos 1.2 hDGenQuarks[11]->Fill(GenQuarks->At(i)->Pt());
492     hDGenQuarks[12]->Fill(GenQuarks->At(i)->Eta());
493     hDGenQuarks[13]->Fill(GenQuarks->At(i)->Phi());
494     }
495     // light quark info
496     else {
497     hDGenQuarks[14]->Fill(GenQuarks->At(i)->Pt());
498     hDGenQuarks[15]->Fill(GenQuarks->At(i)->Eta());
499     hDGenQuarks[16]->Fill(GenQuarks->At(i)->Phi());
500     }
501 loizides 1.1 }
502    
503 loizides 1.6 // wbf
504 loizides 1.5 if (GenqqHs->GetEntries() == 2) {
505 loizides 1.1 hDGenWBF[0]->Fill(MathUtils::DeltaPhi(GenqqHs->At(0)->Phi(),
506     GenqqHs->At(1)->Phi()) * 180./ TMath::Pi());
507 loizides 1.5 hDGenWBF[1]->Fill(TMath::Abs(GenqqHs->At(0)->Eta()-GenqqHs->At(1)->Eta()));
508 loizides 1.1 hDGenWBF[2]->Fill(TMath::Max(GenqqHs->At(0)->Pt(),GenqqHs->At(1)->Pt()));
509     hDGenWBF[3]->Fill(TMath::Min(GenqqHs->At(0)->Pt(),GenqqHs->At(1)->Pt()));
510     CompositeParticle *diqq = new CompositeParticle();
511     diqq->AddDaughter(GenqqHs->At(0));
512     diqq->AddDaughter(GenqqHs->At(1));
513     hDGenWBF[4]->Fill(diqq->Mass());
514     delete diqq;
515     }
516    
517 loizides 1.6 // bosons
518 loizides 1.1 hDGenBosons[0]->Fill(GenBosons->GetEntries());
519 loizides 1.5 for(UInt_t i=0; i<GenBosons->GetEntries(); i++) {
520 loizides 1.1 hDGenBosons[1]->Fill(GenBosons->At(i)->Pt());
521     hDGenBosons[2]->Fill(GenBosons->At(i)->Eta());
522     hDGenBosons[3]->Fill(GenBosons->At(i)->Mass());
523     }
524 ceballos 1.10
525     // photons
526     hDGenPhotons[0]->Fill(GenPhotons->GetEntries());
527     for(UInt_t i=0; i<GenPhotons->GetEntries(); i++) {
528     hDGenPhotons[1]->Fill(GenPhotons->At(i)->Pt());
529     hDGenPhotons[2]->Fill(GenPhotons->At(i)->Eta());
530     }
531 loizides 1.1 }
532     }
533    
534     //--------------------------------------------------------------------------------------------------
535     void GeneratorMod::SlaveBegin()
536     {
537 loizides 1.5 // Book branch and histograms if wanted.
538    
539 loizides 1.1 ReqBranch(fMCPartName, fParticles);
540    
541 loizides 1.5 // fill histograms
542 loizides 1.20 if (GetFillHist()) {
543 loizides 1.5 char sb[1024];
544 loizides 1.6 // leptons from W
545 loizides 1.1 sprintf(sb,"hDGenLeptons_%d", 0); hDGenLeptons[0] = new TH1D(sb,sb,10,-0.5,9.5);
546     sprintf(sb,"hDGenLeptons_%d", 1); hDGenLeptons[1] = new TH1D(sb,sb,100,0.0,200.0);
547     sprintf(sb,"hDGenLeptons_%d", 2); hDGenLeptons[2] = new TH1D(sb,sb,50,0.0,5.0);
548     sprintf(sb,"hDGenLeptons_%d", 3); hDGenLeptons[3] = new TH1D(sb,sb,90,0.0,180.0);
549     sprintf(sb,"hDGenLeptons_%d", 4); hDGenLeptons[4] = new TH1D(sb,sb,1000,0.0,1000.0);
550     sprintf(sb,"hDGenLeptons_%d", 5); hDGenLeptons[5] = new TH1D(sb,sb,50,0.0,5.0);
551     sprintf(sb,"hDGenLeptons_%d", 6); hDGenLeptons[6] = new TH1D(sb,sb,50,0.0,5.0);
552     sprintf(sb,"hDGenLeptons_%d", 7); hDGenLeptons[7] = new TH1D(sb,sb,100,0.0,200.0);
553     sprintf(sb,"hDGenLeptons_%d", 8); hDGenLeptons[8] = new TH1D(sb,sb,100,0.0,200.0);
554     sprintf(sb,"hDGenLeptons_%d", 9); hDGenLeptons[9] = new TH1D(sb,sb,1000,0.0,1000.0);
555     sprintf(sb,"hDGenLeptons_%d",10); hDGenLeptons[10] = new TH1D(sb,sb,90,0.0,180.0);
556 ceballos 1.22 sprintf(sb,"hDGenLeptons_%d",11); hDGenLeptons[11] = new TH1D(sb,sb,100,0.0,5.0);
557     sprintf(sb,"hDGenLeptons_%d",12); hDGenLeptons[12] = new TH1D(sb,sb,100,0.0,200.0);
558     sprintf(sb,"hDGenLeptons_%d",13); hDGenLeptons[13] = new TH1D(sb,sb,100,0.0,200.0);
559     sprintf(sb,"hDGenLeptons_%d",14); hDGenLeptons[14] = new TH1D(sb,sb,100,0.0,200.0);
560     sprintf(sb,"hDGenLeptons_%d",15); hDGenLeptons[15] = new TH1D(sb,sb,1000,0.0,1000.0);
561     sprintf(sb,"hDGenLeptons_%d",16); hDGenLeptons[16] = new TH1D(sb,sb,1000,0.0,1000.0);
562     sprintf(sb,"hDGenLeptons_%d",17); hDGenLeptons[17] = new TH1D(sb,sb,100,0.0,5.0);
563     sprintf(sb,"hDGenLeptons_%d",18); hDGenLeptons[18] = new TH1D(sb,sb,100,0.0,200.0);
564     sprintf(sb,"hDGenLeptons_%d",19); hDGenLeptons[19] = new TH1D(sb,sb,100,0.0,200.0);
565     sprintf(sb,"hDGenLeptons_%d",20); hDGenLeptons[20] = new TH1D(sb,sb,100,0.0,200.0);
566     sprintf(sb,"hDGenLeptons_%d",21); hDGenLeptons[21] = new TH1D(sb,sb,100,0.0,200.0);
567     sprintf(sb,"hDGenLeptons_%d",22); hDGenLeptons[22] = new TH1D(sb,sb,1000,0.0,1000.0);
568     sprintf(sb,"hDGenLeptons_%d",23); hDGenLeptons[23] = new TH1D(sb,sb,1000,0.0,1000.0);
569     sprintf(sb,"hDGenLeptons_%d",24); hDGenLeptons[24] = new TH1D(sb,sb,100,0.0,5.0);
570     for(Int_t i=0; i<25; i++) AddOutput(hDGenLeptons[i]);
571 loizides 1.1
572 loizides 1.6 // all leptons
573 ceballos 1.3 sprintf(sb,"hDGenAllLeptons_%d", 0); hDGenAllLeptons[0] = new TH1D(sb,sb,10,-0.5,9.5);
574     sprintf(sb,"hDGenAllLeptons_%d", 1); hDGenAllLeptons[1] = new TH1D(sb,sb,100,0.0,200.0);
575 ceballos 1.14 sprintf(sb,"hDGenAllLeptons_%d", 2); hDGenAllLeptons[2] = new TH1D(sb,sb,100,-5.0,5.0);
576 ceballos 1.3 sprintf(sb,"hDGenAllLeptons_%d", 3); hDGenAllLeptons[3] = new TH1D(sb,sb,90,0.0,180.0);
577 loizides 1.5 for(Int_t i=0; i<4; i++) AddOutput(hDGenAllLeptons[i]);
578 ceballos 1.3
579 loizides 1.6 // taus
580 loizides 1.1 sprintf(sb,"hDGenTaus_%d", 0); hDGenTaus[0] = new TH1D(sb,sb,10,-0.5,9.5);
581     sprintf(sb,"hDGenTaus_%d", 1); hDGenTaus[1] = new TH1D(sb,sb,100,0.0,200.0);
582     sprintf(sb,"hDGenTaus_%d", 2); hDGenTaus[2] = new TH1D(sb,sb,100,-5.0,5.0);
583     sprintf(sb,"hDGenTaus_%d", 3); hDGenTaus[3] = new TH1D(sb,sb,90,0.0,180.0);
584 loizides 1.5 for(Int_t i=0; i<4; i++) AddOutput(hDGenTaus[i]);
585 loizides 1.1
586 loizides 1.6 // neutrinos
587 loizides 1.1 sprintf(sb,"hDGenNeutrinos_%d", 0); hDGenNeutrinos[0] = new TH1D(sb,sb,10,-0.5,9.5);
588     sprintf(sb,"hDGenNeutrinos_%d", 1); hDGenNeutrinos[1] = new TH1D(sb,sb,100,0.0,200.0);
589     sprintf(sb,"hDGenNeutrinos_%d", 2); hDGenNeutrinos[2] = new TH1D(sb,sb,100,-5.0,5.0);
590     sprintf(sb,"hDGenNeutrinos_%d", 3); hDGenNeutrinos[3] = new TH1D(sb,sb,90,0.0,180.0);
591 loizides 1.5 for(Int_t i=0; i<4; i++) AddOutput(hDGenNeutrinos[i]);
592 loizides 1.1
593 loizides 1.6 // quarks
594 loizides 1.1 sprintf(sb,"hDGenQuarks_%d", 0); hDGenQuarks[0] = new TH1D(sb,sb,10,-0.5,9.5);
595     sprintf(sb,"hDGenQuarks_%d", 1); hDGenQuarks[1] = new TH1D(sb,sb,200,0.0,400.);
596     sprintf(sb,"hDGenQuarks_%d", 2); hDGenQuarks[2] = new TH1D(sb,sb,2000,0.0,2000.);
597     sprintf(sb,"hDGenQuarks_%d", 3); hDGenQuarks[3] = new TH1D(sb,sb,200,0.0,400.);
598     sprintf(sb,"hDGenQuarks_%d", 4); hDGenQuarks[4] = new TH1D(sb,sb,2000,0.0,2000.);
599 ceballos 1.2 sprintf(sb,"hDGenQuarks_%d", 5); hDGenQuarks[5] = new TH1D(sb,sb,200,0.0,400.);
600     sprintf(sb,"hDGenQuarks_%d", 6); hDGenQuarks[6] = new TH1D(sb,sb,200,-10.0,10.);
601 loizides 1.5 sprintf(sb,"hDGenQuarks_%d", 7); hDGenQuarks[7] = new TH1D(sb,sb,200,-TMath::Pi(),
602     TMath::Pi());
603 ceballos 1.2 sprintf(sb,"hDGenQuarks_%d", 8); hDGenQuarks[8] = new TH1D(sb,sb,200,0.0,400.);
604     sprintf(sb,"hDGenQuarks_%d", 9); hDGenQuarks[9] = new TH1D(sb,sb,200,-10.0,10.);
605 loizides 1.5 sprintf(sb,"hDGenQuarks_%d",10); hDGenQuarks[10] = new TH1D(sb,sb,200,-TMath::Pi(),
606     TMath::Pi());
607 ceballos 1.2 sprintf(sb,"hDGenQuarks_%d",11); hDGenQuarks[11] = new TH1D(sb,sb,200,0.0,400.);
608     sprintf(sb,"hDGenQuarks_%d",12); hDGenQuarks[12] = new TH1D(sb,sb,200,-10.0,10.);
609 loizides 1.5 sprintf(sb,"hDGenQuarks_%d",13); hDGenQuarks[13] = new TH1D(sb,sb,200,-TMath::Pi(),
610     TMath::Pi());
611 ceballos 1.2 sprintf(sb,"hDGenQuarks_%d",14); hDGenQuarks[14] = new TH1D(sb,sb,200,0.0,400.);
612     sprintf(sb,"hDGenQuarks_%d",15); hDGenQuarks[15] = new TH1D(sb,sb,200,-10.0,10.);
613 loizides 1.5 sprintf(sb,"hDGenQuarks_%d",16); hDGenQuarks[16] = new TH1D(sb,sb,200,-TMath::Pi(),
614     TMath::Pi());
615     for(Int_t i=0; i<17; i++) AddOutput(hDGenQuarks[i]);
616 loizides 1.1
617     // qqH
618     sprintf(sb,"hDGenWBF_%d", 0); hDGenWBF[0] = new TH1D(sb,sb,90,0.0,180.);
619     sprintf(sb,"hDGenWBF_%d", 1); hDGenWBF[1] = new TH1D(sb,sb,100,0.0,10.);
620     sprintf(sb,"hDGenWBF_%d", 2); hDGenWBF[2] = new TH1D(sb,sb,200,0.0,400.);
621     sprintf(sb,"hDGenWBF_%d", 3); hDGenWBF[3] = new TH1D(sb,sb,200,0.0,400.);
622     sprintf(sb,"hDGenWBF_%d", 4); hDGenWBF[4] = new TH1D(sb,sb,200,0.0,4000.);
623 loizides 1.5 for(Int_t i=0; i<5; i++) AddOutput(hDGenWBF[i]);
624 loizides 1.1
625 loizides 1.6 // bosons
626 loizides 1.1 sprintf(sb,"hDGenBosons_%d", 0); hDGenBosons[0] = new TH1D(sb,sb,10,-0.5,9.5);
627     sprintf(sb,"hDGenBosons_%d", 1); hDGenBosons[1] = new TH1D(sb,sb,200,0.0,400.0);
628     sprintf(sb,"hDGenBosons_%d", 2); hDGenBosons[2] = new TH1D(sb,sb,100,-5.0,5.0);
629     sprintf(sb,"hDGenBosons_%d", 3); hDGenBosons[3] = new TH1D(sb,sb,2000,0.0,2000.0);
630 loizides 1.5 for(Int_t i=0; i<4; i++) AddOutput(hDGenBosons[i]);
631 ceballos 1.10
632     // photons
633     sprintf(sb,"hDGenPhotons_%d", 0); hDGenPhotons[0] = new TH1D(sb,sb,10,-0.5,9.5);
634     sprintf(sb,"hDGenPhotons_%d", 1); hDGenPhotons[1] = new TH1D(sb,sb,200,0.0,400.0);
635 ceballos 1.14 sprintf(sb,"hDGenPhotons_%d", 2); hDGenPhotons[2] = new TH1D(sb,sb,100,-5.0,5.0);
636 ceballos 1.10 for(Int_t i=0; i<3; i++) AddOutput(hDGenPhotons[i]);
637 ceballos 1.16
638     // auxiliar
639     sprintf(sb,"hDVMass_%d", 0); hDVMass[0] = new TH1D(sb,sb,200,0.,200.);
640     sprintf(sb,"hDVMass_%d", 1); hDVMass[1] = new TH1D(sb,sb,200,0.,200.);
641     sprintf(sb,"hDVMass_%d", 2); hDVMass[2] = new TH1D(sb,sb,200,0.,200.);
642     sprintf(sb,"hDVMass_%d", 3); hDVMass[3] = new TH1D(sb,sb,200,0.,200.);
643     sprintf(sb,"hDVMass_%d", 4); hDVMass[4] = new TH1D(sb,sb,200,0.,200.);
644     sprintf(sb,"hDVMass_%d", 5); hDVMass[5] = new TH1D(sb,sb,200,0.,200.);
645     sprintf(sb,"hDVMass_%d", 6); hDVMass[6] = new TH1D(sb,sb,200,0.,200.);
646     sprintf(sb,"hDVMass_%d", 7); hDVMass[7] = new TH1D(sb,sb,200,0.,200.);
647     sprintf(sb,"hDVMass_%d", 8); hDVMass[8] = new TH1D(sb,sb,200,0.,200.);
648     sprintf(sb,"hDVMass_%d", 9); hDVMass[9] = new TH1D(sb,sb,200,0.,200.);
649     for(Int_t i=0; i<10; i++) AddOutput(hDVMass[i]);
650 loizides 1.1 }
651     }