From 7c4fb6740a5cd493399268c488d0ee906c7cb663 Mon Sep 17 00:00:00 2001 From: juanan Date: Tue, 13 Jul 2021 17:46:42 +0200 Subject: [PATCH 01/33] Changes for novel restDAQ package --- inc/TRestRawDAQMetadata.h | 40 ++++++------ inc/TRestRawSignal.h | 1 + src/TRestRawDAQMetadata.cxx | 124 ++++++++---------------------------- src/TRestRawSignal.cxx | 4 ++ 4 files changed, 55 insertions(+), 114 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 43393517..ffffafa5 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -36,21 +36,21 @@ class TRestRawDAQMetadata : public TRestMetadata { virtual void Initialize(); protected: - TString fOutBinFileName; - TString fElectronicsType; - std::vector fPedBuffer; // Pedestal script - std::vector fRunBuffer; // Run script - TString fNamePedScript; // Name of the run script e.g. /home/user/scripts/run - TString fNameRunScript; // Name of the pedestal script e.g. - // /home/user/scripts/ped - UInt_t fGain; // Value of the gain in the script you have to convert it to fC - UInt_t fShappingTime; // Value of the shapping time in the script you have to - // convert it to nS + TString fElectronicsType; // DCC, FEMINOS, ARC, ... + + UInt_t fFECMask; // FEC Mask + UInt_t fGain; // Gain in the AFTER/AGET chip + UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip + UInt_t fClockDiv; // Clock division + Int_t fBaseIp[4] = {192, 168,10,13}; //Base IP of the card + TString fTriggerType; // external or internal + TString fAcquisitionType; // pedestal, calibration or background + UInt_t fCompressMode =0; // 0 uncompressed, 1 compress + UInt_t fNEvents=0; // 0 --> Infinite public: - void PrintMetadata(); - void PrintRunScript(); - void PrintPedScript(); + virtual void PrintMetadata(); + void ReadBaseIp(); // Construtor TRestRawDAQMetadata(); @@ -58,14 +58,18 @@ class TRestRawDAQMetadata : public TRestMetadata { // Destructor virtual ~TRestRawDAQMetadata(); - void SetScriptsBuffer(); - void SetParFromPedBuffer(); // Set gain and shapping time from a given buffer - void SetOutBinFileName(TString fName) { fOutBinFileName = fName; } - + UInt_t GetFECMask() { return fFECMask; } UInt_t GetGain() { return fGain; } UInt_t GetShappingTime() { return fShappingTime; } + UInt_t GetClockDiv() { return fClockDiv; } + TString GetTriggerType() { return fTriggerType; } + TString GetAcquisitionType() { return fAcquisitionType; } + UInt_t GetNEvents() { return fNEvents; } + Int_t* GetBaseIp() { return fBaseIp; } + UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress + UInt_t GetValFromString(TString var, TString line); - ClassDef(TRestRawDAQMetadata, 1); // REST run class + ClassDef(TRestRawDAQMetadata, 2); // REST run class }; #endif diff --git a/inc/TRestRawSignal.h b/inc/TRestRawSignal.h index 05f4d36a..7cf66c7a 100644 --- a/inc/TRestRawSignal.h +++ b/inc/TRestRawSignal.h @@ -216,6 +216,7 @@ class TRestRawSignal : public TObject { TRestRawSignal(); TRestRawSignal(Int_t nBins); + TRestRawSignal(Int_t sID, std::vector &sData); ~TRestRawSignal(); ClassDef(TRestRawSignal, 1); diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 088276e3..9206fb64 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -68,9 +68,6 @@ TRestRawDAQMetadata::TRestRawDAQMetadata(char* cfgFileName) : TRestMetadata(cfgF Initialize(); LoadConfigFromFile(fConfigFileName); - - SetScriptsBuffer(); - SetParFromPedBuffer(); } void TRestRawDAQMetadata::Initialize() { @@ -79,115 +76,50 @@ void TRestRawDAQMetadata::Initialize() { } //______________________________________________________________________________ -TRestRawDAQMetadata::~TRestRawDAQMetadata() { cout << "Deleting TRestRawDAQMetadata" << endl; } +TRestRawDAQMetadata::~TRestRawDAQMetadata() { + + } //______________________________________________________________________________ void TRestRawDAQMetadata::InitFromConfigFile() { // string daqString; - fNamePedScript = GetParameter("pedScript"); - if (fNamePedScript == "") { - cout << "Pedestal script " << endl; - } + fElectronicsType = GetParameter("electronics"); + fFECMask = StringToInteger( GetParameter("fecMask") ); + fGain = StringToInteger( GetParameter("chipGain") ); + fShappingTime = StringToInteger( GetParameter("chipShappingTime") ); + fClockDiv = StringToInteger( GetParameter("clockDiv") ); + fTriggerType = GetParameter("triggerType"); + fAcquisitionType = GetParameter("acquisitionType"); + fCompressMode = StringToInteger(GetParameter("compressMode")); + fNEvents = StringToInteger(GetParameter("Nevents")); + ReadBaseIp( ); + +} - fNameRunScript = GetParameter("runScript"); - if (fNameRunScript == "") { - cout << "Run script " << endl; - } +void TRestRawDAQMetadata::ReadBaseIp( ){ + + std::string ip = GetParameter("baseIp"); + sscanf(ip.c_str(),"%d.%d.%d.%d",&fBaseIp[3],&fBaseIp[2],&fBaseIp[1],&fBaseIp[0]); - fElectronicsType = GetParameter("electronics"); - if (fElectronicsType == "") { - cout << "electronic type not found " << endl; - } } void TRestRawDAQMetadata::PrintMetadata() { cout << endl; cout << "====================================" << endl; - cout << "DAQ : " << GetTitle() << endl; - cout << "Pedestal script : " << fNamePedScript.Data() << endl; - cout << "Run script : " << fNameRunScript.Data() << endl; - cout << "Electronics type : " << fElectronicsType.Data() << endl; - cout << "Gain : " << GetGain() << endl; - cout << "Shapping time : " << GetShappingTime() << endl; + cout << "Base IP : " << fBaseIp[0]<<"."<< fBaseIp[1]<<"."<< fBaseIp[2]<<"."<< fBaseIp[3]<< endl; + cout << "ElectronicsType : " << fElectronicsType.Data() << endl; + cout << "FEC mask : 0x"< &sData) : fSignalID(sID), fSignalData(sData) { + +} + /////////////////////////////////////////////// /// \brief Default destructor /// From 37cb816a68b624a15c26f57c10a36dc43ffae103 Mon Sep 17 00:00:00 2001 From: juanan Date: Thu, 29 Jul 2021 16:09:13 +0200 Subject: [PATCH 02/33] Adding enum and maps for different acquisition and electronics --- inc/TRestRawDAQMetadata.h | 46 +++++++++++++++++++++++++++---------- src/TRestRawDAQMetadata.cxx | 2 +- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index ffffafa5..77e263dd 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -28,6 +28,24 @@ #include "TRestMetadata.h" #include "TString.h" +namespace daq_metadata_types { + + enum class acqTypes : int { + BACKGROUND, + CALIBRATION, + PEDESTAL + }; + + enum class electronicsTypes : int { + DUMMY, + DCC + }; + + inline const std::map acqTypes_map = {{"background",acqTypes::BACKGROUND}, {"calibration",acqTypes::CALIBRATION},{"pedestal",acqTypes::PEDESTAL}}; + inline const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}}; + +} + //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { private: @@ -36,17 +54,17 @@ class TRestRawDAQMetadata : public TRestMetadata { virtual void Initialize(); protected: - TString fElectronicsType; // DCC, FEMINOS, ARC, ... + TString fElectronicsType; // DCC, FEMINOS, ARC, ... - UInt_t fFECMask; // FEC Mask - UInt_t fGain; // Gain in the AFTER/AGET chip - UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip - UInt_t fClockDiv; // Clock division + UInt_t fFECMask; // FEC Mask + UInt_t fGain; // Gain in the AFTER/AGET chip + UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip + UInt_t fClockDiv; // Clock division Int_t fBaseIp[4] = {192, 168,10,13}; //Base IP of the card - TString fTriggerType; // external or internal - TString fAcquisitionType; // pedestal, calibration or background + TString fTriggerType; // external or internal + TString fAcquisitionType; // pedestal, calibration or background UInt_t fCompressMode =0; // 0 uncompressed, 1 compress - UInt_t fNEvents=0; // 0 --> Infinite + Int_t fNEvents=0; // 0 --> Infinite public: virtual void PrintMetadata(); @@ -54,7 +72,7 @@ class TRestRawDAQMetadata : public TRestMetadata { // Construtor TRestRawDAQMetadata(); - TRestRawDAQMetadata(char* cfgFileName); + TRestRawDAQMetadata(const char* cfgFileName); // Destructor virtual ~TRestRawDAQMetadata(); @@ -64,11 +82,15 @@ class TRestRawDAQMetadata : public TRestMetadata { UInt_t GetClockDiv() { return fClockDiv; } TString GetTriggerType() { return fTriggerType; } TString GetAcquisitionType() { return fAcquisitionType; } - UInt_t GetNEvents() { return fNEvents; } + TString GetElectronicsType() { return fElectronicsType; } + Int_t GetNEvents() { return fNEvents; } Int_t* GetBaseIp() { return fBaseIp; } - UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress - + UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress UInt_t GetValFromString(TString var, TString line); + TString GetDecodingFile(){return GetParameter("decodingFile");} + + void SetAcquisitionType (const std::string &typ){fAcquisitionType = typ;} + void SetNEvents(const Int_t & nEv){fNEvents=nEv;} ClassDef(TRestRawDAQMetadata, 2); // REST run class }; diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 9206fb64..9e32c5ca 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -64,7 +64,7 @@ ClassImp(TRestRawDAQMetadata); //______________________________________________________________________________ TRestRawDAQMetadata::TRestRawDAQMetadata() { Initialize(); } -TRestRawDAQMetadata::TRestRawDAQMetadata(char* cfgFileName) : TRestMetadata(cfgFileName) { +TRestRawDAQMetadata::TRestRawDAQMetadata(const char* cfgFileName) : TRestMetadata(cfgFileName) { Initialize(); LoadConfigFromFile(fConfigFileName); From d50587dc7251336f34b2d61a96f23183fc8aad77 Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 30 Jul 2021 18:38:59 +0200 Subject: [PATCH 03/33] Fixing baseIP retreival from metadata, now baseIP uses double colon separation --- inc/TRestRawDAQMetadata.h | 2 +- src/TRestRawDAQMetadata.cxx | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 77e263dd..2bdbe693 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -60,7 +60,7 @@ class TRestRawDAQMetadata : public TRestMetadata { UInt_t fGain; // Gain in the AFTER/AGET chip UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip UInt_t fClockDiv; // Clock division - Int_t fBaseIp[4] = {192, 168,10,13}; //Base IP of the card + Int_t fBaseIp[4] = {192,168,10,13}; //Base IP of the card TString fTriggerType; // external or internal TString fAcquisitionType; // pedestal, calibration or background UInt_t fCompressMode =0; // 0 uncompressed, 1 compress diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 9e32c5ca..b2a69596 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -99,24 +99,25 @@ void TRestRawDAQMetadata::InitFromConfigFile() { void TRestRawDAQMetadata::ReadBaseIp( ){ - std::string ip = GetParameter("baseIp"); - sscanf(ip.c_str(),"%d.%d.%d.%d",&fBaseIp[3],&fBaseIp[2],&fBaseIp[1],&fBaseIp[0]); - + std::string ip = GetParameter("baseIp","192.168.10.13"); + sscanf(ip.c_str(),"%d:%d:%d:%d",&fBaseIp[0],&fBaseIp[1],&fBaseIp[2],&fBaseIp[3]); + std::cout<<"Base IP: "< "<ClassName() << " content" << endl; + metadata << "+++++++++++++++++++++++++++++++++++++++++++++" << endl; + metadata << "Base IP : " << fBaseIp[0]<<"."<< fBaseIp[1]<<"."<< fBaseIp[2]<<"."<< fBaseIp[3]<< endl; + metadata << "ElectronicsType : " << fElectronicsType.Data() << endl; + metadata << "FEC mask : 0x"< Date: Tue, 17 Aug 2021 12:01:24 +0200 Subject: [PATCH 04/33] Removing inline since docker image is not c++17 compatible --- inc/TRestRawDAQMetadata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 2bdbe693..0acc158e 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -41,8 +41,8 @@ namespace daq_metadata_types { DCC }; - inline const std::map acqTypes_map = {{"background",acqTypes::BACKGROUND}, {"calibration",acqTypes::CALIBRATION},{"pedestal",acqTypes::PEDESTAL}}; - inline const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}}; + const std::map acqTypes_map = {{"background",acqTypes::BACKGROUND}, {"calibration",acqTypes::CALIBRATION},{"pedestal",acqTypes::PEDESTAL}}; + const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}}; } From b14812e53335d6d8cfed01d9aded1e4c09bf04cd Mon Sep 17 00:00:00 2001 From: juanan Date: Mon, 23 Aug 2021 18:22:06 +0200 Subject: [PATCH 05/33] Adding fields for FEMINOS --- inc/TRestRawDAQMetadata.h | 25 +++++++++++++++++++------ src/TRestRawDAQMetadata.cxx | 15 ++++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 0acc158e..cf36098e 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -38,11 +38,19 @@ namespace daq_metadata_types { enum class electronicsTypes : int { DUMMY, - DCC + DCC, + FEMINOS + }; + + enum class chipTypes : int { + AFTER, + AGET }; const std::map acqTypes_map = {{"background",acqTypes::BACKGROUND}, {"calibration",acqTypes::CALIBRATION},{"pedestal",acqTypes::PEDESTAL}}; - const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}}; + const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}, {"FEMINOS",electronicsTypes::FEMINOS}}; + const std::map chipTypes_map = {{"after",chipTypes::AFTER}, {"aget",chipTypes::AGET}}; + } @@ -55,20 +63,22 @@ class TRestRawDAQMetadata : public TRestMetadata { protected: TString fElectronicsType; // DCC, FEMINOS, ARC, ... - + TString fChipType; // after or aget UInt_t fFECMask; // FEC Mask UInt_t fGain; // Gain in the AFTER/AGET chip UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip UInt_t fClockDiv; // Clock division Int_t fBaseIp[4] = {192,168,10,13}; //Base IP of the card + Int_t fLocalIp[4] = {192,168,10,10}; //Local IP of the host computer TString fTriggerType; // external or internal TString fAcquisitionType; // pedestal, calibration or background UInt_t fCompressMode =0; // 0 uncompressed, 1 compress - Int_t fNEvents=0; // 0 --> Infinite + Int_t fNEvents=0; // 0 --> Infinite + Int_t fPolarity =0; // 0--> negative, 1 positive public: virtual void PrintMetadata(); - void ReadBaseIp(); + void ReadIp(const std::string ¶m, Int_t *ip ); // Construtor TRestRawDAQMetadata(); @@ -83,9 +93,12 @@ class TRestRawDAQMetadata : public TRestMetadata { TString GetTriggerType() { return fTriggerType; } TString GetAcquisitionType() { return fAcquisitionType; } TString GetElectronicsType() { return fElectronicsType; } + TString GetChipType() { return fChipType; } Int_t GetNEvents() { return fNEvents; } Int_t* GetBaseIp() { return fBaseIp; } - UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress + Int_t* GetLocalIp() { return fLocalIp; } + UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress + UInt_t GetPolarity(){return fPolarity;} UInt_t GetValFromString(TString var, TString line); TString GetDecodingFile(){return GetParameter("decodingFile");} diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index b2a69596..5dac4a1b 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -85,6 +85,7 @@ void TRestRawDAQMetadata::InitFromConfigFile() { // string daqString; fElectronicsType = GetParameter("electronics"); + fElectronicsType = GetParameter("chip"); fFECMask = StringToInteger( GetParameter("fecMask") ); fGain = StringToInteger( GetParameter("chipGain") ); fShappingTime = StringToInteger( GetParameter("chipShappingTime") ); @@ -92,16 +93,18 @@ void TRestRawDAQMetadata::InitFromConfigFile() { fTriggerType = GetParameter("triggerType"); fAcquisitionType = GetParameter("acquisitionType"); fCompressMode = StringToInteger(GetParameter("compressMode")); + fPolarity = StringToInteger(GetParameter("polarity")); fNEvents = StringToInteger(GetParameter("Nevents")); - ReadBaseIp( ); + ReadIp("baseIp",fBaseIp); + ReadIp("localIp",fLocalIp); } -void TRestRawDAQMetadata::ReadBaseIp( ){ +void TRestRawDAQMetadata::ReadIp(const std::string ¶m, Int_t *ip ){ - std::string ip = GetParameter("baseIp","192.168.10.13"); - sscanf(ip.c_str(),"%d:%d:%d:%d",&fBaseIp[0],&fBaseIp[1],&fBaseIp[2],&fBaseIp[3]); - std::cout<<"Base IP: "< "< "<ClassName() << " content" << endl; metadata << "+++++++++++++++++++++++++++++++++++++++++++++" << endl; metadata << "Base IP : " << fBaseIp[0]<<"."<< fBaseIp[1]<<"."<< fBaseIp[2]<<"."<< fBaseIp[3]<< endl; + metadata << "Local IP : " << fLocalIp[0]<<"."<< fLocalIp[1]<<"."<< fLocalIp[2]<<"."<< fLocalIp[3]<< endl; metadata << "ElectronicsType : " << fElectronicsType.Data() << endl; + metadata << "ChipType : " << fChipType.Data() << endl; metadata << "FEC mask : 0x"< Date: Tue, 24 Aug 2021 10:05:17 +0200 Subject: [PATCH 06/33] Bug fix --- src/TRestRawDAQMetadata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 5dac4a1b..6e5e3005 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -85,7 +85,7 @@ void TRestRawDAQMetadata::InitFromConfigFile() { // string daqString; fElectronicsType = GetParameter("electronics"); - fElectronicsType = GetParameter("chip"); + fChipType = GetParameter("chip"); fFECMask = StringToInteger( GetParameter("fecMask") ); fGain = StringToInteger( GetParameter("chipGain") ); fShappingTime = StringToInteger( GetParameter("chipShappingTime") ); From f72ca0589b83d5f5d577d56018be5d9b28017736 Mon Sep 17 00:00:00 2001 From: juanan Date: Wed, 25 Aug 2021 18:18:57 +0200 Subject: [PATCH 07/33] New containers for FEC and ASIC metadata --- inc/ASICMetadata.h | 20 ++++++++++++++++++++ inc/FECMetadata.h | 22 ++++++++++++++++++++++ src/ASICMetadata.cxx | 10 ++++++++++ src/FECMetadata.cxx | 12 ++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 inc/ASICMetadata.h create mode 100644 inc/FECMetadata.h create mode 100644 src/ASICMetadata.cxx create mode 100644 src/FECMetadata.cxx diff --git a/inc/ASICMetadata.h b/inc/ASICMetadata.h new file mode 100644 index 00000000..a784d9fa --- /dev/null +++ b/inc/ASICMetadata.h @@ -0,0 +1,20 @@ + +#include +#include + +class ASICMetadata { + public: + UShort_t polarity; + UShort_t pedCenter; + Float_t pedThr; + UShort_t gain; + UShort_t shappingTime; + UShort_t channelStart; + UShort_t channelEnd; + Bool_t isActive; + Bool_t channelActive[79]; + + ASICMetadata(); + ClassDef(ASICMetadata,1); +}; + diff --git a/inc/FECMetadata.h b/inc/FECMetadata.h new file mode 100644 index 00000000..d5be20c3 --- /dev/null +++ b/inc/FECMetadata.h @@ -0,0 +1,22 @@ + +#include "ASICMetadata.h" +#include "TString.h" +#include + +class FECMetadata { + public: + Int_t id; + Int_t ip[4]; + UShort_t clockDiv; + TString chipType; + ASICMetadata asic[4]; + + FECMetadata(); + + bool operator < (const FECMetadata &fM) const { + return id < fM.id; + } + + ClassDef(FECMetadata,1); +}; + diff --git a/src/ASICMetadata.cxx b/src/ASICMetadata.cxx new file mode 100644 index 00000000..c573ebec --- /dev/null +++ b/src/ASICMetadata.cxx @@ -0,0 +1,10 @@ + + +#include "ASICMetadata.h" + +ClassImp(ASICMetadata); + +ASICMetadata::ASICMetadata(){ + +} + diff --git a/src/FECMetadata.cxx b/src/FECMetadata.cxx new file mode 100644 index 00000000..18d5ac94 --- /dev/null +++ b/src/FECMetadata.cxx @@ -0,0 +1,12 @@ + + +#include "FECMetadata.h" + + +ClassImp(FECMetadata); + +FECMetadata::FECMetadata(){ + +} + + From 36b178c0bbea17c0d9ee9a633d0adafe1ffd8967 Mon Sep 17 00:00:00 2001 From: juanan Date: Wed, 25 Aug 2021 18:21:38 +0200 Subject: [PATCH 08/33] Adding new metadata for single FECs and ASICs --- inc/TRestRawDAQMetadata.h | 15 ++--- src/TRestRawDAQMetadata.cxx | 129 +++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 18 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index cf36098e..5daca3bf 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -26,6 +26,7 @@ #include #include "TRestMetadata.h" +#include "FECMetadata.h" #include "TString.h" namespace daq_metadata_types { @@ -64,9 +65,6 @@ class TRestRawDAQMetadata : public TRestMetadata { protected: TString fElectronicsType; // DCC, FEMINOS, ARC, ... TString fChipType; // after or aget - UInt_t fFECMask; // FEC Mask - UInt_t fGain; // Gain in the AFTER/AGET chip - UInt_t fShappingTime; // Shapping time in the AFTER/AGET chip UInt_t fClockDiv; // Clock division Int_t fBaseIp[4] = {192,168,10,13}; //Base IP of the card Int_t fLocalIp[4] = {192,168,10,10}; //Local IP of the host computer @@ -74,9 +72,10 @@ class TRestRawDAQMetadata : public TRestMetadata { TString fAcquisitionType; // pedestal, calibration or background UInt_t fCompressMode =0; // 0 uncompressed, 1 compress Int_t fNEvents=0; // 0 --> Infinite - Int_t fPolarity =0; // 0--> negative, 1 positive + std::vector fFEC; //Vector of FECs with different info public: + virtual void PrintMetadata(); void ReadIp(const std::string ¶m, Int_t *ip ); @@ -86,9 +85,6 @@ class TRestRawDAQMetadata : public TRestMetadata { // Destructor virtual ~TRestRawDAQMetadata(); - UInt_t GetFECMask() { return fFECMask; } - UInt_t GetGain() { return fGain; } - UInt_t GetShappingTime() { return fShappingTime; } UInt_t GetClockDiv() { return fClockDiv; } TString GetTriggerType() { return fTriggerType; } TString GetAcquisitionType() { return fAcquisitionType; } @@ -98,13 +94,16 @@ class TRestRawDAQMetadata : public TRestMetadata { Int_t* GetBaseIp() { return fBaseIp; } Int_t* GetLocalIp() { return fLocalIp; } UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress - UInt_t GetPolarity(){return fPolarity;} UInt_t GetValFromString(TString var, TString line); TString GetDecodingFile(){return GetParameter("decodingFile");} + std::vector GetFECs(){return fFEC;}; void SetAcquisitionType (const std::string &typ){fAcquisitionType = typ;} void SetNEvents(const Int_t & nEv){fNEvents=nEv;} + void ReadFEC(); + void DumpFEC(const FECMetadata &fec); + ClassDef(TRestRawDAQMetadata, 2); // REST run class }; #endif diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 6e5e3005..0220a319 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -86,25 +86,21 @@ void TRestRawDAQMetadata::InitFromConfigFile() { fElectronicsType = GetParameter("electronics"); fChipType = GetParameter("chip"); - fFECMask = StringToInteger( GetParameter("fecMask") ); - fGain = StringToInteger( GetParameter("chipGain") ); - fShappingTime = StringToInteger( GetParameter("chipShappingTime") ); fClockDiv = StringToInteger( GetParameter("clockDiv") ); fTriggerType = GetParameter("triggerType"); fAcquisitionType = GetParameter("acquisitionType"); fCompressMode = StringToInteger(GetParameter("compressMode")); - fPolarity = StringToInteger(GetParameter("polarity")); fNEvents = StringToInteger(GetParameter("Nevents")); ReadIp("baseIp",fBaseIp); ReadIp("localIp",fLocalIp); - + ReadFEC(); } void TRestRawDAQMetadata::ReadIp(const std::string ¶m, Int_t *ip ){ std::string ipString = GetParameter(param); sscanf(ipString.c_str(),"%d:%d:%d:%d",&ip[0],&ip[1],&ip[2],&ip[3]); - std::cout< "< "<0 && c%10 == 0)metadata< Date: Mon, 30 May 2022 11:02:17 +0200 Subject: [PATCH 09/33] Removal of ASICMetadata, not asic parameters are implemented inside FECMetadata --- inc/ASICMetadata.h | 20 --------------- inc/FECMetadata.h | 16 +++++++++--- inc/TRestRawDAQMetadata.h | 2 +- src/ASICMetadata.cxx | 10 -------- src/TRestRawDAQMetadata.cxx | 50 ++++++++++++++++++------------------- 5 files changed, 39 insertions(+), 59 deletions(-) delete mode 100644 inc/ASICMetadata.h delete mode 100644 src/ASICMetadata.cxx diff --git a/inc/ASICMetadata.h b/inc/ASICMetadata.h deleted file mode 100644 index a784d9fa..00000000 --- a/inc/ASICMetadata.h +++ /dev/null @@ -1,20 +0,0 @@ - -#include -#include - -class ASICMetadata { - public: - UShort_t polarity; - UShort_t pedCenter; - Float_t pedThr; - UShort_t gain; - UShort_t shappingTime; - UShort_t channelStart; - UShort_t channelEnd; - Bool_t isActive; - Bool_t channelActive[79]; - - ASICMetadata(); - ClassDef(ASICMetadata,1); -}; - diff --git a/inc/FECMetadata.h b/inc/FECMetadata.h index d5be20c3..87fda3df 100644 --- a/inc/FECMetadata.h +++ b/inc/FECMetadata.h @@ -1,7 +1,8 @@ -#include "ASICMetadata.h" +#ifndef RestCore_FECMetadata +#define RestCore_FECMetadata + #include "TString.h" -#include class FECMetadata { public: @@ -9,7 +10,15 @@ class FECMetadata { Int_t ip[4]; UShort_t clockDiv; TString chipType; - ASICMetadata asic[4]; + UShort_t asic_polarity[4]; + UShort_t asic_pedCenter[4]; + Float_t asic_pedThr[4]; + UShort_t asic_gain[4]; + UShort_t asic_shappingTime[4]; + UShort_t asic_channelStart[4]; + UShort_t asic_channelEnd[4]; + Bool_t asic_isActive[4]; + Bool_t asic_channelActive[4][79]; FECMetadata(); @@ -20,3 +29,4 @@ class FECMetadata { ClassDef(FECMetadata,1); }; +#endif diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 5daca3bf..321eb99d 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -96,7 +96,7 @@ class TRestRawDAQMetadata : public TRestMetadata { UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress UInt_t GetValFromString(TString var, TString line); TString GetDecodingFile(){return GetParameter("decodingFile");} - std::vector GetFECs(){return fFEC;}; + std::vector GetFECs(){return fFEC;} void SetAcquisitionType (const std::string &typ){fAcquisitionType = typ;} void SetNEvents(const Int_t & nEv){fNEvents=nEv;} diff --git a/src/ASICMetadata.cxx b/src/ASICMetadata.cxx deleted file mode 100644 index c573ebec..00000000 --- a/src/ASICMetadata.cxx +++ /dev/null @@ -1,10 +0,0 @@ - - -#include "ASICMetadata.h" - -ClassImp(ASICMetadata); - -ASICMetadata::ASICMetadata(){ - -} - diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 0220a319..77bf9f17 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -163,39 +163,39 @@ void TRestRawDAQMetadata::ReadFEC(){ if(id=="*"){//Wildcard for(int i=0;i<4;i++){ - fec.asic[i].gain = gain; - fec.asic[i].shappingTime = shappingTime; - fec.asic[i].isActive = asicActive; - fec.asic[i].polarity = polarity; - fec.asic[i].pedCenter = pedCenter; - fec.asic[i].pedThr = pedThr; + fec.asic_gain[i] = gain; + fec.asic_shappingTime[i] = shappingTime; + fec.asic_isActive[i] = asicActive; + fec.asic_polarity[i] = polarity; + fec.asic_pedCenter[i] = pedCenter; + fec.asic_pedThr[i] = pedThr; bool isFirst = true; for(int c=0;c<79;c++){ - fec.asic[i].channelActive[c]=channelActive[c]; + fec.asic_channelActive[i][c]=channelActive[c]; if(channelActive[c] && isFirst){ - fec.asic[i].channelStart = c; + fec.asic_channelStart[i] = c; isFirst=false; } - if(channelActive[c])fec.asic[i].channelEnd = c; + if(channelActive[c])fec.asic_channelEnd[i] = c; } } } else { int i= StringToInteger(id); if(i<4){ - fec.asic[i].gain = gain; - fec.asic[i].shappingTime = shappingTime; - fec.asic[i].isActive = asicActive; - fec.asic[i].polarity = polarity; - fec.asic[i].pedCenter = pedCenter; - fec.asic[i].pedThr = pedThr; + fec.asic_gain[i] = gain; + fec.asic_shappingTime[i] = shappingTime; + fec.asic_isActive[i] = asicActive; + fec.asic_polarity[i] = polarity; + fec.asic_pedCenter[i] = pedCenter; + fec.asic_pedThr[i] = pedThr; bool isFirst = true; for(int c=0;c<79;c++){ - fec.asic[i].channelActive[c]=channelActive[c]; + fec.asic_channelActive[i][c]=channelActive[c]; if(channelActive[c] && isFirst){ - fec.asic[i].channelStart = c; + fec.asic_channelStart[i] = c; isFirst=false; } - if(channelActive[c])fec.asic[i].channelEnd = c; + if(channelActive[c])fec.asic_channelEnd[i] = c; } } } @@ -219,17 +219,17 @@ void TRestRawDAQMetadata::DumpFEC(const FECMetadata &fec){ metadata << "Chip type: "<0 && c%10 == 0)metadata< Date: Thu, 2 Jun 2022 18:54:33 +0200 Subject: [PATCH 10/33] TRESTDAQMetadata updating documentation --- inc/TRestRawDAQMetadata.h | 68 ++++----- src/TRestRawDAQMetadata.cxx | 297 +++++++++++++++++++----------------- 2 files changed, 190 insertions(+), 175 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index ab30adee..723e697d 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -25,35 +25,28 @@ #include -#include "TRestMetadata.h" #include "FECMetadata.h" +#include "TRestMetadata.h" #include "TString.h" namespace daq_metadata_types { - enum class acqTypes : int { - BACKGROUND, - CALIBRATION, - PEDESTAL - }; - - enum class electronicsTypes : int { - DUMMY, - DCC, - FEMINOS - }; +enum class acqTypes : int { BACKGROUND, CALIBRATION, PEDESTAL }; - enum class chipTypes : int { - AFTER, - AGET - }; +enum class electronicsTypes : int { DUMMY, DCC, FEMINOS }; - const std::map acqTypes_map = {{"background",acqTypes::BACKGROUND}, {"calibration",acqTypes::CALIBRATION},{"pedestal",acqTypes::PEDESTAL}}; - const std::map electronicsTypes_map = {{"DUMMY",electronicsTypes::DUMMY}, {"DCC",electronicsTypes::DCC}, {"FEMINOS",electronicsTypes::FEMINOS}}; - const std::map chipTypes_map = {{"after",chipTypes::AFTER}, {"aget",chipTypes::AGET}}; +enum class chipTypes : int { AFTER, AGET }; +const std::map acqTypes_map = {{"background", acqTypes::BACKGROUND}, + {"calibration", acqTypes::CALIBRATION}, + {"pedestal", acqTypes::PEDESTAL}}; +const std::map electronicsTypes_map = {{"DUMMY", electronicsTypes::DUMMY}, + {"DCC", electronicsTypes::DCC}, + {"FEMINOS", electronicsTypes::FEMINOS}}; +const std::map chipTypes_map = {{"after", chipTypes::AFTER}, + {"aget", chipTypes::AGET}}; -} +} // namespace daq_metadata_types //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { @@ -63,21 +56,20 @@ class TRestRawDAQMetadata : public TRestMetadata { void Initialize() override; protected: - TString fElectronicsType; // DCC, FEMINOS, ARC, ... - TString fChipType; // after or aget - UInt_t fClockDiv; // Clock division - Int_t fBaseIp[4] = {192,168,10,13}; //Base IP of the card - Int_t fLocalIp[4] = {192,168,10,10}; //Local IP of the host computer - TString fTriggerType; // external or internal - TString fAcquisitionType; // pedestal, calibration or background - UInt_t fCompressMode =0; // 0 uncompressed, 1 compress - Int_t fNEvents=0; // 0 --> Infinite - std::vector fFEC; //Vector of FECs with different info + TString fElectronicsType; // DCC, FEMINOS, ARC, ... + TString fChipType; // after or aget + UInt_t fClockDiv; // Clock division + Int_t fBaseIp[4] = {192, 168, 10, 13}; // Base IP of the card + Int_t fLocalIp[4] = {192, 168, 10, 10}; // Local IP of the host computer + TString fTriggerType; // external or internal + TString fAcquisitionType; // pedestal, calibration or background + UInt_t fCompressMode = 0; // 0 uncompressed, 1 compress + Int_t fNEvents = 0; // 0 --> Infinite + std::vector fFEC; // Vector of FECs with different info public: - void PrintMetadata() override; - void ReadIp(const std::string ¶m, Int_t *ip ); + void ReadIp(const std::string& param, Int_t* ip); // Constructor TRestRawDAQMetadata(); @@ -93,15 +85,15 @@ class TRestRawDAQMetadata : public TRestMetadata { Int_t GetNEvents() { return fNEvents; } Int_t* GetBaseIp() { return fBaseIp; } Int_t* GetLocalIp() { return fLocalIp; } - UInt_t GetCompressMode(){return fCompressMode;} // 0 uncompressed, 1 compress - TString GetDecodingFile(){return GetParameter("decodingFile");} - std::vector GetFECs(){return fFEC;} + UInt_t GetCompressMode() { return fCompressMode; } // 0 uncompressed, 1 compress + TString GetDecodingFile() { return GetParameter("decodingFile"); } + std::vector GetFECs() { return fFEC; } - void SetAcquisitionType (const std::string &typ){fAcquisitionType = typ;} - void SetNEvents(const Int_t & nEv){fNEvents=nEv;} + void SetAcquisitionType(const std::string& typ) { fAcquisitionType = typ; } + void SetNEvents(const Int_t& nEv) { fNEvents = nEv; } void ReadFEC(); - void DumpFEC(const FECMetadata &fec); + void DumpFEC(const FECMetadata& fec); ClassDefOverride(TRestRawDAQMetadata, 2); // REST run class }; diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index bf99db2e..a668e548 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -21,39 +21,67 @@ *************************************************************************/ ////////////////////////////////////////////////////////////////////////// -/// The TRestRawDaqMetadata ... +/// TRestRawDAQMetadata class is meant to hold DAQ information which is +/// stored in the root files generated using `restDAQ` package. It contains +/// information about the readout type DCC, FEMINOS,... and the different +/// parameters of the readout electronics (FEC, FEM, AGET, AFTER,...). Note +/// that the DAQ is under development, so further changes on this class are +/// foreseen: /// -/// TODO. This class might be obsolete today. It may need additional revision, -/// validation, and documentation. +/// ### Parameters +/// Describe any parameters this process receives: +/// * **electronicsType**: DAQ electronics type, only DCC and FEMINOS are +/// supported so far. +/// * **chipType**: ASIC type, only AGET and AFTER are supported so far +/// * **clockDiv**: Clock division in the FEM +/// * **baseIp**: IP address of the electronics +/// * **localIp**: IP address of the local host (DAQ computer) +/// * **triggerType**: external or internal so far +/// * **acquisitionType**: Type of acquisition: pedestal, calibration or +/// background +/// * **compressMode**: 0 uncompressed, 1 compress (zero suppression) +/// * **nEvents**: Number of events to be acquired (0 for infinite loop) +/// It also includes `FECMetadata` section (see example) /// -///
-/// -/// \warning **⚠ REST is under continous development.** This -/// documentation -/// is offered to you by the REST community. Your HELP is needed to keep this -/// code -/// up to date. Your feedback will be worth to support this software, please -/// report -/// any problems/suggestions you may find while using it at [The REST Framework -/// forum](http://ezpc10.unizar.es). You are welcome to contribute fixing typos, -/// updating -/// information or adding/proposing new contributions. See also our -/// Contribution -/// Guide. +/// ### Examples +/// Give examples of usage and RML descriptions that can be tested. +/// \code +/// +/// +/// +/// +/// +/// +/// +/// +/// /// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \endcode /// -///-------------------------------------------------------------------------- +///---------------------------------------------------------------------- /// -/// RESTsoft - Software for Rare Event Searches with TPCs +/// REST-for-Physics - Software for Rare Event Searches Toolkit /// /// History of developments: /// /// 2015-Nov: First implementation as part of the conceptualization of existing -/// REST software. -/// Juanan Garcia +/// REST software. +/// JuanAn Garcia /// -/// \class TRestRawDAQMetadata -/// \author Juanan Garcia +/// 2021-2022: New implementation for restDAQ package +/// JuanAn Garcia +/// +/// \class TRestRawDAQMetadata +/// \author: Juanan Garcia e-mail: juanangp@unizar.es /// ///
/// @@ -75,162 +103,157 @@ void TRestRawDAQMetadata::Initialize() { SetLibraryVersion(LIBRARY_VERSION); } -TRestRawDAQMetadata::~TRestRawDAQMetadata() { } +TRestRawDAQMetadata::~TRestRawDAQMetadata() {} void TRestRawDAQMetadata::InitFromConfigFile() { // string daqString; fElectronicsType = GetParameter("electronics"); fChipType = GetParameter("chip"); - fClockDiv = StringToInteger( GetParameter("clockDiv") ); + fClockDiv = StringToInteger(GetParameter("clockDiv")); fTriggerType = GetParameter("triggerType"); fAcquisitionType = GetParameter("acquisitionType"); fCompressMode = StringToInteger(GetParameter("compressMode")); fNEvents = StringToInteger(GetParameter("Nevents")); - ReadIp("baseIp",fBaseIp); - ReadIp("localIp",fLocalIp); + ReadIp("baseIp", fBaseIp); + ReadIp("localIp", fLocalIp); ReadFEC(); } -void TRestRawDAQMetadata::ReadIp(const std::string ¶m, Int_t *ip ){ - - std::string ipString = GetParameter(param); - sscanf(ipString.c_str(),"%d:%d:%d:%d",&ip[0],&ip[1],&ip[2],&ip[3]); - //std::cout< "< "<ClassName() << " content" << RESTendl; RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; - RESTMetadata << "Base IP : " << fBaseIp[0]<<"."<< fBaseIp[1]<<"."<< fBaseIp[2]<<"."<< fBaseIp[3]<< RESTendl; - RESTMetadata << "Local IP : " << fLocalIp[0]<<"."<< fLocalIp[1]<<"."<< fLocalIp[2]<<"."<< fLocalIp[3]<< RESTendl; + RESTMetadata << "Base IP : " << fBaseIp[0] << "." << fBaseIp[1] << "." << fBaseIp[2] << "." << fBaseIp[3] + << RESTendl; + RESTMetadata << "Local IP : " << fLocalIp[0] << "." << fLocalIp[1] << "." << fLocalIp[2] << "." + << fLocalIp[3] << RESTendl; RESTMetadata << "ElectronicsType : " << fElectronicsType.Data() << RESTendl; - RESTMetadata << "Clock div : 0x" <0 && c%10 == 0) RESTMetadata<< RESTendl; - } - RESTMetadata<< RESTendl; - } + RESTMetadata << "ASIC " << i << RESTendl; + RESTMetadata << "Polarity: " << fec.asic_polarity[i] << RESTendl; + RESTMetadata << "Gain: 0x" << std::hex << fec.asic_gain[i] << std::dec << RESTendl; + RESTMetadata << "ShappingTime: 0x" << std::hex << fec.asic_shappingTime[i] << std::dec << RESTendl; + RESTMetadata << "Channel start: " << fec.asic_channelStart[i] << RESTendl; + RESTMetadata << "Channel end: " << fec.asic_channelEnd[i] << RESTendl; + RESTMetadata << "Active channels: " << RESTendl; + for (int c = 0; c < 79; c++) { + if (fec.asic_channelActive[c]) RESTMetadata << c << "; "; + if (c > 0 && c % 10 == 0) RESTMetadata << RESTendl; + } + RESTMetadata << RESTendl; + } RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; - } - From 42ba207ff3793b549ec86230dbee4ea39a5057b6 Mon Sep 17 00:00:00 2001 From: juanan Date: Thu, 2 Jun 2022 18:55:59 +0200 Subject: [PATCH 11/33] New method added for a fast retreival of the pulse amplitude after baseline substraction --- inc/TRestRawSignal.h | 4 ++- src/TRestRawSignal.cxx | 56 ++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/inc/TRestRawSignal.h b/inc/TRestRawSignal.h index 64962351..3d6859c5 100644 --- a/inc/TRestRawSignal.h +++ b/inc/TRestRawSignal.h @@ -219,6 +219,8 @@ class TRestRawSignal : public TObject { void Scale(Double_t value); + double GetAmplitudeFast(const TVector2& baselineRange, double signalThreshold); + void WriteSignalToTextFile(const TString& filename); void Print() const; @@ -227,7 +229,7 @@ class TRestRawSignal : public TObject { TRestRawSignal(); TRestRawSignal(Int_t nBins); - TRestRawSignal(Int_t sID, std::vector &sData); + TRestRawSignal(Int_t sID, std::vector& sData); ~TRestRawSignal(); ClassDef(TRestRawSignal, 1); diff --git a/src/TRestRawSignal.cxx b/src/TRestRawSignal.cxx index 4496cb9d..88a7f596 100644 --- a/src/TRestRawSignal.cxx +++ b/src/TRestRawSignal.cxx @@ -90,9 +90,7 @@ TRestRawSignal::TRestRawSignal(Int_t nBins) { fSignalData.resize(nBins, 0); } -TRestRawSignal::TRestRawSignal(Int_t sID, std::vector &sData) : fSignalID(sID), fSignalData(sData) { - -} +TRestRawSignal::TRestRawSignal(Int_t sID, std::vector& sData) : fSignalID(sID), fSignalData(sData) {} /////////////////////////////////////////////// /// \brief Default destructor @@ -633,16 +631,15 @@ void TRestRawSignal::GetSignalSmoothed(TRestRawSignal* smoothedSignal, Int_t ave /// \param averagingPoints It defines the number of neightbour consecutive /// points used to average the signal /// -/// \param option If the option is set to "EXCLUDE OUTLIERS", points that are too far away from the median baseline will be ignored to improve the smoothing result +/// \param option If the option is set to "EXCLUDE OUTLIERS", points that are too far away from the median +/// baseline will be ignored to improve the smoothing result /// std::vector TRestRawSignal::GetSignalSmoothed(Int_t averagingPoints, std::string option) { - std::vector result; - if (option == ""){ - + if (option == "") { result.resize(GetNumberOfPoints()); - + averagingPoints = (averagingPoints / 2) * 2 + 1; // make it odd >= averagingPoints Float_t sumAvg = (Float_t)GetIntegralInRange(0, averagingPoints) / averagingPoints; @@ -657,7 +654,7 @@ std::vector TRestRawSignal::GetSignalSmoothed(Int_t averagingPoints, st for (int i = GetNumberOfPoints() - averagingPoints / 2; i < GetNumberOfPoints(); i++) result[i] = sumAvg; - } else if (ToUpper(option) == "EXCLUDE OUTLIERS"){ + } else if (ToUpper(option) == "EXCLUDE OUTLIERS") { result = GetSignalSmoothed_ExcludeOutliers(averagingPoints); } else { cout << "TRestRawSignal::GetSignalSmoothed. Error! No such option!" << endl; @@ -666,14 +663,15 @@ std::vector TRestRawSignal::GetSignalSmoothed(Int_t averagingPoints, st } /////////////////////////////////////////////// -/// \brief It smoothes the existing signal and returns it in a vector of Float_t values. This method excludes points which are far off from the BaseLine IQR (e.g. signals). -/// In case the baseline parameters were not calculated yet, this method calls CalculateBaseLine with the "ROBUST" option on the entire signal range minus 5 bins on the edges. +/// \brief It smoothes the existing signal and returns it in a vector of Float_t values. This method excludes +/// points which are far off from the BaseLine IQR (e.g. signals). In case the baseline parameters were not +/// calculated yet, this method calls CalculateBaseLine with the "ROBUST" option on the entire signal range +/// minus 5 bins on the edges. /// /// \param averagingPoints It defines the number of neightbour consecutive /// points used to average the signal /// std::vector TRestRawSignal::GetSignalSmoothed_ExcludeOutliers(Int_t averagingPoints) { - std::vector result(GetNumberOfPoints()); if (fBaseLine == 0) CalculateBaseLine(5, GetNumberOfPoints() - 5, "ROBUST"); @@ -689,15 +687,16 @@ std::vector TRestRawSignal::GetSignalSmoothed_ExcludeOutliers(Int_t ave float_t amplitude; for (int i = averagingPoints / 2 + 1; i < GetNumberOfPoints() - averagingPoints / 2; i++) { amplitude = this->GetRawData(i - (averagingPoints / 2 + 1)); - sumAvg -= (std::abs(amplitude - fBaseLine) > 3*fBaseLineSigma)? fBaseLine / averagingPoints : amplitude / averagingPoints; + sumAvg -= (std::abs(amplitude - fBaseLine) > 3 * fBaseLineSigma) ? fBaseLine / averagingPoints + : amplitude / averagingPoints; amplitude = this->GetRawData(i + averagingPoints / 2); - sumAvg += (std::abs(amplitude - fBaseLine) > 3*fBaseLineSigma)? fBaseLine / averagingPoints : amplitude / averagingPoints; + sumAvg += (std::abs(amplitude - fBaseLine) > 3 * fBaseLineSigma) ? fBaseLine / averagingPoints + : amplitude / averagingPoints; result[i] = sumAvg; } // Points at the end, where we can calculate a moving average - for (int i = GetNumberOfPoints() - averagingPoints / 2; i < GetNumberOfPoints(); i++) - result[i] = sumAvg; + for (int i = GetNumberOfPoints() - averagingPoints / 2; i < GetNumberOfPoints(); i++) result[i] = sumAvg; return result; } @@ -819,6 +818,31 @@ void TRestRawSignal::CalculateBaseLineSigmaIQR(Int_t startBin, Int_t endBin) { } } +double TRestRawSignal::GetAmplitudeFast(const TVector2& baselineRange, double signalThreshold) { + double max = 0; + fBaseLineSigma = 0; + fBaseLine = 0; + int nPoints = 0; + for (int i = 0; i < GetNumberOfPoints(); i++) { + short val = GetRawData(i); + if (val > max) max = val; + if (i < baselineRange.X() || i > baselineRange.Y() || val == 0) continue; + fBaseLine += val; + fBaseLineSigma += val * val; + nPoints++; + } + + if (nPoints > 0) { + fBaseLine /= nPoints; + fBaseLineSigma = TMath::Sqrt(fBaseLineSigma / nPoints - fBaseLine * fBaseLine); + } + + // Only pulses above certain threshold + if (max < (fBaseLine + signalThreshold * fBaseLineSigma)) return 0; + + return max - fBaseLine; +} + /////////////////////////////////////////////// /// \brief This method adds an offset to the signal data /// From 3720f67dcf7b71bddae352a5035ff75f104b70d3 Mon Sep 17 00:00:00 2001 From: juanan Date: Thu, 2 Jun 2022 20:04:26 +0200 Subject: [PATCH 12/33] Adding documentation to new function GetAmplitudeFast --- src/TRestRawSignal.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TRestRawSignal.cxx b/src/TRestRawSignal.cxx index 88a7f596..6d61bb20 100644 --- a/src/TRestRawSignal.cxx +++ b/src/TRestRawSignal.cxx @@ -818,6 +818,11 @@ void TRestRawSignal::CalculateBaseLineSigmaIQR(Int_t startBin, Int_t endBin) { } } +/////////////////////////////////////////////// +/// \brief This method calculate the baseline in a certain range and returns the maximum amplitude +/// if the signal is above certain threshold. The calculations are performed in a fast way only +/// using a single loop. +/// double TRestRawSignal::GetAmplitudeFast(const TVector2& baselineRange, double signalThreshold) { double max = 0; fBaseLineSigma = 0; From ec74eb68deeb73bed277c2b3eba7429f40c9d45e Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Thu, 27 Oct 2022 09:41:36 +0200 Subject: [PATCH 13/33] used new name for number of events `nEvents` instead of `Nevents` --- src/TRestRawDAQMetadata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index a668e548..b9fd4adf 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -114,7 +114,7 @@ void TRestRawDAQMetadata::InitFromConfigFile() { fTriggerType = GetParameter("triggerType"); fAcquisitionType = GetParameter("acquisitionType"); fCompressMode = StringToInteger(GetParameter("compressMode")); - fNEvents = StringToInteger(GetParameter("Nevents")); + fNEvents = StringToInteger(GetParameter("nEvents")); ReadIp("baseIp", fBaseIp); ReadIp("localIp", fLocalIp); ReadFEC(); From 118a29430271bff043e589c8a32c4040c8063e2f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 17:20:39 +0000 Subject: [PATCH 14/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/FECMetadata.h | 10 ++++------ src/FECMetadata.cxx | 7 +------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/inc/FECMetadata.h b/inc/FECMetadata.h index 87fda3df..16ac569f 100644 --- a/inc/FECMetadata.h +++ b/inc/FECMetadata.h @@ -5,7 +5,7 @@ #include "TString.h" class FECMetadata { - public: + public: Int_t id; Int_t ip[4]; UShort_t clockDiv; @@ -20,13 +20,11 @@ class FECMetadata { Bool_t asic_isActive[4]; Bool_t asic_channelActive[4][79]; - FECMetadata(); + FECMetadata(); - bool operator < (const FECMetadata &fM) const { - return id < fM.id; - } + bool operator<(const FECMetadata& fM) const { return id < fM.id; } - ClassDef(FECMetadata,1); + ClassDef(FECMetadata, 1); }; #endif diff --git a/src/FECMetadata.cxx b/src/FECMetadata.cxx index 18d5ac94..dce05872 100644 --- a/src/FECMetadata.cxx +++ b/src/FECMetadata.cxx @@ -2,11 +2,6 @@ #include "FECMetadata.h" - ClassImp(FECMetadata); -FECMetadata::FECMetadata(){ - -} - - +FECMetadata::FECMetadata() {} From eb2f3be000b68775ca6889331a369bbfd6fda298 Mon Sep 17 00:00:00 2001 From: juanan Date: Wed, 31 May 2023 20:24:38 +0200 Subject: [PATCH 15/33] Removal of FECMetadata class, implementing struct inside TRestRawDAQMetadata --- inc/FECMetadata.h | 30 ------------------------------ inc/TRestRawDAQMetadata.h | 22 +++++++++++++++++++++- src/FECMetadata.cxx | 7 ------- 3 files changed, 21 insertions(+), 38 deletions(-) delete mode 100644 inc/FECMetadata.h delete mode 100644 src/FECMetadata.cxx diff --git a/inc/FECMetadata.h b/inc/FECMetadata.h deleted file mode 100644 index 16ac569f..00000000 --- a/inc/FECMetadata.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef RestCore_FECMetadata -#define RestCore_FECMetadata - -#include "TString.h" - -class FECMetadata { - public: - Int_t id; - Int_t ip[4]; - UShort_t clockDiv; - TString chipType; - UShort_t asic_polarity[4]; - UShort_t asic_pedCenter[4]; - Float_t asic_pedThr[4]; - UShort_t asic_gain[4]; - UShort_t asic_shappingTime[4]; - UShort_t asic_channelStart[4]; - UShort_t asic_channelEnd[4]; - Bool_t asic_isActive[4]; - Bool_t asic_channelActive[4][79]; - - FECMetadata(); - - bool operator<(const FECMetadata& fM) const { return id < fM.id; } - - ClassDef(FECMetadata, 1); -}; - -#endif diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 723e697d..59474460 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -25,7 +25,6 @@ #include -#include "FECMetadata.h" #include "TRestMetadata.h" #include "TString.h" @@ -50,6 +49,26 @@ const std::map chipTypes_map = {{"after", chipTypes::AFT //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { + public: + + struct FECMetadata { + Int_t id; + Int_t ip[4]; + UShort_t clockDiv; + TString chipType; + UShort_t asic_polarity[4]; + UShort_t asic_pedCenter[4]; + Float_t asic_pedThr[4]; + UShort_t asic_gain[4]; + UShort_t asic_shappingTime[4]; + UShort_t asic_channelStart[4]; + UShort_t asic_channelEnd[4]; + Bool_t asic_isActive[4]; + Bool_t asic_channelActive[4][79]; + + bool operator<(const FECMetadata& fM) const { return id < fM.id; } + }; + private: void InitFromConfigFile() override; @@ -68,6 +87,7 @@ class TRestRawDAQMetadata : public TRestMetadata { std::vector fFEC; // Vector of FECs with different info public: + void PrintMetadata() override; void ReadIp(const std::string& param, Int_t* ip); diff --git a/src/FECMetadata.cxx b/src/FECMetadata.cxx deleted file mode 100644 index dce05872..00000000 --- a/src/FECMetadata.cxx +++ /dev/null @@ -1,7 +0,0 @@ - - -#include "FECMetadata.h" - -ClassImp(FECMetadata); - -FECMetadata::FECMetadata() {} From 6bede405e93d103dd0bc9aa65114da10f2497d6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 18:24:50 +0000 Subject: [PATCH 16/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/TRestRawDAQMetadata.h | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 59474460..8e3b93d8 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -49,25 +49,24 @@ const std::map chipTypes_map = {{"after", chipTypes::AFT //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { - public: - - struct FECMetadata { - Int_t id; - Int_t ip[4]; - UShort_t clockDiv; - TString chipType; - UShort_t asic_polarity[4]; - UShort_t asic_pedCenter[4]; - Float_t asic_pedThr[4]; - UShort_t asic_gain[4]; - UShort_t asic_shappingTime[4]; - UShort_t asic_channelStart[4]; - UShort_t asic_channelEnd[4]; - Bool_t asic_isActive[4]; - Bool_t asic_channelActive[4][79]; - - bool operator<(const FECMetadata& fM) const { return id < fM.id; } - }; + public: + struct FECMetadata { + Int_t id; + Int_t ip[4]; + UShort_t clockDiv; + TString chipType; + UShort_t asic_polarity[4]; + UShort_t asic_pedCenter[4]; + Float_t asic_pedThr[4]; + UShort_t asic_gain[4]; + UShort_t asic_shappingTime[4]; + UShort_t asic_channelStart[4]; + UShort_t asic_channelEnd[4]; + Bool_t asic_isActive[4]; + Bool_t asic_channelActive[4][79]; + + bool operator<(const FECMetadata& fM) const { return id < fM.id; } + }; private: void InitFromConfigFile() override; @@ -87,7 +86,6 @@ class TRestRawDAQMetadata : public TRestMetadata { std::vector fFEC; // Vector of FECs with different info public: - void PrintMetadata() override; void ReadIp(const std::string& param, Int_t* ip); From 7e1c3ebde3b595827c63ff504db1039a18479d7a Mon Sep 17 00:00:00 2001 From: usuario Date: Fri, 2 Jun 2023 11:10:26 +0200 Subject: [PATCH 17/33] Adding copy operator to FECMetadata struct --- inc/TRestRawDAQMetadata.h | 19 +++++++++++++++++++ src/TRestRawDAQMetadata.cxx | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 8e3b93d8..fdf82d0a 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -66,6 +66,25 @@ class TRestRawDAQMetadata : public TRestMetadata { Bool_t asic_channelActive[4][79]; bool operator<(const FECMetadata& fM) const { return id < fM.id; } + void operator=(const FECMetadata& fM) { + id = fM.id; + clockDiv = fM.clockDiv; + chipType = fM.chipType; + for(int i=0; i<4;i++){ + ip[i] = fM.ip[i]; + asic_polarity[i] = fM.asic_polarity[i]; + asic_pedCenter[i] = fM.asic_pedCenter[i]; + asic_pedThr[i] = fM.asic_pedThr[i]; + asic_gain[i] = fM.asic_gain[i]; + asic_shappingTime[i] = fM.asic_shappingTime[i]; + asic_channelStart[i] = fM.asic_channelStart[i]; + asic_channelEnd[i] = fM.asic_channelEnd[i]; + asic_isActive[i] = fM.asic_isActive[i]; + for(int j=0; j<79;j++){ + asic_channelActive[i][j] = fM.asic_channelActive[i][j]; + } + } + } }; private: diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index b9fd4adf..2cab4ef7 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -140,7 +140,7 @@ void TRestRawDAQMetadata::PrintMetadata() { RESTMetadata << "Acquisition type : " << fAcquisitionType.Data() << RESTendl; RESTMetadata << "Number of events : " << fNEvents << RESTendl; - for (auto f : fFEC) DumpFEC(f); + for (const auto &f : fFEC) DumpFEC(f); RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; RESTMetadata << RESTendl; From 8656c4824798f6466fc1aa0c924118e100b83c50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:10:44 +0000 Subject: [PATCH 18/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/TRestRawDAQMetadata.h | 30 +++++++++++++++--------------- src/TRestRawDAQMetadata.cxx | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index fdf82d0a..b0088b8b 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -67,21 +67,21 @@ class TRestRawDAQMetadata : public TRestMetadata { bool operator<(const FECMetadata& fM) const { return id < fM.id; } void operator=(const FECMetadata& fM) { - id = fM.id; - clockDiv = fM.clockDiv; - chipType = fM.chipType; - for(int i=0; i<4;i++){ - ip[i] = fM.ip[i]; - asic_polarity[i] = fM.asic_polarity[i]; - asic_pedCenter[i] = fM.asic_pedCenter[i]; - asic_pedThr[i] = fM.asic_pedThr[i]; - asic_gain[i] = fM.asic_gain[i]; - asic_shappingTime[i] = fM.asic_shappingTime[i]; - asic_channelStart[i] = fM.asic_channelStart[i]; - asic_channelEnd[i] = fM.asic_channelEnd[i]; - asic_isActive[i] = fM.asic_isActive[i]; - for(int j=0; j<79;j++){ - asic_channelActive[i][j] = fM.asic_channelActive[i][j]; + id = fM.id; + clockDiv = fM.clockDiv; + chipType = fM.chipType; + for (int i = 0; i < 4; i++) { + ip[i] = fM.ip[i]; + asic_polarity[i] = fM.asic_polarity[i]; + asic_pedCenter[i] = fM.asic_pedCenter[i]; + asic_pedThr[i] = fM.asic_pedThr[i]; + asic_gain[i] = fM.asic_gain[i]; + asic_shappingTime[i] = fM.asic_shappingTime[i]; + asic_channelStart[i] = fM.asic_channelStart[i]; + asic_channelEnd[i] = fM.asic_channelEnd[i]; + asic_isActive[i] = fM.asic_isActive[i]; + for (int j = 0; j < 79; j++) { + asic_channelActive[i][j] = fM.asic_channelActive[i][j]; } } } diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 2cab4ef7..19ad7808 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -140,7 +140,7 @@ void TRestRawDAQMetadata::PrintMetadata() { RESTMetadata << "Acquisition type : " << fAcquisitionType.Data() << RESTendl; RESTMetadata << "Number of events : " << fNEvents << RESTendl; - for (const auto &f : fFEC) DumpFEC(f); + for (const auto& f : fFEC) DumpFEC(f); RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; RESTMetadata << RESTendl; From 1415759fe48d73d8378e48dfe7344e86cff9250f Mon Sep 17 00:00:00 2001 From: juanan Date: Sun, 4 Jun 2023 20:34:13 +0200 Subject: [PATCH 19/33] Changing to a more generic FEC metadata structure, adding new variables and removing unneccesary stuff --- inc/TRestRawDAQMetadata.h | 113 ++++++++++++++++++++++-------------- src/TRestRawDAQMetadata.cxx | 84 +++++++++++++-------------- 2 files changed, 109 insertions(+), 88 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index b0088b8b..f5262e7a 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -30,47 +30,76 @@ namespace daq_metadata_types { -enum class acqTypes : int { BACKGROUND, CALIBRATION, PEDESTAL }; +enum class acqTypes : int { BACKGROUND = 0, CALIBRATION, PEDESTAL }; -enum class electronicsTypes : int { DUMMY, DCC, FEMINOS }; +enum class electronicsTypes : int { DUMMY = 0, DCC, FEMINOS }; -enum class chipTypes : int { AFTER, AGET }; +enum class chipTypes : int { AFTER = 0, AGET }; + +enum class triggerTypes : int { INTERNAL = 0, EXTERNAL, AUTO, TCM }; + +enum class compressModeTypes : int { ALLCHANNELS = 0, TRIGGEREDCHANNELS, ZEROSUPPRESSION }; const std::map acqTypes_map = {{"background", acqTypes::BACKGROUND}, {"calibration", acqTypes::CALIBRATION}, - {"pedestal", acqTypes::PEDESTAL}}; + {"pedestal", acqTypes::PEDESTAL} + }; + const std::map electronicsTypes_map = {{"DUMMY", electronicsTypes::DUMMY}, {"DCC", electronicsTypes::DCC}, - {"FEMINOS", electronicsTypes::FEMINOS}}; + {"FEMINOS", electronicsTypes::FEMINOS} + }; + const std::map chipTypes_map = {{"after", chipTypes::AFTER}, - {"aget", chipTypes::AGET}}; + {"aget", chipTypes::AGET} + }; + +const std::map triggerTypes_map = {{"internal", triggerTypes::INTERNAL}, + {"external", triggerTypes::EXTERNAL}, + {"auto", triggerTypes::AUTO}, + {"tcm", triggerTypes::TCM} + }; + +const std::map compressMode_map = {{"allchannels", compressModeTypes::ALLCHANNELS}, + {"triggeredcchannels", compressModeTypes::TRIGGEREDCHANNELS}, + {"zerosuppression", compressModeTypes::ZEROSUPPRESSION}, + }; } // namespace daq_metadata_types //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { public: + + static constexpr int nAsics = 4; + static constexpr int nChannels = 79; + struct FECMetadata { - Int_t id; - Int_t ip[4]; - UShort_t clockDiv; - TString chipType; - UShort_t asic_polarity[4]; - UShort_t asic_pedCenter[4]; - Float_t asic_pedThr[4]; - UShort_t asic_gain[4]; - UShort_t asic_shappingTime[4]; - UShort_t asic_channelStart[4]; - UShort_t asic_channelEnd[4]; - Bool_t asic_isActive[4]; - Bool_t asic_channelActive[4][79]; - - bool operator<(const FECMetadata& fM) const { return id < fM.id; } - void operator=(const FECMetadata& fM) { + Int_t id; + Int_t ip[nAsics]; + UShort_t clockDiv; + TString chipType; + UShort_t triggerDelay = 0; + std::array asic_polarity; + std::array asic_pedCenter; + std::array asic_pedThr; + std::array asic_gain; + std::array asic_shappingTime; + std::array asic_channelStart; + std::array asic_channelEnd; + std::array asic_isActive; + std::array asic_coarseThr; + std::array asic_fineThr; + std::array asic_multThr; + std::array asic_multLimit; + std::array , nChannels>asic_channelActive; + + bool operator<(const FECMetadata& fM) const { return id < fM.id; } + void operator=(const FECMetadata& fM) { id = fM.id; clockDiv = fM.clockDiv; chipType = fM.chipType; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < nAsics; i++) { ip[i] = fM.ip[i]; asic_polarity[i] = fM.asic_polarity[i]; asic_pedCenter[i] = fM.asic_pedCenter[i]; @@ -80,7 +109,11 @@ class TRestRawDAQMetadata : public TRestMetadata { asic_channelStart[i] = fM.asic_channelStart[i]; asic_channelEnd[i] = fM.asic_channelEnd[i]; asic_isActive[i] = fM.asic_isActive[i]; - for (int j = 0; j < 79; j++) { + asic_coarseThr[i] = fM.asic_coarseThr[i]; + asic_fineThr[i] = fM.asic_fineThr[i]; + asic_multThr[i] = fM.asic_multThr[i]; + asic_multLimit[i] = fM.asic_multLimit[i]; + for (int j = 0; j < nChannels; j++) { asic_channelActive[i][j] = fM.asic_channelActive[i][j]; } } @@ -94,19 +127,16 @@ class TRestRawDAQMetadata : public TRestMetadata { protected: TString fElectronicsType; // DCC, FEMINOS, ARC, ... - TString fChipType; // after or aget - UInt_t fClockDiv; // Clock division - Int_t fBaseIp[4] = {192, 168, 10, 13}; // Base IP of the card - Int_t fLocalIp[4] = {192, 168, 10, 10}; // Local IP of the host computer - TString fTriggerType; // external or internal + TString fTriggerType; // external, internal, auto or tcm TString fAcquisitionType; // pedestal, calibration or background - UInt_t fCompressMode = 0; // 0 uncompressed, 1 compress + TString fCompressMode; // allchannels, triggeredchannels, zerosuppression Int_t fNEvents = 0; // 0 --> Infinite - std::vector fFEC; // Vector of FECs with different info + Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired + std::vector fFEC; // Vector of FECMETADATA + TString fDecodingFile =""; public: void PrintMetadata() override; - void ReadIp(const std::string& param, Int_t* ip); // Constructor TRestRawDAQMetadata(); @@ -114,17 +144,14 @@ class TRestRawDAQMetadata : public TRestMetadata { // Destructor virtual ~TRestRawDAQMetadata(); - UInt_t GetClockDiv() { return fClockDiv; } - TString GetTriggerType() { return fTriggerType; } - TString GetAcquisitionType() { return fAcquisitionType; } - TString GetElectronicsType() { return fElectronicsType; } - TString GetChipType() { return fChipType; } - Int_t GetNEvents() { return fNEvents; } - Int_t* GetBaseIp() { return fBaseIp; } - Int_t* GetLocalIp() { return fLocalIp; } - UInt_t GetCompressMode() { return fCompressMode; } // 0 uncompressed, 1 compress - TString GetDecodingFile() { return GetParameter("decodingFile"); } - std::vector GetFECs() { return fFEC; } + inline auto GetTriggerType() const { return fTriggerType; } + inline auto GetAcquisitionType() const { return fAcquisitionType; } + inline auto GetElectronicsType() const { return fElectronicsType; } + inline auto GetNEvents() const { return fNEvents; } + inline auto GetNPedestalEvents() const { return fNEvents; } + inline auto GetCompressMode() const { return fCompressMode; } + inline auto GetDecodingFile() const { return fDecodingFile; } + inline auto GetFECs() const { return fFEC; } void SetAcquisitionType(const std::string& typ) { fAcquisitionType = typ; } void SetNEvents(const Int_t& nEv) { fNEvents = nEv; } diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 19ad7808..6fd2236d 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -32,32 +32,27 @@ /// Describe any parameters this process receives: /// * **electronicsType**: DAQ electronics type, only DCC and FEMINOS are /// supported so far. -/// * **chipType**: ASIC type, only AGET and AFTER are supported so far -/// * **clockDiv**: Clock division in the FEM -/// * **baseIp**: IP address of the electronics -/// * **localIp**: IP address of the local host (DAQ computer) -/// * **triggerType**: external or internal so far +/// * **triggerType**: internal, external, auto or tcm /// * **acquisitionType**: Type of acquisition: pedestal, calibration or /// background -/// * **compressMode**: 0 uncompressed, 1 compress (zero suppression) +/// * **compressMode**: allchannels, triggeredchannels or zerosuppression /// * **nEvents**: Number of events to be acquired (0 for infinite loop) +/// * **nPedestalEvents**: Number of pedestal events to be acquired /// It also includes `FECMetadata` section (see example) /// /// ### Examples /// Give examples of usage and RML descriptions that can be tested. /// \code /// -/// -/// -/// -/// +/// /// /// -/// -/// +/// +/// +/// /// /// -/// +/// /// /// /// @@ -106,39 +101,21 @@ void TRestRawDAQMetadata::Initialize() { TRestRawDAQMetadata::~TRestRawDAQMetadata() {} void TRestRawDAQMetadata::InitFromConfigFile() { - // string daqString; + TRestMetadata::InitFromConfigFile(); - fElectronicsType = GetParameter("electronics"); - fChipType = GetParameter("chip"); - fClockDiv = StringToInteger(GetParameter("clockDiv")); - fTriggerType = GetParameter("triggerType"); - fAcquisitionType = GetParameter("acquisitionType"); - fCompressMode = StringToInteger(GetParameter("compressMode")); - fNEvents = StringToInteger(GetParameter("nEvents")); - ReadIp("baseIp", fBaseIp); - ReadIp("localIp", fLocalIp); ReadFEC(); } -void TRestRawDAQMetadata::ReadIp(const std::string& param, Int_t* ip) { - std::string ipString = GetParameter(param); - sscanf(ipString.c_str(), "%d:%d:%d:%d", &ip[0], &ip[1], &ip[2], &ip[3]); - // std::cout< "<ClassName() << " content" << RESTendl; RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; - RESTMetadata << "Base IP : " << fBaseIp[0] << "." << fBaseIp[1] << "." << fBaseIp[2] << "." << fBaseIp[3] - << RESTendl; - RESTMetadata << "Local IP : " << fLocalIp[0] << "." << fLocalIp[1] << "." << fLocalIp[2] << "." - << fLocalIp[3] << RESTendl; - RESTMetadata << "ElectronicsType : " << fElectronicsType.Data() << RESTendl; - RESTMetadata << "Clock div : 0x" << std::hex << fClockDiv << std::dec << RESTendl; RESTMetadata << "Trigger type : " << fTriggerType.Data() << RESTendl; RESTMetadata << "Acquisition type : " << fAcquisitionType.Data() << RESTendl; + RESTMetadata << "Compress mode : " << fCompressMode.Data() << RESTendl; RESTMetadata << "Number of events : " << fNEvents << RESTendl; + RESTMetadata << "Number of pedestal events : " << fNPedestalEvents << RESTendl; for (const auto& f : fFEC) DumpFEC(f); RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; @@ -170,30 +147,39 @@ void TRestRawDAQMetadata::ReadFEC() { uint16_t polarity = StringToInteger(GetFieldValue("polarity", ASICDef)) & 0x1; uint16_t pedCenter = StringToInteger(GetFieldValue("pedcenter", ASICDef)); float pedThr = StringToFloat(GetFieldValue("pedthr", ASICDef)); + uint16_t coarseThr = StringToInteger(GetFieldValue("coarseThr", ASICDef)); + uint16_t fineThr = StringToInteger(GetFieldValue("fineThr", ASICDef)); + uint16_t multThr = StringToInteger(GetFieldValue("multThr", ASICDef)); + uint16_t multLimit = StringToInteger(GetFieldValue("multLimit", ASICDef)); + TiXmlElement* channelDef = GetElement("channel", ASICDef); - bool channelActive[79]; + bool channelActive[nChannels]; while (channelDef) { std::string chId = GetFieldValue("id", channelDef); bool active = StringToBool(GetFieldValue("isActive", channelDef)); if (chId == "*") { - for (int i = 0; i < 79; i++) channelActive[i] = active; + for (int i = 0; i < nChannels; i++) channelActive[i] = active; } else { int i = StringToInteger(chId); - if (i < 79) channelActive[i] = active; + if (i < nChannels) channelActive[i] = active; } channelDef = GetNextElement(channelDef); } if (id == "*") { // Wildcard - for (int i = 0; i < 4; i++) { + for (int i = 0; i < nAsics; i++) { fec.asic_gain[i] = gain; fec.asic_shappingTime[i] = shappingTime; fec.asic_isActive[i] = asicActive; fec.asic_polarity[i] = polarity; fec.asic_pedCenter[i] = pedCenter; fec.asic_pedThr[i] = pedThr; + fec.asic_coarseThr[i] = coarseThr; + fec.asic_fineThr[i] = fineThr; + fec.asic_multThr[i] = multThr; + fec.asic_multLimit[i] = multLimit; bool isFirst = true; - for (int c = 0; c < 79; c++) { + for (int c = 0; c < nChannels; c++) { fec.asic_channelActive[i][c] = channelActive[c]; if (channelActive[c] && isFirst) { fec.asic_channelStart[i] = c; @@ -204,15 +190,19 @@ void TRestRawDAQMetadata::ReadFEC() { } } else { int i = StringToInteger(id); - if (i < 4) { + if (i < nAsics) { fec.asic_gain[i] = gain; fec.asic_shappingTime[i] = shappingTime; fec.asic_isActive[i] = asicActive; fec.asic_polarity[i] = polarity; fec.asic_pedCenter[i] = pedCenter; fec.asic_pedThr[i] = pedThr; + fec.asic_coarseThr[i] = coarseThr; + fec.asic_fineThr[i] = fineThr; + fec.asic_multThr[i] = multThr; + fec.asic_multLimit[i] = multLimit; bool isFirst = true; - for (int c = 0; c < 79; c++) { + for (int c = 0; c < nChannels; c++) { fec.asic_channelActive[i][c] = channelActive[c]; if (channelActive[c] && isFirst) { fec.asic_channelStart[i] = c; @@ -239,18 +229,22 @@ void TRestRawDAQMetadata::DumpFEC(const FECMetadata& fec) { << RESTendl; RESTMetadata << "Chip type: " << fec.chipType << RESTendl; RESTMetadata << "Clock Div: 0x" << std::hex << fec.clockDiv << std::dec << RESTendl; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < nAsics; i++) { if (!fec.asic_isActive[i]) continue; RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; RESTMetadata << "ASIC " << i << RESTendl; - RESTMetadata << "Polarity: " << fec.asic_polarity[i] << RESTendl; + RESTMetadata << "Polarity: (AGET) " << fec.asic_polarity[i] << RESTendl; RESTMetadata << "Gain: 0x" << std::hex << fec.asic_gain[i] << std::dec << RESTendl; RESTMetadata << "ShappingTime: 0x" << std::hex << fec.asic_shappingTime[i] << std::dec << RESTendl; RESTMetadata << "Channel start: " << fec.asic_channelStart[i] << RESTendl; RESTMetadata << "Channel end: " << fec.asic_channelEnd[i] << RESTendl; + RESTMetadata << "Coarse threshold (AGET): 0x" << std::hex << fec.asic_coarseThr[i] << std::dec << RESTendl; + RESTMetadata << "Fine threshold (AGET): 0x" << std::hex << fec.asic_fineThr[i] << std::dec << RESTendl; + RESTMetadata << "Multiplicity threshold (AGET): " << fec.asic_multThr[i] << RESTendl; + RESTMetadata << "Multiplicity limit (AGET): " << fec.asic_multLimit[i] << RESTendl; RESTMetadata << "Active channels: " << RESTendl; - for (int c = 0; c < 79; c++) { - if (fec.asic_channelActive[c]) RESTMetadata << c << "; "; + for (int c = 0; c < nChannels; c++) { + if (fec.asic_channelActive[i][c]) RESTMetadata << c << "; "; if (c > 0 && c % 10 == 0) RESTMetadata << RESTendl; } RESTMetadata << RESTendl; From c066761f3ae6f639a18360b8c7e9a5250248ea81 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 4 Jun 2023 18:34:25 +0000 Subject: [PATCH 20/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/TRestRawDAQMetadata.h | 86 ++++++++++++++++++------------------- src/TRestRawDAQMetadata.cxx | 10 +++-- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index f5262e7a..a15e3c14 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -42,60 +42,56 @@ enum class compressModeTypes : int { ALLCHANNELS = 0, TRIGGEREDCHANNELS, ZEROSUP const std::map acqTypes_map = {{"background", acqTypes::BACKGROUND}, {"calibration", acqTypes::CALIBRATION}, - {"pedestal", acqTypes::PEDESTAL} - }; + {"pedestal", acqTypes::PEDESTAL}}; const std::map electronicsTypes_map = {{"DUMMY", electronicsTypes::DUMMY}, {"DCC", electronicsTypes::DCC}, - {"FEMINOS", electronicsTypes::FEMINOS} - }; + {"FEMINOS", electronicsTypes::FEMINOS}}; const std::map chipTypes_map = {{"after", chipTypes::AFTER}, - {"aget", chipTypes::AGET} - }; + {"aget", chipTypes::AGET}}; const std::map triggerTypes_map = {{"internal", triggerTypes::INTERNAL}, {"external", triggerTypes::EXTERNAL}, {"auto", triggerTypes::AUTO}, - {"tcm", triggerTypes::TCM} - }; + {"tcm", triggerTypes::TCM}}; -const std::map compressMode_map = {{"allchannels", compressModeTypes::ALLCHANNELS}, - {"triggeredcchannels", compressModeTypes::TRIGGEREDCHANNELS}, - {"zerosuppression", compressModeTypes::ZEROSUPPRESSION}, - }; +const std::map compressMode_map = { + {"allchannels", compressModeTypes::ALLCHANNELS}, + {"triggeredcchannels", compressModeTypes::TRIGGEREDCHANNELS}, + {"zerosuppression", compressModeTypes::ZEROSUPPRESSION}, +}; } // namespace daq_metadata_types //! A metadata class to store DAQ information. class TRestRawDAQMetadata : public TRestMetadata { public: - - static constexpr int nAsics = 4; - static constexpr int nChannels = 79; + static constexpr int nAsics = 4; + static constexpr int nChannels = 79; struct FECMetadata { - Int_t id; - Int_t ip[nAsics]; - UShort_t clockDiv; - TString chipType; - UShort_t triggerDelay = 0; - std::array asic_polarity; - std::array asic_pedCenter; - std::array asic_pedThr; - std::array asic_gain; - std::array asic_shappingTime; - std::array asic_channelStart; - std::array asic_channelEnd; - std::array asic_isActive; - std::array asic_coarseThr; - std::array asic_fineThr; - std::array asic_multThr; - std::array asic_multLimit; - std::array , nChannels>asic_channelActive; - - bool operator<(const FECMetadata& fM) const { return id < fM.id; } - void operator=(const FECMetadata& fM) { + Int_t id; + Int_t ip[nAsics]; + UShort_t clockDiv; + TString chipType; + UShort_t triggerDelay = 0; + std::array asic_polarity; + std::array asic_pedCenter; + std::array asic_pedThr; + std::array asic_gain; + std::array asic_shappingTime; + std::array asic_channelStart; + std::array asic_channelEnd; + std::array asic_isActive; + std::array asic_coarseThr; + std::array asic_fineThr; + std::array asic_multThr; + std::array asic_multLimit; + std::array, nChannels> asic_channelActive; + + bool operator<(const FECMetadata& fM) const { return id < fM.id; } + void operator=(const FECMetadata& fM) { id = fM.id; clockDiv = fM.clockDiv; chipType = fM.chipType; @@ -126,14 +122,14 @@ class TRestRawDAQMetadata : public TRestMetadata { void Initialize() override; protected: - TString fElectronicsType; // DCC, FEMINOS, ARC, ... - TString fTriggerType; // external, internal, auto or tcm - TString fAcquisitionType; // pedestal, calibration or background - TString fCompressMode; // allchannels, triggeredchannels, zerosuppression - Int_t fNEvents = 0; // 0 --> Infinite - Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired - std::vector fFEC; // Vector of FECMETADATA - TString fDecodingFile =""; + TString fElectronicsType; // DCC, FEMINOS, ARC, ... + TString fTriggerType; // external, internal, auto or tcm + TString fAcquisitionType; // pedestal, calibration or background + TString fCompressMode; // allchannels, triggeredchannels, zerosuppression + Int_t fNEvents = 0; // 0 --> Infinite + Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired + std::vector fFEC; // Vector of FECMETADATA + TString fDecodingFile = ""; public: void PrintMetadata() override; @@ -151,7 +147,7 @@ class TRestRawDAQMetadata : public TRestMetadata { inline auto GetNPedestalEvents() const { return fNEvents; } inline auto GetCompressMode() const { return fCompressMode; } inline auto GetDecodingFile() const { return fDecodingFile; } - inline auto GetFECs() const { return fFEC; } + inline auto GetFECs() const { return fFEC; } void SetAcquisitionType(const std::string& typ) { fAcquisitionType = typ; } void SetNEvents(const Int_t& nEv) { fNEvents = nEv; } diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 6fd2236d..6c57e2fa 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -52,7 +52,8 @@ /// /// /// -/// +/// /// /// /// @@ -106,7 +107,6 @@ void TRestRawDAQMetadata::InitFromConfigFile() { ReadFEC(); } - void TRestRawDAQMetadata::PrintMetadata() { RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; RESTMetadata << this->ClassName() << " content" << RESTendl; @@ -238,8 +238,10 @@ void TRestRawDAQMetadata::DumpFEC(const FECMetadata& fec) { RESTMetadata << "ShappingTime: 0x" << std::hex << fec.asic_shappingTime[i] << std::dec << RESTendl; RESTMetadata << "Channel start: " << fec.asic_channelStart[i] << RESTendl; RESTMetadata << "Channel end: " << fec.asic_channelEnd[i] << RESTendl; - RESTMetadata << "Coarse threshold (AGET): 0x" << std::hex << fec.asic_coarseThr[i] << std::dec << RESTendl; - RESTMetadata << "Fine threshold (AGET): 0x" << std::hex << fec.asic_fineThr[i] << std::dec << RESTendl; + RESTMetadata << "Coarse threshold (AGET): 0x" << std::hex << fec.asic_coarseThr[i] << std::dec + << RESTendl; + RESTMetadata << "Fine threshold (AGET): 0x" << std::hex << fec.asic_fineThr[i] << std::dec + << RESTendl; RESTMetadata << "Multiplicity threshold (AGET): " << fec.asic_multThr[i] << RESTendl; RESTMetadata << "Multiplicity limit (AGET): " << fec.asic_multLimit[i] << RESTendl; RESTMetadata << "Active channels: " << RESTendl; From fa8c95db1a1dffde9e15761671b88661b52fe052 Mon Sep 17 00:00:00 2001 From: juanan Date: Mon, 5 Jun 2023 10:17:22 +0200 Subject: [PATCH 21/33] Bug fix --- inc/TRestRawDAQMetadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index a15e3c14..bf0e3fc0 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -144,7 +144,7 @@ class TRestRawDAQMetadata : public TRestMetadata { inline auto GetAcquisitionType() const { return fAcquisitionType; } inline auto GetElectronicsType() const { return fElectronicsType; } inline auto GetNEvents() const { return fNEvents; } - inline auto GetNPedestalEvents() const { return fNEvents; } + inline auto GetNPedestalEvents() const { return fNPedestalEvents; } inline auto GetCompressMode() const { return fCompressMode; } inline auto GetDecodingFile() const { return fDecodingFile; } inline auto GetFECs() const { return fFEC; } From a49af8affb3e4a0a47973e6f15c98b68755b7de6 Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 23 Jun 2023 10:34:06 +0200 Subject: [PATCH 22/33] Adding new DAQ metadata maximum file size --- inc/TRestRawDAQMetadata.h | 20 +++++++++++--------- src/TRestRawDAQMetadata.cxx | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index bf0e3fc0..5c234873 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -122,14 +122,15 @@ class TRestRawDAQMetadata : public TRestMetadata { void Initialize() override; protected: - TString fElectronicsType; // DCC, FEMINOS, ARC, ... - TString fTriggerType; // external, internal, auto or tcm - TString fAcquisitionType; // pedestal, calibration or background - TString fCompressMode; // allchannels, triggeredchannels, zerosuppression - Int_t fNEvents = 0; // 0 --> Infinite - Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired - std::vector fFEC; // Vector of FECMETADATA - TString fDecodingFile = ""; + TString fElectronicsType; // DCC, FEMINOS, ARC, ... + TString fTriggerType; // external, internal, auto or tcm + TString fAcquisitionType; // pedestal, calibration or background + TString fCompressMode; // allchannels, triggeredchannels, zerosuppression + Int_t fNEvents = 0; // 0 --> Infinite + Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired + std::vector fFEC; // Vector of FECMETADATA + TString fDecodingFile = ""; // Location of the decoding file + Int_t fMaxFileSize = 1000000000; // Maximum file size in bytes public: void PrintMetadata() override; @@ -148,6 +149,7 @@ class TRestRawDAQMetadata : public TRestMetadata { inline auto GetCompressMode() const { return fCompressMode; } inline auto GetDecodingFile() const { return fDecodingFile; } inline auto GetFECs() const { return fFEC; } + inline auto GetMaxFileSize() const { return fMaxFileSize; } void SetAcquisitionType(const std::string& typ) { fAcquisitionType = typ; } void SetNEvents(const Int_t& nEv) { fNEvents = nEv; } @@ -155,6 +157,6 @@ class TRestRawDAQMetadata : public TRestMetadata { void ReadFEC(); void DumpFEC(const FECMetadata& fec); - ClassDefOverride(TRestRawDAQMetadata, 2); // REST run class + ClassDefOverride(TRestRawDAQMetadata, 3); // REST run class }; #endif diff --git a/src/TRestRawDAQMetadata.cxx b/src/TRestRawDAQMetadata.cxx index 6c57e2fa..9c8bd595 100644 --- a/src/TRestRawDAQMetadata.cxx +++ b/src/TRestRawDAQMetadata.cxx @@ -116,6 +116,7 @@ void TRestRawDAQMetadata::PrintMetadata() { RESTMetadata << "Compress mode : " << fCompressMode.Data() << RESTendl; RESTMetadata << "Number of events : " << fNEvents << RESTendl; RESTMetadata << "Number of pedestal events : " << fNPedestalEvents << RESTendl; + RESTMetadata << "Maximum file size : " << fMaxFileSize << " bytes" << RESTendl; for (const auto& f : fFEC) DumpFEC(f); RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++" << RESTendl; From 24d9512ab3b27ab4584e97aeb8534fad1a53f935 Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 23 Jun 2023 10:34:49 +0200 Subject: [PATCH 23/33] Added new method to remove baseline from zero suppression data --- inc/TRestRawSignal.h | 2 ++ src/TRestRawSignal.cxx | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/inc/TRestRawSignal.h b/inc/TRestRawSignal.h index e44fe28d..d58a5278 100644 --- a/inc/TRestRawSignal.h +++ b/inc/TRestRawSignal.h @@ -157,6 +157,8 @@ class TRestRawSignal : public TObject { void InitializePointsOverThreshold(const TVector2& thrPar, Int_t nPointsOver, Int_t nPointsFlat = 512); + void ZeroSuppressionToRaw(); + Double_t GetIntegral(); Double_t GetIntegralInRange(Int_t startBin, Int_t endBin); diff --git a/src/TRestRawSignal.cxx b/src/TRestRawSignal.cxx index 9436f7ea..6eba1220 100644 --- a/src/TRestRawSignal.cxx +++ b/src/TRestRawSignal.cxx @@ -894,6 +894,20 @@ void TRestRawSignal::WriteSignalToTextFile(const TString& filename) { fclose(file); } +/////////////////////////////////////////////// +/// \brief This method transforms zero suppression +/// raw data into a raw data event using the firs +/// +void TRestRawSignal::ZeroSuppressionToRaw( ) { + Short_t offset = 0; + for (int i = 0; i < GetNumberOfPoints(); i++){ + const Short_t val = fSignalData[i]; + if(val == 0 )continue; + if(offset == 0 )offset = val; + fSignalData[i] = val - offset; + } +} + /////////////////////////////////////////////// /// \brief It prints the signal data on screen. /// From a0fba18c33c1f93c107f8da4a278ea40371f3206 Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 23 Jun 2023 12:11:18 +0200 Subject: [PATCH 24/33] New process TRestRawZeroSupressionToRawProcess to remove the baseline in zero suppression acquired events --- inc/TRestRawZeroSupressionToRawProcess.h | 63 +++++++++++++ src/TRestRawZeroSupressionToRawProcess.cxx | 101 +++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 inc/TRestRawZeroSupressionToRawProcess.h create mode 100644 src/TRestRawZeroSupressionToRawProcess.cxx diff --git a/inc/TRestRawZeroSupressionToRawProcess.h b/inc/TRestRawZeroSupressionToRawProcess.h new file mode 100644 index 00000000..4f9a019a --- /dev/null +++ b/inc/TRestRawZeroSupressionToRawProcess.h @@ -0,0 +1,63 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see http://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see http://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef RESTProc_TRestRawZeroSupressionToRawProcess +#define RESTProc_TRestRawZeroSupressionToRawProcess + +#include "TRestEvent.h" +#include "TRestRawSignalEvent.h" +#include "TRestEventProcess.h" + +/// This process remove the offset on a zerosuppression acquired event +class TRestRawZeroSupressionToRawProcess : public TRestEventProcess { +private: + /// Pointer to TRestRawSignalEvent input event + TRestRawSignalEvent* fEvent; //! + + void Initialize() override; + +public: + any GetInputEvent() const override { return fEvent; } + any GetOutputEvent() const override { return fEvent; } + + void InitProcess() override; + +const char* GetProcessName() const override { return "ZeroSupressionToRaw"; } + + TRestEvent* ProcessEvent (TRestEvent* eventInput) override; + + void EndProcess() override; + + /// It prints out the process parameters stored in the metadata structure + void PrintMetadata() override { + BeginPrintProcess(); + + EndPrintProcess(); + } + + TRestRawZeroSupressionToRawProcess(); + ~TRestRawZeroSupressionToRawProcess(); + + ClassDefOverride(TRestRawZeroSupressionToRawProcess, 1); + +}; +#endif diff --git a/src/TRestRawZeroSupressionToRawProcess.cxx b/src/TRestRawZeroSupressionToRawProcess.cxx new file mode 100644 index 00000000..60a2f734 --- /dev/null +++ b/src/TRestRawZeroSupressionToRawProcess.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see http://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see http://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// TRestRawZeroSuppressionToRaw process remove the offset on a zerosuppression +/// acquired event using the first bin as baseline. +/// +/// ### Examples +/// Give examples of usage and RML descriptions that can be tested. +/// \code +/// +/// \endcode +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2023-June: First implementation of TRestRawZeroSupressionToRawProcess +/// JuanAn Garcia +/// +/// \class TRestRawZeroSupressionToRawProcess +/// \author: JuanAn Garcia juanangp@unizar.es +/// +///
+/// + +#include "TRestRawZeroSupressionToRawProcess.h" + +ClassImp(TRestRawZeroSupressionToRawProcess); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestRawZeroSupressionToRawProcess::TRestRawZeroSupressionToRawProcess() { + Initialize(); +} + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestRawZeroSupressionToRawProcess::~TRestRawZeroSupressionToRawProcess() { +} + +/////////////////////////////////////////////// +/// \brief Function to initialize input/output event members and define +/// the section name +/// +void TRestRawZeroSupressionToRawProcess::Initialize() { + SetSectionName(this->ClassName()); + SetLibraryVersion(LIBRARY_VERSION); + fEvent = nullptr; +} + +/////////////////////////////////////////////// +/// \brief Process initialization. +/// +void TRestRawZeroSupressionToRawProcess::InitProcess() { + + +} + +/////////////////////////////////////////////// +/// \brief The main processing event function +/// +TRestEvent* TRestRawZeroSupressionToRawProcess::ProcessEvent(TRestEvent * evInput) { + fEvent = (TRestRawSignalEvent*)evInput; + for (int n = 0; n < fEvent->GetNumberOfSignals(); n++) { + TRestRawSignal* rawSignal = fEvent->GetSignal(n); + rawSignal->ZeroSuppressionToRaw(); + } + + return fEvent; +} + +/////////////////////////////////////////////// +/// \brief Function to include required actions after all events have been +/// processed. +/// +void TRestRawZeroSupressionToRawProcess::EndProcess() { + +} + From c5f644d3633b0639f39d83e8e933b362bb5c6136 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 10:12:14 +0000 Subject: [PATCH 25/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/TRestRawDAQMetadata.h | 18 ++--- inc/TRestRawZeroSupressionToRawProcess.h | 11 ++- src/TRestRawSignal.cxx | 10 +-- src/TRestRawZeroSupressionToRawProcess.cxx | 89 ++++++++++------------ 4 files changed, 59 insertions(+), 69 deletions(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 5c234873..13c71b52 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -122,15 +122,15 @@ class TRestRawDAQMetadata : public TRestMetadata { void Initialize() override; protected: - TString fElectronicsType; // DCC, FEMINOS, ARC, ... - TString fTriggerType; // external, internal, auto or tcm - TString fAcquisitionType; // pedestal, calibration or background - TString fCompressMode; // allchannels, triggeredchannels, zerosuppression - Int_t fNEvents = 0; // 0 --> Infinite - Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired - std::vector fFEC; // Vector of FECMETADATA - TString fDecodingFile = ""; // Location of the decoding file - Int_t fMaxFileSize = 1000000000; // Maximum file size in bytes + TString fElectronicsType; // DCC, FEMINOS, ARC, ... + TString fTriggerType; // external, internal, auto or tcm + TString fAcquisitionType; // pedestal, calibration or background + TString fCompressMode; // allchannels, triggeredchannels, zerosuppression + Int_t fNEvents = 0; // 0 --> Infinite + Int_t fNPedestalEvents = 100; // Number of pedestal events to be acquired + std::vector fFEC; // Vector of FECMETADATA + TString fDecodingFile = ""; // Location of the decoding file + Int_t fMaxFileSize = 1000000000; // Maximum file size in bytes public: void PrintMetadata() override; diff --git a/inc/TRestRawZeroSupressionToRawProcess.h b/inc/TRestRawZeroSupressionToRawProcess.h index 4f9a019a..5e7d6bd8 100644 --- a/inc/TRestRawZeroSupressionToRawProcess.h +++ b/inc/TRestRawZeroSupressionToRawProcess.h @@ -24,26 +24,26 @@ #define RESTProc_TRestRawZeroSupressionToRawProcess #include "TRestEvent.h" -#include "TRestRawSignalEvent.h" #include "TRestEventProcess.h" +#include "TRestRawSignalEvent.h" /// This process remove the offset on a zerosuppression acquired event class TRestRawZeroSupressionToRawProcess : public TRestEventProcess { -private: + private: /// Pointer to TRestRawSignalEvent input event TRestRawSignalEvent* fEvent; //! void Initialize() override; -public: + public: any GetInputEvent() const override { return fEvent; } any GetOutputEvent() const override { return fEvent; } void InitProcess() override; -const char* GetProcessName() const override { return "ZeroSupressionToRaw"; } + const char* GetProcessName() const override { return "ZeroSupressionToRaw"; } - TRestEvent* ProcessEvent (TRestEvent* eventInput) override; + TRestEvent* ProcessEvent(TRestEvent* eventInput) override; void EndProcess() override; @@ -58,6 +58,5 @@ const char* GetProcessName() const override { return "ZeroSupressionToRaw"; } ~TRestRawZeroSupressionToRawProcess(); ClassDefOverride(TRestRawZeroSupressionToRawProcess, 1); - }; #endif diff --git a/src/TRestRawSignal.cxx b/src/TRestRawSignal.cxx index 6eba1220..91779b0f 100644 --- a/src/TRestRawSignal.cxx +++ b/src/TRestRawSignal.cxx @@ -898,12 +898,12 @@ void TRestRawSignal::WriteSignalToTextFile(const TString& filename) { /// \brief This method transforms zero suppression /// raw data into a raw data event using the firs /// -void TRestRawSignal::ZeroSuppressionToRaw( ) { +void TRestRawSignal::ZeroSuppressionToRaw() { Short_t offset = 0; - for (int i = 0; i < GetNumberOfPoints(); i++){ - const Short_t val = fSignalData[i]; - if(val == 0 )continue; - if(offset == 0 )offset = val; + for (int i = 0; i < GetNumberOfPoints(); i++) { + const Short_t val = fSignalData[i]; + if (val == 0) continue; + if (offset == 0) offset = val; fSignalData[i] = val - offset; } } diff --git a/src/TRestRawZeroSupressionToRawProcess.cxx b/src/TRestRawZeroSupressionToRawProcess.cxx index 60a2f734..9b01bc6b 100644 --- a/src/TRestRawZeroSupressionToRawProcess.cxx +++ b/src/TRestRawZeroSupressionToRawProcess.cxx @@ -23,79 +23,70 @@ ///////////////////////////////////////////////////////////////////////// /// TRestRawZeroSuppressionToRaw process remove the offset on a zerosuppression /// acquired event using the first bin as baseline. -/// +/// /// ### Examples -/// Give examples of usage and RML descriptions that can be tested. +/// Give examples of usage and RML descriptions that can be tested. /// \code /// /// \endcode -/// -/// REST-for-Physics - Software for Rare Event Searches Toolkit -/// -/// History of developments: -/// +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// /// 2023-June: First implementation of TRestRawZeroSupressionToRawProcess -/// JuanAn Garcia -/// -/// \class TRestRawZeroSupressionToRawProcess +/// JuanAn Garcia +/// +/// \class TRestRawZeroSupressionToRawProcess /// \author: JuanAn Garcia juanangp@unizar.es -/// -///
-/// +/// +///
+/// #include "TRestRawZeroSupressionToRawProcess.h" ClassImp(TRestRawZeroSupressionToRawProcess); -/////////////////////////////////////////////// -/// \brief Default constructor -/// -TRestRawZeroSupressionToRawProcess::TRestRawZeroSupressionToRawProcess() { - Initialize(); -} +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestRawZeroSupressionToRawProcess::TRestRawZeroSupressionToRawProcess() { Initialize(); } -/////////////////////////////////////////////// -/// \brief Default destructor -/// -TRestRawZeroSupressionToRawProcess::~TRestRawZeroSupressionToRawProcess() { -} +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestRawZeroSupressionToRawProcess::~TRestRawZeroSupressionToRawProcess() {} -/////////////////////////////////////////////// -/// \brief Function to initialize input/output event members and define -/// the section name -/// +/////////////////////////////////////////////// +/// \brief Function to initialize input/output event members and define +/// the section name +/// void TRestRawZeroSupressionToRawProcess::Initialize() { SetSectionName(this->ClassName()); SetLibraryVersion(LIBRARY_VERSION); - fEvent = nullptr; + fEvent = nullptr; } -/////////////////////////////////////////////// -/// \brief Process initialization. -/// -void TRestRawZeroSupressionToRawProcess::InitProcess() { - - -} +/////////////////////////////////////////////// +/// \brief Process initialization. +/// +void TRestRawZeroSupressionToRawProcess::InitProcess() {} -/////////////////////////////////////////////// -/// \brief The main processing event function -/// -TRestEvent* TRestRawZeroSupressionToRawProcess::ProcessEvent(TRestEvent * evInput) { +/////////////////////////////////////////////// +/// \brief The main processing event function +/// +TRestEvent* TRestRawZeroSupressionToRawProcess::ProcessEvent(TRestEvent* evInput) { fEvent = (TRestRawSignalEvent*)evInput; - for (int n = 0; n < fEvent->GetNumberOfSignals(); n++) { + for (int n = 0; n < fEvent->GetNumberOfSignals(); n++) { TRestRawSignal* rawSignal = fEvent->GetSignal(n); rawSignal->ZeroSuppressionToRaw(); - } + } return fEvent; } -/////////////////////////////////////////////// +/////////////////////////////////////////////// /// \brief Function to include required actions after all events have been -/// processed. -/// -void TRestRawZeroSupressionToRawProcess::EndProcess() { - -} - +/// processed. +/// +void TRestRawZeroSupressionToRawProcess::EndProcess() {} From e46a544bb8a190475ac5ee1c49f02c66db536865 Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 23 Jun 2023 12:18:44 +0200 Subject: [PATCH 26/33] Adding RML example to TRestRawZeroSupressionToRawProcess --- src/TRestRawZeroSupressionToRawProcess.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TRestRawZeroSupressionToRawProcess.cxx b/src/TRestRawZeroSupressionToRawProcess.cxx index 9b01bc6b..ce026030 100644 --- a/src/TRestRawZeroSupressionToRawProcess.cxx +++ b/src/TRestRawZeroSupressionToRawProcess.cxx @@ -27,7 +27,7 @@ /// ### Examples /// Give examples of usage and RML descriptions that can be tested. /// \code -/// +/// /// \endcode /// /// REST-for-Physics - Software for Rare Event Searches Toolkit From 64cb31889b3617a0cba424d5f19af0e7dc74479d Mon Sep 17 00:00:00 2001 From: juanan Date: Fri, 8 Sep 2023 17:40:38 +0200 Subject: [PATCH 27/33] Fixing compilation error after recent changes in master --- inc/TRestRawZeroSupressionToRawProcess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/TRestRawZeroSupressionToRawProcess.h b/inc/TRestRawZeroSupressionToRawProcess.h index 5e7d6bd8..880d3368 100644 --- a/inc/TRestRawZeroSupressionToRawProcess.h +++ b/inc/TRestRawZeroSupressionToRawProcess.h @@ -36,8 +36,8 @@ class TRestRawZeroSupressionToRawProcess : public TRestEventProcess { void Initialize() override; public: - any GetInputEvent() const override { return fEvent; } - any GetOutputEvent() const override { return fEvent; } + RESTValue GetInputEvent() const override { return fEvent; } + RESTValue GetOutputEvent() const override { return fEvent; } void InitProcess() override; From 6528512cd769533121749bc6666355a6ea45d56d Mon Sep 17 00:00:00 2001 From: juanan Date: Mon, 29 Apr 2024 09:49:15 +0200 Subject: [PATCH 28/33] Adding ARC electronics as electronic type --- inc/TRestRawDAQMetadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 13c71b52..26fe5925 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -32,7 +32,7 @@ namespace daq_metadata_types { enum class acqTypes : int { BACKGROUND = 0, CALIBRATION, PEDESTAL }; -enum class electronicsTypes : int { DUMMY = 0, DCC, FEMINOS }; +enum class electronicsTypes : int { DUMMY = 0, DCC, FEMINOS, ARC }; enum class chipTypes : int { AFTER = 0, AGET }; From bcab3e42c179e4e3c3473d17afff927eaa0eac4a Mon Sep 17 00:00:00 2001 From: usuario Date: Mon, 29 Apr 2024 11:36:43 +0200 Subject: [PATCH 29/33] Adding ARC electronics type to map --- inc/TRestRawDAQMetadata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 26fe5925..021fe419 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -46,7 +46,8 @@ const std::map acqTypes_map = {{"background", acqTypes::B const std::map electronicsTypes_map = {{"DUMMY", electronicsTypes::DUMMY}, {"DCC", electronicsTypes::DCC}, - {"FEMINOS", electronicsTypes::FEMINOS}}; + {"FEMINOS", electronicsTypes::FEMINOS}, +{"ARC", electronicsTypes::ARC} }; const std::map chipTypes_map = {{"after", chipTypes::AFTER}, {"aget", chipTypes::AGET}}; From e56761e6f05efe3bc116a3a0dc33116b500bf870 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 09:42:18 +0000 Subject: [PATCH 30/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- inc/TRestRawDAQMetadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 021fe419..055f7594 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -47,7 +47,7 @@ const std::map acqTypes_map = {{"background", acqTypes::B const std::map electronicsTypes_map = {{"DUMMY", electronicsTypes::DUMMY}, {"DCC", electronicsTypes::DCC}, {"FEMINOS", electronicsTypes::FEMINOS}, -{"ARC", electronicsTypes::ARC} }; + {"ARC", electronicsTypes::ARC}}; const std::map chipTypes_map = {{"after", chipTypes::AFTER}, {"aget", chipTypes::AGET}}; From cb54bfba5429bd632a602b9990b2ac9e98921728 Mon Sep 17 00:00:00 2001 From: usuario Date: Thu, 30 May 2024 09:46:57 +0200 Subject: [PATCH 31/33] Fixing typo --- inc/TRestRawDAQMetadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestRawDAQMetadata.h b/inc/TRestRawDAQMetadata.h index 021fe419..2ee6dc93 100644 --- a/inc/TRestRawDAQMetadata.h +++ b/inc/TRestRawDAQMetadata.h @@ -59,7 +59,7 @@ const std::map triggerTypes_map = {{"internal", trigg const std::map compressMode_map = { {"allchannels", compressModeTypes::ALLCHANNELS}, - {"triggeredcchannels", compressModeTypes::TRIGGEREDCHANNELS}, + {"triggeredchannels", compressModeTypes::TRIGGEREDCHANNELS}, {"zerosuppression", compressModeTypes::ZEROSUPPRESSION}, }; From fa69e3f2dc7f03a2394fa9228af41e373945ece8 Mon Sep 17 00:00:00 2001 From: usuario Date: Fri, 31 May 2024 10:51:02 +0200 Subject: [PATCH 32/33] Adding new macro to cmpute noise and RMS --- macros/REST_Raw_NoiseRMS.C | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 macros/REST_Raw_NoiseRMS.C diff --git a/macros/REST_Raw_NoiseRMS.C b/macros/REST_Raw_NoiseRMS.C new file mode 100644 index 00000000..7f359e0b --- /dev/null +++ b/macros/REST_Raw_NoiseRMS.C @@ -0,0 +1,58 @@ + + +void REST_Raw_NoiseRMS (const std::string &fileName, int nEvents = 10){ + + + TRestRun run(fileName); + + TRestRawSignalEvent *rawEvent = (TRestRawSignalEvent*)run.GetInputEvent(); + + std::map channelMapMean; + std::map channelMapStd; + std::map channelMapCount; + + + int entries = run.GetEntries(); + + nEvents = std::min(nEvents, entries); + + for(int i=0;iGetNumberOfSignals(); s++) { + TRestRawSignal* rawSignal = rawEvent->GetSignal(s); + const int daqChannel = rawSignal->GetSignalID(); + for(int p=0;pGetNumberOfPoints();p++){ + short data = rawSignal->GetRawData(p); + channelMapMean[daqChannel] += data; + channelMapStd[daqChannel] += data*data; + channelMapCount[daqChannel]++; + } + } + + } + + auto grE = new TGraphErrors(); + + int c =0; + for(const auto & [channel, count] : channelMapCount){ + if(count>0){ + double mean = channelMapMean[channel]/count; + double std = sqrt(channelMapStd[channel]/count - mean*mean ); + std::cout<< "Channel "<SetPoint(c, channel, mean); + grE->SetPointError(c,0,std); + c++; + } + + } + + std::cout<<"Total number of events processed "<Draw("AP"); + + + +} + From a4662f0b08658a6ec1e5c6d969a4c20c89f02cb4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 08:51:57 +0000 Subject: [PATCH 33/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- macros/REST_Raw_NoiseRMS.C | 93 +++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/macros/REST_Raw_NoiseRMS.C b/macros/REST_Raw_NoiseRMS.C index 7f359e0b..14071e51 100644 --- a/macros/REST_Raw_NoiseRMS.C +++ b/macros/REST_Raw_NoiseRMS.C @@ -1,58 +1,49 @@ -void REST_Raw_NoiseRMS (const std::string &fileName, int nEvents = 10){ - - - TRestRun run(fileName); - - TRestRawSignalEvent *rawEvent = (TRestRawSignalEvent*)run.GetInputEvent(); - - std::map channelMapMean; - std::map channelMapStd; - std::map channelMapCount; - - - int entries = run.GetEntries(); - - nEvents = std::min(nEvents, entries); - - for(int i=0;iGetNumberOfSignals(); s++) { - TRestRawSignal* rawSignal = rawEvent->GetSignal(s); - const int daqChannel = rawSignal->GetSignalID(); - for(int p=0;pGetNumberOfPoints();p++){ - short data = rawSignal->GetRawData(p); - channelMapMean[daqChannel] += data; - channelMapStd[daqChannel] += data*data; - channelMapCount[daqChannel]++; - } - } - - } - - auto grE = new TGraphErrors(); - - int c =0; - for(const auto & [channel, count] : channelMapCount){ - if(count>0){ - double mean = channelMapMean[channel]/count; - double std = sqrt(channelMapStd[channel]/count - mean*mean ); - std::cout<< "Channel "<SetPoint(c, channel, mean); - grE->SetPointError(c,0,std); - c++; +void REST_Raw_NoiseRMS(const std::string& fileName, int nEvents = 10) { + TRestRun run(fileName); + + TRestRawSignalEvent* rawEvent = (TRestRawSignalEvent*)run.GetInputEvent(); + + std::map channelMapMean; + std::map channelMapStd; + std::map channelMapCount; + + int entries = run.GetEntries(); + + nEvents = std::min(nEvents, entries); + + for (int i = 0; i < nEvents; i++) { + run.GetEntry(i); + int chId; + double mean = 0, rms = 0; + for (int s = 0; s < rawEvent->GetNumberOfSignals(); s++) { + TRestRawSignal* rawSignal = rawEvent->GetSignal(s); + const int daqChannel = rawSignal->GetSignalID(); + for (int p = 0; p < rawSignal->GetNumberOfPoints(); p++) { + short data = rawSignal->GetRawData(p); + channelMapMean[daqChannel] += data; + channelMapStd[daqChannel] += data * data; + channelMapCount[daqChannel]++; + } + } } - } - - std::cout<<"Total number of events processed "<Draw("AP"); - + auto grE = new TGraphErrors(); + + int c = 0; + for (const auto& [channel, count] : channelMapCount) { + if (count > 0) { + double mean = channelMapMean[channel] / count; + double std = sqrt(channelMapStd[channel] / count - mean * mean); + std::cout << "Channel " << channel << " Mean " << mean << " Std " << std << endl; + grE->SetPoint(c, channel, mean); + grE->SetPointError(c, 0, std); + c++; + } + } + std::cout << "Total number of events processed " << nEvents << endl; + grE->Draw("AP"); } -