CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | List of all members
cass::pp230 Class Reference

retrieve photonenergy. More...

#include <machine_data.h>

+ Inheritance diagram for cass::pp230:
+ Collaboration diagram for cass::pp230:

Public Member Functions

 pp230 (const name_t &)
 constructor More...
 
virtual void process (const CASSEvent &, result_t &)
 calc the photonenergy from the bld More...
 
virtual void loadSettings (size_t)
 load the settings from cass.ini More...
 
- Public Member Functions inherited from cass::Processor
 Processor (const name_t &name)
 constructor More...
 
virtual ~Processor ()
 virtual destructor More...
 
virtual void processEvent (const CASSEvent &event)
 process the event More...
 
virtual const result_tresult (const CASSEvent::id_t eventid=0)
 retrieve a result for a given id. More...
 
virtual void releaseEvent (const CASSEvent &event)
 tell the list that the result for event can be overwritten More...
 
result_t::shared_pointer resultCopy (const uint64_t eventid)
 retrieve histogram for id More...
 
virtual void load ()
 load the general settings More...
 
virtual void aboutToQuit ()
 function that will be called when the processor is about to be deleted More...
 
const names_tdependencies ()
 Define all processors keys a processor depends on. More...
 
void clearDependencies ()
 clear the dependenies More...
 
void clearHistograms ()
 clear the histograms More...
 
virtual void processCommand (std::string command)
 process command in pp More...
 
const name_t name () const
 retrieve the name of this processor More...
 
bool hide () const
 retrieve the hide flag of this processor More...
 
const std::string & comment () const
 retrieve the comment of this processor More...
 

Additional Inherited Members

- Public Types inherited from cass::Processor
typedef std::tr1::shared_ptr< Processorshared_pointer
 a shared pointer of this More...
 
typedef std::string name_t
 define the name type More...
 
typedef std::list< name_tnames_t
 define the list of names More...
 
typedef CachedList::item_type result_t
 define the results More...
 
typedef CachedList::item_sp resultsp_t
 define the shared pointer to the result More...
 
- Protected Member Functions inherited from cass::Processor
virtual void createHistList (result_t::shared_pointer result)
 create result list. More...
 
void setupGeneral ()
 general setup of the processor More...
 
bool setupCondition (bool defaultConditionType=true)
 setup the condition. More...
 
shared_pointer setupDependency (const std::string &depVarName, const name_t &name="")
 setup the dependecy. More...
 
- Protected Attributes inherited from cass::Processor
const name_t _name
 the processors name More...
 
bool _hide
 flag to tell whether this pp should be hidden in the dropdown list More...
 
std::string _comment
 optional comment that one can add to a processor. More...
 
CachedList _resultList
 the list of results More...
 
names_t _dependencies
 the list of dependencies More...
 
shared_pointer _condition
 pointer to the processor that will contain the condition More...
 

Detailed Description

retrieve photonenergy.

Available PostProcessors:
"230":Photon energy of Shot

This processor will calculate the photonenergy from the BLD. Here is an email corrospondence from Andy Acquila and Anton Barty explaining where the calculation comes from:

Hi Benedikt,

I wish I had a paper about the wakefield correction, however I can't find it
However below is an email from James (Jim) Welch to Mark Messerschmidt.
It contains matlab code that we copied for the correction.  Also attached is a
plot from Anton of the effect of the correction as compared to the undulator
equation.

Please let me know if you have any questions.

Cheers,
Andy

Marc,

The formula I use calculates the resonant photon energy based on an estimate of
the electron beam energy at the first in-line undulator segment, and the K of
that segment.

The energy estimate for the first in-line segment starts with the DL2 bend
energy, and on a shot by shot basis, adds a correction based on the DL2 bpms for
the incoming energy, a correction for the wakefield energy loss which depends on
the measured peak bunch current (averaged over 10 shots), and a correction for
the spontaneous energy loss due to emission from the undulator segments.

The matlab code is below. We still have some problems coming up with good values
for wakeloss, especially if beam conditions are unusual. Also there may be a
slight shift between the resonant photon energy and the FEL peak of the
spectrum. Another factor that is uncertain is what exact value to use for the K
in the resonance formula. Any suggestions would be appreciated.

       - Jim


function photonEnergyeV = photonEnergyeV(DL2energyGeV,
peakCurrent, charge,K,xltu250, xltu450, display_output)
%
% photonEnergyeV = photonEnergyeV(DL2energyGeV,peakCurrent,charge,K,xltu25, xltu450, display_output)
%
% Return the resonant photon energy eV for the fundamental based on the peak
% current, DL2 beam energy, and K of first active segment, beam position in
% the two dogleg bpms.
%
% If no input arguments are present it will get the input from the machine

% If no input, parameters are set actual machine parameters
if nargin==0
  display_output = 0;  % set to 1 to do displays

  % Get the present peak current
  for q=1:10 % average over several reads
      temp(q) = lcaGet('BLEN:LI24:886:BIMAX');
  end
  peakCurrent=  mean(temp);

  % Get present charge in pC
  charge = 1000*lcaGet('FBCK:BCI0:1:CHRGSP');

  % Get present beam energy in DL2
  npts = 100;
  [xltu250, xltu450 ] = bpmDoglegRead(npts);
  if any([xltu250, xltu450]==0); % if bpms not reading, assume zero
      xltu250=0; xltu450=0;
  end
  DL2energyGeV = energyCorrectDL2(xltu250, xltu450, display_output);
  if display_output
      display(['DL2 energy ' num2str(DL2energyGeV) 'GeV' ]);
  end
end

% Get the present taper configuration
taper = segmentTranslate;

% Get total energy loss in each segment. Extracted segments have only wake
% loss
activeSegments = find(taper < 11); % these are active
energyLossPerSegment(1:33) = wakefield(peakCurrent, charge, display_output); % MeV loss per segment
energyLossPerSegment(activeSegments) = ...% add wakefield to active segments
  energyLossPerSegment(activeSegments) + SRloss( DL2energyGeV, display_output);

% Calculate energy profile [GeV]
energyProfile(1:33) = DL2energyGeV - LTUwakeLoss(peakCurrent,charge, display_output)/1000;
for q=1:33 % energyProfile represents average electron energy in each segment.
  energyProfile(q) = energyProfile(q)...
      - 0.001*sum(energyLossPerSegment(1:q)) - 0.0005*energyLossPerSegment(q);
end

% Calculate the resonant photon energy of the first active segment)
for q=1:33
  pvKACT{q,1} = sprintf('USEG:UND1:%d50:KACT',q);
end
if nargin==0
  Kprofile = lcaGetSmart(pvKACT);
else
  Kprofile = K*ones(33,1); % pretend they are all the same if K is supplied
end
photonEnergyeV = 8265.9 * ( energyProfile( activeSegments(1) ) / 13.64 )^2 *...
   (1 + 3.5^2/2) /(1 + Kprofile( activeSegments(1) )^2 / 2 ) ;
if display_output
  display(['1st harmonic photon energy: ', num2str(photonEnergyeV,'%5.0f') ' eV']);
end


function wakeLossPerSegment = wakefield(peakCurrent, charge, display_output)
% return the wake field induced energy loss per electron per segment
% Assume proportion to peak current.
% wakeLossPerSegment = 0.15 * peakCurrent/500; % MeV/segment, from Juhao 8/09
% if abs(peakCurrent) > 4000
%     wakeLossPerSegment = 0.15 * 300/500; % MeV/segment, adjusted to match 20 pC meas 10/6/09
% end

% Use Nuhn calculation for undulator
segmentLength = mean(diff(segmentCenters));
compressState = charge>25; % assume undercompressed for more than 25 pC, else overcompressed
wakeLossPerSegment = segmentLength * 0.001 *...
  util_UndulatorWakeAmplitude(abs(peakCurrent)/1000, charge, compressState);
if display_output
  display([ 'Wake loss/segment ' num2str(-wakeLossPerSegment,2) ' MeV']);
end

function LTUwakeLoss = LTUwakeLoss(peakCurrent, charge, display_output)
% Add LTU loss per Novohatsky
LTUfactor = 7.8; % MeV loss for 20 pC 0.5 micron rms bunch length
peakCurrentRef = 20e-12 * 3e8/0.5e-6/sqrt(2*pi); % Amps of peak current for LTUfactor
LTUwakeLoss = LTUfactor * (peakCurrent/peakCurrentRef);% scale with peak current^2/Q
if display_output
  display(['LTU wake loss ', num2str(LTUwakeLoss,2) ' MeV']);
end

function SRlossPerSegment = SRloss(electronEnergy, display_output)
% returns energy loss per segment [MeV] from spontaneous radiation in MeV
SRlossPerSegment = 0.63 * (electronEnergy/13.64)^2;
if display_output
  display(['SR loss/segment ', num2str(SRlossPerSegment,2) ' MeV']);
end

% This function is not used but could be added
function DL2energyGeV = energyCorrectDL2(xltu250, xltu450, display_output)
% correctedEnergy = energyCorrectDL2(xltu250, xltu450)
%
% returns the "corrected" = measured energies for a set of BSA bpm readings based on
% DL2 bpm readings and the DL2 magnet strengths. Use an average of the last
% npts stored in BSA buffers

bendEnergyGeV = lcaGetSmart('BEND:DMP1:400:BDES'); %use dump bend power supply
etax = .125 ; % [m] design value for dispersion at bpms in dogleg
DL2energyGeV = bendEnergyGeV + bendEnergyGeV*0.001*(xltu250(1,:)...
  - xltu450(1,:))/(2*etax);
if display_output
  display(['DL2 bend energy ' num2str(bendEnergyGeV) 'GeV' ]);
end

function [xltu250, xltu450 ] = bpmDoglegRead(npts, display_output)
% Return the averaged dogleg2 bpm x readings from buffered data
pvBPM = {'BPMS:LTU1:250:XHSTBR'; 'BPMS:LTU1:450:XHSTBR'};
bpms = lcaGet(pvBPM, npts);
xltu250 = mean(bpms(1,:));
xltu450 = mean(bpms(2,:));


On Aug 10, 2011, at 5:52 AM, Anton Barty wrote:

> Hi Benedikt
>
> At a conference right now, so no web access for papers.
> I'll cc' to Andy who may be able to dig up a paper online.
>
>
> The formulae came from LCLS machine physics, possibly via Marc Messerschmidt.
>
> To first order, it's the standard undulator equation - which requires such
> stuff as undulator K-factors (known from the undulator design and calibrations).
> This is the energy at which SASE lasing initiates.  The formulae basically
> relate electron beam energy to
>
> You can find a summary of formulae here (in B.2 - undulator radiation)
> http://xdb.lbl.gov/Section2/Sec_2-1.html
>
> The other terms are corrections to the electron energy due to wakefield losses
> and the like and make for relatively small corrections (<1%)  to the undulator
> energy.
>
See also
Processor for a list of all commonly available cass.ini settings.
Author
Lutz Foucar

Definition at line 477 of file machine_data.h.

Constructor & Destructor Documentation

pp230::pp230 ( const name_t name)

constructor

Definition at line 268 of file machine_data.cpp.

References loadSettings().

Member Function Documentation

void pp230::loadSettings ( size_t  )
virtual
void pp230::process ( const CASSEvent evt,
result_t result 
)
virtual

calc the photonenergy from the bld

Reimplemented from cass::Processor.

Definition at line 285 of file machine_data.cpp.

References cass::CASSEvent::devices(), cass::CASSEvent::MachineData, and cass::Result< T >::setValue().


The documentation for this class was generated from the following files: