ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/GeneratorMod.cc
Revision: 1.26
Committed: Fri Feb 13 12:51:10 2009 UTC (16 years, 2 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.25: +13 -2 lines
Log Message:
adding mass cut at gen level

File Contents

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