Commit d4f17f99 authored by j.a.galan.81@gmail.com's avatar j.a.galan.81@gmail.com
Browse files

First commit

parents
set(contents)
COMPILEDIR(RestRaw)
/*************************************************************************
* 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 RestCore_TRestRawAFTERToSignalProcess
#define RestCore_TRestRawAFTERToSignalProcess
#include "TRestRawToSignalProcess.h"
#include "TRestDetectorSignalEvent.h"
// ATENTION: new T2K Daq versions 2.X need to read one extra word
#define NEW_DAQ_T2K_2_X
//--------------------------------------------------------
// Structure acquisition data
//--------------------------------------------------------
struct EventHeader {
int eventSize;
int eventNumb;
// int eventTime;
// unsigned short dummy;
};
#ifdef NEW_DAQ_T2K_2_X
// ATENTION!!!!!
// New verison of the DaqT2K (2.x)
// added 30th July 2012 (JuanAn)
struct DataPacketHeader {
unsigned short size;
unsigned short dcc;
unsigned short hdr;
unsigned short args;
unsigned short ts_h;
unsigned short ts_l;
unsigned short ecnt;
unsigned short scnt;
};
#else
struct DataPacketHeader {
unsigned short size;
unsigned short hdr;
unsigned short args;
unsigned short ts_h;
unsigned short ts_l;
unsigned short ecnt;
unsigned short scnt;
};
#endif
struct DataPacketEnd {
unsigned short crc1;
unsigned short crc2;
};
//! A process to read binary files produced with AFTER electronics
class TRestRawAFTERToSignalProcess : public TRestRawToSignalProcess {
protected:
unsigned int prevTime;
double reducedTime;
public:
void Initialize();
void InitProcess();
TRestEvent* ProcessEvent(TRestEvent* evInput);
TString GetProcessName() { return (TString) "AFTERToSignal"; }
TRestMetadata* GetProcessMetadata() { return NULL; }
Bool_t isExternal() { return true; }
TRestRawAFTERToSignalProcess();
TRestRawAFTERToSignalProcess(char* cfgFileName);
~TRestRawAFTERToSignalProcess();
ClassDef(TRestRawAFTERToSignalProcess, 1);
};
#endif
/*************************************************************************
* 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 RestCore_TRestRawCommonNoiseReductionProcess
#define RestCore_TRestRawCommonNoiseReductionProcess
#include <TRestRawSignalEvent.h>
#include "TRestEventProcess.h"
//! A process to substract the common channels noise from RawSignal type of data.
class TRestRawCommonNoiseReductionProcess : public TRestEventProcess {
private:
/// A pointer to the specific TRestRawSignalEvent input
TRestRawSignalEvent* fInputEvent;
/// A pointer to the specific TRestRawSignalEvent output
TRestRawSignalEvent* fOutputEvent;
/// The mode defines the method to be used (It can be 0 or 1).
Int_t fMode = 0;
/// The percentage of signals taken from the array center to be considered for the average.
Int_t fcenterWidth = 0;
void InitFromConfigFile();
void Initialize();
void LoadDefaultConfig();
protected:
// add here the members of your event process
public:
any GetInputEvent() { return fInputEvent; }
any GetOutputEvent() { return fOutputEvent; }
void InitProcess();
TRestEvent* ProcessEvent(TRestEvent* eventInput);
void EndProcess();
void LoadConfig(std::string cfgFilename, std::string name = "");
void PrintMetadata() {
BeginPrintProcess();
metadata << " fMode : [" << fMode << "]";
if (fMode == 0) metadata << " --> Mode 0 activated." << endl;
if (fMode == 1) metadata << " --> Mode 1 activated." << endl;
metadata << " fcenterWidth : " << fcenterWidth << endl;
EndPrintProcess();
}
/// Returns a new instance of this class
TRestEventProcess* Maker() { return new TRestRawCommonNoiseReductionProcess; }
/// Returns the reduced process name
TString GetProcessName() { return (TString) "commonNoiseReduction"; }
// Constructor
TRestRawCommonNoiseReductionProcess();
TRestRawCommonNoiseReductionProcess(char* cfgFileName);
// Destructor
~TRestRawCommonNoiseReductionProcess();
ClassDef(TRestRawCommonNoiseReductionProcess, 1);
};
#endif
///______________________________________________________________________________
///______________________________________________________________________________
///______________________________________________________________________________
///
///
/// RESTSoft : Software for Rare Event Searches with TPCs
///
/// TRestRawDAQMetadata inherited from TRestMetadata
///
/// Load metadata of the DAQ
///
/// Jan 2016: First concept
/// Created as part of the conceptualization of existing REST
/// software.
/// JuanAn Garcia
///_______________________________________________________________________________
#ifndef RestCore_TRestRawDAQMetadata
#define RestCore_TRestRawDAQMetadata
#include <iostream>
#include "TRestMetadata.h"
#include "TString.h"
class TRestRawDAQMetadata : public TRestMetadata {
private:
void InitFromConfigFile();
virtual void Initialize();
protected:
TString fOutBinFileName;
TString fElectronicsType;
std::vector<TString> fPedBuffer; // Pedestal script
std::vector<TString> 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
public:
void PrintMetadata();
void PrintRunScript();
void PrintPedScript();
// Construtor
TRestRawDAQMetadata();
TRestRawDAQMetadata(char* cfgFileName);
// Destructor
virtual ~TRestRawDAQMetadata();
void SetScriptsBuffer();
void SetParFromPedBuffer(); // Set gain and shapping time from a given buffer
void SetOutBinFileName(TString fName) { fOutBinFileName = fName; }
UInt_t GetGain() { return fGain; }
UInt_t GetShappingTime() { return fShappingTime; }
UInt_t GetValFromString(TString var, TString line);
ClassDef(TRestRawDAQMetadata, 1); // REST run class
};
#endif
/*************************************************************************
* 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 RestCore_TRestRawFindResponseSignalProcess
#define RestCore_TRestRawFindResponseSignalProcess
#include <TRestRawSignalEvent.h>
#include "TRestEventProcess.h"
//! A process to find a representative signal to generate a response signal
class TRestRawFindResponseSignalProcess : public TRestEventProcess {
private:
TRestRawSignalEvent* fInputSignalEvent; //!
TRestRawSignalEvent* fOutputSignalEvent; //!
void Initialize();
void LoadDefaultConfig();
protected:
// add here the members of your event process
public:
any GetInputEvent() { return fInputSignalEvent; }
any GetOutputEvent() { return fOutputSignalEvent; }
void InitProcess();
TRestEvent* ProcessEvent(TRestEvent* eventInput);
void EndProcess();
void LoadConfig(std::string cfgFilename, string name = "");
void PrintMetadata() {
BeginPrintProcess();
EndPrintProcess();
}
TRestMetadata* GetProcessMetadata() { return NULL; }
TString GetProcessName() { return (TString) "findResponseSignal"; }
TRestRawFindResponseSignalProcess();
TRestRawFindResponseSignalProcess(char* cfgFileName);
~TRestRawFindResponseSignalProcess();
ClassDef(TRestRawFindResponseSignalProcess, 1);
};
#endif
/*************************************************************************
* 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 RestCore_TRestRawMemoryBufferToSignalProcess
#define RestCore_TRestRawMemoryBufferToSignalProcess
#include "TRestEventProcess.h"
#include "TRestRawSignalEvent.h"
typedef struct {
/// It allows interaction with the buffer generating process
unsigned int dataReady;
/// It stores the number of signals that have been registered in the buffer
unsigned int nSignals;
/// It stores the event id for the corresponding buffer
unsigned int eventId;
/// It stores the unix timestamp for the corresponding buffer
double timeStamp;
/// It defines the maximum number of signals used to determine the maximum
/// size of the buffer
unsigned int maxSignals;
/// It defines the maximum number of samples per signal used to determine the
/// maximum size of the buffer
unsigned int maxSamples;
/// It stores the size of the buffer, which should be maxSignals * (
/// maxSamples + 1 )
unsigned int bufferSize;
} daqInfo;
//! A process to read a shared buffer created by another external process and
//! create a TRestRawSignalEvent
class TRestRawMemoryBufferToSignalProcess : public TRestEventProcess {
private:
#ifndef __CINT__
/// A pointer to the specific TRestRawSignalEvent input
TRestRawSignalEvent* fOutputRawSignalEvent; //!
/// A pointer to the daqInfo data structure containning relevant information
/// shared by the daq
daqInfo* fShMem_daqInfo; //!
/// It is used internally to control the semaphore
int fSemaphoreId; //!
/// A pointer to a shared buffer previously created by an external process
/// (i.e. the daq).
unsigned short int* fShMem_Buffer; //!
/// A value used to generate a unique key to access the shared daqInfo
/// structure, created by a external process (i.e. the daq).
Int_t fKeyDaqInfo; //!
/// A value used to generate a unique key to control the semaphore and manage
/// access to shared resources.
Int_t fKeySemaphore; //!
/// A value used to generate a unique key to access the shared buffer, created
/// by a external process (i.e. the daq).
Int_t fKeyBuffer; //!
/// The value in microseconds used in the main event process loop to allow the
/// daq access the shared resources.
Int_t fTimeDelay; //!
/// If true the shared buffer will be re-set to zero once TRestRawSignal has
/// been loaded.
Bool_t fReset; //!
#endif
void SemaphoreGreen(int id);
void SemaphoreRed(int id);
void InitFromConfigFile();
void Initialize();
void LoadDefaultConfig();
protected:
public:
any GetInputEvent() { return any((TRestEvent*)NULL); }
any GetOutputEvent() { return fOutputRawSignalEvent; }
void InitProcess();
void BeginOfEventProcess();
TRestEvent* ProcessEvent(TRestEvent* eventInput);
void LoadConfig(std::string cfgFilename, std::string name = "");
/// It prints out the process parameters stored in the metadata structure
void PrintMetadata() {
BeginPrintProcess();
EndPrintProcess();
}
/// Returns a new instance of this class
TRestEventProcess* Maker() { return new TRestRawMemoryBufferToSignalProcess; }
/// Returns the name of this process
TString GetProcessName() { return (TString) "sharedMemoryBufferToSignalEvent"; }
// Constructor
TRestRawMemoryBufferToSignalProcess();
TRestRawMemoryBufferToSignalProcess(char* cfgFileName);
// Destructor
~TRestRawMemoryBufferToSignalProcess();
ClassDef(TRestRawMemoryBufferToSignalProcess, 1);
};
#endif
///______________________________________________________________________________
///______________________________________________________________________________
///______________________________________________________________________________
///
///
/// RESTSoft : Software for Rare Event Searches with TPCs
///
/// TRestRawMultiCoBoAsAdToSignalProcess.h
///
/// Template to use to design "event process" classes inherited from
/// TRestProcess
/// How to use: replace TRestRawMultiCoBoAsAdToSignalProcess by your
/// name, fill the required functions following instructions and add
/// all needed additional members and funcionality
///
/// May 2017: First concept
/// Created as part of the conceptualization of existing REST
/// software. Javier Galan
///_______________________________________________________________________________
#ifndef RestCore_TRestRawMultiCoBoAsAdToSignalProcess
#define RestCore_TRestRawMultiCoBoAsAdToSignalProcess
#include <map>
#include "TRestRawSignalEvent.h"
#include "TRestRawToSignalProcess.h"
#include "TRestDetectorSignalEvent.h"
struct CoBoDataFrame {
CoBoDataFrame() {
timeStamp = 0;
evId = -1;
asadId = -1;
for (int m = 0; m < 272; m++) chHit[m] = kFALSE;
for (int m = 0; m < 272; m++)
for (int l = 0; l < 512; l++) data[m][l] = 0;
}
TTimeStamp timeStamp;
Bool_t chHit[272];
Int_t data[272][512];
Int_t evId; // if equals -1, this data frame is used but have not been
// re-filled
Int_t asadId;
};
struct CoBoHeaderFrame {
CoBoHeaderFrame() {
for (int m = 0; m < 256; m++) frameHeader[m] = 0;
}
UChar_t frameHeader[256]; // 256: size of header of the cobo data frame
unsigned int frameSize;
unsigned int frameType;
unsigned int revision;
unsigned int headerSize;
unsigned int itemSize;
unsigned int nItems;
unsigned int eventIdx;
unsigned int asadIdx;
unsigned int readOffset;
unsigned int status;
Long64_t eventTime;
// TTimeStamp fEveTimeStamp;
// int fEveTimeSec;
// int fEveTimeNanoSec;
void Show() {
cout << "------ Frame Header ------" << endl;
cout << "frameSize " << frameSize << endl;
cout << "frameType " << frameType << endl;
cout << "revision " << revision << endl;
cout << "headerSize " << headerSize << endl;
cout << "itemSize " << itemSize << endl;
cout << "nItems " << nItems << endl;
cout << "eventTime " << eventTime << endl;
cout << "eventIdx " << eventIdx << endl;
cout << "asadIdx " << asadIdx << endl;
cout << "readOffset " << readOffset << endl;
cout << "status " << status << endl;
}
};
class TRestRawMultiCoBoAsAdToSignalProcess : public TRestRawToSignalProcess {
private:
#ifndef __CINT__
TRestRawSignal sgnl; //!
UChar_t frameDataP[2048]; //!///for partial readout data frame
UChar_t frameDataF[278528]; //!///for full readout data frame
TTimeStamp fStartTimeStamp; //!
std::map<int, CoBoDataFrame> fDataFrame; //!///asadId, dataframe
vector<CoBoHeaderFrame> fHeaderFrame; //!///reserves a header frame for each file
int fCurrentEvent = -1; //!
int fNextEvent = -1; //!
#endif
public:
void InitProcess();
void Initialize();
Bool_t InitializeStartTimeStampFromFilename(TString fName);
TRestEvent* ProcessEvent(TRestEvent* evInput);
void EndProcess();
Bool_t FillBuffer(Int_t n);
bool fillbuffer();
bool ReadFrameHeader(CoBoHeaderFrame& Frame);
bool ReadFrameDataP(FILE* f, CoBoHeaderFrame& hdr);
bool ReadFrameDataF(CoBoHeaderFrame& hdr);
void ClearBuffer(Int_t n);
Int_t GetLowestEventId();
Bool_t EndReading();
// Constructor
TRestRawMultiCoBoAsAdToSignalProcess();
TRestRawMultiCoBoAsAdToSignalProcess(char* cfgFileName);
// Destructor
~TRestRawMultiCoBoAsAdToSignalProcess();
ClassDef(TRestRawMultiCoBoAsAdToSignalProcess,
1); // Template for a REST "event process" class inherited from
// TRestEventProcess
};
#endif
/*************************************************************************
* This file is part of the REST software framework. *
* *
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *