SND@LHC Software
Loading...
Searching...
No Matches
mptest1.f90 File Reference

MC for simple 100 plane chamber. More...

Go to the source code of this file.

Modules

module  mptest1
 Parameters and data.
 

Functions/Subroutines

subroutine mptest
 Generate test files.
 
subroutine genlin (ip)
 Generate line and measurements.
 

Variables

integer(mpi), parameter mptest1::nplan =100
 
real(mps), parameter mptest1::detx = 10.0
 x-value of first plane
 
real(mps), parameter mptest1::disx = 10.0
 distance between planes
 
real(mps), parameter mptest1::thck = 2.0
 thickness of plane
 
real(mps), parameter mptest1::heit =100.0
 height of detector plane
 
real(mps), parameter mptest1::effp =0.90
 plane efficiency
 
real(mps), parameter mptest1::sgmp =0.0150
 measurement sigma
 
real(mps), dimension(nplanmptest1::del
 shift (position deviation) (alignment parameter)
 
real(mps), dimension(nplanmptest1::dvd
 rel. drift velocity deviation (calibration parameter)
 
real(mpsmptest1::ynull
 track position at vertex
 
real(mpsmptest1::slope
 track slope
 
integer(mpimptest1::nhits
 number of hits
 
integer(mpi), dimension(nplanmptest1::ihits
 plane numbers (planes with hits)
 
real(mps), dimension(nplanmptest1::eff
 plane efficiency
 
real(mps), dimension(nplanmptest1::sgm
 measurement sigma (plane)
 
real(mps), dimension(nplanmptest1::ydrft
 signed drift length
 
real(mps), dimension(nplanmptest1::xhits
 position perp. to plane (hit)
 
real(mps), dimension(nplanmptest1::yhits
 measured position in plane (hit)
 
real(mps), dimension(nplanmptest1::sigma
 measurement sigma (hit)
 

Detailed Description

MC for simple 100 plane chamber.

Author
Volker Blobel, University Hamburg, 2005-2009 (initial Fortran77 version)
Claus Kleinwort, DESY (maintenance and developement)

No B-field, straight tracks. Selected with command line option '-t'.

Global parameters:

  • Position offsets in measurement direction (alignment).
  • Relative drift velocity corrections (calibration).

Definition in file mptest1.f90.

Function/Subroutine Documentation

◆ genlin()

subroutine genlin ( integer(mpi), intent(in)  ip)

Generate line and measurements.

Parameters
[in]ipprint flag

Definition at line 305 of file mptest1.f90.

306 USE mptest1
307
308 IMPLICIT NONE
309 REAL(mps) :: gr
310 REAL(mps) :: gran
311 REAL(mps) :: uran
312 REAL(mps) :: x
313 REAL(mps) :: ybias
314 REAL(mps) :: ydvds
315 REAL(mps) :: ylin
316 REAL(mps) :: ymeas
317 REAL(mps) :: ywire
318 INTEGER(mpi) :: i
319 INTEGER(mpi) :: nwire
320
321 INTEGER(mpi), INTENT(IN) :: ip
322
323 ! ...
324 ynull=0.5*heit+0.1*heit*(uran()-0.5) ! uniform vertex
325 slope=(uran()-0.5)*heit/(real(nplan-1,mps)*disx)
326 IF(ip /= 0) THEN
327 WRITE(*,*) ' '
328 ! WRITE(*,*) 'YNULL=',YNULL,' SLOPE=',SLOPE
329 END IF
330 nhits=0
331 DO i=1,nplan
332 x=detx+real(i-1,mps)*disx ! +0.5*THCK
333 IF(uran() < eff(i)) THEN
334 ylin =ynull+slope*x ! true y value
335 ybias =ylin-del(i) ! biased value
336 nwire=int(1.0+ybias/4.0,mpi) ! wire number
337 IF(nwire <= 0.OR.nwire > 25) EXIT ! check wire number
338 nhits=nhits+1 ! track hits the plane
339 xhits(nhits)=x
340 ihits(nhits)=i
341 gr=gran()
342 ymeas=sgm(i)*gr
343 ydvds=0.0
344 yhits(nhits)=ybias+ymeas+ydvds ! measured
345 ywire=real(nwire,mps)*4.0-2.0
346 ydrft(nhits)=ybias-ywire ! signed drift length
347 ydvds=ydrft(nhits)*dvd(i)
348 yhits(nhits)=ybias+ymeas-ydvds ! measured
349 sigma(nhits)=sgm(i)
350 IF(ip /= 0) THEN
351 ! WRITE(*,101) NHITS,I,X,YLIN,YBIAS,YMEAS,
352 ! + SGM(I),YHITS(NHITS),GR,DEL(I)
353 END IF
354 END IF
355 END DO
356! 101 FORMAT(2I3,F5.0,7F8.4)
Parameters and data.
Definition mptest1.f90:35
real(mps), dimension(nplan) ydrft
signed drift length
Definition mptest1.f90:62
real(mps) ynull
track position at vertex
Definition mptest1.f90:55
real(mps), dimension(nplan) sgm
measurement sigma (plane)
Definition mptest1.f90:61
real(mps), parameter detx
x-value of first plane
Definition mptest1.f90:44
real(mps) slope
track slope
Definition mptest1.f90:56
real(mps), dimension(nplan) sigma
measurement sigma (hit)
Definition mptest1.f90:65
integer(mpi) nhits
number of hits
Definition mptest1.f90:58
real(mps), parameter heit
height of detector plane
Definition mptest1.f90:47
real(mps), dimension(nplan) dvd
rel. drift velocity deviation (calibration parameter)
Definition mptest1.f90:53
integer(mpi), dimension(nplan) ihits
plane numbers (planes with hits)
Definition mptest1.f90:59
real(mps), dimension(nplan) yhits
measured position in plane (hit)
Definition mptest1.f90:64
real(mps), dimension(nplan) xhits
position perp. to plane (hit)
Definition mptest1.f90:63
real(mps), dimension(nplan) eff
plane efficiency
Definition mptest1.f90:60
real(mps), dimension(nplan) del
shift (position deviation) (alignment parameter)
Definition mptest1.f90:52
real(mps), parameter disx
distance between planes
Definition mptest1.f90:45
integer(mpi), parameter nplan
Definition mptest1.f90:41
real(mps) function uran()
Random number U(0,1) using RANSHI.
Definition randoms.f90:142
real(mps) function gran()
Gauss random number.
Definition randoms.f90:162

◆ mptest()

subroutine mptest

Generate test files.

Create text and binary files.

 unit  8: textfile mp2str.txt   = steering file
 unit  9: textfile mp2con.txt   = constraint file
 unit 51: binary file mp2test.bin, written using CALL MILLE(.)
 existing file are removed

Definition at line 78 of file mptest1.f90.

79 USE mptest1
80
81 IMPLICIT NONE
82 REAL(mps) :: dbar
83 REAL(mps) :: det
84 REAL(mps) :: displ
85 REAL(mps) :: drift
86 REAL(mps) :: eps
87 REAL(mps) :: eta
88 REAL(mps) :: gran
89 REAL(mps) :: one
90 REAL(mps) :: ww
91 REAL(mps) :: x
92 REAL(mps) :: xbar
93 INTEGER(mpi) :: i
94 INTEGER(mpi) :: icount
95 INTEGER(mpi) :: ios
96 INTEGER(mpi) :: ip
97 INTEGER(mpi) :: ipl
98 INTEGER(mpi) :: labelt
99 INTEGER(mpi) :: luns
100 INTEGER(mpi) :: lunt
101 INTEGER(mpi) :: ncount
102 INTEGER(mpi) :: nrecds
103 INTEGER(mpi) :: nthits
104
105 REAL(mpd) :: s1
106 REAL(mpd) :: s2
107 REAL(mpd) :: sw
108 REAL(mpd) :: sv
109 REAL(mpd) :: sum1
110 REAL(mpd) :: sum2
111 REAL(mps) :: derlc(2)
112 REAL(mps) :: dergl(2)
113 INTEGER(mpi) :: label(2)
114 LOGICAL :: ex1
115 LOGICAL :: ex2
116 LOGICAL :: ex3
117 ! ...
118 !CC CALL RNTIME
119 INQUIRE(file='mp2str.txt',iostat=ios,exist=ex1) ! keep, if existing
120 INQUIRE(file='mp2con.txt',iostat=ios,exist=ex2) ! keep, if existing
121
122 INQUIRE(file='mp2tst.bin',iostat=ios,exist=ex3) ! remove, if existing
123
124 WRITE(*,*) ' '
125 WRITE(*,*) 'Generating test data for mp II...'
126 WRITE(*,*) ' '
127 ! file management
128 IF(ex3) CALL system('rm mp2tst.bin') ! remove old file
129
130 IF(.NOT.ex1) OPEN(unit=7,access='SEQUENTIAL',form='FORMATTED', &
131 file='mp2str.txt')
132 IF(.NOT.ex2) OPEN(unit=9,access='SEQUENTIAL',form='FORMATTED', &
133 file='mp2con.txt')
134 OPEN(unit=51,access='SEQUENTIAL',form='UNFORMATTED', file='mp2tst.bin')
135
136 DO i=1,nplan
137 eff(i)=effp ! plane efficiency
138 sgm(i)=sgmp ! measurement sigma
139 del(i)=0.0 ! true shift is zero
140 END DO
141
142 ipl=7 ! modify one plane (7)
143 eff(ipl)=0.1 ! low efficiency
144 sgm(ipl)=0.0400 ! bad resolution
145
146 ! misalign detector planes -----------------------------------------
147
148 displ=0.1 ! displacement 1 mm * N(0,1)
149 drift=0.02 ! Vdrift deviation 2 % * N(0,1)
150 DO i=1,nplan
151 del(i)=displ*gran() ! shift
152 dvd(i)=drift*gran() ! rel. drift velocitu deviation
153 END DO
154 del(10)=0.0 ! no shift
155 del(90)=0.0 ! no shift
156
157 ! write text files -------------------------------------------------
158
159 IF(.NOT.ex1) THEN
160 luns=7 ! steerfile
161 WRITE(luns,101) '* Default test steering file'
162 WRITE(luns,101) 'fortranfiles ! following bin files are fortran'
163 WRITE(luns,101) 'mp2con.txt ! constraints text file '
164 WRITE(luns,101) 'mp2tst.bin ! binary data file'
165 WRITE(luns,101) 'Cfiles ! following bin files are Cfiles'
166 ! WRITE(LUNS,101) '*outlierrejection 100.0 ! reject if Chi^2/Ndf >'
167 ! WRITE(LUNS,101) '*outliersuppression 3 ! 3 local_fit iterations'
168
169 WRITE(luns,101) '*hugecut 50.0 !cut factor in iteration 0'
170 WRITE(luns,101) '*chisqcut 1.0 1.0 ! cut factor in iterations 1 and 2'
171 WRITE(luns,101) '*entries 10 ! lower limit on number of entries/parameter'
172 WRITE(luns,101) &
173 '*pairentries 10 ! lower limit on number of parameter pairs', &
174 ' ! (not yet!)'
175 WRITE(luns,101) '*printrecord 1 2 ! debug printout for records'
176 WRITE(luns,101) &
177 '*printrecord -1 -1 ! debug printout for bad data records'
178 WRITE(luns,101) &
179 '*outlierdownweighting 2 ! number of internal iterations (> 1)'
180 WRITE(luns,101) '*dwfractioncut 0.2 ! 0 < value < 0.5'
181 WRITE(luns,101) '*presigma 0.01 ! default value for presigma'
182 WRITE(luns,101) '*regularisation 1.0 ! regularisation factor'
183 WRITE(luns,101) '*regularisation 1.0 0.01 ! regularisation factor, pre-sigma'
184
185 WRITE(luns,101) ' '
186 WRITE(luns,101) '*bandwidth 0 ! width of precond. band matrix'
187 WRITE(luns,101) 'method diagonalization 3 0.001 ! diagonalization '
188 WRITE(luns,101) 'method fullMINRES 3 0.01 ! minimal residual '
189 WRITE(luns,101) 'method sparseMINRES 3 0.01 ! minimal residual '
190 WRITE(luns,101) '*mrestol 1.0D-8 ! epsilon for MINRES'
191 WRITE(luns,101) 'method inversion 3 0.001 ! Gauss matrix inversion'
192 WRITE(luns,101) '* last method is applied'
193 WRITE(luns,101) '*matiter 3 ! recalculate matrix in iterations'
194 WRITE(luns,101) ' '
195 WRITE(luns,101) 'end ! optional for end-of-data'
196 ENDIF
197
198 lunt=9 ! constraint file
199 one=1.0 ! shift constraint
200 IF(.NOT.ex2) WRITE(lunt,*) 'Constraint 0.0'
201 DO i=1,nplan
202 labelt=10+i*2
203 x=detx+real(i-1,mps)*disx+0.5*thck
204 IF(.NOT.ex2) WRITE(lunt,103) labelt,one
205 END DO
206
207 sw=0.0_mpd ! tilt constraint
208 sv=0.0_mpd
209 s1=0.0_mpd
210 s2=0.0_mpd
211 IF(.NOT.ex2) WRITE(lunt,*) 'Constraint 0.0' ! write
212 dbar=0.5*real(nplan-1,mps)*disx
213 xbar=detx+0.5*real(nplan-1,mps)*disx! +0.5*THCK
214 DO i=1,nplan
215 labelt=10+i*2
216 x=detx+real(i-1,mps)*disx !+0.5*THCK
217 ww=(x-xbar)/dbar
218 IF(.NOT.ex2) WRITE(lunt,103) labelt,ww ! write
219 s1=s1+del(i)
220 s2=s2+ww*del(i)
221 sw=sw+ww
222 sv=sv+ww*ww
223 END DO
224
225
226 det=real(real(nplan,mpd)*sv-sw*sw,mps)
227 eps=real(sv*s1-sw*s2,mps)/det
228 eta=real(real(nplan,mpd)*s2-sw*s1,mps)/det
229 DO i=1,nplan
230 x=detx+real(i-1,mps)*disx
231 ww=(x-xbar)/dbar
232 del(i)=del(i)-eps-eta*ww ! correct displacement ...
233 END DO ! ... for constraints
234
235 sum1=0.0
236 sum2=0.0
237 DO i=1,nplan
238 sum1=sum1+del(i)
239 x=detx+real(i-1,mps)*disx !+0.5*THCK
240 ww=(x-xbar)/dbar
241 sum2=sum2+del(i)*ww
242 END DO
243 ! WRITE(*,*) ' Check for constraints ',SUM1,SUM2
244
245 ! record loop ------------------------------------------------------
246
247 ncount=10000
248 nthits=0
249 nrecds=0
250
251 DO icount=1,ncount
252 ip=0
253 IF(icount == 8759) ip=1
254 ! IF(ICOUNT.EQ.6309) IP=1
255 ! IF(ICOUNT.EQ.7468) IP=1
256 CALL genlin(ip) ! generate hits
257
258 DO i=1,nhits
259 derlc(1)=1.0
260 derlc(2)=xhits(i)
261 dergl(1)=1.0
262 dergl(2)=ydrft(i)
263 label(1)=10+ihits(i)*2
264 label(2)=500 + ihits(i)
265 CALL mille(2,derlc,2,dergl,label,yhits(i),sigma(i))
266 nthits=nthits+1 ! count hits
267 END DO
268 CALL endle
269 nrecds=nrecds+1 ! count records
270 END DO
271
272 ! ------------------------------------------------------------------
273 IF(.NOT.ex1) THEN
274 rewind(7)
275 CLOSE (7)
276 END IF
277 IF(.NOT.ex2) THEN
278 rewind(9)
279 CLOSE (9)
280 END IF
281 rewind(51)
282 CLOSE (51)
283
284 ! WRITE(*,*) ' '
285 ! WRITE(*,*) 'Shifts and drift velocity deviations:'
286 ! DO I=1,NPLAN
287 ! WRITE(*,102) I,DEL(I),DVD(I)
288 ! END DO
289
290
291 WRITE(*,*) ' '
292 WRITE(*,*) ' '
293 WRITE(*,*) ncount,' tracks generated with ',nthits,' hits.'
294 WRITE(*,*) nrecds,' records written.'
295 WRITE(*,*) ' '
296101 FORMAT(a)
297 ! 102 FORMAT(I6,2F10.5)
298103 FORMAT(i8,f10.5)
subroutine mille(nlc, derlc, ngl, dergl, label, rmeas, sigma)
Add data block to record. Called from user code.
Definition mille.f90:76
subroutine genlin(ip)
Generate line and measurements.
Definition mptest1.f90:306
real(mps), parameter thck
thickness of plane
Definition mptest1.f90:46
real(mps), parameter effp
plane efficiency
Definition mptest1.f90:48
real(mps), parameter sgmp
measurement sigma
Definition mptest1.f90:49