-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwhg_analysis.f
1074 lines (894 loc) · 28.7 KB
/
pwhg_analysis.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c The next subroutines, open some histograms and prepare them
c to receive data
c You can substitute these with your favourite ones
c init : opens the histograms
c topout : closes them
c pwhgfill : fills the histograms with data
subroutine init_hist
implicit none
include 'LesHouches.h'
include '../pwhg_book.h'
include 'pwhg_math.h'
integer numplots
real * 8 binsize(100)
common/pwhghistcommon/binsize,numplots
real *8 cut_etabj,cut_ptbj,cut_etal,cut_ptl,
$ cut_etasj,cut_ptsj,cut_ptv
common/ccuts/cut_etabj,cut_ptbj,cut_etal,cut_ptl,
$ cut_etasj,cut_ptsj,cut_ptv
real *8 jet_ktRadius,jet_ktptmin
common/cjetsparam/jet_ktRadius,jet_ktptmin
integer diag
character * 10 cut
integer icut
c jet parameters
jet_ktRadius = 0.7d0
jet_ktptmin = 0d0
jet_ktRadius = 1d0
jet_ktptmin = 10d0
write(*,*) '**************************************************'
write(*,*) '**************************************************'
write(*,*) ' JET PARAMETERS '
write(*,*) '**************************************************'
write(*,*) '**************************************************'
write(*,*) ' inclusive kt (fastkt implementation): '
write(*,*) ' jet radius ', jet_ktRadius
write(*,*) ' jet ptmin ', jet_ktptmin
write(*,*) '**************************************************'
write(*,*) '**************************************************'
c cut_1 set (as in 0702198, and no cuts on the
c spectator jet, i.e. as in the old code for s-channel)
cut_etabj = 2d0 !2.5d0
cut_ptbj = 20d0 !50d0
cut_etal = 2.5d0 !2.5d0
cut_ptl = 10d0 !20d0
cut_ptv = 20d0 !20d0
c$$$ cut_etasj= 2.5d0
c$$$ cut_ptsj = 20d0
c$$$ cut_etasj= 2.5d0
c$$$ cut_ptsj = 50d0
write(*,*) '**************************************************'
write(*,*) '**************************************************'
write(*,*) ' ANALYSIS CUTS '
write(*,*) '**************************************************'
write(*,*) '**************************************************'
write(*,*) ' CUTS: '
write(*,*) ' eta b ', cut_etabj
write(*,*) ' pt b ', cut_ptbj
write(*,*) ' eta l ', cut_etal
write(*,*) ' pt l ', cut_ptl
write(*,*) ' pt vl ', cut_ptv
c$$$ write(*,*) ' eta spect-jet ', cut_etasj
c$$$ write(*,*) ' pt spect-jet ', cut_ptsj
write(*,*) '**************************************************'
write(*,*) '**************************************************'
call pwhginihist
icut=-1
diag=0
111 continue
icut=icut+1
if (icut.eq.0) then
cut = ' nocut'
elseif (icut.eq.1) then
numplots=diag
cut = ' cut_1'
elseif (icut.eq.2) then
goto 222
else
write(*,*) 'Error in init_hist, icut ',icut
call exit(1)
endif
c top
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'t pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 1.2d0
call pwhgbookup(diag,'t pt zoom'//cut,'LOG',binsize(diag),
$ 0d0,60d0)
diag=diag+1
binsize(diag) = 20d0
call pwhgbookup(diag,'t pt tail'//cut,'LOG',binsize(diag),
$ 0d0,1000d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'t y'//cut,'LOG',binsize(diag),-6d0,6d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'t eta'//cut,'LOG',binsize(diag),-6d0,6d0)
diag=diag+1
binsize(diag) = 0.8d0
call pwhgbookup(diag,'t minv'//cut,'LOG',binsize(diag),
$ 175d0-20d0,175d0+20d0)
c W
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'W pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 1.2d0
call pwhgbookup(diag,'W pt zoom'//cut,'LOG',binsize(diag),
$ 0d0,60d0)
diag=diag+1
binsize(diag) = 20d0
call pwhgbookup(diag,'W pt tail'//cut,'LOG',binsize(diag),
$ 0d0,1000d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'W y'//cut,'LOG',binsize(diag),-6d0,6d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'W eta'//cut,'LOG',binsize(diag),-6d0,6d0)
diag=diag+1
binsize(diag) = 0.8d0
call pwhgbookup(diag,'W minv'//cut,'LOG',binsize(diag),
$ 80d0-20d0,80d0+20d0)
c hardest b
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'b pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 1.2d0
call pwhgbookup(diag,'b pt zoom'//cut,'LOG',binsize(diag),
$ 0d0,60d0)
diag=diag+1
binsize(diag) = 20d0
call pwhgbookup(diag,'b pt tail'//cut,'LOG',binsize(diag),
$ 0d0,1000d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'b y'//cut,'LOG',binsize(diag),-6d0,6d0)
c hardest bbar
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'bbar pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 1.2d0
call pwhgbookup(diag,'bbar pt zoom'//cut,'LOG',binsize(diag),
$ 0d0,60d0)
diag=diag+1
binsize(diag) = 20d0
call pwhgbookup(diag,'bbar pt tail'//cut,'LOG',binsize(diag),
$ 0d0,1000d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'bbar y'//cut,'LOG',binsize(diag),-6d0,6d0)
c J1
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'j1 pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'j1 eta'//cut,'LOG',binsize(diag),-6d0,6d0)
c J2
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'j2 pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'j2 eta'//cut,'LOG',binsize(diag),-6d0,6d0)
c pt(t,j1)
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'tj1 pt'//cut,'LOG',binsize(diag),0d0,200d0)
c dphi t-j1
diag=diag+1
binsize(diag) = pi/50d0
call pwhgbookup(diag,'phitj1'//cut,'LIN',binsize(diag),0d0,pi)
c hardest charged lepton
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'lep pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'lep eta'//cut,'LOG',binsize(diag),-6d0,6d0)
c hardest neutrino
diag=diag+1
binsize(diag) = 4d0
call pwhgbookup(diag,'v pt'//cut,'LOG',binsize(diag),0d0,200d0)
diag=diag+1
binsize(diag) = 0.24d0
call pwhgbookup(diag,'v eta'//cut,'LOG',binsize(diag),-6d0,6d0)
c s-channel spin correlation
c cth between charged lepton and right beam axis (-z direction)
diag=diag+1
binsize(diag) = 0.04d0
call pwhgbookup(diag,'cth l-rb'//cut,'LIN',binsize(diag),-1d0,1d0)
c total cross section sanity check
diag=diag+1
binsize(diag) = 1d0
call pwhgbookup(diag,'total'//cut,'LOG',binsize(diag),0d0,3d0)
goto 111
222 end
subroutine analysis(dsig)
implicit none
real * 8 dsig
include 'hepevt.h'
include 'pwhg_math.h'
include 'LesHouches.h'
c other common blocks
integer numplots
real * 8 binsize(100)
common/pwhghistcommon/binsize,numplots
real *8 cut_etabj,cut_ptbj,cut_etal,cut_ptl,
$ cut_etasj,cut_ptsj,cut_ptv
common/ccuts/cut_etabj,cut_ptbj,cut_etal,cut_ptl,
$ cut_etasj,cut_ptsj,cut_ptv
real *8 jet_ktRadius,jet_ktptmin
common/cjetsparam/jet_ktRadius,jet_ktptmin
integer i,ihep,mu,ist_top,ist_w,ist,id,diag,j,jjet
logical cuts,ini,condition_b,condition_bbar,condition,skipjet
data ini/.true./
save ini
integer maxnum
parameter (maxnum=10)
real *8 p_top(0:3,maxnum),p_w(0:3,maxnum),
$ p_l(0:3,maxnum),p_v(0:3,maxnum),
$ p_b(0:3,maxnum),p_bbar(0:3,maxnum)
integer nt,nw,nl,nv,nb,nbbar,nbjets,njets
integer jb,jl,jv,bflavjet,specjet,ij1,ij2
real *8 pj1(0:3),pj2(0:3),pspecj(0:3),pbj(0:3)
real *8 pt_t,y_t,eta_t,minv_t,pt_w,y_w,eta_w,minv_w,pt_tj1
real *8 pttemp,pt_b,y_b,pt_bbar,y_bbar,pt_j1,eta_j1,pt_j2,eta_j2
real *8 tmp,dphi_tj1,pt_l,eta_l,pt_v,eta_v,cth,beta(3)
real *8 eta_bjet,pt_bjet,pt_sj,eta_sj,pttemp_bjet,pttemp_spec
real *8 prbeam(0:3),ptemp(0:3),ptemp2(0:3)
integer maxtrack,maxjet
parameter (maxtrack=2048, maxjet=2048)
real *8 pjet(4,maxtrack),ptrack(4,maxtrack)
integer jpart,ntracks,jetvec(maxtrack),ihep_of_track(maxtrack),
$ jetvec_of_bjet(maxtrack)
c we need to tell to this analysis file which program is running it
character * 6 WHCPRG
common/cWHCPRG/WHCPRG
data WHCPRG/'NLO '/
real *8 azi
if (ini) then
write(*,*) '*****************************'
if(whcprg.eq.'NLO'.or.whcprg.eq.'LHE') then
write(*,*) ' NLO analysis not implemented '
write(*,*) 'No analysis will be run'
elseif(WHCPRG.eq.'HERWIG') then
write (*,*) ' HERWIG ANALYSIS '
elseif(WHCPRG.eq.'PYTHIA') then
write (*,*) ' PYTHIA ANALYSIS '
endif
write(*,*) '*****************************'
ini=.false.
endif
if (whcprg.eq.'NLO'.or.whcprg.eq.'LHE') then
return
elseif (WHCPRG.eq.'HERWIG'.or.WHCPRG.eq.'PYTHIA') then
if(WHCPRG.eq.'HERWIG') then
ist_top=155
ist_w =195 !: for undecayed events
ist_w =155 !: for decayed events
elseif(WHCPRG.eq.'PYTHIA') then
ist_top=3
ist_w =3
endif
nt=0
nw=0
nl=0
nv=0
nb=0
nbbar=0
do ihep=1,nhep
ist=isthep(ihep)
id=idhep(ihep)
condition_b=.false.
condition_bbar=.false.
condition_b=(ist.eq.1).and.
$ (((id.gt.-600).and.(id.lt.-500)).or.
$ ((id.gt.5000).and.(id.lt.6000)))
condition_bbar=(ist.eq.1).and.
$ (((id.gt.500).and.(id.lt.600)).or.
$ ((id.gt.-6000).and.(id.lt.-5000)))
if(condition_b.and.condition_bbar) then
write(*,*) 'both b and bbar true at the same time'
call exit(1)
endif
c top
if(ist.eq.ist_top.and.abs(id).eq.6) then
c !: no ttype used
nt=nt+1
p_top(0,nt)=phep(4,ihep)
do mu=1,3
p_top(mu,nt)=phep(mu,ihep)
enddo
c W
elseif(ist.eq.ist_w.and.abs(id).eq.24) then
c !: no ttype used
nw=nw+1
p_w(0,nw)=phep(4,ihep)
do mu=1,3
p_w(mu,nw)=phep(mu,ihep)
enddo
c electron
elseif(ist.eq.1.and.abs(id).eq.11) then
c !: no ttype, or decaytype, used
nl=nl+1
p_l(0,nl)=phep(4,ihep)
do mu=1,3
p_l(mu,nl)=phep(mu,ihep)
enddo
c electron neutrino
elseif(ist.eq.1.and.abs(id).eq.12) then
c !: no ttype, or decaytype, used
nv=nv+1
p_v(0,nv)=phep(4,ihep)
do mu=1,3
p_v(mu,nv)=phep(mu,ihep)
enddo
c b hadrons
elseif(condition_b) then
nb=nb+1
p_b(0,nb)=phep(4,ihep)
do mu=1,3
p_b(mu,nb)=phep(mu,ihep)
enddo
c bbar hadrons
elseif(condition_bbar) then
nbbar=nbbar+1
p_bbar(0,nbbar)=phep(4,ihep)
do mu=1,3
p_bbar(mu,nbbar)=phep(mu,ihep)
enddo
endif
enddo
c set up arrays for jet finding
ntracks=0
njets=0
do jpart=1,maxtrack
do mu=1,4
ptrack(mu,jpart)=0d0
enddo
jetvec(jpart)=0
enddo
do jjet=1,maxjet
do mu=1,4
pjet(mu,jjet)=0d0
enddo
enddo
c loop over final state particles, to find particles that
c can be clustered
do ihep=1,nhep
c exclude leptons, gauge and Higgs bosons, but include gluons
if ((isthep(ihep).eq.1).and.(
$ (abs(idhep(ihep)).le.10).or.
$ (abs(idhep(ihep)).ge.40).or.
$ (abs(idhep(ihep)).eq.21))) then
c copy momenta to construct jets
ntracks=ntracks+1
ihep_of_track(ntracks)=ihep
do mu=1,4
ptrack(mu,ntracks)=phep(mu,ihep)
enddo
if(ntracks.eq.maxtrack) then
write(*,*)
$ 'hwanal: too many particles, increase maxtrack'
call exit(1)
endif
endif
enddo
if (ntracks.eq.0) then
write(*,*) 'No tracks found, drop analysis of this event'
goto 999
endif
else
write(*,*) 'Invalid WHCPRG'
call exit(1)
endif
**********************************************************************
* kt algorithm, fastjet implementation
njets=0
call fastjetktwhich(ptrack,ntracks,jet_ktptmin,jet_ktRadius,
$ pjet,njets,jetvec)
**********************************************************************
skipjet=.false.
c tag b-flavoured jets
nbjets=0
do i=1,ntracks
ihep=ihep_of_track(i)
condition_b=(
$ ((abs(idhep(ihep)).gt.500).and.(abs(idhep(ihep)).lt.600)).or.
$ ((abs(idhep(ihep)).gt.5000).and.(abs(idhep(ihep)).lt.6000)))
if(condition_b) then
nbjets=nbjets+1
jetvec_of_bjet(nbjets)=jetvec(i)
endif
enddo
c find the hardest non-b-flavoured jet (spectator jet)
c and the hardest b-flavoured jet
pttemp_spec=-1d0
pttemp_bjet=-1d0
specjet=-1
bflavjet=-1
do jjet=1,njets
c loop on all jets
condition=.true.
do j=1,nbjets
c loop on all b-jets: condition becomes false if current
c jet (jjet) corresponds to one of the b-jets.
condition=condition.and.(jjet.ne.jetvec_of_bjet(j))
enddo
if(condition) then
c non-b-jet
if((pjet(1,jjet)**2+pjet(2,jjet)**2).gt.pttemp_spec) then
pttemp_spec=(pjet(1,jjet)**2+pjet(2,jjet)**2)
specjet=jjet
endif
else
c b-jet
if((pjet(1,jjet)**2+pjet(2,jjet)**2).gt.pttemp_bjet) then
pttemp_bjet=(pjet(1,jjet)**2+pjet(2,jjet)**2)
bflavjet=jjet
endif
endif
enddo
c find the 2 hardest jets
c We want to exclude the jet arising from the top decay.
c In this analysis, we assume that this jet is the hardest
c b-flavoured one, i.e. the one tagged above as bflavjet.
c Notice that this is different from what we did in the
c POWHEG-st code, where an explicit tjet search was present.
if(njets.ge.1) then
c Sort jets according to decreasing pt
c Find the hardest jet
pttemp=-1d0
ij1=0
tmp=0d0
do jjet=1,njets
if(jjet.ne.bflavjet) then
tmp=sqrt(pjet(1,jjet)**2+pjet(2,jjet)**2)
if(tmp.gt.pttemp) then
ij1=jjet
pttemp=tmp
endif
endif
enddo
c Now ij1 is the hardest jet
if(ij1.ne.0) then
pj1(0)=pjet(4,ij1)
do mu=1,3
pj1(mu)=pjet(mu,ij1)
enddo
endif
if(njets.ge.2) then
c Find the next-to-hardest jet
pttemp=-1d0
ij2=0
tmp=0d0
do jjet=1,njets
if(jjet.ne.bflavjet) then
tmp=sqrt(pjet(1,jjet)**2+pjet(2,jjet)**2)
if((tmp.gt.pttemp).and.(jjet.ne.ij1))then
ij2=jjet
pttemp=tmp
endif
endif
enddo
c Now ij2 is the next-to-hardest jet
if(ij2.ne.0) then
pj2(0)=pjet(4,ij2)
do mu=1,3
pj2(mu)=pjet(mu,ij2)
enddo
endif
if(ij1.eq.ij2) then
write(*,*) 'Suspicious event: ij1=ij2'
skipjet=.true.
endif
endif
else
skipjet=.true.
endif
ccccccccccccccccccccccccccccccc
c Observables
ccccccccccccccccccccccccccccccc
c t
pt_t = sqrt(p_top(1,1)**2+p_top(2,1)**2)
call getrapidity(p_top(0,1),y_t)
call get_pseudorap(p_top(0,1),eta_t)
call getinvmass(p_top(0,1),minv_t)
c w
pt_w = sqrt(p_w(1,1)**2+p_w(2,1)**2)
call getrapidity(p_w(0,1),y_w)
call get_pseudorap(p_w(0,1),eta_w)
call getinvmass(p_w(0,1),minv_w)
c hardest b
if(nb.gt.0) then
pttemp=-1d0
jb=0
do i=1,nb
pt_b = sqrt(p_b(1,i)**2+p_b(2,i)**2)
if(pt_b.gt.pttemp) then
pttemp=pt_b
jb=i
endif
enddo
call getrapidity(p_b(0,jb),y_b)
endif
c hardest bbar
if(nbbar.gt.0) then
pttemp=-1d0
jb=0
do i=1,nbbar
pt_bbar = sqrt(p_bbar(1,i)**2+p_bbar(2,i)**2)
if(pt_bbar.gt.pttemp) then
pttemp=pt_bbar
jb=i
endif
enddo
call getrapidity(p_bbar(0,jb),y_bbar)
endif
if(.not.skipjet) then
c j1
if(ij1.gt.0.and.nt.gt.0) then
pt_j1 = sqrt(pj1(1)**2+pj1(2)**2)
call get_pseudorap(pj1,eta_j1)
dphi_tj1 = dabs(atan2(p_top(2,1),p_top(1,1)) -
$ atan2(pj1(2),pj1(1)))
dphi_tj1=min(dphi_tj1,2d0*pi-dphi_tj1)
dphi_tj1 = abs(azi(p_top(0,1))-azi(pj1))
if (dphi_tj1.gt.pi) then
dphi_tj1 = 2*pi-dphi_tj1
endif
endif
c j2
if(ij2.gt.0) then
pt_j2 = sqrt(pj2(1)**2+pj2(2)**2)
call get_pseudorap(pj2,eta_j2)
endif
endif
c hardest lepton
if(nl.gt.0) then
pttemp=-1d0
jl=0
do i=1,nl
pt_l = sqrt(p_l(1,i)**2+p_l(2,i)**2)
if(pt_l.gt.pttemp) then
pttemp=pt_l
jl=i
endif
enddo
call get_pseudorap(p_l(0,jl),eta_l)
endif
c hardest neutrino
if(nv.gt.0) then
pttemp=-1d0
jv=0
do i=1,nv
pt_v = sqrt(p_v(1,i)**2+p_v(2,i)**2)
if(pt_v.gt.pttemp) then
pttemp=pt_v
jv=i
endif
enddo
call get_pseudorap(p_v(0,jv),eta_v)
endif
c spin-correlation (chi asymmetry)
if(nt.gt.0) then
prbeam(0)=1.
prbeam(1)=0.
prbeam(2)=0.
prbeam(3)=-1.
do mu=1,3
beta(mu)=-p_top(mu,1)/p_top(0,1)
enddo
call boost_pow(beta,prbeam,ptemp)
call boost_pow(beta,p_l(0,1),ptemp2)
cth=(ptemp(1)*ptemp2(1)+ptemp(2)*ptemp2(2)+
#ptemp(3)*ptemp2(3))
cth=cth/sqrt(ptemp(1)**2+ptemp(2)**2+ptemp(3)**2)
cth=cth/sqrt(ptemp2(1)**2+ptemp2(2)**2+ptemp2(3)**2)
endif
cccccccccccccccccccccccccccccccccc
c Histograms filling, no cuts
cccccccccccccccccccccccccccccccccc
diag=0
c-----top
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c y_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,y_t,dsig/binsize(diag))
c eta_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,eta_t,dsig/binsize(diag))
c minv_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,minv_t,dsig/binsize(diag))
c-----w
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c y_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,y_w,dsig/binsize(diag))
c eta_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,eta_w,dsig/binsize(diag))
c minv_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,minv_w,dsig/binsize(diag))
c-----b
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c y_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,y_b,dsig/binsize(diag))
c-----bbar
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c y_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,y_bbar,dsig/binsize(diag))
c-----J1
c pt_j1
diag=diag+1
if(ij1.gt.0.and..not.skipjet)
$ call pwhgfill(diag,pt_j1,dsig/binsize(diag))
c eta_j1
diag=diag+1
if(ij1.gt.0.and..not.skipjet)
$ call pwhgfill(diag,eta_j1,dsig/binsize(diag))
c-----J2
c pt_j2
diag=diag+1
if(ij2.gt.0.and..not.skipjet)
$ call pwhgfill(diag,pt_j2,dsig/binsize(diag))
c eta_j2
diag=diag+1
if(ij2.gt.0.and..not.skipjet)
$ call pwhgfill(diag,eta_j2,dsig/binsize(diag))
c-----pt(t,j1)
diag=diag+1
if(ij1.gt.0.and.nt.gt.0.and..not.skipjet) then
pt_tj1=sqrt((p_top(1,1)+pj1(1))**2+(p_top(2,1)+pj1(2))**2 )
call pwhgfill(diag,pt_tj1,dsig/binsize(diag))
endif
c-----phi(t-j1)
c dphi_tj1
diag=diag+1
if(ij1.gt.0.and.nt.gt.0.and..not.skipjet)
$ call pwhgfill(diag,dphi_tj1,dsig/binsize(diag))
c-----lept
c pt_l
diag=diag+1
if(nl.gt.0) call pwhgfill(diag,pt_l,dsig/binsize(diag))
c eta_l
diag=diag+1
if(nl.gt.0) call pwhgfill(diag,eta_l,dsig/binsize(diag))
c-----neutr
c pt_l
diag=diag+1
if(nv.gt.0) call pwhgfill(diag,pt_v,dsig/binsize(diag))
c eta_l
diag=diag+1
if(nv.gt.0) call pwhgfill(diag,eta_v,dsig/binsize(diag))
c-----spin corr
diag=diag+1
if(nt.gt.0)
$ call pwhgfill(diag,cth,dsig/binsize(diag))
c-----total
diag=diag+1
call pwhgfill(diag,1.5d0,dsig/binsize(diag))
ccccccccccccccccccccccccccccc
c Histogram filling, cuts
ccccccccccccccccccccccccccccc
c Cuts, set 1
cuts=.false.
if(bflavjet.gt.0) then
pbj(0)=pjet(4,bflavjet)
do mu=1,3
pbj(mu)=pjet(mu,bflavjet)
enddo
pt_bjet=sqrt(pbj(1)**2+pbj(2)**2)
call get_pseudorap(pbj,eta_bjet)
cccccccccccccccccccccccccccccccccccc
c$$$ pt_bjet=pt_b
c$$$ eta_bjet=y_b
cccccccccccccccccccccccccccccccccccc
c$$$ pt_sj=sqrt(pspecj(1)**2+pspecj(2)**2)
c$$$ call get_pseudorap(pspecj,eta_sj)
cuts=(
$ (dabs(eta_bjet) .lt.cut_etabj).and.
$ (pt_bjet .gt.cut_ptbj).and.
$ (dabs(eta_l) .lt.cut_etal).and.
$ (pt_l .gt.cut_ptl).and.
$ (pt_v .gt.cut_ptv))
c$$$ $ (dabs(eta_sj).lt.cut_etasj).and.
c$$$ $ (pt_sj .gt.cut_ptsj))
c$$$ $ (dabs(eta_sj).gt.cut_etasj).and.
c$$$ $ (pt_sj .gt.cut_ptsj))
endif
if(cuts) then
c reply same structure as above, without definition of variables
c-----top
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c pt_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,pt_t,dsig/binsize(diag))
c y_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,y_t,dsig/binsize(diag))
c eta_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,eta_t,dsig/binsize(diag))
c minv_top
diag=diag+1
if(nt.gt.0) call pwhgfill(diag,minv_t,dsig/binsize(diag))
c-----w
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c pt_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,pt_w,dsig/binsize(diag))
c y_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,y_w,dsig/binsize(diag))
c eta_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,eta_w,dsig/binsize(diag))
c minv_w
diag=diag+1
if(nw.gt.0) call pwhgfill(diag,minv_w,dsig/binsize(diag))
c-----b
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c pt_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,pt_b,dsig/binsize(diag))
c y_b
diag=diag+1
if(nb.gt.0) call pwhgfill(diag,y_b,dsig/binsize(diag))
c-----bbar
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c pt_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,pt_bbar,dsig/binsize(diag))
c y_bbar
diag=diag+1
if(nbbar.gt.0) call pwhgfill(diag,y_bbar,dsig/binsize(diag))
c-----J1
c pt_j1
diag=diag+1
if(ij1.gt.0.and..not.skipjet)
$ call pwhgfill(diag,pt_j1,dsig/binsize(diag))
c eta_j1
diag=diag+1
if(ij1.gt.0.and..not.skipjet)
$ call pwhgfill(diag,eta_j1,dsig/binsize(diag))
c-----J2
c pt_j2
diag=diag+1
if(ij2.gt.0.and..not.skipjet)
$ call pwhgfill(diag,pt_j2,dsig/binsize(diag))
c eta_j2
diag=diag+1
if(ij2.gt.0.and..not.skipjet)
$ call pwhgfill(diag,eta_j2,dsig/binsize(diag))
c-----pt(t,j1)
diag=diag+1
if(ij1.gt.0.and.nt.gt.0.and..not.skipjet) then
pt_tj1=sqrt((p_top(1,1)+pj1(1))**2+(p_top(2,1)+pj1(2))**2 )
call pwhgfill(diag,pt_tj1,dsig/binsize(diag))
endif
c-----phi(t-j1)
c dphi_tj1
diag=diag+1
if(ij1.gt.0.and.nt.gt.0.and..not.skipjet)
$ call pwhgfill(diag,dphi_tj1,dsig/binsize(diag))
c-----lept
c pt_l
diag=diag+1
if(nl.gt.0) call pwhgfill(diag,pt_l,dsig/binsize(diag))
c eta_l
diag=diag+1
if(nl.gt.0) call pwhgfill(diag,eta_l,dsig/binsize(diag))
c-----neutr
c pt_l