Commit ab924980 authored by dino's avatar dino
Browse files

A few adjustments in connection with the call to process_stop

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@782 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 3a1ea47c
......@@ -36,6 +36,8 @@ fTrigger("data:ranc0")
fDanteDz = 0;
fDanteRz1 = fDanteRy = fDanteRz2 = fDanteRx = 0;
fDanteVc = 0;
fDanteChXcal0 = fDanteChYcal0 = 0; // offsets
fDanteChXcal1 = fDanteChYcal1 = 1.f; // gains
rawBufLen = 0;
rawBuf = NULL;
......@@ -200,6 +202,12 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
else if( stringEq(keyw, "DanteBeta") ) {
ok = 1 == sscanf(data.c_str(), "%f", &fDanteVc);
}
else if( stringEq(keyw, "DanteCalX") ) {
ok = 2 == sscanf(data.c_str(), "%f %f", &fDanteChXcal0, &fDanteChXcal1);
}
else if( stringEq(keyw, "DanteCalY") ) {
ok = 2 == sscanf(data.c_str(), "%f %f", &fDanteChYcal0, &fDanteChYcal1);
}
else if( stringEq(keyw, "Verbose") ) {
fVerbose = true;
ok = true;
......
......@@ -75,6 +75,8 @@ protected:
UInt_t fDanteChT, fDanteChX, fDanteChY;
Float_t fDanteDz, fDanteRz1, fDanteRy, fDanteRz2, fDanteRx;
Float_t fDanteVc;
Float_t fDanteChXcal0, fDanteChXcal1; // calibration coefficients
Float_t fDanteChYcal0, fDanteChYcal1; // calibration coefficients
public:
// next three methods can be overloaded in the daughter class
......
......@@ -315,9 +315,11 @@ bool AncillaryFilterATCA::analyseDante(Float_t posx, Float_t posy)
{
// transformation to mm
// should be parametrized and defined in a setup file
DantePos[0] = (780.f-posx)*0.074f; // x=(780-ych)*0.074
DantePos[1] = (posy-718.f)*0.107f; // y=(xch-718)*0.107
//DantePos[0] = (780.f-posx)*0.074f; // x=(780-ych)*0.074
//DantePos[1] = (posy-718.f)*0.107f; // y=(xch-718)*0.107
DantePos[0] = fDanteChXcal0 + posx * fDanteChXcal1;
DantePos[1] = fDanteChYcal0 + posy * fDanteChYcal1;
DantePos[2] = fDanteDz;
RotDante.Rotate(DantePos, DantePos_3D);
......
......@@ -297,14 +297,17 @@ bool AncillaryFilterVME::initPresort()
SpecAll->setComment("Projection of all parameters");
hGroup.add(SpecAll);
// if(MatrAll_PRISMA) delete MatrAll_PRISMA; MatrAll_PRISMA = NULL;
// if(fAllPairsMat && TotNumMod >= 3) {
// MatrAll_PRISMA = new nDhist<unsigned short>(3*32, 3*32, mtAllSize, mtAllSize);
// MatrAll_PRISMA->setFileName(fOdirPrefix+"Matr?All_PRISMA.matr");
// MatrAll_PRISMA->setComment("Matrix of all pairs");
// hGroup.add(MatrAll_PRISMA);
// }
#ifdef AF_PRISMA
if(MatrAll_PRISMA) delete MatrAll_PRISMA; MatrAll_PRISMA = NULL;
if(fAllPairsMat && TotNumMod >= 3) {
MatrAll_PRISMA = new nDhist<unsigned short>(3*32, 3*32, mtAllSize, mtAllSize);
MatrAll_PRISMA->setFileName(fOdirPrefix+"Matr?All_PRISMA.matr");
MatrAll_PRISMA->setComment("Matrix of all pairs");
hGroup.add(MatrAll_PRISMA);
}
#endif
#ifdef AF_DANTE
if(fAllPairsMat && TotNumMod >= 5) {
if(MatrAll_DANTE) delete MatrAll_DANTE; MatrAll_DANTE = NULL;
MatrAll_DANTE = new nDhist<unsigned short>(2*32, 2*32, mtAllSize, mtAllSize);
......@@ -312,6 +315,7 @@ bool AncillaryFilterVME::initPresort()
MatrAll_DANTE->setComment("Matrix of all pairs");
hGroup.add(MatrAll_DANTE);
}
#endif
#ifdef _FromGRU_
TxTy_Dante0 = new TH2F("RawTimeX-RawTimeY_Dante0", "RawTimeX-RawTimeY_Dante0", 256,0,4096,256,0,4096);
......@@ -629,9 +633,11 @@ bool AncillaryFilterVME::processEventDANTE(Float_t posx, Float_t posy)
{
// transformation to mm
// should be parametrized and defined in a setup file
DantePos[0] = (780.f - posx) * 0.074f; // x=(780-ych)*0.074
DantePos[1] = (posy - 718.f) * 0.107f; // y=(xch-718)*0.107
//DantePos[0] = (780.f - posx) * 0.074f; // x=(780-ych)*0.074
//DantePos[1] = (posy - 718.f) * 0.107f; // y=(xch-718)*0.107
DantePos[0] = fDanteChXcal0 + posx * fDanteChXcal1;
DantePos[1] = fDanteChYcal0 + posy * fDanteChYcal1;
DantePos[2] = fDanteDz;
RotDante.Rotate(DantePos, DantePos_3D);
......
......@@ -12,7 +12,7 @@ public:
enum EModule { NONE, ADC, TDC, SCALER };
Converter_t() : Crate(0), Slot(0), NumChan(0), Type(NONE),
Value(NULL), Threshold(NULL), Offset(NULL), Gain(NULL) {;}
Value(NULL), Threshold(NULL), Offset(NULL), Gain(NULL) {;}
bool Setup(std::string name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan);
void Clear() { memset(Value, 0, NumChan*sizeof(Float_t)); }
Float_t xValue(UInt_t chan) {
......
......@@ -182,7 +182,7 @@ void PSAFilter::process_initialise (UInt_t *error_code)
#if TCOUNT > 1
// launch the threads of the local chains
cout << "Grid Search called using " << TCOUNT << " THREADS with blocks of " << TMODULO << " EVENTS" << endl;
cout << crystal_id << "-Grid Search called using " << TCOUNT << " THREADS with blocks of " << TMODULO << " EVENTS" << endl;
for(int slot = 0; slot < TCOUNT ; slot++) {
Slot[slot].State = 0; // start in the non-running state
Slot[slot].Thread = new boost::thread(tProcess(this, slot));
......@@ -632,7 +632,7 @@ void PSAFilter::process_start (UInt_t *error_code)
void PSAFilter::process_stop (UInt_t *error_code)
{
cout << "\nPSAFilter::process_stop called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PSAFilter::process_stop called with GetPID() " << GetPID() << endl;
*error_code = 0;
cServer.Finish();
......@@ -640,20 +640,20 @@ void PSAFilter::process_stop (UInt_t *error_code)
void PSAFilter::process_pause (UInt_t *error_code)
{
cout << "\nPSAFilter::process_pause called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PSAFilter::process_pause called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
void PSAFilter::process_resume (UInt_t *error_code)
{
cout << "\nPSAFilter::process_resume called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PSAFilter::process_resume called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
/*
void PSAFilter::process_unload (UInt_terror_code)
{
cout << "PSAFilter::process_unload called with GetPID()" << GetPID() << endl;
cout << "\n" << crystal_id << "-PSAFilter::process_unload called with GetPID()" << GetPID() << endl;
*error_code = 0;
} */
......
......@@ -561,7 +561,7 @@ Int_t PreprocessingFilter::SetOutput(char * outbuffptr)
// the basic version does nothing
Int_t PreprocessingFilter::Process()
{
cout << "in PreprocessingFilter::Process, which should never be called !!" << endl;
cout << "\n" << crystal_id << "-in PreprocessingFilter::Process, which should never be called !!" << endl;
return 0;
}
......@@ -603,7 +603,7 @@ void PreprocessingFilter::process_start ( UInt_t *error_code )
void PreprocessingFilter::process_stop ( UInt_t *error_code )
{
cout << "\nPreprocessingFilter::process_stop called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PreprocessingFilter::process_stop called with GetPID() " << GetPID() << endl;
*error_code = 0;
cServer.Finish();
......@@ -611,19 +611,19 @@ void PreprocessingFilter::process_stop ( UInt_t *error_code )
void PreprocessingFilter::process_pause ( UInt_t *error_code )
{
cout << "\nPreprocessingFilter::process_pause called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PreprocessingFilter::process_pause called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
void PreprocessingFilter::process_resume ( UInt_t *error_code )
{
cout << "\nPreprocessingFilter::process_resume called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-PreprocessingFilter::process_resume called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
//void PreprocessingFilter::process_unload (UInt_terror_code)
//{
//cout << "PreprocessingFilter::process_unload called with GetPID()" << GetPID() << endl;
//cout << "\n" << crystal_id << "-PreprocessingFilter::process_unload called with GetPID()" << GetPID() << endl;
//*error_code = 0;
//}
......@@ -256,8 +256,7 @@ void AncillaryProducerTCP::process_block (void *output_buffer,
// This is how the non-blocking read has been implemented
*error_code = 0;
if (stop_called && sleep_asked)
{
if (stop_called && sleep_asked) {
*used_size_of_output_buffer = 0;
return;
}
......@@ -319,7 +318,6 @@ void AncillaryProducerTCP::process_block (void *output_buffer,
if(numEvents) {
LOCK_COUT;
cout << " just before cServer.Prompt AncTCP " << endl;
cServer.Prompt(fDetectorID, numEvents, *used_size_of_output_buffer );
cout << " evn = " << setw(8) << evnumber
<< " tst = " << fixed << setprecision(1) << setw(4) << timestamp/double(tst1second)
......@@ -327,14 +325,16 @@ void AncillaryProducerTCP::process_block (void *output_buffer,
}
if(*error_code != 0)
cout << "\nAncillaryProducerTCP::process_block() returning with error " << *error_code << endl << endl;
cout << "\n"<< fDetectorID << "-AncillaryProducerTCP::process_block() returning with error " << *error_code << endl;
if(stop_called)
cout << "\n"<< fDetectorID << "-AncillaryProducerTCP::process_block() returning with stop_called " << endl << endl;
return;
}
void AncillaryProducerTCP::process_start(uint32_t *error_code)
{
cout << "\nAncillaryProducerTCP::process_start called " << endl;
cout << "\n" << fDetectorID << "-AncillaryProducerTCP::process_start called " << endl;
cServer.Start(NULL, gMotherClass);
stop_called = false;
......@@ -344,58 +344,63 @@ void AncillaryProducerTCP::process_start(uint32_t *error_code)
void AncillaryProducerTCP::process_stop(uint32_t *error_code)
{
cout << "\nAncillaryProducerTCP::process_stop called " << endl;
cout << "\n" << fDetectorID << "-AncillaryProducerTCP::process_stop called " << endl;
*error_code = 0;
stop_called = true;
cServer.Finish();
// Temporary
return;
bytes_to_get = bytes_to_get_orig = 0;
if(input_buffer) {
delete [] input_buffer;
input_buffer = NULL;
}
size_of_input_buffer = read_size_of_input_buffer = used_size_of_input_buffer = 0;
old_event_still_present = false;
#if OS_TYPE == OS_LINUX
//close connection
tcp_client->close();
tcp_listener->close();
#endif
if(input_file && input_file.is_open())
input_file.close();
if(output_file && output_file.is_open())
output_file.close();
// Cannot perform any of these actions here, because process_stop is called
// asynchronously while processing is still going on.
// The stop-called flag should be used somewhere else to make the intended cleanups
// bytes_to_get = bytes_to_get_orig = 0;
// if(input_buffer) {
// delete [] input_buffer;
// input_buffer = NULL;
// }
// size_of_input_buffer = read_size_of_input_buffer = used_size_of_input_buffer = 0;
// old_event_still_present = false;
//
//#if OS_TYPE == OS_LINUX
// //close connection
// tcp_client->close();
// tcp_listener->close();
//#endif
//
// if(input_file && input_file.is_open())
// input_file.close();
// if(output_file && output_file.is_open())
// output_file.close();
//
//#if OS_TYPE == OS_LINUX
// //free memory
// if (tcp_client) delete tcp_client;
// if (input_stream) delete input_stream;
// if (tcp_listener) delete tcp_listener;
//#endif
#if OS_TYPE == OS_LINUX
//free memory
if (tcp_client) delete tcp_client;
if (input_stream) delete input_stream;
if (tcp_listener) delete tcp_listener;
#endif
}
void AncillaryProducerTCP::process_reset(uint32_t *error_code)
{
*error_code = 0;
cout << "\nAncillaryProducerTCP::process_reset called " << endl;
cout << "\n" << fDetectorID << "-AncillaryProducerTCP::process_reset called " << endl;
cServer.Reset();
}
void AncillaryProducerTCP::process_resume(uint32_t *error_code)
{
cout << "\nAncillaryProducerTCP::process_resume called " << endl;
cout << "\n" << fDetectorID << "-AncillaryProducerTCP::process_resume called " << endl;
*error_code = 0;
}
void AncillaryProducerTCP::process_pause(uint32_t *error_code)
{
cout << "\nAncillaryProducerTCP::process_pause called " << endl;
cout << "\n" << fDetectorID << "-AncillaryProducerTCP::process_pause called " << endl;
*error_code = 0;
}
// Close the connection to the TCP client (if it is still open) and try to open a new one.
......@@ -422,7 +427,7 @@ bool AncillaryProducerTCP::reset_stream(uint32_t *error_code)
// Cannot accept" (aka there is no client waiting to be connected)
// To avoid blocking on tcp_listener->accept(), do some sleep and return
//if (fVerbose)
cout << "going to sleep" << endl;
cout << "going to sleep ... ";
if (stop_called)
cout << "stop_called!!!" <<endl;
usleep(500000);
......@@ -431,7 +436,7 @@ bool AncillaryProducerTCP::reset_stream(uint32_t *error_code)
return false;
}
//if(fVerbose)
cout << "Try to accept()..." << endl;
cout << "Try to accept()... ";
// Witout the can_accept() test, this could block waiting for a client to connect
input_stream = new tcp_socket_stream(tcp_listener->accept());
//if(fVerbose)
......
......@@ -39,6 +39,7 @@ fTrigger("data:crystal")
crystal_id = 0;
crystal_status = 0;
stop_called = false;
}
CrystalProducer::~CrystalProducer()
......@@ -219,22 +220,24 @@ void CrystalProducer::process_start ( UInt_t *error_code )
cServer.Start(&hGroup, gMotherClass);
*error_code = 0;
stop_called = false;
}
void CrystalProducer::process_stop ( UInt_t *error_code )
{
cout << "\nCrystalProducer::process_stop called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-CrystalProducer::process_stop called with GetPID() " << GetPID() << endl;
*error_code = 0;
stop_called = true;
}
void CrystalProducer::process_pause ( UInt_t *error_code )
{
cout << "\nCrystalProducer::process_pause called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-CrystalProducer::process_pause called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
void CrystalProducer::process_resume ( UInt_t *error_code )
{
cout << "\nCrystalProducer::process_resume called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-CrystalProducer::process_resume called with GetPID() " << GetPID() << endl;
*error_code = 0;
}
......@@ -48,6 +48,8 @@ protected:
UInt_t evnumber;
ULong64_t timestamp;
Bool_t stop_called;
// the configuration parameters
std::string fConfPath;
std::string fIdirPrefix;
......
......@@ -46,12 +46,12 @@ CrystalProducerATCA::~CrystalProducerATCA()
void CrystalProducerATCA::process_start ( UInt_t *error_code )
{
cout << "\nCrystalProducerATCA::process_start called with GetPID() " << GetPID() << endl;
cout << "\n" << crystal_id << "-CrystalProducerATCA::process_start called with GetPID() " << GetPID() << endl;
#if OS_TYPE == OS_WINDOWS
// put here, this does not work with Narval and is moved to AlgoSpecificInitialise()
if( !StartATCA(fNumFilesIn) ) {
cout << "CrystalProducerATCA::process_start -> error from StartATCA()" << endl;
cout << crystal_id << "-CrystalProducerATCA::process_start -> error from StartATCA()" << endl;
*error_code = 121;
return;
}
......@@ -69,6 +69,7 @@ void CrystalProducerATCA::process_stop(UInt_t *error_code)
cServer.Finish();
stop_called = true;
AbortRead();
}
......@@ -91,7 +92,7 @@ Int_t CrystalProducerATCA::AlgoSpecificInitialise()
#if !(OS_TYPE == OS_WINDOWS)
// moved here because in Narval it does not work if called from process_start
if( !StartATCA(fNumFilesIn) ) {
cout << "CrystalProducerATCA::AlgoSpecificInitialise() -> error from StartATCA()" << endl;
cout << crystal_id << "-CrystalProducerATCA::AlgoSpecificInitialise() -> error from StartATCA()" << endl;
return 121;
}
#endif
......@@ -136,9 +137,13 @@ void CrystalProducerATCA::process_block( void *output_buffer, UInt_t size_of_out
{
ULong64_t timestamp0 = 0;
*error_code = 0;
*used_size_of_output_buffer = 0;
if(stop_called)
return;
*error_code = 0;
// Use only part of output_buffer to avoid possible overflows in PreprocessingFilter
// and PSAFilter when fTraceLengthRaw < 2 * defTraceLengthPSA (due to float traces)
// Needed if using the emulator with its fixed length buffers; in Narval one
......@@ -203,6 +208,7 @@ void CrystalProducerATCA::process_block( void *output_buffer, UInt_t size_of_out
LOCK_COUT
Log.GetProcessMethod() = "CrystalProducerATCA::process_block";
Log << error << " During : NextEventATCA()" << dolog;
cout << "\n" << crystal_id << "-CrystalProducerATCA::process_block is going to finish" << endl;
break;
}
#ifdef REPEAT_SAME_EVENT
......@@ -352,9 +358,13 @@ void CrystalProducerATCA::process_block( void *output_buffer, UInt_t size_of_out
{
ULong64_t timestamp0 = 0;
*error_code = 0;
*used_size_of_output_buffer = 0;
if(stop_called)
return;
*error_code = 0;
// Use only part of output_buffer to avoid possible overflows in PreprocessingFilter
// and PSAFilter when fTraceLengthRaw < 2 * defTraceLengthPSA (due to float traces)
// Needed if using the emulator with its fixed length buffers; in Narval one
......@@ -416,6 +426,7 @@ void CrystalProducerATCA::process_block( void *output_buffer, UInt_t size_of_out
LOCK_COUT
Log.GetProcessMethod() = "CrystalProducerATCA::process_block";
Log << error << " During : NextEventATCA()" << dolog;
cout << "\n" << crystal_id << "-CrystalProducerATCA::process_block is going to finish" << endl;
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment