Skip to content

Commit

Permalink
Merge pull request #97 from rest-for-physics/lobis-pre-commit
Browse files Browse the repository at this point in the history
Implement pre-commit checks and format files
  • Loading branch information
lobis authored Feb 10, 2023
2 parents 4ab6c30 + 716528b commit f403fce
Show file tree
Hide file tree
Showing 25 changed files with 302 additions and 271 deletions.
6 changes: 6 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://cmake-format.readthedocs.io/en/latest/configuration.html

format:
tab_size: 4
separate_ctrl_name_with_space: true
separate_fn_name_with_space: false
6 changes: 5 additions & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defaults:
jobs:
framework-validation:
uses: rest-for-physics/framework/.github/workflows/validation.yml@master

libCheck:
name: Validate library
runs-on: ubuntu-latest
Expand All @@ -43,6 +43,10 @@ jobs:
with:
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_RAW=ON"
branch: ${{ env.BRANCH_NAME }}
- name: Verify pre-commit config files match
run: |
cd $GITHUB_WORKSPACE
curl https://raw.githubusercontent.com/rest-for-physics/framework/master/scripts/validatePreCommitConfig.py | python
- name: Cache framework installation
id: rawlib-install-cache
uses: actions/cache@v3
Expand Down
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: check-xml
- id: requirements-txt-fixer
- id: end-of-file-fixer
exclude: external/.*$
- id: mixed-line-ending
exclude: external/.*$
- id: trailing-whitespace
exclude: external/.*$

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.6
hooks:
- id: clang-format
exclude: external/.*$

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
additional_dependencies: [ pyyaml ]
# - id: cmake-lint

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ if (NOT ${RESTLIB_DETECTOR} MATCHES "ON")
list(REMOVE_ITEM deps detector)
endif ()

COMPILELIB(deps)
compilelib(deps)

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

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

ADD_LIBRARY_TEST()
add_library_test()
57 changes: 24 additions & 33 deletions examples/tdsAQS.rml
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<TRestManager name="TDS" title="Reading TDS rawdata" verboseLevel="info" >

<TRestRun name="TDSRun" title="Reading a TDS Scope file" verboseLevel="silent">
<parameter name="experimentName" value="GEMMM"/>
<parameter name="runNumber" value="preserve"/>
<parameter name="runTag" value="preserve"/>
<parameter name="runType" value="TDS"/>
<parameter name="runDescription" value=""/>
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="0"/>
<parameter name="overwrite" value="on" />
<parameter name="outputFileName" value="R[fRunNumber]_[fRunType]_[fParentRunNumber].root" />
<parameter name="readOnly" value="false" />
<parameter name="inputFormat" value="GEMMM[fRunNumber].raw.[fParentRunNumber]" />
</TRestRun>

<TRestProcessRunner name="Processor" verboseLevel="info">
<parameter name="eventsToProcess" value="0" />
<parameter name="threadNumber" value="1"/>

<parameter name="inputAnalysisStorage" value="on"/>
<parameter name="inputEventStorage" value="on"/>
<parameter name="outputEventStorage" value="on"/>

<addProcess type="TRestRawTDSToSignalProcess" name="tdsRaw" value="ON" electronics="TDS"/>

</TRestProcessRunner>

<addTask command="Processor->RunProcess()" value="ON"/>

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<TRestManager name="TDS" title="Reading TDS rawdata" verboseLevel="info">
<TRestRun name="TDSRun" title="Reading a TDS Scope file" verboseLevel="silent">
<parameter name="experimentName" value="GEMMM"/>
<parameter name="runNumber" value="preserve"/>
<parameter name="runTag" value="preserve"/>
<parameter name="runType" value="TDS"/>
<parameter name="runDescription" value=""/>
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="0"/>
<parameter name="overwrite" value="on"/>
<parameter name="outputFileName" value="R[fRunNumber]_[fRunType]_[fParentRunNumber].root"/>
<parameter name="readOnly" value="false"/>
<parameter name="inputFormat" value="GEMMM[fRunNumber].raw.[fParentRunNumber]"/>
</TRestRun>
<TRestProcessRunner name="Processor" verboseLevel="info">
<parameter name="eventsToProcess" value="0"/>
<parameter name="threadNumber" value="1"/>
<parameter name="inputAnalysisStorage" value="on"/>
<parameter name="inputEventStorage" value="on"/>
<parameter name="outputEventStorage" value="on"/>
<addProcess type="TRestRawTDSToSignalProcess" name="tdsRaw" value="ON" electronics="TDS"/>
</TRestProcessRunner>
<addTask command="Processor-&gt;RunProcess()" value="ON"/>
</TRestManager>

3 changes: 2 additions & 1 deletion inc/TRestRawBaseLineCorrectionProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class TRestRawBaseLineCorrectionProcess : public TRestEventProcess {
BeginPrintProcess();

RESTMetadata << "Smoothing window size: " << fSmoothingWindow << RESTendl;
RESTMetadata << "Baseline correction applied to signals with IDs in range (" << fSignalsRange.X() << "," << fSignalsRange.Y() << ")" << RESTendl;
RESTMetadata << "Baseline correction applied to signals with IDs in range (" << fSignalsRange.X()
<< "," << fSignalsRange.Y() << ")" << RESTendl;

EndPrintProcess();
}
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawFEUDreamToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class TRestRawFEUDreamToSignalProcess : public TRestRawToSignalProcess {
bool get_zs_mode() const { return (((data)&0x400) >> 10); }
int get_Feu_ID() const { return (((data)&0xFF)); }
long int get_finetstp() const { return (((data)&0x0007)); }
//#define GET_FINETSTP(word) (word & 0x0007)
// #define GET_FINETSTP(word) (word & 0x0007)
int get_sample_ID() const { return (((data)&0xFF8) >> 3); }
int get_channel_ID() const { return (((data)&0x3F)); }
int get_dream_ID() const { return (((data)&0xE00) >> 9); } // non-zS mode
Expand Down
4 changes: 2 additions & 2 deletions inc/TRestRawSignalAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class TRestRawSignalAnalysisProcess : public TRestEventProcess {
BeginPrintProcess();

RESTMetadata << "Baseline range : ( " << fBaseLineRange.X() << " , " << fBaseLineRange.Y() << " ) "
<< RESTendl;
<< RESTendl;
RESTMetadata << "Integral range : ( " << fIntegralRange.X() << " , " << fIntegralRange.Y() << " ) "
<< RESTendl;
<< RESTendl;
RESTMetadata << "Point Threshold : " << fPointThreshold << " sigmas" << RESTendl;
RESTMetadata << "Signal threshold : " << fSignalThreshold << " sigmas" << RESTendl;
RESTMetadata << "Number of points over threshold : " << fPointsOverThreshold << RESTendl;
Expand Down
4 changes: 2 additions & 2 deletions inc/TRestRawUSTCToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

#include "TRestRawToSignalProcess.h"

//#define V3_Readout_Format_Long
// #define V3_Readout_Format_Long
#define V4_Readout_Format
//#define Incoherent_Event_Generation
// #define Incoherent_Event_Generation

#ifdef V3_Readout_Format_Long
#define DATA_SIZE 1048
Expand Down
1 change: 0 additions & 1 deletion pipeline/clang-format/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ if [ "-" = "$1" ] ; then
}"' '"${file}"'
done
fi

1 change: 0 additions & 1 deletion pipeline/clang-format/clangformattest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ fi
git reset HEAD --hard

exit 1

14 changes: 7 additions & 7 deletions pipeline/processes/analysis/globals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<parameter name="mainDataPath" value="." />
<parameter name="verboseLevel" value="silent" /> %options are : silent, warning, info, silent

<variable name="BL_MIN" value="20" overwrite="false" />
<variable name="BL_MAX" value="150" overwrite="false" />
<variable name="BL_MIN" value="20" overwrite="false" />
<variable name="BL_MAX" value="150" overwrite="false" />

<variable name="INT_MIN" value="150" overwrite="false" />
<variable name="INT_MAX" value="450" overwrite="false" />
<variable name="INT_MIN" value="150" overwrite="false" />
<variable name="INT_MAX" value="450" overwrite="false" />

<variable name="NPOINTS" value="7" overwrite="false" />
<variable name="POINT_TH" value="3.5" overwrite="false" />
<variable name="SGNL_TH" value="3.5" overwrite="false" />
<variable name="NPOINTS" value="7" overwrite="false" />
<variable name="POINT_TH" value="3.5" overwrite="false" />
<variable name="SGNL_TH" value="3.5" overwrite="false" />
</globals>
20 changes: 10 additions & 10 deletions pipeline/processes/analysis/veto.rml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="0"/>
<parameter name="overwrite" value="off" />

<parameter name="inputFormat" value="R[fRunNumber]_[fRunTag]-[fParentRunNumber].aqs"/>
<parameter name="outputFileName" value="R[fRunNumber]_output.root" />

Expand Down Expand Up @@ -56,15 +56,15 @@
pointThreshold="${POINT_TH}" pointsOverThreshold="${NPOINTS}" signalThreshold="${SGNL_TH}"
verboseLevel="silent" >
// We define all observables except MinValue because is not yet on validation.root
<observable name="NumberOfSignals" type="int" value="ON" />
<observable name="NumberOfGoodSignals" type="int" value="ON" />
<observable name="ThresholdIntegral" type="double" value="ON" />
<observable name="TripleMaxIntegral" type="double" value="ON" />
<observable name="AmplitudeRatio" type="double" value="ON" />
<observable name="MaxPeakTime" type="double" value="ON" />
<observable name="MinPeakTime" type="double" value="ON" />
<observable name="MaxPeakTimeDelay" type="double" value="ON" />
<observable name="AveragePeakTime" type="double" value="ON" />
<observable name="NumberOfSignals" type="int" value="ON" />
<observable name="NumberOfGoodSignals" type="int" value="ON" />
<observable name="ThresholdIntegral" type="double" value="ON" />
<observable name="TripleMaxIntegral" type="double" value="ON" />
<observable name="AmplitudeRatio" type="double" value="ON" />
<observable name="MaxPeakTime" type="double" value="ON" />
<observable name="MinPeakTime" type="double" value="ON" />
<observable name="MaxPeakTimeDelay" type="double" value="ON" />
<observable name="AveragePeakTime" type="double" value="ON" />

<cut name="NumberOfGoodSignals" value="(1,1000)" />
</addProcess>
Expand Down
12 changes: 6 additions & 6 deletions pipeline/processes/noise/addNoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

sgnl = ROOT.TRestRawSignal()

for x in range(0,512):
for x in range(0, 512):
sgnl.AddPoint(0)

rawEv.AddSignal(sgnl)

addNoiseProcess = ROOT.TRestRawSignalAddNoiseProcess("metadata.rml")

outEv = addNoiseProcess.ProcessEvent( rawEv )
outEv = addNoiseProcess.ProcessEvent(rawEv)

outEv.GetSignal(0).CalculateBaseLine(50,450)
outEv.GetSignal(0).CalculateBaseLine(50, 450)
baseLineSigma = outEv.GetSignal(0).GetBaseLineSigma()

print ("\nEvaluating baseline sigma at the output event")
print("\nEvaluating baseline sigma at the output event")
if baseLineSigma < 15 or baseLineSigma > 25:
print ("\nEvaluation failed! Sigma is outside (15,25) range!" )
print("\nEvaluation failed! Sigma is outside (15,25) range!")
exit(202)
print ("[\033[92m OK \x1b[0m]")
print("[\033[92m OK \x1b[0m]")

exit(0)
112 changes: 47 additions & 65 deletions pipeline/processes/veto/veto.rml
Original file line number Diff line number Diff line change
@@ -1,67 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<TRestManager>

<globals>
<parameter name="mainDataPath" value="." />

</globals>


<TRestRun name="VetoTest9Units" title="IAXO D0 Muon Veto Test" verboseLevel="silent">
<parameter name="experimentName" value="IAXOD0"/>
<parameter name="runNumber" value="preserve"/>
<parameter name="runTag" value="preserve"/>
<parameter name="runType" value="VetoValidation"/>
<parameter name="runDescription" value=""/>
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="0"/>
<parameter name="overwrite" value="off" />

<parameter name="inputFormat" value="R[fRunNumber]_[fRunTag]-[fParentRunNumber].aqs"/>
<parameter name="outputFileName" value="R[fRunNumber]_output.root" />

<parameter name="readOnly" value="false" />

</TRestRun>

<TRestProcessRunner name="RawSignals" title="Raw processing and analysis" verboseLevel="info">

<parameter name="firstEntry" value="0" />
<parameter name="lastEntry" value="0" />
<parameter name="eventsToProcess" value="50" />

<addProcess type="TRestRawMultiFEMINOSToSignalProcess" name="virtualDAQ" value="ON" verboseLevel="silent">
<parameter name="pedScript" value="ped"/>
<parameter name="runScript" value="run"/>
<parameter name="electronics" value="TCMFeminos"/>
<parameter name="fileFormat" value="SJTU" />
</addProcess>

<addProcess type="TRestRawVetoAnalysisProcess" name="veto" value="ON">
<parameter name="baseLineRange" value="(10,100)"/>
<parameter name="range" value="(10,500)"/>
<parameter name="observable" value="all"/>

<vetoGroup name="top" signalIDs="4688,4705,4728,4744"/>
<vetoGroup name="bottom" signalIDs="4647,4620,4637,4668"/>
<vetoGroup name="back" signalIDs="4676,4612,4672"/>
<vetoGroup name="right" signalIDs="4849,4620,4637,4668"/>
</addProcess>

</TRestProcessRunner>

<addTask type="processEvents" value="ON" />

<TRestRawVetoAnalysisProcess name="veto" value="ON">
<parameter name="baseLineRange" value="(10,100)"/>
<parameter name="range" value="(10,500)"/>
<parameter name="observable" value="all"/>

<vetoGroup name="top" signalIDs="4688,4705,4728,4744"/>
<vetoGroup name="bottom" signalIDs="4647,4620,4637,4668"/>
<vetoGroup name="back" signalIDs="4676,4612,4672"/>
<vetoGroup name="right" signalIDs="4849,4620,4637,4668"/>
</TRestRawVetoAnalysisProcess>

<globals>
<parameter name="mainDataPath" value="."/>
</globals>
<TRestRun name="VetoTest9Units" title="IAXO D0 Muon Veto Test" verboseLevel="silent">
<parameter name="experimentName" value="IAXOD0"/>
<parameter name="runNumber" value="preserve"/>
<parameter name="runTag" value="preserve"/>
<parameter name="runType" value="VetoValidation"/>
<parameter name="runDescription" value=""/>
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="0"/>
<parameter name="overwrite" value="off"/>
<parameter name="inputFormat" value="R[fRunNumber]_[fRunTag]-[fParentRunNumber].aqs"/>
<parameter name="outputFileName" value="R[fRunNumber]_output.root"/>
<parameter name="readOnly" value="false"/>
</TRestRun>
<TRestProcessRunner name="RawSignals" title="Raw processing and analysis" verboseLevel="info">
<parameter name="firstEntry" value="0"/>
<parameter name="lastEntry" value="0"/>
<parameter name="eventsToProcess" value="50"/>
<addProcess type="TRestRawMultiFEMINOSToSignalProcess" name="virtualDAQ" value="ON" verboseLevel="silent">
<parameter name="pedScript" value="ped"/>
<parameter name="runScript" value="run"/>
<parameter name="electronics" value="TCMFeminos"/>
<parameter name="fileFormat" value="SJTU"/>
</addProcess>
<addProcess type="TRestRawVetoAnalysisProcess" name="veto" value="ON">
<parameter name="baseLineRange" value="(10,100)"/>
<parameter name="range" value="(10,500)"/>
<parameter name="observable" value="all"/>
<vetoGroup name="top" signalIDs="4688,4705,4728,4744"/>
<vetoGroup name="bottom" signalIDs="4647,4620,4637,4668"/>
<vetoGroup name="back" signalIDs="4676,4612,4672"/>
<vetoGroup name="right" signalIDs="4849,4620,4637,4668"/>
</addProcess>
</TRestProcessRunner>
<addTask type="processEvents" value="ON"/>
<TRestRawVetoAnalysisProcess name="veto" value="ON">
<parameter name="baseLineRange" value="(10,100)"/>
<parameter name="range" value="(10,500)"/>
<parameter name="observable" value="all"/>
<vetoGroup name="top" signalIDs="4688,4705,4728,4744"/>
<vetoGroup name="bottom" signalIDs="4647,4620,4637,4668"/>
<vetoGroup name="back" signalIDs="4676,4612,4672"/>
<vetoGroup name="right" signalIDs="4849,4620,4637,4668"/>
</TRestRawVetoAnalysisProcess>
</TRestManager>
Loading

0 comments on commit f403fce

Please sign in to comment.