Skip to content

Commit

Permalink
Addressing some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
juanangp committed Apr 29, 2024
1 parent 22ebf6a commit 218c78b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 35 deletions.
30 changes: 15 additions & 15 deletions daq/FEMINOSPacket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ void FEMINOSPacket::DataPacket_Print (uint16_t *fr, const uint16_t &size){
printf("Event_Count %d\n", evC);

} else if ((*fr & PFX_4_BIT_CONTENT_MASK) == PFX_END_OF_EVENT){
uint32_t size_ev = ( GET_EOE_SIZE(*fr)) << 16;
uint32_t size_ev = (( GET_EOE_SIZE(*fr)) << 16 ) & 0xFFFF0000;
fr++;
sz_rd++;
size_ev |= *fr;
size_ev |= *fr & 0xFFFF;
fr++;
sz_rd++;
printf("----- End of Event ----- (size %d bytes)\n", size);
Expand Down Expand Up @@ -291,15 +291,18 @@ bool FEMINOSPacket::GetNextEvent(std::deque <uint16_t> &buffer, TRestRawSignalEv
while (!endOfEvent && !buffer.empty()){
//std::cout<<"Val 0x"<<std::hex<<buffer.front()<<std::dec<<" " <<buffer.front()<<std::endl;

//TimeStamp and Event Count, once for every event
if ((buffer.front() & PFX_4_BIT_CONTENT_MASK) == PFX_START_OF_EVENT){
if ((buffer.front() & PFX_9_BIT_CONTENT_MASK) == PFX_START_OF_DFRAME){
buffer.pop_front();
//std::cout<<"START OF DFRAME filled with "<< buffer.front() <<" bytes"<<std::endl;
buffer.pop_front();
} else if ((buffer.front() & PFX_4_BIT_CONTENT_MASK) == PFX_START_OF_EVENT){
//std::cout<<"START OF EVENT "<<std::endl;
buffer.pop_front();
tS = buffer.front();
tS = buffer.front() & 0xFFFF;
buffer.pop_front();
tS |= ( buffer.front() << 16);
tS |= ( buffer.front() << 16) & 0xFFFF0000;
buffer.pop_front();
tS |= ( buffer.front() << 24);
tS |= ( buffer.front() << 24) & 0xFFFF00000000;
buffer.pop_front();

//Event count
Expand All @@ -308,16 +311,12 @@ bool FEMINOSPacket::GetNextEvent(std::deque <uint16_t> &buffer, TRestRawSignalEv
ev_count |= ( buffer.front() << 16);
buffer.pop_front();

//std::cout<<"EvCnt "<<ev_count<<" TS "<<(double)tS <<std::endl;
//std::cout<<"EvCnt "<<ev_count<<" TS "<<tS <<std::endl;
} else if ((buffer.front() & PFX_14_BIT_CONTENT_MASK) == PFX_CARD_CHIP_CHAN_HIT_CNT){
//printf( "Card %02d Chip %01d Channel_Hit_Count %02d\n", GET_CARD_IX(buffer.front()), GET_CHIP_IX(buffer.front()), GET_CHAN_IX(buffer.front()) );
buffer.pop_front();
} else if ((buffer.front() & PFX_12_BIT_CONTENT_MASK) == PFX_CHIP_LAST_CELL_READ){

for(int i=0;i<4;i++){
//printf( "Chip %01d Last_Cell_Read %03d (0x%03x)\n",GET_LST_READ_CELL_CHIP_IX(buffer.front()), GET_LST_READ_CELL(buffer.front()), GET_LST_READ_CELL(buffer.front()));
buffer.pop_front();
}
buffer.pop_front();
} else if ( (buffer.front() & PFX_14_BIT_CONTENT_MASK) == PFX_CARD_CHIP_CHAN_HIT_IX ) {
uint16_t cardID = GET_CARD_IX(buffer.front());
uint16_t chipID = GET_CHIP_IX(buffer.front());
Expand All @@ -338,19 +337,20 @@ bool FEMINOSPacket::GetNextEvent(std::deque <uint16_t> &buffer, TRestRawSignalEv
//std::cout<<"TimeBin "<<timeBin<<" "<<GET_ADC_DATA(buffer.front())<<std::endl;
}
buffer.pop_front();
if(buffer.empty())break;
}

TRestRawSignal rawSignal(physChannel, sData);
sEvent->AddSignal(rawSignal);

} else if ( (buffer.front() & PFX_4_BIT_CONTENT_MASK) == PFX_END_OF_EVENT ){
endOfEvent=true;
//std::cout<<"END OF EVENT ";
//std::cout<<"END OF EVENT "<<std::endl;
buffer.pop_front();
//std::cout<<" event size "<<buffer.front()<<std::endl;
buffer.pop_front();//Skip event size
break;
} else if ( (buffer.front() & PFX_4_BIT_CONTENT_MASK) == PFX_END_OF_FRAME ){
} else if ( (buffer.front() & PFX_0_BIT_CONTENT_MASK) == PFX_END_OF_FRAME ){
//std::cout<<" END OF FRAME "<<std::endl;
buffer.pop_front();
break;
Expand Down
2 changes: 1 addition & 1 deletion daq/TRESTDAQFEMINOS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void TRESTDAQFEMINOS::ReceiveThread( std::vector<FEMProxy> *FEMA ) {
} else {
std::unique_lock<std::mutex> lock_mem(FEM.mutex_mem);
//const std::deque<uint16_t> frame (&buf_rcv[1], &buf_rcv[size -1]);
FEM.buffer.insert(FEM.buffer.end(), &buf_rcv[3], &buf_rcv[size -1]);//Skip 2 first words
FEM.buffer.insert(FEM.buffer.end(), &buf_rcv[1], &buf_rcv[size -1]);
int bufferSize = FEM.buffer.size();
lock_mem.unlock();
if (verboseLevel >= TRestStringOutput::REST_Verbose_Level::REST_Debug)
Expand Down
20 changes: 1 addition & 19 deletions daq/TRESTDAQFEMINOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,11 @@ Based on mclient program from Denis Calvet
#define __TREST_DAQ_FEMINOS__

#include "TRESTDAQ.h"
#include "TRESTDAQSocket.h"
#include "FEMProxy.h"

#include <iostream>
#include <thread>
#include <memory>
#include <deque>

class FEMProxy : public TRESTDAQSocket {

public:
FEMProxy(){ }
bool pendingEvent=false;
TRestRawDAQMetadata::FECMetadata fecMetadata;
//std::atomic_int
int cmd_sent=0;
//std::atomic_int
int cmd_rcv=0;

std::deque <uint16_t> buffer;

inline static std::mutex mutex_socket;
inline static std::mutex mutex_mem;
};

class TRESTDAQFEMINOS : public TRESTDAQ {
public:
Expand Down
3 changes: 3 additions & 0 deletions daq/TRESTDAQManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Control data acquisition via shared memory, should be always running
#include "TRESTDAQDCC.h"
#include "TRESTDAQDummy.h"
#include "TRESTDAQFEMINOS.h"
#include "TRESTDAQARC.h"

TRESTDAQManager::TRESTDAQManager() {
int shmid;
Expand Down Expand Up @@ -88,6 +89,8 @@ std::unique_ptr<TRESTDAQ> TRESTDAQManager::GetTRESTDAQ (TRestRun* rR, TRestRawDA
daq = std::make_unique<TRESTDAQDCC>(rR, dM);
} else if (eT->second == daq_metadata_types::electronicsTypes::FEMINOS) {
daq = std::make_unique<TRESTDAQFEMINOS>(rR, dM);
} else if (eT->second == daq_metadata_types::electronicsTypes::ARC) {
daq = std::make_unique<TRESTDAQARC>(rR, dM);
} else {
std::cout << electronicsType << " not implemented, skipping..." << std::endl;
}
Expand Down

0 comments on commit 218c78b

Please sign in to comment.