Ticket #352: WWGen_cut_dl.cc
File WWGen_cut_dl.cc, 14.4 KB (added by , 9 years ago) |
---|
Line | |
---|---|
1 | |
2 | //IMPORTANT: Add .cc extension: WWGen.cc |
3 | |
4 | |
5 | #include "Rivet/Analysis.hh" |
6 | #include "Rivet/Projections/FinalState.hh" |
7 | #include "Rivet/Projections/LeadingParticlesFinalState.hh" |
8 | #include "Rivet/Projections/VisibleFinalState.hh" |
9 | #include "Rivet/Projections/FastJets.hh" |
10 | |
11 | #include <iostream> |
12 | #include <fstream> |
13 | |
14 | #include "Rivet/Projections/UnstableFinalState.hh" |
15 | #include "Rivet/Projections/IdentifiedFinalState.hh" |
16 | |
17 | #include "Rivet/Projections/DressedLeptons.hh" |
18 | |
19 | using namespace std; |
20 | |
21 | namespace Rivet { |
22 | |
23 | |
24 | |
25 | |
26 | class WWGen_cut_dl : public Analysis { |
27 | public: |
28 | |
29 | /// Constructor |
30 | WWGen_cut_dl() |
31 | : Analysis("WWGen_cut_dl") |
32 | { ce=0; |
33 | cmu=0; |
34 | numev=0; |
35 | numlep=0; |
36 | numneu=0; |
37 | numwm=0; |
38 | numwp=0; |
39 | } |
40 | |
41 | public: |
42 | |
43 | /// Book histograms and initialise projections before the run |
44 | void init() { |
45 | |
46 | |
47 | |
48 | |
49 | /// @todo Initialise and register projections here |
50 | addProjection(VisibleFinalState(-50,50),"vfs"); |
51 | |
52 | LeadingParticlesFinalState leadingLeptons(FinalState(-2.50, 2.50, 0*GeV)); |
53 | leadingLeptons.addParticleIdPair(PID::ELECTRON); |
54 | leadingLeptons.addParticleIdPair(PID::MUON); |
55 | // leadingLeptons.acceptIdPair(15); |
56 | addProjection(leadingLeptons, "leptons"); |
57 | |
58 | LeadingParticlesFinalState leadingNeutrinos(FinalState(-5, 5, 0*GeV)); |
59 | leadingNeutrinos.addParticleIdPair(12); |
60 | leadingNeutrinos.addParticleIdPair(14); |
61 | // leadingNeutrinos.acceptIdPair(16); |
62 | addProjection(leadingNeutrinos, "neutrinos"); |
63 | |
64 | addProjection(FastJets(FinalState(-6,6), FastJets::ANTIKT, 0.5), "jets"); |
65 | |
66 | IdentifiedFinalState photon(FinalState(-5, 5, 0*GeV)); |
67 | photon.acceptId(22); |
68 | addProjection(photon, "Photon"); |
69 | |
70 | DressedLeptons dl ( photon, leadingLeptons, 0.1,true,-5,5,0*GeV,false); |
71 | addProjection(dl, "DressedLeptons"); |
72 | |
73 | |
74 | |
75 | |
76 | //Higgs |
77 | _h_mh = bookHisto1D("mh", 130, 50, 180); |
78 | _h_mh_0j = bookHisto1D("mh_0j", 130, 50, 180); |
79 | _h_mh_1j = bookHisto1D("mh_1j", 130, 50, 180); |
80 | _h_mh_2j = bookHisto1D("mh_2j", 130, 50, 180); |
81 | _h_mth = bookHisto1D("mth", 25, 0, 250); |
82 | _h_mth_0j = bookHisto1D("mth_0j", 25, 0, 250); |
83 | _h_mth_1j = bookHisto1D("mth_1j", 25, 0, 250); |
84 | _h_mth_2j = bookHisto1D("mth_2j", 25, 0, 250); |
85 | _h_pth = bookHisto1D("pth", 25, 0, 250); //pt higgs |
86 | _h_etah = bookHisto1D("etah", 25, 0, 4); //eta higgs |
87 | |
88 | //leptons |
89 | _h_mll = bookHisto1D("mll", 25, 0, 250); |
90 | _h_mll_0j = bookHisto1D("mll_0j", 25, 0, 250); |
91 | _h_mll_1j = bookHisto1D("mll_1j", 25, 0, 250); |
92 | _h_mll_2j = bookHisto1D("mll_2j", 25, 0, 250); |
93 | _h_pt_1l = bookHisto1D("pt_1l", 25, 0, 250); //pt leading lepton |
94 | _h_pt_2l = bookHisto1D("pt_2l", 25, 0, 250); //pt sub-leading lepton |
95 | _h_pt_ll = bookHisto1D("pt_ll", 25, 0, 250); //pt leading + sub-leading leptons |
96 | _h_eta_1l = bookHisto1D("eta_1l", 20, -10, 10); //eta leading lepton |
97 | _h_eta_2l = bookHisto1D("eta_2l", 20, -10, 10); //eta sub-leading lepton |
98 | _h_deta_l = bookHisto1D("deta_l", 25, 0, 10); //Delta-eta |
99 | _h_dphi_l = bookHisto1D("dphi_l", 25, 0, 4); //Delta-phi leptons |
100 | |
101 | //W+- mass |
102 | _h_mwm = bookHisto1D("mwm", 160, 0, 160); |
103 | _h_mwp = bookHisto1D("mwp", 160, 0, 160); |
104 | |
105 | _h_mwm_0j = bookHisto1D("mwm_0j", 160, 0, 160); |
106 | _h_mwm_1j = bookHisto1D("mwm_1j", 160, 0, 160); |
107 | _h_mwm_2j = bookHisto1D("mwm_2j", 160, 0, 160); |
108 | |
109 | _h_mwp_0j = bookHisto1D("mwp_0j", 160, 0, 160); |
110 | _h_mwp_1j = bookHisto1D("mwp_1j", 160, 0, 160); |
111 | _h_mwp_2j = bookHisto1D("mwp_2j", 160, 0, 160); |
112 | |
113 | //jets |
114 | _h_mjj = bookHisto1D("mjj", 25, 0, 250);//massa dei due jets |
115 | _h_pt_1j = bookHisto1D("pt_1j", 25, 0, 250); //pt leading jet |
116 | _h_pt_2j = bookHisto1D("pt_2j", 25, 0, 250); //pt sub-leading jet |
117 | _h_eta_1j = bookHisto1D("eta_1j", 25, 0, 5); //eta leading lepton |
118 | _h_eta_2j = bookHisto1D("eta_2j", 25, 0, 5); //eta sub-leading lepton |
119 | _h_deta_j = bookHisto1D("deta_j", 25, 0, 10); //Delta-eta jets |
120 | _h_njet = bookHisto1D("njet", 4, -0.5, 3.5); |
121 | _h_njet_onPeak = bookHisto1D("njet_onPeak", 4, -0.5, 3.5); |
122 | _h_njet_offPeak = bookHisto1D("njet_offPeak", 4, -0.5, 3.5); |
123 | |
124 | //Weight |
125 | _h_weight= bookHisto1D("weight", 300, -300, 300); |
126 | } |
127 | |
128 | |
129 | /// Perform the per-event analysis |
130 | void analyze(const Event& event) { |
131 | double weight = event.weight(); |
132 | |
133 | std::vector<Rivet::DressedLepton> dressed= applyProjection< DressedLeptons >(event,"DressedLeptons").dressedLeptons(); |
134 | //std::vector<Rivet::Particles> dressed= applyProjection< DressedLeptons >(event,"DressedLeptons").dressedLeptons(); |
135 | std::sort(dressed.begin(), dressed.end(), cmpMomByPt); |
136 | |
137 | Particles cand_leptons; |
138 | foreach (const Particle & particle, dressed){//ByPt |
139 | // foreach ( const Particle & particle, applyProjection< LeadingParticlesFinalState>(event,"leptons").particlesByPt() ){//ByPt |
140 | if (cand_leptons.size() == 0 && particle.pt() > 25*GeV && fabs(particle.eta()) < 2.4){ |
141 | cand_leptons.push_back(particle);} |
142 | else if (cand_leptons.size() == 1 && particle.pt() > 10*GeV && fabs(particle.eta()) < 2.4){ |
143 | cand_leptons.push_back(particle); |
144 | } |
145 | } |
146 | |
147 | if (cand_leptons.size() <2){ |
148 | // std::cout << "not enough leptons: STRANGE!!" << std::endl; |
149 | vetoEvent; |
150 | } |
151 | |
152 | Particles vfs_particles = applyProjection<VisibleFinalState>(event, "vfs").particles(); |
153 | FourMomentum pTmiss; |
154 | foreach ( const Particle & p, vfs_particles ) { |
155 | pTmiss -= p.momentum(); |
156 | } |
157 | double eTmiss = pTmiss.pT(); |
158 | |
159 | Particles cand_neutrinos; |
160 | foreach ( const Particle & neutrino, applyProjection< LeadingParticlesFinalState>(event,"neutrinos").particlesByPt() ){//ByPt |
161 | if (cand_neutrinos.size() < 2) |
162 | cand_neutrinos.push_back(neutrino); |
163 | } |
164 | |
165 | if (cand_neutrinos.size()<2 ){ |
166 | // std::cout << "not enough neutrinos: STRANGE!!" << std::endl; |
167 | vetoEvent; |
168 | } |
169 | |
170 | |
171 | Jets cand_jets; |
172 | foreach (const Jet& jet, |
173 | applyProjection<FastJets>(event, "jets").jetsByPt(30.0*GeV) ) { |
174 | if ( fabs( jet.eta() ) < 4.9 ) { |
175 | bool isolated = true; |
176 | foreach (const Particle& neutrino, cand_neutrinos){ |
177 | if (deltaR(neutrino, jet) < 0.5){ |
178 | isolated = false; |
179 | break; |
180 | } |
181 | } |
182 | if (isolated) { |
183 | foreach (const Particle& lepton, cand_leptons){ |
184 | if (deltaR(lepton, jet) < 0.5){ |
185 | isolated = false; |
186 | break; |
187 | } |
188 | } |
189 | } |
190 | if (isolated) |
191 | cand_jets.push_back(jet); |
192 | } |
193 | } |
194 | |
195 | unsigned int njet = 0; |
196 | foreach (const Jet& jet, cand_jets){ |
197 | if (jet.momentum().pT()>30*GeV) |
198 | njet += 1; |
199 | } |
200 | |
201 | //W+- |
202 | FourMomentum wm; |
203 | FourMomentum wp; |
204 | |
205 | if( ((cand_leptons[0].charge() )* (cand_leptons[1].charge()))==1 ){ |
206 | vetoEvent; |
207 | |
208 | } |
209 | |
210 | //per il leptone 1 |
211 | // for (size_t j=0; j< 2 ;++j){ |
212 | for (size_t i=0; i< 2 ;++i){ |
213 | if ( (cand_leptons[0].pid()+cand_neutrinos[i].pid())==-1){//caso W- |
214 | wm=cand_leptons[0].momentum()+cand_neutrinos[i].momentum(); |
215 | numwm++; |
216 | break; |
217 | } |
218 | if ( (cand_leptons[0].pid()+cand_neutrinos[i].pid())==1){//caso W+ |
219 | wp=cand_leptons[0].momentum()+cand_neutrinos[i].momentum(); |
220 | numwp++; |
221 | break; |
222 | // }else{ |
223 | //vetoEvent; |
224 | } |
225 | } |
226 | // }//for j |
227 | |
228 | |
229 | //per il leptone 2 |
230 | for (size_t i=0; i< 2 ;++i){ |
231 | if ( (cand_leptons[1].pid()+cand_neutrinos[i].pid())==-1){//caso W- |
232 | wm=cand_leptons[1].momentum()+cand_neutrinos[i].momentum(); |
233 | numwm++; |
234 | break; |
235 | } |
236 | if ( (cand_leptons[1].pid()+cand_neutrinos[i].pid())==1){//caso W+ |
237 | wp=cand_leptons[1].momentum()+cand_neutrinos[i].momentum(); |
238 | numwp++; |
239 | break; |
240 | //}else{ |
241 | //vetoEvent; |
242 | } |
243 | } |
244 | |
245 | //Higgs |
246 | double mh ; |
247 | double pth; |
248 | FourMomentum ll(0,0,0,0); |
249 | FourMomentum nn(0,0,0,0); |
250 | ll= cand_leptons[0].momentum() + cand_leptons[1].momentum(); |
251 | nn = cand_neutrinos[0].momentum() + cand_neutrinos[1].momentum(); |
252 | double mll = ll.mass(); |
253 | double ptll = ll.pT(); |
254 | mh = (wm+wp).mass(); |
255 | pth=(wm+wp).pT(); |
256 | double etah=(wm+wp).eta(); |
257 | double mth = sqrt( 2*ptll*eTmiss*( 1 - cos(fabs(deltaPhi(ll, pTmiss))))); |
258 | |
259 | //W+W- mass |
260 | double mwm =wm.mass(); |
261 | double mwp =wp.mass(); |
262 | |
263 | //leptons |
264 | double pt1 = cand_leptons[0].momentum().pT();//pt del leading lepton |
265 | double pt2 = cand_leptons[1].momentum().pT(); |
266 | double eta_1l= cand_leptons[0].eta(); |
267 | double eta_2l= cand_leptons[1].eta(); |
268 | double pt_ll=ll.pT();//prima somma vettoriale, poi valuto il pt |
269 | double deta_l=eta_1l-eta_2l; |
270 | double dphi_l=deltaPhi( eta_1l, eta_2l); |
271 | |
272 | |
273 | if(mwp<5. || mwm<5.){ |
274 | vetoEvent; } |
275 | if((nn.pt())<20.){ |
276 | vetoEvent; } |
277 | |
278 | //per contare gli eventi selezionati (=> eventi in cui ho H->WW) |
279 | numev++; |
280 | |
281 | //Fill histrogram w/o request |
282 | //Higgs |
283 | _h_mh->fill(mh, weight); |
284 | _h_mth->fill(mth, weight); |
285 | _h_pth->fill(pth, weight); |
286 | |
287 | if(fabs(etah) <5000000){ |
288 | _h_etah->fill(etah, weight); } |
289 | |
290 | //lepton |
291 | _h_mll->fill(mll, weight); |
292 | _h_pt_1l->fill(pt1, weight); |
293 | _h_pt_2l->fill(pt2, weight); |
294 | _h_pt_ll->fill(pt_ll, weight); |
295 | _h_eta_1l->fill(eta_1l, weight); |
296 | _h_eta_2l->fill(eta_2l, weight); |
297 | _h_deta_l->fill(deta_l, weight); |
298 | _h_dphi_l->fill(dphi_l, weight); |
299 | |
300 | //W+- |
301 | _h_mwm->fill(mwm, weight); |
302 | _h_mwp->fill(mwp, weight); |
303 | |
304 | //Njets |
305 | _h_njet->fill(njet, weight); |
306 | if (mh < 130*GeV) |
307 | _h_njet_onPeak->fill(njet, weight); |
308 | else |
309 | _h_njet_offPeak->fill(njet, weight); |
310 | |
311 | //Fill histrogram with Njet request |
312 | if (njet == 0){ |
313 | _h_mll_0j->fill(mll, weight); |
314 | _h_mth_0j->fill(mth, weight); |
315 | _h_mh_0j->fill(mh, weight); |
316 | |
317 | _h_mwm_0j->fill(mwm, weight); |
318 | _h_mwp_0j->fill(mwp, weight); |
319 | |
320 | } else if (njet == 1){ |
321 | _h_mll_1j->fill(mll, weight); |
322 | _h_mth_1j->fill(mth, weight); |
323 | _h_mh_1j->fill(mh, weight); |
324 | double pt_1j= cand_jets[0].momentum().pT(); |
325 | double eta_1j= cand_jets[0].momentum().eta(); |
326 | _h_pt_1j->fill(pt_1j, weight); |
327 | _h_eta_1j->fill(eta_1j, weight); |
328 | _h_mwm_1j->fill(mwm, weight); |
329 | _h_mwp_1j->fill(mwp, weight); |
330 | } else { |
331 | _h_mll_2j->fill(mll, weight); |
332 | _h_mth_2j->fill(mth, weight); |
333 | _h_mh_2j->fill(mh, weight); |
334 | double pt_1j= cand_jets[0].momentum().pT(); |
335 | double pt_2j= cand_jets[1].momentum().pT(); |
336 | FourMomentum jj = cand_jets[0].momentum() + cand_jets[1].momentum(); |
337 | double mjj=jj.mass(); |
338 | double eta_1j= cand_jets[0].momentum().eta(); |
339 | double eta_2j= cand_jets[1].momentum().eta(); |
340 | double deta_j=eta_1j-eta_2j; |
341 | _h_pt_1j->fill(pt_1j, weight); |
342 | _h_pt_2j->fill(pt_2j, weight); |
343 | _h_eta_1j->fill(eta_1j, weight); |
344 | _h_eta_2j->fill(eta_2j, weight); |
345 | _h_mjj->fill(mjj, weight); |
346 | _h_deta_j->fill( deta_j,weight); |
347 | _h_mwm_2j->fill(mwm, weight); |
348 | _h_mwp_2j->fill(mwp, weight); |
349 | |
350 | |
351 | } |
352 | |
353 | _h_weight->fill(weight); |
354 | |
355 | }//loop void analyze |
356 | |
357 | |
358 | void finalize() { |
359 | // su sherpa final cross section = 6.246e-01 +- 2.214e-02 pb |
360 | // double xsec=crossSection(); |
361 | // double xsec=sumOfWeights(); |
362 | double xsec=1.; |
363 | std::cout << "xsec is: " << xsec << std::endl; |
364 | |
365 | scale(_h_njet, xsec/sumOfWeights() ); |
366 | scale(_h_njet_onPeak, xsec/sumOfWeights()); |
367 | scale(_h_njet_offPeak, xsec/sumOfWeights()); |
368 | scale(_h_mll, xsec/sumOfWeights()); |
369 | scale(_h_mth, xsec/sumOfWeights()); |
370 | scale(_h_mh, xsec/sumOfWeights()); |
371 | |
372 | scale(_h_mll_0j, xsec/sumOfWeights()); |
373 | scale(_h_mth_0j, xsec/sumOfWeights()); |
374 | scale(_h_mh_0j, xsec/sumOfWeights()); |
375 | |
376 | scale(_h_mll_1j, xsec/sumOfWeights()); |
377 | scale(_h_mth_1j, xsec/sumOfWeights()); |
378 | scale(_h_mh_1j, xsec/sumOfWeights()); |
379 | |
380 | scale(_h_mll_2j, xsec/sumOfWeights()); |
381 | scale(_h_mth_2j, xsec/sumOfWeights()); |
382 | scale(_h_mh_2j, xsec/sumOfWeights()); |
383 | |
384 | scale(_h_mwm, xsec/sumOfWeights()); |
385 | scale(_h_mwp, xsec/sumOfWeights()); |
386 | |
387 | scale(_h_mwm_0j, xsec/sumOfWeights()); |
388 | scale(_h_mwm_1j, xsec/sumOfWeights()); |
389 | scale(_h_mwm_2j, xsec/sumOfWeights()); |
390 | scale(_h_mwp_0j, xsec/sumOfWeights()); |
391 | scale(_h_mwp_1j, xsec/sumOfWeights()); |
392 | scale(_h_mwp_2j, xsec/sumOfWeights()); |
393 | |
394 | |
395 | //new |
396 | scale(_h_pth, xsec/sumOfWeights()); |
397 | scale(_h_etah, xsec/sumOfWeights()); |
398 | |
399 | scale(_h_pt_1l, xsec/sumOfWeights()); |
400 | scale(_h_pt_2l, xsec/sumOfWeights()); |
401 | scale(_h_pt_ll, xsec/sumOfWeights()); |
402 | scale(_h_eta_1l, xsec/sumOfWeights()); |
403 | scale(_h_eta_2l, xsec/sumOfWeights()); |
404 | scale(_h_deta_l, xsec/sumOfWeights()); |
405 | scale(_h_dphi_l, xsec/sumOfWeights()); |
406 | |
407 | scale(_h_mjj, xsec/sumOfWeights()); |
408 | scale(_h_pt_1j,xsec/sumOfWeights()); |
409 | scale(_h_pt_2j, xsec/sumOfWeights()); |
410 | scale(_h_eta_1j, xsec/sumOfWeights()); |
411 | scale(_h_eta_2j, xsec/sumOfWeights()); |
412 | scale(_h_deta_j, xsec/sumOfWeights()); |
413 | scale(_h_weight, xsec/sumOfWeights()); |
414 | |
415 | |
416 | std::cout<< "num selected event with two W and so H= "<<numev<< std::endl; |
417 | std::cout<< "num W-="<<numwm<<" num W+= "<<numwp<< std::endl; |
418 | |
419 | } |
420 | |
421 | private: |
422 | |
423 | // Data members like post-cuts event weight counters go here |
424 | |
425 | |
426 | private: |
427 | |
428 | //Higgs |
429 | Histo1DPtr _h_mh; |
430 | Histo1DPtr _h_mh_0j; |
431 | Histo1DPtr _h_mh_1j; |
432 | Histo1DPtr _h_mh_2j; |
433 | Histo1DPtr _h_mth; |
434 | Histo1DPtr _h_mth_0j; |
435 | Histo1DPtr _h_mth_1j; |
436 | Histo1DPtr _h_mth_2j; |
437 | Histo1DPtr _h_pth; |
438 | Histo1DPtr _h_etah; |
439 | |
440 | //leptons |
441 | Histo1DPtr _h_mll; |
442 | Histo1DPtr _h_mll_0j; |
443 | Histo1DPtr _h_mll_1j; |
444 | Histo1DPtr _h_mll_2j; |
445 | Histo1DPtr _h_pt_1l; |
446 | Histo1DPtr _h_pt_2l; |
447 | Histo1DPtr _h_pt_ll; |
448 | Histo1DPtr _h_eta_1l; |
449 | Histo1DPtr _h_eta_2l; |
450 | Histo1DPtr _h_deta_l; |
451 | Histo1DPtr _h_dphi_l; |
452 | |
453 | //W+- mass |
454 | Histo1DPtr _h_mwm; |
455 | Histo1DPtr _h_mwp; |
456 | Histo1DPtr _h_mwm_0j; |
457 | Histo1DPtr _h_mwm_1j; |
458 | Histo1DPtr _h_mwm_2j; |
459 | Histo1DPtr _h_mwp_0j; |
460 | Histo1DPtr _h_mwp_1j; |
461 | Histo1DPtr _h_mwp_2j; |
462 | |
463 | //Jets |
464 | Histo1DPtr _h_mjj; |
465 | Histo1DPtr _h_pt_1j; |
466 | Histo1DPtr _h_pt_2j; |
467 | Histo1DPtr _h_eta_1j; |
468 | Histo1DPtr _h_eta_2j; |
469 | Histo1DPtr _h_deta_j; |
470 | Histo1DPtr _h_njet; |
471 | Histo1DPtr _h_njet_onPeak; |
472 | Histo1DPtr _h_njet_offPeak; |
473 | |
474 | Histo1DPtr _h_weight; |
475 | |
476 | ofstream myfile; |
477 | double ce; |
478 | double cmu; |
479 | int numev; |
480 | int numlep; |
481 | int numneu; |
482 | int numwp; |
483 | int numwm; |
484 | |
485 | }; |
486 | // The hook for the plugin system |
487 | DECLARE_RIVET_PLUGIN(WWGen_cut_dl); |
488 | |
489 | } |
490 | |
491 |