COSMOS v7.655  COSMOSv7655
(AirShowerMC)
add2hist.f
Go to the documentation of this file.
1  implicit none
2 ! Suppose we have n histograms
3 ! h1, h2, h3, ....hn
4 ! 1) cp h1 h0
5 ! 2) h0 + h2 --> h; mv h h0
6 ! 3) h0 + h3 --> h; mv h h0
7 ! ..
8 ! n) h0 + hn --> h; mv h h0
9 !
10 ! This program add two histogram; h0 + hx--> h
11 ! environmental variable
12 ! file h0: HISTFILE0
13 ! file hx: HISTFILEX
14 ! file h: HISTFILET
15 !
16  include "../../Hist/Z90histc.h"
17  include "../../Hist/Z90histo.h"
18  include "../../Hist/Z90hist1.h"
19  include "../../Hist/Z90hist2.h"
20  include "../../Hist/Z90hist3.h"
21  type(histogram1) h10, h1x, h1t
22  type(histogram2) h20, h2x, h2t
23  type(histogram3) h30, h3x, h3t
24 
25 
26  integer fn0, fnx, fnt
27  integer kgetenv2
28 
29  integer leng, i
30  integer icon0, iconx, icont
31  character*128 hist0, histx, histt
32  character*6 histid0, histidx, oldhist
33 
34  fn0 = 2
35  fnx = 3
36  fnt = 4
37  leng = kgetenv2("HISTFILE0", hist0)
38  call copenfw2(fn0, hist0, 2, icon0)
39  if(icon0 .ne. 1) then
40  write(0,*) hist0(1:leng)
41  if( icon0 .eq. 0) then
42  write(0,*) 'not exists'
43  else
44  write(0,*) ' cannot be opened '
45  endif
46  write(0,*) ' icon=',icon0
47  stop 9999
48  else
49  write(0,*) hist0(1:leng), ' opened'
50  endif
51  leng = kgetenv2("HISTFILEX", histx)
52  call copenfw2(fnx, histx, 2, iconx)
53  if(iconx .ne. 1) then
54  write(0,*) histx(1:leng)
55  if( iconx .eq. 0) then
56  write(0,*) 'not exists'
57  else
58  write(0,*) ' cannot be opened '
59  endif
60  write(0,*) ' icon=',iconx
61  stop 9999
62  else
63  write(0,*) histx(1:leng), ' opened'
64  endif
65 
66  leng = kgetenv2("HISTFILET", histt)
67  call copenfw2(fnt, histt, 2, icont)
68  if(icont .ne. 0) then
69  write(0,*) histt(1:leng)
70  write(0,*) ' cannot be opened '
71  write(0,*) ' icon=',icont
72  stop 9999
73  else
74  write(0,*) histt(1:leng), ' opened'
75  endif
76 
77  leng = kgetenv2("OLDHIST", oldhist)
78  if(oldhist .eq. "yes") then
79  write(0,*) ' old histogram format is assumed'
80  call kwhistfmt(.true.) ! old format
81  else
82  write(0,*) ' new histogram format is assumed'
83  endif
84  do while(.true.)
85  read( fn0, end=1000 ) histid0
86  read( fnx ) histidx
87  if(histid0 .ne. histidx) then
88  write(0,*) histid0, histidx, ' differ'
89  stop 9876
90  endif
91  if( histid0 .eq. '#hist1' ) then
92  call kwhistr(h10, fn0, icon0)
93  call kwhistr(h1x, fnx, iconx)
94  call kwhista(h10, h1x, h1t)
95 
96  call kwhistw(h1t, fnt)
97  call kwhistd(h10)
98  call kwhistd(h1x)
99  call kwhistd(h1t)
100  elseif(histid0 .eq. '#hist2' ) then
101  call kwhistr2(h20, fn0, icon0)
102  call kwhistr2(h2x, fnx, iconx)
103  call kwhista2(h20, h2x, h2t)
104  call kwhistw2(h2t, fnt)
105  call kwhistd2(h20)
106  call kwhistd2(h2x)
107  call kwhistd2(h2t)
108  elseif(histid0 .eq. '#hist3' ) then
109  call kwhistr3(h30, fn0, icon0)
110  call kwhistr3(h3x, fnx, iconx)
111  call kwhista3(h30, h3x, h3t)
112  call kwhistw3(h3t, fnt)
113  call kwhistd3(h30)
114  call kwhistd3(h3x)
115  call kwhistd3(h3t)
116  else
117  write(0,*) 'histid=', histid0, ' invalid'
118  stop 9000
119  endif
120  enddo
121  1000 continue
122  write(0,*) 'all data processed '
123  end
124 
125 
126 
integer function kgetenv2(envname, envresult)
Definition: cgetLoginN.f:77
void kwhistd(struct histogram1 *h)
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
integer leng
Definition: interface2.h:1
subroutine copenfw2(io, fnin, form, icon)
Definition: copenf.f:205
void kwhista(struct histogram1 *h1, struct histogram1 *h2, struct histogram1 *h)
void kwhistr(struct histogram1 *h, FILE *bfnor, int icon)
void kwhistw(struct histogram1 *h, FILE *bfnow)