/[PAMELA software]/DarthVader/TrackerLevel2/src/F77/analysissubroutines.f
ViewVC logotype

Contents of /DarthVader/TrackerLevel2/src/F77/analysissubroutines.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Tue Nov 7 15:55:11 2006 UTC (18 years, 2 months ago) by pam-fi
Branch: MAIN
Changes since 1.10: +83 -30 lines
track fit optimized and some bugs fixed

1 ************************************************************
2 * The following subroutines
3 * - track_finding >> hough transform
4 * - track_fitting >> bob golden fitting
5 * all the procedures to create LEVEL2 data, starting from LEVEL1 data.
6 *
7 *
8 *
9 * (This subroutine and all the dependent subroutines
10 * will be included in the flight software)
11 ************************************************************
12 subroutine track_finding(iflag)
13
14 include 'commontracker.f'
15 include 'level1.f'
16 include 'common_momanhough.f'
17 include 'common_mech.f'
18 include 'common_xyzPAM.f'
19 include 'common_mini_2.f'
20 include 'calib.f'
21 c include 'level1.f'
22 include 'level2.f'
23
24 c include 'momanhough_init.f'
25
26 *-------------------------------------------------------------------------------
27 * STEP 1
28 *-------------------------------------------------------------------------------
29 * X-Y cluster association
30 *
31 * Clusters are associated to form COUPLES
32 * Clusters not associated in any couple are called SINGLETS
33 *
34 * Track identification (Hough transform) and fitting is first done on couples.
35 * Hence singlets are possibly added to the track.
36 *
37 * Variables assigned by the routine "cl_to_couples" are those in the
38 * common blocks:
39 * - common/clusters/cl_good
40 * - common/couples/clx,cly,ncp_plane,ncp_tot,cp_useds1,cp_useds2
41 * - common/singlets/ncls,cls,cl_single
42 *-------------------------------------------------------------------------------
43 *-------------------------------------------------------------------------------
44
45 c iflag=0
46 call cl_to_couples(iflag)
47 if(iflag.eq.1)then !bad event
48 goto 880 !go to next event
49 endif
50
51 *-----------------------------------------------------
52 *-----------------------------------------------------
53 * HOUGH TRASFORM
54 *-----------------------------------------------------
55 *-----------------------------------------------------
56
57
58 *-------------------------------------------------------------------------------
59 * STEP 2
60 *-------------------------------------------------------------------------------
61 *
62 * Association of couples to form
63 * - DOUBLETS in YZ view
64 * - TRIPLETS in XZ view
65 *
66 * Variables assigned by the routine "cp_to_doubtrip" are those in the
67 * common blocks:
68 * - common/hough_param/
69 * $ alfayz1, !Y0
70 * $ alfayz2, !tg theta-yz
71 * $ alfaxz1, !X0
72 * $ alfaxz2, !tg theta-xz
73 * $ alfaxz3 !1/r
74 * - common/doublets/ndblt,cpyz1,cpyz2
75 * - common/triplets/ntrpt,cpxz1,cpxz2,cpxz3
76 *-------------------------------------------------------------------------------
77 *-------------------------------------------------------------------------------
78
79 c iflag=0
80 call cp_to_doubtrip(iflag)
81 if(iflag.eq.1)then !bad event
82 goto 880 !go to next event
83 endif
84
85
86 *-------------------------------------------------------------------------------
87 * STEP 3
88 *-------------------------------------------------------------------------------
89 *
90 * Classification of doublets and triplets to form CLOUDS,
91 * according to distance in parameter space.
92 *
93 * cloud = cluster of points (doublets/triplets) in parameter space
94 *
95 *
96 *
97 * Variables assigned by the routine "doub_to_YZcloud" are those in the
98 * common blocks:
99 * - common/clouds_yz/
100 * $ nclouds_yz
101 * $ ,alfayz1_av,alfayz2_av
102 * $ ,ptcloud_yz,db_cloud,cpcloud_yz
103 *
104 * Variables assigned by the routine "trip_to_XZcloud" are those in the
105 * common blocks:
106 * common/clouds_xz/
107 * $ nclouds_xz xz2_av,alfaxz3_av
108 * $ ,ptcloud_xz,tr_cloud,cpcloud_xz
109 *-------------------------------------------------------------------------------
110 *-------------------------------------------------------------------------------
111 * count number of hit planes
112 planehit=0
113 do np=1,nplanes
114 if(ncp_plane(np).ne.0)then
115 planehit=planehit+1
116 endif
117 enddo
118 if(planehit.lt.3) goto 880 ! exit
119
120 nptxz_min=x_min_start
121 nplxz_min=x_min_start
122
123 nptyz_min=y_min_start
124 nplyz_min=y_min_start
125
126 cutdistyz=cutystart
127 cutdistxz=cutxstart
128
129 878 continue
130 call doub_to_YZcloud(iflag)
131 if(iflag.eq.1)then !bad event
132 goto 880 !fill ntp and go to next event
133 endif
134 if(nclouds_yz.eq.0.and.cutdistyz.lt.maxcuty)then
135 if(cutdistyz.lt.maxcuty/2)then
136 cutdistyz=cutdistyz+cutystep
137 else
138 cutdistyz=cutdistyz+(3*cutystep)
139 endif
140 goto 878
141 endif
142
143 if(planehit.eq.3) goto 881
144
145 879 continue
146 call trip_to_XZcloud(iflag)
147 if(iflag.eq.1)then !bad event
148 goto 880 !fill ntp and go to next event
149 endif
150
151 if(nclouds_xz.eq.0.and.cutdistxz.lt.maxcutx)then
152 cutdistxz=cutdistxz+cutxstep
153 goto 879
154 endif
155
156
157 881 continue
158 * if there is at least three planes on the Y view decreases cuts on X view
159 if(nclouds_xz.eq.0.and.nclouds_yz.gt.0.and.
160 $ nplxz_min.ne.y_min_start)then
161 nptxz_min=x_min_step
162 nplxz_min=x_min_start-x_min_step
163 goto 879
164 endif
165
166 880 return
167 end
168
169 ************************************************************
170
171
172 subroutine track_fitting(iflag)
173
174 include 'commontracker.f'
175 include 'level1.f'
176 include 'common_momanhough.f'
177 include 'common_mech.f'
178 include 'common_xyzPAM.f'
179 include 'common_mini_2.f'
180 include 'calib.f'
181 include 'level2.f'
182
183 c include 'momanhough_init.f'
184
185 logical FIMAGE !
186 real*8 AL_GUESS(5)
187
188 *-------------------------------------------------------------------------------
189 * STEP 4 (ITERATED until any other physical track isn't found)
190 *-------------------------------------------------------------------------------
191 *
192 * YZ and XZ clouds are combined in order to obtain the initial guess
193 * of the candidate-track parameters.
194 * A minimum number of matching couples between YZ and XZ clouds is required.
195 *
196 * A TRACK CANDIDATE is defined by
197 * - the couples resulting from the INTERSECTION of the two clouds, and
198 * - the associated track parameters (evaluated by performing a zero-order
199 * track fitting)
200 *
201 * The NTRACKS candidate-track parameters are stored in common block:
202 *
203 * - common/track_candidates/NTRACKS,AL_STORE
204 * $ ,XV_STORE,YV_STORE,ZV_STORE
205 * $ ,XM_STORE,YM_STORE,ZM_STORE
206 * $ ,RESX_STORE,RESY_STORE
207 * $ ,AXV_STORE,AYV_STORE
208 * $ ,XGOOD_STORE,YGOOD_STORE
209 * $ ,CP_STORE,RCHI2_STORE
210 *
211 *-------------------------------------------------------------------------------
212 *-------------------------------------------------------------------------------
213 ntrk=0 !counter of identified physical tracks
214
215 11111 continue !<<<<<<< come here when performing a new search
216
217 c iflag=0
218 call clouds_to_ctrack(iflag)
219 if(iflag.eq.1)then !no candidate tracks found
220 goto 880 !fill ntp and go to next event
221 endif
222
223 FIMAGE=.false. !processing best track (not track image)
224 ibest=0 !best track among candidates
225 iimage=0 !track image
226 * ------------- select the best track -------------
227 c$$$ rchi2best=1000000000.
228 c$$$ do i=1,ntracks
229 c$$$ if(RCHI2_STORE(i).lt.rchi2best.and.
230 c$$$ $ RCHI2_STORE(i).gt.0)then
231 c$$$ ibest=i
232 c$$$ rchi2best=RCHI2_STORE(i)
233 c$$$ endif
234 c$$$ enddo
235 c$$$ if(ibest.eq.0)goto 880 !>> no good candidates
236
237 rchi2best=1000000000.
238 ndofbest=0 !(1)
239 do i=1,ntracks
240 if(RCHI2_STORE(i).lt.rchi2best.and.
241 $ RCHI2_STORE(i).gt.0)then
242 ndof=0 !(1)
243 do ii=1,nplanes !(1)
244 ndof=ndof !(1)
245 $ +int(xgood_store(ii,i)) !(1)
246 $ +int(ygood_store(ii,i)) !(1)
247 enddo !(1)
248 if(ndof.ge.ndofbest)then !(1)
249 ibest=i
250 rchi2best=RCHI2_STORE(i)
251 ndofbest=ndof !(1)
252 endif !(1)
253 endif
254 enddo
255 if(ibest.eq.0)goto 880 !>> no good candidates
256 *-------------------------------------------------------------------------------
257 * The best track candidate (ibest) is selected and a new fitting is performed.
258 * Previous to this, the track is refined by:
259 * - possibly adding new COUPLES or SINGLETS from the missing planes
260 * - evaluating the coordinates with improved PFAs
261 * ( angle-dependent ETA algorithms )
262 *-------------------------------------------------------------------------------
263
264 1212 continue !<<<<< come here to fit track-image
265
266 if(.not.FIMAGE)then !processing best candidate
267 icand=ibest
268 else !processing image
269 icand=iimage
270 iimage=0
271 endif
272 if(icand.eq.0)then
273 print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand
274 $ ,ibest,iimage
275 return
276 endif
277
278 * *-*-*-*-*-*-*-*-*-*-*-*-*-*-*
279 call refine_track(icand)
280 * *-*-*-*-*-*-*-*-*-*-*-*-*-*-*
281
282 * **********************************************************
283 * ************************** FIT *** FIT *** FIT *** FIT ***
284 * **********************************************************
285 call guess()
286 do i=1,5
287 AL_GUESS(i)=AL(i)
288 enddo
289
290 do i=1,5
291 AL(i)=dble(AL_STORE(i,icand))
292 enddo
293
294 IDCAND = icand !fitted track-candidate
295 ifail=0 !error flag in chi2 computation
296 jstep=0 !# minimization steps
297
298 iprint=0
299 c if(DEBUG)iprint=1
300 if(.true.)iprint=1
301 call mini2(jstep,ifail,iprint)
302 if(ifail.ne.0) then
303 if(.true.)then
304 print *,
305 $ '*** MINIMIZATION FAILURE *** (after refinement) '
306 $ ,iev
307
308 print*,'guess: ',(al_guess(i),i=1,5)
309 print*,'previous: ',(al_store(i,icand),i=1,5)
310 print*,'result: ',(al(i),i=1,5)
311 print*,'xgood ',xgood
312 print*,'ygood ',ygood
313 print*,'----------------------------------------------'
314 endif
315 c chi2=-chi2
316 endif
317
318 if(DEBUG)then
319 print*,'----------------------------- improved track coord'
320 22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5)
321 do ip=1,6
322 write(*,22222)ip,zm(ip),xm(ip),ym(ip)
323 $ ,xm_A(ip),ym_A(ip),xm_B(ip),ym_B(ip)
324 $ ,xgood(ip),ygood(ip),resx(ip),resy(ip)
325 enddo
326 endif
327
328 c rchi2=chi2/dble(ndof)
329 if(DEBUG)then
330 print*,' '
331 print*,'****** SELECTED TRACK *************'
332 print*,'# R. chi2 RIG'
333 print*,' --- ',chi2,' --- '
334 $ ,1./abs(AL(5))
335 print*,'***********************************'
336 endif
337 * **********************************************************
338 * ************************** FIT *** FIT *** FIT *** FIT ***
339 * **********************************************************
340
341
342 * ------------- search if the track has an IMAGE -------------
343 * ------------- (also this is stored ) -------------
344 if(FIMAGE)goto 122 !>>> jump! (this is already an image)
345 * now search for track-image, by comparing couples IDs
346 do i=1,ntracks
347 iimage=i
348 do ip=1,nplanes
349 if( CP_STORE(nplanes-ip+1,icand).ne.
350 $ -1*CP_STORE(nplanes-ip+1,i) )iimage=0
351 enddo
352 if( iimage.ne.0.and.
353 c $ RCHI2_STORE(i).le.CHI2MAX.and.
354 c $ RCHI2_STORE(i).gt.0.and.
355 $ .true.)then
356 if(DEBUG)print*,'Track candidate ',iimage
357 $ ,' >>> TRACK IMAGE >>> of'
358 $ ,ibest
359 goto 122 !image track found
360 endif
361 enddo
362 122 continue
363
364 * --- and store the results --------------------------------
365 ntrk = ntrk + 1 !counter of found tracks
366 if(.not.FIMAGE
367 $ .and.iimage.eq.0) image(ntrk)= 0
368 if(.not.FIMAGE
369 $ .and.iimage.ne.0)image(ntrk)=ntrk+1 !this is the image of the next
370 if(FIMAGE) image(ntrk)=ntrk-1 !this is the image of the previous
371 call fill_level2_tracks(ntrk) !==> good2=.true.
372 c print*,'++++++++++ iimage,fimage,ntrk,image '
373 c $ ,iimage,fimage,ntrk,image(ntrk)
374
375 if(ntrk.eq.NTRKMAX)then
376 if(verbose)
377 $ print*,
378 $ '** warning ** number of identified '//
379 $ 'tracks exceeds vector dimension '
380 $ ,'( ',NTRKMAX,' )'
381 cc good2=.false.
382 goto 880 !fill ntp and go to next event
383 endif
384 if(iimage.ne.0)then
385 FIMAGE=.true. !
386 goto 1212 !>>> fit image-track
387 endif
388
389 * --- then remove selected clusters (ibest+iimage) from clouds ----
390 call clean_XYclouds(ibest,iflag)
391 if(iflag.eq.1)then !bad event
392 goto 880 !fill ntp and go to next event
393 endif
394
395 * **********************************************************
396 * condition to start a new search
397 * **********************************************************
398 ixznew=0
399 do ixz=1,nclouds_xz
400 if(ptcloud_xz(ixz).ge.nptxz_min)ixznew=1
401 enddo
402 iyznew=0
403 do iyz=1,nclouds_yz
404 if(ptcloud_yz(iyz).ge.nptyz_min)iyznew=1
405 enddo
406
407 if(ixznew.ne.0.and.
408 $ iyznew.ne.0.and.
409 $ rchi2best.le.CHI2MAX.and.
410 c $ rchi2best.lt.15..and.
411 $ .true.)then
412 if(DEBUG)then
413 print*,'***** NEW SEARCH ****'
414 endif
415 goto 11111 !try new search
416
417 endif
418 * **********************************************
419
420
421
422 880 return
423 end
424
425
426
427
428 c$$$************************************************************
429 c$$$
430 c$$$ subroutine readmipparam
431 c$$$
432 c$$$ include 'commontracker.f'
433 c$$$ include 'calib.f'
434 c$$$
435 c$$$ character*60 fname_param
436 c$$$ 201 format('trk-LADDER',i1,'-mip.dat')
437 c$$$ do ilad=1,nladders_view
438 c$$$ write(fname_param,201)ilad
439 c$$$ print *,'Opening file: ',fname_param
440 c$$$ open(10,
441 c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param))
442 c$$$ $ ,STATUS='UNKNOWN'
443 c$$$ $ ,IOSTAT=iostat
444 c$$$ $ )
445 c$$$ if(iostat.ne.0)then
446 c$$$ print*,'READMIPPARAM: *** Error in opening file ***'
447 c$$$ return
448 c$$$ endif
449 c$$$ do iv=1,nviews
450 c$$$ read(10,*
451 c$$$ $ ,IOSTAT=iostat
452 c$$$ $ )pip,
453 c$$$ $ mip(int(pip),ilad)
454 c$$$c print*,ilad,iv,pip,mip(int(pip),ilad)
455 c$$$ enddo
456 c$$$ close(10)
457 c$$$ enddo
458 c$$$
459 c$$$ return
460 c$$$ end
461 c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * ***
462 c$$$ subroutine readchargeparam
463 c$$$
464 c$$$
465 c$$$ include 'commontracker.f'
466 c$$$ include 'calib.f'
467 c$$$
468 c$$$ character*60 fname_param
469 c$$$ 201 format('charge-l',i1,'.dat')
470 c$$$ do ilad=1,nladders_view
471 c$$$ write(fname_param,201)ilad
472 c$$$ print *,'Opening file: ',fname_param
473 c$$$ open(10,
474 c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param))
475 c$$$ $ ,STATUS='UNKNOWN'
476 c$$$ $ ,IOSTAT=iostat
477 c$$$ $ )
478 c$$$ if(iostat.ne.0)then
479 c$$$ print*,'READCHARGEPARAM: *** Error in opening file ***'
480 c$$$ return
481 c$$$ endif
482 c$$$ do ip=1,nplanes
483 c$$$ read(10,*
484 c$$$ $ ,IOSTAT=iostat
485 c$$$ $ )pip,
486 c$$$ $ kch(ip,ilad),cch(ip,ilad),sch(ip,ilad)
487 c$$$c print*,ilad,ip,pip,kch(ip,ilad),
488 c$$$c $ cch(ip,ilad),sch(ip,ilad)
489 c$$$ enddo
490 c$$$ close(10)
491 c$$$ enddo
492 c$$$
493 c$$$ return
494 c$$$ end
495 c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * ***
496 c$$$ subroutine readetaparam
497 c$$$* -----------------------------------------
498 c$$$* read eta2,3,4 calibration parameters
499 c$$$* and fill variables:
500 c$$$*
501 c$$$* eta2(netabin,nladders_view,nviews)
502 c$$$* eta3(2*netabin,nladders_view,nviews)
503 c$$$* eta4(2*netabin,nladders_view,nviews)
504 c$$$*
505 c$$$ include 'commontracker.f'
506 c$$$ include 'calib.f'
507 c$$$
508 c$$$ character*40 fname_binning
509 c$$$ character*40 fname_param
510 c$$$c character*120 cmd1
511 c$$$c character*120 cmd2
512 c$$$
513 c$$$
514 c$$$******retrieve ANGULAR BINNING info
515 c$$$ fname_binning='binning.dat'
516 c$$$ print *,'Opening file: ',fname_binning
517 c$$$ open(10,
518 c$$$ $ FILE='./bin-aux/'//fname_binning(1:LNBLNK(fname_binning))
519 c$$$ $ ,STATUS='UNKNOWN'
520 c$$$ $ ,IOSTAT=iostat
521 c$$$ $ )
522 c$$$ if(iostat.ne.0)then
523 c$$$ print*,'READETAPARAM: *** Error in opening file ***'
524 c$$$ return
525 c$$$ endif
526 c$$$ print*,'---- ANGULAR BINNING ----'
527 c$$$ print*,'Bin - angL - angR'
528 c$$$ 101 format(i2,' ',f6.2,' ',f6.2)
529 c$$$ do ibin=1,nangmax
530 c$$$ read(10,*
531 c$$$ $ ,IOSTAT=iostat
532 c$$$ $ )xnn,angL(ibin),angR(ibin)
533 c$$$ if(iostat.ne.0)goto 1000
534 c$$$ write(*,101)int(xnn),angL(ibin),angR(ibin)
535 c$$$ enddo
536 c$$$ 1000 nangbin=int(xnn)
537 c$$$ close(10)
538 c$$$ print*,'-------------------------'
539 c$$$
540 c$$$
541 c$$$
542 c$$$ do ieta=2,4 !loop on eta 2,3,4
543 c$$$******retrieve correction parameters
544 c$$$ 200 format(' Opening eta',i1,' files...')
545 c$$$ write(*,200)ieta
546 c$$$
547 c$$$ 201 format('eta',i1,'-bin',i1,'-l',i1,'.dat')
548 c$$$ 202 format('eta',i1,'-bin',i2,'-l',i1,'.dat')
549 c$$$ do iang=1,nangbin
550 c$$$ do ilad=1,nladders_view
551 c$$$ if(iang.lt.10)write(fname_param,201)ieta,iang,ilad
552 c$$$ if(iang.ge.10)write(fname_param,202)ieta,iang,ilad
553 c$$$c print *,'Opening file: ',fname_param
554 c$$$ open(10,
555 c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param))
556 c$$$ $ ,STATUS='UNKNOWN'
557 c$$$ $ ,IOSTAT=iostat
558 c$$$ $ )
559 c$$$ if(iostat.ne.0)then
560 c$$$ print*,'READETAPARAM: *** Error in opening file ***'
561 c$$$ return
562 c$$$ endif
563 c$$$ do ival=1,netavalmax
564 c$$$ if(ieta.eq.2)read(10,*
565 c$$$ $ ,IOSTAT=iostat
566 c$$$ $ )
567 c$$$ $ eta2(ival,iang),
568 c$$$ $ (feta2(ival,iv,ilad,iang),iv=1,nviews)
569 c$$$ if(ieta.eq.3)read(10,*
570 c$$$ $ ,IOSTAT=iostat
571 c$$$ $ )
572 c$$$ $ eta3(ival,iang),
573 c$$$ $ (feta3(ival,iv,ilad,iang),iv=1,nviews)
574 c$$$ if(ieta.eq.4)read(10,*
575 c$$$ $ ,IOSTAT=iostat
576 c$$$ $ )
577 c$$$ $ eta4(ival,iang),
578 c$$$ $ (feta4(ival,iv,ilad,iang),iv=1,nviews)
579 c$$$ if(iostat.ne.0)then
580 c$$$ netaval=ival-1
581 c$$$c$$$ if(eta2(1,iang).ne.-eta2(netaval,iang))
582 c$$$c$$$ $ print*,'**** ERROR on parameters !!! ****'
583 c$$$ goto 2000
584 c$$$ endif
585 c$$$ enddo
586 c$$$ 2000 close(10)
587 c$$$* print*,'... done'
588 c$$$ enddo
589 c$$$ enddo
590 c$$$
591 c$$$ enddo !end loop on eta 2,3,4
592 c$$$
593 c$$$
594 c$$$ return
595 c$$$ end
596 c$$$
597
598
599 ************************************************************
600 ************************************************************
601 ************************************************************
602 ************************************************************
603 *
604 * This routine provides the coordinates (in cm) in the PAMELA reference system:
605 * - of the point associated with a COUPLE ---> (xPAM,yPAM,zPAM)
606 * - of the extremes of the segment
607 * associated with a SINGLET ---------------> (xPAM_A,yPAM_A,zPAM_A)
608 * ---> (xPAM_B,yPAM_B,zPAM_B)
609 *
610 * It also assigns the spatial resolution to the evaluated coordinates,
611 * as a function (in principle) of the multiplicity, the angle, the PFA etc...
612 *
613 *
614 * To call the routine you must pass the arguments:
615 * icx - ID of cluster x
616 * icy - ID of cluster y
617 * sensor - sensor (1,2)
618 * PFAx - Position Finding Algorithm in x (COG2,ETA2,...)
619 * PFAy - Position Finding Algorithm in y (COG2,ETA2,...)
620 * angx - Projected angle in x
621 * angy - Projected angle in y
622 *
623 * --------- COUPLES -------------------------------------------------------
624 * The couple defines a point in the space.
625 * The coordinates of the point are evaluated as follows:
626 * 1 - the corrected coordinates relative to the sensor are evaluated
627 * according to the chosen PFA --> (xi,yi,0)
628 * 2 - coordinates are rotated and traslated, according to the aligmnet
629 * parameters, and expressed in the reference system of the mechanical
630 * sensor --> (xrt,yrt,zrt)
631 * 3 - coordinates are finally converted to the PAMELA reference system
632 * --> (xPAM,yPAM,zPAM)
633 *
634 * --------- SINGLETS -------------------------------------------------------
635 * Since a coordinate is missing, the singlet defines not a point
636 * in the space but a segment AB (parallel to the strips).
637 * In this case the routine returns the coordinates in the PAMELA reference
638 * system of the two extremes A and B of the segment:
639 * --> (xPAM_A,yPAM_A,zPAM_A)
640 * --> (xPAM_B,yPAM_B,zPAM_B)
641 *
642 * ==========================================================
643 *
644 * The output of the routine is stored in the commons:
645 *
646 * double precision xPAM,yPAM,zPAM
647 * common/coord_xyz_PAM/xPAM,yPAM,zPAM
648 *
649 * double precision xPAM_A,yPAM_A,zPAM_A
650 * double precision xPAM_B,yPAM_B,zPAM_B
651 * common/coord_AB_PAM/xPAM_A,yPAM_A,zPAM_A,xPAM_B,yPAM_B,zPAM_B
652 *
653 * double precision resxPAM,resyPAM
654 * common/resolution_PAM/resxPAM,resyPAM
655 *
656 * (in file common_xyzPAM.f)
657 *
658 *
659
660 subroutine xyz_PAM(icx,icy,sensor,PFAx,PFAy,angx,angy)
661
662 c*****************************************************
663 c 07/10/2005 modified by elena vannuccini --> (1)
664 c 01/02/2006 modified by elena vannuccini --> (2)
665 c 02/02/2006 modified by Elena Vannuccini --> (3)
666 c (implemented new p.f.a.)
667 c 03/02/2006 modified by Elena Vannuccini --> (4)
668 c (implemented variable resolution)
669 c*****************************************************
670
671 include 'commontracker.f'
672 include 'level1.f'
673 include 'calib.f'
674 c include 'level1.f'
675 include 'common_align.f'
676 include 'common_mech.f'
677 include 'common_xyzPAM.f'
678 c include 'common_resxy.f'
679
680 c logical DEBUG
681 c common/dbg/DEBUG
682
683 integer icx,icy !X-Y cluster ID
684 integer sensor
685 integer viewx,viewy
686 character*4 PFAx,PFAy !PFA to be used
687 real angx,angy !X-Y angle
688
689 real stripx,stripy
690
691 double precision xrt,yrt,zrt
692 double precision xrt_A,yrt_A,zrt_A
693 double precision xrt_B,yrt_B,zrt_B
694 c double precision xi,yi,zi
695 c double precision xi_A,yi_A,zi_A
696 c double precision xi_B,yi_B,zi_B
697
698
699 parameter (ndivx=30)
700
701 resxPAM = 0
702 resyPAM = 0
703
704 xPAM = 0.
705 yPAM = 0.
706 zPAM = 0.
707 xPAM_A = 0.
708 yPAM_A = 0.
709 zPAM_A = 0.
710 xPAM_B = 0.
711 yPAM_B = 0.
712 zPAM_B = 0.
713
714 * -----------------
715 * CLUSTER X
716 * -----------------
717
718 if(icx.ne.0)then
719 viewx = VIEW(icx)
720 nldx = nld(MAXS(icx),VIEW(icx))
721 nplx = npl(VIEW(icx))
722 resxPAM = RESXAV !!!!!!!TEMPORANEO!!!!!!!!!!!!!!!!
723
724 stripx = float(MAXS(icx))
725 if(PFAx.eq.'COG1')then !(1)
726 stripx = stripx !(1)
727 resxPAM = resxPAM !(1)
728 elseif(PFAx.eq.'COG2')then
729 stripx = stripx + cog(2,icx)
730 resxPAM = resxPAM*fbad_cog(2,icx)
731 elseif(PFAx.eq.'ETA2')then
732 c cog2 = cog(2,icx)
733 c etacorr = pfaeta2(cog2,viewx,nldx,angx)
734 c stripx = stripx + etacorr
735 stripx = stripx + pfaeta2(icx,angx) !(3)
736 resxPAM = risx_eta2(angx) ! (4)
737 if(DEBUG.and.fbad_cog(2,icx).ne.1)
738 $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)
739 resxPAM = resxPAM*fbad_cog(2,icx)
740 elseif(PFAx.eq.'ETA3')then !(3)
741 stripx = stripx + pfaeta3(icx,angx) !(3)
742 resxPAM = risx_eta3(angx) ! (4)
743 if(DEBUG.and.fbad_cog(3,icx).ne.1) !(3)
744 $ print*,'BAD icx >>> ',viewx,fbad_cog(3,icx)!(3)
745 resxPAM = resxPAM*fbad_cog(3,icx) !(3)
746 elseif(PFAx.eq.'ETA4')then !(3)
747 stripx = stripx + pfaeta4(icx,angx) !(3)
748 resxPAM = risx_eta4(angx) ! (4)
749 if(DEBUG.and.fbad_cog(4,icx).ne.1) !(3)
750 $ print*,'BAD icx >>> ',viewx,fbad_cog(4,icx)!(3)
751 resxPAM = resxPAM*fbad_cog(4,icx) !(3)
752 elseif(PFAx.eq.'ETA')then !(3)
753 stripx = stripx + pfaeta(icx,angx) !(3)
754 resxPAM = ris_eta(icx,angx) ! (4)
755 if(DEBUG.and.fbad_cog(2,icx).ne.1) !(3)
756 $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)!(3)
757 c resxPAM = resxPAM*fbad_cog(2,icx) !(3)TEMPORANEO
758 resxPAM = resxPAM*fbad_eta(icx,angx) !(3)(4)
759 elseif(PFAx.eq.'COG')then !(2)
760 stripx = stripx + cog(0,icx) !(2)
761 resxPAM = risx_cog(angx) ! (4)
762 resxPAM = resxPAM*fbad_cog(0,icx)!(2)
763 else
764 print*,'*** Non valid p.f.a. (x) --> ',PFAx
765 endif
766
767 endif
768 c if(icy.eq.0.and.icx.ne.0)
769 c $ print*,PFAx,icx,angx,stripx,resxPAM,'***'
770
771 * -----------------
772 * CLUSTER Y
773 * -----------------
774
775 if(icy.ne.0)then
776 viewy = VIEW(icy)
777 nldy = nld(MAXS(icy),VIEW(icy))
778 nply = npl(VIEW(icy))
779 resyPAM = RESYAV !!!!!!!TEMPORANEO!!!!!!!!!!!!!!!!
780
781
782 if(icx.ne.0.and.(nply.ne.nplx.or.nldy.ne.nldx))then
783 print*,'xyz_PAM ***ERROR*** invalid cluster couple!!! '
784 $ ,icx,icy
785 goto 100
786 endif
787
788 stripy = float(MAXS(icy))
789 if(PFAy.eq.'COG1')then !(1)
790 stripy = stripy !(1)
791 resyPAM = resyPAM !(1)
792 elseif(PFAy.eq.'COG2')then
793 stripy = stripy + cog(2,icy)
794 resyPAM = resyPAM*fbad_cog(2,icy)
795 elseif(PFAy.eq.'ETA2')then
796 c cog2 = cog(2,icy)
797 c etacorr = pfaeta2(cog2,viewy,nldy,angy)
798 c stripy = stripy + etacorr
799 stripy = stripy + pfaeta2(icy,angy) !(3)
800 resyPAM = risy_eta2(angy) ! (4)
801 resyPAM = resyPAM*fbad_cog(2,icy)
802 if(DEBUG.and.fbad_cog(2,icy).ne.1)
803 $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)
804 elseif(PFAy.eq.'ETA3')then !(3)
805 stripy = stripy + pfaeta3(icy,angy) !(3)
806 resyPAM = resyPAM*fbad_cog(3,icy) !(3)
807 if(DEBUG.and.fbad_cog(3,icy).ne.1) !(3)
808 $ print*,'BAD icy >>> ',viewy,fbad_cog(3,icy)!(3)
809 elseif(PFAy.eq.'ETA4')then !(3)
810 stripy = stripy + pfaeta4(icy,angy) !(3)
811 resyPAM = resyPAM*fbad_cog(4,icy) !(3)
812 if(DEBUG.and.fbad_cog(4,icy).ne.1) !(3)
813 $ print*,'BAD icy >>> ',viewy,fbad_cog(4,icy)!(3)
814 elseif(PFAy.eq.'ETA')then !(3)
815 stripy = stripy + pfaeta(icy,angy) !(3)
816 resyPAM = ris_eta(icy,angy) ! (4)
817 c resyPAM = resyPAM*fbad_cog(2,icy) !(3)TEMPORANEO
818 resyPAM = resyPAM*fbad_eta(icy,angy) ! (4)
819 if(DEBUG.and.fbad_cog(2,icy).ne.1) !(3)
820 $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)!(3)
821 elseif(PFAy.eq.'COG')then
822 stripy = stripy + cog(0,icy)
823 resyPAM = risy_cog(angy) ! (4)
824 c resyPAM = ris_eta(icy,angy) ! (4)
825 resyPAM = resyPAM*fbad_cog(0,icy)
826 else
827 print*,'*** Non valid p.f.a. (x) --> ',PFAx
828 endif
829
830 endif
831
832
833 c===========================================================
834 C COUPLE
835 C===========================================================
836 if(icx.ne.0.and.icy.ne.0)then
837
838 c------------------------------------------------------------------------
839 c (xi,yi,zi) = mechanical coordinates in the silicon sensor frame
840 c------------------------------------------------------------------------
841 if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
842 $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips...
843 print*,'xyz_PAM (couple):',
844 $ ' WARNING: false X strip: strip ',stripx
845 endif
846 xi = acoordsi(stripx,viewx)
847 yi = acoordsi(stripy,viewy)
848 zi = 0.
849
850
851 c------------------------------------------------------------------------
852 c (xrt,yrt,zrt) = rototranslated coordinates in the silicon sensor frame
853 c------------------------------------------------------------------------
854 c N.B. I convert angles from microradiants to radiants
855
856 xrt = xi
857 $ - omega(nplx,nldx,sensor)*yi
858 $ + gamma(nplx,nldx,sensor)*zi
859 $ + dx(nplx,nldx,sensor)
860
861 yrt = omega(nplx,nldx,sensor)*xi
862 $ + yi
863 $ - beta(nplx,nldx,sensor)*zi
864 $ + dy(nplx,nldx,sensor)
865
866 zrt = -gamma(nplx,nldx,sensor)*xi
867 $ + beta(nplx,nldx,sensor)*yi
868 $ + zi
869 $ + dz(nplx,nldx,sensor)
870
871 c xrt = xi
872 c yrt = yi
873 c zrt = zi
874
875 c------------------------------------------------------------------------
876 c (xPAM,yPAM,zPAM) = measured coordinates (in cm)
877 c in PAMELA reference system
878 c------------------------------------------------------------------------
879
880 xPAM = dcoord(xrt,viewx,nldx,sensor) / 1.d4
881 yPAM = dcoord(yrt,viewy,nldy,sensor) / 1.d4
882 zPAM = ( zrt + z_mech_sensor(nplx,nldx,sensor)*1000. ) / 1.d4
883
884 xPAM_A = 0.
885 yPAM_A = 0.
886 zPAM_A = 0.
887
888 xPAM_B = 0.
889 yPAM_B = 0.
890 zPAM_B = 0.
891
892 elseif(
893 $ (icx.ne.0.and.icy.eq.0).or.
894 $ (icx.eq.0.and.icy.ne.0).or.
895 $ .false.
896 $ )then
897
898 c------------------------------------------------------------------------
899 c (xi,yi,zi) = mechanical coordinates in the silicon sensor frame
900 c------------------------------------------------------------------------
901
902 if(icy.ne.0)then
903 c===========================================================
904 C Y-SINGLET
905 C===========================================================
906 nplx = nply
907 nldx = nldy
908 viewx = viewy + 1
909
910 yi = acoordsi(stripy,viewy)
911
912 xi_A = edgeY_d - SiDimX/2
913 yi_A = yi
914 zi_A = 0.
915
916 xi_B = SiDimX/2 - edgeY_u
917 yi_B = yi
918 zi_B = 0.
919
920 c print*,'Y-cl ',icy,stripy,' --> ',yi
921 c print*,xi_A,' <--> ',xi_B
922
923 elseif(icx.ne.0)then
924 c===========================================================
925 C X-SINGLET
926 C===========================================================
927
928 nply = nplx
929 nldy = nldx
930 viewy = viewx - 1
931
932 c print*,'X-singlet ',icx,nplx,nldx,viewx,stripx
933 c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips...
934 if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
935 $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips...
936 print*,'xyz_PAM (X-singlet):',
937 $ ' WARNING: false X strip: strip ',stripx
938 endif
939 xi = acoordsi(stripx,viewx)
940
941 xi_A = xi
942 yi_A = edgeX_d - SiDimY/2
943 zi_A = 0.
944
945 xi_B = xi
946 yi_B = SiDimY/2 - edgeX_u
947 zi_B = 0.
948
949 if(viewy.eq.11)then
950 yi = yi_A
951 yi_A = yi_B
952 yi_B = yi
953 endif
954
955 c print*,'X-cl ',icx,stripx,' --> ',xi
956 c print*,yi_A,' <--> ',yi_B
957
958 else
959
960 print *,'routine xyz_PAM ---> not properly used !!!'
961 print *,'icx = ',icx
962 print *,'icy = ',icy
963 goto 100
964
965 endif
966 c------------------------------------------------------------------------
967 c (xrt,yrt,zrt) = rototranslated coordinates in the silicon sensor frame
968 c------------------------------------------------------------------------
969 c N.B. I convert angles from microradiants to radiants
970
971 xrt_A = xi_A
972 $ - omega(nplx,nldx,sensor)*yi_A
973 $ + gamma(nplx,nldx,sensor)*zi_A
974 $ + dx(nplx,nldx,sensor)
975
976 yrt_A = omega(nplx,nldx,sensor)*xi_A
977 $ + yi_A
978 $ - beta(nplx,nldx,sensor)*zi_A
979 $ + dy(nplx,nldx,sensor)
980
981 zrt_A = -gamma(nplx,nldx,sensor)*xi_A
982 $ + beta(nplx,nldx,sensor)*yi_A
983 $ + zi_A
984 $ + dz(nplx,nldx,sensor)
985
986 xrt_B = xi_B
987 $ - omega(nplx,nldx,sensor)*yi_B
988 $ + gamma(nplx,nldx,sensor)*zi_B
989 $ + dx(nplx,nldx,sensor)
990
991 yrt_B = omega(nplx,nldx,sensor)*xi_B
992 $ + yi_B
993 $ - beta(nplx,nldx,sensor)*zi_B
994 $ + dy(nplx,nldx,sensor)
995
996 zrt_B = -gamma(nplx,nldx,sensor)*xi_B
997 $ + beta(nplx,nldx,sensor)*yi_B
998 $ + zi_B
999 $ + dz(nplx,nldx,sensor)
1000
1001
1002 c xrt = xi
1003 c yrt = yi
1004 c zrt = zi
1005
1006 c------------------------------------------------------------------------
1007 c (xPAM,yPAM,zPAM) = measured coordinates (in cm)
1008 c in PAMELA reference system
1009 c------------------------------------------------------------------------
1010
1011 xPAM = 0.
1012 yPAM = 0.
1013 zPAM = 0.
1014
1015 xPAM_A = dcoord(xrt_A,viewx,nldx,sensor) / 1.d4
1016 yPAM_A = dcoord(yrt_A,viewy,nldy,sensor) / 1.d4
1017 zPAM_A = ( zrt_A + z_mech_sensor(nplx,nldx,sensor)*1000.)/ 1.d4
1018
1019 xPAM_B = dcoord(xrt_B,viewx,nldx,sensor) / 1.d4
1020 yPAM_B = dcoord(yrt_B,viewy,nldy,sensor) / 1.d4
1021 zPAM_B = ( zrt_B + z_mech_sensor(nplx,nldx,sensor)*1000.)/ 1.d4
1022
1023
1024 c print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')'
1025
1026 else
1027
1028 print *,'routine xyz_PAM ---> not properly used !!!'
1029 print *,'icx = ',icx
1030 print *,'icy = ',icy
1031
1032 endif
1033
1034 100 continue
1035 end
1036
1037
1038 ********************************************************************************
1039 ********************************************************************************
1040 ********************************************************************************
1041 *
1042 * The function distance_to(XP,YP) should be used after
1043 * a call to the xyz_PAM routine and it evaluate the
1044 * NORMALIZED distance (PROJECTED on the XY plane) between
1045 * the point (XP,YP), argument of the function,
1046 * and:
1047 *
1048 * - the point (xPAM,yPAM,zPAM), in the case of a COUPLE
1049 * or
1050 * - the segment (xPAM_A,yPAM_A,zPAM_A)-(xPAM_B,yPAM_B,zPAM_B),
1051 * in the case of a SINGLET.
1052 *
1053 * ( The routine xyz_PAM fills the common defined in "common_xyzPAM.f",
1054 * which stores the coordinates of the couple/singlet )
1055 *
1056 ********************************************************************************
1057
1058 real function distance_to(XPP,YPP)
1059
1060 include 'common_xyzPAM.f'
1061
1062 * -----------------------------------
1063 * it computes the normalized distance
1064 * ( i.e. distance/resolution )
1065 * -----------------------------------
1066
1067 double precision distance,RE
1068 double precision BETA,ALFA,xmi,ymi
1069
1070 * ----------------------
1071 if (
1072 + xPAM.eq.0.and.
1073 + yPAM.eq.0.and.
1074 + zPAM.eq.0.and.
1075 + xPAM_A.ne.0.and.
1076 + yPAM_A.ne.0.and.
1077 + zPAM_A.ne.0.and.
1078 + xPAM_B.ne.0.and.
1079 + yPAM_B.ne.0.and.
1080 + zPAM_B.ne.0.and.
1081 + .true.)then
1082 * -----------------------
1083 * DISTANCE TO --- SINGLET
1084 * -----------------------
1085 if(abs(sngl(xPAM_B-xPAM_A)).lt.abs(sngl(yPAM_B-yPAM_A)))then
1086 * |||---------- X CLUSTER
1087
1088 BETA = (xPAM_B-xPAM_A)/(yPAM_B-yPAM_A)
1089 ALFA = xPAM_A - BETA * yPAM_A
1090
1091 ymi = ( YPP + BETA*XPP - BETA*ALFA )/(1+BETA**2)
1092 if(ymi.lt.dmin1(yPAM_A,yPAM_B))ymi=dmin1(yPAM_A,yPAM_B)
1093 if(ymi.gt.dmax1(yPAM_A,yPAM_B))ymi=dmax1(yPAM_A,yPAM_B)
1094 xmi = ALFA + BETA * ymi
1095 RE = resxPAM
1096
1097 else
1098 * |||---------- Y CLUSTER
1099
1100 BETA = (yPAM_B-yPAM_A)/(xPAM_B-xPAM_A)
1101 ALFA = yPAM_A - BETA * xPAM_A
1102
1103 xmi = ( XPP + BETA*YPP - BETA*ALFA )/(1+BETA**2)
1104 if(xmi.lt.dmin1(xPAM_A,xPAM_B))xmi=dmin1(xPAM_A,xPAM_B)
1105 if(xmi.gt.dmax1(xPAM_A,xPAM_B))xmi=dmax1(xPAM_A,xPAM_B)
1106 ymi = ALFA + BETA * xmi
1107 RE = resyPAM
1108
1109 endif
1110
1111 distance=
1112 $ ((xmi-XPP)**2+(ymi-YPP)**2)/RE**2
1113 distance=dsqrt(distance)
1114
1115 c$$$ print*,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b
1116 c$$$ $ ,' --- distance_to --- ',xpp,ypp
1117 c$$$ print*,' resolution ',re
1118
1119
1120 * ----------------------
1121 elseif(
1122 + xPAM.ne.0.and.
1123 + yPAM.ne.0.and.
1124 + zPAM.ne.0.and.
1125 + xPAM_A.eq.0.and.
1126 + yPAM_A.eq.0.and.
1127 + zPAM_A.eq.0.and.
1128 + xPAM_B.eq.0.and.
1129 + yPAM_B.eq.0.and.
1130 + zPAM_B.eq.0.and.
1131 + .true.)then
1132 * ----------------------
1133 * DISTANCE TO --- COUPLE
1134 * ----------------------
1135
1136 distance=
1137 $ ((xPAM-XPP)/resxPAM)**2
1138 $ +
1139 $ ((yPAM-YPP)/resyPAM)**2
1140 distance=dsqrt(distance)
1141
1142 c$$$ print*,xPAM,yPAM,zPAM
1143 c$$$ $ ,' --- distance_to --- ',xpp,ypp
1144 c$$$ print*,' resolution ',resxPAM,resyPAM
1145
1146 else
1147
1148 print*
1149 $ ,' function distance_to ---> wrong usage!!!'
1150 print*,' xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM
1151 print*,' xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b '
1152 $ ,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b
1153 endif
1154
1155 distance_to = sngl(distance)
1156
1157 return
1158 end
1159
1160 ********************************************************************************
1161 ********************************************************************************
1162 ********************************************************************************
1163 ********************************************************************************
1164
1165 subroutine whichsensor(nplPAM,xPAM,yPAM,ladder,sensor)
1166 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1167 * Given the plane (1-6 from BOTTOM to TOP!!) and the (xPAM,yPAM)
1168 * coordinates (in the PAMELA reference system), it returns
1169 * the ladder and the sensor which the point belongs to.
1170 *
1171 * The method to assign a point to a sensor consists in
1172 * - calculating the sum of the distances between the point
1173 * and the sensor edges
1174 * - requiring that it is less-equal than (SiDimX+SiDimY)
1175 *
1176 * NB -- SiDimX and SiDimY are not the dimentions of the SENSITIVE volume
1177 * but of the whole silicon sensor
1178 *
1179 * CONVENTION:
1180 * - sensor 1 is the one closest to the hybrid
1181 * - ladder 1 is the first to be read out (strips from 1 to 1024)
1182 *
1183 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1184 include 'commontracker.f'
1185 include 'common_align.f'
1186
1187 integer ladder,sensor,viewx,viewy
1188 real c1(4),c2(4),c3(4)
1189 data c1/1.,0.,0.,1./
1190 data c2/1.,-1.,-1.,1./
1191 data c3/1.,1.,0.,0./
1192 real*8 yvvv,xvvv
1193 double precision xi,yi,zi
1194 double precision xrt,yrt,zrt
1195 real AA,BB
1196 real yvv(4),xvv(4)
1197
1198 * tollerance to consider the track inside the sensitive area
1199 real ptoll
1200 data ptoll/150./ !um
1201
1202 external nviewx,nviewy,acoordsi,dcoord
1203
1204 nplpt = nplPAM !plane
1205 viewx = nviewx(nplpt)
1206 viewy = nviewy(nplpt)
1207
1208 do il=1,nladders_view
1209 do is=1,2
1210
1211 do iv=1,4 !loop on sensor vertexes
1212 stripx = (il-c1(iv))*1024 + c1(iv) + c2(iv)*3
1213 stripy = (il-c3(iv))*1024 + c3(iv)
1214 c------------------------------------------------------------------------
1215 c (xi,yi,zi) = mechanical coordinates in the silicon sensor frame
1216 c------------------------------------------------------------------------
1217 if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
1218 $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips...
1219 c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips...
1220 print*,'whichsensor: ',
1221 $ ' WARNING: false X strip: strip ',stripx
1222 endif
1223 xi = acoordsi(stripx,viewx)
1224 yi = acoordsi(stripy,viewy)
1225 zi = 0.
1226 c------------------------------------------------------------------------
1227 c (xrt,yrt,zrt) = rototranslated coordinates in the silicon sensor frame
1228 c------------------------------------------------------------------------
1229 c N.B. I convert angles from microradiants to radiants
1230 xrt = xi
1231 $ - omega(nplpt,il,is)*yi
1232 $ + gamma(nplpt,il,is)*zi
1233 $ + dx(nplpt,il,is)
1234 yrt = omega(nplpt,il,is)*xi
1235 $ + yi
1236 $ - beta(nplpt,il,is)*zi
1237 $ + dy(nplpt,il,is)
1238 zrt = -gamma(nplpt,il,is)*xi
1239 $ + beta(nplpt,il,is)*yi
1240 $ + zi
1241 $ + dz(nplpt,il,is)
1242 c------------------------------------------------------------------------
1243 c measured coordinates (in cm) in PAMELA reference system
1244 c------------------------------------------------------------------------
1245 yvvv = dcoord(yrt,viewy,il,is) / 1.d4
1246 xvvv = dcoord(xrt,viewx,il,is) / 1.d4
1247
1248 yvv(iv)=sngl(yvvv)
1249 xvv(iv)=sngl(xvvv)
1250 c print*,'LADDER ',il,' SENSOR ',is,' vertexes >> '
1251 c $ ,iv,xvv(iv),yvv(iv)
1252 enddo !end loop on sensor vertexes
1253
1254 dtot=0.
1255 do iside=1,4,2 !loop on sensor edges X
1256 iv1=iside
1257 iv2=mod(iside,4)+1
1258 * straight line passing trhough two consecutive vertexes
1259 AA = (yvv(iv1)-yvv(iv2))/(xvv(iv1)-xvv(iv2))
1260 BB = yvv(iv1) - AA*xvv(iv1)
1261 * point along the straight line closer to the track
1262 xoo = (xPAM+AA*yPAM-AA*BB)/(1+AA**2)
1263 yoo = AA*xoo + BB
1264 * sum of the distances
1265 dtot = dtot +
1266 $ sqrt((xPAM-xoo)**2+(yPAM-yoo)**2)
1267 enddo !end loop on sensor edges
1268 do iside=2,4,2 !loop on sensor edges Y
1269 iv1=iside
1270 iv2=mod(iside,4)+1
1271 * straight line passing trhough two consecutive vertexes
1272 AA = (xvv(iv1)-xvv(iv2))/(yvv(iv1)-yvv(iv2))
1273 BB = xvv(iv1) - AA*yvv(iv1)
1274 * point along the straight line closer to the track
1275 yoo = (yPAM+AA*xPAM-AA*BB)/(1+AA**2)
1276 xoo = AA*yoo + BB
1277 * sum of the distances
1278 dtot = dtot +
1279 $ sqrt((xPAM-xoo)**2+(yPAM-yoo)**2)
1280 enddo !end loop on sensor edges
1281
1282
1283 * half-perimeter of sensitive area
1284 Perim =
1285 $ SiDimX - edgeX_l - edgeX_r
1286 $ +SiDimY - edgeY_l - edgeY_r
1287 Perim = (Perim + ptoll)/1.e4
1288 if(dtot.le.Perim)goto 100
1289
1290
1291 enddo
1292 enddo
1293
1294 ladder = 0
1295 sensor = 0
1296 goto 200
1297
1298 100 continue
1299 ladder = il
1300 sensor = is
1301
1302
1303 200 return
1304 end
1305
1306
1307
1308 *************************************************************************
1309
1310 subroutine reverse(v,n,temp) !invert the order of the components of v(n) vector
1311
1312 implicit double precision (A-H,O-Z)
1313
1314 dimension v(*)
1315 dimension temp(*)
1316 integer i,n
1317
1318 do i=1,n
1319 temp(i)=v(n+1-i)
1320 enddo
1321
1322 do i=1,n
1323 v(i)=temp(i)
1324 enddo
1325
1326 return
1327 end
1328
1329 *************************************************************************
1330 *************************************************************************
1331 *************************************************************************
1332 *************************************************************************
1333 *************************************************************************
1334 *************************************************************************
1335 *************************************************************************
1336 *************************************************************************
1337 *************************************************************************
1338 *************************************************************************
1339 *************************************************************************
1340 *************************************************************************
1341 *************************************************************************
1342 *************************************************************************
1343 *************************************************************************
1344 integer function ip_cp(id)
1345 *
1346 * given the couple id,
1347 * it returns the plane number
1348 *
1349 include 'commontracker.f'
1350 include 'level1.f'
1351 c include 'common_analysis.f'
1352 include 'common_momanhough.f'
1353
1354 ip_cp=0
1355 ncpp=0
1356 do ip=1,nplanes
1357 ncpp=ncpp+ncp_plane(ip)
1358 if(ncpp.ge.abs(id))then
1359 ip_cp=ip
1360 goto 100
1361 endif
1362 enddo
1363 100 continue
1364 return
1365 end
1366
1367
1368 integer function is_cp(id)
1369 *
1370 * given the couple id,
1371 * it returns the sensor number
1372 *
1373 is_cp=0
1374 if(id.lt.0)is_cp=1
1375 if(id.gt.0)is_cp=2
1376 if(id.eq.0)print*,'IS_CP ===> wrong couple id !!!'
1377
1378 return
1379 end
1380
1381
1382 integer function icp_cp(id)
1383 *
1384 * given the couple id,
1385 * it returns the id number ON THE PLANE
1386 *
1387 include 'commontracker.f'
1388 include 'level1.f'
1389 c include 'common_analysis.f'
1390 include 'common_momanhough.f'
1391
1392 icp_cp=0
1393
1394 ncpp=0
1395 do ip=1,nplanes
1396 ncppold=ncpp
1397 ncpp=ncpp+ncp_plane(ip)
1398 if(ncpp.ge.abs(id))then
1399 icp_cp=abs(id)-ncppold
1400 goto 100
1401 endif
1402 enddo
1403 100 continue
1404 return
1405 end
1406
1407
1408
1409 integer function id_cp(ip,icp,is)
1410 *
1411 * given a plane, a couple and the sensor
1412 * it returns the absolute couple id
1413 * negative if sensor =1
1414 * positive if sensor =2
1415 *
1416 include 'commontracker.f'
1417 include 'level1.f'
1418 c include 'calib.f'
1419 c include 'level1.f'
1420 c include 'common_analysis.f'
1421 include 'common_momanhough.f'
1422
1423 id_cp=0
1424
1425 if(ip.gt.1)then
1426 do i=1,ip-1
1427 id_cp = id_cp + ncp_plane(i)
1428 enddo
1429 endif
1430
1431 id_cp = id_cp + icp
1432
1433 if(is.eq.1) id_cp = -id_cp
1434
1435 return
1436 end
1437
1438
1439
1440
1441 *************************************************************************
1442 *************************************************************************
1443 *************************************************************************
1444 *************************************************************************
1445 *************************************************************************
1446 *************************************************************************
1447 c$$$ subroutine book_debug
1448 c$$$
1449 c$$$ include 'commontracker.f'
1450 c$$$ include 'common_momanhough.f'
1451 c$$$ include 'common_level2debug.f'
1452 c$$$
1453 c$$$ character*35 block1,block2,block3!,block4
1454 c$$$ $ ,block5!,block6
1455 c$$$
1456 c$$$* * * * * * * * * * * * * * * * * * * * * * * *
1457 c$$$* HOUGH TRANSFORM PARAMETERS
1458 c$$$
1459 c$$$ call HBOOK2(1003
1460 c$$$ $ ,'y vs tg thyz'
1461 c$$$ $ ,300,-1.,1. !x
1462 c$$$ $ ,3000,-70.,70.,0.) !y
1463 c$$$
1464 c$$$ call HBOOK1(1004
1465 c$$$ $ ,'Dy'
1466 c$$$ $ ,100,0.,2.,0.)
1467 c$$$
1468 c$$$ call HBOOK1(1005
1469 c$$$ $ ,'D thyz'
1470 c$$$ $ ,100,0.,.05,0.)
1471 c$$$
1472 c$$$
1473 c$$$
1474 c$$$* DEBUG ntuple:
1475 c$$$ call HBNT(ntp_level2+1,'LEVEL2',' ')
1476 c$$$
1477 c$$$ call HBNAME(ntp_level2+1,'EVENT',good2_nt,
1478 c$$$ $ 'GOOD2:L,NEV2:I')
1479 c$$$
1480 c$$$ 411 format('NDBLT:I::[0,',I5,']')
1481 c$$$ write(block1,411) ndblt_max_nt
1482 c$$$ call HBNAME(ntp_level2+1,'HOUGH YZ',ndblt_nt,
1483 c$$$ $ block1//'
1484 c$$$ $ ,ALFAYZ1(NDBLT):R
1485 c$$$ $ ,ALFAYZ2(NDBLT):R
1486 c$$$ $ ,DB_CLOUD(NDBLT):I
1487 c$$$ $ ')
1488 c$$$
1489 c$$$ 412 format('NTRPT:I::[0,',I5,']')
1490 c$$$ write(block2,412) ntrpt_max_nt
1491 c$$$ call HBNAME(ntp_level2+1,'HOUGH XZ',NTRPT_nt,
1492 c$$$ $ block2//'
1493 c$$$ $ ,ALFAXZ1(NTRPT):R
1494 c$$$ $ ,ALFAXZ2(NTRPT):R
1495 c$$$ $ ,ALFAXZ3(NTRPT):R
1496 c$$$ $ ,TR_CLOUD(NTRPT):I
1497 c$$$ $ ')
1498 c$$$
1499 c$$$
1500 c$$$ 413 format('NCLOUDS_YZ:I::[0,',I4,']')
1501 c$$$c$$$ 414 format('DB_CLOUD(',I4,'):I')
1502 c$$$ write(block3,413) ncloyz_max
1503 c$$$c$$$ write(block4,414) ndblt_max_nt
1504 c$$$ call HBNAME(ntp_level2+1,'CLOUD YZ',NCLOUDS_YZ,
1505 c$$$ $ block3//'
1506 c$$$ $ ,ALFAYZ1_AV(NCLOUDS_YZ):R
1507 c$$$ $ ,ALFAYZ2_AV(NCLOUDS_YZ):R
1508 c$$$ $ ,PTCLOUD_YZ(NCLOUDS_YZ):I'
1509 c$$$c$$$ $ ,'//block4
1510 c$$$ $ )
1511 c$$$
1512 c$$$ 415 format('NCLOUDS_XZ:I::[0,',I4,']')
1513 c$$$c$$$ 416 format('TR_CLOUD(',I5,'):I')
1514 c$$$ write(block5,415) ncloxz_max
1515 c$$$c$$$ write(block6,416) ntrpt_max_nt
1516 c$$$ call HBNAME(ntp_level2+1,'CLOUD XZ',NCLOUDS_XZ,
1517 c$$$ $ block5//'
1518 c$$$ $ ,ALFAXZ1_AV(NCLOUDS_XZ):R
1519 c$$$ $ ,ALFAXZ2_AV(NCLOUDS_XZ):R
1520 c$$$ $ ,ALFAXZ3_AV(NCLOUDS_XZ):R
1521 c$$$ $ ,PTCLOUD_XZ(NCLOUDS_XZ):I'
1522 c$$$c$$$ $ ,'//block6
1523 c$$$ $ )
1524 c$$$
1525 c$$$
1526 c$$$ return
1527 c$$$ end
1528 ***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...***
1529 *
1530 *
1531 *
1532 *
1533 *
1534 *
1535 *
1536 *
1537 *
1538 ***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...***
1539 c$$$ subroutine book_level2
1540 c$$$c*****************************************************
1541 c$$$cccccc 11/9/2005 modified by david fedele
1542 c$$$cccccc 07/10/2005 modified by elena vannuccini --> (2)
1543 c$$$c*****************************************************
1544 c$$$
1545 c$$$ include 'commontracker.f'
1546 c$$$ include 'common_momanhough.f'
1547 c$$$ include 'level2.f'
1548 c$$$
1549 c$$$ character*35 block1,block2
1550 c$$$
1551 c$$$c print*,'__________ booking LEVEL2 n-tuple __________'
1552 c$$$
1553 c$$$* LEVEL1 ntuple:
1554 c$$$ call HBNT(ntp_level2,'LEVEL2',' ')
1555 c$$$
1556 c$$$c*****************************************************
1557 c$$$cccccc 11/9/2005 modified by david fedele
1558 c$$$c call HBNAME(ntp_level2,'EVENT',good2,'GOOD2:L,NEV2:I')
1559 c$$$cccccc 06/10/2005 modified by elena vannuccini
1560 c$$$c call HBNAME(ntp_level2,'GENERAL',good2,'GOOD2:L,NEV2:I
1561 c$$$c $ ,WHIC_CALIB:I,SWCODE:I')
1562 c$$$ call HBNAME(ntp_level2,'GENERAL',good2,'GOOD2:L,NEV2:I
1563 c$$$ $ ,WHICH_CALIB:I,SWCODE:I,CRC(12):L')
1564 c$$$c*********************************************************
1565 c$$$
1566 c$$$
1567 c$$$c$$$# ifndef TEST2003
1568 c$$$c$$$
1569 c$$$c$$$ call HBNAME(ntp_level2,'CPU',pkt_type
1570 c$$$c$$$ $ ,'PKT_TYPE:I::[0,50]
1571 c$$$c$$$ $ ,PKT_NUM:I
1572 c$$$c$$$ $ ,OBT:I'//
1573 c$$$c$$$c********************************************************
1574 c$$$c$$$cccccc 11/9/2005 modified by david fedele
1575 c$$$c$$$c $ ,WHICH_CALIB:I::[0,50]')
1576 c$$$c$$$ $ ',CPU_CRC:L')
1577 c$$$c$$$c********************************************************
1578 c$$$c$$$
1579 c$$$c$$$# endif
1580 c$$$
1581 c$$$ 417 format('NTRK:I::[0,',I4,']')
1582 c$$$ 418 format(',IMAGE(NTRK):I::[0,',I4,']')
1583 c$$$ write(block1,417)NTRKMAX
1584 c$$$ write(block2,418)NTRKMAX
1585 c$$$ call HBNAME(ntp_level2,'TRACKS',NTRK,
1586 c$$$ $ block1//
1587 c$$$ $ block2//'
1588 c$$$ $ ,XM(6,NTRK):R
1589 c$$$ $ ,YM(6,NTRK):R
1590 c$$$ $ ,ZM(6,NTRK):R
1591 c$$$ $ ,RESX(6,NTRK):R
1592 c$$$ $ ,RESY(6,NTRK):R
1593 c$$$ $ ,AL(5,NTRK):R
1594 c$$$ $ ,COVAL(5,5,NTRK):R
1595 c$$$ $ ,CHI2(NTRK):R
1596 c$$$ $ ,XGOOD(6,NTRK):I::[0,1]
1597 c$$$ $ ,YGOOD(6,NTRK):I::[0,1]
1598 c$$$ $ ,XV(6,NTRK):R
1599 c$$$ $ ,YV(6,NTRK):R
1600 c$$$ $ ,ZV(6,NTRK):R
1601 c$$$ $ ,AXV(6,NTRK):R
1602 c$$$ $ ,AYV(6,NTRK):R'//
1603 c$$$c*****************************************************
1604 c$$$cccccc 11/9/2005 modified by david fedele
1605 c$$$c $ ,DEDXP(6,NTRK):R'//
1606 c$$$c $ ')
1607 c$$$ $ ',DEDX_X(6,NTRK):R
1608 c$$$ $ ,DEDX_Y(6,NTRK):R'//
1609 c$$$c****************************************************
1610 c$$$cccccc 06/10/2005 modified by elena vannuccini
1611 c$$$c $ ,CRC(12):L
1612 c$$$ $ ',BdL(NTRK):R'
1613 c$$$ $ )
1614 c$$$c****************************************************
1615 c$$$
1616 c$$$
1617 c$$$ call HBNAME(ntp_level2,'SINGLETX',nclsx,
1618 c$$$c*****************************************************
1619 c$$$cccccc 11/9/2005 modified by david fedele
1620 c$$$c $ 'NCLSX(6):I,NCLSY(6):I')
1621 c$$$ $ 'NCLSX:I::[0,500],PLANEX(NCLSX):I
1622 c$$$ $ ,XS(2,NCLSX):R,SGNLXS(NCLSX):R') !(2)
1623 c$$$c $ ,XS(NCLSX):R,SGNLXS(NCLSX):R') !(2)
1624 c$$$ call HBNAME(ntp_level2,'SINGLETY',nclsy,
1625 c$$$ $ 'NCLSY:I::[0,500],PLANEY(NCLSY):I
1626 c$$$ $ ,YS(2,NCLSY):R,SGNLYS(NCLSY):R') !(2)
1627 c$$$c $ ,YS(NCLSY):R,SGNLYS(NCLSY):R') !(2)
1628 c$$$ return
1629 c$$$ end
1630
1631 c$$$ subroutine fill_level2_clouds
1632 c$$$c*****************************************************
1633 c$$$c 29/11/2005 created by elena vannuccini
1634 c$$$c*****************************************************
1635 c$$$
1636 c$$$* -------------------------------------------------------
1637 c$$$* This routine fills the variables related to the hough
1638 c$$$* transform, for the debig n-tuple
1639 c$$$* -------------------------------------------------------
1640 c$$$
1641 c$$$ include 'commontracker.f'
1642 c$$$ include 'common_momanhough.f'
1643 c$$$ include 'common_level2debug.f'
1644 c$$$ include 'level2.f'
1645 c$$$
1646 c$$$ good2_nt=.true.!good2
1647 c$$$c nev2_nt=nev2
1648 c$$$
1649 c$$$ if(.false.
1650 c$$$ $ .or.ntrpt.gt.ntrpt_max_nt
1651 c$$$ $ .or.ndblt.gt.ndblt_max_nt
1652 c$$$ $ .or.NCLOUDS_XZ.gt.ncloxz_max
1653 c$$$ $ .or.NCLOUDS_yZ.gt.ncloyz_max
1654 c$$$ $ )then
1655 c$$$ good2_nt=.false.
1656 c$$$ ntrpt_nt=0
1657 c$$$ ndblt_nt=0
1658 c$$$ NCLOUDS_XZ_nt=0
1659 c$$$ NCLOUDS_YZ_nt=0
1660 c$$$ else
1661 c$$$ ndblt_nt=ndblt
1662 c$$$ ntrpt_nt=ntrpt
1663 c$$$ if(ndblt.ne.0)then
1664 c$$$ do id=1,ndblt
1665 c$$$ alfayz1_nt(id)=alfayz1(id) !Y0
1666 c$$$ alfayz2_nt(id)=alfayz2(id) !tg theta-yz
1667 c$$$c db_cloud_nt(id)=db_cloud(id)
1668 c$$$ enddo
1669 c$$$ endif
1670 c$$$ if(ndblt.ne.0)then
1671 c$$$ do it=1,ntrpt
1672 c$$$ alfaxz1_nt(it)=alfaxz1(it) !X0
1673 c$$$ alfaxz2_nt(it)=alfaxz2(it) !tg theta-xz
1674 c$$$ alfaxz3_nt(it)=alfaxz3(it) !1/r
1675 c$$$c tr_cloud_nt(it)=tr_cloud(it)
1676 c$$$ enddo
1677 c$$$ endif
1678 c$$$ nclouds_yz_nt=nclouds_yz
1679 c$$$ nclouds_xz_nt=nclouds_xz
1680 c$$$ if(nclouds_yz.ne.0)then
1681 c$$$ nnn=0
1682 c$$$ do iyz=1,nclouds_yz
1683 c$$$ ptcloud_yz_nt(iyz)=ptcloud_yz(iyz)
1684 c$$$ alfayz1_av_nt(iyz)=alfayz1_av(iyz)
1685 c$$$ alfayz2_av_nt(iyz)=alfayz2_av(iyz)
1686 c$$$ nnn=nnn+ptcloud_yz(iyz)
1687 c$$$ enddo
1688 c$$$ do ipt=1,nnn
1689 c$$$ db_cloud_nt(ipt)=db_cloud(ipt)
1690 c$$$ enddo
1691 c$$$c print*,'#### ntupla #### ptcloud_yz '
1692 c$$$c $ ,(ptcloud_yz(i),i=1,nclouds_yz)
1693 c$$$c print*,'#### ntupla #### db_cloud '
1694 c$$$c $ ,(db_cloud(i),i=1,nnn)
1695 c$$$ endif
1696 c$$$ if(nclouds_xz.ne.0)then
1697 c$$$ nnn=0
1698 c$$$ do ixz=1,nclouds_xz
1699 c$$$ ptcloud_xz_nt(ixz)=ptcloud_xz(ixz)
1700 c$$$ alfaxz1_av_nt(ixz)=alfaxz1_av(ixz)
1701 c$$$ alfaxz2_av_nt(ixz)=alfaxz2_av(ixz)
1702 c$$$ alfaxz3_av_nt(ixz)=alfaxz3_av(ixz)
1703 c$$$ nnn=nnn+ptcloud_xz(ixz)
1704 c$$$ enddo
1705 c$$$ do ipt=1,nnn
1706 c$$$ tr_cloud_nt(ipt)=tr_cloud(ipt)
1707 c$$$ enddo
1708 c$$$c print*,'#### ntupla #### ptcloud_xz '
1709 c$$$c $ ,(ptcloud_xz(i),i=1,nclouds_xz)
1710 c$$$c print*,'#### ntupla #### tr_cloud '
1711 c$$$c $ ,(tr_cloud(i),i=1,nnn)
1712 c$$$ endif
1713 c$$$ endif
1714 c$$$ end
1715
1716
1717 ***************************************************
1718 * *
1719 * *
1720 * *
1721 * *
1722 * *
1723 * *
1724 **************************************************
1725
1726 subroutine cl_to_couples(iflag)
1727
1728 include 'commontracker.f'
1729 include 'level1.f'
1730 include 'common_momanhough.f'
1731 c include 'momanhough_init.f'
1732 include 'calib.f'
1733 c include 'level1.f'
1734
1735 * output flag
1736 * --------------
1737 * 0 = good event
1738 * 1 = bad event
1739 * --------------
1740 integer iflag
1741
1742 integer badseed,badclx,badcly
1743
1744 * init variables
1745 ncp_tot=0
1746 do ip=1,nplanes
1747 do ico=1,ncouplemax
1748 clx(ip,ico)=0
1749 cly(ip,ico)=0
1750 enddo
1751 ncp_plane(ip)=0
1752 do icl=1,nclstrmax_level2
1753 cls(ip,icl)=1
1754 enddo
1755 ncls(ip)=0
1756 enddo
1757 do icl=1,nclstrmax_level2
1758 cl_single(icl) = 1
1759 cl_good(icl) = 0
1760 enddo
1761 do iv=1,nviews
1762 ncl_view(iv) = 0
1763 mask_view(iv) = 0 !all included
1764 enddo
1765
1766 * count number of cluster per view
1767 do icl=1,nclstr1
1768 ncl_view(VIEW(icl)) = ncl_view(VIEW(icl)) + 1
1769 enddo
1770 * mask views with too many clusters
1771 do iv=1,nviews
1772 if( ncl_view(iv).gt. nclustermax)then
1773 mask_view(iv) = 1
1774 if(DEBUG)print*,' * WARNING * cl_to_couple: n.clusters > '
1775 $ ,nclustermax,' on view ', iv,' --> masked!'
1776 endif
1777 enddo
1778
1779
1780 * start association
1781 ncouples=0
1782 do icx=1,nclstr1 !loop on cluster (X)
1783 if(mod(VIEW(icx),2).eq.1)goto 10
1784
1785 * ----------------------------------------------------
1786 * jump masked views (X VIEW)
1787 * ----------------------------------------------------
1788 if( mask_view(VIEW(icx)).ne.0 ) goto 10
1789 * ----------------------------------------------------
1790 * cut on charge (X VIEW)
1791 * ----------------------------------------------------
1792 if(dedx(icx).lt.dedx_x_min)then
1793 cl_single(icx)=0
1794 goto 10
1795 endif
1796 * ----------------------------------------------------
1797 * cut BAD (X VIEW)
1798 * ----------------------------------------------------
1799 badseed=BAD(VIEW(icx),nvk(MAXS(icx)),nst(MAXS(icx)))
1800 ifirst=INDSTART(icx)
1801 if(icx.ne.nclstr1) then
1802 ilast=INDSTART(icx+1)-1
1803 else
1804 ilast=TOTCLLENGTH
1805 endif
1806 badclx=badseed
1807 do igood=-ngoodstr,ngoodstr
1808 ibad=1
1809 if((INDMAX(icx)+igood).gt.ifirst.and.
1810 $ (INDMAX(icx)+igood).lt.ilast.and.
1811 $ .true.)then
1812 ibad=BAD(VIEW(icx),
1813 $ nvk(MAXS(icx)+igood),
1814 $ nst(MAXS(icx)+igood))
1815 endif
1816 badclx=badclx*ibad
1817 enddo
1818 * ----------------------------------------------------
1819 * >>> eliminato il taglio sulle BAD <<<
1820 * ----------------------------------------------------
1821 c if(badcl.eq.0)then
1822 c cl_single(icx)=0
1823 c goto 10
1824 c endif
1825 * ----------------------------------------------------
1826
1827 cl_good(icx)=1
1828 nplx=npl(VIEW(icx))
1829 nldx=nld(MAXS(icx),VIEW(icx))
1830
1831 do icy=1,nclstr1 !loop on cluster (Y)
1832 if(mod(VIEW(icy),2).eq.0)goto 20
1833
1834 * ----------------------------------------------------
1835 * jump masked views (Y VIEW)
1836 * ----------------------------------------------------
1837 if( mask_view(VIEW(icy)).ne.0 ) goto 20
1838
1839 * ----------------------------------------------------
1840 * cut on charge (Y VIEW)
1841 * ----------------------------------------------------
1842 if(dedx(icy).lt.dedx_y_min)then
1843 cl_single(icy)=0
1844 goto 20
1845 endif
1846 * ----------------------------------------------------
1847 * cut BAD (Y VIEW)
1848 * ----------------------------------------------------
1849 badseed=BAD(VIEW(icy),nvk(MAXS(icy)),nst(MAXS(icy)))
1850 ifirst=INDSTART(icy)
1851 if(icy.ne.nclstr1) then
1852 ilast=INDSTART(icy+1)-1
1853 else
1854 ilast=TOTCLLENGTH
1855 endif
1856 badcly=badseed
1857 do igood=-ngoodstr,ngoodstr
1858 ibad=1
1859 if((INDMAX(icy)+igood).gt.ifirst.and.
1860 $ (INDMAX(icy)+igood).lt.ilast.and.
1861 $ .true.)
1862 $ ibad=BAD(VIEW(icy),
1863 $ nvk(MAXS(icy)+igood),
1864 $ nst(MAXS(icy)+igood))
1865 badcly=badcly*ibad
1866 enddo
1867 * ----------------------------------------------------
1868 * >>> eliminato il taglio sulle BAD <<<
1869 * ----------------------------------------------------
1870 c if(badcl.eq.0)then
1871 c cl_single(icy)=0
1872 c goto 20
1873 c endif
1874 * ----------------------------------------------------
1875
1876 cl_good(icy)=1
1877 nply=npl(VIEW(icy))
1878 nldy=nld(MAXS(icy),VIEW(icy))
1879
1880 * ----------------------------------------------
1881 * CONDITION TO FORM A COUPLE
1882 * ----------------------------------------------
1883 * geometrical consistency (same plane and ladder)
1884 if(nply.eq.nplx.and.nldy.eq.nldx)then
1885 * charge correlation
1886 * (modified to be applied only below saturation... obviously)
1887
1888 if( .not.(dedx(icy).gt.chsaty.and.dedx(icx).gt.chsatx)
1889 $ .and.
1890 $ .not.(dedx(icy).lt.chmipy.and.dedx(icx).lt.chmipx)
1891 $ .and.
1892 $ (badclx.eq.1.and.badcly.eq.1)
1893 $ .and.
1894 $ .true.)then
1895
1896 ddd=(dedx(icy)
1897 $ -kch(nplx,nldx)*dedx(icx)-cch(nplx,nldx))
1898 ddd=ddd/sqrt(kch(nplx,nldx)**2+1)
1899
1900 c cut = chcut * sch(nplx,nldx)
1901
1902 sss=(kch(nplx,nldx)*dedx(icy)+dedx(icx)
1903 $ -kch(nplx,nldx)*cch(nplx,nldx))
1904 sss=sss/sqrt(kch(nplx,nldx)**2+1)
1905 cut = chcut * (16 + sss/50.)
1906
1907 if(abs(ddd).gt.cut)then
1908 goto 20 !charge not consistent
1909 endif
1910 endif
1911
1912 * ------------------> COUPLE <------------------
1913 * check to do not overflow vector dimentions
1914 c$$$ if(ncp_plane(nplx).gt.ncouplemax)then
1915 c$$$ if(DEBUG)print*,
1916 c$$$ $ ' ** warning ** number of identified'//
1917 c$$$ $ ' couples on plane ',nplx,
1918 c$$$ $ ' exceeds vector dimention'//
1919 c$$$ $ ' ( ',ncouplemax,' )'
1920 c$$$c good2=.false.
1921 c$$$c goto 880 !fill ntp and go to next event
1922 c$$$ iflag=1
1923 c$$$ return
1924 c$$$ endif
1925
1926 if(ncp_plane(nplx).eq.ncouplemax)then
1927 if(verbose)print*,
1928 $ '** warning ** number of identified '//
1929 $ 'couples on plane ',nplx,
1930 $ 'exceeds vector dimention '
1931 $ ,'( ',ncouplemax,' )'
1932 c good2=.false.
1933 c goto 880 !fill ntp and go to next event
1934 mask_view(nviewx(nplx)) = 2
1935 mask_view(nviewy(nply)) = 2
1936 c iflag=1
1937 c return
1938 endif
1939
1940 ncp_plane(nplx) = ncp_plane(nplx) + 1
1941 clx(nplx,ncp_plane(nplx))=icx
1942 cly(nply,ncp_plane(nplx))=icy
1943 cl_single(icx)=0
1944 cl_single(icy)=0
1945 endif
1946 * ----------------------------------------------
1947
1948 20 continue
1949 enddo !end loop on clusters(Y)
1950
1951 10 continue
1952 enddo !end loop on clusters(X)
1953
1954
1955 do icl=1,nclstr1
1956 if(cl_single(icl).eq.1)then
1957 ip=npl(VIEW(icl))
1958 ncls(ip)=ncls(ip)+1
1959 cls(ip,ncls(ip))=icl
1960 endif
1961 enddo
1962
1963
1964 if(DEBUG)then
1965 print*,'clusters ',nclstr1
1966 print*,'good ',(cl_good(i),i=1,nclstr1)
1967 print*,'singles ',(cl_single(i),i=1,nclstr1)
1968 print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes)
1969 endif
1970
1971 do ip=1,6
1972 ncp_tot = ncp_tot + ncp_plane(ip)
1973 enddo
1974 c if(ncp_tot.gt.ncp_max)goto 100!next event (TEMPORANEO!!!)
1975
1976 c$$$ if(ncp_tot.gt.ncp_max)then
1977 c$$$ if(verbose)print*,
1978 c$$$ $ '** warning ** number of identified '//
1979 c$$$ $ 'couples exceeds upper limit for Hough tr. '
1980 c$$$ $ ,'( ',ncp_max,' )'
1981 c$$$ iflag=1
1982 c$$$ return
1983 c$$$ endif
1984
1985 return
1986 end
1987
1988 ***************************************************
1989 * *
1990 * *
1991 * *
1992 * *
1993 * *
1994 * *
1995 **************************************************
1996 c$$$ subroutine cl_to_couples_nocharge(iflag)
1997 c$$$
1998 c$$$ include 'commontracker.f'
1999 c$$$ include 'level1.f'
2000 c$$$ include 'common_momanhough.f'
2001 c$$$c include 'momanhough_init.f'
2002 c$$$ include 'calib.f'
2003 c$$$c include 'level1.f'
2004 c$$$
2005 c$$$
2006 c$$$* output flag
2007 c$$$* --------------
2008 c$$$* 0 = good event
2009 c$$$* 1 = bad event
2010 c$$$* --------------
2011 c$$$ integer iflag
2012 c$$$
2013 c$$$ integer badseed,badcl
2014 c$$$
2015 c$$$* init variables
2016 c$$$ ncp_tot=0
2017 c$$$ do ip=1,nplanes
2018 c$$$ do ico=1,ncouplemax
2019 c$$$ clx(ip,ico)=0
2020 c$$$ cly(ip,ico)=0
2021 c$$$ enddo
2022 c$$$ ncp_plane(ip)=0
2023 c$$$ do icl=1,nclstrmax_level2
2024 c$$$ cls(ip,icl)=1
2025 c$$$ enddo
2026 c$$$ ncls(ip)=0
2027 c$$$ enddo
2028 c$$$ do icl=1,nclstrmax_level2
2029 c$$$ cl_single(icl)=1
2030 c$$$ cl_good(icl)=0
2031 c$$$ enddo
2032 c$$$
2033 c$$$* start association
2034 c$$$ ncouples=0
2035 c$$$ do icx=1,nclstr1 !loop on cluster (X)
2036 c$$$ if(mod(VIEW(icx),2).eq.1)goto 10
2037 c$$$
2038 c$$$* ----------------------------------------------------
2039 c$$$* cut on charge (X VIEW)
2040 c$$$ if(dedx(icx).lt.dedx_x_min)then
2041 c$$$ cl_single(icx)=0
2042 c$$$ goto 10
2043 c$$$ endif
2044 c$$$* cut BAD (X VIEW)
2045 c$$$ badseed=BAD(VIEW(icx),nvk(MAXS(icx)),nst(MAXS(icx)))
2046 c$$$ ifirst=INDSTART(icx)
2047 c$$$ if(icx.ne.nclstr1) then
2048 c$$$ ilast=INDSTART(icx+1)-1
2049 c$$$ else
2050 c$$$ ilast=TOTCLLENGTH
2051 c$$$ endif
2052 c$$$ badcl=badseed
2053 c$$$ do igood=-ngoodstr,ngoodstr
2054 c$$$ ibad=1
2055 c$$$ if((INDMAX(icx)+igood).gt.ifirst.and.
2056 c$$$ $ (INDMAX(icx)+igood).lt.ilast.and.
2057 c$$$ $ .true.)then
2058 c$$$ ibad=BAD(VIEW(icx),
2059 c$$$ $ nvk(MAXS(icx)+igood),
2060 c$$$ $ nst(MAXS(icx)+igood))
2061 c$$$ endif
2062 c$$$ badcl=badcl*ibad
2063 c$$$ enddo
2064 c$$$ if(badcl.eq.0)then !<<<<<<<<<<<<<< BAD cut
2065 c$$$ cl_single(icx)=0 !<<<<<<<<<<<<<< BAD cut
2066 c$$$ goto 10 !<<<<<<<<<<<<<< BAD cut
2067 c$$$ endif !<<<<<<<<<<<<<< BAD cut
2068 c$$$* ----------------------------------------------------
2069 c$$$
2070 c$$$ cl_good(icx)=1
2071 c$$$ nplx=npl(VIEW(icx))
2072 c$$$ nldx=nld(MAXS(icx),VIEW(icx))
2073 c$$$
2074 c$$$ do icy=1,nclstr1 !loop on cluster (Y)
2075 c$$$ if(mod(VIEW(icy),2).eq.0)goto 20
2076 c$$$
2077 c$$$* ----------------------------------------------------
2078 c$$$* cut on charge (Y VIEW)
2079 c$$$ if(dedx(icy).lt.dedx_y_min)then
2080 c$$$ cl_single(icy)=0
2081 c$$$ goto 20
2082 c$$$ endif
2083 c$$$* cut BAD (Y VIEW)
2084 c$$$ badseed=BAD(VIEW(icy),nvk(MAXS(icy)),nst(MAXS(icy)))
2085 c$$$ ifirst=INDSTART(icy)
2086 c$$$ if(icy.ne.nclstr1) then
2087 c$$$ ilast=INDSTART(icy+1)-1
2088 c$$$ else
2089 c$$$ ilast=TOTCLLENGTH
2090 c$$$ endif
2091 c$$$ badcl=badseed
2092 c$$$ do igood=-ngoodstr,ngoodstr
2093 c$$$ ibad=1
2094 c$$$ if((INDMAX(icy)+igood).gt.ifirst.and.
2095 c$$$ $ (INDMAX(icy)+igood).lt.ilast.and.
2096 c$$$ $ .true.)
2097 c$$$ $ ibad=BAD(VIEW(icy),
2098 c$$$ $ nvk(MAXS(icy)+igood),
2099 c$$$ $ nst(MAXS(icy)+igood))
2100 c$$$ badcl=badcl*ibad
2101 c$$$ enddo
2102 c$$$ if(badcl.eq.0)then !<<<<<<<<<<<<<< BAD cut
2103 c$$$ cl_single(icy)=0 !<<<<<<<<<<<<<< BAD cut
2104 c$$$ goto 20 !<<<<<<<<<<<<<< BAD cut
2105 c$$$ endif !<<<<<<<<<<<<<< BAD cut
2106 c$$$* ----------------------------------------------------
2107 c$$$
2108 c$$$
2109 c$$$ cl_good(icy)=1
2110 c$$$ nply=npl(VIEW(icy))
2111 c$$$ nldy=nld(MAXS(icy),VIEW(icy))
2112 c$$$
2113 c$$$* ----------------------------------------------
2114 c$$$* CONDITION TO FORM A COUPLE
2115 c$$$* ----------------------------------------------
2116 c$$$* geometrical consistency (same plane and ladder)
2117 c$$$ if(nply.eq.nplx.and.nldy.eq.nldx)then
2118 c$$$* charge correlation
2119 c$$$* ===========================================================
2120 c$$$* this version of the subroutine is used for the calibration
2121 c$$$* thus charge-correlation selection is obviously removed
2122 c$$$* ===========================================================
2123 c$$$c$$$ ddd=(dedx(icy)
2124 c$$$c$$$ $ -kch(nplx,nldx)*dedx(icx)-cch(nplx,nldx))
2125 c$$$c$$$ ddd=ddd/sqrt(kch(nplx,nldx)**2+1)
2126 c$$$c$$$ cut=chcut*sch(nplx,nldx)
2127 c$$$c$$$ if(abs(ddd).gt.cut)goto 20 !charge not consistent
2128 c$$$* ===========================================================
2129 c$$$
2130 c$$$
2131 c$$$* ------------------> COUPLE <------------------
2132 c$$$* check to do not overflow vector dimentions
2133 c$$$c$$$ if(ncp_plane(nplx).gt.ncouplemax)then
2134 c$$$c$$$ if(DEBUG)print*,
2135 c$$$c$$$ $ ' ** warning ** number of identified'//
2136 c$$$c$$$ $ ' couples on plane ',nplx,
2137 c$$$c$$$ $ ' exceeds vector dimention'//
2138 c$$$c$$$ $ ' ( ',ncouplemax,' )'
2139 c$$$c$$$c good2=.false.
2140 c$$$c$$$c goto 880 !fill ntp and go to next event
2141 c$$$c$$$ iflag=1
2142 c$$$c$$$ return
2143 c$$$c$$$ endif
2144 c$$$
2145 c$$$ if(ncp_plane(nplx).eq.ncouplemax)then
2146 c$$$ if(verbose)print*,
2147 c$$$ $ '** warning ** number of identified '//
2148 c$$$ $ 'couples on plane ',nplx,
2149 c$$$ $ 'exceeds vector dimention '
2150 c$$$ $ ,'( ',ncouplemax,' )'
2151 c$$$c good2=.false.
2152 c$$$c goto 880 !fill ntp and go to next event
2153 c$$$ iflag=1
2154 c$$$ return
2155 c$$$ endif
2156 c$$$
2157 c$$$ ncp_plane(nplx) = ncp_plane(nplx) + 1
2158 c$$$ clx(nplx,ncp_plane(nplx))=icx
2159 c$$$ cly(nply,ncp_plane(nplx))=icy
2160 c$$$ cl_single(icx)=0
2161 c$$$ cl_single(icy)=0
2162 c$$$ endif
2163 c$$$* ----------------------------------------------
2164 c$$$
2165 c$$$ 20 continue
2166 c$$$ enddo !end loop on clusters(Y)
2167 c$$$
2168 c$$$ 10 continue
2169 c$$$ enddo !end loop on clusters(X)
2170 c$$$
2171 c$$$
2172 c$$$ do icl=1,nclstr1
2173 c$$$ if(cl_single(icl).eq.1)then
2174 c$$$ ip=npl(VIEW(icl))
2175 c$$$ ncls(ip)=ncls(ip)+1
2176 c$$$ cls(ip,ncls(ip))=icl
2177 c$$$ endif
2178 c$$$ enddo
2179 c$$$
2180 c$$$
2181 c$$$ if(DEBUG)then
2182 c$$$ print*,'clusters ',nclstr1
2183 c$$$ print*,'good ',(cl_good(i),i=1,nclstr1)
2184 c$$$ print*,'singles ',(cl_single(i),i=1,nclstr1)
2185 c$$$ print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes)
2186 c$$$ endif
2187 c$$$
2188 c$$$ do ip=1,6
2189 c$$$ ncp_tot=ncp_tot+ncp_plane(ip)
2190 c$$$ enddo
2191 c$$$c if(ncp_tot.gt.ncp_max)goto 100!next event (TEMPORANEO!!!)
2192 c$$$
2193 c$$$ if(ncp_tot.gt.ncp_max)then
2194 c$$$ if(verbose)print*,
2195 c$$$ $ '** warning ** number of identified '//
2196 c$$$ $ 'couples exceeds upper limit for Hough tr. '
2197 c$$$ $ ,'( ',ncp_max,' )'
2198 c$$$c good2=.false.
2199 c$$$c goto 880 !fill ntp and go to next event
2200 c$$$ iflag=1
2201 c$$$ return
2202 c$$$ endif
2203 c$$$
2204 c$$$ return
2205 c$$$ end
2206 c$$$
2207
2208 ***************************************************
2209 * *
2210 * *
2211 * *
2212 * *
2213 * *
2214 * *
2215 **************************************************
2216
2217 subroutine cp_to_doubtrip(iflag)
2218 c*****************************************************
2219 c 02/02/2006 modified by Elena Vannuccini --> (1)
2220 c*****************************************************
2221
2222 include 'commontracker.f'
2223 include 'level1.f'
2224 include 'common_momanhough.f'
2225 c include 'momanhough_init.f'
2226 include 'common_xyzPAM.f'
2227 include 'common_mini_2.f'
2228 include 'calib.f'
2229 c include 'level1.f'
2230
2231
2232 * output flag
2233 * --------------
2234 * 0 = good event
2235 * 1 = bad event
2236 * --------------
2237 integer iflag
2238
2239
2240 * -----------------------------
2241 * DOUBLETS/TRIPLETS coordinates
2242 c double precision xm1,ym1,zm1
2243 c double precision xm2,ym2,zm2
2244 c double precision xm3,ym3,zm3
2245
2246 real xm1,ym1,zm1
2247 real xm2,ym2,zm2
2248 real xm3,ym3,zm3
2249 * -----------------------------
2250 * variable needed for tricircle:
2251 real xp(3),zp(3)!TRIPLETS coordinates, to find a circle
2252 EQUIVALENCE (xm1,xp(1))
2253 EQUIVALENCE (xm2,xp(2))
2254 EQUIVALENCE (xm3,xp(3))
2255 EQUIVALENCE (zm1,zp(1))
2256 EQUIVALENCE (zm2,zp(2))
2257 EQUIVALENCE (zm3,zp(3))
2258 real angp(3),resp(3),chi
2259 real xc,zc,radius
2260 * -----------------------------
2261
2262
2263
2264 ndblt=0 !number of doublets
2265 ntrpt=0 !number of triplets
2266
2267 do ip1=1,(nplanes-1) !loop on planes - COPPIA 1
2268 do is1=1,2 !loop on sensors - COPPIA 1
2269
2270 do icp1=1,ncp_plane(ip1) !loop on COPPIA 1
2271 icx1=clx(ip1,icp1)
2272 icy1=cly(ip1,icp1)
2273 c call xyz_PAM(icx1,icy1,is1,'COG2','COG2',0.,0.)!(1)
2274 call xyz_PAM(icx1,icy1,is1,PFAdef,PFAdef,0.,0.) !(1)
2275 xm1=xPAM
2276 ym1=yPAM
2277 zm1=zPAM
2278 c print*,'***',is1,xm1,ym1,zm1
2279 do ip2=(ip1+1),nplanes !loop on planes - COPPIA 2
2280 do is2=1,2 !loop on sensors -ndblt COPPIA 2
2281
2282 do icp2=1,ncp_plane(ip2) !loop on COPPIA 2
2283 icx2=clx(ip2,icp2)
2284 icy2=cly(ip2,icp2)
2285 c call xyz_PAM
2286 c $ (icx2,icy2,is2,'COG2','COG2',0.,0.)!(1)
2287 call xyz_PAM
2288 $ (icx2,icy2,is2,PFAdef,PFAdef,0.,0.) !(1)
2289 xm2=xPAM
2290 ym2=yPAM
2291 zm2=zPAM
2292
2293 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2294 * track parameters on Y VIEW
2295 * (2 couples needed)
2296 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2297 if(ndblt.eq.ndblt_max)then
2298 if(verbose)print*,
2299 $ '** warning ** number of identified '//
2300 $ 'doublets exceeds vector dimention '
2301 $ ,'( ',ndblt_max,' )'
2302 c good2=.false.
2303 c goto 880 !fill ntp and go to next event
2304 do iv=1,12
2305 mask_view(iv) = 3
2306 enddo
2307 iflag=1
2308 return
2309 endif
2310 ndblt = ndblt + 1
2311 * store doublet info
2312 cpyz1(ndblt)=id_cp(ip1,icp1,is1)
2313 cpyz2(ndblt)=id_cp(ip2,icp2,is2)
2314 * tg(th_yz)
2315 alfayz2(ndblt)=(ym1-ym2)/(zm1-zm2)
2316 * y0 (cm)
2317 alfayz1(ndblt)=alfayz2(ndblt)*(zini-zm1)+ym1
2318
2319 **** -----------------------------------------------****
2320 **** reject non phisical couples ****
2321 **** -----------------------------------------------****
2322 if(
2323 $ abs(alfayz2(ndblt)).gt.alfyz2_max
2324 $ .or.
2325 $ abs(alfayz1(ndblt)).gt.alfyz1_max
2326 $ )ndblt = ndblt-1
2327
2328 c$$$ if(iev.eq.33)then
2329 c$$$ print*,'********* ',ndblt,' -- ',icp1,icp2,is1,is2
2330 c$$$ $ ,' || ',icx1,icy1,icx2,icy2
2331 c$$$ $ ,' || ',xm1,ym1,xm2,ym2
2332 c$$$ $ ,' || ',alfayz2(ndblt),alfayz1(ndblt)
2333 c$$$ endif
2334 c$$$
2335 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2336 * track parameters on Y VIEW - end
2337 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2338
2339
2340 if(ip2.eq.nplanes)goto 30 !no possible combination with 3 couples
2341 do ip3=(ip2+1),nplanes !loop on planes - COPPIA 3
2342 do is3=1,2 !loop on sensors - COPPIA 3
2343
2344 do icp3=1,ncp_plane(ip3) !loop on COPPIA 3
2345 icx3=clx(ip3,icp3)
2346 icy3=cly(ip3,icp3)
2347 c call xyz_PAM
2348 c $ (icx3,icy3,is3,'COG2','COG2',0.,0.)!(1)
2349 call xyz_PAM
2350 $ (icx3,icy3,is3,PFAdef,PFAdef,0.,0.) !(1)
2351 xm3=xPAM
2352 ym3=yPAM
2353 zm3=zPAM
2354 * find the circle passing through the three points
2355 call tricircle(3,xp,zp,angp,resp,chi
2356 $ ,xc,zc,radius,iflag)
2357 c print*,xc,zc,radius
2358 * the circle must intersect the reference plane
2359 if(
2360 c $ (xc.le.-1.*xclimit.or.
2361 c $ xc.ge.xclimit).and.
2362 $ radius**2.ge.(ZINI-zc)**2.and.
2363 $ iflag.eq.0.and.
2364 $ .true.)then
2365
2366 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2367 * track parameters on X VIEW
2368 * (3 couples needed)
2369 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2370 if(ntrpt.eq.ntrpt_max)then
2371 if(verbose)print*,
2372 $ '** warning ** number of identified '//
2373 $ 'triplets exceeds vector dimention '
2374 $ ,'( ',ntrpt_max,' )'
2375 c good2=.false.
2376 c goto 880 !fill ntp and go to next event
2377 do iv=1,nviews
2378 mask_view(iv) = 4
2379 enddo
2380 iflag=1
2381 return
2382 endif
2383 ntrpt = ntrpt +1
2384 * store triplet info
2385 cpxz1(ntrpt)=id_cp(ip1,icp1,is1)
2386 cpxz2(ntrpt)=id_cp(ip2,icp2,is2)
2387 cpxz3(ntrpt)=id_cp(ip3,icp3,is3)
2388
2389 if(xc.lt.0)then
2390 *************POSITIVE DEFLECTION
2391 alfaxz1(ntrpt) = xc+sqrt(radius**2-(ZINI-zc)**2)
2392 alfaxz2(ntrpt) = (ZINI-zc)/sqrt(radius**2-(ZINI-zc)**2)
2393 alfaxz3(ntrpt) = 1/radius
2394 else
2395 *************NEGATIVE DEFLECTION
2396 alfaxz1(ntrpt) = xc-sqrt(radius**2-(ZINI-zc)**2)
2397 alfaxz2(ntrpt) = -(ZINI-zc)/sqrt(radius**2-(ZINI-zc)**2)
2398 alfaxz3(ntrpt) = -1/radius
2399 endif
2400
2401 **** -----------------------------------------------****
2402 **** reject non phisical triplets ****
2403 **** -----------------------------------------------****
2404 if(
2405 $ abs(alfaxz2(ntrpt)).gt.alfxz2_max
2406 $ .or.
2407 $ abs(alfaxz1(ntrpt)).gt.alfxz1_max
2408 $ )ntrpt = ntrpt-1
2409
2410
2411 c print*,alfaxz1(ntrpt),alfaxz2(ntrpt),alfaxz3(ntrpt)
2412 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2413 * track parameters on X VIEW - end
2414 * - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2415 endif
2416 enddo !end loop on COPPIA 3
2417 enddo !end loop on sensors - COPPIA 3
2418 enddo !end loop on planes - COPPIA 3
2419 30 continue
2420
2421 1 enddo !end loop on COPPIA 2
2422 enddo !end loop on sensors - COPPIA 2
2423 enddo !end loop on planes - COPPIA 2
2424
2425 enddo !end loop on COPPIA1
2426 enddo !end loop on sensors - COPPIA 1
2427 enddo !end loop on planes - COPPIA 1
2428
2429 if(DEBUG)then
2430 print*,'--- doublets ',ndblt
2431 print*,'--- triplets ',ntrpt
2432 endif
2433
2434 c goto 880 !ntp fill
2435
2436
2437 return
2438 end
2439
2440
2441
2442 ***************************************************
2443 * *
2444 * *
2445 * *
2446 * *
2447 * *
2448 * *
2449 **************************************************
2450
2451 subroutine doub_to_YZcloud(iflag)
2452
2453 include 'commontracker.f'
2454 include 'level1.f'
2455 include 'common_momanhough.f'
2456 c include 'momanhough_init.f'
2457
2458
2459 * output flag
2460 * --------------
2461 * 0 = good event
2462 * 1 = bad event
2463 * --------------
2464 integer iflag
2465
2466 integer db_used(ndblt_max)
2467 integer db_temp(ndblt_max)
2468 integer db_all(ndblt_max) !stores db ID in each cloud
2469
2470 integer hit_plane(nplanes)
2471
2472 * mask for used couples
2473 integer cp_useds1(ncouplemaxtot) ! sensor 1
2474 integer cp_useds2(ncouplemaxtot) ! sensor 2
2475
2476
2477 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2478 * classification of DOUBLETS
2479 * according to distance in parameter space
2480 * (cloud = group of points (doublets) in parameter space)
2481 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2482 do idb=1,ndblt
2483 db_used(idb)=0
2484 enddo
2485
2486 distance=0
2487 nclouds_yz=0 !number of clouds
2488 npt_tot=0
2489 nloop=0
2490 90 continue
2491 do idb1=1,ndblt !loop (1) on DOUBLETS
2492 if(db_used(idb1).eq.1)goto 2228 !db already included in a cloud
2493
2494 c print*,'--------------'
2495 c print*,'** ',idb1,' **'
2496
2497 do icp=1,ncp_tot
2498 cp_useds1(icp)=0 !init
2499 cp_useds2(icp)=0 !init
2500 enddo
2501 do idb=1,ndblt
2502 db_all(idb)=0
2503 enddo
2504 if(cpyz1(idb1).gt.0)cp_useds2(cpyz1(idb1))=1
2505 if(cpyz1(idb1).lt.0)cp_useds1(-cpyz1(idb1))=1
2506 if(cpyz2(idb1).gt.0)cp_useds2(cpyz2(idb1))=1
2507 if(cpyz2(idb1).lt.0)cp_useds1(-cpyz2(idb1))=1
2508 temp1 = alfayz1(idb1)
2509 temp2 = alfayz2(idb1)
2510 npt=1 !counter of points in the cloud
2511
2512 db_all(npt) = idb1
2513
2514 nptloop=1
2515 db_temp(1)=idb1
2516
2517 88 continue
2518
2519 npv=0 !# new points inlcuded
2520 do iloop=1,nptloop
2521 idbref=db_temp(iloop) !local point of reference
2522 ccccc if(db_used(idbref).eq.1)goto 1188 !next
2523
2524 do idb2=1,ndblt !loop (2) on DOUBLETS
2525 if(idb2.eq.idbref)goto 1118 !next doublet
2526 if(db_used(idb2).eq.1)goto 1118
2527
2528
2529 * doublet distance in parameter space
2530 distance=
2531 $ ((alfayz1(idbref)-alfayz1(idb2))/Dalfayz1)**2
2532 $ +((alfayz2(idbref)-alfayz2(idb2))/Dalfayz2)**2
2533 distance = sqrt(distance)
2534
2535 c$$$ if(iev.eq.33)then
2536 c$$$ if(distance.lt.100)
2537 c$$$ $ print*,'********* ',idb1,idbref,idb2,distance
2538 c$$$ if(distance.lt.100)
2539 c$$$ $ print*,'********* ',alfayz1(idbref),alfayz1(idb2)
2540 c$$$ $ ,alfayz2(idbref),alfayz2(idb2)
2541 c$$$ endif
2542 if(distance.lt.cutdistyz)then
2543
2544 c print*,idb1,idb2,distance,' cloud ',nclouds_yz
2545 if(cpyz1(idb2).gt.0)cp_useds2(cpyz1(idb2))=1
2546 if(cpyz1(idb2).lt.0)cp_useds1(-cpyz1(idb2))=1
2547 if(cpyz2(idb2).gt.0)cp_useds2(cpyz2(idb2))=1
2548 if(cpyz2(idb2).lt.0)cp_useds1(-cpyz2(idb2))=1
2549 npt = npt + 1 !counter of points in the cloud
2550
2551 npv = npv +1
2552 db_temp(npv) = idb2
2553 db_used(idbref) = 1
2554 db_used(idb2) = 1
2555
2556 db_all(npt) = idb2
2557
2558 temp1 = temp1 + alfayz1(idb2)
2559 temp2 = temp2 + alfayz2(idb2)
2560 c print*,'* idbref,idb2 ',idbref,idb2
2561 endif
2562
2563 1118 continue
2564 enddo !end loop (2) on DOUBLETS
2565
2566 1188 continue
2567 enddo !end loop on... bo?
2568
2569 nptloop=npv
2570 if(nptloop.ne.0)goto 88
2571
2572 * ------------------------------------------
2573 * stores the cloud only if
2574 * 1) it includes a minimum number of REAL couples
2575 * 1bis) it inlcudes a minimum number of doublets
2576 * 2) it is not already stored
2577 * ------------------------------------------
2578 do ip=1,nplanes
2579 hit_plane(ip)=0
2580 enddo
2581 ncpused=0
2582 do icp=1,ncp_tot
2583 if(cp_useds1(icp).ne.0.or.cp_useds2(icp).ne.0)then
2584 ncpused=ncpused+1
2585 ip=ip_cp(icp)
2586 hit_plane(ip)=1
2587 endif
2588 enddo
2589 nplused=0
2590 do ip=1,nplanes
2591 nplused=nplused+ hit_plane(ip)
2592 enddo
2593 c print*,'>>>> ',ncpused,npt,nplused
2594 c if(ncpused.lt.ncpyz_min)goto 2228 !next doublet
2595 if(npt.lt.nptyz_min)goto 2228 !next doublet
2596 if(nplused.lt.nplyz_min)goto 2228 !next doublet
2597
2598 * ~~~~~~~~~~~~~~~~~
2599 * >>> NEW CLOUD <<<
2600
2601 if(nclouds_yz.ge.ncloyz_max)then
2602 if(verbose)print*,
2603 $ '** warning ** number of identified '//
2604 $ 'YZ clouds exceeds vector dimention '
2605 $ ,'( ',ncloyz_max,' )'
2606 c good2=.false.
2607 c goto 880 !fill ntp and go to next event
2608 do iv=1,nviews
2609 mask_view(iv) = 5
2610 enddo
2611 iflag=1
2612 return
2613 endif
2614
2615 nclouds_yz = nclouds_yz + 1 !increase counter
2616 alfayz1_av(nclouds_yz) = temp1/npt !store average parameter
2617 alfayz2_av(nclouds_yz) = temp2/npt ! "
2618 do icp=1,ncp_tot
2619 cpcloud_yz(nclouds_yz,icp)=
2620 $ cp_useds1(icp)+2*cp_useds2(icp) !store cp info
2621 enddo
2622 ptcloud_yz(nclouds_yz)=npt
2623 c ptcloud_yz_nt(nclouds_yz)=npt
2624 do ipt=1,npt
2625 db_cloud(npt_tot+ipt) = db_all(ipt)
2626 c print*,'>> ',ipt,db_all(ipt)
2627 enddo
2628 npt_tot=npt_tot+npt
2629 if(DEBUG)then
2630 print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~'
2631 print*,'>>>> cloud ',nclouds_yz,' --- ',npt,' points'
2632 print*,'- alfayz1 ',alfayz1_av(nclouds_yz)
2633 print*,'- alfayz2 ',alfayz2_av(nclouds_yz)
2634 print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot)
2635 print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot)
2636 print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes)
2637 c$$$ print*,'nt-uple: ptcloud_yz(',nclouds_yz,') = '
2638 c$$$ $ ,ptcloud_yz(nclouds_yz)
2639 c$$$ print*,'nt-uple: db_cloud(...) = '
2640 c$$$ $ ,(db_cloud(iii),iii=npt_tot-npt+1,npt_tot)
2641 endif
2642 * >>> NEW CLOUD <<<
2643 * ~~~~~~~~~~~~~~~~~
2644 2228 continue
2645 enddo !end loop (1) on DOUBLETS
2646
2647
2648 if(nloop.lt.nstepy)then
2649 cutdistyz = cutdistyz+cutystep
2650 nloop = nloop+1
2651 goto 90
2652 endif
2653
2654 if(DEBUG)then
2655 print*,'---------------------- '
2656 print*,'Y-Z total clouds ',nclouds_yz
2657 print*,' '
2658 endif
2659
2660
2661 return
2662 end
2663
2664
2665
2666
2667
2668 ***************************************************
2669 * *
2670 * *
2671 * *
2672 * *
2673 * *
2674 * *
2675 **************************************************
2676
2677 subroutine trip_to_XZcloud(iflag)
2678
2679 include 'commontracker.f'
2680 include 'level1.f'
2681 include 'common_momanhough.f'
2682 c include 'momanhough_init.f'
2683
2684
2685 * output flag
2686 * --------------
2687 * 0 = good event
2688 * 1 = bad event
2689 * --------------
2690 integer iflag
2691
2692 integer tr_used(ntrpt_max)
2693 integer tr_temp(ntrpt_max)
2694 integer tr_incl(ntrpt_max)
2695 integer tr_all(ntrpt_max) !stores tr ID in each cloud
2696
2697 integer hit_plane(nplanes)
2698
2699 * mask for used couples
2700 integer cp_useds1(ncouplemaxtot) ! sensor 1
2701 integer cp_useds2(ncouplemaxtot) ! sensor 2
2702
2703 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2704 * classification of TRIPLETS
2705 * according to distance in parameter space
2706 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2707 do itr=1,ntrpt
2708 tr_used(itr)=0
2709 enddo
2710
2711 distance=0
2712 nclouds_xz=0 !number of clouds
2713 npt_tot=0 !total number of selected triplets
2714 nloop=0
2715 91 continue
2716 do itr1=1,ntrpt !loop (1) on TRIPLETS
2717 if(tr_used(itr1).eq.1)goto 22288 !already included in a cloud
2718 c print*,'--------------'
2719 c print*,'** ',itr1,' **'
2720
2721 do icp=1,ncp_tot
2722 cp_useds1(icp)=0
2723 cp_useds2(icp)=0
2724 enddo
2725 do itr=1,ntrpt
2726 tr_all(itr)=0 !list of included triplets
2727 enddo
2728 if(cpxz1(itr1).gt.0)cp_useds2(cpxz1(itr1))=1
2729 if(cpxz1(itr1).lt.0)cp_useds1(-cpxz1(itr1))=1
2730 if(cpxz2(itr1).gt.0)cp_useds2(cpxz2(itr1))=1
2731 if(cpxz2(itr1).lt.0)cp_useds1(-cpxz2(itr1))=1
2732 if(cpxz3(itr1).gt.0)cp_useds2(cpxz3(itr1))=1
2733 if(cpxz3(itr1).lt.0)cp_useds1(-cpxz3(itr1))=1
2734 temp1 = alfaxz1(itr1)
2735 temp2 = alfaxz2(itr1)
2736 temp3 = alfaxz3(itr1)
2737 npt=1 !counter of points in the cloud
2738
2739 tr_all(npt) = itr1
2740
2741 nptloop=1
2742 c tr_temp(1)=itr1
2743 tr_incl(1)=itr1
2744
2745 8881 continue
2746
2747 npv=0 !# new points inlcuded
2748 do iloop=1,nptloop
2749 itrref=tr_incl(iloop) !local point of reference
2750 do itr2=1,ntrpt !loop (2) on TRIPLETS
2751 if(itr2.eq.itr1)goto 11188 !next triplet
2752 if(tr_used(itr2).eq.1)goto 11188 !next triplet
2753 * triplet distance in parameter space
2754 * solo i due parametri spaziali per il momemnto
2755 distance=
2756 $ ((alfaxz1(itrref)-alfaxz1(itr2))/Dalfaxz1)**2
2757 $ +((alfaxz2(itrref)-alfaxz2(itr2))/Dalfaxz2)**2
2758 distance = sqrt(distance)
2759
2760 if(distance.lt.cutdistxz)then
2761 c print*,idb1,idb2,distance,' cloud ',nclouds_yz
2762 if(cpxz1(itr2).gt.0)cp_useds2(cpxz1(itr2))=1
2763 if(cpxz1(itr2).lt.0)cp_useds1(-cpxz1(itr2))=1
2764 if(cpxz2(itr2).gt.0)cp_useds2(cpxz2(itr2))=1
2765 if(cpxz2(itr2).lt.0)cp_useds1(-cpxz2(itr2))=1
2766 if(cpxz3(itr2).gt.0)cp_useds2(cpxz3(itr2))=1
2767 if(cpxz3(itr2).lt.0)cp_useds1(-cpxz3(itr2))=1
2768 npt = npt + 1 !counter of points in the cloud
2769
2770 npv = npv +1
2771 tr_temp(npv) = itr2
2772 tr_used(itrref) = 1
2773 tr_used(itr2) = 1
2774
2775 tr_all(npt) = itr2
2776
2777 temp1 = temp1 + alfaxz1(itr2)
2778 temp2 = temp2 + alfaxz2(itr2)
2779 temp3 = temp3 + alfaxz3(itr2)
2780 c print*,'* itrref,itr2 ',itrref,itr2,distance
2781 endif
2782
2783 11188 continue
2784 enddo !end loop (2) on TRIPLETS
2785
2786 11888 continue
2787 enddo !end loop on... bo?
2788
2789 nptloop=npv
2790 do i=1,npv
2791 tr_incl(i)=tr_temp(i)
2792 enddo
2793 if(nptloop.ne.0)goto 8881
2794
2795 * ------------------------------------------
2796 * stores the cloud only if
2797 * 1) it includes a minimum number of REAL couples
2798 * 1bis)
2799 * 2) it is not already stored
2800 * ------------------------------------------
2801 c print*,'check cp_used'
2802 do ip=1,nplanes
2803 hit_plane(ip)=0
2804 enddo
2805 ncpused=0
2806 do icp=1,ncp_tot
2807 if(cp_useds1(icp).ne.0.or.cp_useds2(icp).ne.0)then
2808 ncpused=ncpused+1
2809 ip=ip_cp(icp)
2810 hit_plane(ip)=1
2811 endif
2812 enddo
2813 nplused=0
2814 do ip=1,nplanes
2815 nplused=nplused+ hit_plane(ip)
2816 enddo
2817 c if(ncpused.lt.ncpxz_min)goto 22288 !next triplet
2818 if(npt.lt.nptxz_min)goto 22288 !next triplet
2819 if(nplused.lt.nplxz_min)goto 22288 !next doublet
2820
2821 * ~~~~~~~~~~~~~~~~~
2822 * >>> NEW CLOUD <<<
2823 if(nclouds_xz.ge.ncloxz_max)then
2824 if(verbose)print*,
2825 $ '** warning ** number of identified '//
2826 $ 'XZ clouds exceeds vector dimention '
2827 $ ,'( ',ncloxz_max,' )'
2828 c good2=.false.
2829 c goto 880 !fill ntp and go to next event
2830 do iv=1,nviews
2831 mask_view(iv) = 6
2832 enddo
2833 iflag=1
2834 return
2835 endif
2836 nclouds_xz = nclouds_xz + 1 !increase counter
2837 alfaxz1_av(nclouds_xz) = temp1/npt !store average parameter
2838 alfaxz2_av(nclouds_xz) = temp2/npt ! "
2839 alfaxz3_av(nclouds_xz) = temp3/npt ! "
2840 do icp=1,ncp_tot
2841 cpcloud_xz(nclouds_xz,icp)=
2842 $ cp_useds1(icp)+2*cp_useds2(icp) !store cp info
2843 enddo
2844 ptcloud_xz(nclouds_xz)=npt
2845 do ipt=1,npt
2846 tr_cloud(npt_tot+ipt) = tr_all(ipt)
2847 enddo
2848 npt_tot=npt_tot+npt
2849
2850 if(DEBUG)then
2851 print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~'
2852 print*,'>>>> cloud ',nclouds_xz,' --- ',npt,' points'
2853 print*,'- alfaxz1 ',alfaxz1_av(nclouds_xz)
2854 print*,'- alfaxz2 ',alfaxz2_av(nclouds_xz)
2855 print*,'- alfaxz3 ',alfaxz3_av(nclouds_xz)
2856 print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot)
2857 print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot)
2858 print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes)
2859 c$$$ print*,'nt-uple: ptcloud_xz(',nclouds_xz,') = '
2860 c$$$ $ ,ptcloud_xz(nclouds_xz)
2861 c$$$ print*,'nt-uple: tr_cloud(...) = '
2862 c$$$ $ ,(tr_cloud(iii),iii=npt_tot-npt+1,npt_tot)
2863 endif
2864 * >>> NEW CLOUD <<<
2865 * ~~~~~~~~~~~~~~~~~
2866 22288 continue
2867 enddo !end loop (1) on DOUBLETS
2868
2869 if(nloop.lt.nstepx)then
2870 cutdistxz=cutdistxz+cutxstep
2871 nloop=nloop+1
2872 goto 91
2873 endif
2874
2875 if(DEBUG)then
2876 print*,'---------------------- '
2877 print*,'X-Z total clouds ',nclouds_xz
2878 print*,' '
2879 endif
2880
2881
2882 return
2883 end
2884
2885
2886 ***************************************************
2887 * *
2888 * *
2889 * *
2890 * *
2891 * *
2892 * *
2893 **************************************************
2894
2895 subroutine clouds_to_ctrack(iflag)
2896 c*****************************************************
2897 c 02/02/2006 modified by Elena Vannuccini --> (1)
2898 c*****************************************************
2899
2900 include 'commontracker.f'
2901 include 'level1.f'
2902 include 'common_momanhough.f'
2903 include 'common_xyzPAM.f'
2904 include 'common_mini_2.f'
2905 include 'common_mech.f'
2906 c include 'momanhough_init.f'
2907
2908
2909 * output flag
2910 * --------------
2911 * 0 = good event
2912 * 1 = bad event
2913 * --------------
2914 integer iflag
2915
2916 * -----------------------------------------------------------
2917 * mask to store (locally) the couples included
2918 * in the intersection bewteen a XZ and YZ cloud
2919 integer cpintersec(ncouplemaxtot)
2920 * -----------------------------------------------------------
2921 * list of matching couples in the combination
2922 * between a XZ and YZ cloud
2923 integer cp_match(nplanes,2*ncouplemax)
2924 integer ncp_match(nplanes)
2925 * -----------------------------------------------------------
2926 integer hit_plane(nplanes)
2927 * -----------------------------------------------------------
2928 * variables for track fitting
2929 double precision AL_INI(5)
2930 c double precision tath
2931 * -----------------------------------------------------------
2932 c real fitz(nplanes) !z coordinates of the planes in cm
2933
2934
2935
2936 ntracks=0 !counter of track candidates
2937
2938 do iyz=1,nclouds_yz !loop on YZ couds
2939 do ixz=1,nclouds_xz !loop on XZ couds
2940
2941 * --------------------------------------------------
2942 * check of consistency of the clouds
2943 * ---> required a minimum number of matching couples
2944 * the track fit will be performed on the INTERSECTION
2945 * of the two clouds
2946 * --------------------------------------------------
2947 do ip=1,nplanes
2948 hit_plane(ip)=0
2949 ncp_match(ip)=0
2950 do icpp=1,ncouplemax
2951 cp_match(ip,icpp)=0 !init couple list
2952 enddo
2953 enddo
2954 ncp_ok=0
2955 do icp=1,ncp_tot !loop on couples
2956 * get info on
2957 cpintersec(icp)=min(
2958 $ cpcloud_yz(iyz,icp),
2959 $ cpcloud_xz(ixz,icp))
2960 if(
2961 $ (cpcloud_yz(iyz,icp).eq.1.and.cpcloud_xz(ixz,icp).eq.2).or.
2962 $ (cpcloud_yz(iyz,icp).eq.2.and.cpcloud_xz(ixz,icp).eq.1).or.
2963 $ .false.)cpintersec(icp)=0
2964 if(cpintersec(icp).ne.0)then
2965 ncp_ok=ncp_ok+1
2966
2967 ip=ip_cp(icp)
2968 hit_plane(ip)=1
2969 if(cpintersec(icp).eq.1)then
2970 * 1) only the couple image in sensor 1 matches
2971 id=-icp
2972 ncp_match(ip)=ncp_match(ip)+1
2973 cp_match(ip,ncp_match(ip))=id
2974 elseif(cpintersec(icp).eq.2)then
2975 * 2) only the couple image in sensor 2 matches
2976 id=icp
2977 ncp_match(ip)=ncp_match(ip)+1
2978 cp_match(ip,ncp_match(ip))=id
2979 else
2980 * 3) both couple images match
2981 id=icp
2982 do is=1,2
2983 id=-id
2984 ncp_match(ip)=ncp_match(ip)+1
2985 cp_match(ip,ncp_match(ip))=id
2986 enddo
2987 endif
2988 endif !end matching condition
2989 enddo !end loop on couples
2990
2991 nplused=0
2992 do ip=1,nplanes
2993 nplused=nplused+ hit_plane(ip)
2994 enddo
2995
2996 if(nplused.lt.nplxz_min)goto 888 !next doublet
2997 if(ncp_ok.lt.ncpok)goto 888 !next cloud
2998
2999 if(DEBUG)then
3000 print*,'Combination ',iyz,ixz
3001 $ ,' db ',ptcloud_yz(iyz)
3002 $ ,' tr ',ptcloud_xz(ixz)
3003 $ ,' -----> # matching couples ',ncp_ok
3004 endif
3005 c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~'
3006 c$$$ print*,'Configurazione cluster XZ'
3007 c$$$ print*,'1 -- ',(clx(1,i),i=1,ncp_plane(1))
3008 c$$$ print*,'2 -- ',(clx(2,i),i=1,ncp_plane(1))
3009 c$$$ print*,'3 -- ',(clx(3,i),i=1,ncp_plane(1))
3010 c$$$ print*,'4 -- ',(clx(4,i),i=1,ncp_plane(1))
3011 c$$$ print*,'5 -- ',(clx(5,i),i=1,ncp_plane(1))
3012 c$$$ print*,'6 -- ',(clx(6,i),i=1,ncp_plane(1))
3013 c$$$ print*,'Configurazione cluster YZ'
3014 c$$$ print*,'1 -- ',(cly(1,i),i=1,ncp_plane(1))
3015 c$$$ print*,'2 -- ',(cly(2,i),i=1,ncp_plane(1))
3016 c$$$ print*,'3 -- ',(cly(3,i),i=1,ncp_plane(1))
3017 c$$$ print*,'4 -- ',(cly(4,i),i=1,ncp_plane(1))
3018 c$$$ print*,'5 -- ',(cly(5,i),i=1,ncp_plane(1))
3019 c$$$ print*,'6 -- ',(cly(6,i),i=1,ncp_plane(1))
3020 c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~'
3021
3022 * -------> INITIAL GUESS <-------
3023 cccc SBAGLIATO
3024 c$$$ AL_INI(1) = dreal(alfaxz1_av(ixz))
3025 c$$$ AL_INI(2) = dreal(alfayz1_av(iyz))
3026 c$$$ AL_INI(4) = PIGR + datan(dreal(alfayz2_av(iyz))
3027 c$$$ $ /dreal(alfaxz2_av(ixz)))
3028 c$$$ tath = -dreal(alfaxz2_av(ixz))/dcos(AL_INI(4))
3029 c$$$ AL_INI(3) = tath/sqrt(1+tath**2)
3030 c$$$ AL_INI(5) = (1.e2*alfaxz3_av(ixz))/(0.3*0.43) !0.
3031 cccc GIUSTO (ma si sua guess())
3032 c$$$ AL_INI(1) = dreal(alfaxz1_av(ixz))
3033 c$$$ AL_INI(2) = dreal(alfayz1_av(iyz))
3034 c$$$ tath = -dreal(alfaxz2_av(ixz))/dcos(AL_INI(4))
3035 c$$$ AL_INI(3) = tath/sqrt(1+tath**2)
3036 c$$$ IF(alfaxz2_av(ixz).NE.0)THEN
3037 c$$$ AL_INI(4) = PIGR + datan(dreal(alfayz2_av(iyz))
3038 c$$$ $ /dreal(alfaxz2_av(ixz)))
3039 c$$$ ELSE
3040 c$$$ AL_INI(4) = acos(-1.)/2
3041 c$$$ IF(alfayz2_av(iyz).LT.0)AL_INI(4) = AL_INI(4)+acos(-1.)
3042 c$$$ ENDIF
3043 c$$$ IF(alfaxz2_av(ixz).LT.0)AL_INI(4)= acos(-1.)+ AL_INI(4)
3044 c$$$ AL_INI(4) = -acos(-1.) + AL_INI(4) !from incidence direction to tracking rs
3045 c$$$
3046 c$$$ AL_INI(5) = (1.e2*alfaxz3_av(ixz))/(0.3*0.43) !0.
3047 c$$$
3048 c$$$ if(AL_INI(5).gt.defmax)goto 888 !next cloud
3049
3050 if(DEBUG)then
3051 print*,'1 >>> ',(cp_match(6,i),i=1,ncp_match(6))
3052 print*,'2 >>> ',(cp_match(5,i),i=1,ncp_match(5))
3053 print*,'3 >>> ',(cp_match(4,i),i=1,ncp_match(4))
3054 print*,'4 >>> ',(cp_match(3,i),i=1,ncp_match(3))
3055 print*,'5 >>> ',(cp_match(2,i),i=1,ncp_match(2))
3056 print*,'6 >>> ',(cp_match(1,i),i=1,ncp_match(1))
3057 endif
3058
3059 do icp1=1,max(1,ncp_match(1))
3060 hit_plane(1)=icp1
3061 if(ncp_match(1).eq.0)hit_plane(1)=0 !-icp1
3062
3063 do icp2=1,max(1,ncp_match(2))
3064 hit_plane(2)=icp2
3065 if(ncp_match(2).eq.0)hit_plane(2)=0 !-icp2
3066
3067 do icp3=1,max(1,ncp_match(3))
3068 hit_plane(3)=icp3
3069 if(ncp_match(3).eq.0)hit_plane(3)=0 !-icp3
3070
3071 do icp4=1,max(1,ncp_match(4))
3072 hit_plane(4)=icp4
3073 if(ncp_match(4).eq.0)hit_plane(4)=0 !-icp4
3074
3075 do icp5=1,max(1,ncp_match(5))
3076 hit_plane(5)=icp5
3077 if(ncp_match(5).eq.0)hit_plane(5)=0 !-icp5
3078
3079 do icp6=1,max(1,ncp_match(6))
3080 hit_plane(6)=icp6
3081 if(ncp_match(6).eq.0)hit_plane(6)=0 !-icp6
3082
3083
3084 call track_init !init TRACK common
3085
3086 do ip=1,nplanes !loop on planes
3087 if(hit_plane(ip).ne.0)then
3088 id=cp_match(ip,hit_plane(ip))
3089 is=is_cp(id)
3090 icp=icp_cp(id)
3091 if(ip_cp(id).ne.ip)
3092 $ print*,'OKKIO!!'
3093 $ ,'id ',id,is,icp
3094 $ ,ip_cp(id),ip
3095 icx=clx(ip,icp)
3096 icy=cly(ip,icp)
3097 * *************************
3098 c call xyz_PAM(icx,icy,is,
3099 c $ 'COG2','COG2',0.,0.)
3100 call xyz_PAM(icx,icy,is, !(1)
3101 $ PFAdef,PFAdef,0.,0.) !(1)
3102 * *************************
3103 * -----------------------------
3104 xgood(nplanes-ip+1)=1.
3105 ygood(nplanes-ip+1)=1.
3106 xm(nplanes-ip+1)=xPAM
3107 ym(nplanes-ip+1)=yPAM
3108 zm(nplanes-ip+1)=zPAM
3109 resx(nplanes-ip+1)=resxPAM
3110 resy(nplanes-ip+1)=resyPAM
3111 * -----------------------------
3112 endif
3113 enddo !end loop on planes
3114 * **********************************************************
3115 * ************************** FIT *** FIT *** FIT *** FIT ***
3116 * **********************************************************
3117 cccc scommentare se si usa al_ini della nuvola
3118 c$$$ do i=1,5
3119 c$$$ AL(i)=AL_INI(i)
3120 c$$$ enddo
3121 call guess()
3122 do i=1,5
3123 AL_INI(i)=AL(i)
3124 enddo
3125 ifail=0 !error flag in chi^2 computation
3126 jstep=0 !number of minimization steps
3127 iprint=0
3128 c if(DEBUG)iprint=1
3129 if(DEBUG)iprint=1
3130 call mini2(jstep,ifail,iprint)
3131 if(ifail.ne.0) then
3132 if(DEBUG)then
3133 print *,
3134 $ '*** MINIMIZATION FAILURE *** '
3135 $ //'(clouds_to_ctrack)'
3136 print*,'initial guess: '
3137
3138 print*,'AL_INI(1) = ',AL_INI(1)
3139 print*,'AL_INI(2) = ',AL_INI(2)
3140 print*,'AL_INI(3) = ',AL_INI(3)
3141 print*,'AL_INI(4) = ',AL_INI(4)
3142 print*,'AL_INI(5) = ',AL_INI(5)
3143 endif
3144 c chi2=-chi2
3145 endif
3146 * **********************************************************
3147 * ************************** FIT *** FIT *** FIT *** FIT ***
3148 * **********************************************************
3149
3150 if(chi2.le.0.)goto 666
3151
3152 * --------------------------
3153 * STORE candidate TRACK INFO
3154 * --------------------------
3155 if(ntracks.eq.NTRACKSMAX)then
3156
3157 if(verbose)print*,
3158 $ '** warning ** number of candidate tracks '//
3159 $ ' exceeds vector dimension '
3160 $ ,'( ',NTRACKSMAX,' )'
3161 c good2=.false.
3162 c goto 880 !fill ntp and go to next event
3163 do iv=1,nviews
3164 mask_view(iv) = 7
3165 enddo
3166 iflag=1
3167 return
3168 endif
3169
3170 ntracks = ntracks + 1
3171
3172 c$$$ ndof=0
3173 do ip=1,nplanes
3174 c$$$ ndof=ndof
3175 c$$$ $ +int(xgood(ip))
3176 c$$$ $ +int(ygood(ip))
3177 XV_STORE(ip,ntracks)=sngl(xv(ip))
3178 YV_STORE(ip,ntracks)=sngl(yv(ip))
3179 ZV_STORE(ip,ntracks)=sngl(zv(ip))
3180 XM_STORE(ip,ntracks)=sngl(xm(ip))
3181 YM_STORE(ip,ntracks)=sngl(ym(ip))
3182 ZM_STORE(ip,ntracks)=sngl(zm(ip))
3183 RESX_STORE(ip,ntracks)=sngl(resx(ip))
3184 RESY_STORE(ip,ntracks)=sngl(resy(ip))
3185 XV_STORE(ip,ntracks)=sngl(xv(ip))
3186 YV_STORE(ip,ntracks)=sngl(yv(ip))
3187 ZV_STORE(ip,ntracks)=sngl(zv(ip))
3188 AXV_STORE(ip,ntracks)=sngl(axv(ip))
3189 AYV_STORE(ip,ntracks)=sngl(ayv(ip))
3190 XGOOD_STORE(ip,ntracks)=sngl(xgood(ip))
3191 YGOOD_STORE(ip,ntracks)=sngl(ygood(ip))
3192 if(hit_plane(ip).ne.0)then
3193 CP_STORE(nplanes-ip+1,ntracks)=
3194 $ cp_match(ip,hit_plane(ip))
3195 else
3196 CP_STORE(nplanes-ip+1,ntracks)=0
3197 endif
3198 CLS_STORE(nplanes-ip+1,ntracks)=0
3199 do i=1,5
3200 AL_STORE(i,ntracks)=sngl(AL(i))
3201 enddo
3202 enddo
3203
3204 c$$$ * Number of Degree Of Freedom
3205 c$$$ ndof=ndof-5
3206 c$$$ * reduced chi^2
3207 c$$$ rchi2=chi2/dble(ndof)
3208 RCHI2_STORE(ntracks)=chi2
3209
3210 * --------------------------------
3211 * STORE candidate TRACK INFO - end
3212 * --------------------------------
3213
3214 666 continue
3215 enddo !end loop on cp in plane 6
3216 enddo !end loop on cp in plane 5
3217 enddo !end loop on cp in plane 4
3218 enddo !end loop on cp in plane 3
3219 enddo !end loop on cp in plane 2
3220 enddo !end loop on cp in plane 1
3221
3222 888 continue
3223 enddo !end loop on XZ couds
3224 enddo !end loop on YZ couds
3225
3226 if(ntracks.eq.0)then
3227 iflag=1
3228 return
3229 endif
3230
3231 if(DEBUG)then
3232 print*,'****** TRACK CANDIDATES ***********'
3233 print*,'# R. chi2 RIG'
3234 do i=1,ntracks
3235 print*,i,' --- ',rchi2_store(i),' --- '
3236 $ ,1./abs(AL_STORE(5,i))
3237 enddo
3238 print*,'***********************************'
3239 endif
3240
3241
3242 return
3243 end
3244
3245
3246 ***************************************************
3247 * *
3248 * *
3249 * *
3250 * *
3251 * *
3252 * *
3253 **************************************************
3254
3255 subroutine refine_track(ibest)
3256
3257 c******************************************************
3258 cccccc 06/10/2005 modified by elena vannuccini ---> (1)
3259 cccccc 31/01/2006 modified by elena vannuccini ---> (2)
3260 cccccc 12/08/2006 modified by elena vannucicni ---> (3)
3261 c******************************************************
3262
3263 include 'commontracker.f'
3264 include 'level1.f'
3265 include 'common_momanhough.f'
3266 include 'common_xyzPAM.f'
3267 include 'common_mini_2.f'
3268 include 'common_mech.f'
3269 c include 'momanhough_init.f'
3270 c include 'level1.f'
3271 include 'calib.f'
3272
3273
3274 * flag to chose PFA
3275 character*10 PFA
3276 common/FINALPFA/PFA
3277
3278 * =================================================
3279 * new estimate of positions using ETA algorithm
3280 * and
3281 * search for new couples and single clusters to add
3282 * =================================================
3283 call track_init
3284 do ip=1,nplanes !loop on planes
3285
3286 * |||||||||||||||||||||||||||||||||||||||||||||||||
3287 * -------------------------------------------------
3288 * If the plane has been already included, it just
3289 * computes again the coordinates of the x-y couple
3290 * using improved PFAs
3291 * -------------------------------------------------
3292 * |||||||||||||||||||||||||||||||||||||||||||||||||
3293 if(XGOOD_STORE(nplanes-ip+1,ibest).eq.1..and.
3294 $ YGOOD_STORE(nplanes-ip+1,ibest).eq.1. )then
3295
3296 id=CP_STORE(nplanes-ip+1,ibest)
3297
3298 is=is_cp(id)
3299 icp=icp_cp(id)
3300 if(ip_cp(id).ne.ip)
3301 $ print*,'OKKIO!!'
3302 $ ,'id ',id,is,icp
3303 $ ,ip_cp(id),ip
3304 icx=clx(ip,icp)
3305 icy=cly(ip,icp)
3306 call xyz_PAM(icx,icy,is,
3307 c $ 'ETA2','ETA2',
3308 $ PFA,PFA,
3309 $ AXV_STORE(nplanes-ip+1,ibest),
3310 $ AYV_STORE(nplanes-ip+1,ibest))
3311 c$$$ call xyz_PAM(icx,icy,is,
3312 c$$$ $ 'COG2','COG2',
3313 c$$$ $ 0.,
3314 c$$$ $ 0.)
3315 xm(nplanes-ip+1) = xPAM
3316 ym(nplanes-ip+1) = yPAM
3317 zm(nplanes-ip+1) = zPAM
3318 xgood(nplanes-ip+1) = 1
3319 ygood(nplanes-ip+1) = 1
3320 resx(nplanes-ip+1) = resxPAM
3321 resy(nplanes-ip+1) = resyPAM
3322
3323 c dedxtrk(nplanes-ip+1) = (dedx(icx)+dedx(icy))/2. !(1)
3324 dedxtrk_x(nplanes-ip+1)=dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)
3325 dedxtrk_y(nplanes-ip+1)=dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)
3326
3327 * |||||||||||||||||||||||||||||||||||||||||||||||||
3328 * -------------------------------------------------
3329 * If the plane has NOT been already included,
3330 * it tries to include a COUPLE or a single cluster
3331 * -------------------------------------------------
3332 * |||||||||||||||||||||||||||||||||||||||||||||||||
3333 else
3334
3335 xgood(nplanes-ip+1)=0
3336 ygood(nplanes-ip+1)=0
3337
3338 * --------------------------------------------------------------
3339 * determine which ladder and sensor are intersected by the track
3340 xP=XV_STORE(nplanes-ip+1,ibest)
3341 yP=YV_STORE(nplanes-ip+1,ibest)
3342 zP=ZV_STORE(nplanes-ip+1,ibest)
3343 call whichsensor(ip,xP,yP,nldt,ist)
3344 * if the track hit the plane in a dead area, go to the next plane
3345 if(nldt.eq.0.or.ist.eq.0)goto 133
3346 * --------------------------------------------------------------
3347
3348 if(DEBUG)then
3349 print*,
3350 $ '------ Plane ',ip,' intersected on LADDER ',nldt
3351 $ ,' SENSOR ',ist
3352 print*,
3353 $ '------ coord: ',XP,YP
3354 endif
3355
3356 * ===========================================
3357 * STEP 1 >>>>>>> try to include a new couple
3358 * ===========================================
3359 c if(DEBUG)print*,'>>>> try to include a new couple'
3360 distmin=1000000.
3361 xmm = 0.
3362 ymm = 0.
3363 zmm = 0.
3364 rxmm = 0.
3365 rymm = 0.
3366 dedxmmx = 0. !(1)
3367 dedxmmy = 0. !(1)
3368 idm = 0 !ID of the closer couple
3369 distance=0.
3370 do icp=1,ncp_plane(ip) !loop on couples on plane icp
3371 icx=clx(ip,icp)
3372 icy=cly(ip,icp)
3373 if(LADDER(icx).ne.nldt.or. !If the ladder number does not match
3374 c $ cl_used(icx).eq.1.or. !or the X cluster is already used
3375 c $ cl_used(icy).eq.1.or. !or the Y cluster is already used
3376 $ cl_used(icx).ne.0.or. !or the X cluster is already used !(3)
3377 $ cl_used(icy).ne.0.or. !or the Y cluster is already used !(3)
3378 $ .false.)goto 1188 !then jump to next couple.
3379 *
3380 call xyz_PAM(icx,icy,ist,
3381 $ PFA,PFA,
3382 c $ 'ETA2','ETA2',
3383 $ AXV_STORE(nplanes-ip+1,ibest),
3384 $ AYV_STORE(nplanes-ip+1,ibest))
3385
3386 distance = distance_to(XP,YP)
3387 distance = distance / RCHI2_STORE(ibest)!<<< MS
3388 id=id_cp(ip,icp,ist)
3389 if(DEBUG)print*,'( couple ',id
3390 $ ,' ) normalized distance ',distance
3391 if(distance.lt.distmin)then
3392 xmm = xPAM
3393 ymm = yPAM
3394 zmm = zPAM
3395 rxmm = resxPAM
3396 rymm = resyPAM
3397 distmin = distance
3398 idm = id
3399 c dedxmm = (dedx(icx)+dedx(icy))/2. !(1)
3400 dedxmmx = dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)
3401 dedxmmy = dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)
3402 endif
3403 1188 continue
3404 enddo !end loop on couples on plane icp
3405 if(distmin.le.clinc)then
3406 * -----------------------------------
3407 xm(nplanes-ip+1) = xmm !<<<
3408 ym(nplanes-ip+1) = ymm !<<<
3409 zm(nplanes-ip+1) = zmm !<<<
3410 xgood(nplanes-ip+1) = 1 !<<<
3411 ygood(nplanes-ip+1) = 1 !<<<
3412 resx(nplanes-ip+1)=rxmm !<<<
3413 resy(nplanes-ip+1)=rymm !<<<
3414 c dedxtrk(nplanes-ip+1) = dedxmm !<<< !(1)
3415 dedxtrk_x(nplanes-ip+1) = dedxmmx !(1)
3416 dedxtrk_y(nplanes-ip+1) = dedxmmy !(1)
3417 * -----------------------------------
3418 CP_STORE(nplanes-ip+1,ibest)=idm
3419 if(DEBUG)print*,'%%%% included couple ',idm
3420 $ ,' (norm.dist.= ',distmin,', cut ',clinc,' )'
3421 goto 133 !next plane
3422 endif
3423 * ================================================
3424 * STEP 2 >>>>>>> try to include a single cluster
3425 * either from a couple or single
3426 * ================================================
3427 c if(DEBUG)print*,'>>>> try to include a new cluster'
3428 distmin=1000000.
3429 xmm_A = 0. !---------------------------
3430 ymm_A = 0. ! init variables that
3431 zmm_A = 0. ! define the SINGLET
3432 xmm_B = 0. !
3433 ymm_B = 0. !
3434 zmm_B = 0. !
3435 rxmm = 0. !
3436 rymm = 0. !
3437 dedxmmx = 0. !(1)
3438 dedxmmy = 0. !(1)
3439 iclm=0 !---------------------------
3440 distance=0.
3441
3442 *----- clusters inside couples -------------------------------------
3443 do icp=1,ncp_plane(ip) !loop on cluster inside couples
3444 icx=clx(ip,icp)
3445 icy=cly(ip,icp)
3446 id=id_cp(ip,icp,ist)
3447 if(LADDER(icx).ne.nldt)goto 11882 !if the ladder number does not match
3448 * !jump to the next couple
3449 *----- try cluster x -----------------------------------------------
3450 c if(cl_used(icx).eq.1)goto 11881 !if the X cluster is already used
3451 if(cl_used(icx).ne.0)goto 11881 !if the X cluster is already used !(3)
3452 * !jump to the Y cluster
3453 call xyz_PAM(icx,0,ist,
3454 c $ 'ETA2','ETA2',
3455 $ PFA,PFA,
3456 $ AXV_STORE(nplanes-ip+1,ibest),0.)
3457 distance = distance_to(XP,YP)
3458 distance = distance / RCHI2_STORE(ibest)!<<< MS
3459 if(DEBUG)print*,'( cl-X ',icx
3460 $ ,' in cp ',id,' ) normalized distance ',distance
3461 if(distance.lt.distmin)then
3462 xmm_A = xPAM_A
3463 ymm_A = yPAM_A
3464 zmm_A = zPAM_A
3465 xmm_B = xPAM_B
3466 ymm_B = yPAM_B
3467 zmm_B = zPAM_B
3468 rxmm = resxPAM
3469 rymm = resyPAM
3470 distmin = distance
3471 iclm = icx
3472 c dedxmm = dedx(icx) !(1)
3473 dedxmmx = dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)
3474 dedxmmy = 0. !(1)
3475 endif
3476 11881 continue
3477 *----- try cluster y -----------------------------------------------
3478 c if(cl_used(icy).eq.1)goto 11882 !if the Y cluster is already used
3479 if(cl_used(icy).ne.0)goto 11882 !if the Y cluster is already used !(3)
3480 * !jump to the next couple
3481 call xyz_PAM(0,icy,ist,
3482 c $ 'ETA2','ETA2',
3483 $ PFA,PFA,
3484 $ 0.,AYV_STORE(nplanes-ip+1,ibest))
3485 distance = distance_to(XP,YP)
3486 distance = distance / RCHI2_STORE(ibest)!<<< MS
3487 if(DEBUG)print*,'( cl-Y ',icy
3488 $ ,' in cp ',id,' ) normalized distance ',distance
3489 if(distance.lt.distmin)then
3490 xmm_A = xPAM_A
3491 ymm_A = yPAM_A
3492 zmm_A = zPAM_A
3493 xmm_B = xPAM_B
3494 ymm_B = yPAM_B
3495 zmm_B = zPAM_B
3496 rxmm = resxPAM
3497 rymm = resyPAM
3498 distmin = distance
3499 iclm = icy
3500 c dedxmm = dedx(icy) !(1)
3501 dedxmmx = 0. !(1)
3502 dedxmmy = dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)
3503 endif
3504 11882 continue
3505 enddo !end loop on cluster inside couples
3506 *----- single clusters -----------------------------------------------
3507 do ic=1,ncls(ip) !loop on single clusters
3508 icl=cls(ip,ic)
3509 c if(cl_used(icl).eq.1.or. !if the cluster is already used
3510 if(cl_used(icl).ne.0.or. !if the cluster is already used !(3)
3511 $ LADDER(icl).ne.nldt.or. !or the ladder number does not match
3512 $ .false.)goto 18882 !jump to the next singlet
3513 if(mod(VIEW(icl),2).eq.0)then!<---- X view
3514 call xyz_PAM(icl,0,ist,
3515 c $ 'ETA2','ETA2',
3516 $ PFA,PFA,
3517 $ AXV_STORE(nplanes-ip+1,ibest),0.)
3518 else !<---- Y view
3519 call xyz_PAM(0,icl,ist,
3520 c $ 'ETA2','ETA2',
3521 $ PFA,PFA,
3522 $ 0.,AYV_STORE(nplanes-ip+1,ibest))
3523 endif
3524
3525 distance = distance_to(XP,YP)
3526 distance = distance / RCHI2_STORE(ibest)!<<< MS
3527 if(DEBUG)print*,'( cl-s ',icl
3528 $ ,' ) normalized distance ',distance
3529 if(distance.lt.distmin)then
3530 xmm_A = xPAM_A
3531 ymm_A = yPAM_A
3532 zmm_A = zPAM_A
3533 xmm_B = xPAM_B
3534 ymm_B = yPAM_B
3535 zmm_B = zPAM_B
3536 rxmm = resxPAM
3537 rymm = resyPAM
3538 distmin = distance
3539 iclm = icl
3540 c dedxmm = dedx(icl) !(1)
3541 if(mod(VIEW(icl),2).eq.0)then !<---- X view
3542 dedxmmx = dedx(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2)
3543 dedxmmy = 0. !(1)
3544 else !<---- Y view
3545 dedxmmx = 0. !(1)
3546 dedxmmy = dedx(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2)
3547 endif
3548 endif
3549 18882 continue
3550 enddo !end loop on single clusters
3551
3552 if(distmin.le.clinc)then
3553
3554 CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<<
3555 * ----------------------------
3556 c print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
3557 if(mod(VIEW(iclm),2).eq.0)then
3558 XGOOD(nplanes-ip+1)=1.
3559 resx(nplanes-ip+1)=rxmm
3560 if(DEBUG)print*,'%%%% included X-cl ',iclm
3561 c if(.true.)print*,'%%%% included X-cl ',iclm
3562 $ ,'( chi^2, ',RCHI2_STORE(ibest)
3563 $ ,', norm.dist.= ',distmin
3564 $ ,', cut ',clinc,' )'
3565 else
3566 YGOOD(nplanes-ip+1)=1.
3567 resy(nplanes-ip+1)=rymm
3568 if(DEBUG)print*,'%%%% included Y-cl ',iclm
3569 c if(.true.)print*,'%%%% included Y-cl ',iclm
3570 $ ,'( chi^2, ',RCHI2_STORE(ibest)
3571 $ ,', norm.dist.= ', distmin
3572 $ ,', cut ',clinc,' )'
3573 endif
3574 c print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
3575 * ----------------------------
3576 xm_A(nplanes-ip+1) = xmm_A
3577 ym_A(nplanes-ip+1) = ymm_A
3578 xm_B(nplanes-ip+1) = xmm_B
3579 ym_B(nplanes-ip+1) = ymm_B
3580 zm(nplanes-ip+1) = (zmm_A+zmm_B)/2.
3581 c dedxtrk(nplanes-ip+1) = dedxmm !<<< !(1)
3582 dedxtrk_x(nplanes-ip+1) = dedxmmx !<<< !(1)
3583 dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< !(1)
3584 * ----------------------------
3585 endif
3586 endif
3587 133 continue
3588 enddo !end loop on planes
3589
3590
3591
3592 return
3593 end
3594
3595 ***************************************************
3596 * *
3597 * *
3598 * *
3599 * *
3600 * *
3601 * *
3602 **************************************************
3603 cccccc 12/08/2006 modified by elena ---> (1)
3604 *
3605 subroutine clean_XYclouds(ibest,iflag)
3606
3607 include 'commontracker.f'
3608 include 'level1.f'
3609 include 'common_momanhough.f'
3610 c include 'momanhough_init.f'
3611 include 'level2.f' !(1)
3612 c include 'calib.f'
3613 c include 'level1.f'
3614
3615
3616
3617 do ip=1,nplanes !loop on planes
3618
3619 id=CP_STORE(nplanes-ip+1,ibest)
3620 icl=CLS_STORE(nplanes-ip+1,ibest)
3621 if(id.ne.0.or.icl.ne.0)then
3622 if(id.ne.0)then
3623 iclx=clx(ip,icp_cp(id))
3624 icly=cly(ip,icp_cp(id))
3625 c cl_used(iclx)=1 !tag used clusters
3626 c cl_used(icly)=1 !tag used clusters
3627 cl_used(iclx)=ntrk !tag used clusters !(1)
3628 cl_used(icly)=ntrk !tag used clusters !(1)
3629 elseif(icl.ne.0)then
3630 c cl_used(icl)=1 !tag used clusters
3631 cl_used(icl)=ntrk !tag used clusters !1)
3632 endif
3633
3634 c if(DEBUG)then
3635 c print*,ip,' <<< ',id
3636 c endif
3637 * -----------------------------
3638 * remove the couple from clouds
3639 * remove also vitual couples containing the
3640 * selected clusters
3641 * -----------------------------
3642 do icp=1,ncp_plane(ip)
3643 if(
3644 $ clx(ip,icp).eq.iclx
3645 $ .or.
3646 $ clx(ip,icp).eq.icl
3647 $ .or.
3648 $ cly(ip,icp).eq.icly
3649 $ .or.
3650 $ cly(ip,icp).eq.icl
3651 $ )then
3652 id=id_cp(ip,icp,1)
3653 if(DEBUG)then
3654 print*,ip,' <<< cp ',id
3655 $ ,' ( cl-x '
3656 $ ,clx(ip,icp)
3657 $ ,' cl-y '
3658 $ ,cly(ip,icp),' ) --> removed'
3659 endif
3660 * -----------------------------
3661 * remove the couple from clouds
3662 do iyz=1,nclouds_yz
3663 if(cpcloud_yz(iyz,abs(id)).ne.0)then
3664 ptcloud_yz(iyz)=ptcloud_yz(iyz)-1
3665 cpcloud_yz(iyz,abs(id))=0
3666 endif
3667 enddo
3668 do ixz=1,nclouds_xz
3669 if(cpcloud_xz(ixz,abs(id)).ne.0)then
3670 ptcloud_xz(ixz)=ptcloud_xz(ixz)-1
3671 cpcloud_xz(ixz,abs(id))=0
3672 endif
3673 enddo
3674 * -----------------------------
3675 endif
3676 enddo
3677
3678 endif
3679 enddo !end loop on planes
3680
3681 return
3682 end
3683
3684
3685
3686
3687 c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * ***
3688 c$$$ real function fbad_cog(ncog,ic)
3689 c$$$
3690 c$$$
3691 c$$$ include 'commontracker.f'
3692 c$$$ include 'level1.f'
3693 c$$$ include 'calib.f'
3694 c$$$
3695 c$$$* --> signal of the central strip
3696 c$$$ sc = CLSIGNAL(INDMAX(ic)) !center
3697 c$$$
3698 c$$$* signal of adjacent strips
3699 c$$$* --> left
3700 c$$$ sl1 = 0 !left 1
3701 c$$$ if(
3702 c$$$ $ (INDMAX(ic)-1).ge.INDSTART(ic)
3703 c$$$ $ )
3704 c$$$ $ sl1 = max(0.,CLSIGNAL(INDMAX(ic)-1))
3705 c$$$
3706 c$$$ sl2 = 0 !left 2
3707 c$$$ if(
3708 c$$$ $ (INDMAX(ic)-2).ge.INDSTART(ic)
3709 c$$$ $ )
3710 c$$$ $ sl2 = max(0.,CLSIGNAL(INDMAX(ic)-2))
3711 c$$$
3712 c$$$* --> right
3713 c$$$ sr1 = 0 !right 1
3714 c$$$ if(
3715 c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1))
3716 c$$$ $ .or.
3717 c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+1).le.TOTCLLENGTH)
3718 c$$$ $ )
3719 c$$$ $ sr1 = max(0.,CLSIGNAL(INDMAX(ic)+1))
3720 c$$$
3721 c$$$ sr2 = 0 !right 2
3722 c$$$ if(
3723 c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1))
3724 c$$$ $ .or.
3725 c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+2).le.TOTCLLENGTH)
3726 c$$$ $ )
3727 c$$$ $ sr2 = max(0.,CLSIGNAL(INDMAX(ic)+2))
3728 c$$$
3729 c$$$
3730 c$$$ if(mod(int(VIEW(ic)),2).eq.1)then !Y-view
3731 c$$$ f = 4.
3732 c$$$ si = 8.4
3733 c$$$ else !X-view
3734 c$$$ f = 6.
3735 c$$$ si = 3.9
3736 c$$$ endif
3737 c$$$
3738 c$$$ fbad_cog = 1.
3739 c$$$ f0 = 1
3740 c$$$ f1 = 1
3741 c$$$ f2 = 1
3742 c$$$ f3 = 1
3743 c$$$ if(sl1.gt.sr1.and.sl1.gt.0.)then
3744 c$$$
3745 c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)) ).eq.0)f0=f
3746 c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)-1)).eq.0)f1=f
3747 c$$$c if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)+1)).eq.0)f3=f
3748 c$$$
3749 c$$$ if(ncog.eq.2.and.sl1.ne.0)then
3750 c$$$ fbad_cog = (f1**2*sc**2/sl1**2+f0**2)/(sc**2/sl1**2+1.)
3751 c$$$ elseif(ncog.eq.3.and.sl1.ne.0.and.sr1.ne.0)then
3752 c$$$ fbad_cog = 1.
3753 c$$$ elseif(ncog.eq.4.and.sl1.ne.0.and.sr1.ne.0.and.sl2.ne.0)then
3754 c$$$ fbad_cog = 1.
3755 c$$$ else
3756 c$$$ fbad_cog = 1.
3757 c$$$ endif
3758 c$$$
3759 c$$$ elseif(sl1.le.sr1.and.sr1.gt.0.)then
3760 c$$$
3761 c$$$
3762 c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)) ).eq.0)f0=f
3763 c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)+1)).eq.0)f1=f
3764 c$$$c if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)-1)).eq.0)f3=f
3765 c$$$
3766 c$$$ if(ncog.eq.2.and.sr1.ne.0)then
3767 c$$$ fbad_cog = (f1**2*sc**2/sr1**2+f0**2)/(sc**2/sr1**2+1.)
3768 c$$$ elseif(ncog.eq.3.and.sr1.ne.0.and.sl1.ne.0)then
3769 c$$$ fbad_cog = 1.
3770 c$$$ elseif(ncog.eq.4.and.sr1.ne.0.and.sl1.ne.0.and.sr2.ne.0)then
3771 c$$$ fbad_cog = 1.
3772 c$$$ else
3773 c$$$ fbad_cog = 1.
3774 c$$$ endif
3775 c$$$
3776 c$$$ endif
3777 c$$$
3778 c$$$ fbad_cog = sqrt(fbad_cog)
3779 c$$$
3780 c$$$ return
3781 c$$$ end
3782 c$$$
3783
3784
3785
3786 * ****************************************************
3787
3788 subroutine init_level2
3789
3790 include 'commontracker.f'
3791 include 'level1.f'
3792 include 'common_momanhough.f'
3793 include 'level2.f'
3794 c include 'level1.f'
3795
3796 do i=1,nviews
3797 good2(i)=good1(i)
3798 enddo
3799
3800
3801 NTRK = 0
3802 do it=1,NTRKMAX
3803 IMAGE(IT)=0
3804 CHI2_nt(IT) = -100000.
3805 do ip=1,nplanes
3806 XM_nt(IP,IT) = 0
3807 YM_nt(IP,IT) = 0
3808 ZM_nt(IP,IT) = 0
3809 RESX_nt(IP,IT) = 0
3810 RESY_nt(IP,IT) = 0
3811 XGOOD_nt(IP,IT) = 0
3812 YGOOD_nt(IP,IT) = 0
3813 DEDX_X(IP,IT) = 0
3814 DEDX_Y(IP,IT) = 0
3815 CLTRX(IP,IT) = 0
3816 CLTRY(IP,IT) = 0
3817 enddo
3818 do ipa=1,5
3819 AL_nt(IPA,IT) = 0
3820 do ipaa=1,5
3821 coval(ipa,ipaa,IT)=0
3822 enddo
3823 enddo
3824 enddo
3825 nclsx=0
3826 nclsy=0
3827 do ip=1,NSINGMAX
3828 planex(ip)=0
3829 xs(1,ip)=0
3830 xs(2,ip)=0
3831 sgnlxs(ip)=0
3832 planey(ip)=0
3833 ys(1,ip)=0
3834 ys(2,ip)=0
3835 sgnlys(ip)=0
3836 enddo
3837 end
3838
3839
3840 ************************************************************
3841 *
3842 *
3843 *
3844 *
3845 *
3846 *
3847 *
3848 ************************************************************
3849
3850
3851 subroutine init_hough
3852
3853 include 'commontracker.f'
3854 include 'level1.f'
3855 include 'common_momanhough.f'
3856 include 'common_hough.f'
3857 include 'level2.f'
3858
3859 ntrpt_nt=0
3860 ndblt_nt=0
3861 NCLOUDS_XZ_nt=0
3862 NCLOUDS_YZ_nt=0
3863 do idb=1,ndblt_max_nt
3864 db_cloud_nt(idb)=0
3865 alfayz1_nt(idb)=0
3866 alfayz2_nt(idb)=0
3867 enddo
3868 do itr=1,ntrpl_max_nt
3869 tr_cloud_nt(itr)=0
3870 alfaxz1_nt(itr)=0
3871 alfaxz2_nt(itr)=0
3872 alfaxz3_nt(itr)=0
3873 enddo
3874 do idb=1,ncloyz_max
3875 ptcloud_yz_nt(idb)=0
3876 alfayz1_av_nt(idb)=0
3877 alfayz2_av_nt(idb)=0
3878 enddo
3879 do itr=1,ncloxz_max
3880 ptcloud_xz_nt(itr)=0
3881 alfaxz1_av_nt(itr)=0
3882 alfaxz2_av_nt(itr)=0
3883 alfaxz3_av_nt(itr)=0
3884 enddo
3885
3886 ntrpt=0
3887 ndblt=0
3888 NCLOUDS_XZ=0
3889 NCLOUDS_YZ=0
3890 do idb=1,ndblt_max
3891 db_cloud(idb)=0
3892 cpyz1(idb)=0
3893 cpyz2(idb)=0
3894 alfayz1(idb)=0
3895 alfayz2(idb)=0
3896 enddo
3897 do itr=1,ntrpl_max
3898 tr_cloud(itr)=0
3899 cpxz1(itr)=0
3900 cpxz2(itr)=0
3901 cpxz3(itr)=0
3902 alfaxz1(itr)=0
3903 alfaxz2(itr)=0
3904 alfaxz3(itr)=0
3905 enddo
3906 do idb=1,ncloyz_max
3907 ptcloud_yz(idb)=0
3908 alfayz1_av(idb)=0
3909 alfayz2_av(idb)=0
3910 do idbb=1,ncouplemaxtot
3911 cpcloud_yz(idb,idbb)=0
3912 enddo
3913 enddo
3914 do itr=1,ncloxz_max
3915 ptcloud_xz(itr)=0
3916 alfaxz1_av(itr)=0
3917 alfaxz2_av(itr)=0
3918 alfaxz3_av(itr)=0
3919 do itrr=1,ncouplemaxtot
3920 cpcloud_xz(itr,itrr)=0
3921 enddo
3922 enddo
3923 end
3924 ************************************************************
3925 *
3926 *
3927 *
3928 *
3929 *
3930 *
3931 *
3932 ************************************************************
3933
3934
3935 subroutine fill_level2_tracks(ntr)
3936
3937 * -------------------------------------------------------
3938 * This routine fills the ntr-th element of the variables
3939 * inside the level2_tracks common, which correspond
3940 * to the ntr-th track info.
3941 * -------------------------------------------------------
3942
3943
3944 include 'commontracker.f'
3945 c include 'level1.f'
3946 include 'level1.f'
3947 include 'common_momanhough.f'
3948 include 'level2.f'
3949 include 'common_mini_2.f'
3950 real sinth,phi,pig
3951 pig=acos(-1.)
3952
3953 chi2_nt(ntr) = sngl(chi2)
3954 nstep_nt(ntr) = nstep
3955
3956 phi = al(4)
3957 sinth = al(3)
3958 if(sinth.lt.0)then
3959 sinth = -sinth
3960 phi = phi + pig
3961 endif
3962 npig = aint(phi/(2*pig))
3963 phi = phi - npig*2*pig
3964 if(phi.lt.0)
3965 $ phi = phi + 2*pig
3966 al(4) = phi
3967 al(3) = sinth
3968
3969 do i=1,5
3970 al_nt(i,ntr) = sngl(al(i))
3971 do j=1,5
3972 coval(i,j,ntr) = sngl(cov(i,j))
3973 enddo
3974 enddo
3975
3976 do ip=1,nplanes ! loop on planes
3977 xgood_nt(ip,ntr) = int(xgood(ip))
3978 ygood_nt(ip,ntr) = int(ygood(ip))
3979 xm_nt(ip,ntr) = sngl(xm(ip))
3980 ym_nt(ip,ntr) = sngl(ym(ip))
3981 zm_nt(ip,ntr) = sngl(zm(ip))
3982 RESX_nt(IP,ntr) = sngl(resx(ip))
3983 RESY_nt(IP,ntr) = sngl(resy(ip))
3984 xv_nt(ip,ntr) = sngl(xv(ip))
3985 yv_nt(ip,ntr) = sngl(yv(ip))
3986 zv_nt(ip,ntr) = sngl(zv(ip))
3987 axv_nt(ip,ntr) = sngl(axv(ip))
3988 ayv_nt(ip,ntr) = sngl(ayv(ip))
3989 dedx_x(ip,ntr) = sngl(dedxtrk_x(ip)) !(2)
3990 dedx_y(ip,ntr) = sngl(dedxtrk_y(ip)) !(2)
3991
3992 id = CP_STORE(ip,IDCAND)
3993 icl = CLS_STORE(ip,IDCAND)
3994 if(id.ne.0)then
3995 cltrx(ip,ntr) = clx(nplanes-ip+1,icp_cp(id))
3996 cltry(ip,ntr) = cly(nplanes-ip+1,icp_cp(id))
3997 c print*,ip,' ',cltrx(ip,ntr),cltry(ip,ntr)
3998 elseif(icl.ne.0)then
3999 if(mod(VIEW(icl),2).eq.0)cltrx(ip,ntr)=icl
4000 if(mod(VIEW(icl),2).eq.1)cltry(ip,ntr)=icl
4001 c print*,ip,' ',cltrx(ip,ntr),cltry(ip,ntr)
4002 endif
4003
4004 enddo
4005
4006
4007 end
4008
4009 subroutine fill_level2_siglets
4010
4011 * -------------------------------------------------------
4012 * This routine fills the elements of the variables
4013 * inside the level2_singletsx and level2_singletsy commons,
4014 * which store info on clusters outside the tracks
4015 * -------------------------------------------------------
4016
4017 include 'commontracker.f'
4018 c include 'level1.f'
4019 include 'calib.f'
4020 include 'level1.f'
4021 include 'common_momanhough.f'
4022 include 'level2.f'
4023 include 'common_xyzPAM.f'
4024
4025 * count #cluster per plane not associated to any track
4026 c good2=1!.true.
4027 nclsx = 0
4028 nclsy = 0
4029
4030 do iv = 1,nviews
4031 if( mask_view(iv).ne.0 )good2(iv) = 20+mask_view(iv)
4032 enddo
4033
4034 do icl=1,nclstr1
4035 if(cl_used(icl).eq.0)then !cluster not included in any track
4036 ip=nplanes-npl(VIEW(icl))+1
4037 if(mod(VIEW(icl),2).eq.0)then !=== X views
4038 nclsx = nclsx + 1
4039 planex(nclsx) = ip
4040 sgnlxs(nclsx) = dedx(icl)/mip(VIEW(icl),LADDER(icl))!(2)
4041 clsx(nclsx) = icl
4042 do is=1,2
4043 c call xyz_PAM(icl,0,is,'COG1',' ',0.,0.)
4044 call xyz_PAM(icl,0,is,PFAdef,' ',0.,0.)
4045 xs(is,nclsx) = (xPAM_A+xPAM_B)/2
4046 enddo
4047 c$$$ print*,'nclsx ',nclsx
4048 c$$$ print*,'planex(nclsx) ',planex(nclsx)
4049 c$$$ print*,'sgnlxs(nclsx) ',sgnlxs(nclsx)
4050 c$$$ print*,'xs(1,nclsx) ',xs(1,nclsx)
4051 c$$$ print*,'xs(2,nclsx) ',xs(2,nclsx)
4052 else !=== Y views
4053 nclsy = nclsy + 1
4054 planey(nclsy) = ip
4055 sgnlys(nclsy) = dedx(icl)/mip(VIEW(icl),LADDER(icl))!(2)
4056 clsy(nclsy) = icl
4057 do is=1,2
4058 c call xyz_PAM(0,icl,is,' ','COG1',0.,0.)
4059 call xyz_PAM(0,icl,is,' ',PFAdef,0.,0.)
4060 ys(is,nclsy) = (yPAM_A+yPAM_B)/2
4061 enddo
4062 c$$$ print*,'nclsy ',nclsy
4063 c$$$ print*,'planey(nclsy) ',planey(nclsy)
4064 c$$$ print*,'sgnlys(nclsy) ',sgnlys(nclsy)
4065 c$$$ print*,'ys(1,nclsy) ',ys(1,nclsy)
4066 c$$$ print*,'ys(2,nclsy) ',ys(2,nclsy)
4067 endif
4068 endif
4069 c print*,icl,cl_used(icl),cl_good(icl),ip,VIEW(icl)!nclsx(ip),nclsy(ip)
4070
4071 ***** LO METTO QUI PERCHE` NON SO DOVE METTERLO
4072 whichtrack(icl) = cl_used(icl)
4073
4074 enddo
4075 end
4076
4077 ***************************************************
4078 * *
4079 * *
4080 * *
4081 * *
4082 * *
4083 * *
4084 **************************************************
4085
4086 subroutine fill_hough
4087
4088 * -------------------------------------------------------
4089 * This routine fills the variables related to the hough
4090 * transform, for the debig n-tuple
4091 * -------------------------------------------------------
4092
4093 include 'commontracker.f'
4094 include 'level1.f'
4095 include 'common_momanhough.f'
4096 include 'common_hough.f'
4097 include 'level2.f'
4098
4099 if(.false.
4100 $ .or.ntrpt.gt.ntrpt_max_nt
4101 $ .or.ndblt.gt.ndblt_max_nt
4102 $ .or.NCLOUDS_XZ.gt.ncloxz_max
4103 $ .or.NCLOUDS_yZ.gt.ncloyz_max
4104 $ )then
4105 ntrpt_nt=0
4106 ndblt_nt=0
4107 NCLOUDS_XZ_nt=0
4108 NCLOUDS_YZ_nt=0
4109 else
4110 ndblt_nt=ndblt
4111 ntrpt_nt=ntrpt
4112 if(ndblt.ne.0)then
4113 do id=1,ndblt
4114 alfayz1_nt(id)=alfayz1(id) !Y0
4115 alfayz2_nt(id)=alfayz2(id) !tg theta-yz
4116 enddo
4117 endif
4118 if(ndblt.ne.0)then
4119 do it=1,ntrpt
4120 alfaxz1_nt(it)=alfaxz1(it) !X0
4121 alfaxz2_nt(it)=alfaxz2(it) !tg theta-xz
4122 alfaxz3_nt(it)=alfaxz3(it) !1/r
4123 enddo
4124 endif
4125 nclouds_yz_nt=nclouds_yz
4126 nclouds_xz_nt=nclouds_xz
4127 if(nclouds_yz.ne.0)then
4128 nnn=0
4129 do iyz=1,nclouds_yz
4130 ptcloud_yz_nt(iyz)=ptcloud_yz(iyz)
4131 alfayz1_av_nt(iyz)=alfayz1_av(iyz)
4132 alfayz2_av_nt(iyz)=alfayz2_av(iyz)
4133 nnn=nnn+ptcloud_yz(iyz)
4134 enddo
4135 do ipt=1,nnn
4136 db_cloud_nt(ipt)=db_cloud(ipt)
4137 enddo
4138 endif
4139 if(nclouds_xz.ne.0)then
4140 nnn=0
4141 do ixz=1,nclouds_xz
4142 ptcloud_xz_nt(ixz)=ptcloud_xz(ixz)
4143 alfaxz1_av_nt(ixz)=alfaxz1_av(ixz)
4144 alfaxz2_av_nt(ixz)=alfaxz2_av(ixz)
4145 alfaxz3_av_nt(ixz)=alfaxz3_av(ixz)
4146 nnn=nnn+ptcloud_xz(ixz)
4147 enddo
4148 do ipt=1,nnn
4149 tr_cloud_nt(ipt)=tr_cloud(ipt)
4150 enddo
4151 endif
4152 endif
4153 end
4154

  ViewVC Help
Powered by ViewVC 1.1.23