Index: /fact/tools/pyscripts/pyfact/pyfact.py
===================================================================
--- /fact/tools/pyscripts/pyfact/pyfact.py	(revision 13379)
+++ /fact/tools/pyscripts/pyfact/pyfact.py	(revision 13380)
@@ -83,5 +83,6 @@
                 user_action_calib=lambda acal_data, data, blm, tom, gm, scells, nroi: None,
                 baseline_file_name='',
-                return_dict = None):
+                return_dict = None,
+                do_calibration = True):
         """ initialize object
         
@@ -107,7 +108,8 @@
             print 'and some time later, the option will not be supported anymore'
             return_dict = False
-
         self.return_dict = return_dict
         
+        self.do_calibration = do_calibration
+
         self.data_file_name = data_file_name
         self.calib_file_name = calib_file_name
@@ -198,5 +200,6 @@
             raise StopIteration
         else:
-            self.calibrate_drs_amplitude()
+            if self.do_calibration == True:
+                self.calibrate_drs_amplitude()
 
         #print 'nevents = ', self.nevents, 'event_id = ', self.event_id.value
@@ -229,18 +232,24 @@
         gm  = np.reshape(self.gm,  (self.npix, self.Ngm) )
         
+        # double the calibration constants
+        blm = np.hstack((blm,blm))
+        gm = np.hstack((gm,gm))
+        
         for pixel in range( self.npix ):
             # rotate the pixel baseline mean to the Data startCell
-            blm_pixel = np.roll( blm[pixel,:], -self.start_cells[pixel] )
+            #blm_pixel = np.roll( blm[pixel,:], -self.start_cells[pixel] )
+            blm_pixel = blm[pixel, self.start_cells[pixel]:self.start_cells[pixel]+self.nroi]
             # rotate the pixel gain mean to the Data startCell
-            gm_pixel = np.roll( gm[pixel,:], -self.start_cells[pixel] )
+            #gm_pixel = np.roll( gm[pixel,:], -self.start_cells[pixel] )
+            gm_pixel = gm[pixel, self.start_cells[pixel]:self.start_cells[pixel]+self.nroi]
             # the 'trigger offset mean' does not need to be rolled
             # on the contrary, it seems there is an offset in the DRS data,
             # which is related to its distance to the startCell, not to its 
             # distance to the beginning of the physical pipeline in the DRS chip
-            tom_pixel = tom[pixel,:]
+            tom_pixel = tom[pixel,0:self.nroi ]
             
-            acal_data[pixel,:] -= blm_pixel[0:self.nroi]
-            acal_data[pixel,:] -= tom_pixel[0:self.nroi]
-            acal_data[pixel,:] /= gm_pixel[0:self.nroi]
+            acal_data[pixel,:] -= blm_pixel
+            acal_data[pixel,:] -= tom_pixel
+            acal_data[pixel,:] /= gm_pixel
             
         self.acal_data = acal_data * 1907.35
