diff --git a/CMakeLists.txt b/CMakeLists.txt index b75de8d..34e9858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ set(LibraryVersion "1.0") add_definitions(-DLIBRARY_VERSION="${LibraryVersion}") -COMPILELIB("") +set(deps detector) + +COMPILELIB(deps) diff --git a/inc/TRestDriftVolume.h b/inc/TRestDriftVolume.h new file mode 100644 index 0000000..4aa3c94 --- /dev/null +++ b/inc/TRestDriftVolume.h @@ -0,0 +1,8 @@ +#ifndef RestCore_TRestDriftVolume +#define RestCore_TRestDriftVolume + +#include "TRestDetectorDriftVolume.h" + +typedef TRestDetectorDriftVolume TRestDriftVolume; + +#endif \ No newline at end of file diff --git a/inc/TRestGainMap.h b/inc/TRestGainMap.h new file mode 100644 index 0000000..1d26cbc --- /dev/null +++ b/inc/TRestGainMap.h @@ -0,0 +1,9 @@ +#ifndef RestCore_TRestGainMap +#define RestCore_TRestGainMap + + +#include "TRestDetectorGainMap.h" + +typedef TRestDetectorGainMap TRestGainMap; + +#endif \ No newline at end of file diff --git a/inc/TRestGas.h b/inc/TRestGas.h new file mode 100644 index 0000000..bfe4781 --- /dev/null +++ b/inc/TRestGas.h @@ -0,0 +1,8 @@ +#ifndef RestCore_TRestGas +#define RestCore_TRestGas + +#include "TRestDetectorGas.h" + +typedef TRestDetectorGas TRestGas; + +#endif \ No newline at end of file diff --git a/inc/TRestHitsEvent.h b/inc/TRestHitsEvent.h new file mode 100644 index 0000000..d3a67ef --- /dev/null +++ b/inc/TRestHitsEvent.h @@ -0,0 +1,90 @@ + +#ifndef TRestSoft_TRestHitsEvent +#define TRestSoft_TRestHitsEvent + +#include + +#include + +#include "TArrayI.h" +#include "TAxis.h" +#include "TGraph2D.h" +#include "TH2F.h" +#include "TMath.h" +#include "TObject.h" +#include "TRestEvent.h" +#include "TRestHits.h" +#include "TVector3.h" + +//! An event data type that register a vector of TRestHits, +//! allowing us to save a 3-coordinate position and energy. +class TRestHitsEvent : public TRestEvent { + private: + /// An auxiliar TRestHits structure to register hits on XZ projection + TRestHits* fXZHits; //! + /// An auxiliar TRestHits structure to register hits on YZ projection + TRestHits* fYZHits; //! + + /// An auxiliar TRestHits structure to register hits on XYZ projection + TRestHits* fXYZHits; //! + + /// Stores the minimum x-position value. It is initialized by SetBoundaries. + Double_t fMinX; //! + /// Stores the maximum x-position value. It is initialized by SetBoundaries. + Double_t fMaxX; //! + + /// Stores the minimum y-position value. It is initialized by SetBoundaries. + Double_t fMinY; //! + /// Stores the maximum y-position value. It is initialized by SetBoundaries. + Double_t fMaxY; //! + + /// Stores the minimum z-position value. It is initialized by SetBoundaries. + Double_t fMinZ; //! + /// Stores the maximum z-position value. It is initialized by SetBoundaries. + Double_t fMaxZ; //! + + protected: + // TODO These graphs should be placed in TRestHits? + // (following similar GetGraph implementation in TRestSignal) + + /// An auxiliar TGraph pointer to visualize hits on XY-projection. + TGraph* fXYHitGraph; //! + /// An auxiliar TGraph pointer to visualize hits on XZ-projection. + TGraph* fXZHitGraph; //! + /// An auxiliar TGraph pointer to visualize hits on YZ-projection. + TGraph* fYZHitGraph; //! + + /// An auxiliar TH2F histogram to visualize hits on XY-projection. + TH2F* fXYHisto; //! + /// An auxiliar TH2F histogram to visualize hits on YZ-projection. + TH2F* fYZHisto; //! + /// An auxiliar TH2F histogram to visualize hits on XZ-projection. + TH2F* fXZHisto; //! + + TGraph2D* gxz = NULL; //! + TGraph2D* gyz = NULL; //! + + /// An auxiliar TH1F histogram to visualize hits on X-projection. + TH1F* fXHisto; //! + /// An auxiliar TH1F histogram to visualize hits on Y-projection. + TH1F* fYHisto; //! + /// An auxiliar TH1F histogram to visualize hits on Z-projection. + TH1F* fZHisto; //! + + /// The hits structure that is is saved to disk. + TRestHits fHits; // + + public: + void Initialize() { + TRestEvent::Initialize(); + fHits.RemoveHits(); + } + + // Construtor + TRestHitsEvent() {} + // Destructor + ~TRestHitsEvent() {} + + ClassDef(TRestHitsEvent, 2); +}; +#endif diff --git a/inc/TRestLegacyProcess.h b/inc/TRestLegacyProcess.h index f100ca4..20882fa 100644 --- a/inc/TRestLegacyProcess.h +++ b/inc/TRestLegacyProcess.h @@ -52,4 +52,23 @@ class TRestLegacyProcess : public TRestEventProcess { ClassDefOverride(TRestLegacyProcess, 0); }; + +#define LegacyProcessDef(thisname, newname, n) \ + any GetInputEvent() const final { return any((TRestEvent*)nullptr); } \ + any GetOutputEvent() const final { return any((TRestEvent*)nullptr); } \ + void InitProcess() final{}; \ + TRestEvent* ProcessEvent(TRestEvent* eventInput) final { \ + RESTError << "You are trying to execute a legacy process " #thisname << RESTendl; \ + RESTError << "This is not allow, this class is kept for backward compatibility" << RESTendl; \ + exit(1); \ + return nullptr; \ + } \ + void EndProcess() final{}; \ + const char* GetProcessName() const final { return #thisname; } \ + thisname() { \ + RESTWarning << "Creating legacy process " #thisname << RESTendl; \ + RESTWarning << "This process is now implemented under" #newname << RESTendl; \ + } \ + ClassDef(thisname, n) + #endif diff --git a/inc/TRestRawZeroSuppresionProcess.h b/inc/TRestRawZeroSuppresionProcess.h index a45b411..f49a6a8 100644 --- a/inc/TRestRawZeroSuppresionProcess.h +++ b/inc/TRestRawZeroSuppresionProcess.h @@ -26,7 +26,7 @@ #include "TRestLegacyProcess.h" //! A process to identify signal and remove baseline noise from a TRestRawSignalEvent. -class TRestRawZeroSuppresionProcess : public TRestLegacyProcess { +class TRestRawZeroSuppresionProcess : public TRestEventProcess { private: /// The ADC range used for baseline offset definition TVector2 fBaseLineRange; @@ -54,7 +54,7 @@ class TRestRawZeroSuppresionProcess : public TRestLegacyProcess { public: /// It prints out the process parameters stored in the metadata structure - void PrintMetadata() override { + void PrintMetadata() { BeginPrintProcess(); RESTMetadata << "Base line range definition : ( " << fBaseLineRange.X() << " , " << fBaseLineRange.Y() << " ) " << RESTendl; @@ -71,15 +71,6 @@ class TRestRawZeroSuppresionProcess : public TRestLegacyProcess { EndPrintProcess(); } - TRestRawZeroSuppresionProcess() { - RESTWarning << "Creating legacy process TRestRawZeroSuppresionProcess" << RESTendl; - RESTWarning << "This process is now implemented under TRestRawToDetectorSignalProcess" << RESTendl; - } - TRestRawZeroSuppresionProcess(char* cfgFileName) { - RESTWarning << "Creating legacy process TRestRawZeroSuppresionProcess" << RESTendl; - RESTWarning << "This process is now implemented under TRestRawToDetectorSignalProcess" << RESTendl; - } - - ClassDefOverride(TRestRawZeroSuppresionProcess, 4); + LegacyProcessDef(TRestRawZeroSuppresionProcess, TRestRawToDetectorSignalProcess, 4); }; #endif diff --git a/inc/TRestReadout.h b/inc/TRestReadout.h new file mode 100644 index 0000000..6e68ddf --- /dev/null +++ b/inc/TRestReadout.h @@ -0,0 +1,36 @@ +/************************************************************************* + * 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_TRestReadout +#define RestCore_TRestReadout + +#include + +#include "TObject.h" +#include "TRestMetadata.h" +#include "TRestDetectorReadout.h" + +/// A metadata class to generate/store a readout description. +typedef TRestDetectorReadout TRestReadout; + + +#endif diff --git a/inc/TRestReadoutChannel.h b/inc/TRestReadoutChannel.h new file mode 100644 index 0000000..de0a85a --- /dev/null +++ b/inc/TRestReadoutChannel.h @@ -0,0 +1,35 @@ +/************************************************************************* + * 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_TRestReadoutChannel +#define RestCore_TRestReadoutChannel + +#include + +#include "TObject.h" +#include "TRestMetadata.h" + +#include "TRestDetectorReadoutChannel.h" + +typedef TRestDetectorReadoutChannel TRestReadoutChannel; + +#endif diff --git a/inc/TRestReadoutMapping.h b/inc/TRestReadoutMapping.h new file mode 100644 index 0000000..0971b98 --- /dev/null +++ b/inc/TRestReadoutMapping.h @@ -0,0 +1,36 @@ +/************************************************************************* + * 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_TRestReadoutMapping +#define RestCore_TRestReadoutMapping + +#include + +#include +#include + +#include "TRestDetectorReadoutMapping.h" + +typedef TRestDetectorReadoutMapping TRestReadoutMapping; + + +#endif diff --git a/inc/TRestReadoutModule.h b/inc/TRestReadoutModule.h new file mode 100644 index 0000000..9588f76 --- /dev/null +++ b/inc/TRestReadoutModule.h @@ -0,0 +1,37 @@ +/************************************************************************* + * 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_TRestReadoutModule +#define RestCore_TRestReadoutModule + +#include + +#include +#include "TObject.h" + +#include + +#include "TRestDetectorReadoutModule.h" + +typedef TRestDetectorReadoutModule TRestReadoutModule; + +#endif diff --git a/inc/TRestReadoutPixel.h b/inc/TRestReadoutPixel.h new file mode 100644 index 0000000..92ea5d7 --- /dev/null +++ b/inc/TRestReadoutPixel.h @@ -0,0 +1,32 @@ +/************************************************************************* + * 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_TRestReadoutPixel +#define RestCore_TRestReadoutPixel + +#include + +#include "TRestDetectorReadoutPixel.h" + +typedef TRestDetectorReadoutPixel TRestReadoutPixel; + +#endif diff --git a/inc/TRestReadoutPlane.h b/inc/TRestReadoutPlane.h new file mode 100644 index 0000000..ffadf0d --- /dev/null +++ b/inc/TRestReadoutPlane.h @@ -0,0 +1,35 @@ +/************************************************************************* + * 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_TRestReadoutPlane +#define RestCore_TRestReadoutPlane + +#include + +#include "TObject.h" + +#include "TRestDetectorReadoutPlane.h" + +typedef TRestDetectorReadoutPlane TRestReadoutPlane; + + +#endif diff --git a/inc/TRestSignal.h b/inc/TRestSignal.h new file mode 100644 index 0000000..79714c0 --- /dev/null +++ b/inc/TRestSignal.h @@ -0,0 +1,176 @@ +///______________________________________________________________________________ +///______________________________________________________________________________ +///______________________________________________________________________________ +/// +/// +/// RESTSoft : Software for Rare Event Searches with TPCs +/// +/// TRestSignal.h +/// +/// Event class to store signals fromm simulation and acquisition +/// events +/// +/// sept 2015: First concept +/// Created as part of the conceptualization of existing REST +/// software. +/// JuanAn Garcia/Javier Galan +/// nov 2015: +/// Changed vectors fSignalTime and fSignalCharge from to +///< Float_t> JuanAn Garcia +///_______________________________________________________________________________ + +#ifndef RestCore_TRestSignal +#define RestCore_TRestSignal + +#include + +#include +#include +#include +#include + +class TRestSignal : public TObject { + private: + Int_t GetMinIndex(); + Int_t GetTimeIndex(Double_t t); + + protected: + Int_t fSignalID; + + std::vector fSignalTime; // Vector with the time of the signal + std::vector fSignalCharge; // Vector with the charge of the signal + + void AddPoint(TVector2 p); + void SetPoint(TVector2 p); + + public: +#ifndef __CINT__ + + TGraph* fGraph; //! + + std::vector fPointsOverThreshold; //! +#endif + + void Initialize() { + fSignalCharge.clear(); + fSignalTime.clear(); + fSignalID = -1; + } + + // TODO other objects should probably skip using GetMaxIndex direclty + Int_t GetMaxIndex(Int_t from = 0, Int_t to = 0); + + // Getters + TVector2 GetPoint(Int_t n) { + TVector2 vector2(GetTime(n), GetData(n)); + + return vector2; + } + + Int_t GetSignalID() { return fSignalID; } + Int_t GetID() { return fSignalID; } + + void IncreaseTimeBinBy(Int_t bin, Double_t data) { + if (bin >= GetNumberOfPoints()) { + std::cout << "Increase time bin: outside limits" << std::endl; + return; + } + + fSignalCharge[bin] += data; + } + + Int_t GetNumberOfPoints() { + if (fSignalTime.size() != fSignalCharge.size()) { + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "WARNING, the two vector sizes did not match" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + } + return fSignalTime.size(); + } + + Double_t GetIntegralWithTime(Double_t startTime, Double_t endTime); + Double_t GetIntegral(Int_t startBin = 0, Int_t endBin = 0); + /* +Double_t GetIntegralWithThreshold(Int_t from, Int_t to, Int_t startBaseline, Int_t endBaseline, + Double_t threshold = 2, Int_t nPointsOverThreshold = 5, + Double_t nMinSigmas = 5); +Double_t GetIntegralWithThreshold(Int_t from, Int_t to, Double_t baseline, Double_t pointThreshold, + Int_t nPointsOverThreshold, Double_t signalThreshold); + */ + + void Normalize(Double_t scale = 1.); + + std::vector GetPointsOverThreshold() { return fPointsOverThreshold; } + + Double_t GetAverage(Int_t start = 0, Int_t end = 0); + Int_t GetMaxPeakWidth(); + Double_t GetMaxPeakWithTime(Double_t startTime, Double_t endTime); + + Double_t GetMaxPeakValue(); + Double_t GetMinPeakValue(); + + Double_t GetMaxPeakTime(Int_t from = 0, Int_t to = 0); + + Double_t GetMaxValue() { return GetMaxPeakValue(); } + Double_t GetMinValue() { return GetMinPeakValue(); } + + Double_t GetMinTime(); + Double_t GetMaxTime(); + + Double_t GetData(Int_t index) { return (double)fSignalCharge[index]; } + Double_t GetTime(Int_t index) { return (double)fSignalTime[index]; } + + // Setters + void SetSignalID(Int_t sID) { fSignalID = sID; } + void SetID(Int_t sID) { fSignalID = sID; } + + void NewPoint(Float_t time, Float_t data); + void AddPoint(Double_t t, Double_t d); + void AddCharge(Double_t t, Double_t d); + void AddDeposit(Double_t t, Double_t d); + + void SetPoint(Double_t t, Double_t d); + void SetPoint(Int_t index, Double_t t, Double_t d); + + Double_t GetStandardDeviation(Int_t startBin, Int_t endBin); + Double_t GetBaseLine(Int_t startBin, Int_t endBin); + Double_t GetBaseLineSigma(Int_t startBin, Int_t endBin, Double_t baseline = 0); + + Double_t SubstractBaseline(Int_t startBin, Int_t endBin); + void AddOffset(Double_t offset); + + void MultiplySignalBy(Double_t factor); + void ExponentialConvolution(Double_t fromTime, Double_t decayTime, Double_t offset = 0); + void SignalAddition(TRestSignal* inSgnl); + + Bool_t isSorted(); + void Sort(); + + void GetDifferentialSignal(TRestSignal* diffSgnl, Int_t smearPoints = 5); + void GetSignalDelayed(TRestSignal* delayedSignal, Int_t delay); + void GetSignalSmoothed(TRestSignal* smthSignal, Int_t averagingPoints = 3); + + void GetWhiteNoiseSignal(TRestSignal* noiseSgnl, Double_t noiseLevel = 1.); + void GetSignalGaussianConvolution(TRestSignal* convSgnl, Double_t sigma = 100., Int_t nSigmas = 5); + + void AddGaussianSignal(Double_t amp, Double_t sigma, Double_t time, Int_t N, Double_t fromTime, + Double_t toTime); + + void Reset() { + fSignalTime.clear(); + fSignalCharge.clear(); + } + + void WriteSignalToTextFile(TString filename); + void Print(); + + TGraph* GetGraph(Int_t color = 1); + + // Construtor + TRestSignal(); + // Destructor + ~TRestSignal(); + + ClassDef(TRestSignal, 1); +}; +#endif diff --git a/inc/TRestSignalEvent.h b/inc/TRestSignalEvent.h new file mode 100644 index 0000000..c8f4ee7 --- /dev/null +++ b/inc/TRestSignalEvent.h @@ -0,0 +1,104 @@ +///______________________________________________________________________________ +///______________________________________________________________________________ +///______________________________________________________________________________ +/// +/// +/// RESTSoft : Software for Rare Event Searches with TPCs +/// +/// TRestSignalEvent.h +/// +/// Event class to store DAQ events either from simulation and +/// acquisition +/// +/// sept 2015: First concept +/// Created as part of the conceptualization of existing REST +/// software. +/// JuanAn Garcia +///_______________________________________________________________________________ + +#ifndef RestDAQ_TRestSignalEvent +#define RestDAQ_TRestSignalEvent + +#include + +#include +#include +#include +#include +#include +#include + +#include "TRestEvent.h" +#include "TRestSignal.h" + +class TRestSignalEvent : public TRestEvent { + protected: +#ifndef __CINT__ + Double_t fMinTime; //! + Double_t fMaxTime; //! + Double_t fMinValue; //! + Double_t fMaxValue; //! +#endif + + std::vector fSignal; // Collection of signals that define the event + + private: + void SetMaxAndMin(); + + public: + Bool_t signalIDExists(Int_t sID) { + if (GetSignalIndex(sID) == -1) return false; + return true; + } + + void SortSignals() { + for (int n = 0; n < GetNumberOfSignals(); n++) fSignal[n].Sort(); + } + + // Setters + void AddSignal(TRestSignal s); + + void AddChargeToSignal(Int_t sgnlID, Double_t tm, Double_t chrg); + + // Getters + Int_t GetNumberOfSignals() { return fSignal.size(); } + TRestSignal* GetSignal(Int_t n) { return &fSignal[n]; } + + TRestSignal* GetSignalById(Int_t sid) { + Int_t index = GetSignalIndex(sid); + if (index < 0) return NULL; + + return &fSignal[index]; + } + + Int_t GetSignalIndex(Int_t signalID); + + Double_t GetBaseLineAverage(Int_t startBin, Int_t endBin); + Double_t GetBaseLineSigmaAverage(Int_t startBin, Int_t endBin); + void SubstractBaselines(Int_t startBin, Int_t endBin); + Double_t GetIntegral(Int_t startBin = 0, Int_t endBin = 0); + // Double_t GetIntegralWithThreshold(Int_t from, Int_t to, Int_t startBaseline, Int_t endBaseline, + // Double_t nSigmas, Int_t nPointsOverThreshold, + // Double_t minPeakAmplitude); + + Double_t GetMaxValue(); + Double_t GetMinValue(); + Double_t GetMinTime(); + Double_t GetMaxTime(); + + Double_t GetIntegralWithTime(Double_t startTime, Double_t endTime); + + // Default + void Initialize(); + void PrintEvent(); + + TPad* DrawEvent(const TString& option = ""); + + // Construtor + TRestSignalEvent(); + // Destructor + ~TRestSignalEvent(); + + ClassDef(TRestSignalEvent, 1); // REST event superclass +}; +#endif diff --git a/inc/TRestSignalZeroSuppresionProcess.h b/inc/TRestSignalZeroSuppresionProcess.h new file mode 100644 index 0000000..4292c62 --- /dev/null +++ b/inc/TRestSignalZeroSuppresionProcess.h @@ -0,0 +1,85 @@ +/************************************************************************* + * 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_TRestSignalZeroSuppresionProcess +#define RestCore_TRestSignalZeroSuppresionProcess + +//#include +//#include + +#include "TRestLegacyProcess.h" + +//! A process to identify signal and remove baseline noise from a TRestRawSignalEvent. +class TRestSignalZeroSuppresionProcess : public TRestEventProcess { + private: + /// The ADC range used for baseline offset definition + TVector2 fBaseLineRange; + + /// The ADC range used for integral definition and signal identification + TVector2 fIntegralRange; + + /// Number of sigmas over baseline fluctuation to accept a point is over threshold. + Double_t fPointThreshold; + + /// A threshold parameter to accept or reject a pre-identified signal. See process description. + Double_t fSignalThreshold; + + /// Number of consecutive points over threshold required to accept a signal. + Int_t fPointsOverThreshold; + + Int_t fNPointsFlatThreshold; + + /// A parameter to determine if baseline correction has been applied by a previous process, not used + bool fBaseLineCorrection; + + /// A parameter to determine whether to cut empty events + bool fCutEmptyEvents; + + /// The ADC sampling used to transform ADC units to physical time in the output TRestSignalEvent. Given in + /// us. + Double_t fSampling; + + public: + /// It prints out the process parameters stored in the RESTMetadata structure + void PrintMetadata() { + BeginPrintProcess(); + + RESTMetadata << "Base line range definition : ( " << fBaseLineRange.X() << " , " << fBaseLineRange.Y() + << " ) " << RESTendl; + RESTMetadata << "Integral range : ( " << fIntegralRange.X() << " , " << fIntegralRange.Y() << " ) " + << RESTendl; + RESTMetadata << "Point Threshold : " << fPointThreshold << " sigmas" << RESTendl; + RESTMetadata << "Signal threshold : " << fSignalThreshold << " sigmas" << RESTendl; + RESTMetadata << "Number of points over threshold : " << fPointsOverThreshold << RESTendl; + RESTMetadata << "Sampling rate : " << 1. / fSampling << " MHz" << RESTendl; + RESTMetadata << "Max Number of points of flat signal tail : " << fNPointsFlatThreshold << RESTendl; + RESTMetadata << "Cut empty events : " << (fCutEmptyEvents ? "true" : "false") << RESTendl; + + if (fBaseLineCorrection) + RESTMetadata << "BaseLine correction is enabled for TRestRawSignalAnalysisProcess" << RESTendl; + + EndPrintProcess(); + } + + LegacyProcessDef(TRestSignalZeroSuppresionProcess, TRestRawToDetectorSignalProcess, 4); +}; +#endif diff --git a/src/TRestDriftVolume.cxx b/src/TRestDriftVolume.cxx new file mode 100644 index 0000000..72076b7 --- /dev/null +++ b/src/TRestDriftVolume.cxx @@ -0,0 +1 @@ +#include "TRestDriftVolume.h" \ No newline at end of file diff --git a/src/TRestGainMap.cxx b/src/TRestGainMap.cxx new file mode 100644 index 0000000..ba8781a --- /dev/null +++ b/src/TRestGainMap.cxx @@ -0,0 +1 @@ +#include "TRestGainMap.h" diff --git a/src/TRestGas.cxx b/src/TRestGas.cxx new file mode 100644 index 0000000..1fe460d --- /dev/null +++ b/src/TRestGas.cxx @@ -0,0 +1 @@ +#include "TRestGas.h" \ No newline at end of file diff --git a/src/TRestHitsEvent.cxx b/src/TRestHitsEvent.cxx new file mode 100644 index 0000000..cc72222 --- /dev/null +++ b/src/TRestHitsEvent.cxx @@ -0,0 +1,42 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// TRestHitsEvent is a structure that ... +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2016-March: First implementation of hits event data type into REST_v2. +/// Javier Galan +/// +/// \class TRestHitsEvent +/// \author Javier Galan +/// +///
+/// +#include "TRestHitsEvent.h" + +ClassImp(TRestHitsEvent) \ No newline at end of file diff --git a/src/TRestReadout.cxx b/src/TRestReadout.cxx new file mode 100644 index 0000000..edae262 --- /dev/null +++ b/src/TRestReadout.cxx @@ -0,0 +1,267 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This is the main RESTMetadata readout class of REST. The readout class +/// defines the methods allowing to stablish a relation between the hits +/// inside the TPC and the signals read out by the electronics daq. +/// +/// A full readout description is composed by at least one readout plane, +/// (TRestReadoutPlane), where we can place any number of readout modules +/// (TRestReadoutModule). A readout module is composed by readout channels +/// (TRestReadoutChannel) which describe the basic active detection area, +/// which can take any complex shape by combinning primitive geometry +/// elements (TRestReadoutPixel). +/// +/// REST processes such as TRestSignalToHitsProcess and +/// TRestHitsToSignalProcess use the TRestReadout class to transform the +/// spatial coordinates into raw signal data, and viceversa. +/// +/// ### Constructing the readout through an RML file +/// +/// The readout definition must be initialized through a RML file. The +/// basic RESTMetadata structure of a readout follows this scheme +/// +/// \code +///
+/// +/// +/// +/// // First, we need to construct the different readout modules we will +/// // use inside the readout plane definition. +/// +/// +/// // Later, when we construct the readout plane we will use "modName" +/// // to add the module to the readout plane definition. +/// +/// +/// +/// +/// ... +/// // Add as many pixel definitions as needed to create the channel +/// definition +/// ... +/// +/// +/// // And add as many readout channels as need to construct your +/// readout module +/// ... +/// ... +/// +/// +/// // The id number given to the readout channel is the physical +/// readout +/// // channel used inside the decoding. +/// +/// ... +/// ... +/// +/// +/// +/// +/// // If your readout is composed by modules with different size or channel +/// topologies, +/// // you will need add additional definitions here. +/// +/// // The readout plane allows to define the position, the orientation +/// (planeVector), +/// // and the position of the cathode that will define the detector active +/// volume. +/// +/// // We can then insert the modules inside each readout plane +/// // Offset +/// introduced to the daq signal channel inside the +/// decoding file. +/// +/// +/// +/// ... +/// +/// // Add as many modules as needed to construct your readout. +/// +/// +/// // If needed you may add any additional readout layers to your +/// definition adding new +/// // readout plane definitions here. +/// +/// +///
+/// \endcode +/// +/// +/// The *mappingNodes* parameter allows to specify the size of the virtual grid +/// that will be used to map the readout. The mapping allows to speed up the +/// process finding a pixel inside a module for a given x,y coordinates. +/// In general, the number of mapping nodes should be high enough so that every +/// pixel from any readout channel is associated to, or contains, a node in the +/// grid. However, as higher is the number of nodes in the mapping grid, higher +/// will be the required computation time to find a pixel for a given x,y +/// coordinates. If this value is not defined REST will try to find an optimum +/// value for this parameter. Therefore, it is recommended to do not specify +/// this parameter, except for solving readout problems or optimization +/// purposes. +/// +/// ### The decoding +/// +/// The relation between the channel number imposed by the electronic +/// acquisition and the readout channel id defined inside *readoutChannel* is +/// given to TRestReadout through a decoding file. +/// +/// The *decodingFile* parameter inside each module added to the readout plane +/// allows to set the filename (in the code above, *module.dec*) of a file +/// used to define the relation between the physical readout *id* defined +/// at each readout channel, as +/// and the daq channel number defined at the acquisition system. +/// If *no decoding* file is defined the relation between daq and readout +/// channel is assigned *one to one*. +/// The decoding file must be a text file definning two columns with as +/// many columns as the number of channels defined in the readout module. +/// The first column is the daq channel number, and the second column is +/// the readout channel defined in the RML file. +/// +/// An example of contents of a decoding file. Here 0, 1, 2, 3, ... are +/// the physical readout channels corresponding to the daq channels 67, +/// 65, 63, 61, ... +/// +/// \code +/// 67 0 +/// 65 1 +/// 63 2 +/// 61 3 +/// 59 4 +/// 57 5 +/// 54 6 +/// ... +/// ... +/// \endcode +/// +/// The channel number defined on the left column will be shifted by the +/// value *firstDaqChannel* defined when adding the readout module to the +/// readout plane. This may allow to re-use a decoding file for different +/// readout modules in case we have a repetitive connection pattern. +/// +/// ### Using the readout class +/// +/// Once TRestReadout has been initialized, through and RML file or a +/// previously stored TRestReadout class stored in a ROOT file, +/// we can find the corresponding xy-position for a given readout channel +/// id, module id, and readout plane, or the corresponding coordinates for +/// a given channel inside a module containned in a readout plane. +/// +/// The following code shows how we can identify the readout plane +/// (*planeId*), the readout module (*moduleId*), and the readout channel +/// (*chanId*) for a given x,y,z coordinates. +/// +/// \code +/// for( int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++ ) +/// { +/// // We check if the xyz coordinates are in the volume defined by +/// the readout plane modId = +/// fReadout->GetReadoutPlane(p)->isInsideDriftVolume( x, y, z ); +/// +/// // If the hit is containned in the readout, the last function +/// returns the id of the +/// // readout module that contains the x,y coordinates. +/// if( modId >= 0 ) +/// { +/// // We found the hit at planeId +/// planeId = p; +/// +/// // Then we obtain the readoutChannel *id* as defined in the +/// readout. Int_t chanId = fReadout->GetReadoutPlane( p +/// )->FindChannel( modId, x, y ); +/// +/// break; +/// } +/// } +/// \endcode +/// +/// Once we found the readout channel, we can obtain the associated daq +/// channel number, that was defined using the decoding file. +/// +/// \code +/// Int_t daqId = fReadout->GetReadoutPlane( planeId ) +/// ->GetModule( modId ) +/// ->GetChannel( chanId )->GetDaqID( ); +/// \endcode +/// +/// The other way around we can obtain the corresponding x and y coordinates for +/// a given daq channel id. The following code shows the basic idea to find +/// *signalId*. +/// +/// \code +/// for( int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++ ) +/// { +/// TRestReadoutPlane *plane = fReadout->GetReadoutPlane( p ); +/// for( int m = 0; m < plane->GetNumberOfModules(); m++ ) +/// { +/// TRestReadoutModule *mod = plane->GetModule( m ); +/// +/// // We iterate over all readout modules searching for the one +/// that contains our signal id if( mod->isDaqIDInside( signalID +/// ) ) +/// { +/// // If we find it we use the readoutModule id, and the +/// signalId corresponding +/// // to the physical readout channel and obtain the x,y +/// coordinates. +/// +/// readoutChannelID = mod->DaqToReadoutChannel( signalID ); +/// readoutModuleID = mod->GetModuleID(); +/// +/// x = plane->GetX( readoutModuleID, readoutChannelID ); +/// y = plane->GetY( readoutModuleID, readoutChannelID ); +/// break; +/// } +/// } +/// } +/// \endcode +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2015-aug: First concept. +/// Javier Galan +/// +/// \class TRestReadout +/// \author Javier Galan +/// +///
+/// +/// + +#include "TRestReadout.h" \ No newline at end of file diff --git a/src/TRestReadoutChannel.cxx b/src/TRestReadoutChannel.cxx new file mode 100644 index 0000000..4a38262 --- /dev/null +++ b/src/TRestReadoutChannel.cxx @@ -0,0 +1,44 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This class stores the readout pixel geometrical description, origin +/// position, orientation, and size. A readout pixel is the most elementary +/// component of a readout used to construct a readout channel. +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2015-aug: First concept. +/// Javier Galan +/// +/// \class TRestReadoutChannel +/// \author Javier Galan +/// +///
+/// + +#include "TRestReadoutChannel.h" \ No newline at end of file diff --git a/src/TRestReadoutMapping.cxx b/src/TRestReadoutMapping.cxx new file mode 100644 index 0000000..454a265 --- /dev/null +++ b/src/TRestReadoutMapping.cxx @@ -0,0 +1,49 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This class defines a uniform coordinate grid with XY-nodes. Each node +/// is associated to a channel and pixel from the readout module definition. +/// It is TRestReadoutModule::DoReadoutMapping the responsible to establish +/// the correspondence between nodes and the set (channel,pixel). +/// +/// In complex readouts the pixel and channel can be hard to identify. +/// This class will be used by TRestReadoutModule::FindChannel in order to +/// try to guess the pixel and channel where a given coordinate is found. +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2015-aug: First concept. +/// Javier Galan +/// +/// \class TRestReadoutMapping +/// \author Javier Galan +/// +///
+/// + +#include "TRestReadoutMapping.h" \ No newline at end of file diff --git a/src/TRestReadoutModule.cxx b/src/TRestReadoutModule.cxx new file mode 100644 index 0000000..14b0979 --- /dev/null +++ b/src/TRestReadoutModule.cxx @@ -0,0 +1,45 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This class stores the readout module geometrical description, module +/// position, orientation, and size. It contains a vector of +/// TRestReadoutChannel with the definition of the readout channels +/// existing in the readout module. +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2015-aug: First concept. +/// Javier Galan +/// +/// \class TRestReadoutModule +/// \author Javier Galan +/// +///
+/// + +#include "TRestReadoutModule.h" \ No newline at end of file diff --git a/src/TRestReadoutPixel.cxx b/src/TRestReadoutPixel.cxx new file mode 100644 index 0000000..66d37a6 --- /dev/null +++ b/src/TRestReadoutPixel.cxx @@ -0,0 +1,44 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This class stores the readout pixel geometrical description, origin +/// position, orientation, and size. A readout pixel is the most elementary +/// component of a readout used to construct a readout channel. +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2015-aug: First concept. +/// Javier Galan +/// +/// \class TRestReadoutPixel +/// \author Javier Galan +/// +///
+/// + +#include "TRestReadoutPixel.h" \ No newline at end of file diff --git a/src/TRestReadoutPlane.cxx b/src/TRestReadoutPlane.cxx new file mode 100644 index 0000000..06bdd8b --- /dev/null +++ b/src/TRestReadoutPlane.cxx @@ -0,0 +1,45 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// +/// This class stores the readout plane geometrical description, plane +/// position, orientation, and cathode position. It contains +/// a vector of TRestReadoutModule with the readout modules that are +/// implemented in the readout plane. +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2016-mar: First concept. +/// Javier Galan +/// +/// \class TRestReadoutPlane +/// \author Javier Galan +/// +///
+/// + +#include "TRestReadoutPlane.h" \ No newline at end of file diff --git a/src/TRestSignal.cxx b/src/TRestSignal.cxx new file mode 100644 index 0000000..263a9af --- /dev/null +++ b/src/TRestSignal.cxx @@ -0,0 +1,520 @@ +///______________________________________________________________________________ +///______________________________________________________________________________ +///______________________________________________________________________________ +/// +/// +/// RESTSoft : Software for Rare Event Searches with TPCs +/// +/// TRestSignal.cxx +/// +/// Event class to store signals from simulation and acquisition +/// events +/// +/// sept 2015: First concept +/// Created as part of the conceptualization of existing REST +/// software. +/// JuanAn Garcia/Javier Galan +/// nov 2015: +/// Changed vectors fSignalTime and fSignalCharge from +/// to +///< Float_t> JuanAn Garcia +// dec 2015: +// +// Javier Galan +///_______________________________________________________________________________ + +#include "TRestSignal.h" +using namespace std; + +#include +#include +#include + +ClassImp(TRestSignal) + //______________________________________________________________________________ + TRestSignal::TRestSignal() { + // TRestSignal default constructor + fGraph = NULL; + fSignalID = -1; + fSignalTime.clear(); + fSignalCharge.clear(); + + fPointsOverThreshold.clear(); +} + +//______________________________________________________________________________ +TRestSignal::~TRestSignal() { + // TRestSignal destructor +} + +void TRestSignal::NewPoint(Float_t time, Float_t data) { + fSignalTime.push_back(time); + fSignalCharge.push_back(data); +} + +void TRestSignal::AddPoint(TVector2 p) { + Int_t index = GetTimeIndex(p.X()); + Float_t x = p.X(); + Float_t y = p.Y(); + + if (index >= 0) { + fSignalTime[index] = x; + fSignalCharge[index] += y; + } else { + fSignalTime.push_back(x); + fSignalCharge.push_back(y); + } +} +void TRestSignal::SetPoint(TVector2 p) { + Int_t index = GetTimeIndex(p.X()); + Float_t x = p.X(); + Float_t y = p.Y(); + + if (index >= 0) { + fSignalTime[index] = x; + fSignalCharge[index] = y; + } else { + fSignalTime.push_back(x); + fSignalCharge.push_back(y); + } +} + +void TRestSignal::AddPoint(Double_t t, Double_t d) { + TVector2 p(t, d); + AddPoint(p); +} +void TRestSignal::AddCharge(Double_t t, Double_t d) { + TVector2 p(t, d); + AddPoint(p); +} +void TRestSignal::AddDeposit(Double_t t, Double_t d) { + TVector2 p(t, d); + AddPoint(p); +} + +void TRestSignal::SetPoint(Double_t t, Double_t d) { + TVector2 p(t, d); + SetPoint(p); +} +void TRestSignal::SetPoint(Int_t index, Double_t t, Double_t d) { + fSignalTime[index] = t; + fSignalCharge[index] = d; +} + +Double_t TRestSignal::GetIntegral(Int_t startBin, Int_t endBin) { + if (startBin < 0) startBin = 0; + if (endBin <= 0 || endBin > GetNumberOfPoints()) endBin = GetNumberOfPoints(); + + Double_t sum = 0; + for (int i = startBin; i < endBin; i++) sum += GetData(i); + + return sum; +} + +void TRestSignal::Normalize(Double_t scale) { + Double_t sum = GetIntegral(); + + for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] = scale * GetData(i) / sum; +} + +Double_t TRestSignal::GetIntegralWithTime(Double_t startTime, Double_t endTime) { + Double_t sum = 0; + for (int i = 0; i < GetNumberOfPoints(); i++) + if (GetTime(i) >= startTime && GetTime(i) < endTime) sum += GetData(i); + + return sum; +} + +Double_t TRestSignal::GetMaxPeakWithTime(Double_t startTime, Double_t endTime) { + Double_t max = -1E10; + + for (int i = 0; i < GetNumberOfPoints(); i++) + if (GetTime(i) >= startTime && GetTime(i) < endTime) { + if (this->GetData(i) > max) max = GetData(i); + } + + return max; +} + +/* {{{ +Double_t TRestSignal::GetIntegralWithThreshold(Int_t from, Int_t to, Int_t startBaseline, Int_t endBaseline, + Double_t nSigmas, Int_t nPointsOverThreshold, + Double_t nMinSigmas) { + if (startBaseline < 0) startBaseline = 0; + if (endBaseline <= 0 || endBaseline > GetNumberOfPoints()) endBaseline = GetNumberOfPoints(); + + Double_t baseLine = GetBaseLine(startBaseline, endBaseline); + + Double_t pointThreshold = nSigmas * GetBaseLineSigma(startBaseline, endBaseline); + Double_t signalThreshold = nMinSigmas * GetBaseLineSigma(startBaseline, endBaseline); + + return GetIntegralWithThreshold(from, to, baseLine, pointThreshold, nPointsOverThreshold, + signalThreshold); +} + +Double_t TRestSignal::GetIntegralWithThreshold(Int_t from, Int_t to, Double_t baseline, + Double_t pointThreshold, Int_t nPointsOverThreshold, + Double_t signalThreshold) { + Double_t sum = 0; + Int_t nPoints = 0; + fPointsOverThreshold.clear(); + + if (to > GetNumberOfPoints()) to = GetNumberOfPoints(); + + Float_t maxValue = 0; + for (int i = from; i < to; i++) { + if (GetData(i) > baseline + pointThreshold) { + if (GetData(i) > maxValue) maxValue = GetData(i); + nPoints++; + } else { + if (nPoints >= nPointsOverThreshold) { + Double_t sig = GetStandardDeviation(i - nPoints, i); + if (sig > signalThreshold) { + for (int j = i - nPoints; j < i; j++) { + sum += this->GetData(j); + fPointsOverThreshold.push_back(j); + } + } + } + nPoints = 0; + maxValue = 0; + } + } + + if (nPoints >= nPointsOverThreshold) { + Double_t sig = GetStandardDeviation(to - nPoints, to); + if (sig > signalThreshold) { + for (int j = to - nPoints; j < to; j++) { + sum += this->GetData(j); + fPointsOverThreshold.push_back(j); + } + } + } + + return sum; +} +}}} */ + +Double_t TRestSignal::GetAverage(Int_t start, Int_t end) { + this->Sort(); + + if (end == 0) end = this->GetNumberOfPoints(); + + Double_t sum = 0; + for (int i = start; i <= end; i++) { + sum += this->GetData(i); + } + return sum / (end - start + 1); +} + +Int_t TRestSignal::GetMaxPeakWidth() { + this->Sort(); + + Int_t mIndex = this->GetMaxIndex(); + Double_t maxValue = this->GetData(mIndex); + + Double_t value = maxValue; + Int_t rightIndex = mIndex; + while (value > maxValue / 2) { + value = this->GetData(rightIndex); + rightIndex++; + } + Int_t leftIndex = mIndex; + value = maxValue; + while (value > maxValue / 2) { + value = this->GetData(leftIndex); + leftIndex--; + } + + return rightIndex - leftIndex; +} + +Double_t TRestSignal::GetMaxPeakValue() { return GetData(GetMaxIndex()); } + +Int_t TRestSignal::GetMaxIndex(Int_t from, Int_t to) { + Double_t max = -1E10; + Int_t index = 0; + + if (from < 0) from = 0; + if (to > GetNumberOfPoints()) to = GetNumberOfPoints(); + + if (to == 0) to = GetNumberOfPoints(); + + for (int i = from; i < to; i++) { + if (this->GetData(i) > max) { + max = GetData(i); + index = i; + } + } + + return index; +} + +Double_t TRestSignal::GetMaxPeakTime(Int_t from, Int_t to) { return GetTime(GetMaxIndex(from, to)); } + +Double_t TRestSignal::GetMinPeakValue() { return GetData(GetMinIndex()); } + +Int_t TRestSignal::GetMinIndex() { + Double_t min = 1E10; + Int_t index = 0; + + for (int i = 0; i < GetNumberOfPoints(); i++) { + if (this->GetData(i) < min) { + min = GetData(i); + index = i; + } + } + + return index; +} + +Double_t TRestSignal::GetMinTime() { + Double_t minTime = 1E10; + for (int n = 0; n < GetNumberOfPoints(); n++) + if (minTime > fSignalTime[n]) minTime = fSignalTime[n]; + + return minTime; +} + +Double_t TRestSignal::GetMaxTime() { + Double_t maxTime = -1E10; + for (int n = 0; n < GetNumberOfPoints(); n++) + if (maxTime < fSignalTime[n]) maxTime = fSignalTime[n]; + + return maxTime; +} + +Int_t TRestSignal::GetTimeIndex(Double_t t) { + Float_t time = t; + + for (int n = 0; n < GetNumberOfPoints(); n++) + if (time == fSignalTime[n]) return n; + return -1; +} + +Bool_t TRestSignal::isSorted() { + for (int i = 0; i < GetNumberOfPoints() - 1; i++) { + if (GetTime(i + 1) < GetTime(i)) return false; + } + return true; +} + +void TRestSignal::Sort() { + while (!isSorted()) { + for (int i = 0; i < GetNumberOfPoints(); i++) { + for (int j = i; j < GetNumberOfPoints(); j++) { + if (GetTime(i) > GetTime(j)) { + iter_swap(fSignalTime.begin() + i, fSignalTime.begin() + j); + iter_swap(fSignalCharge.begin() + i, fSignalCharge.begin() + j); + } + } + } + } +} + +void TRestSignal::GetDifferentialSignal(TRestSignal* diffSgnl, Int_t smearPoints) { + this->Sort(); + + for (int i = 0; i < smearPoints; i++) diffSgnl->AddPoint(GetTime(i), 0); + + for (int i = smearPoints; i < this->GetNumberOfPoints() - smearPoints; i++) { + Double_t value = (this->GetData(i + smearPoints) - GetData(i - smearPoints)) / + (GetTime(i + smearPoints) - GetTime(i - smearPoints)); + Double_t time = (GetTime(i + smearPoints) + GetTime(i - smearPoints)) / 2.; + + diffSgnl->AddPoint(time, value); + } + + for (int i = GetNumberOfPoints() - smearPoints; i < GetNumberOfPoints(); i++) + diffSgnl->AddPoint(GetTime(i), 0); +} + +void TRestSignal::GetSignalDelayed(TRestSignal* delayedSignal, Int_t delay) { + this->Sort(); + + for (int i = 0; i < delay; i++) delayedSignal->AddPoint(GetTime(i), GetData(i)); + + for (int i = delay; i < GetNumberOfPoints(); i++) delayedSignal->AddPoint(GetTime(i), GetData(i - delay)); +} + +void TRestSignal::GetSignalSmoothed(TRestSignal* smthSignal, Int_t averagingPoints) { + this->Sort(); + + averagingPoints = (averagingPoints / 2) * 2 + 1; // make it odd >= averagingPoints + + Double_t sum = GetIntegral(0, averagingPoints); + for (int i = 0; i <= averagingPoints / 2; i++) smthSignal->AddPoint(GetTime(i), sum / averagingPoints); + + for (int i = averagingPoints / 2 + 1; i < GetNumberOfPoints() - averagingPoints / 2; i++) { + sum -= this->GetData(i - (averagingPoints / 2 + 1)); + sum += this->GetData(i + averagingPoints / 2); + smthSignal->AddPoint(this->GetTime(i), sum / averagingPoints); + } + + for (int i = GetNumberOfPoints() - averagingPoints / 2; i < GetNumberOfPoints(); i++) + smthSignal->AddPoint(GetTime(i), sum / averagingPoints); +} + +Double_t TRestSignal::GetBaseLine(Int_t startBin, Int_t endBin) { + if (endBin - startBin <= 0) return 0.; + + Double_t baseLine = 0; + for (int i = startBin; i < endBin; i++) baseLine += fSignalCharge[i]; + + return baseLine / (endBin - startBin); +} + +Double_t TRestSignal::GetStandardDeviation(Int_t startBin, Int_t endBin) { + Double_t bL = GetBaseLine(startBin, endBin); + return GetBaseLineSigma(startBin, endBin, bL); +} + +Double_t TRestSignal::GetBaseLineSigma(Int_t startBin, Int_t endBin, Double_t baseline) { + Double_t bL = baseline; + if (bL == 0) bL = GetBaseLine(startBin, endBin); + + Double_t baseLineSigma = 0; + for (int i = startBin; i < endBin; i++) + baseLineSigma += (bL - fSignalCharge[i]) * (bL - fSignalCharge[i]); + + return TMath::Sqrt(baseLineSigma / (endBin - startBin)); +} + +Double_t TRestSignal::SubstractBaseline(Int_t startBin, Int_t endBin) { + Double_t bL = GetBaseLine(startBin, endBin); + + AddOffset(-bL); + + return bL; +} + +void TRestSignal::AddOffset(Double_t offset) { + for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] = fSignalCharge[i] + offset; +} + +void TRestSignal::MultiplySignalBy(Double_t factor) { + for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] = factor * fSignalCharge[i]; +} + +void TRestSignal::ExponentialConvolution(Double_t fromTime, Double_t decayTime, Double_t offset) { + for (int i = 0; i < GetNumberOfPoints(); i++) { + if (fSignalTime[i] > fromTime) + fSignalCharge[i] = + (fSignalCharge[i] - offset) * exp(-(fSignalTime[i] - fromTime) / decayTime) + offset; + } +} + +void TRestSignal::SignalAddition(TRestSignal* inSgnl) { + if (this->GetNumberOfPoints() != inSgnl->GetNumberOfPoints()) { + cout << "ERROR : I cannot add two signals with different number of points" << endl; + return; + } + + Int_t badSignalTimes = 0; + + for (int i = 0; i < GetNumberOfPoints(); i++) + if (GetTime(i) != inSgnl->GetTime(i)) { + cout << "Time : " << GetTime(i) << " != " << inSgnl->GetTime(i) << endl; + badSignalTimes++; + } + + if (badSignalTimes) { + cout << "ERROR : The times of signal addition must be the same" << endl; + return; + } + + for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] += inSgnl->GetData(i); +} + +void TRestSignal::AddGaussianSignal(Double_t amp, Double_t sigma, Double_t time, Int_t N, Double_t fromTime, + Double_t toTime) { + for (int i = 0; i < N; i++) { + Double_t tme = fromTime + (double)i / (N - 1) * (toTime - fromTime); + + Double_t dta = 300 + amp * TMath::Exp(-0.5 * (tme - time) * (tme - time) / sigma / sigma); + + cout << "T : " << tme << " D : " << dta << endl; + AddPoint(tme, dta); + } +} + +void TRestSignal::GetWhiteNoiseSignal(TRestSignal* noiseSgnl, Double_t noiseLevel) { + this->Sort(); + + for (int i = 0; i < GetNumberOfPoints(); i++) { + TRandom3* fRandom = new TRandom3(0); + + noiseSgnl->AddPoint(GetTime(i), GetData(i) + fRandom->Gaus(0, noiseLevel)); + + delete fRandom; + } +} + +void TRestSignal::GetSignalGaussianConvolution(TRestSignal* convSgnl, Double_t sigma, Int_t nSigmas) { + this->Sort(); + + Int_t nPoints = GetMaxTime() - GetMinTime(); + TF1* fGaus = new TF1("fGauss", "exp(-0.5*((x-[1])/[2])**2)", -nPoints, nPoints); + sigma = sigma * 1000.; // conversion to nanoseconds + fGaus->SetParameter(2, sigma); // the width of the gaussian is set + + Double_t totChargeInitial = 0.; + Double_t totChargeFinal = 0.; + + Double_t sum; + + // We calculate the charge of the event before convolution + for (int i = 0; i < GetNumberOfPoints(); i++) totChargeInitial += fSignalCharge[i]; + + // The gaussian convolution of the initial signal is performed + for (int i = GetMinTime() - nSigmas * sigma; i < GetMaxTime() + nSigmas * sigma; i++) { + for (int j = 0; j < GetNumberOfPoints(); j++) { + if (TMath::Abs(i - GetTime(j)) > nSigmas * sigma) continue; + if (TMath::Abs(i - GetTime(j)) > nSigmas * sigma && i < GetTime(j)) break; + + fGaus->SetParameter(1, GetTime(j)); + sum = fSignalCharge[j] / TMath::Sqrt(2. * TMath::Pi()) / sigma * fGaus->Integral(i, i + 1); + + convSgnl->AddPoint(i, sum); + totChargeFinal += sum; + } + } + + cout << "Initial charge of the pulse " << totChargeInitial << endl; + cout << "Final charge of the pulse " << totChargeFinal << endl; +} + +void TRestSignal::WriteSignalToTextFile(TString filename) { + FILE* fff = fopen(filename.Data(), "w"); + for (int i = 0; i < GetNumberOfPoints(); i++) fprintf(fff, "%e\t%e\n", GetTime(i), GetData(i)); + fclose(fff); +} + +void TRestSignal::Print() { + for (int i = 0; i < GetNumberOfPoints(); i++) + cout << "Time : " << GetTime(i) << " Charge : " << GetData(i) << endl; +} + +TGraph* TRestSignal::GetGraph(Int_t color) { + if (fGraph != NULL) { + delete fGraph; + fGraph = NULL; + } + + fGraph = new TGraph(); + + // cout << "Signal ID " << this->GetSignalID( ) << " points " << + // this->GetNumberOfPoints() << endl; + + fGraph->SetLineWidth(2); + fGraph->SetLineColor(color); + fGraph->SetMarkerStyle(7); + + int points = 0; + for (int n = 0; n < GetNumberOfPoints(); n++) { + fGraph->SetPoint(points, GetTime(n), GetData(n)); + points++; + } + + return fGraph; +} diff --git a/src/TRestSignalEvent.cxx b/src/TRestSignalEvent.cxx new file mode 100644 index 0000000..5012973 --- /dev/null +++ b/src/TRestSignalEvent.cxx @@ -0,0 +1,240 @@ +//______________________________________________________________________________ +///______________________________________________________________________________ +///______________________________________________________________________________ +/// +/// +/// RESTSoft : Software for Rare Event Searches with TPCs +/// +/// TRestSignalEvent.h +/// +/// Event class to store DAQ events either from simulation and +/// acquisition +/// +/// sept 2015: First concept +/// Created as part of the conceptualization of existing REST +/// software. +/// JuanAn Garcia/Javier Galan +/// +/// feb 2016: Added titles to axis in DrawGraph using TMultiGraph +/// Javier Gracia +///_______________________________________________________________________________ + +#include + +#include "TRestRun.h" +#include "TRestSignalEvent.h" +using namespace std; + +ClassImp(TRestSignalEvent) + //______________________________________________________________________________ + TRestSignalEvent::TRestSignalEvent() { + // TRestSignalEvent default constructor + RESTWarning << "Creating legacy event TRestSignalEvent" << RESTendl; + RESTWarning << "This event is now named TRestDetectorSignalEvent" << RESTendl; + Initialize(); +} + +//______________________________________________________________________________ +TRestSignalEvent::~TRestSignalEvent() { + // TRestSignalEvent destructor +} + +void TRestSignalEvent::Initialize() { + TRestEvent::Initialize(); + fSignal.clear(); + fPad = NULL; + fMinValue = 1E10; + fMaxValue = -1E10; + fMinTime = 1E10; + fMaxTime = -1E10; +} + +void TRestSignalEvent::AddSignal(TRestSignal s) { + if (signalIDExists(s.GetSignalID())) { + cout << "Warning. Signal ID : " << s.GetSignalID() + << " already exists. Signal will not be added to signal event" << endl; + return; + } + + fSignal.push_back(s); +} + +Int_t TRestSignalEvent::GetSignalIndex(Int_t signalID) { + for (int i = 0; i < GetNumberOfSignals(); i++) + if (fSignal[i].GetSignalID() == signalID) return i; + return -1; +} + +Double_t TRestSignalEvent::GetIntegral(Int_t startBin, Int_t endBin) { + Double_t sum = 0; + + for (int i = 0; i < GetNumberOfSignals(); i++) sum += fSignal[i].GetIntegral(startBin, endBin); + + return sum; +} + +Double_t TRestSignalEvent::GetIntegralWithTime(Double_t startTime, Double_t endTime) { + Double_t sum = 0; + for (int n = 0; n < GetNumberOfSignals(); n++) sum += fSignal[n].GetIntegralWithTime(startTime, endTime); + + return sum; +} + +/* +Double_t TRestSignalEvent::GetIntegralWithThreshold(Int_t from, Int_t to, Int_t startBaseline, + Int_t endBaseline, Double_t nSigmas, + Int_t nPointsOverThreshold, Double_t minPeakAmplitude) { + Double_t sum = 0; + + for (int i = 0; i < GetNumberOfSignals(); i++) + sum += fSignal[i].GetIntegralWithThreshold(from, to, startBaseline, endBaseline, nSigmas, + nPointsOverThreshold, minPeakAmplitude); + + return sum; +} +*/ + +Double_t TRestSignalEvent::GetBaseLineAverage(Int_t startBin, Int_t endBin) { + Double_t baseLineMean = 0; + + for (int sgnl = 0; sgnl < GetNumberOfSignals(); sgnl++) { + Double_t baseline = GetSignal(sgnl)->GetBaseLine(startBin, endBin); + baseLineMean += baseline; + } + + return baseLineMean / GetNumberOfSignals(); +} + +Double_t TRestSignalEvent::GetBaseLineSigmaAverage(Int_t startBin, Int_t endBin) { + Double_t baseLineSigmaMean = 0; + + for (int sgnl = 0; sgnl < GetNumberOfSignals(); sgnl++) { + Double_t baselineSigma = GetSignal(sgnl)->GetBaseLineSigma(startBin, endBin); + baseLineSigmaMean += baselineSigma; + } + + return baseLineSigmaMean / GetNumberOfSignals(); +} + +void TRestSignalEvent::SubstractBaselines(Int_t startBin, Int_t endBin) { + for (int sgnl = 0; sgnl < GetNumberOfSignals(); sgnl++) + GetSignal(sgnl)->SubstractBaseline(startBin, endBin); +} + +void TRestSignalEvent::AddChargeToSignal(Int_t sgnlID, Double_t tm, Double_t chrg) { + Int_t sgnlIndex = GetSignalIndex(sgnlID); + if (sgnlIndex == -1) { + sgnlIndex = GetNumberOfSignals(); + + TRestSignal sgnl; + sgnl.SetSignalID(sgnlID); + AddSignal(sgnl); + } + + fSignal[sgnlIndex].AddDeposit(tm, chrg); +} + +void TRestSignalEvent::PrintEvent() { + TRestEvent::PrintEvent(); + + for (int i = 0; i < GetNumberOfSignals(); i++) { + cout << "================================================" << endl; + cout << "Signal ID : " << fSignal[i].GetSignalID() << endl; + cout << "Integral : " << fSignal[i].GetIntegral() << endl; + cout << "------------------------------------------------" << endl; + fSignal[i].Print(); + cout << "================================================" << endl; + } +} + +// TODO: GetMaxTimeFast, GetMinTimeFast, GetMaxValueFast that return the value +// of fMinTime, fMaxTime, etc +void TRestSignalEvent::SetMaxAndMin() { + fMinValue = 1E10; + fMaxValue = -1E10; + fMinTime = 1E10; + fMaxTime = -1E10; + + for (int s = 0; s < GetNumberOfSignals(); s++) { + if (fMinTime > fSignal[s].GetMinTime()) fMinTime = fSignal[s].GetMinTime(); + if (fMaxTime < fSignal[s].GetMaxTime()) fMaxTime = fSignal[s].GetMaxTime(); + + if (fMinValue > fSignal[s].GetMinValue()) fMinValue = fSignal[s].GetMinValue(); + if (fMaxValue < fSignal[s].GetMaxValue()) fMaxValue = fSignal[s].GetMaxValue(); + } +} + +Double_t TRestSignalEvent::GetMaxValue() { + SetMaxAndMin(); + return fMaxValue; +} + +Double_t TRestSignalEvent::GetMinValue() { + SetMaxAndMin(); + return fMinValue; +} + +Double_t TRestSignalEvent::GetMinTime() { + Double_t minTime = 1.e10; + for (int s = 0; s < GetNumberOfSignals(); s++) + if (minTime > fSignal[s].GetMinTime()) minTime = fSignal[s].GetMinTime(); + return minTime; +} + +Double_t TRestSignalEvent::GetMaxTime() { + Double_t maxTime = -1.e10; + for (int s = 0; s < GetNumberOfSignals(); s++) + if (maxTime < fSignal[s].GetMaxTime()) maxTime = fSignal[s].GetMaxTime(); + return maxTime; +} + +// Draw current event in a Tpad +TPad* TRestSignalEvent::DrawEvent(const TString& option) { + if (fPad != NULL) { + delete fPad; + fPad = NULL; + } + + int nSignals = this->GetNumberOfSignals(); + + if (nSignals == 0) { + cout << "Empty event " << endl; + return NULL; + } + + fMinValue = 1E10; + fMaxValue = -1E10; + fMinTime = 1E10; + fMaxTime = -1E10; + + fPad = new TPad(this->GetName(), " ", 0, 0, 1, 1); + fPad->Draw(); + fPad->cd(); + fPad->DrawFrame(GetMinTime(), GetMinValue(), GetMaxTime(), GetMaxValue()); + + char title[256]; + sprintf(title, "Event ID %d", this->GetID()); + + TMultiGraph* mg = new TMultiGraph(); + mg->SetTitle(title); + mg->GetXaxis()->SetTitle("Time [us]"); + mg->GetXaxis()->SetTitleOffset(1.1); + mg->GetYaxis()->SetTitle("Amplitude [a.u.]"); + mg->GetYaxis()->SetTitleOffset(0.8); + + mg->GetYaxis()->SetTitleSize(1.4 * mg->GetYaxis()->GetTitleSize()); + mg->GetXaxis()->SetTitleSize(1.4 * mg->GetXaxis()->GetTitleSize()); + mg->GetYaxis()->SetLabelSize(1.25 * mg->GetYaxis()->GetLabelSize()); + mg->GetXaxis()->SetLabelSize(1.25 * mg->GetXaxis()->GetLabelSize()); + + for (int n = 0; n < nSignals; n++) { + TGraph* gr = fSignal[n].GetGraph(n + 1); + + mg->Add(gr); + } + + fPad->cd(); + mg->Draw(""); + + return fPad; +} diff --git a/src/TRestSignalZeroSuppresionProcess.cxx b/src/TRestSignalZeroSuppresionProcess.cxx new file mode 100644 index 0000000..41395df --- /dev/null +++ b/src/TRestSignalZeroSuppresionProcess.cxx @@ -0,0 +1,89 @@ +/************************************************************************* + * 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. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +/// The TRestSignalZeroSuppresionProcess identifies the points that are over +/// threshold from the input TRestRawSignalEvent. The resulting points, that +/// are presumed to be a physical signal, will be transported to the output +/// TRestSignalEvent returned by this process. The data points transferred to +/// the output TRestSignalEvent will have physical time units related to the +/// sampling rate of the raw signal received as input, and defined as a +/// parameter in this process. +/// +/// The different parameters required by this process are: +/// * baselineRange : A 2D-vector definning the range, in number of bins, +/// where the baseline properties will be calculated. +/// * integralRange : A 2D-vector definning the time window, in number of bins, +/// where the signal will be considered. +/// * pointThreshold : The number of sigmas over the baseline flunctuations to +/// consider a point is over the threshold. +/// * pointsOverThreshold : The number of consecutive points over threshold +/// required to consider them as a physical signal. +/// * signalThreshold : The number of sigmas a set of consecutive points +/// identified over threshold must be over the baseline fluctuations to be +/// finally considered a physical signal. +/// * pointsFlatThreshold : A parameter to help removing the un-physical or +/// un-expected tail that follows the physical signal. \TODO more details? +/// * sampling : The time duration of a time bin from the input TRestRawSignalEvent. +/// If no units are specified, the default units, microseconds, will be +/// considered. +/// +/// \TODO Add description of observables here. +/// +/// +/// An example of definition of this process inside a data processing chain, +/// inside the `` section. +/// +/// The values given between `${}` are enviroment variables that can be defined +/// at the system or at the `` section. See also TRestMetadata for +/// additional details. +/// +/// \code +/// +/// \endcode +/// +///-------------------------------------------------------------------------- +/// +/// RESTsoft - Software for Rare Event Searches with TPCs +/// +/// History of developments: +/// +/// 2016-January: Conception and implementation of signal zero suppression +/// process. +/// Javier Galan +/// +/// \class TRestSignalZeroSuppresionProcess +/// \author Javier Galan +/// \author Kaixiang Ni +/// +///
+/// + +#include "TRestSignalZeroSuppresionProcess.h" \ No newline at end of file