Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added testing boilerplate, basic tests and global formatting #51

Merged
merged 11 commits into from
Apr 5, 2022
110 changes: 55 additions & 55 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: nkx1231/root6-geant4-garfield:0.8
image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics

stages:
- pre-build
Expand All @@ -8,42 +8,42 @@ stages:
- externalPcs

before_script:
- export USER="raw"
- pwd
- echo $CI_SERVER_HOST
- echo $CRONJOB
- export HOME=${CI_PROJECT_DIR}/install/
- if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi
- if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi
- root-config --version
- if [ -f "/opt/geant4/install/bin/geant4.sh" ]; then source /opt/geant4/install/bin/geant4.sh; fi
- geant4-config --version
- if [ -d "/opt/garfieldpp/install" ]; then export GARFIELD_HOME=/opt/garfieldpp/install; fi
- if [ -d "/opt/garfieldpp/install" ]; then export HEED_DATABASE=$GARFIELD_HOME/Heed/heed++/database; fi
- if [ -d "/opt/garfieldpp/install" ]; then export LD_LIBRARY_PATH=$GARFIELD_HOME/lib:$LD_LIBRARY_PATH; fi
- ls $GARFIELD_HOME
- python3 --version
- apt update && apt install -y wget
- export USER="raw"
- pwd
- echo $CI_SERVER_HOST
- echo $CRONJOB
- export HOME=${CI_PROJECT_DIR}/install/
- if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi
- if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi
- root-config --version
- if [ -f "/opt/geant4/install/bin/geant4.sh" ]; then source /opt/geant4/install/bin/geant4.sh; fi
- geant4-config --version
- if [ -d "/opt/garfieldpp/install" ]; then export GARFIELD_HOME=/opt/garfieldpp/install; fi
- if [ -d "/opt/garfieldpp/install" ]; then export HEED_DATABASE=$GARFIELD_HOME/Heed/heed++/database; fi
- if [ -d "/opt/garfieldpp/install" ]; then export LD_LIBRARY_PATH=$GARFIELD_HOME/lib:$LD_LIBRARY_PATH; fi
- ls $GARFIELD_HOME
- python3 --version
- apt update && apt install -y wget

clang-format:
stage: pre-build
script:
- echo "**$CRONJOB**"
- echo "**$CI_SERVER_HOST**"
- cd ${CI_PROJECT_DIR}/pipeline/clang-format/
- ./clangformattest.sh
# We execute only at a schedulled pipeline that defines CRONJOB variable
only:
variables:
- $CRONJOB
stage: pre-build
script:
- echo "**$CRONJOB**"
- echo "**$CI_SERVER_HOST**"
- cd ${CI_PROJECT_DIR}/pipeline/clang-format/
- ./clangformattest.sh
# We execute only at a scheduled pipeline that defines CRONJOB variable
only:
variables:
- $CRONJOB

validateLibrary:
stage: pre-build
script:
- python3 pipeline/validateLibrary.py .
Validate Library:
stage: pre-build
script:
- python3 pipeline/validateLibrary.py .

build:
type: build
Build:
stage: build
script:
- echo "**${CI_PROJECT_DIR}**"
- rm -rf ${CI_PROJECT_DIR}/install
Expand All @@ -69,65 +69,65 @@ build:
- ${CI_PROJECT_DIR}/framework/build
expire_in: 1 day

loadRESTLibs:
type: loadRESTLibs
Load REST Libraries:
stage: loadRESTLibs
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- restRoot -b -q

addSignalNoise:
type: process
Add Signal Noise:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/noise
- python addNoise.py
commonNoise:
type: process

Common Noise:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/commonNoise
- restRoot -b -q commonNoise.C

vetoAnalysis:
type: process
Veto Analysis:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/veto
- restManager --c veto.rml --f ../../data/R01208_Ar2Iso_Background14h_14Vetos_IccubFEC-000.aqs
- python vetoValidation.py
- python vetoValidation.py

signalShaping:
type: process
Signal Shaping:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/shaping
- restRoot -b -q shaping.C
fittingProcess:
type: process

Fitting Process:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/fit
- restRoot -b -q fit.C
generalFitProcess:
type: process

General Fit Process:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/fit
- restRoot -b -q GeneralFit.C

analysisProcess:
type: process
Analysis Process:
stage: process
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/processes/analysis
- restManager --c veto.rml --f ../../data/R01208_Ar2Iso_Background14h_14Vetos_IccubFEC-000.aqs
- restRoot -b -q validate.C

dreamData:
type: externalPcs
Dream Data:
stage: externalPcs
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/external/dream
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
set( LibraryVersion "1.5" )
set(LibraryVersion "1.5")
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")

COMPILELIB("")

file(GLOB_RECURSE MAC "${CMAKE_CURRENT_SOURCE_DIR}/macros/*")
INSTALL(FILES ${MAC} DESTINATION ./macros/raw)

ADD_LIBRARY_TEST()
2 changes: 1 addition & 1 deletion inc/TRestRawAFTERToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TRestRawAFTERToSignalProcess : public TRestRawToSignalProcess {
void InitProcess();
TRestEvent* ProcessEvent(TRestEvent* evInput);
TString GetProcessName() { return (TString) "AFTERToSignal"; }
TRestMetadata* GetProcessMetadata() { return NULL; }
TRestMetadata* GetProcessMetadata() { return nullptr; }

Bool_t isExternal() { return true; }

Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawCommonNoiseReductionProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "TRestEventProcess.h"
#include "TRestRawSignal.h"

//! A process to substract the common channels noise from RawSignal type
//! A process to subtract the common channels noise from RawSignal type
class TRestRawCommonNoiseReductionProcess : public TRestEventProcess {
private:
/// A pointer to the specific TRestRawSignalEvent input
Expand Down
4 changes: 2 additions & 2 deletions inc/TRestRawDAQMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class TRestRawDAQMetadata : public TRestMetadata {
void PrintRunScript();
void PrintPedScript();

// Construtor
// Constructor
TRestRawDAQMetadata();
TRestRawDAQMetadata(char* cfgFileName);
// Destructor
virtual ~TRestRawDAQMetadata();

void SetScriptsBuffer();
void SetParFromPedBuffer(); // Set gain and shapping time from a given buffer
void SetParFromPedBuffer(); // Set gain and shaping time from a given buffer
void SetOutBinFileName(TString fName) { fOutBinFileName = fName; }

UInt_t GetGain() { return fGain; }
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawFFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TRestRawFFT : public TObject {
void WriteFrequencyToTextFile(TString filename);
void WriteTimeSignalToTextFile(TString filename);

// Construtor
// Constructor
TRestRawFFT();
// Destructor
~TRestRawFFT();
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawFindResponseSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TRestRawFindResponseSignalProcess : public TRestEventProcess {
EndPrintProcess();
}

TRestMetadata* GetProcessMetadata() { return NULL; }
TRestMetadata* GetProcessMetadata() { return nullptr; }

TString GetProcessName() { return (TString) "findResponseSignal"; }

Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawMemoryBufferToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TRestRawMemoryBufferToSignalProcess : public TRestEventProcess {

protected:
public:
any GetInputEvent() { return any((TRestEvent*)NULL); }
any GetInputEvent() { return any((TRestEvent*)nullptr); }
any GetOutputEvent() { return fOutputRawSignalEvent; }

void InitProcess();
Expand Down
20 changes: 11 additions & 9 deletions inc/TRestRawMultiCoBoAsAdToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ struct 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;
for (bool& m : chHit) m = kFALSE;
for (auto& m : data) {
for (int& l : m) {
l = 0;
}
}
}
TTimeStamp timeStamp;
Bool_t chHit[272];
Expand All @@ -49,7 +51,9 @@ struct CoBoDataFrame {

struct CoBoHeaderFrame {
CoBoHeaderFrame() {
for (int m = 0; m < 256; m++) frameHeader[m] = 0;
for (unsigned char& m : frameHeader) {
m = 0;
}
// 4294967295 == -1 --> ends reading
// 4294967294 == -2 --> just initialized
eventIdx = (unsigned int)4294967294;
Expand Down Expand Up @@ -93,7 +97,7 @@ struct CoBoHeaderFrame {
class TRestRawMultiCoBoAsAdToSignalProcess : public TRestRawToSignalProcess {
private:
#ifndef __CINT__
TRestRawSignal sgnl; //!
TRestRawSignal signal; //!

UChar_t frameDataP[2048]; //!///for partial readout data frame
UChar_t frameDataF[278528]; //!///for full readout data frame
Expand Down Expand Up @@ -138,8 +142,6 @@ class TRestRawMultiCoBoAsAdToSignalProcess : public TRestRawToSignalProcess {
// Destructor
~TRestRawMultiCoBoAsAdToSignalProcess();

ClassDef(TRestRawMultiCoBoAsAdToSignalProcess,
1); // Template for a REST "event process" class inherited from
// TRestEventProcess
ClassDef(TRestRawMultiCoBoAsAdToSignalProcess, 1);
};
#endif
2 changes: 1 addition & 1 deletion inc/TRestRawSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TRestRawSignal : public TObject {
void SetTailPoints(Int_t p) { fTailPoints = p; }

/// It sets/constrains the range for any calculation.
void SetRange(TVector2 rng) { fRange = rng; }
void SetRange(TVector2 range) { fRange = range; }

void SetRangeToMax() { fRange = TVector2(0, GetNumberOfPoints()); }

Expand Down
5 changes: 2 additions & 3 deletions inc/TRestRawSignalAddNoiseProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TRestRawSignalAddNoiseProcess : public TRestEventProcess {
EndPrintProcess();
}

TRestMetadata* GetProcessMetadata() { return NULL; }
TRestMetadata* GetProcessMetadata() { return nullptr; }

TString GetProcessName() { return (TString) "rawSignalAddNoise"; }

Expand All @@ -70,7 +70,6 @@ class TRestRawSignalAddNoiseProcess : public TRestEventProcess {
// Destructor
~TRestRawSignalAddNoiseProcess();

ClassDef(TRestRawSignalAddNoiseProcess, 1); // Template for a REST "event process" class inherited from
// TRestEventProcess
ClassDef(TRestRawSignalAddNoiseProcess, 1);
};
#endif
1 change: 0 additions & 1 deletion inc/TRestRawSignalConvolutionFittingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,5 @@ class TRestRawSignalConvolutionFittingProcess : public TRestEventProcess {
~TRestRawSignalConvolutionFittingProcess(); // Destructor

ClassDef(TRestRawSignalConvolutionFittingProcess, 1);
// Template for a REST "event process" class inherited from TRestEventProcess
};
#endif
10 changes: 5 additions & 5 deletions inc/TRestRawSignalEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#include <TMultiGraph.h>
#include <TObject.h>
#include <TPad.h>
#include <TRestEvent.h>
#include <TVector2.h>

#include <iostream>

#include "TRestEvent.h"
#include "TRestRawSignal.h"

//! An event container for time rawdata signals with fixed length
Expand Down Expand Up @@ -113,7 +113,7 @@ class TRestRawSignalEvent : public TRestEvent {

TRestRawSignal* GetSignalById(Int_t sid) {
Int_t index = GetSignalIndex(sid);
if (index < 0) return NULL;
if (index < 0) return nullptr;

return &fSignal[index];
}
Expand All @@ -128,7 +128,7 @@ class TRestRawSignalEvent : public TRestEvent {

Double_t GetBaseLineAverage();
Double_t GetBaseLineSigmaAverage();
// void SubstractBaselines();
// void SubtractBaselines();
Double_t GetIntegral();
Double_t GetThresholdIntegral();

Expand All @@ -149,11 +149,11 @@ class TRestRawSignalEvent : public TRestEvent {
TPad* DrawEvent(TString option = "");
TPad* DrawSignal(Int_t signal, TString option = "");

// Construtor
// Constructor
TRestRawSignalEvent();
// Destructor
virtual ~TRestRawSignalEvent();

ClassDef(TRestRawSignalEvent, 1); // REST event superclass
ClassDef(TRestRawSignalEvent, 1);
};
#endif
7 changes: 3 additions & 4 deletions inc/TRestRawSignalFitEventProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ class TRestRawSignalFitEventProcess : public TRestEventProcess {
metadata << "Amplitude gauss initial value : " << fAmplitudeInitialValue << endl;
}

if (fAgetFit == true) {
if (fAgetFit) {
metadata << "Fitting mode : AGET" << endl;
}
if (fAgetFit == false) {
if (!fAgetFit) {
metadata << "Fitting mode : Convolution" << endl;
}

if (fAddAllPulses == true) {
if (fAddAllPulses) {
metadata << "Adding all pulses in the event" << endl;
}

Expand All @@ -128,6 +128,5 @@ class TRestRawSignalFitEventProcess : public TRestEventProcess {
~TRestRawSignalFitEventProcess(); // Destructor

ClassDef(TRestRawSignalFitEventProcess, 3);
// Template for a REST "event process" class inherited from TRestEventProcess
};
#endif
1 change: 0 additions & 1 deletion inc/TRestRawSignalFittingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,5 @@ class TRestRawSignalFittingProcess : public TRestEventProcess {
~TRestRawSignalFittingProcess(); // Destructor

ClassDef(TRestRawSignalFittingProcess, 2);
// Template for a REST "event process" class inherited from TRestEventProcess
};
#endif
Loading