Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions Class/DigitizerClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum DigiReg {
class Digitizer{
RQ_OBJECT("Digitizer")
public:
Digitizer(int ID, uint32_t ChannelMask, string expName);
Digitizer(int portID, int ID, uint32_t ChannelMask, string expName);
~Digitizer();

void SetChannelMask(bool ch7, bool ch6, bool ch5, bool ch4, bool ch3, bool ch2, bool ch1, bool ch0);
Expand Down Expand Up @@ -184,6 +184,7 @@ string GetAcqMode() { return AcqMode == 1 ? "list" : "mixed

int serialNumber;

int portID;
int boardID; /// board identity
int handle; /// i don't know why, but better separete the handle from boardID
int ret; /// return value, refer to CAEN_DGTZ_ErrorCode
Expand Down Expand Up @@ -283,11 +284,12 @@ string GetAcqMode() { return AcqMode == 1 ? "list" : "mixed
int CalNOpenChannel(uint32_t mask);
};

Digitizer::Digitizer(int ID, uint32_t ChannelMask, string expName){
Digitizer::Digitizer(int portID, int ID, uint32_t ChannelMask, string expName){

this->expName = expName;

///================== initialization
this->portID = portID;
boardID = ID;
handle = -1;
NChannel = 0;
Expand Down Expand Up @@ -337,8 +339,8 @@ Digitizer::Digitizer(int ID, uint32_t ChannelMask, string expName){
LinkType = CAEN_DGTZ_USB; /// Link Type
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, boardID, 0, VMEBaseAddress, &handle);
if (ret != 0){ ///---------- try Optical link
LinkType = CAEN_DGTZ_PCI_OpticalLink ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, boardID, 0, VMEBaseAddress, &handle);
LinkType = CAEN_DGTZ_OpticalLink ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
EventAggr = 0;
}

Expand All @@ -364,6 +366,11 @@ Digitizer::Digitizer(int ID, uint32_t ChannelMask, string expName){
printf("ROC FPGA Release is %s\n", BoardInfo.ROC_FirmwareRel);
printf("AMC FPGA Release is %s\n", BoardInfo.AMC_FirmwareRel);

switch(BoardInfo.Model){
case CAEN_DGTZ_V1730: ch2ns = 2; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: ch2ns = 4; break; ///ns -> 250 MSamples/s
}

int MajorNumber;
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &MajorNumber);
if (MajorNumber != V1730_DPP_PHA_CODE) {
Expand Down Expand Up @@ -412,11 +419,15 @@ Digitizer::Digitizer(int ID, uint32_t ChannelMask, string expName){
to allocate the right memory amount */
/// Allocate memory for the readout buffer
ret = CAEN_DGTZ_MallocReadoutBuffer(handle, &buffer, &AllocatedSize);
printf("allowcated %d byte for buffer\n", AllocatedSize);
/// Allocate memory for the events
ret |= CAEN_DGTZ_MallocDPPEvents(handle, reinterpret_cast<void**>(&Events), &AllocatedSize) ;
printf("allowcated %d byte for Events\n", AllocatedSize);

/// Allocate memory for the waveforms
for( int i = 0 ; i < NChannel; i++){
ret |= CAEN_DGTZ_MallocDPPWaveforms(handle, reinterpret_cast<void**>(&Waveform[i]), &AllocatedSize);
printf("allowcated %d byte for waveform\n", AllocatedSize);
}

if (ret != 0) {
Expand Down Expand Up @@ -977,19 +988,19 @@ void Digitizer::GetChannelSetting(int ch){

printf("==========----- discriminator \n");
CAEN_DGTZ_ReadRegister(handle, 0x106C + (ch << 8), value); printf("%20s %d LSB\n", "Threshold", value[0]); ///Threshold
CAEN_DGTZ_ReadRegister(handle, 0x1074 + (ch << 8), value); printf("%20s %d ch \n", "trigger hold off *", value[0] * 8); ///Trigger Hold off
CAEN_DGTZ_ReadRegister(handle, 0x1074 + (ch << 8), value); printf("%20s %d ch \n", "trigger hold off *", value[0] * 4 * ch2ns); ///Trigger Hold off
CAEN_DGTZ_ReadRegister(handle, 0x1054 + (ch << 8), value); printf("%20s %d sample \n", "Fast Dis. smoothing", value[0] ); ///Fast Discriminator smoothing
CAEN_DGTZ_ReadRegister(handle, 0x1058 + (ch << 8), value); printf("%20s %d ns \n", "Input rise time **", value[0] * 8 * ch2ns); ///Input rise time
CAEN_DGTZ_ReadRegister(handle, 0x1058 + (ch << 8), value); printf("%20s %d ns \n", "Input rise time **", value[0] * 4 * ch2ns); ///Input rise time

printf("==========----- Trapezoid \n");
CAEN_DGTZ_ReadRegister(handle, 0x1080 + (ch << 8), value); printf("%20s %d bit = Floor( rise x decay / 64 )\n", "Trap. Rescaling", trapRescaling ); ///Trap. Rescaling Factor
CAEN_DGTZ_ReadRegister(handle, 0x105C + (ch << 8), value); printf("%20s %d ns \n", "Trap. rise time **", value[0] * 8 * ch2ns ); ///Trap. rise time, 2 for 1 ch to 2ns
CAEN_DGTZ_ReadRegister(handle, 0x105C + (ch << 8), value); printf("%20s %d ns \n", "Trap. rise time **", value[0] * 4 * ch2ns ); ///Trap. rise time, 2 for 1 ch to 2ns
CAEN_DGTZ_ReadRegister(handle, 0x1060 + (ch << 8), value);
int flatTopTime = value[0] * 8 * ch2ns; printf("%20s %d ns \n", "Trap. flat time **", flatTopTime); ///Trap. flat time
CAEN_DGTZ_ReadRegister(handle, 0x1068 + (ch << 8), value); printf("%20s %d ns \n", "Decay time **", value[0] * 8 * ch2ns); ///Trap. pole zero
CAEN_DGTZ_ReadRegister(handle, 0x1064 + (ch << 8), value); printf("%20s %d ns = %.2f %% \n", "peaking time **", value[0] * 8 * ch2ns, value[0] * 800. * ch2ns / flatTopTime ); //Peaking time
int flatTopTime = value[0] * 4 * ch2ns; printf("%20s %d ns \n", "Trap. flat time **", flatTopTime); ///Trap. flat time
CAEN_DGTZ_ReadRegister(handle, 0x1068 + (ch << 8), value); printf("%20s %d ns \n", "Decay time **", value[0] * 4 * ch2ns); ///Trap. pole zero
CAEN_DGTZ_ReadRegister(handle, 0x1064 + (ch << 8), value); printf("%20s %d ns = %.2f %% \n", "peaking time **", value[0] * 4 * ch2ns, value[0] * 400. * ch2ns / flatTopTime ); //Peaking time
printf("%20s %.0f sample\n", "Ns peak", pow(4, NsPeak & 3)); //Ns peak
CAEN_DGTZ_ReadRegister(handle, 0x1078 + (ch << 8), value); printf("%20s %d ns \n", "Peak hole off **", value[0] * 8 *ch2ns ); ///Peak hold off
CAEN_DGTZ_ReadRegister(handle, 0x1078 + (ch << 8), value); printf("%20s %d ns \n", "Peak hole off **", value[0] * 4 *ch2ns ); ///Peak hold off

printf("==========----- Other \n");
CAEN_DGTZ_ReadRegister(handle, 0x10C4 + (ch << 8), value); printf("%20s %d \n", "Energy fine gain ?", value[0]); ///Energy fine gain
Expand Down Expand Up @@ -1135,13 +1146,13 @@ void Digitizer::LoadChannelSetting (const int ch, string fileName) {
if( count == 0 ) DPPParams.thr[ch] = atoi(line.substr(0, pos).c_str());
if( count == 1 ) DPPParams.trgho[ch] = atoi(line.substr(0, pos).c_str());
if( count == 2 ) DPPParams.a[ch] = atoi(line.substr(0, pos).c_str());
if( count == 3 ) DPPParams.b[ch] = atoi(line.substr(0, pos).c_str())/8*8; /// digitizer only accept multiple of 8
if( count == 4 ) DPPParams.k[ch] = atoi(line.substr(0, pos).c_str())/8*8;
if( count == 5 ) DPPParams.m[ch] = atoi(line.substr(0, pos).c_str())/8*8;
if( count == 6 ) DPPParams.M[ch] = atoi(line.substr(0, pos).c_str())/8*8;
if( count == 7 ) DPPParams.ftd[ch] = atoi(line.substr(0, pos).c_str())/8*8;
if( count == 3 ) DPPParams.b[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns; /// digitizer only accept multiple of 4 * ch2ns
if( count == 4 ) DPPParams.k[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns;
if( count == 5 ) DPPParams.m[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns;
if( count == 6 ) DPPParams.M[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns;
if( count == 7 ) DPPParams.ftd[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns;
if( count == 8 ) DPPParams.nspk[ch] = atoi(line.substr(0, pos).c_str());
if( count == 9 ) DPPParams.pkho[ch] = atoi(line.substr(0, pos).c_str())/8*8;
if( count == 9 ) DPPParams.pkho[ch] = atoi(line.substr(0, pos).c_str())/4/ch2ns*4*ch2ns;
if( count == 10 ) DPPParams.nsbl[ch] = atoi(line.substr(0, pos).c_str());
if( count == 11 ) inputDynamicRange[ch] = atoi(line.substr(0, pos).c_str());
if( count == 12 ) DCOffset[ch] = atof(line.substr(0, pos).c_str());
Expand Down
2 changes: 1 addition & 1 deletion setting/setting_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
400 // Peak holdoff (ch), start at the end of flat-top, defines how close must be two trapezoid to be considered as piled up
//============= Input
3 // Ns baseline, number of samples for baseline average calculation. Options: 1->16 samples; 2->64 samples; 3->256 samples; 4->1024 samples; 5->4096 samples; 6->16384 samples
1 //input dynamic range, 0 = 2 Vpp, 1 = 0.5 Vpp
0 //input dynamic range, 0 = 2 Vpp, 1 = 0.5 Vpp
//============= Others
0.9 // DC offset ( from 0 to 1, for positive pulse, 1 = baseline bottom )
1000 // pre trigger size [ch];
Expand Down
18 changes: 9 additions & 9 deletions setting/setting_15.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
//============= Discriminator
125 //Tigger Threshold (in LSB)
200 //Tigger Threshold (in LSB)
496 // Trigger Hold Off
32 // Fast Discriminator smooth, Trigger Filter smoothing factor (number of samples to average for RC-CR2 filter) Options: 1; 2; 4; 8; 16; 32
48 // Input Signal Rise time (ch)
16 // Fast Discriminator smooth, Trigger Filter smoothing factor (number of samples to average for RC-CR2 filter) Options: 1; 2; 4; 8; 16; 32
96 // Input Signal Rise time (ch)
//============= Trapezoid
496 //Trapezoid Rise Time (ch)
496 //Trapezoid Flat Top (ch)
400 //Trapezoid Rise Time (ch)
400 //Trapezoid Flat Top (ch)
5000 //Decay Time Constant (ch)
250 // Flat top delay (peaking time) (ch)
100 // Flat top delay (peaking time) (ch)
3 // Ns peak, Peak mean (number of samples to average for trapezoid height calculation). Options: 0-> 1 sample; 1->4 samples; 2->16 samples; 3->64 samples
400 // Peak holdoff (ch), start at the end of flat-top, defines how close must be two trapezoid to be considered as piled up
//============= Input
3 // Ns baseline, number of samples for baseline average calculation. Options: 1->16 samples; 2->64 samples; 3->256 samples; 4->1024 samples; 5->4096 samples; 6->16384 samples
1 //input dynamic range, 0 = 2 Vpp, 1 = 0.5 Vpp
//============= Others
0.5 // DC offset ( from 0 to 1, for positive pulse, 1 = baseline bottom )
1000 // pre trigger size [ch];
0.2 // DC offset ( from 0 to 1, for positive pulse, 1 = baseline bottom )
500 // pre trigger size [ch];
true // is pulse positive parity;
30000 // Energy fine gain, 33900 is roughly equal Compass 10x, 30000 is roughly equal to real voltage at Vpp=2.0x
1 // Energy fine gain, 33900 is roughly equal Compass 10x, 30000 is roughly equal to real voltage at Vpp=2.0x
500 // Baseline holdoff (ns)
1.00 // Energy Normalization Factor
0 // decimation (the input signal samples are averaged within this number of samples): 0 ->disabled; 1->2 samples; 2->4 samples; 3->8 samples
Expand Down
39 changes: 20 additions & 19 deletions src/BoxScore.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,37 @@ void paintCanvas(){
/* ########################################################################### */
int main(int argc, char *argv[]){

if( argc != 3 && argc != 4 && argc != 5 && argc != 6 ) {
if( argc != 4 && argc != 5 && argc != 6 && argc != 7 ) {
printf("usage:\n");
printf(" + use DetectDigitizer \n");
printf(" |\n");
printf("$./BoxScore boardID location (tree.root) (debug)\n");
printf(" | \n");
printf(" +-- testing (all ch)\n");
printf(" +-- exit (1, 3) \n");
printf(" +-- cross (1, 4)\n");
printf(" +-- crosstime (1, 4) \n");
printf(" +-- ZD (zero-degree) (2, 5)\n");
printf(" +-- XY \n");
printf(" +-- XYede (XY de-e only) \n");
printf(" +-- XYpos (X,Y 1-D only) \n");
printf(" +-- IonCh (IonChamber) \n");
printf(" +-- MCP (Micro Channel Plate) \n");
printf("$./BoxScore portID boardID location (tree.root) (debug)\n");
printf(" | \n");
printf(" +-- testing (all ch)\n");
printf(" +-- exit (1, 3) \n");
printf(" +-- cross (1, 4)\n");
printf(" +-- crosstime (1, 4) \n");
printf(" +-- ZD (zero-degree) (2, 5)\n");
printf(" +-- XY \n");
printf(" +-- XYede (XY de-e only) \n");
printf(" +-- XYpos (X,Y 1-D only) \n");
printf(" +-- IonCh (IonChamber) \n");
printf(" +-- MCP (Micro Channel Plate) \n");
return -1;
}

cutopt = "RECREATE"; // by default
cutFileName = "data/cutsFile.root"; // default

const int nInput = argc;
const int boardID = atoi(argv[1]);
string location = argv[2];
const int portID = atoi(argv[1]);
const int boardID = atoi(argv[2]);
string location = argv[3];

//string expName = argv[3];

if( argc >= 4 ) rootFileName = argv[3];
if( argc >= 5 ) isDebug = atoi(argv[4]);
if( argc >= 4 ) rootFileName = argv[4];
if( argc >= 5 ) isDebug = atoi(argv[5]);

char hostname[100];
gethostname(hostname, 100);
Expand Down Expand Up @@ -192,7 +193,7 @@ int main(int argc, char *argv[]){
string expName = "infl21";

printf("******************************************** \n");
printf("**** BoxScoreXY **** \n");
printf("**** BoxScore **** \n");
printf("******************************************** \n");
printf(" Current DateTime : %d-%02d-%02d, %02d:%02d:%02d\n", year, month, day, hour, minute, secound);
printf(" hostname : %s \n", hostname);
Expand All @@ -210,7 +211,7 @@ int main(int argc, char *argv[]){

uint ChannelMask = gp->GetChannelMask();

dig = new Digitizer(boardID, ChannelMask, expName);
dig = new Digitizer(portID, boardID, ChannelMask, expName);
if( !dig->IsConnected() ) return -1;
int NChannels = dig->GetNChannel();
string tag = "tag=" + location; //tag for database
Expand Down
32 changes: 19 additions & 13 deletions src/DetectDigitizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ int main(int argc, char* argv[])
uint32_t size,bsize;
uint32_t numEvents;
i = sizeof(CAEN_DGTZ_TriggerMode_t);
int port;

for(b=0; b<MAXNB; b++){
for( port = 0; port < 3; port ++){

for(b=0; b<MAXNB; b++){
/* IMPORTANT: The following function identifies the different boards with a system which may change
for different connection methods (USB, Conet, ecc). Refer to CAENDigitizer user manual for more info.
brief:
Expand All @@ -121,22 +124,23 @@ int main(int argc, char* argv[])
<VMEBaseAddress>[b-1] = <0xZZZZZZZZ> (address of last board)
See the manual for details */

printf("========================= boardID = %d / %d \n", b, MAXNB-1);
printf("========================= boardID = %d / %d, portID = %d / %d\n", b, MAXNB-1, port, 3);
ret = CAEN_DGTZ_OpenDigitizer(CAEN_DGTZ_USB, b,0,0,&handle[b]);

if ( ret != CAEN_DGTZ_Success) {
printf(" USD : can't open digitizer. probably not connected.\n");
ret = CAEN_DGTZ_OpenDigitizer(CAEN_DGTZ_PCI_OpticalLink, b,0,0,&handle[b]);
if(ret != CAEN_DGTZ_Success) {
printf(" Optical Link : can't open digitizer. probably not connected.\n");
continue;
if( b == MAXNB-1 ) goto QuitProgram;
}
}
if ( ret == CAEN_DGTZ_Success) {
port = 4; /// to break port loop
}else{
printf(" USD : can't open digitizer. probably not connected.\n");
ret = CAEN_DGTZ_OpenDigitizer(CAEN_DGTZ_OpticalLink, port,b,0,&handle[b]);
if(ret != CAEN_DGTZ_Success) {
printf(" Optical Link : can't open digitizer. probably not connected.\n");
continue;
if( b == MAXNB-1 ) goto QuitProgram;
}
}

/* Once we have the handler to the digitizer, we use it to call the other functions */
ret = CAEN_DGTZ_GetInfo(handle[b], &BoardInfo);
printf("\nConnected to CAEN Digitizer Model %s, recognized as board %d\n", BoardInfo.ModelName, b);
printf("\nConnected to CAEN Digitizer Model %s, recognized as board %d, port %d\n", BoardInfo.ModelName, b, port);
printf("\tBoard Model Familty %d\n", BoardInfo.FamilyCode);
printf("\tSerialNumber :\e[33m %d \e[0m\n", BoardInfo.SerialNumber);
printf("\tR0C (Read-out-Controller) FPGA Release is %s\n", BoardInfo.ROC_FirmwareRel);
Expand Down Expand Up @@ -225,7 +229,9 @@ int main(int argc, char* argv[])
// goto QuitProgram;
//}
//printf("\n");
}
}

printf("\n\nPress 's' to start the acquisition\n"); // c = 9
printf("Press 'k' to stop the acquisition\n"); // c = 1
printf("Press 'r' to read a register\n"); // c = 3
Expand Down