mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'g2' into m3
This commit is contained in:
commit
24c4cd8d84
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -374,26 +374,16 @@ void setupDetector() {
|
|||||||
burstPeriodReg = 0;
|
burstPeriodReg = 0;
|
||||||
filter = 0;
|
filter = 0;
|
||||||
cdsGain = 0;
|
cdsGain = 0;
|
||||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
memset(clkPhase, 0, sizeof(clkPhase));
|
||||||
clkPhase[i] = 0;
|
memset(dacValues, 0, sizeof(dacValues));
|
||||||
}
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
|
||||||
dacValues[i] = 0;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
||||||
for (int j = 0; j < NCHIP; ++j) {
|
for (int j = 0; j < NCHIP; ++j) {
|
||||||
onChipdacValues[i][j] = -1;
|
onChipdacValues[i][j] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < NCHIP; ++i) {
|
memset(vetoReference, 0, sizeof(vetoReference));
|
||||||
for (int j = 0; j < NCHAN; ++j) {
|
memset(vetoGainIndices, 0, sizeof(vetoGainIndices));
|
||||||
vetoReference[i][j] = 0;
|
memset(adcConfiguration, 0, sizeof(adcConfiguration));
|
||||||
vetoGainIndices[i][j] = 0;
|
|
||||||
}
|
|
||||||
for (int j = 0; j < NADC; ++j) {
|
|
||||||
adcConfiguration[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
sharedMemory_setStatus(IDLE);
|
sharedMemory_setStatus(IDLE);
|
||||||
#endif
|
#endif
|
||||||
@ -1789,9 +1779,7 @@ int setVetoReference(int gainIndex, int value) {
|
|||||||
LOG(logINFO, ("Setting veto reference [chip:-1, G%d, value:0x%x]\n",
|
LOG(logINFO, ("Setting veto reference [chip:-1, G%d, value:0x%x]\n",
|
||||||
gainIndex, value));
|
gainIndex, value));
|
||||||
int values[NCHAN];
|
int values[NCHAN];
|
||||||
memset(values, 0, sizeof(values));
|
|
||||||
int gainIndices[NCHAN];
|
int gainIndices[NCHAN];
|
||||||
memset(gainIndices, 0, sizeof(gainIndices));
|
|
||||||
for (int ich = 0; ich < NCHAN; ++ich) {
|
for (int ich = 0; ich < NCHAN; ++ich) {
|
||||||
values[ich] = value;
|
values[ich] = value;
|
||||||
gainIndices[ich] = gainIndex;
|
gainIndices[ich] = gainIndex;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6332,16 +6332,14 @@ int set_veto_photon(int file_des) {
|
|||||||
int args[2] = {-1, -1};
|
int args[2] = {-1, -1};
|
||||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
int chipIndex = args[0];
|
const int chipIndex = args[0];
|
||||||
int numChannels = args[1];
|
const int numChannels = args[1];
|
||||||
|
|
||||||
int gainIndices[args[1]];
|
int gainIndices[numChannels];
|
||||||
memset(gainIndices, 0, sizeof(gainIndices));
|
|
||||||
if (receiveData(file_des, gainIndices, sizeof(gainIndices), INT32) < 0)
|
if (receiveData(file_des, gainIndices, sizeof(gainIndices), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
int values[args[1]];
|
int values[numChannels];
|
||||||
memset(values, 0, sizeof(values));
|
|
||||||
if (receiveData(file_des, values, sizeof(values), INT32) < 0)
|
if (receiveData(file_des, values, sizeof(values), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
@ -6353,19 +6351,18 @@ int set_veto_photon(int file_des) {
|
|||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
|
if (numChannels != NCHAN) {
|
||||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
|
||||||
ret = FAIL;
|
|
||||||
sprintf(mess, "Could not set veto photon. Invalid chip index %d\n",
|
|
||||||
chipIndex);
|
|
||||||
LOG(logERROR, (mess));
|
|
||||||
} else if (numChannels != NCHAN) {
|
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not set veto photon. Invalid number of channels %d. "
|
"Could not set veto photon. Invalid number of channels %d. "
|
||||||
"Expected %d\n",
|
"Expected %d\n",
|
||||||
numChannels, NCHAN);
|
numChannels, NCHAN);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
|
} else if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not set veto photon. Invalid chip index %d\n",
|
||||||
|
chipIndex);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < NCHAN; ++i) {
|
for (int i = 0; i < NCHAN; ++i) {
|
||||||
if (gainIndices[i] < 0 || gainIndices[i] > 2) {
|
if (gainIndices[i] < 0 || gainIndices[i] > 2) {
|
||||||
|
@ -1389,19 +1389,25 @@ void Module::setInjectChannel(const int offsetChannel,
|
|||||||
sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr);
|
sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendVetoPhoton(const int chipIndex, int *gainIndices,
|
void Module::sendVetoPhoton(const int chipIndex, std::vector<int> gainIndices,
|
||||||
int *values) {
|
std::vector<int> values) {
|
||||||
int fnum = F_SET_VETO_PHOTON;
|
const int nch = gainIndices.size();
|
||||||
int ret = FAIL;
|
if (gainIndices.size() != values.size()) {
|
||||||
int nch = shm()->nChan.x;
|
throw RuntimeError("Number of Gain Indices and values do not match! "
|
||||||
int args[]{chipIndex, nch};
|
"Gain Indices size: " +
|
||||||
|
std::to_string(gainIndices.size()) +
|
||||||
|
", values size: " + std::to_string(values.size()));
|
||||||
|
}
|
||||||
LOG(logDEBUG1) << "Sending veto photon/file to detector [chip:" << chipIndex
|
LOG(logDEBUG1) << "Sending veto photon/file to detector [chip:" << chipIndex
|
||||||
<< ", nch:" << nch << "]";
|
<< ", nch:" << nch << "]";
|
||||||
|
int fnum = F_SET_VETO_PHOTON;
|
||||||
|
int ret = FAIL;
|
||||||
|
int args[]{chipIndex, nch};
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.Send(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
client.Send(args, sizeof(args));
|
client.Send(args, sizeof(args));
|
||||||
client.Send(gainIndices, sizeof(int) * nch);
|
client.Send(gainIndices.data(), sizeof(int) * nch);
|
||||||
client.Send(values, sizeof(int) * nch);
|
client.Send(values.data(), sizeof(int) * nch);
|
||||||
client.Receive(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
@ -1413,6 +1419,7 @@ void Module::sendVetoPhoton(const int chipIndex, int *gainIndices,
|
|||||||
|
|
||||||
void Module::getVetoPhoton(const int chipIndex,
|
void Module::getVetoPhoton(const int chipIndex,
|
||||||
const std::string &fname) const {
|
const std::string &fname) const {
|
||||||
|
LOG(logDEBUG1) << "Getting veto photon [" << chipIndex << "]\n";
|
||||||
int fnum = F_GET_VETO_PHOTON;
|
int fnum = F_GET_VETO_PHOTON;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
@ -1425,16 +1432,18 @@ void Module::getVetoPhoton(const int chipIndex,
|
|||||||
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
||||||
" returned error: " + std::string(mess));
|
" returned error: " + std::string(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
int nch = -1;
|
int nch = -1;
|
||||||
client.Receive(&nch, sizeof(nch));
|
client.Receive(&nch, sizeof(nch));
|
||||||
LOG(logDEBUG1) << "Getting veto photon [" << chipIndex << "]: " << nch
|
if (nch != shm()->nChan.x) {
|
||||||
<< " channels\n";
|
throw RuntimeError("Could not get veto photon. Expected " +
|
||||||
int gainIndices[nch];
|
std::to_string(shm()->nChan.x) + " channels, got " +
|
||||||
memset(gainIndices, 0, sizeof(gainIndices));
|
std::to_string(nch));
|
||||||
client.Receive(gainIndices, sizeof(gainIndices));
|
}
|
||||||
int values[nch];
|
std::vector<int> gainIndices(nch);
|
||||||
memset(values, 0, sizeof(values));
|
std::vector<int> values(nch);
|
||||||
client.Receive(values, sizeof(values));
|
client.Receive(gainIndices.data(), nch * sizeof(int));
|
||||||
|
client.Receive(values.data(), nch * sizeof(int));
|
||||||
|
|
||||||
// save to file
|
// save to file
|
||||||
std::ofstream outfile;
|
std::ofstream outfile;
|
||||||
@ -1475,12 +1484,8 @@ void Module::setVetoPhoton(const int chipIndex, const int numPhotons,
|
|||||||
LOG(logDEBUG1) << "Setting veto photon. Reading Gain values from file";
|
LOG(logDEBUG1) << "Setting veto photon. Reading Gain values from file";
|
||||||
|
|
||||||
int totalEnergy = numPhotons * energy;
|
int totalEnergy = numPhotons * energy;
|
||||||
int ch = shm()->nChan.x;
|
std::vector<int> gainIndices;
|
||||||
int nRead = 0;
|
std::vector<int> values;
|
||||||
int values[ch];
|
|
||||||
int gainIndices[ch];
|
|
||||||
memset(values, 0, sizeof(values));
|
|
||||||
memset(gainIndices, 0, sizeof(gainIndices));
|
|
||||||
|
|
||||||
while (infile.good()) {
|
while (infile.good()) {
|
||||||
std::string line;
|
std::string line;
|
||||||
@ -1503,7 +1508,7 @@ void Module::setVetoPhoton(const int chipIndex, const int numPhotons,
|
|||||||
if (ss.fail()) {
|
if (ss.fail()) {
|
||||||
throw RuntimeError("Could not set veto photon. Invalid pedestals, "
|
throw RuntimeError("Could not set veto photon. Invalid pedestals, "
|
||||||
"gain values or gain thresholds for channel " +
|
"gain values or gain thresholds for channel " +
|
||||||
std::to_string(nRead));
|
std::to_string(gainIndices.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// caluclate gain index from gain thresholds and threhsold energy
|
// caluclate gain index from gain thresholds and threhsold energy
|
||||||
@ -1513,19 +1518,17 @@ void Module::setVetoPhoton(const int chipIndex, const int numPhotons,
|
|||||||
} else if (totalEnergy < gainThreshold[1]) {
|
} else if (totalEnergy < gainThreshold[1]) {
|
||||||
gainIndex = 1;
|
gainIndex = 1;
|
||||||
}
|
}
|
||||||
// calculate ADU values = pedestal + gainvalue * total energy
|
gainIndices.push_back(gainIndex);
|
||||||
values[nRead] =
|
// calculate ADU value
|
||||||
gainPedestal[gainIndex] + (gainValue[gainIndex] * totalEnergy);
|
values.push_back(gainPedestal[gainIndex] +
|
||||||
gainIndices[nRead] = gainIndex;
|
(gainValue[gainIndex] * totalEnergy));
|
||||||
++nRead;
|
|
||||||
if (nRead >= ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (nRead != ch) {
|
// check size
|
||||||
throw RuntimeError("Could not set veto photon. Insufficient pedestal "
|
if ((int)gainIndices.size() != shm()->nChan.x) {
|
||||||
"for gain values: " +
|
throw RuntimeError("Could not set veto photon. Invalid number of "
|
||||||
std::to_string(nRead));
|
"entries in file. Expected " +
|
||||||
|
std::to_string(shm()->nChan.x) + ", read " +
|
||||||
|
std::to_string(gainIndices.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendVetoPhoton(chipIndex, gainIndices, values);
|
sendVetoPhoton(chipIndex, gainIndices, values);
|
||||||
@ -1558,12 +1561,8 @@ void Module::setVetoFile(const int chipIndex, const std::string &fname) {
|
|||||||
" for reading");
|
" for reading");
|
||||||
}
|
}
|
||||||
|
|
||||||
int ch = shm()->nChan.x;
|
std::vector<int> gainIndices;
|
||||||
int nRead = 0;
|
std::vector<int> values;
|
||||||
int gainIndices[ch];
|
|
||||||
memset(gainIndices, 0, sizeof(gainIndices));
|
|
||||||
int values[ch];
|
|
||||||
memset(values, 0, sizeof(values));
|
|
||||||
|
|
||||||
for (std::string line; std::getline(input_file, line);) {
|
for (std::string line; std::getline(input_file, line);) {
|
||||||
if (line.find('#') != std::string::npos) {
|
if (line.find('#') != std::string::npos) {
|
||||||
@ -1574,25 +1573,32 @@ void Module::setVetoFile(const int chipIndex, const std::string &fname) {
|
|||||||
// convert command and string to a vector
|
// convert command and string to a vector
|
||||||
std::istringstream iss(line);
|
std::istringstream iss(line);
|
||||||
std::string val;
|
std::string val;
|
||||||
iss >> gainIndices[nRead] >> val;
|
int gainIndex = -1;
|
||||||
|
int value = -1;
|
||||||
|
iss >> gainIndex >> val;
|
||||||
if (iss.fail()) {
|
if (iss.fail()) {
|
||||||
throw RuntimeError("Could not set veto file. Invalid gain "
|
throw RuntimeError("Could not set veto file. Invalid gain "
|
||||||
"or reference value for channel " +
|
"or reference value for channel " +
|
||||||
std::to_string(nRead));
|
std::to_string(gainIndices.size()));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
values[nRead] = StringTo<int>(val);
|
value = StringTo<int>(val);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw RuntimeError("Could not set veto file. Invalid value " +
|
throw RuntimeError("Could not set veto file. Invalid value " +
|
||||||
val + " for channel " +
|
val + " for channel " +
|
||||||
std::to_string(nRead));
|
std::to_string(gainIndices.size()));
|
||||||
}
|
|
||||||
++nRead;
|
|
||||||
if (nRead >= ch) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
gainIndices.push_back(gainIndex);
|
||||||
|
values.push_back(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// check size
|
||||||
|
if ((int)gainIndices.size() != shm()->nChan.x) {
|
||||||
|
throw RuntimeError("Could not set veto file. Invalid number of "
|
||||||
|
"entries in file. Expected " +
|
||||||
|
std::to_string(shm()->nChan.x) + ", read " +
|
||||||
|
std::to_string(gainIndices.size()));
|
||||||
|
}
|
||||||
|
|
||||||
sendVetoPhoton(chipIndex, gainIndices, values);
|
sendVetoPhoton(chipIndex, gainIndices, values);
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setBurstPeriod(int64_t value);
|
void setBurstPeriod(int64_t value);
|
||||||
std::array<int, 2> getInjectChannel() const;
|
std::array<int, 2> getInjectChannel() const;
|
||||||
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
||||||
void sendVetoPhoton(const int chipIndex, int *gainIndices, int *values);
|
void sendVetoPhoton(const int chipIndex, std::vector<int> gainIndices,
|
||||||
|
std::vector<int> values);
|
||||||
void getVetoPhoton(const int chipIndex, const std::string &fname) const;
|
void getVetoPhoton(const int chipIndex, const std::string &fname) const;
|
||||||
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||||
const int energy, const std::string &fname);
|
const int energy, const std::string &fname);
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#define APILIB 0x200409
|
#define APILIB 0x200409
|
||||||
#define APIRECEIVER 0x200409
|
#define APIRECEIVER 0x200409
|
||||||
#define APIGUI 0x200409
|
#define APIGUI 0x200409
|
||||||
#define APICTB 0x200723
|
#define APICTB 0x200729
|
||||||
#define APIGOTTHARD 0x200723
|
#define APIGOTTHARD 0x200729
|
||||||
#define APIMYTHEN3 0x200723
|
#define APIGOTTHARD2 0x200729
|
||||||
#define APIMOENCH 0x200722
|
#define APIJUNGFRAU 0x200729
|
||||||
#define APIEIGER 0x200723
|
#define APIMYTHEN3 0x200729
|
||||||
#define APIJUNGFRAU 0x200728
|
#define APIMOENCH 0x200728
|
||||||
#define APIGOTTHARD2 0x200728
|
#define APIEIGER 0x200729
|
||||||
|
Loading…
x
Reference in New Issue
Block a user