| 1 |
************************************************************************* |
| 2 |
* |
| 3 |
* Program reductionflight.f |
| 4 |
* |
| 5 |
* - reads readraw.f output files: LEVEL0 ntuple, and ped, sig and bad histograms |
| 6 |
* - decodes raw data (DATATRACKER) using DSP ped, sig and bad values |
| 7 |
* - looks for clusters information using ped, sig and bad values from |
| 8 |
* DSP histograms |
| 9 |
* - fills LEVEL1 ntuple |
| 10 |
* |
| 11 |
************************************************************************* |
| 12 |
|
| 13 |
subroutine reductionflight(ierror) |
| 14 |
|
| 15 |
include 'commontracker.f' |
| 16 |
include 'level0.f' |
| 17 |
include 'level1.f' |
| 18 |
include 'common_reduction.f' |
| 19 |
include 'calib.f' |
| 20 |
|
| 21 |
data eventn_old/nviews*0/ |
| 22 |
|
| 23 |
integer ierror |
| 24 |
ierror = 0 |
| 25 |
|
| 26 |
c$$$ debug = .true. |
| 27 |
c$$$ verbose = .true. |
| 28 |
c$$$ warning = .true. |
| 29 |
|
| 30 |
* ////////////////////////// |
| 31 |
* initialize some parameters |
| 32 |
* ////////////////////////// |
| 33 |
|
| 34 |
call init_level1 |
| 35 |
|
| 36 |
c debug=.true. |
| 37 |
|
| 38 |
if(debug)print*,'-- check LEVEL0 status' |
| 39 |
|
| 40 |
ievco=-1 |
| 41 |
mismatch=0 |
| 42 |
c good1 = good0 |
| 43 |
c-------------------------------------------------- |
| 44 |
c check the LEVEL0 event status for missing |
| 45 |
c sections or DSP alarms |
| 46 |
c ==> set the variable GOOD1(12) |
| 47 |
c-------------------------------------------------- |
| 48 |
do iv=1,nviews |
| 49 |
if(DSPnumber(iv).gt.0.and.DSPnumber(iv).le.12)then |
| 50 |
c ------------------------ |
| 51 |
c GOOD |
| 52 |
c ------------------------ |
| 53 |
GOOD1(DSPnumber(iv))=0 !OK |
| 54 |
c ------------------------ |
| 55 |
c CRC error |
| 56 |
c ------------------------ |
| 57 |
if(crc(iv).eq.1) then |
| 58 |
c GOOD1(DSPnumber(iv)) = 2 |
| 59 |
c GOOD1(DSPnumber(iv)) = GOOD1(DSPnumber(iv)) + 2**1 |
| 60 |
GOOD1(DSPnumber(iv)) = ior(GOOD1(DSPnumber(iv)),2**1) |
| 61 |
102 format(' * WARNING * Event ',i7,' view',i3 |
| 62 |
$ ,' CRC error') |
| 63 |
if(debug)write(*,102)eventn(1),DSPnumber(iv) |
| 64 |
c goto 18 !next view |
| 65 |
endif |
| 66 |
c ------------------------ |
| 67 |
c online-software alarm |
| 68 |
c ------------------------ |
| 69 |
if( |
| 70 |
$ fl1(iv).ne.0.or. |
| 71 |
$ fl2(iv).ne.0.or. |
| 72 |
$ fl3(iv).ne.0.or. |
| 73 |
$ fl4(iv).ne.0.or. |
| 74 |
$ fl5(iv).ne.0.or. |
| 75 |
$ fl6(iv).ne.0.or. |
| 76 |
$ fc(iv).ne.0.or. |
| 77 |
$ DATAlength(iv).eq.0.or. |
| 78 |
$ .false.)then |
| 79 |
c GOOD1(DSPnumber(iv))=3 |
| 80 |
c GOOD1(DSPnumber(iv)) = GOOD1(DSPnumber(iv)) + 2**2 |
| 81 |
GOOD1(DSPnumber(iv)) = ior(GOOD1(DSPnumber(iv)),2**2) |
| 82 |
103 format(' * WARNING * Event ',i7,' view',i3 |
| 83 |
$ ,' software alarm') |
| 84 |
if(debug)write(*,103)eventn(1),DSPnumber(iv) |
| 85 |
c goto 18 |
| 86 |
endif |
| 87 |
c ------------------------ |
| 88 |
c DSP-counter jump |
| 89 |
c ------------------------ |
| 90 |
c commentato perche` non e` un controllo significativo nel caso in cui |
| 91 |
c la subroutine venga chiamata per riprocessare l'evento |
| 92 |
c sostituito con un check dei contatori dei vari dsp |
| 93 |
c$$$ if( |
| 94 |
c$$$ $ eventn_old(iv).ne.0.and. !first event in this file |
| 95 |
c$$$ $ eventn(iv).ne.1.and. !first event in run |
| 96 |
c$$$ $ good_old(DSPnumber(iv)).ne.0.and. !previous event corrupted |
| 97 |
c$$$ $ .true.)then |
| 98 |
c$$$ |
| 99 |
c$$$ if(eventn(iv).ne.(eventn_old(iv)+1))then |
| 100 |
c$$$c GOOD1(DSPnumber(iv))=4 |
| 101 |
c$$$c GOOD1(DSPnumber(iv)) = GOOD1(DSPnumber(iv)) + 2**3 |
| 102 |
c$$$ GOOD1(DSPnumber(iv)) = ior(GOOD1(DSPnumber(iv)),2**3) |
| 103 |
c$$$ 104 format(' * WARNING * Event ',i7,' view',i3 |
| 104 |
c$$$ $ ,' counter jump ',i10,i10) |
| 105 |
c$$$ if(debug)write(*,104)eventn(1),DSPnumber(iv) |
| 106 |
c$$$ $ ,eventn_old(iv),eventn(iv)) |
| 107 |
c$$$ goto 18 |
| 108 |
c$$$ endif |
| 109 |
c$$$ |
| 110 |
c$$$ endif |
| 111 |
c ------------------------ |
| 112 |
c 18 continue |
| 113 |
c ------------------------ |
| 114 |
c DSP-counter |
| 115 |
c ------------------------ |
| 116 |
if( DSPnumber(iv).ne.0.and.GOOD1(DSPnumber(iv)).ne.1)then |
| 117 |
if(iv.ne.1.and.ievco.ne.-1)then |
| 118 |
if( eventn(iv).ne.ievco )then |
| 119 |
mismatch=1 |
| 120 |
endif |
| 121 |
endif |
| 122 |
ievco = eventn(iv) |
| 123 |
endif |
| 124 |
endif |
| 125 |
enddo |
| 126 |
|
| 127 |
c print*,'*** ',(eventn(iv),iv=1,12) |
| 128 |
|
| 129 |
if(mismatch.eq.1.and.debug) |
| 130 |
$ print*,' * WARNING * DSP counter mismatch: ' |
| 131 |
$ ,(eventn(iv),iv=1,12) |
| 132 |
|
| 133 |
ngood = 0 |
| 134 |
do iv = 1,nviews |
| 135 |
|
| 136 |
if(mismatch.eq.1.and.GOOD1(iv).ne.1) |
| 137 |
$ GOOD1(iv)=ior(GOOD1(iv),2**3) |
| 138 |
|
| 139 |
eventn_old(iv) = eventn(iv) |
| 140 |
good_old(iv) = good1(iv) |
| 141 |
ngood = ngood + good1(iv) |
| 142 |
|
| 143 |
enddo |
| 144 |
c$$$ if(verbose.and.ngood.ne.0)print*,'* WARNING * Event ',eventn(1) |
| 145 |
c$$$ $ ,':LEVEL0 event status: ' |
| 146 |
c$$$ $ ,(good1(i),i=1,nviews) |
| 147 |
c-------------------------------------------------- |
| 148 |
c read the variable DATATRACKER from LEVEL0 |
| 149 |
c and fill the variable ADC (invertin view 11) |
| 150 |
c-------------------------------------------------- |
| 151 |
|
| 152 |
if(debug)print*,'-- fill ADC vectors' |
| 153 |
|
| 154 |
call filladc(iflag) |
| 155 |
if(iflag.ne.0)then |
| 156 |
ierror = 220 |
| 157 |
endif |
| 158 |
|
| 159 |
c-------------------------------------------------- |
| 160 |
c computes common noise for each VA1 |
| 161 |
c (excluding strips with signal, |
| 162 |
c tagged with the flag CLSTR) |
| 163 |
c-------------------------------------------------- |
| 164 |
if(debug)print*,'-- compute CN' |
| 165 |
|
| 166 |
do iv=1,nviews |
| 167 |
ima=0 |
| 168 |
do ik=1,nva1_view |
| 169 |
cn(iv,ik) = 0 |
| 170 |
cnrms(iv,ik) = 0 |
| 171 |
cnn(iv,ik) = -1 |
| 172 |
iflag = 0 |
| 173 |
mask_vk_ev(iv,ik) = 1 |
| 174 |
call stripmask(iv,ik) !compute mask(i,j,k), combining VA1-masks |
| 175 |
* -------------------------------------- |
| 176 |
* if chip is not masked ---> evaluate CN |
| 177 |
* -------------------------------------- |
| 178 |
if( mask(iv,ik,1).eq.1 ) then !!!NBNB mask per la striscia 1 !!!!!!!! |
| 179 |
call cncomp(iv,ik,iflag) |
| 180 |
if(iflag.ne.0)then |
| 181 |
ima=ima+1 |
| 182 |
mask_vk_ev(iv,ik)=0 |
| 183 |
ierror = 220 |
| 184 |
endif |
| 185 |
call stripmask(iv,ik) !compute mask(i,j,k), combining VA1-masks |
| 186 |
endif |
| 187 |
enddo |
| 188 |
100 format(' * WARNING * Event ',i7,' view',i3,': VK MASK ',24i1) |
| 189 |
if(ima.ne.0.and.verbose)write(*,100)eventn(1),iv |
| 190 |
$ ,(mask_vk_ev(iv,ik),ik=1,nva1_view) |
| 191 |
c if(ima.ne.0)write(*,100)eventn(1),iv |
| 192 |
c $ ,(mask_vk_ev(iv,ik),ik=1,nva1_view) |
| 193 |
enddo |
| 194 |
|
| 195 |
cc call stripmask !compute mask(i,j,k), combining mask_vk_ev and mask_vk |
| 196 |
|
| 197 |
c--------------------------------------------- |
| 198 |
c loops on views, VA1 and strips, |
| 199 |
c and computes strips signals using |
| 200 |
c badstrip, pedestals, and |
| 201 |
c sigma informations from histograms |
| 202 |
c--------------------------------------------- |
| 203 |
ind=1 !clsignal array index |
| 204 |
|
| 205 |
if(debug)print*,'-- search clusters' |
| 206 |
do iv=1,nviews !loop on views |
| 207 |
do is=1,nstrips_view !loop on strips (1) |
| 208 |
if(mod(iv,2).eq.1) then |
| 209 |
C=== > Y view |
| 210 |
c print*,iv,nvk(is),nst(is),adc(iv,nvk(is),nst(is)) |
| 211 |
c $ ,cn(iv,nvk(is)) |
| 212 |
c $ ,pedestal(iv,nvk(is),nst(is)) |
| 213 |
value(is)= -(DBLE(adc(iv,nvk(is),nst(is))) |
| 214 |
$ -cn(iv,nvk(is))-pedestal(iv,nvk(is),nst(is))) |
| 215 |
$ *mask(iv,nvk(is),nst(is)) |
| 216 |
clseedcut(is)=clcuty*sigma(iv,nvk(is),nst(is)) |
| 217 |
$ *mask(iv,nvk(is),nst(is)) |
| 218 |
clinclcut(is)=incuty*sigma(iv,nvk(is),nst(is)) |
| 219 |
$ *mask(iv,nvk(is),nst(is)) |
| 220 |
sat(is)=0 |
| 221 |
if( adc(iv,nvk(is),nst(is)).lt.adc_saty )sat(is)=1 |
| 222 |
else |
| 223 |
C=== > X view |
| 224 |
value(is)= (DBLE(adc(iv,nvk(is),nst(is))) |
| 225 |
$ -cn(iv,nvk(is))-pedestal(iv,nvk(is),nst(is))) |
| 226 |
$ *mask(iv,nvk(is),nst(is)) |
| 227 |
clseedcut(is)=clcutx*sigma(iv,nvk(is),nst(is)) |
| 228 |
$ *mask(iv,nvk(is),nst(is)) |
| 229 |
clinclcut(is)=incutx*sigma(iv,nvk(is),nst(is)) |
| 230 |
$ *mask(iv,nvk(is),nst(is)) |
| 231 |
sat(is)=0 |
| 232 |
if( adc(iv,nvk(is),nst(is)).gt.adc_satx )sat(is)=1 |
| 233 |
endif |
| 234 |
enddo !end loop on strips (1) |
| 235 |
call search_cluster(iv) |
| 236 |
|
| 237 |
if(.not.flag_shower)then |
| 238 |
call save_cluster(iv) |
| 239 |
if(debug)print*,'view ',iv,' #clusters ', nclstr_view |
| 240 |
else |
| 241 |
fshower(iv) = 1 |
| 242 |
c GOOD1(DSPnumber(iv)) = 11 !AHAHAHAHA ORRORE!! |
| 243 |
c GOOD1(iv) = 11 |
| 244 |
c GOOD1(iv) = GOOD1(iv) + 2**5 |
| 245 |
GOOD1(iv) = ior(GOOD1(iv),2**5) |
| 246 |
101 format(' * WARNING * Event ',i7,' view',i3 |
| 247 |
$ ,' #clusters > ',i5,' --> MASKED') |
| 248 |
if(verbose)write(*,101)eventn(1),iv,nclstrmax_view |
| 249 |
endif |
| 250 |
enddo ! end loop on views |
| 251 |
do iv=1,nviews |
| 252 |
do ik=1,nva1_view |
| 253 |
cnev(iv,ik) = cn(iv,ik) !assigns computed CN to ntuple variables |
| 254 |
cnrmsev(iv,ik) = cnrms(iv,ik) !assigns computed CN to ntuple variables |
| 255 |
cnnev(iv,ik) = cnn(iv,ik) !assigns computed CN to ntuple variables |
| 256 |
enddo |
| 257 |
enddo |
| 258 |
C--------------------------------------------- |
| 259 |
C come here if GOOD1=0 |
| 260 |
C or the event has too many clusters |
| 261 |
C--------------------------------------------- |
| 262 |
200 continue |
| 263 |
|
| 264 |
ngood = 0 |
| 265 |
do iv = 1,nviews |
| 266 |
ngood = ngood + good1(iv) |
| 267 |
enddo |
| 268 |
if(verbose.and.ngood.ne.0)print*,'* WARNING * Event ',eventn(1) |
| 269 |
$ ,':LEVEL1 event status: ' |
| 270 |
$ ,(good1(i),i=1,nviews) |
| 271 |
c------------------------------------------------------------------------ |
| 272 |
c |
| 273 |
c closes files and exits |
| 274 |
c |
| 275 |
c------------------------------------------------------------------------ |
| 276 |
RETURN |
| 277 |
END |
| 278 |
|
| 279 |
***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** |
| 280 |
* |
| 281 |
* |
| 282 |
* |
| 283 |
* |
| 284 |
* |
| 285 |
* |
| 286 |
* |
| 287 |
* |
| 288 |
* |
| 289 |
***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** |
| 290 |
|
| 291 |
|
| 292 |
subroutine init_level1 |
| 293 |
|
| 294 |
include 'commontracker.f' |
| 295 |
include 'level1.f' |
| 296 |
include 'level0.f' |
| 297 |
|
| 298 |
c good1 = 0 |
| 299 |
do iv=1,12 |
| 300 |
good1(iv) = 1 !missing packet |
| 301 |
enddo |
| 302 |
nclstr1 = 0 |
| 303 |
totCLlength = 0 |
| 304 |
do ic=1,nclstrmax |
| 305 |
view(ic) = 0 |
| 306 |
ladder(ic) = 0 |
| 307 |
indstart(ic) = 0 |
| 308 |
indmax(ic) = 0 |
| 309 |
maxs(ic) = 0 |
| 310 |
mult(ic) = 0 |
| 311 |
sgnl(ic) = 0 |
| 312 |
whichtrack(ic) = 0 !assigned @ level2 |
| 313 |
|
| 314 |
enddo |
| 315 |
do id=1,maxlength !??? |
| 316 |
clsignal(id) = 0. |
| 317 |
clsigma(id) = 0. |
| 318 |
cladc(id) = 0. |
| 319 |
clbad(id) = 0. |
| 320 |
enddo |
| 321 |
do iv=1,nviews |
| 322 |
c crc1(iv)=0 |
| 323 |
do ik=1,nva1_view |
| 324 |
cnev(iv,ik) = 0 |
| 325 |
cnnev(iv,ik) = 0 |
| 326 |
enddo |
| 327 |
fshower(iv) = 0 |
| 328 |
enddo |
| 329 |
|
| 330 |
return |
| 331 |
end |
| 332 |
|
| 333 |
*---***---***---***---***---***---***---***---*** |
| 334 |
* |
| 335 |
* |
| 336 |
* |
| 337 |
* |
| 338 |
* |
| 339 |
*---***---***---***---***---***---***---***---*** |
| 340 |
|
| 341 |
subroutine search_cluster(iv) |
| 342 |
|
| 343 |
include 'commontracker.f' |
| 344 |
include 'level0.f' |
| 345 |
include 'level1.f' |
| 346 |
include 'calib.f' |
| 347 |
|
| 348 |
include 'common_reduction.f' |
| 349 |
|
| 350 |
|
| 351 |
c local variables |
| 352 |
integer rmax,lmax !estremi del cluster |
| 353 |
integer rstop,lstop |
| 354 |
integer first,last |
| 355 |
integer fsat,lsat |
| 356 |
|
| 357 |
external nst |
| 358 |
|
| 359 |
iseed=-999 !cluster seed index initialization |
| 360 |
|
| 361 |
inext=-999 !index where to start new cluster search |
| 362 |
|
| 363 |
flag_shower = .false. |
| 364 |
nclstr_view=0 |
| 365 |
|
| 366 |
do jl=1,nladders_view !1..3 !loops on ladders |
| 367 |
|
| 368 |
first = 1+nstrips_ladder*(jl-1) !1,1025,2049 |
| 369 |
last = nstrips_ladder*jl !1024,2048,3072 |
| 370 |
|
| 371 |
* X views have 1018 strips instead of 1024 |
| 372 |
if(mod(iv,2).eq.0) then |
| 373 |
first=first+3 |
| 374 |
last=last-3 |
| 375 |
endif |
| 376 |
|
| 377 |
do is=first,last !loop on strips in each ladder |
| 378 |
|
| 379 |
c--------------------------------------------- |
| 380 |
c new-cluster search starts at index inext |
| 381 |
c--------------------------------------------- |
| 382 |
if(is.lt.inext) goto 220 ! next strip |
| 383 |
|
| 384 |
if(value(is).gt.clseedcut(is)) then |
| 385 |
c----------------------------------------- |
| 386 |
c possible SEED... |
| 387 |
c----------------------------------------- |
| 388 |
itemp = is |
| 389 |
fsat = 0 ! first saturated strip |
| 390 |
lsat = 0 ! last saturated strip |
| 391 |
if(itemp.eq.last) goto 230 !estremo... |
| 392 |
c ------------------------ |
| 393 |
c search for first maximum |
| 394 |
c ------------------------ |
| 395 |
do while( |
| 396 |
$ value(itemp).le.value(itemp+1) |
| 397 |
$ .and.value(itemp+1).gt.clseedcut(itemp+1)) |
| 398 |
itemp = itemp+1 |
| 399 |
if(itemp.eq.last) goto 230 !stops if reaches last strip |
| 400 |
if(sat(itemp).eq.1) goto 230 !stop if reaches a saturated strip |
| 401 |
enddo ! of the ladder |
| 402 |
230 continue |
| 403 |
c ----------------------------- |
| 404 |
c check if strips are saturated |
| 405 |
c ----------------------------- |
| 406 |
if( sat(itemp).eq.1 )then |
| 407 |
fsat = itemp |
| 408 |
lsat = itemp |
| 409 |
if(itemp.eq.last) goto 231 !estremo... |
| 410 |
do while( sat(itemp+1).eq.1 ) |
| 411 |
itemp = itemp+1 |
| 412 |
lsat = itemp |
| 413 |
if(itemp.eq.last) goto 231 !stops if reaches last strip |
| 414 |
enddo |
| 415 |
endif |
| 416 |
231 continue |
| 417 |
c--------------------------------------------------------------------------- |
| 418 |
c fownd SEED!!! |
| 419 |
c (if there are saturated strips, the cluster is centered in the middle) |
| 420 |
c--------------------------------------------------------------------------- |
| 421 |
if(fsat.eq.0.and.lsat.eq.0)then |
| 422 |
iseed = itemp ! <<< SEED |
| 423 |
else |
| 424 |
iseed = int((lsat+fsat)/2) ! <<< SEED |
| 425 |
c$$$ print*,'saturated strips ',fsat,lsat,iseed |
| 426 |
c$$$ print*,'--> ',(value(ii),ii=fsat,lsat) |
| 427 |
endif |
| 428 |
c--------------------------------------------------------------- |
| 429 |
c after finding a cluster seed, checks also adjacent strips, |
| 430 |
C and tags the ones exceeding clinclcut |
| 431 |
c--------------------------------------------------------------- |
| 432 |
ir=iseed !indici destro |
| 433 |
il=iseed ! e sinistro |
| 434 |
|
| 435 |
rmax=ir !estremo destro del cluster |
| 436 |
lmax=il ! e sinistro |
| 437 |
|
| 438 |
rstop=0 !initialize flags used to exit from |
| 439 |
lstop=0 ! inclusion loop |
| 440 |
|
| 441 |
do while(lstop.eq.0.or.rstop.eq.0) !shifts left and right from |
| 442 |
|
| 443 |
|
| 444 |
ir=ir+1 !index for right side |
| 445 |
il=il-1 !index for left side |
| 446 |
c------------------------------------------------------------------------ |
| 447 |
c checks for last or first strip of the ladder |
| 448 |
c------------------------------------------------------------------------ |
| 449 |
if( ir.gt.last ) rstop = 1 |
| 450 |
if( il.lt.first ) lstop = 1 |
| 451 |
|
| 452 |
c------------------------------------------------------------------------ |
| 453 |
c add strips exceeding inclusion cut |
| 454 |
c------------------------------------------------------------------------ |
| 455 |
if( (rmax-lmax+1).ge.nclstrp )goto 210 !exits inclusion loop |
| 456 |
|
| 457 |
if(rstop.eq.0) then !if right cluster morder has not been reached |
| 458 |
if(value(ir).gt.clinclcut(ir)) then |
| 459 |
rmax=ir !include a strip on the right |
| 460 |
else |
| 461 |
rstop=1 !cluster right end |
| 462 |
endif |
| 463 |
endif |
| 464 |
|
| 465 |
if( (rmax-lmax+1).ge.nclstrp )goto 210 !exits inclusion loop |
| 466 |
|
| 467 |
if(lstop.eq.0) then !if left cluster morder has not been reached |
| 468 |
if(value(il).gt.clinclcut(il)) then |
| 469 |
lmax=il !include a strip on the left |
| 470 |
else |
| 471 |
lstop=1 !cluster left end |
| 472 |
endif |
| 473 |
endif |
| 474 |
|
| 475 |
enddo !ends strip inclusion loop |
| 476 |
goto 211 |
| 477 |
210 continue !jumps here if more than nclstrp have been included |
| 478 |
c print*,'>>> nclstrp! ' |
| 479 |
211 continue |
| 480 |
c----------------------------------------- |
| 481 |
c end of inclusion loop! |
| 482 |
c----------------------------------------- |
| 483 |
|
| 484 |
c------------------------------------------------------------------------ |
| 485 |
c adjust the cluster in order to have at least a strip around the seed |
| 486 |
c------------------------------------------------------------------------ |
| 487 |
if(iseed.eq.lmax.and.lmax.ne.first)then |
| 488 |
lmax = lmax-1 |
| 489 |
if( (rmax-lmax+1).gt.nclstrp )rmax=rmax-1 |
| 490 |
endif |
| 491 |
if(iseed.eq.rmax.and.rmax.ne.last )then |
| 492 |
rmax = rmax+1 |
| 493 |
if( (rmax-lmax+1).gt.nclstrp )lmax=lmax+1 |
| 494 |
endif |
| 495 |
|
| 496 |
c------------------------------------------------------------------------ |
| 497 |
c adjust the cluster in order to store a minimum number of strips |
| 498 |
c------------------------------------------------------------------------ |
| 499 |
do while( (rmax-lmax+1).lt.nclstrpmin ) |
| 500 |
|
| 501 |
vl = -99999 |
| 502 |
vr = -99999 |
| 503 |
if(lmax-1.ge.first) vl = value(lmax-1) |
| 504 |
if(rmax+1.le.last ) vr = value(rmax+1) |
| 505 |
if(vr.ge.vl) then |
| 506 |
rmax = rmax+1 |
| 507 |
else |
| 508 |
lmax = lmax-1 |
| 509 |
endif |
| 510 |
|
| 511 |
enddo |
| 512 |
|
| 513 |
c-------------------------------------------------------- |
| 514 |
c store cluster info |
| 515 |
c-------------------------------------------------------- |
| 516 |
nclstr_view = nclstr_view + 1 !cluster number |
| 517 |
|
| 518 |
if(nclstr_view.gt.nclstrmax_view) then !too many clusters for the view: |
| 519 |
c$$$ if(verbose) print*,'Event ',eventn(1), |
| 520 |
c$$$ $ ': more than ',nclstrmax_view |
| 521 |
c$$$ $ ,' clusters on view ',iv |
| 522 |
flag_shower = .true. |
| 523 |
goto 2000 |
| 524 |
endif |
| 525 |
|
| 526 |
ladder_view(nclstr_view) = nld(iseed,iv) |
| 527 |
maxs_view(nclstr_view) = iseed |
| 528 |
mult_view(nclstr_view) = rmax-lmax+1 |
| 529 |
rmax_view(nclstr_view) = rmax |
| 530 |
lmax_view(nclstr_view) = lmax |
| 531 |
|
| 532 |
c$$$ if(rmax-lmax+1.gt.25) |
| 533 |
c$$$ $ print*,'view ',iv |
| 534 |
c$$$ $ ,' cl ',nclstr_view,' mult ',rmax-lmax+1 |
| 535 |
c------------------------------------------------------------------------ |
| 536 |
c search for a double peak inside the cluster |
| 537 |
c------------------------------------------------------------------------ |
| 538 |
inext = rmax+1 !<< index where to start new-cluster search |
| 539 |
|
| 540 |
vmax = 0 |
| 541 |
vmin = value(iseed) |
| 542 |
imax = iseed |
| 543 |
imin = iseed |
| 544 |
do iss = max(iseed+1,lsat+1),rmax |
| 545 |
if( value(iss).lt.vmin )then |
| 546 |
if( imax.ne.iseed )goto 221 !found dowble peek |
| 547 |
imin = iss |
| 548 |
vmin = value(iss) |
| 549 |
else |
| 550 |
delta = value(iss) - value(imin) |
| 551 |
cut = sqrt(clinclcut(iss)**2 + clinclcut(imin)**2) |
| 552 |
if( |
| 553 |
$ delta.gt.cut .and. |
| 554 |
$ value(iss).gt.clseedcut(iss).and. |
| 555 |
$ .true.)then |
| 556 |
if( value(iss).gt.vmax )then |
| 557 |
imax = iss |
| 558 |
vmax = value(iss) |
| 559 |
else |
| 560 |
goto 221 !found dowble peek |
| 561 |
endif |
| 562 |
endif |
| 563 |
endif |
| 564 |
enddo |
| 565 |
221 continue |
| 566 |
|
| 567 |
if(imax.gt.iseed)then |
| 568 |
inext = imax !<< index where to start new-cluster search |
| 569 |
c$$$ print*,'--- double peek ---' |
| 570 |
c$$$ print*,(value(ii),ii=lmax,rmax) |
| 571 |
c$$$ print*,'seed ',iseed,' imin ',imin,' imax ',imax |
| 572 |
endif |
| 573 |
c-------------------------------------------------------- |
| 574 |
c |
| 575 |
c-------------------------------------------------------- |
| 576 |
endif !end possible seed conditio |
| 577 |
220 continue !jumps here to skip strips left of last seed |
| 578 |
|
| 579 |
enddo ! end loop on strips |
| 580 |
enddo !end loop on ladders |
| 581 |
2000 continue |
| 582 |
return |
| 583 |
end |
| 584 |
|
| 585 |
|
| 586 |
*---***---***---***---***---***---***---***---*** |
| 587 |
* |
| 588 |
* |
| 589 |
* |
| 590 |
* |
| 591 |
* |
| 592 |
*---***---***---***---***---***---***---***---*** |
| 593 |
|
| 594 |
subroutine save_cluster(iv) |
| 595 |
* |
| 596 |
* (080/2006 Elena Vannuccini) |
| 597 |
* Save the clusters view by view |
| 598 |
|
| 599 |
include 'commontracker.f' |
| 600 |
include 'level1.f' |
| 601 |
include 'calib.f' |
| 602 |
include 'common_reduction.f' |
| 603 |
|
| 604 |
integer CLlength !lunghezza in strip del cluster |
| 605 |
|
| 606 |
do ic=1,nclstr_view |
| 607 |
|
| 608 |
nclstr1 = nclstr1+1 |
| 609 |
view(nclstr1) = iv |
| 610 |
ladder(nclstr1) = ladder_view(ic) |
| 611 |
maxs(nclstr1) = maxs_view(ic) |
| 612 |
mult(nclstr1) = mult_view(ic) |
| 613 |
|
| 614 |
c posizione dell'inizio del cluster nell' array clsignal |
| 615 |
indstart(nclstr1) = ind |
| 616 |
c posizione del cluster seed nell'array clsignal |
| 617 |
indmax(nclstr1) = indstart(nclstr1) |
| 618 |
$ +( maxs_view(ic) - lmax_view(ic) ) |
| 619 |
|
| 620 |
CLlength = rmax_view(ic) - lmax_view(ic) + 1 !numero di strip salvate |
| 621 |
totCLlength = totCLlength + CLlength |
| 622 |
sgnl(nclstr1) = 0 |
| 623 |
do j=lmax_view(ic),rmax_view(ic) !stores sequentially cluter strip values in |
| 624 |
|
| 625 |
clsignal(ind) = value(j) ! clsignal array |
| 626 |
c$$$ print*,ind,clsignal(ind) |
| 627 |
ivk=nvk(j) |
| 628 |
ist=nst(j) |
| 629 |
|
| 630 |
clsigma(ind) = sigma(iv,ivk,ist) |
| 631 |
cladc(ind) = adc(iv,ivk,ist) |
| 632 |
clbad(ind) = bad(iv,ivk,ist) |
| 633 |
c clped(ind) = pedestal(iv,ivk,ist) |
| 634 |
|
| 635 |
ind=ind+1 |
| 636 |
c if(value(j).gt.0) |
| 637 |
if(value(j).gt.clinclcut(j)) |
| 638 |
$ sgnl(nclstr1) = sgnl(nclstr1) + value(j) !cluster charge |
| 639 |
enddo |
| 640 |
|
| 641 |
c$$$ print*,'view ',iv,' -- save_cluster -- nclstr1: ' |
| 642 |
c$$$ $ ,nclstr1,maxs(nclstr1),mult(nclstr1),sgnl(nclstr1) |
| 643 |
c$$$ print*,'----------------------' |
| 644 |
|
| 645 |
enddo |
| 646 |
|
| 647 |
return |
| 648 |
end |
| 649 |
*---***---***---***---***---***---***---***---*** |
| 650 |
* |
| 651 |
* |
| 652 |
* |
| 653 |
* |
| 654 |
* |
| 655 |
*---***---***---***---***---***---***---***---*** |
| 656 |
|
| 657 |
|
| 658 |
c$$$ subroutine stripmask |
| 659 |
c$$$ |
| 660 |
c$$$* this routine set va1 and single-strip masks, |
| 661 |
c$$$* on the basis of the VA1 mask saved in the DB |
| 662 |
c$$$* |
| 663 |
c$$$* mask(nviews,nva1_view,nstrips_va1) !strip mask |
| 664 |
c$$$* mask_vk(nviews,nva1_view) !VA1 mask |
| 665 |
c$$$* |
| 666 |
c$$$ include 'commontracker.f' |
| 667 |
c$$$ include 'level1.f' |
| 668 |
c$$$ include 'common_reduction.f' |
| 669 |
c$$$ include 'calib.f' |
| 670 |
c$$$ |
| 671 |
c$$$* init mask |
| 672 |
c$$$ do iv=1,nviews |
| 673 |
c$$$ do ivk=1,nva1_view |
| 674 |
c$$$ do is=1,nstrips_va1 |
| 675 |
c$$$c mask(iv,ivk,is) = mask_vk(iv,ivk) |
| 676 |
c$$$ if( mask_vk(iv,ivk) .ne. -1)then |
| 677 |
c$$$ mask(iv,ivk,is) = 1 |
| 678 |
c$$$ $ * mask_vk(iv,ivk) !from DB |
| 679 |
c$$$ $ * mask_vk_ev(iv,ivk) !from <SIG> |
| 680 |
c$$$ $ * mask_vk_run(iv,ivk) !from CN |
| 681 |
c$$$ else |
| 682 |
c$$$ mask(iv,ivk,is) = -1 |
| 683 |
c$$$ $ * mask_vk(iv,ivk) !from DB |
| 684 |
c$$$ $ * mask_vk_ev(iv,ivk) !from CN |
| 685 |
c$$$ endif |
| 686 |
c$$$ enddo |
| 687 |
c$$$ enddo |
| 688 |
c$$$ enddo |
| 689 |
c$$$ |
| 690 |
c$$$ |
| 691 |
c$$$ return |
| 692 |
c$$$ end |
| 693 |
|
| 694 |
subroutine stripmask(iv,ivk) |
| 695 |
|
| 696 |
* ----------------------------------------------- |
| 697 |
* this routine set va1 and single-strip masks, |
| 698 |
* on the basis of the VA1 mask saved in the DB |
| 699 |
* |
| 700 |
* mask(nviews,nva1_view,nstrips_va1) !strip mask |
| 701 |
* mask_vk(nviews,nva1_view) !VA1 mask |
| 702 |
* ----------------------------------------------- |
| 703 |
include 'commontracker.f' |
| 704 |
include 'level1.f' |
| 705 |
include 'common_reduction.f' |
| 706 |
include 'calib.f' |
| 707 |
|
| 708 |
* init mask |
| 709 |
do is=1,nstrips_va1 |
| 710 |
* -------------------------------------------------------- |
| 711 |
* if VA1-mask from DB is 0 or 1, three masks are combined: |
| 712 |
* - from DB (a-priori mask) |
| 713 |
* - run-based (chip declared bad on the basis of <SIG>) |
| 714 |
* - event-based (failure in CN computation) |
| 715 |
* -------------------------------------------------------- |
| 716 |
c print*,iv,ivk |
| 717 |
c $ ,mask_vk(iv,ivk),mask_vk_ev(iv,ivk),mask_vk_run(iv,ivk) |
| 718 |
if( mask_vk(iv,ivk) .ne. -1)then |
| 719 |
mask(iv,ivk,is) = 1 |
| 720 |
$ * mask_vk(iv,ivk) !from DB |
| 721 |
$ * mask_vk_ev(iv,ivk) !from <SIG> |
| 722 |
$ * mask_vk_run(iv,ivk) !from CN |
| 723 |
* ----------------------------------------------------------- |
| 724 |
* if VA1-mask from DB is -1 only event-based mask is applied |
| 725 |
* ----------------------------------------------------------- |
| 726 |
else |
| 727 |
mask(iv,ivk,is) = -1 |
| 728 |
$ * mask_vk(iv,ivk) !from DB |
| 729 |
$ * mask_vk_ev(iv,ivk) !from CN |
| 730 |
endif |
| 731 |
enddo |
| 732 |
|
| 733 |
|
| 734 |
return |
| 735 |
end |