Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Extracting the data with pyana, some examples

Outline of a pyana module

Code Block
none
none

Point detector delay scan

...

  • Fetching the ControlPV information:
    ControlPV is available from the env object, and since it only changes at the beginning
    of each calibration cycle, the begincalibcycle function is the appropriate place to get it:
    Code Block
    none
    none
        def begincalibcycle( self, evt, env ) :
    

    The ControlConfig object may contain several pvControl and pvMonitor objects. In this case
    there's only one, but make sure the name matches anyway: title
    Code Block
    none
    none
    
            # get updated configuration object at each calibcycle. 
            ctrl_config = env.getConfig(TypeId.Type.Id_ControlConfig)
    
            for ic in range (0, ctrl_config.npvControls() ):
                cpv = ctrl_config.pvControl(ic)
                if cpv.name()=="fs2:ramp_angsft_target":
    
                    # store the value in a class variable (visible in every class method)
                    self.current_pv_value = cpv.value() )
    
    Code Block
  • Fetching the IPIMB and PhaseCavity information:
    All the other information that we need, is available through the evt object, and
    event member function is the place to get it:
    Code Block
    none
    none
        def event( self, evt, env ) :
    
            # Use 

    Use "XppSb3Ipm-1|Ipimb-0" (a.k.a. IPM3) sum of all channels for normalization and filtering
    Code Block
    none
    none
    
            ipmN_raw = evt.get(TypeId.Type.Id_IpimbData, "XppSb3Ipm-1|Ipimb-0")
            ipmN_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Ipm-1|Ipimb-0")
    
            # we use the IpmFex information, and choose to use the sum 
            # of all channel values for normalization and filtering 
            ipmN_norm = ipmN_fex.sum
    
            # Use 

    Use "XppSb3Pim-1|Ipimb-0" (a.k.a. PIM3) channel 1 as signal
    Code Block
    none
    none
     signal
    
            ipmS_raw = evt.get(TypeId.Type.Id_IpimbData, "XppSb3Pim-1|Ipimb-0" )
            ipmS_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Pim-1|Ipimb-0" )
    
            # Here, we use IpmFex channel 1 (counting from 0) as the signal
            ipm_sig = ipmS_fex.channel[1]
    

    Get the phase cavity:
    Code Block
    none
    nonetitleFetching the Phase Cavity information
        def event(self, evt, env):
    
            pc = evt.getPhaseCavity()
            phasecav1 = pc.fFitTime1
            phasecav2 = pc.fFitTime2
            charge1 = pc.fCharge1
            charge2 = pc.fCharge2
    

    Compute delay time and fill histograms
    Code Block
    title
    none
    noneComputing the delay time and making histograms
    
        def event(self, evt, env):
    
            delaytime = self.current_pv_value + phasecav1*1e3    
    
            # The "histograms" are nothing but python lists. Append to them, and turn them into arrays at the end. 
            self.h_ipm_rsig.append( ipm_sig )
            self.h_ipm_nsig.append( ipm_sig/ipm_norm )
            self.h_delaytime.append( delaytime )
    

...