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


emenergy (emenergy-8.9) [xmmsas_20230412_1735-21.0.0]


Algorithm

   subroutine emenergy

   Read the file names among parameters

   Opening of input file event 
   Copy of input file event on output file event if need be
 
   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

   call EVFLAG

   call REJECT_E3E4 with no background
   call CCDBKG
   call CLIPE4
   call CCDBKG
   discard flags applied by intermediate calls to REJECT_E3E4 and CLIPE4

   call REJECT_E3E4
   call MAKE_E
   call CTI_CORR
   call ENERGY
 
   Close files

 SUBROUTINE EVFLAG 
   if evflag requested  then
      Loop over events
         flag events using binary coding for different reasons  
      end loop
   endif
 
SUBROUTINE CCDBKG 
   if useccfdarkframe then read dark frame map
   else if maskedccdset is set then read DIAGNOSTIC map
   Subtract the offsets
   Correct the Ei columns by the contents of the reference map
      integrated over the area associated to each Ei
   if  ccdbkg requested then
      Loop over events
        except for flagged events, events with peripix > 0, pattern > 4,
                   E1 < minenergy
        calculation of sigmae4 = summation of energy E4
        calculation of sigmaper = summation of (16-peripix)
      end loop
      divide sigmae4 by sigmaper to obtain BKG value
      if fillccdbkg then
        Loop over positions where less than fillminnumber events contribute
           Average E4 over rows rowav and columns colav
           Replace BKG by rowav + colav - full average
        end loop
      endif
      if bkgfile NE ' ' then
         save of the arrays sigmae4 and sigmaper in a new fits file
      keywords are recopied
   endif

SUBROUTINE CLIPE4
    Get variance on E4 - BKG(x,y) after applying same selection as in CCDBKG
    Flag events where E4 is more than 3 sigma away from BKG(x,y)

SUBROUTINE REJECT_E3E4
    if reject_e3e4 requested then
      Read e3cen,e4cen,e3rad,e4rad,e3ang from CAL
      Loop over events rows
         loce3 = E3
         loce4 = E4
         if bad offsets nearby then
            loce3 = loce3 + projection of additional offsets onto pixels in E3
            offe4 = sum of additional offsets in outer corona
            if peripix==0 and offe4 < 16000  loce4 = loce4 + offe4
         endif
         loce3 = (loce3 - BKG * (8- number of pixels in E2)) / (E1-BKG) - e3cen
         loce4 = (loce4 - BKG * (16-PERIPIX)) / (E1-BKG) - e4cen
         dist2 = (loce3*cos(e3ang)+loce4*sin(e3ang))/e3rad)**2 +
                 (loce4*cos(e3ang)-loce3*sin(e3ang))/e4rad)**2
         Flag events with dist2 > 1
      end loop
    endif

SUBROUTINE MAKE_E 
   if make_e requested
      call CAL_integerToReal(ener1,e1rand)
      edum = E2
      if bad offsets nearby then
         e1rand = e1rand + additional offsets on central pixel
         edum = edum + projection of additional offsets onto pixels in E2
      endif
      call CAL_mosPhaBuild(e1rand,edum,pattern,pha,BKG,E3,E4,peripix,flag)
   endif

SUBROUTINE CTI_CORR 
   if cti_corr requested  call CAL_mosCTIcorrection

SUBROUTINE ENERGY 
   if  energy requested  call CAL_mosGainCorrect

   end subroutine  emenergy



XMM-Newton SOC -- 2023-04-16