Index: version-MWPC/neonIO.py
===================================================================
--- version-MWPC/neonIO.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/neonIO.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
@@ -291,12 +291,17 @@
 
 
-    def roiProcess(self, pos, tubeno):
+    def roiProcess(self, pos):
         name=mtd['sample_1']
         Xdata=[]
-        for j in range(name.getNumberHistograms()):
+        XYdata=[[] for i in range(2)]
+        dataLen=name.getNumberHistograms()
+        for j in range(dataLen):
             #Xdata.append(name.getDetector(j).getRelativePos().X()*1000)
-            Xdata.append(name.getDetector(j).getRelativePos().Y()*1000)
-            #XYdata[1].append(name.getDetector(j).getRelativePos().X())
+            #Ydata.append(name.getDetector(j).getRelativePos().Y()*1000)
+            XYdata[0].append(name.getDetector(j).getRelativePos().X()*1000)
+            XYdata[1].append(name.getDetector(j).getRelativePos().Y()*1000)
         index=[]
+        #pos[3]=pos[3]+50
+        #pos[2]=pos[2]+25
         if pos[1]>pos[3]:
             ymax=pos[1]
@@ -305,15 +310,18 @@
             ymax=pos[3]
             ymin=pos[1]
-        for i in range(len(Xdata)):
-            #if XYdata[1][i]>=pos[0] and XYdata[1][i]<=pos[2] and XYdata[2][i]>=pos[3] and XYdata[2][i] <=pos[1]:
-            if i >= (tubeno-1)*300 and i < tubeno*300:
-                if Xdata[i]>=ymin and Xdata[i]<=ymax:
-                    index.append(i)
-                else:
-                    pass
-            else:
-                pass
-        #print "ROI: ",pos, " " ,tubeno
-        #print "ROI: ",index
+        if pos[0]>pos[2]:
+            xmax=pos[0]
+            xmin=pos[2]
+        else:
+            xmax=pos[2]
+            xmin=pos[0]
+            
+
+        for i in range(dataLen):
+            if XYdata[0][i]>=xmin and XYdata[0][i]<=xmax and XYdata[1][i]>=ymin and XYdata[1][i] <= ymax:
+                index.append(i)
+            else:
+                pass
+        print "ROI: ",index
         ExtractSpectra(InputWorkspace='sample_1', OutputWorkspace='roiWS', WorkspaceIndexList=index)
 
@@ -438,11 +446,11 @@
                     '''
                     self.confRoi=self.getROIcommand()
-                    self.confRoi['roi'] = False
+                    #self.confRoi['roi'] = True
                     if self.myDict['running']:
                         print "Judge ROI: ",self.confRoi['roi']
                         self.logger.debug("start process ws")
                         if self.confRoi['roi']:
-                            print self.confRoi['pos'], self.confRoi['tubeNo']
-                            self.roiProcess(self.confRoi['pos'],self.confRoi['tubeNo'])
+                            print "position of ROI: ",self.confRoi['pos']
+                            self.roiProcess(self.confRoi['pos'])
                             self.wsProcess('roiWS')
                         else:
Index: version-MWPC/test/neutronC.py
===================================================================
--- version-MWPC/test/neutronC.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/test/neutronC.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
@@ -16,9 +16,9 @@
 
 
-    path="/MR/workspace/MantidData/neutroncounts2"
+    path="/MR/workspace/MantidData/neutroncounts"
     tmp=r_read.get(path)
     tmp=json.loads(tmp)
     tmp=int(tmp)
-    be=time.time()
+    print tmp
     '''
     while True:
@@ -35,3 +35,2 @@
             tmp=tmp2
     '''
-    print " neutron counts:",tmp
Index: version-MWPC/testRES.py
===================================================================
--- version-MWPC/testRES.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
+++ version-MWPC/testRES.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
@@ -0,0 +1,24 @@
+import os
+import subprocess
+import time
+import sys
+t=0
+while True:
+    _cmd="top -n 1 | grep 139146"
+    try:
+        a = subprocess.check_output(_cmd, shell=True)
+        a=a.split(' ')
+        for i in range(len(a)-1,-1,-1):
+            if a[i]=='':
+                a.remove('')
+        print t,';',a
+        res=a[5]
+        print t,';',res,'\n'
+        f=open('res.dat','a+')
+        f.write(str(t)+';'+str(res)+'\n')
+        f.close()
+    except:
+        pass
+    #t=t+1
+    #sys.exit()
+    time.sleep(60)
