Page History
...
The examples above are meant to show you how you can make your own code. With different experiments using different hardware and having different goals, these examples might not apply to your particular experiment / datafile. If so, you'll need to search the main code and libraries a bit to find something more suitable. Here's a brief description of the functions of the myana.cc example and main.cc:
...
This is the "user analysis module". This is where you fill in your own code to extract the information that you want from your experiment's xtc file. This module contain only the following functions:
Code Block |
---|
beginjob()called at the beginning of an analysis job. You can for instance book histograms here. beginrun() called at the beginning of a run (the analysis job might analyze several runs)begincalib() called for each calibration cycleevent() this is where you fetch, process and store information about each event (shot).endcalib() endrun() endjob() // called at the beginning of an analysis job. You can for instance book histograms here.
beginrun() // called at the beginning of a run (the analysis job might analyze several runs)
begincalib() // called for each calibration cycle
event() // this is where you fetch, process and store information about each event (shot).
endcalib()
endrun()
endjob()
|
In the example, a profile histogram is booked in beginjob()
and voltage vs. time is filled in each event. The profile histogram displays the average value of all events.
...
This is the main control of the analysis, but you should avoid editing this file. After the all utility functions (in main) and user functions (in myana) have been read, main()
is executed and controls the flow of the analysis. For each xtc file it calls
anafile(xtcname, maxevt, skip, iDebugLevel);
which iterates through the xtc file, keeps track of all the datagrams in it, and makes sure to execute your beginjob()
and event()
functions.
All the functionality needed to get data from the xtc file is (or should be) defined in main.cc and in the files it includes (including the pdsdata library). Get an uppdated list of all the available functions by looking at main.hh (implementations are in main.cc).
Anchor | ||||
---|---|---|---|---|
|
More examples
...
- myana_morefeatures.cc
This version of the "user analysis module" shows how to obtain some more information from the xtc file:beginjob()
:- we book a profile histogram for AMO Ion Time-of-flight (AmoITof) waveform data, and also five regular histograms to fill with single event data from the first five events. To do this we need some information about the AmoITof configuration, which is obtained using the getAcqConfig(). This gives us the number of channels that were used, number of samples and sampling intervals, all needed to book the histogram.
- also a constant-fraction histogram is booked for AmoITof. This has it's own fill function, as we shall see from the event() function.
- For the Electron Time-of-flight detector (AmoETof), we similarly get the configuration data and make one profile histogram for each channel used.
- Also get config information about the Magnetic bottle electron spectrometer (AmoMbes).
- A Princeton camera and a fast CCD (FCCD) was also in use. These have their own getConfig functions: getPrincetonConfig( DetInfo::SxrBeamline, ...) and getFccdConfig(SxrFccd, ...).
In beginrun() we get the config info from AmoITof again, to check if it changed between runs in the same job.
event()
:- fills the histograms booked at the beginning of the job: getAcqValue() gets the data from a given detector for each event. The main program is already keeping track of which event we're processing at the time. The constant-fraction histogram is filled by the function fillConstFrac(), defined in main.cc. This histogram is filled with the boundary position each time the pulse crosses the threshold,
- the rest of
event()
uses a lot of get-functions to show how to use some of these. Generally, they all give you values through scalar or array variables passed as arguments to the functions. The example doesn't show what you would use this information for, but you might already know that
...
- myana_etof.cc
More histogram building for ETof Acquiris
...
- myana_itof.cc, myana_bin.cc
More ITof Aquiris averaging, and more about binning
...
- myana_mbes.cc
Magnetic electron bottle spectrometer (Mbes) Acquiris, time resolved binning
...
- myana_esort.cc, myana_bin.cc
Energy binning for Mbes Acquiris
...
- ACQexp.cc, EXSavg.cc, (or EXSavgOMP.cc for parallel processing)
Opal image processing, projections, image export
...
- examples/myana_tuple.cc
Example of how to store several variables in a root NTuple for further processing (histogramming, correlation studies etc.).
...
...
Anchor | ||||
---|---|---|---|---|
|
Configuration and Event Data retrieval functions:
...
- Most of the functions return 0 if it was a successful function call, any other number means it failed.
Wiki Markup Values are obtained through the arguments of the function calls. E.g. declare an array in your myana.cc, and {{getXXXValue(&myarray\[0\])}} will fill the array for you.
- Enums: Several of the functions can be used to extract data from several of the detectors. Which detector is specified by an enum (named constant integers). You are encouraged to use the names instead of the numbers, in case the underlying order changes in a new version of the program.
...
...
Acquiris digitizer
...
Code Block |
---|
int getAcqConfig(AcqDetector det, int& numChannels, int& numSamples, double& sampleInterval); |
Fetches the configuration information for any of the Acquiris devices. Returns 1 if the requested detector does not exist, and 2 if it was not in use. Tells you the number of channels used for this device, the number of samples collected and the sample interval. This is typically done in the beginjob()
or beginrun()
functions.
Code Block |
---|
int getAcqValue(AcqDetector det, int channel, double*& time, double*& voltage); int getAcqValue(AcqDetector det, int channel, double*& time, double*& voltage, double& trigtime); |
Fetches waveform data from any of the Acquiris devices. Fills your arrays with the waveform time and voltage, and optionally gives you the trigger time.
In the myana.cc example, we fetch data from the AmoITof device (AMO Ion Time-of-flight).
Other Acquiris devices (see main.hh for an up-to-date list):
Code Block |
---|
AMO:
AmoIms - ion momentum spectrometer
AmoGasdet - gas detector (in the Front End Enclusure)
AmoETof - electron time-of-flight
AmoMbes - magnetic bottle electron spectrometer
AmoVmiAcq - (Vmi = Velocity mapping imaging)
AmoBpsAcq - (Bps = Beam position screen)
Camp - for the CAMP experimental setup
SXR:
SxrBeamlineAcq1
SxrBeamlineAcq2
SxrEndstationAcq1
SxrEndstationAcq2
|
Panel |
...
Image data
...
There are several getters for fetching image data from the xtc file. Depending on which camera was in use, one of these should be appropriate:
- Opal1000 camera:
getOpal1kValue
(an alias for getFrameValue)
- Which camera?
getTm6740Value (an alias for getFrameValue)
- FrameDetector (general):
Gives you the width and height (in pixels) of the image, and a pointer to the start of the pixel array of a Pds::Camera::FrameV1 object. Specify the detector (using an appropriate enum).Code Block int getFrameConfig (FrameDetector det); int getFrameValue(FrameDetector det, int& frameWidth, int& frameHeight, unsigned short*& image );
Code Block Available frame detectors: AMO: AmoVmi AmoBps1 AmoBps2 SXR: SxrBeamlineOpal1 SxrBeamlineOpal2 SxrEndstationOpal1 SxrEndstationOpal2 SxrFccd XPP: XppSb1PimCvd XppMonPimCvd XppSb3PimCvd XppSb4PimCvd
- XPP CsPad detector:
Gives you a pointer to the first position in the array of pixel data from the XPP CsPad detector (or alternatively you can get a pointer to the Pds::CsPad::ElementV1 object itself).Code Block namespace Pds { namespace CsPad { class ConfigV1; }} int getCspadConfig (Pds::DetInfo::Detector det, unsigned& quadMask, unsigned& asicMask); int getCspadConfig (Pds::DetInfo::Detector det, Pds::CsPad::ConfigV1& cfg); namespace Pds { namespace CsPad { class ElementV1; }} int getCspadQuad (Pds::DetInfo::Detector det, unsigned quad, const uint16_t*& pixels); int getCspadQuad (Pds::DetInfo::Detector det, unsigned quad, const Pds::CsPad::ElementV1*& data);
For an example of how to draw an image as a 2D root histogram, see the myana_cspad.cc example.
- Fast CCD camera:
Configures the information from the Fast CCD. Fills arguments with values depending on how the image/waveform data were taken. There is noCode Block int getFccdConfig(FrameDetector det, uint16_t& outputMode, bool& ccdEnable, bool& focusMode, uint32_t& exposureTime, float& dacVoltage1, float& dacVoltage2, float& dacVoltage3, float& dacVoltage4, float& dacVoltage5, float& dacVoltage6, float& dacVoltage7, float& dacVoltage8, float& dacVoltage9, float& dacVoltage10, float& dacVoltage11, float& dacVoltage12, float& dacVoltage13, float& dacVoltage14, float& dacVoltage15, float& dacVoltage16, float& dacVoltage17, uint16_t& waveform0, uint16_t& waveform1, uint16_t& waveform2, uint16_t& waveform3, uint16_t& waveform4, uint16_t& waveform5, uint16_t& waveform6, uint16_t& waveform7, uint16_t& waveform8, uint16_t& waveform9, uint16_t& waveform10, uint16_t& waveform11, uint16_t& waveform12, uint16_t& waveform13, uint16_t& waveform14);
getFccdValue
in main.hh, so I think you need to usegetFrameValue
for this .
- PnCCD camera (used by CAMP):
This camera has 4 links, each link provides a 512 x 512 x 16 bit image. This function combines the four images to a single 1024 x 1024 x 16 bit image.Code Block int getPnCcdValue (int deviceId, unsigned char*& image, int& width, int& height );
deviceId
can be PnCcd0 or PnCcd1, width and height are the number of pixels in each direction.
- Princeton camera:
fetches the configuration and data from the camera.Code Block int getPrincetonConfig(Pds::DetInfo::Detector det, int iDevId, int& width, int& height, int& orgX, int& orgY, int& binX, int&binY); int getPrincetonValue(Pds::DetInfo::Detector det, int iDevId, unsigned short *& image); int getPrincetonTemperature(Pds::DetInfo::Detector det, int iDevId, float& temperature);
getPrincetonTemperature
is there to check the temperature of the camera at the time of data taking (not necessarily available for every shot).
Other functions:
Several other functions are available to get information from other monitors around the experimental setup. They may or may not be of importance to your data quality...
...
- Ipimb detector (Intensity Position, Intensity Monitor Board)
Code Block int getIpimbConfig(Pds::DetInfo::Detector det, int iDevId); int getIpimbVolts(Pds::DetInfo::Detector det, int iDevId, float &channel0, float &channel1, float &channel2, float &channel3);
- Encoder detector
Code Block int getEncoderConfig (Pds::DetInfo::Detector det, int iDevId); int getEncoderCount(Pds::DetInfo::Detector det, int iDevId, unsigned int& encoderCount);
- DiodeFex (Diode feature extraction)
Code Block int getDiodeFexConfig (Pds::DetInfo::Detector det, int iDevId, float* base, float* scale); int getDiodeFexValue (Pds::DetInfo::Detector det, int iDevId, float& value);
- Imp detector Fex (Imp feature extraction)
Code Block int getIpmFexConfig (Pds::DetInfo::Detector det, int iDevId, float* base0, float* scale0, float* base1, float* scale1, float* base2, float* scale2, float* base3, float* scale3, float& xscale, float& yscale); int getIpmFexValue (Pds::DetInfo::Detector det, int iDevId, float* channels, float& sum, float& xpos, float& ypos);
- Front end enclosure Gas detector
Gives you the shot energy to the array shotEnergy4.Code Block int getFeeGasDet (double* shotEnergy);
- Electron beam monitor
Gives electron beam values for each of these doubles. The measured charge of the beam (in nC),Code Block int getEBeam(double& charge, double& energy, double& posx, double& posy, double& angx, double& angy); int getEBeam(double& charge, double& energy, double& posx, double& posy, double& angx, double& angy, double& pkcurr);
the measured energy of the beam (in MeV), the 2D position of the beam (in mm) away from the origin
(nominal beam position), and 2D angular position (in mrad) off the assumed direction. and the
pkcurr = current? in (Amps)
- Phase cavity montior
Gives you the phase cavity fit time (low and high?) and charges (before and after?).Code Block int getPhaseCavity(double& fitTime1, double& fitTime2, double& charge1, double& charge2);
- Event Receiver counter
number of Fifo pulses associated with this shot (usually 1 or 2). For each of these there is EvrData:Code Block int getEvrDataNumber()
- Event Receiver data
eventCode tells you something about the beam quality of this pulse. Usually the event code is 140, meaning electrons were produced upstream (beam was on). It does not tell you about the photon status.Code Block int getEvrData(int id, unsigned int& eventCode, unsigned int& fiducial, unsigned int& timeStamp );
fiducial is the higher timestamp of the pulse (end time)
timeStamp is the lower timestamp of the pulse (start time)
- EPICS values (Process variables)
Get integers, floats, strings from any EPICS channel (PV = process variable)Code Block int getPvInt (const char* pvName, int& value); int getPvFloat (const char* pvName, float& value); int getPvString (const char* pvName, char*& value);