~maddevelopers/mg5amcnlo/new_clustering

« back to all changes in this revision

Viewing changes to Template/NLO/FixedOrderAnalysis/analysis_td_hw_orders.f

  • Committer: Rikkert Frederix
  • Date: 2021-09-09 15:51:40 UTC
  • mfrom: (78.75.502 3.2.1)
  • Revision ID: frederix@physik.uzh.ch-20210909155140-rg6umfq68h6h47cf
merge with 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
c
 
2
c This file contains the default histograms for fixed order runs: it
 
3
c only plots the total rate as an example. It can be used as a template
 
4
c to make distributions for other observables.
 
5
c
 
6
c This uses the hbook package and generates histograms in the top-drawer
 
7
c format. This format is human-readable. After running, the histograms
 
8
c can be found in the Events/run_XX/ directory.
 
9
c
 
10
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
11
      subroutine analysis_begin(nwgt,weights_info)
 
12
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
13
c This subroutine is called once at the start of each run. Here the
 
14
c histograms should be declared. 
 
15
c
 
16
c Declare the histograms using 'bookup'.
 
17
c     o) The first argument is an integer that labels the histogram. In
 
18
c     the analysis_end and analysis_fill subroutines this label is used
 
19
c     to keep track of the histogram. The label should be a number
 
20
c     between 1 and NPLOTS/4=5000 (can be increased in dbook.inc).
 
21
c     o) The second argument is a string that will apear above the
 
22
c     histogram. Do not use brackets "(" or ")" inside this string.
 
23
c     o) The third, forth and fifth arguments are the bin size, the
 
24
c     lower edge of the first bin and the upper edge of the last
 
25
c     bin. There is a maximum of 100 bins per histogram.
 
26
c     o) When including scale and/or PDF uncertainties, declare a
 
27
c     histogram for each weight, and compute the uncertainties from the
 
28
c     final set of histograms
 
29
c
 
30
      implicit none
 
31
c When including scale and/or PDF uncertainties the total number of
 
32
c weights considered is nwgt
 
33
      integer nwgt
 
34
c In the weights_info, there is an text string that explains what each
 
35
c weight will mean. The size of this array of strings is equal to nwgt.
 
36
      character*(*) weights_info(*)
 
37
c Local variables
 
38
      integer kk,l,nwgt_analysis
 
39
      common/c_analysis/nwgt_analysis
 
40
c Initialize the histogramming package (hbook):
 
41
      call inihist
 
42
c Fill the c_analysis common block with the number of weights that will
 
43
c be computed
 
44
      nwgt_analysis=nwgt
 
45
c
 
46
c loop over all the weights that are computed (depends on run_card
 
47
c parameters do_rwgt_scale and do_rwgt_pdf):
 
48
      do kk=1,nwgt_analysis
 
49
c make sure that there is a separate histogram initialized for each
 
50
c weight
 
51
         l=(kk-1)*4
 
52
c declare (i.e. book) the histograms
 
53
         call bookup(l+1,'total rate      '//weights_info(kk),
 
54
     &        1.0d0,0.5d0,5.5d0)
 
55
         call bookup(l+2,'total rate Born '//weights_info(kk),
 
56
     &        1.0d0,0.5d0,5.5d0)
 
57
         call bookup(l+3,'total rate QCD'//weights_info(kk),
 
58
     &        1.0d0,0.5d0,5.5d0)
 
59
         call bookup(l+4,'total rate EW '//weights_info(kk),
 
60
     &        1.0d0,0.5d0,5.5d0)
 
61
      enddo
 
62
      return
 
63
      end
 
64
 
 
65
 
 
66
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
67
      subroutine analysis_end(xnorm)
 
68
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
69
c This subroutine is called once at the end of the run. Here the
 
70
c histograms are written to disk. Note that this is done for each
 
71
c integration channel separately. There is an external script that will
 
72
c read the top drawer files in each of the integration channels and
 
73
c combines them by summing all the bins in a final single top-drawer
 
74
c file to be put in the Events/run_XX directory.
 
75
c      
 
76
c The histograms are put in a format to be written to file. Use the
 
77
c multitop() subroutine.
 
78
c     o) The first argument is the histogram label
 
79
c     o) The second and third arguments are not used (keep them to the
 
80
c     default 3,2)
 
81
c     o) Fourth argument is the label for the x-axis. Do not use
 
82
c     brackets "(" or ")" inside this string.
 
83
c     o) Fifth argument is the y-axis
 
84
c     o) Final argument declares if the y-axis should be a linear 'LIN'
 
85
c     or logarithmic 'LOG' scale.
 
86
      implicit none
 
87
      character*14 ytit
 
88
      double precision xnorm
 
89
      integer i
 
90
c Local variables
 
91
      integer kk,l,nwgt_analysis
 
92
      common/c_analysis/nwgt_analysis
 
93
c This defines NPLOTS:
 
94
      include 'dbook.inc'
 
95
c Open the topdrawer file to write the histograms (do not remove the
 
96
c next to calls)
 
97
      call open_topdrawer_file
 
98
      call mclear
 
99
c Do not touch the folloing 4 lines. These lines make sure that the
 
100
c histograms will have the correct overall normalisation: cross section
 
101
c (in pb) per bin.
 
102
      do i=1,NPLOTS
 
103
         call mopera(i,'+',i,i,xnorm,0.d0)
 
104
         call mfinal(i)
 
105
      enddo
 
106
      ytit='sigma per bin '
 
107
c Loop over the plots that are declared with bookup
 
108
      do kk=1,nwgt_analysis
 
109
         l=(kk-1)*4
 
110
         do i=1,8
 
111
c convert them to a format suitable for writing
 
112
            call multitop(l+i,3,2,'total rate',ytit,'LIN')
 
113
         enddo
 
114
      enddo
 
115
c Close the topdrawer file (Do not remove this call)
 
116
      call close_topdrawer_file
 
117
      return
 
118
      end
 
119
 
 
120
 
 
121
 
 
122
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
123
      subroutine analysis_fill(p,istatus,ipdg,wgts,ibody)
 
124
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
125
c This subroutine is called for each n-body and (n+1)-body configuration
 
126
c that passes the generation cuts. Here the histrograms are filled.
 
127
      implicit none
 
128
c This includes the 'nexternal' parameter that labels the number of
 
129
c particles in the (n+1)-body process
 
130
      include 'nexternal.inc'
 
131
c This is an array which is '-1' for initial state and '1' for final
 
132
c state particles
 
133
      integer istatus(nexternal)
 
134
c This is an array with (simplified) PDG codes for the particles. Note
 
135
c that channels that are combined (i.e. they have the same matrix
 
136
c elements) are given only 1 set of PDG codes. This means, e.g., that
 
137
c when using a 5-flavour scheme calculation (massless b quark), no
 
138
c b-tagging can be applied.
 
139
      integer iPDG(nexternal)
 
140
c The array of the momenta and masses of the initial and final state
 
141
c particles in the lab frame. The format is "E, px, py, pz, mass", while
 
142
c the second dimension loops over the particles in the process. Note
 
143
c that these are the (n+1)-body particles; for the n-body there is one
 
144
c momenta equal to all zero's (this is not necessarily the last particle
 
145
c in the list). If one uses IR-safe obserables only, there should be no
 
146
c difficulty in using this.
 
147
      double precision p(0:4,nexternal)
 
148
c The weight of the current phase-space point is wgts(1). If scale
 
149
c and/or PDF uncertainties are included through reweighting, the rest of
 
150
c the array contains the list of weights in the same order as described
 
151
c by the weigths_info strings in analysis_begin
 
152
      double precision wgts(*)
 
153
c The ibody variable is:
 
154
c     ibody=1 : (n+1)-body contribution
 
155
c     ibody=2 : n-body contribution (excluding the Born)
 
156
c     ibody=3 : Born contribution
 
157
c The histograms need to be filled for all these contribution to get the
 
158
c physics NLO results. (Note that the adaptive phase-space integration
 
159
c is optimized using the sum of the contributions, therefore plotting
 
160
c them separately might lead to larger than expected statistical
 
161
c fluctuations).
 
162
      integer ibody
 
163
c local variables
 
164
      double precision wgt,var
 
165
      integer kk,l,nwgt_analysis
 
166
      common/c_analysis/nwgt_analysis
 
167
      ! stuff for plotting the different splitorders
 
168
      integer orders_tag_plot
 
169
      common /corderstagplot/ orders_tag_plot
 
170
c
 
171
c Fill the histograms here using a call to the mfill() subroutine. The
 
172
c first argument is the histogram label, the second is the numerical
 
173
c value of the variable to plot for the current phase-space point and
 
174
c the final argument is the weight of the current phase-space point.
 
175
      var=1d0
 
176
c loop over all the weights that are computed (depends on run_card
 
177
c parameters do_rwgt_scale and do_rwgt_pdf):
 
178
      do kk=1,nwgt_analysis
 
179
         wgt=wgts(kk)
 
180
         l=(kk-1)*4
 
181
c always fill the total rate
 
182
         call mfill(l+1,var,wgt)
 
183
c only fill the total rate for the Born when ibody=3
 
184
         if (ibody.eq.3) call mfill(l+2,var,wgt)
 
185
C fill the different partonic subchannels         
 
186
         if (orders_tag_plot.eq.402) call mfill(l+3,var,wgt)
 
187
         if (orders_tag_plot.eq.600) call mfill(l+4,var,wgt)
 
188
      enddo
 
189
      return
 
190
      end