~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to vendor/StdHEP/mcfio/example/tN1.F

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
        program tN1
 
2
c
 
3
c       Example program for mcfio. Simple case for Ntuple
 
4
c
 
5
        implicit none
 
6
#include "mcfio.inc"
 
7
        integer ostr_all, ostr_sel, istr_old
 
8
        character *60 filename
 
9
        character *80 title
 
10
        integer numblocks, blkids(3)
 
11
        integer i, ivalue
 
12
        integer NUMTRIES
 
13
        PARAMETER (NUMTRIES = 50)
 
14
#include "glob22.inc"
 
15
#include "glo23.inc"
 
16
        
 
17
c
 
18
c       Initialization phase.
 
19
c
 
20
        call mcfio_Init
 
21
c       filename = '/home/focus/scr1/pltmp/mcfio_mcfio/testN1_l.dat'
 
22
        filename = 'testN1_l.dat'
 
23
        title = ' First Simple test '
 
24
        numblocks = 3
 
25
        ostr_all = mcfio_OpenWriteDirect(filename, title, %val(0), 
 
26
     &             NUMTRIES, blkids, 0)
 
27
        if (ostr_all .eq. -1) then 
 
28
           print *, ' Can t open output file, give up '
 
29
           stop
 
30
        end if
 
31
        blkids(1) = mcfio_DeclareNtuple(22, 'Global Super_22', 'Top',
 
32
     &                                 ostr_all, 'glob22.db') 
 
33
     
 
34
        blkids(2) = mcfio_DeclareNtuple(23, 'Global Super_23', 'Top',
 
35
     &                                 ostr_all, 'glo23.db') 
 
36
     
 
37
        blkids(3) = mcfio_DeclareNtuple(1, 
 
38
     &                                 'Global Super_Charm', 'Charming',
 
39
     &                                 ostr_all, 'glob22.db')
 
40
        if (mcfio_EndDeclNTuples(ostr_all) .ne. 3) then 
 
41
            print *, 'Problem with stream initialisation '
 
42
            stop
 
43
        end if
 
44
c
 
45
c       Set the version token.  We must do this..
 
46
c
 
47
        glob_c.version = '1.10'
 
48
        version_glo23 = '1.00'        
 
49
        ivalue = 456
 
50
        call mcfio_SetEventInfo(ostr_all, MCFIO_RUNNUMBER, ivalue) 
 
51
        do i = 1, NUMTRIES
 
52
          call fill_glob22(i)
 
53
          if (mcfio_NTuple(ostr_all,blkids(1), glob_c.version)
 
54
     &           .eq. -1) then 
 
55
            print *, 'Problem with Encoding glob22 '
 
56
            stop
 
57
          end if
 
58
          call fill_glo23(i)
 
59
          if (mcfio_NTuple(ostr_all,blkids(2), version_glo23)
 
60
     &           .eq. -1) then 
 
61
            print *, 'Problem with Encoding glo23 '
 
62
            stop
 
63
          end if
 
64
          if (mcfio_NextEvent(ostr_all) .eq. -1) then 
 
65
             print *,'  Error writing next event, Stop '
 
66
             stop
 
67
          end if
 
68
          print *,' Written evt number ',i
 
69
        end do
 
70
        call mcfio_close(ostr_all)
 
71
        stop
 
72
        end 
 
73
        subroutine fill_glob22(ievt)
 
74
        implicit none
 
75
c
 
76
c       Dummy fill for now.. 
 
77
c
 
78
#include "glob22.inc"
 
79
        integer ievt, i,j, k
 
80
        
 
81
        glob_c.eventnumber(1) = mod(ievt,64)
 
82
c       No_way = ievt+99
 
83
        glob_c.Missinget = 578.9 - ievt*1.
 
84
        glob_c.something = 123.5 +ievt*7.
 
85
        glob_c.nglob = mod(ievt, 10)
 
86
        if (ievt .eq. 1) glob_c.nglob = 12
 
87
        if (glob_c.nglob .eq. 0) return
 
88
        do i=1, glob_c.nglob
 
89
           glob_c.glob_var(i).missingEtphi = 'Not too much '
 
90
           if (i .gt. 4)
 
91
     &      glob_c.glob_var(i).missingEtphi = 'Quite a bit'
 
92
           do j = 1,80
 
93
              glob_c.glob_var(i).v6_new(j) = j + mod(ievt,2)
 
94
           end do
 
95
           do j= 1,6
 
96
              do k = 1,5
 
97
                  glob_c.glob_var(i).v5_new(k,j) = 0.0
 
98
              end do
 
99
           end do
 
100
          glob_c.glob_var(i).v7_now2 = ievt*10 + i
 
101
          glob_c.glob_var(i).missingetnomuon = ievt*100. + i*10.
 
102
          glob_c.glob_var(i).v7_now = ievt/10. + i
 
103
          glob_c.glob_var(i).v7_now_last = i*1.d0
 
104
        end do
 
105
        return
 
106
        end 
 
107
        
 
108
        subroutine fill_glo23(ievt)
 
109
        implicit none
 
110
c
 
111
c       Dummy fill for now.. 
 
112
c
 
113
#include "glo23.inc"
 
114
c
 
115
        integer ievt, i,j,k,iseed
 
116
        save iseed
 
117
        data iseed /5683873/
 
118
#if AIX
 
119
        real rand
 
120
#else
 
121
        real ran
 
122
        external ran
 
123
#endif
 
124
        
 
125
#if AIX
 
126
        ngl23 = ifix(ngl23_max*rand()/10.)
 
127
#else
 
128
        ngl23 = ifix(ngl23_max*ran(iseed)/10.)
 
129
#endif
 
130
        eventnumber = ievt
 
131
#if AIX
 
132
        triggerbit1(1) = .false.
 
133
        triggerbit1(2) = .false.
 
134
#else
 
135
        triggerbit1(1) = 0
 
136
        triggerbit1(2) = 0
 
137
#endif
 
138
        runnumber = 456
 
139
        No_way = 0
 
140
        missingEt = 789.
 
141
        something = 0.
 
142
        do i = 1, ngl23
 
143
          do j= 1,5
 
144
           do k = 1,8
 
145
            Amtrack(j,k,i) = 1.0 *(j + k + i)
 
146
           end do
 
147
          end do
 
148
           
 
149
          do j= 1,10
 
150
           do k = 1,10
 
151
            v5_new(j,k,i) = 0.
 
152
           end do
 
153
          end do
 
154
          v7_now2(i) = 0.
 
155
          missingetnomuon(i) = 0.
 
156
        end do
 
157
        return 
 
158
        end 
 
159
        
 
160
           
 
161
               
 
162
         
 
163
            
 
164
          
 
165