subroutine event_display_get_event(ireturn_code) c c c This routine fetches the next event from the event data file. c The file is opened, read, and then deleted so that the DAQ will c recognize that it's time to create a new file. c c c George Gollin, g-gollin@uiuc.edu, 1999. c c return codes (only the last error is reported): c 0 if everything's fine, and we have good event data. c 1 if we couldn't open the file c 2 if we hit the end-of-file before encountering "EOD" c 3 if we had a problem reading strip data header line c 4 if we had a problem reading dem1 data header line c 5 if we had a problem reading dem2 data header line c 6 if we had a problem reading marebo data header line c 16 if we had a problem reading module data header line c 7 if we couldn't delete the event data file after reading it c 8 if we tried reading detector data before encountering a header c -9 encountered bad strip detector data c -10 encountered bad run number, event number header line c -11 encountered bad dem1 detector data c -12 encountered bad dem2 detector data c -22 encountered bad module detector data c -13 found fewer lines of strip hit data than expected c -14 found fewer lines of dem1 hit data than expected c -15 found fewer lines of dem2 hit data than expected c -16 found fewer lines of marebo hit data than expected c -17 encountered bad marebo detector data c -26 found fewer lines of module hit data than expected c -27 encountered bad module detector data c c c negative values for return code correspond to errors where the data line c was ignored, but I continued to read from the file. positive values c mean the event data was unusable. c c #include "event_display.inc" #include "event_display_data.inc" c c c data format is described in the common blocks. c c NOTE: pixel detectors with z position set to zero will be ignored. c logical first_time,file_exists logical now_reading_strips, now_reading_dem1, now_reading_dem2 logical now_reading_demm, now_reading_demd logical hit_EOD, found_run c character*132 line_buffer character*132 line character*80 text c ccc integer*4 system c c data first_time /.true./ c data lines_read_from_file /0/ data ievents_read /0/ c c c ************************************************************************* c c c c ******************* (initialize stuff) c c ireturn_code=0 c do iv=1,2 do ipl=1,4 num_strip_hits(iv,ipl)=0 ifound_strip_hits(iv,ipl)=0 end do end do c num_strip_hits_total=0 num_dem1_hits=0 num_dem2_hits=0 num_demm_hits=0 num_demd_hits=0 ifound_strip_hits_total=0 ifound_dem1_hits=0 ifound_dem2_hits=0 ifound_demm_hits=0 ifound_demd_hits=0 lines_read_from_file=0 c phidem1=0. psidem1=0. thetadem1=0. xplane_z0(ipldem1)=0. yplane_z0(ipldem1)=0. c phidem2=0. psidem2=0. thetadem2=0. xplane_z0(ipldem2)=0. yplane_z0(ipldem2)=0. c phidemm=0. psidemm=0. thetademm=0. xplane_z0(ipldemm)=0. yplane_z0(ipldemm)=0. c phidemd=0. psidemd=0. thetademd=0. xplane_z0(ipldemd)=0. yplane_z0(ipldemd)=0. c z_read_dem1=0. z_read_dem2=0. z_read_demm=0. z_read_demd=0. c c the module has some of its detector cells shared by single readout c channels. keep track of that here, so I don't mess up my bookkeeping. number_shared_hits=0 c c c ******************* (open the file for single event's data) c c c file may not be available as soon as I ask for it, do do this in a loop. do itry=0,10000 c c c ask... inquire(file=file_data(1:lenocc(file_data)), exist=file_exists) c c c open it if available... if(file_exists) then c c wait a second, in case file was being written at the time we detected it.. call system('sleep 1') c c now open it: open(lun_data, file=file_data(1:lenocc(file_data)), . status='old', iostat=io_err) c c c if we've been waiting a while, offer a comment saying we got the file> if(itry .gt. 1000) then call event_display_write_message( . '...FINALLY got the data file. I am SO patient!') c else if(itry .gt. 200) then call event_display_write_message( . '...OK, I got the data file. Sure took long enough!') c else if(itry .gt. 50) then call event_display_write_message( . '...I got the data file. Took a while, didn.t it?') c else if(itry .gt. 5) then call event_display_write_message( . '...Time to rock-n-roll.') c end if c c c jump to the next step if file opened OK: if(io_err .eq. 0) go to 100 c c c we're here if the file existed but didn't open properly. write a message, c then fall through to the end of the loop, and try again. perhaps file was c open, and was still being created? call event_display_write_message( . 'couldn.t open event data file even though it existed!') c else c c c we are here when file didn't exist yet. If the user isn't bored, we want c to wait a bit, then try again. If the user is fed up, they'll hit a button c in a DAQ window which will cause the control file to be deleted. I'll c take this as a sign that it is time to stop the display program. print a c message and update the x window occasionally while we wait. iambored=300 if(mod(itry,iambored) .eq. 1) then c call event_display_write_message( . 'waiting for data file... '//file_data) c mode_synchronize=10 call ixupdwi(mode_synchronize) end if c c c if we've waited a bit longer, suggest how to kill the program: if(mod(itry,5*iambored) .eq. 4) then c call event_display_write_message( . '...the STOP button in this window is disabled while ' . //'waiting for data') call event_display_write_message( . ' but you can kill the display from the DAQ window ' . //'or by ') call event_display_write_message( . ' manually deleting '//file_control) c mode_synchronize=10 call ixupdwi(mode_synchronize) end if c c c refresh the window if something has changed (for example, if the user c has resized the window out of boredom). the ...initialize_geometry routine c is the one that can notice all this... call event_display_initialize_geometry if(something_changed) then call event_display_draw_detector call event_display_draw_hits call event_display_write_message('') mode_synchronize=10 call ixupdwi(mode_synchronize) end if c end if c c c Has the DAQ deleted the control file? If so, time to stop. call event_display_control_exists(file_exists) if(.not. file_exists) then c c write message... call event_display_write_message( . 'Just received request from DAQ to stop. Good bye!') c c force an update of the screen... mode_synchronize=10 call ixupdwi(mode_synchronize) c c pause a bit, so there's time for the user to read the message: call system('sleep 2') c c set the stop-now flag, then return: i_want_to_stop=.true. c return end if c c c wait for about 2 seconds, then go back to the start of the loop which looks c for the data file. call system('sleep 1') c end do c c c ******************* (file wasn't there, so give up...) c c c end up here if we were unable to open the file after many attempts. c perhaps no run was in progress? c call event_display_write_message( . 'I have failed miserably in numerous attempts '// . 'to open the data file '//file_data) ireturn_code=1 return c c c ******************* (ready to start reading from the file) c c 100 continue c c so far so good: now read the file. see comments in the common blocks for c information about file format. cc call event_display_write_message( cc . 'opened data file '//file_data) c c c ******************* (initialize type-of-detector data flags) c c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.false. found_run=.false. c c c ******************* (loop over reads starts here) c 200 continue c c c read a line, treating it as text... read(lun_data, 1000, iostat=io_err) line_buffer 1000 format(a) c c c if this was written using list-directed (free form) output, there's probably c a blank as the first character. protect against this by finding the first c non-blank character. I'm having trouble with the cernlib routine, c so do it myself. c do i=1,132 ifirst=i if(line_buffer(i:i) .ne. ' ') go to 25 end do c 25 continue c last=133-ifirst do i=1,132 if(i .le. last) then line(i:i)=line_buffer(i+ifirst-1:i+ifirst-1) else line(i:i)=' ' end if end do c length=lenocc(line) c c c c ******************* (check to see that we read a line OK) c c c problems reading the line? if so, we probably hit the end of file c without encountering the EOD line. if(io_err .ne. 0) then c c print *, c . ' hit EOF before encountering last word in event??' c print *,' iostat returned was... ',io_err c call event_display_write_message( . ' hit EOF before encountering last word in event??') c ireturn_code=2 return endif c c lines_read_from_file=lines_read_from_file+1 c c c ******************* (start of data for a new detector?) c c c see if the first few characters are "STRIPS" or "DEM1" or... to c tell us what kind of data we're reading here. Treat marebo like dem2. c c start of strip data? c if( line(1:6) .eq. 'STRIPS' .or. . line(1:6) .eq. 'Strips' .or. . line(1:6) .eq. 'sTRIPS' .or. . line(1:6) .eq. 'strips' ) then c now_reading_strips=.true. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.false. found_run=.false. c c remaining fields are length of strip data and z for each strip. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) read(line(7:), *, iostat=io_err) num_strip_hits_total, . (z_read_sirocco(ipl), ipl=1,8) c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading strip header record' c print *,' iostat returned was... ',io_err c call event_display_write_message( . ' ...problem reading strip header record') c ireturn_code=3 return end if c c c load the z's: do ipl=1,4 xplane_z0(ipl)=z_read_sirocco(ipl) yplane_z0(ipl)=z_read_sirocco(ipl+4) end do c c c now get the next line of data: go to 200 c c c c start of dem1 data? c else if(line(1:4) .eq. 'DEM1' .or. . line(1:4) .eq. 'Dem1' .or. . line(1:4) .eq. 'dEM1' .or. . line(1:4) .eq. 'dem1' ) then c now_reading_strips=.false. now_reading_dem1=.true. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.false. found_run=.false. c c remaining fields are length of dem1 data, three angles, and z. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) read(line(5:), *, iostat=io_err) num_dem1_hits_read, . phi_read_dem1, psi_read_dem1, theta_read_dem1, z_read_dem1 . ,number_cols_read_dem1, number_rows_read_dem1 c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading dem1 header record' c print *,' iostat returned was... ',io_err c call event_display_write_message( . ' ...problem reading dem1 header record') c ireturn_code=4 return end if c c c load the angles and z's, but only if the z position is non-zero: if(z_read_dem1 .ne. 0.) then num_dem1_hits=num_dem1_hits_read phidem1=phi_read_dem1 psidem1=psi_read_dem1 thetadem1=theta_read_dem1 xplane_z0(ipldem1)=z_read_dem1 yplane_z0(ipldem1)=z_read_dem1 number_cols_dem1=number_cols_read_dem1 number_rows_dem1=number_rows_read_dem1 end if c c c c now get the next line of data: go to 200 c c c c start of dem2 data? c else if(line(1:4) .eq. 'DEM2' .or. . line(1:4) .eq. 'Dem2' .or. . line(1:4) .eq. 'dEM2' .or. . line(1:4) .eq. 'dem2' ) then c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.true. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.false. found_run=.false. c c remaining fields are length of dem2 data, three angles, and z. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) read(line(5:), *, iostat=io_err) num_dem2_hits_read, . phi_read_dem2, psi_read_dem2, theta_read_dem2, z_read_dem2 . ,number_cols_read_dem2, number_rows_read_dem2 c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading dem2 header record' c print *,' iostat returned was... ',io_err c c call event_display_write_message( . ' ...problem reading dem2 header record') c ireturn_code=5 return end if c c c load the angles and z's, but only if the z position is non-zero: if(z_read_dem2 .ne. 0.) then num_dem2_hits=num_dem2_hits_read phidem2=phi_read_dem2 psidem2=psi_read_dem2 thetadem2=theta_read_dem2 xplane_z0(ipldem2)=z_read_dem2 yplane_z0(ipldem2)=z_read_dem2 number_cols_dem2=number_cols_read_dem2 number_rows_dem2=number_rows_read_dem2 end if c c c now get the next line of data: go to 200 c c c c start of marebo data? c else if(line(1:6) .eq. 'MAREBO' .or. . line(1:6) .eq. 'Marebo' .or. . line(1:6) .eq. 'mAREBO' .or. . line(1:6) .eq. 'marebo' ) then c c else if(line(1:4) .eq. 'DEMM' .or. c . line(1:4) .eq. 'Demm' .or. c . line(1:4) .eq. 'dEMM' .or. c . line(1:4) .eq. 'demm' ) then c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.true. now_reading_demd=.false. hit_EOD=.false. found_run=.false. c c remaining fields are length of marebo data, three angles, and z. c I want to treat this like dem2 for the purposes of the display. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) ccccc read(line(5:), *, iostat=io_err) num_demm_hits_read, read(line(7:), *, iostat=io_err) num_demm_hits_read, . phi_read_demm, psi_read_demm, theta_read_demm, . z_read_demm . ,number_cols_read_demm, number_rows_read_demm c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading marebo header record' c print *,' iostat returned was... ',io_err c c call event_display_write_message( . ' ...problem reading marebo header record') c ireturn_code=6 return end if c c c load the angles and z's, but only if the z position is non-zero: if(z_read_demm .ne. 0.) then num_demm_hits=num_demm_hits_read phidemm=phi_read_demm psidemm=psi_read_demm thetademm=theta_read_demm xplane_z0(ipldemm)=z_read_demm yplane_z0(ipldemm)=z_read_demm number_cols_demm=number_cols_read_demm number_rows_demm=number_rows_read_demm end if c c c now get the next line of data: go to 200 c c c c start of module data? c else if(line(1:4) .eq. 'MOD1' .or. . line(1:4) .eq. 'Mod1' .or. . line(1:4) .eq. 'mOD1' .or. . line(1:4) .eq. 'mod1' ) then c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.true. hit_EOD=.false. found_run=.false. c c remaining fields are length of module data, three angles, and z. c I want to treat this like dem2 for the purposes of the display. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) read(line(5:), *, iostat=io_err) num_demd_hits_read, . phi_read_demd, psi_read_demd, theta_read_demd, . z_read_demd . ,number_cols_read_demd, number_rows_read_demd c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading marebo header record' c print *,' iostat returned was... ',io_err c c call event_display_write_message( . ' ...problem reading module header record') c ireturn_code=16 return end if c c c load the angles and z's, but only if the z position is non-zero: if(z_read_demd .ne. 0.) then num_demd_hits=num_demd_hits_read phidemd=phi_read_demd psidemd=psi_read_demd thetademd=theta_read_demd xplane_z0(ipldemd)=z_read_demd yplane_z0(ipldemd)=z_read_demd number_cols_demd=number_cols_read_demd number_rows_demd=number_rows_read_demd end if c c c now get the next line of data: go to 200 c c c c end-of-event marker? c else if(line(1:3) .eq. 'EOD' .or. . line(1:3) .eq. 'Eod' .or. . line(1:3) .eq. 'eOD' .or. . line(1:3) .eq. 'eod' ) then c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.true. found_run=.false. c c c increment the events-read counter: ievents_read=ievents_read+1 c c c now see which pixel detectors were actually in place, in order to decide c how to map the angle-changing buttons. I can only have at most two c detectors' buttons displayed. Use the value of z_read_... to see if c the detector exists. c iset=0 ib1=2 ib2=ib1+1 ib3=ib2+1 map_button(new_dem1_phi_button)=0 map_button(new_dem1_psi_button)=0 map_button(new_dem1_theta_button)=0 map_button(new_dem2_phi_button)=0 map_button(new_dem2_psi_button)=0 map_button(new_dem2_theta_button)=0 map_button(new_demm_phi_button)=0 map_button(new_demm_psi_button)=0 map_button(new_demm_theta_button)=0 map_button(new_demd_phi_button)=0 map_button(new_demd_psi_button)=0 map_button(new_demd_theta_button)=0 c c first trio of buttons: if(z_read_dem1 .ne. 0.) then map_button(new_dem1_phi_button)=ib1 map_button(new_dem1_psi_button)=ib2 map_button(new_dem1_theta_button)=ib3 iset=1 c else if(z_read_dem2 .ne. 0.) then map_button(new_dem2_phi_button)=ib1 map_button(new_dem2_psi_button)=ib2 map_button(new_dem2_theta_button)=ib3 iset=2 c else if(z_read_demm .ne. 0.) then map_button(new_demm_phi_button)=ib1 map_button(new_demm_psi_button)=ib2 map_button(new_demm_theta_button)=ib3 iset=3 c else if(z_read_demd .ne. 0.) then map_button(new_demd_phi_button)=ib1 map_button(new_demd_psi_button)=ib2 map_button(new_demd_theta_button)=ib3 iset=4 c end if c c next trio of buttons: ib1=ib3+1 ib2=ib1+1 ib3=ib2+1 if(iset .eq. 1 .and. z_read_dem2 .ne. 0.) then map_button(new_dem2_phi_button)=ib1 map_button(new_dem2_psi_button)=ib2 map_button(new_dem2_theta_button)=ib3 c else if((iset.eq.1 .or. iset.eq.2) .and. . z_read_demm .ne. 0.) then map_button(new_demm_phi_button)=ib1 map_button(new_demm_psi_button)=ib2 map_button(new_demm_theta_button)=ib3 c else if((iset.eq.1 .or. iset.eq.2 .or. iset.eq.3) .and. . z_read_demd .ne. 0.) then map_button(new_demd_phi_button)=ib1 map_button(new_demd_psi_button)=ib2 map_button(new_demd_theta_button)=ib3 c end if c c c now check to see if we found the number of lines of data we expected: c strip data... if(ifound_strip_hits_total .ne. num_strip_hits_total) then c print *,' expected ', num_strip_hits_total, ' but found ', c . ifound_strip_hits_total c c 11111111112222222222333333333344444444445 c 12345678901234567890123456789012345678901234567890 text=' ...number of hit strips disagrees with header: ' . //'found xxxxxx, expected yyyyyy' c write(text(57:62), '(i6)') ifound_strip_hits_total write(text(74:79), '(i6)') num_strip_hits_total c call event_display_write_message(text(1:79)) c ireturn_code=-13 end if c c dem1 data... if(ifound_dem1_hits .ne. num_dem1_hits) then c print *,' expected ', num_dem1_hits, ' but found ', c . ifound_dem1_hits c c 11111111112222222222333333333344444444445 c 12345678901234567890123456789012345678901234567890 text=' ..number of dem1 pixels disagrees with header: ' . //'found xxxxxx, expected yyyyyy' c write(text(57:62), '(i6)') ifound_dem1_hits write(text(74:79), '(i6)') num_dem1_hits c call event_display_write_message(text(1:79)) c ireturn_code=-14 end if c c dem2 data... if(ifound_dem2_hits .ne. num_dem2_hits) then c print *,' expected ', num_dem2_hits, ' but found ', c . ifound_dem2_hits c c 11111111112222222222333333333344444444445 c 12345678901234567890123456789012345678901234567890 text=' ..number of dem2 pixels disagrees with header: ' . //'found xxxxxx, expected yyyyyy' c write(text(57:62), '(i6)') ifound_dem2_hits write(text(74:79), '(i6)') num_dem2_hits c call event_display_write_message(text(1:79)) c ireturn_code=-15 end if c c c marebo data... if(ifound_demm_hits .ne. num_demm_hits) then c print *,' expected ', num_demm_hits, ' but found ', c . ifound_demm_hits c c 11111111112222222222333333333344444444445 c 12345678901234567890123456789012345678901234567890 text=' ..nmber of marebo pixels disagrees wth header: ' . //'found xxxxxx, expected yyyyyy' c write(text(57:62), '(i6)') ifound_demm_hits write(text(74:79), '(i6)') num_demm_hits c call event_display_write_message(text(1:79)) c ireturn_code=-16 end if c c c module data... if(ifound_demd_hits - number_shared_hits .ne. . num_demd_hits) then c print *,' expected ', num_demd_hits, ' but found ', c . ifound_demd_hits c c 11111111112222222222333333333344444444445 c 12345678901234567890123456789012345678901234567890 text=' ..nmber of module pixels disagrees wth header: ' . //'found xxxxxx, expected yyyyyy' c write(text(57:62), '(i6)') . ifound_demd_hits - number_shared_hits write(text(74:79), '(i6)') num_demd_hits c call event_display_write_message(text(1:79)) c ireturn_code=-26 end if c c c close the event data file: cc call event_display_write_message( cc . 'found EOD record, so closing data file') close(lun_data) c c c since we're done reading this event's raw data, delete the file so c that Thierry can tell that he can write another one for us. if(delete_file_when_finished) then c c system call to delete file... istat=0 ccc istat=system('rm '//file_data) call system('rm '//file_data) c c worked OK? if(istat .ne. 0) then c no... c print *,' bad status returned by system call', c . ' to delete ',file_data c print *,' status was ',istat c call event_display_write_message( . ' ...problem deleting data file when finished') c ireturn_code=7 end if c end if c return c c c c run number, event number marker? c else if(line(1:3) .eq. 'RUN' .or. . line(1:3) .eq. 'Run' .or. . line(1:3) .eq. 'rUN' .or. . line(1:3) .eq. 'run' ) then c now_reading_strips=.false. now_reading_dem1=.false. now_reading_dem2=.false. now_reading_demm=.false. now_reading_demd=.false. hit_EOD=.false. found_run=.true. c c c remaining fields are run number and event number. c c CAREFUL!! the digit in "read(line(x:)..." must be 1 greater than the digit c in the "if(line(1:y)..." statement above. c the colon in the line(1:y) read(line(4:), *, iostat=io_err) irun_number, ievent_number c c check that it went OK. if(io_err .ne. 0) then c c print *, c . ' hit problem reading run number header record' c print *,' iostat returned was... ',io_err c print *,' irun_number, ievent_number ', c . irun_number, ievent_number call event_display_write_message( . ' ...problem reading run number header') c ireturn_code=-10 c get the next line, instead of trashing the entire event... go to 200 end if c c tell the user what we found: write(text(1:25), '(4hrun ,i6,8h event ,i7)') . irun_number, ievent_number call event_display_write_message(text(1:25)) c c now get the next line of data: go to 200 c end if c c c c ******************* (check to see that we know what kind of data we have) c c c we only end up here if the line wasn't recognized as the start of a new c detector's data, or as an end-of-data marker, or as the run number/event c number specifier. If we don't know what kind of detector we're dealing c with at this point, there's been an error. c if(.not. now_reading_strips .and. . .not. now_reading_dem1 .and. . .not. now_reading_dem2 .and. . .not. now_reading_demm .and. . .not. now_reading_demd ) then c c print *,' tried reading detector data before finding header' c call event_display_write_message( . ' ... tried reading detector data before finding header') c ireturn_code=8 return end if c c c ******************* (handle strip data) c c if(now_reading_strips) then c c strip data: sirocco number, strip number, and amplitude. first strip c is 0, not 1. read(line(1:), *, iostat=io_err) isir, istrip, iamp c c c check that format was OK. if(io_err .ne. 0) then c c print *, c . ' problem reading strip data: file line ', c . lines_read_from_file c print *,' bad data had sirocco, strip, amplitude as ', c . isir, istrip, iamp c call event_display_write_message( . ' ... strip data problem') c c ireturn_code=-9 c get the next line, instead of just quiting... go to 200 end if c c c data are OK... determine whether x or y view... ifound_strip_hits_total=ifound_strip_hits_total + 1 if(isir .le. 4) then iview=1 iplane=isir else iview=2 iplane=isir-4 end if c c c check for legal plane and strip number: if(istrip .lt. 0 .or. istrip .gt. number_strips-1 .or. . iplane .lt. 1 .or. iplane .gt. 4) then c ccc print *,' bad sirocco, strip and/or plane: ', ccc . istrip, iplane c ccc call event_display_write_message( ccc . ' ... strip data problem') c ireturn_code=-9 c get the next line, instead of just quiting... go to 200 end if c c c here if it's fine, excellent, marvelous data... ifound_strip_hits(iview,iplane)= . ifound_strip_hits(iview, iplane) + 1 num_strip_hits(iview,iplane)= . num_strip_hits(iview, iplane) + 1 istrip_number_read(ifound_strip_hits(iview,iplane), . iview, iplane)=istrip istrip_adc_read(ifound_strip_hits(iview,iplane), . iview, iplane)=iamp c c c we're done, so get the next line of data... go to 200 end if c c c ******************* (handle dem1 data) c c if(now_reading_dem1) then c c pixel demonstrator 1 data: column, row, beam crossing number, TOT. c columns, rows start at 0, not 1. read(line(1:), *, iostat=io_err) icol, irow, ibc, itot c c c check that format was OK. if(io_err .ne. 0) then c c print *, c . ' problem reading dem1 data: file line ', c . lines_read_from_file c print *,' bad data had column, row, beamcrossing, tot ', c . icol, irow, ibc, itot c call event_display_write_message( . ' ... dem1 data problem') c ireturn_code=-11 c get the next line, instead of just quiting... go to 200 end if c c c data read OK... check for legal plane and strip number: ifound_dem1_hits=ifound_dem1_hits + 1 if(icol .lt. 0 .or. icol .gt. number_cols_dem1-1 .or. . irow .lt. 0 .or. irow .gt. number_rows_dem1-1 .or. . ibc .lt. 0 .or. ibc .gt. 16 .or. . itot .lt. 0 .or. itot .gt. 1023) then c c print *,' bad dem1 data: icol, irow, ibc, itot are', c . icol, irow, ibc, itot c ccc call event_display_write_message( ccc . ' ... dem1 data problem') c ireturn_code=-11 c get the next line, instead of just quiting... go to 200 end if c c c ah, such fine data we have! idem1_col_read(ifound_dem1_hits)=icol idem1_row_read(ifound_dem1_hits)=irow idem1_beam_crossing(ifound_dem1_hits)=ibc idem1_tot_read(ifound_dem1_hits)=itot c c c we're done, so get the next line of data... go to 200 end if c c c ******************* (handle dem2 data) c c if(now_reading_dem2) then c c pixel demonstrator 2 data: column, row, beam crossing number, TOT. c columns, rows start at 0, not 1. read(line(1:), *, iostat=io_err) icol, irow, ibc, itot c c c check that format was OK. if(io_err .ne. 0) then c c print *, c . ' problem reading dem2 data: file line ', c . lines_read_from_file c print *,' bad data had column, row, beamcrossing, tot ', c . icol, irow, ibc, itot c call event_display_write_message( . ' ... dem2 data problem') c ireturn_code=-12 c get the next line, instead of just quiting... go to 200 end if c c c data read OK... check for legal plane and strip number: ifound_dem2_hits=ifound_dem2_hits + 1 if(icol .lt. 0 .or. icol .gt. number_cols_dem2-1 .or. . irow .lt. 0 .or. irow .gt. number_rows_dem2-1 .or. . ibc .lt. 0 .or. ibc .gt. 16 .or. . itot .lt. 0 .or. itot .gt. 1023) then c ccc print *,' bad dem2 data: icol, irow, ibc, itot are', ccc . icol, irow, ibc, itot c ccc call event_display_write_message( ccc . ' ... dem2 data problem') c ireturn_code=-12 c get the next line, instead of just quiting... go to 200 end if c c c ah, such exquisite data we have! idem2_col_read(ifound_dem2_hits)=icol idem2_row_read(ifound_dem2_hits)=irow idem2_beam_crossing(ifound_dem2_hits)=ibc idem2_tot_read(ifound_dem2_hits)=itot c c c we're done, so get the next line of data... go to 200 end if c c c ******************* (handle marebo data) c c if(now_reading_demm) then c c Marebo data: column, row, beam crossing number, TOT. c columns, rows start at 0, not 1. read(line(1:), *, iostat=io_err) icol, irow, ibc, itot c c c check that format was OK. if(io_err .ne. 0) then c c print *, c . ' problem reading demm data: file line ', c . lines_read_from_file c print *,' bad data had column, row, beamcrossing, tot ', c . icol, irow, ibc, itot c call event_display_write_message( . ' ... demm data problem') c ireturn_code=-17 c get the next line, instead of just quiting... go to 200 end if c c c data read OK... check for legal plane and strip number: ifound_demm_hits=ifound_demm_hits + 1 if(icol .lt. 0 .or. icol .gt. number_cols_demm-1 .or. . irow .lt. 0 .or. irow .gt. number_rows_demm-1 .or. . ibc .lt. 0 .or. ibc .gt. 16 .or. . itot .lt. 0 .or. itot .gt. 1023) then c ccc print *,' bad demm data: icol, irow, ibc, itot are', ccc . icol, irow, ibc, itot c ccc call event_display_write_message( ccc . ' ... demm data problem') c ireturn_code=-17 c get the next line, instead of just quiting... go to 200 end if c c c ah, such exquisite data we have! idemm_col_read(ifound_demm_hits)=icol idemm_row_read(ifound_demm_hits)=irow idemm_beam_crossing(ifound_demm_hits)=ibc idemm_tot_read(ifound_demm_hits)=itot c c c we're done, so get the next line of data... go to 200 end if c c ******************* (handle module data) c c if(now_reading_demd) then c c pixel module data: column, row, beam crossing number, TOT. c columns, rows start at 0, not 1. read(line(1:), *, iostat=io_err) icol, irow, ibc, itot c c c check that format was OK. if(io_err .ne. 0) then c c print *, c . ' problem reading demd data: file line ', c . lines_read_from_file c print *,' bad data had column, row, beamcrossing, tot ', c . icol, irow, ibc, itot c call event_display_write_message( . ' ... demd data problem') c ireturn_code=-22 c get the next line, instead of just quiting... go to 200 end if c c c data read OK... check for legal plane and strip number: ifound_demd_hits=ifound_demd_hits + 1 if(icol .lt. 0 .or. icol .gt. number_cols_demd-1 .or. . irow .lt. 0 .or. irow .gt. number_rows_demd-1 .or. . ibc .lt. 0 .or. ibc .gt. 16 .or. . itot .lt. 0 .or. itot .gt. 1023) then c ccc print *,' bad demd data: icol, irow, ibc, itot are', ccc . icol, irow, ibc, itot c ccc call event_display_write_message( ccc . ' ... demd data problem') c ireturn_code=-22 c get the next line, instead of just quiting... go to 200 end if c c c ah, such exquisite data we have! idemd_col_read(ifound_demd_hits)=icol idemd_row_read(ifound_demd_hits)=irow idemd_beam_crossing(ifound_demd_hits)=ibc idemd_tot_read(ifound_demd_hits)=itot c c detector cells 160 - 163 share readout with cells 153, 155, 157, 159 c respectively. By hand, we'll have to mess with how we display this. c c c we're done, so get the next line of data... go to 200 end if c c c end