XMM-Newton SAS Home Page
XMM-Newton Science Analysis System


emevents (emevents-8.8) [xmmsas_20211130_0941-20.0.0]


Algorithm

MODULE em_events_module

   Read the file names of event files (input and output) and frame file

   Open files 
   Get keyword values   
 
   parameters read : choice of sub_tasks to execute
   Loop over input task parameters
      Read the task parameter / 1 to perform the procedure,
                                0 not to perform it  /
   End loop

   Get the values of files columns in memory
  
SUBROUTINE CUT_BAD 
   if cut_bad requested  then
     read bad pixels in extension
     Loop over frames
       Creation of image using inverse pattern definition 
       Connection with binodal task 
          in the case of 2 files (prime and redundant) analysis
       Set bad pixels to 0
       Loop over events
          Use of EDUSOFT code for new pattern reconstruction
          creation of new rows and destruction of old ones
       end loop
     end loop
   endif
  
SUBROUTINE DIAGO 
   if diago requested then 
     Loop over event rows for diagonal patterns
       Check if both E1 and E2 energies are different from Si K energy
       In this case :
         first correct the existing pattern    
         pattern is 0, e2 is 0, others the same   
         second create another pattern   
         pattern is 0, e1 is old e2, X & Y to be calculated 
         depending on pattern  
         e2 is 0, others the same   
         both patterns are flagged   
         ( do not correct the NVALID in the file frame )   
      end loop
      new rows have been created at the end of file
      now shift of lines in order to insert new events
      Loop over number of new lines
         Shift all rows following place of insertion
      end loop
    endif

    Check events with energy value below EMDHLOW or above EMDHHIGH

SUBROUTINE CUT_GTI 
    if cut_gti requested  then 
      Loop over frame rows
         all events whose frames were flagged are flagged for rejection 
      end loop
    endif

SUBROUTINE PUT_XY 
    if put_xy requested then
      Loop over events
         center the events, substract the underscan, add 1.
         flag the events outside the field of view
      end loop
      Modify window keywords
      Compute camera coordinates
    endif 

SUBROUTINE PUT_TI  ( Imaging mode )
    if put_ti requested then
      Loop over frame rows
         Loop over events rows
           calculate the average time for the frame 
           copy this time in the time column of events file
         end loop
       end loop
     endif
 
SUBROUTINE PUT_TT  ( Timing mode )
     if put_tt requested then
       Loop over frame rows
         Loop over events rows
           calculate the new time as reference frame time plus Y offset
           copy this time in the time column of events file
         end loop
       end loop
     endif

SUBROUTINE REJECT_ROWS
    if reject_rows requested then
       Loop over frame rows
         Loop over events rows
            Build RAWY profile
         end loop
         Loop over events rows
            Flag events with RAWY profile larger than maxeventsperrow
            If 2 or more, flag events within +/- widthnexttorow
               (in the same frame) as well
         end loop
       end loop
    endif

SUBROUTINE REJECT_E3
    if reject_e3 requested then
      if detectbadoffsets and not SW mode then
         Build median E3 on each row and column
         Look for successive rows/columns with median E3 < -100
         Solve E3(i) = - 3*offset(i-1) - 2*offset(i) - 3*offset(i+1)
         to deduce which offset is wrong
         Flag events on rows/columns with wrong offset
      endif
      Read e3threshold from CAL
      Loop over events rows
         Flag events with pattern <= 4 and E3 < e3threshold
      end loop
    endif

For each triplet in tolfxy, call REJECT_FLICKERING
SUBROUTINE REJECT_FLICKERING(ftol,xtol,ytol)
    Ignore events OUT_OF_CCD_WINDOW, IN_BAD_FRAME, ON_BADROW, ON_BADPIX
    volref = (2*ftol+1) * (2*xtol+1) * (2*ytol+1)
    Get map of average event density, smoothed at xtol, ytol
    Get number of events per frame, smoothed at ftol
    Loop over events
       Count number of other events within ftol, xtol, ytol
       Estimate local average from larger of averages
          over FRAME (for sources) and RAWX,RAWY (for flares)
       If Poisson probability to get observed counts is > 1E-6, count as peak
    end loop
    Keep only local maxima among peaks
    Loop over peaks
       Identify events closer than 2*ftol in FRAME, 10*(xtol,ytol) in RAWX,RAWY
       If spatial distribution is compatible with a source
          (not too peaked, not too elongated) don't flag
       else flag events close to the peak, up to the point
          where the density meets the average
    end loop

SUBROUTINE SP_GATTI 
    if sp_gatti requested   then
      Loop over events rows
        calculate the E1 spectrum, the (E1+gatti) spectrum 
        and the gatti spectrum
      end loop
      Convolution of E1 and gatti spectra
    endif

    sequence of instructions for outevent1 creation 
 
    closing files
        
end module



XMM-Newton SOC -- 2021-11-30