#include <CCAENV1x90.h>
class CCAENV1x90 {CCAENV1x90(unsigned int nSlot, unsigned int nCrate, unsigned long nBase);
const unsigned int getModel();
const unsigned char getVersion();
const unsigned int getSerialNumber();
const unsigned int getChipCount();
const unsigned int getChannelCount();
unsigned short SR();
bool isSetSR(unsigned short bitnum);
unsigned short ReadCR();
bool isSetCR(unsigned short bitnum);
void Terminate();
void Unterminate();
void TerminateWithSwitch();
void EnableTriggerTagTime();
void DisableTriggerTagTime();
bool DataReady();
bool AlmostFull();
bool isFull();
bool isTriggerMatching();
bool isHeaderEnabled();
bool isTerminated();
bool HadError(unsigned int nChip);
int ReadResolution();
bool isPairMode();
bool WereTriggersLost();
void SetGeographicalID(unsigned short int);
unsigned short GetGeographicalID();
void Reset();
void Clear();
void EventReset();
void Trigger();
unsigned long TriggerCount();
unsigned short EventCount();
void SetAlmostFullLevel(unsigned int nWords));
unsigned short GetAlmostFullLevel();
void DefineECLOutput(ECLOutputSelect signal);
ECLOutputSelect GetECLOutputDefinition();
unsigned short EventFIFOCount();
unsigned long ReadEventFIFO();
bool isEventFIFOReady();
bool isEventFIFOFull();
unsigned short FIFOEventNumber(unsigned long fifoentry);
unsigned short FIFOWordCount(unsigned long fifoentry);
void TriggerMatchMode();
void ContinuousStorageMode();
void TransferUntilDone();
void TransferOneAtATime();
void LoadDefaultConfig();
void SaveUserConfig();
void LoadUserConfig();
void AutoLoadUserConfig();
void AutoLoadDefaultConfig();
void SetWindowWidth(unsigned int nWidth);
void SetWindowOffset(int nOffset);
void SetExtraSearchMargin(unsigned int nMargin);
void SetRejectMargin(unsigned int Margin);
void EnableTriggerTimeSubtraction();
void DisableTriggerTimeSubtraction();
TriggerConfiguration GetTriggerConfiguration()();
unsigned int GetMatchWindow(TriggerConfiguration config);
int GetWindowOffset(TriggerConfiguration config);
unsigned int GetExtraSearchMargin(TriggerConfiguration config);
unsigned int GetRejectMargin(TriggerConfiguration config);
bool isTriggerTimeSubtracted(TriggerConfiguration config);
void SetEdgeDetectMode(EdgeMode nEdgeMode);
EdgeMode GetEdgeDetectMode();
void SetIndividualLSB(Resolution nResolution);
void SetPairResolutions(LEResolution nLeadingEdge, PWResolution nPulseWidth);
unsigned short GetResolution();
Resolution InterpretEdgeResolution(unsigned short nResolution);
LEResolution InterpretLEResolution(unsigned short nResolution);
PWResolution InterpretWidthResolution(unsigned short nResolution);
void SetDoubleHitResolution(DeadTime nDead);
DeadTime GetDoubleHitResolution();
void EnableTDCEncapsulation();
void DisableTDCEncapsulation();
bool isTDCEncapsulationOn();
void SetMaxHitsPerEvent(HitMax nHits);
HitMax GetMaxHitsPerEvent();
void EnableErrorMark();
void DisableErrorMark();
void EnableBypassOnError();
void DisableBypassOnError();
void SetErrorEnables(unsigned short nErrors);
unsigned short GetErrorEnables();
void SetL1Size(L1Size nL1Size);
L1Size GetL1Size();
void EnableChannel(unsigned short nChannel);
void DisableChannel(unsigned short nChannel);
void EnableAllChannels();
void DisableAllChannels();
void SetChannelEnables(std::vector<unsigned short> masks);
void GetChannelEnables(std::vector<unsigned short>& masks);
void SetChipEnables(unsignedshort nChip, unsigned int nMask);
unsigned int GetChipEnables(unsigned short nChip);
unsigned int GetChipId(unsigned short nChip);
void GetuCFirmwareInfo(unsigned short& nRevision, unsigned short& nDay, unsigned short& nMonth, unsigned short& nYear);
unsigned short GetChipErrors(unsigned short nChip);
unsigned int ReadData(void* pBuffer, unsigned int nMaxLongs);
unsigned int ReadPacket(void* pBuffer, unsigned int nMaxLongs);
unsigned int ReadValid(void* pBuffer, unsigned int nMaxLongs);
}
This very complex class provides support for the very complex CAEN V1190 and CAEN V1290 multhit TDCs and their variants. Be sure you have read the manual on this TDC thoroughly before you attempt to program the device. While there are models of this device that are capable of geographical addressing, We have not purchased them. The software is written only to support base addressing.
The TDC is essentially a free running time digitizer. When used in trigger matching mode, it can simulate a common stop or commnon start multihit TDC. One important point is that times relative to the trigger will jitter by the module's FPGA clock. If you use this module you must digitize the gate time in one channel as well so that you can compute gate relativel timing by digital subtraction. Only in this way will you get the full time resolution offered by the TDC.
For the data types specific to the module support code, see the section Types and pulbic data below.
Called when a CAENV1x90 object is created to initialize the object
and, provisionally, the module represented by the object.
nSlot
is the geographical address that
will be assigned to the module.
nCrate
and nBase
define the location of the module in VME space in terms of a VME
crate number and an A32 base address withihn that
crate.
Returns the model number of the device. This will be either 1190 or 1290
Returns the sub model of the device. This is the single letter that follows the device model number and currently can be one of N, 'A', or 'B'.
Return the serial number of the device. This serial number is also stamped on the small metal tag at the bottom of the module front panel.
Returns the number of TDC chips on the board. Some of the models, like the 1290N only have 2 TDC chips on board while most others have 4. As some functions require you to supply a TDC number, this function can be called to determine how high the TDC number is allowed to go.
Returns the number of TDC channels supported by the board. This is a function of whether or not the module is an 1190, 1290 and whether it has the N suffix after its model number.
Returns the contents of the board's status register. Normally you will not need to call this function.
Returns true if the bit numbered bitnum
is set
in the board status register.
Returns the current value of the control register. Normall you will not need to invoke this function.
Returns true if the bit numbered
bitnum
is set in the control register.
Enables the on board termination of the module inputs.
See Unterminate
and
TerminateWithSwitch
for other alternatives.
Disable on board termination of the module's inputs.
See Terminate
and TerminateWithSwitch
for other options.
Set the module so that it's slide switch enables or disables termination.
See Terminate
and Unterminate
for alternatives to this.
Tells the module to place the time of the trigger input in the buffer.
Tells the module not to place the time of the trigger input in the buffer.
Returns true if data can be read from the TDC module (the data buffer has some data).
Returns true if the amount of data in the module exceeds the almost full threshold programmed into it.
Returns true of the data buffer for the module is full.
Returns true if the module has been set to trigger matching mode. In trigger matching mode, times are collected into events that occur within some defined time window of the trigger.
Returns true if the module has been told to insert event header information in the data stream.
Returns true if the module inputs are terminated.
Returns true if the module reported an error.
Return the resolution code from the module.
Returns true if the module has been programmed in pair mode. Pair mode measures the times between pulse pairs, rather than the timing of individual pulses.
Returns true if the board missed triggers due to rate conditions.
Sets the geographical ID of the module. The geographical Id is a virtual slot number that is presented in the data stream from the module to identify where the data came from.
Returns the module's geographical id.
Does a soft reset on the module.
Clears any data the module may have stored in its fifo buffer.
Resets the event counter to zero .
Peforms a software trigger.
Returns the number of events the module has had since the last event count reset.
Returns the number of events that resulted in data stored in the buffer.
Defines the FIFO almost full level. If there are more than
nWords
longowrds of data in the FIFO,
the board is considered to be almost full of data and
calls to AlmostFull
will result in
true
Returns the number of longwords that define the FIFO almost full condition.
Selects the meaning of the ECL user output of the module. See the section "Types and Public Data" for a definition of ECLOutputSelect the legal values it can take and what they mean.
Returns the meaning of the ECL user output. See the section Types and Public Data" for a definition of ECLOutputSelect the legal values it can take and what they mean.
Returns the number of events stored in the module FIFO. This is done by reading the Event FIFO Stored Register.
Reads the event FIFO. This a destructive read, in the sense that once read the datum read cannot be reread. The Event FIFO is a longword. The lower 16 bits are the number of words in an event, while the upper 16 bits are the event number of an event. You can use this to determine how many words to read from the module event FIFO for an event.
Returns true if the Event FIFO is not empty.
Returns true if the event FIFO is true. The event FIFO can only hold 1024 longwords.
Returns the event number field from the fifoentry
which was returned via ReadEventFIFO
.
Given a fifoentry
received from a call to
ReadEventFIFO
returns the value of the
event word count field.
Sets the module in trigger match mode. In this mode, hits in the channels are grouped into events that are within a programmable timing window of the gate input.
Sets the module into continous storage mode. In this mode, hits are just recorded relative to the last Reset time (bunch reset), without any time relationship constraints. Think of this data as a stream of hits.
This mode refers to the manner in which data from a single TDC chip are transferred to the data buffer. After calling this function, each TDC transfer data from its L1 storage into the FIFO event buffer until an event has been completely read in before yielding the data path to the FIFO to the next TDC chip.
See also TransferOneAtATim
which is an alternative
to this.
See also TransferUntilDone
after transferring
a single hit to the output event FIFO, each TDC chip yields the
data path to the next TDC.
Sets up the module with the default trigger configuration:
Continuous storage mode
Window width 500ns
Window Offset -1us.
Reject margin 100ns
Extra search margin 200ns
All channels enabled
Saves the current trigger configuration as the User
Trigger Configuration. The user trigger configuration
can be loaded via a call to
LoadUserConfig
, or made to load on power up
via a call to AutoLoadUserConfig
. The
user trigger configuration is stored in non-volatile memory and
therefore preserved across power cycles of the board.
Loads the most recently saved user trigger configuration.
The user trigger configuration is created by programming the
trigger and calling SaveUserConfig
.
Sets the module to load the user configuration on power up or
reset. This should be used with extreme caution and only with TDC
modules you own. Otherwise you can be handing a board to
someone that will power up with a trigger configuration that is
much different than what the user might expect from reading
the manual. Similarly, because someone could have done this to you,
you should call LoadDefaultConfiguration
prior
to setting up the trigger configuration so that you are
starting from a known initial state.
Causes the default trigger configuration to be loaded on the
next power up or reset. If you are using the module in an\
application where you have called AutoLoadUserConfig
,
it would be polite to call this before returning the module to the
pool so that it has expected behavior on power up.
Sets the trigger matching window width. The window width and the
window offset (see SetWindowOffset
) are the main
parameters that determine
which hits are grouped together into an event when the module is set to
trigger matching mode. See also the TDC hardware manual where the
trigger matching parameters are discussed in detail.
Sets the offset of the window relative to the gate of the trigger
matching window. This offset defines the time that the trigger match
window opens relative to the gate. The window offset
together with the window width
(see SetWindowWidth
) defines the time window during
which hits are collected into events when the module is run in trigger
matching mode. See the TDC hardware manual where the trigger
matchin paramters are discussed in detail.
Sets the trigger matching extra search margin. This is an additional slice of time at the end of the trigger matching window during which hits will be accepted into an event. This helps compensate for internal pipeline and clock jitter delays that would otherwise prematurely cut off the trigger match window.
Sets the width of an additional bit of time at the front of the trigger matching window during which hits will be accepted into an event in trigger matching mode. This helps compensate for the jitter of the start in the trigger matching window due to the granularity of the FPGA clock.
Tells the module to subtract the trigger time from times produced in trigger matching mode. Note that you must still provide a time reference channel as the trigger time granularity is that of the FPGA clock rather than the resolution of the TDC chip.
Turns off the subtraction of the trigger time from the times produced by the module in trigger matching mode. The times will be relative to the last 'bunch reset'.
Returns the entire trigger configuration. The resulting
TriggerConfiguration data type is documented in
the section "Types and Public Data" below, however normally you use
it by handing it to functions like GetMatchWindow
e.g.
that knwow how to extract elements of the trigger configuration.
Returns the trigger match window from the config
TriggerConfiguration.
Returns the window offset from the config
TriggerConfiguration
parameter.
Returns the extra search margin from the
config
TriggerConfiguration parameter.
Get the trigger rejection margin from the
config
TriggerConfiguration
Returns true If the config
TriggerConfiguration would enable trigger time
subtraction.
Sets the edge detection mode of the TDC
to nEdgeMode
. The edge detection mode
defines what a hit is and what the TDC measures. The
EdgeMode type, and the meaning of the values it can
take are described in the section
"Types and Public Data" below.
Returns the currently programmed edge detection mode. See "Types and Public Data below for a description of the EdgeMode data type, the values it can have, and what they mean.
Selects the resolution (meaning of the Least Significant Bit of the time) for all TDC chips. The data type Resolution is described in the section "Types and Public Data" below.
Sets the time resolutions of the leading edge and pair timings. The meaning of the data types PWResolution and LEResolution are described in the section "Types and Public Data" below.
Returns information about the resolution settings programmed into the
TDC module. The unsigned short that was returned is
intended to be passed to functions like
InterpretEdgeResolution
to get detailed information
about the resolution.
Given a resolution value returned from GetResolution
Returns the edge resolutions that are encoded in it. See
"Types and Public Data" below for a description of
Resolution and its legal values.
Interprets and returns the leading edge resolution from a value
returned by GetResolution
.
See "Types and Public Data" below for more a description of
of the LEResolution data type, and the values it can
take.
Interprets and returns the pair widht resolution from an value that
was gotten from GetResolution
.
See "Types and Public Data" below for more information about the
PWResolution and the values it can take.
Set the double hit resolution of the TDC. This is the deadtime between hits during which another hit will not be recorded. See "Types and Public Data" below for more information about the DeadTime data type and the values it can take.
Returns the currently programmed double hit resolution. See "Types and Public Data" below for more information about the DeadTime data type and the values it can take.
Turns on the encapsulation of the data from a single TDC chip in chip headers and trailers. See the TDC hardware manual for information about the nature and format of these headers and trailers.
Turns off the encapsulation of the data from a single TDC chip
(see EnableTDCEncapsulation
).
Returns true if TDC chip data encapsulation is enabled.
Set the maximum number of hits the tdc board will accept per event (in trigger matching mode). Note that this is not a per-channel maximum hit count, but a per-module maximum. See the section "Types and Public Data" for more information about the HitMax data type and the values it can take.
Returns the maximum number of hits that will be accepted within
a trigger matching window (defaulted or set by
SetMaxHitsPerEvent
).
See the section "Types and Public Data" for more information about
the HitMax data type and the values it can take.
Enables the TDC to insert an error word into the data when an error condition occurs in the TDC. See the TDC hardware manual for more information about the format of this error word and the error condition it can report.
Turns off the insertion of an error mark word in the data when the TDC detects an error condition.
Enables bypassing TDC chips that detect error conditions. When bypassed a chip will not contribute data to the output stream. See the hardware manual for more information about what this means.
Disables bypassing a TDC chip that has detected an error condition. In this mode, TDC chips with error conditions will continue to contribe data to the output stream to the best of their ability constrained by the actual error condition.
Sets the mask of errors the TDC is enabled to detect. This is a bit mask with bits numbered from lowest oder to highest order defined as followed:
0 - Vernier error, DLL unlocked or excessive jitter. |
1 - Coarse error or parity error on coards count. |
2 - Channel select error, probably an internal timing error. |
3 - L1 buffer parity error |
4 - Trigger FIFO parity error. |
5 - Trigger matching error (state machine got really mixed up). |
6 - Readout FIFO parity error. |
7 - Readout state error. |
8 - Set up parity error. |
9 - Control parity error. |
10 - JTAG instruction parity error. |
Returns the mask of error enables. This mask has the same format
as the mask described in SetErrorEnables
.
Set the usable size of the TDC module's level 1 buffer. See "Types and Public Data" below for a description of the L1Size data type and the values it can assume.
Returns the current size selected for the level 1 buffer. See "Types and Public Data" below for a description of the L1Size data type and the values it can assume.
Enables the specified channel. The channel numbering may not be
obvious for modules other than the V1190 (full 128 channels).
Check the hardware manual
for more information about this. nChannel
specifies which channel should be enabled.
Disables the specified channel. Note that channel numbering may not be straightforward for modules other than the V1190 (full 128 channels). Be sure to consult the hardware manual for more information about this.
Enables all of the channels on the module.
Disables all of the channels in the modules. Effectively disables the module for data acquisition.
Sets enables/disables for all of the channels. masks
is a vector of channel enable/disable masks that supplied 128 bits of
enable disable information numbered from low channel to high channel
from low bit of the first 16 bits of the first mask through the top bit
of the last mask.
Be sure that you read the hardware manual for your TDC model before you jump to conclusions about which channels are which. The mapping of channel numbers to front panel numbers is not always straightforward for modules other than the V1190.
Retrieves the channel enable masks.
Set the channel enables for a single chip. nChip
selects the chip and nMask
provides the
32 bits of channel enables for that chip.
Returns the enable mask for a single chip. nChip
selects the chip you are interested in. The enables are returned as
the function value.
Returns the id code fo the TDC. Note that there is no documentation about possible values that can be returned.
Returns the version/release data information about the firmware for the microcontroller that is used to set up the TDC module. This micro controllers is what the software interacts with to perform most of the operations described up until now.
Reads a mask that describes which errors have occured for a specific
TDC chip. See SetErrorEnables
for information about
the bits in this mask.
Reads data from the TDC. This actually ReadPacket
if the module is in trigger matching mode or ReadValid
if the module is in continuous storage mode. These two functions
are described below.
Reads data from the TDC output FIFO into pBuffer
until either
nMaxLongs
long words have been read, or until
a global trailer is encountered. When the TDC is in trigger matching mode,
and if nMaxLongs
is larger than the
the number of longs until the next global trailer, this is equivalent to
reading a single event from the TDC.
One way to ensure that you read complete events is to read the
event FIFO to determine how large the next event is and then
read that event once you are sure you have a large enough buffer to hold it.
Reads data from the TDC into Buffer
a filler word is encountered or until nMaxLongs
longwords have been read, whichever is first. This is the preferred
way to read the module when it is in continuous storage mode.
This section describes data types that are used in calls to public methods of
the CCAENV1x90
device support class.
ECLOutputSelect
.
The CCAENV1x90 TDC has a programmable ECL output on its control bus.
The ECLOutputSelect
type is an enumerated
type that provides symbolic names to the possible signals that can be
programmed to appear on this output:
DATA_READY
Data are ready in the module. In the case of trigger matching mode, I believe data are only ready if a full event has been digitized and stored.
FULL
The event FIFO buffer is full.
ALMOST_FULL
The FIFO is almost full as defined by the almost full level programmed in the devie.
ERROR
An error has ocurred in the TDC.
TriggerConfiguration
.
This is a structure, that is intended to be decoded by e.g.
GetWindowOffset
. It is the data
that is returned from the TDC microcontroller when
GetTriggerConfiguration
is called.
it has the following fields:
s_MatchWidth
The matching window width in FPGA clock ticks.
s_MatchOffset
The matching window offset in FPGA clock ticks (signed).
s_MatchExtra
The extra mathing margin.
s_RejectMargin
The reject margin of the matching window.
s_Subtracting
Inidicates if the gate time is subtracted from times in the matching window.
EdgeMode
.
This is an enumeration whose values are used to specify what constitutes a
hit in a channel.
EdgeMode_Pair
A hit is a pulse, and the measurement consists of the time of the leading edge and the width of the pulse.
EdgeMode_Leading
A hit is the leading edge of an input pulse.
EdgeMode_Trailing
A hit is the trailing edge of a pulse.
EdgeMode_Both
Both edges of each pulse are digitized.
Resolution
.
This is an enumerated type that defines the possible resolutions
of the least significant bit of the time measures. It can take the following
values:
Res_25ps
The resolution is 25ps. This is only legal for the V1290.
Res_100ps
The resolution is 100ps.
Res_200ps
The resolution is 200ps.
Res_800ps
The resolution is 800ps.
LEResolution
.
Specifies the resolution with which the leading pulse in a pulse
pair is measured. This is an enumerated type that has
possible values that look like
LE_nnnps
,
where nnn is the number of picoseconds of resolution and can take the values
100, 200, 400, 800, 1600, 3120, 6250, and
12500.
PWResolution
. Specifies the resolution of the width of a pulse pair.
This is an enumerated type with two formats:
PW_nnnps
,
and PW_mmmns
.
In the first form, nnn is the resolution in picoseconds
and can be any of: 100 200 400 800 1600 3200 6250 12500.
In the second form, mmm is the resolution in nanoseconds
and can be any fo the following: 25 50 100 200 400 800.
DeadTime
. This enumerated constant specifies the double hit resolution (dead time between
conesecutive hits in the same channel. Values have the form
DT_nnnns
, where
nnn is this timing parameter in ns and can be any
of the following 5, 10, 30, 100.
HitMax
.
This is an enumerated tpe that dtermines how many hits will be accepted in
a trigger matching window for an event. Note that this limit spans all
channels rather than being a per channel limit. Values of this type
are of the form HITS_n
where n determines the maximum number of hits
andcan be any of the following: 0, 1, 2, 4, 8, 16, 32, 64, 128,
UNLIMITED.
L1Size
.
Limits the size of the TDC level 1 buffer. This enumerated type has
values of the form: L1_nwds
,
where n is the L1 buffersize limit in
32 bit longwords and can be one of:
2, 4, 8, 16, 32, 64, 128, 256.
Constants. The following set of 16 bit constants are defined, and represent bits in the
error enable mask ERR_VERNIER, ERR_COARSE, ERR_SELECT,
ERR_L1PARITY, ERR_TFIFOPARITY, ERR_MATCHERROR, ERR_RFIFOPARITY, ERR_RDOSTATE,
ERR_SUPPARITY, ERR_CTLPARITY, ERR_JTAGPARITY
Various exception types may be thrown including:
std::string
If the module addressed did not have a legal type
CException
A standard NSCL Exception typ thrown iif there are low level problems accessing the device.
Improper function paramters will in general result in an excetpion from the DesignByContract.h header.