1 |
************************************************************************* |
2 |
* Program analysis.f |
3 |
* |
4 |
* - reads cluster information (LEVEL1, reduction.f output ntuple) |
5 |
* - perform track identification and fit |
6 |
* - create LEVEL2 ntuple |
7 |
* |
8 |
************************************************************************* |
9 |
subroutine analysisflight |
10 |
|
11 |
include 'commontracker.f' |
12 |
include 'level1.f' |
13 |
include 'common_momanhough.f' |
14 |
include 'common_mech.f' |
15 |
include 'common_xyzPAM.f' |
16 |
include 'common_mini_2.f' |
17 |
include 'calib.f' |
18 |
include 'level2.f' |
19 |
|
20 |
* input flag |
21 |
* |
22 |
c integer fin |
23 |
|
24 |
* flag to chose PFA |
25 |
character*10 PFA |
26 |
common/FINALPFA/PFA |
27 |
|
28 |
c parameter (inf=1.e8) !just a huge number... |
29 |
|
30 |
* external functions |
31 |
external npl |
32 |
external acoordsi,coordsi,nld,coord,dcoord |
33 |
|
34 |
integer hitplanex(6) |
35 |
integer hitplaney(6) |
36 |
|
37 |
logical BAD_NUCLEUS |
38 |
|
39 |
************************************************************ |
40 |
************************************************************ |
41 |
************************************************************ |
42 |
* |
43 |
* track analysis |
44 |
* |
45 |
************************************************************ |
46 |
************************************************************ |
47 |
************************************************************ |
48 |
|
49 |
call idtoc(pfaid,PFA) |
50 |
|
51 |
|
52 |
if(DEBUG.EQ.1)then |
53 |
print*,'----------------------------------' |
54 |
print*,'Settings: ' |
55 |
print*,'PFA ',pfaid,' ---> ',PFA |
56 |
print*,'tracking mode ',trackmode |
57 |
print*,'fit-tolerance factor ',fact |
58 |
print*,'minimum n.step ',istepmin |
59 |
|
60 |
endif |
61 |
|
62 |
RECOVER_SINGLETS = .false. |
63 |
RECOVER_NUCLEI = .false. |
64 |
SECOND_SEARCH = .false. |
65 |
|
66 |
ntrk_old = 0 |
67 |
|
68 |
dedx_x_min = dedx_x_min_mip !mip search |
69 |
dedx_y_min = dedx_y_min_mip ! |
70 |
|
71 |
c 887 continue ! Emiliano, fix compilation warning (gcc 4.1), Label 887 defined but not used |
72 |
|
73 |
*------------------------------------------------------ |
74 |
do i=1,nclstr1 |
75 |
cl_used(i)=0 !init mask of clusters associated to a track |
76 |
enddo |
77 |
|
78 |
call init_level2 |
79 |
call init_hough |
80 |
*------------------------------------------------------ |
81 |
|
82 |
888 continue |
83 |
|
84 |
|
85 |
* /////////////////////////////////////////////// |
86 |
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
87 |
|
88 |
iflag=0 |
89 |
call track_finding(iflag) |
90 |
if(iflag.eq.1)then !bad event |
91 |
goto 880 !fill ntp and go to next event |
92 |
endif |
93 |
|
94 |
* ---------------------------------------------------- |
95 |
* fill hough output variables only for the first searc |
96 |
* ---------------------------------------------------- |
97 |
if(.not.SECOND_SEARCH)call fill_hough |
98 |
|
99 |
iflag=0 |
100 |
call track_fitting(iflag) |
101 |
|
102 |
|
103 |
* //////////////////////////////////////////////// |
104 |
* PATCH to recover events with less than 3 couples |
105 |
* //////////////////////////////////////////////// |
106 |
* if no tracks have been found |
107 |
* and n.planes with at least one couple (planehit) |
108 |
* is less than 3 try to recover applying the hough |
109 |
* transform to singlet |
110 |
nplanehit=0 |
111 |
do ip=1,NPLANES |
112 |
if(ncp_plane(ip).gt.0)nplanehit=nplanehit+1 |
113 |
enddo |
114 |
if(DEBUG.eq.1)then |
115 |
cc if(.true.)then |
116 |
print*,'' |
117 |
print*,'-----------------------------------' |
118 |
print*,'n.tracks ',ntrk |
119 |
print*,'n.hit-planes ',nplanehit |
120 |
endif |
121 |
if( |
122 |
$ .not.RECOVER_SINGLETS.and. !recover only once |
123 |
$ ntrk.eq.0 .and. !no tracks has been found |
124 |
$ nplanehit.le.3 .and. !if less than 3 hit planes (n.real couples) |
125 |
$ .true.)then |
126 |
RECOVER_SINGLETS=.true. |
127 |
cc if(.true.) |
128 |
if(DEBUG.EQ.1) |
129 |
$ print*,' -----> ((( TRY TO RECOVER SINGLETS )))' |
130 |
goto 888 !back to track finding |
131 |
endif |
132 |
|
133 |
|
134 |
* @~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@ |
135 |
* |
136 |
* EV may 2014 ==> SKIP NUCLEI PATCH |
137 |
* (done differently...) |
138 |
* |
139 |
* @~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@ |
140 |
goto 7575 |
141 |
|
142 |
|
143 |
* //////////////////////////////////////////////// |
144 |
* PATCH to recover nuclei |
145 |
* //////////////////////////////////////////////// |
146 |
itrk = ntrk !check the last track first |
147 |
isimage = 0 |
148 |
BAD_NUCLEUS=.false. |
149 |
150 continue |
150 |
|
151 |
dedxav = 0. |
152 |
npt = 0 |
153 |
dedxmin = 1000000 |
154 |
if(itrk.gt.0)then |
155 |
do ip=1,NPLANES |
156 |
cc print*,ip,' ** ',dedx_x(ip,itrk),dedx_y(ip,itrk) |
157 |
if(xgood_nt(ip,itrk).eq.1)then |
158 |
dedxav = dedxav + abs(dedx_x(ip,itrk)) |
159 |
if(abs(dedx_x(ip,itrk)).lt.dedxmin) |
160 |
$ dedxmin=abs(dedx_x(ip,itrk)) |
161 |
npt = npt + 1 |
162 |
endif |
163 |
if(ygood_nt(ip,itrk).eq.1)then |
164 |
dedxav = dedxav + abs(dedx_y(ip,itrk)) |
165 |
if(abs(dedx_y(ip,itrk)).lt.dedxmin) |
166 |
$ dedxmin=abs(dedx_y(ip,itrk)) |
167 |
npt = npt + 1 |
168 |
endif |
169 |
enddo |
170 |
if(npt.gt.0)dedxav = dedxav/npt |
171 |
if( dedxav.gt.dedx_min_nuclei )then |
172 |
if( (dedxav-dedxmin)/dedxav.gt.ddedx_min_nuclei ) |
173 |
$ BAD_NUCLEUS=.true. |
174 |
endif |
175 |
endif |
176 |
if(DEBUG.eq.1)then |
177 |
cc if(.true.)then |
178 |
print*,'' |
179 |
print*,'-----------------------------------' |
180 |
print*,'itrk ',itrk |
181 |
print*,'dedx(average) ',dedxav,' cut ',dedx_min_nuclei |
182 |
print*,'dedx(minimum) ',dedxmin |
183 |
if(dedxav.gt.0)print*,'(av-min)/av',(dedxav-dedxmin)/dedxav |
184 |
$ ,' cut ',ddedx_min_nuclei |
185 |
print*,'BAD_NUCLEUS ? ',BAD_NUCLEUS |
186 |
endif |
187 |
|
188 |
itrk=0 |
189 |
if(ntrk.gt.0)itrk = image(ntrk) |
190 |
if(itrk.gt.0.and.isimage.eq.0)then !hence check the image |
191 |
isimage=1 |
192 |
goto 150 |
193 |
endif |
194 |
|
195 |
|
196 |
if( |
197 |
$ .not.RECOVER_NUCLEI.and. !recover only once |
198 |
$ (ntrk.eq.0.or.BAD_NUCLEUS).and. !no tracks found or bad nucleus |
199 |
$ .true.)then |
200 |
|
201 |
RECOVER_NUCLEI = .true. |
202 |
dedx_x_min = dedx_x_min_nuclei |
203 |
dedx_y_min = dedx_y_min_nuclei |
204 |
cc if(.true.) |
205 |
if(DEBUG.EQ.1) |
206 |
$ print*,' -----> ((( TRY TO RECOVER NUCLEI )))' |
207 |
* ---------------------------------------------- |
208 |
* in case of re-tracking, un-tag used clusters |
209 |
* ---------------------------------------------- |
210 |
if(ntrk.ne.0)then |
211 |
do ip=1,NPLANES |
212 |
if(cltrx(ip,ntrk).ne.0)cl_used(cltrx(ip,ntrk)) = 0 !un-tag used clusters |
213 |
if(cltry(ip,ntrk).ne.0)cl_used(cltry(ip,ntrk)) = 0 !un-tag used clusters |
214 |
enddo |
215 |
ntrk = ntrk-1 !decrement track |
216 |
if(isimage.eq.1)then |
217 |
do ip=1,NPLANES |
218 |
if(cltrx(ip,ntrk).ne.0)cl_used(cltrx(ip,ntrk)) = 0 !un-tag used clusters |
219 |
if(cltry(ip,ntrk).ne.0)cl_used(cltry(ip,ntrk)) = 0 !un-tag used clusters |
220 |
enddo |
221 |
ntrk = ntrk-1 !decrement track image |
222 |
endif |
223 |
endif |
224 |
goto 888 !back to track finding |
225 |
|
226 |
endif |
227 |
* ---------------------------------------------- |
228 |
* back to default parameters for the second-track search |
229 |
* ---------------------------------------------- |
230 |
if(RECOVER_NUCLEI)then |
231 |
dedx_x_min = dedx_x_min_mip |
232 |
dedx_y_min = dedx_y_min_mip |
233 |
RECOVER_NUCLEI = .false. |
234 |
endif |
235 |
|
236 |
* @~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@ |
237 |
7575 continue |
238 |
* @~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@ |
239 |
|
240 |
if(ntrk.eq.0)goto 880 |
241 |
|
242 |
* ///////////////////////////////////////////////////// |
243 |
* PATCH to perform a more efficient second-track search |
244 |
* ///////////////////////////////////////////////////// |
245 |
* ------------------------------------------------- |
246 |
* n. hit planes and number of clusters |
247 |
* ------------------------------------------------- |
248 |
do ip=1,NPLANES |
249 |
hitplanex(ip)=0 |
250 |
hitplaney(ip)=0 |
251 |
nclusters=0 |
252 |
enddo |
253 |
do icl=1,nclstr1 |
254 |
ip = npl(VIEW(icl)) |
255 |
if(cl_good(icl).eq.0.or.cl_used(icl).eq.1)goto 9 |
256 |
if(mod(VIEW(icl),2).eq.1)hitplaney(ip)=hitplaney(ip)+1 !YY |
257 |
if(mod(VIEW(icl),2).eq.0)hitplanex(ip)=hitplanex(ip)+1 !XX |
258 |
nclusters=nclusters+1 |
259 |
9 continue |
260 |
enddo |
261 |
nhitplaney=0 |
262 |
nhitplanex=0 |
263 |
do ip=1,NPLANES |
264 |
if(hitplaney(ip).gt.0)nhitplaney=nhitplaney+1 |
265 |
if(hitplanex(ip).gt.0)nhitplanex=nhitplanex+1 |
266 |
enddo |
267 |
* ------------------------------------------------- |
268 |
* chi2 cut |
269 |
* ------------------------------------------------- |
270 |
p0 = 1.111588e+00 |
271 |
p1 = 1.707656e+00 |
272 |
p2 = 1.489693e-01 |
273 |
chi2m025 = p0 |
274 |
$ + abs(al_nt(5,ntrk))*p1 |
275 |
$ + al_nt(5,ntrk)*al_nt(5,ntrk)*p2 |
276 |
chi2m025_0 = p0 + 0.07*p1 + 0.07*0.07*p2 |
277 |
cc chi2m = (chi2m025-chi2m025_0+12**0.25)**4. !95% |
278 |
chi2m = (chi2m025-chi2m025_0+20.**0.25)**4. !??? |
279 |
* ------------------------------------------------- |
280 |
* image track |
281 |
* ------------------------------------------------- |
282 |
ntrk_best = ntrk |
283 |
chi2_best = chi2_nt(ntrk) |
284 |
if(image(ntrk).ne.0) |
285 |
$ chi2_best = min(chi2_nt(ntrk),chi2_nt(image(ntrk))) |
286 |
if(DEBUG.eq.1)then |
287 |
cc if(.true.)then |
288 |
print*,'' |
289 |
print*,'-----------------------------------' |
290 |
print*,'chi2_nt(',ntrk_best,') = ',chi2_best,' < ',chi2m,' ?' |
291 |
print*,'nhitplanex',nhitplanex |
292 |
print*,'nhitplaney',nhitplaney |
293 |
print*,'nclusters',nclusters |
294 |
endif |
295 |
if( |
296 |
$ ntrk.gt.ntrk_old.and. !one track must have been already found |
297 |
$ chi2_best.gt.0 .and. !this track must not be garbage |
298 |
$ chi2_best.lt.chi2m .and. !" |
299 |
$ nhitplaney.ge.3.and. !a minimum number of hit planes is required |
300 |
$ nhitplanex.ge.3.and. !" |
301 |
$ nclusters.le.20.and. !limit on number of clusters to save time |
302 |
$ .true.)then |
303 |
|
304 |
SECOND_SEARCH=.true. |
305 |
c RECOVER_SINGLETS=.true. !OPTIMIZATION |
306 |
ntrk_old=ntrk |
307 |
|
308 |
if(DEBUG.EQ.1) |
309 |
cc if(.true.) |
310 |
$ print*,'***** NEW SEARCH ****' |
311 |
goto 888 !back to track finding |
312 |
|
313 |
endif |
314 |
|
315 |
880 continue |
316 |
|
317 |
* ********************************************************** |
318 |
* stores info about clusters not associated with any track |
319 |
* ********************************************************** |
320 |
|
321 |
call fill_level2_siglets |
322 |
|
323 |
if(DEBUG.EQ.1)then |
324 |
print*,'' |
325 |
print*,'DONE!' |
326 |
print*,'' |
327 |
print*,'* summary *' |
328 |
print*,'tracks ',ntrk |
329 |
print*,'cl used ',(cl_used(i),i=1,nclstr1) |
330 |
print*,'' |
331 |
print*,'' |
332 |
endif |
333 |
|
334 |
ngood = 0 |
335 |
do iv = 1,nviews |
336 |
ngood = ngood + good1(iv) |
337 |
enddo |
338 |
|
339 |
c 8800 continue |
340 |
continue |
341 |
|
342 |
|
343 |
* /////////////////////////////////////////////// |
344 |
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
345 |
|
346 |
c 100 continue |
347 |
continue |
348 |
|
349 |
return |
350 |
end |
351 |
|
352 |
|
353 |
************************************************************ |
354 |
|
355 |
|