Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis authored Feb 24, 2024
2 parents 0804dca + 2002d9c commit 4fbfaca
Show file tree
Hide file tree
Showing 44 changed files with 3,773 additions and 130 deletions.
5 changes: 4 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.github/ @lobis
.github/* @lobis
* @jgalan
* @juanangp
* @lobis
* @nkx111
*.py @lobis
*.cmake @lobis
CMakelists.txt @lobis
2 changes: 1 addition & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ jobs:
run: |
source ${{ env.REST_PATH }}/thisREST.sh
cd framework/pipeline/trex
wget https://sultan.unizar.es/trexdm-readouts/readouts_v2.4.root
wget https://rest-for-physics.github.io/trexdm-readouts/readouts_v2.4.root
restManager --c 01_raw.rml --f R01928_tagTest_Vm_250_Vd_160_Pr_6_Gain_0x0_Shape_0xF_Clock_0x4-068.aqs
restManager --c 02_signal.rml --f RawData_01928.root
restManager --c 03_hits.rml --f Signals_01928.root
Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,27 @@ else ()
set(REST_MPFR OFF)
endif (${REST_MPFR} MATCHES "ON")

if (((${REST_ALL_LIBS} MATCHES "ON") AND (NOT DEFINED RESTLIB_AXION))
OR (${RESTLIB_AXION} MATCHES "ON"))
# GSL #### Find GSL
find_package(GSL REQUIRED)

# Include GSL directories
set(external_include_dirs ${external_include_dirs} ${GSL_INCLUDE_DIRS})

# Link GSL libraries
set(external_libs ${external_libs};${GSL_LIBRARIES})

message(STATUS "Found GSL libraries : ${GSL_LIBRARIES}")
message(STATUS "GSL headers : ${GSL_INCLUDE_DIRS}")

set(REST_GSL ON)
else ()
set(REST_GSL OFF)
message(STATUS "GSL libraries not required")
endif (((${REST_ALL_LIBS} MATCHES "ON") AND (NOT DEFINED RESTLIB_AXION))
OR (${RESTLIB_AXION} MATCHES "ON"))

# CURL #####
find_library(CURL_LIB curl)
if (NOT ${CURL_LIB} STREQUAL "CURL_LIB-NOTFOUND")
Expand Down
Binary file added doc/doxygen/images/component_hitmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/doxygen/images/component_spectra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions macros/REST_AddComponentDataSet.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "TRestComponent.h"
#include "TRestTask.h"

#ifndef RestTask_AddComponent
#define RestTask_AddComponent

//*******************************************************************************************************
//*** Description: This macro will load from an RML the component chosen in the arguments and it
//*** will write it inside the file given as outputFile
//***
//*** --------------
//*** Usage: restManager AddComponentDataSet components.rml sectionName [outputFile] [componentName] [update]
//***
//*** Arguments description:
//***
//*** - cfgFile: The RML configuration file where the component definition can be found.
//*** - sectionName: The section name used to select a component inside the RML file.
//*** - outputFile: The file where the component is written, by default is components.root.
//*** - componentName: This argument allows to change the component name stored in the output file.
//*** By default it will take the same value as section name.
//*** - update: If disabled it will create a new file erasing any other previously added components.
//*** It is enabled by default.
//***
//*******************************************************************************************************

Int_t REST_AddComponentDataSet(std::string cfgFile, std::string sectionName,
std::string outputFile = "components.root", std::string componentName = "",
Bool_t update = true) {
TRestComponentDataSet comp(cfgFile.c_str(), sectionName.c_str());
comp.Initialize();

TFile* f;
if (update)
f = TFile::Open(outputFile.c_str(), "UPDATE");
else
f = TFile::Open(outputFile.c_str(), "RECREATE");

if (componentName == "") componentName = sectionName;

comp.Write(componentName.c_str());

f->Close();

return 0;
}
#endif
46 changes: 46 additions & 0 deletions macros/REST_AddComponentFormula.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "TRestComponent.h"
#include "TRestTask.h"

#ifndef RestTask_AddComponentFormula
#define RestTask_AddComponentFormula

//*******************************************************************************************************
//*** Description: This macro will load from an RML the component chosen in the arguments and it
//*** will write it inside the file given as outputFile
//***
//*** --------------
//*** Usage: restManager AddComponentFormula components.rml sectionName [outputFile] [componentName] [update]
//***
//*** Arguments description:
//***
//*** - cfgFile: The RML configuration file where the component definition can be found.
//*** - sectionName: The section name used to select a component inside the RML file.
//*** - outputFile: The file where the component is written, by default is components.root.
//*** - componentName: This argument allows to change the component name stored in the output file.
//*** By default it will take the same value as section name.
//*** - update: If disabled it will create a new file erasing any other previously added components.
//*** It is enabled by default.
//***
//*******************************************************************************************************

Int_t REST_AddComponentFormula(std::string cfgFile, std::string sectionName,
std::string outputFile = "components.root", std::string componentName = "",
Bool_t update = true) {
TRestComponentFormula comp(cfgFile.c_str(), sectionName.c_str());
comp.Initialize();

TFile* f;
if (update)
f = TFile::Open(outputFile.c_str(), "UPDATE");
else
f = TFile::Open(outputFile.c_str(), "RECREATE");

if (componentName == "") componentName = sectionName;

comp.Write(componentName.c_str());

f->Close();

return 0;
}
#endif
13 changes: 6 additions & 7 deletions macros/REST_CheckValidRuns.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ namespace fs = std::filesystem;
//*** CAUTION: Be aware that any non-REST file in the list will be removed if you use purge=1
//***
//*******************************************************************************************************
Int_t REST_CheckValidRuns(TString namePattern, Bool_t purge = false) {
Int_t REST_CheckValidRuns(std::string namePattern, Bool_t purge = false) {
TGeoManager::SetVerboseLevel(0);

vector<std::string> filesNotWellClosed;

TRestStringOutput RESTLog;

string a = TRestTools::Execute((string)("ls -d -1 " + namePattern));
vector<string> b = Split(a, "\n");
std::vector<std::string> b = TRestTools::GetFilesMatchingPattern(namePattern, true);

Double_t totalTime = 0;
int cont = 0;
Expand Down Expand Up @@ -76,11 +75,12 @@ Int_t REST_CheckValidRuns(TString namePattern, Bool_t purge = false) {
}

RESTLog << "Run time (hours) : " << run->GetRunLength() / 3600. << RESTendl;
if (run->GetRunLength() > 0) totalTime += run->GetRunLength() / 3600.;
RESTLog << "Entries : " << run->GetEntries() << RESTendl;

if (run->GetEndTimestamp() == 0 || run->GetRunLength() < 0) {
if (run->GetEndTimestamp() == 0 || run->GetRunLength() < 0 || run->GetEntries() == 0) {
filesNotWellClosed.push_back(filename);
}
} else if (run->GetRunLength() > 0)
totalTime += run->GetRunLength() / 3600.;

delete run;

Expand All @@ -100,7 +100,6 @@ Int_t REST_CheckValidRuns(TString namePattern, Bool_t purge = false) {
if (purge) {
RESTLog << "---------------------------" << RESTendl;
RESTLog << "The files have been removed" << RESTendl;
RESTLog << "---------------------------" << RESTendl;
}
}

Expand Down
1 change: 1 addition & 0 deletions macros/REST_OpenInputFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void REST_OpenInputFile(const std::string& fileName) {
printf("\n%s\n", " - dSet->PrintMetadata()");
printf("%s\n", " - dSet->GetDataFrame().GetColumnNames()");
printf("%s\n\n", " - dSet->GetTree()->GetEntries()");
printf("%s\n", " - dSet->GetDataFrame().Display(\"\")->Print()");
printf("%s\n\n", " - dSet->GetDataFrame().Display({\"colName1,colName2\"})->Print()");
if (dSet) delete dSet;
dSet = new TRestDataSet();
Expand Down
32 changes: 6 additions & 26 deletions pipeline/panda-x/P3AutoChain.rml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--In this example, when launching the analysis, we are doing following operations inside TRestManager:
1. Initialize TRestRun
1.1 set input and output file for TRestRun(here input and output is in "globals")
Expand All @@ -13,25 +12,17 @@
2.4.1 add additional observables in the process
3. Add a task to call TRestProcessRunner to run
-->

<TRestManager name="CoBoDataAnalysis" title="Example" verboseLevel="info">

<TRestRun name="SJTU_Proto">
<parameter name="runNumber" value="auto"/>//change this value to "auto" to enable database
<parameter name="inputFileName" value="auto"/>
</TRestRun>

<TRestRun name="SJTU_Proto"><parameter name="runNumber" value="auto"/>//change this value to "auto" to enable database
<parameter name="inputFileName" value="auto"/></TRestRun>
<TRestProcessRunner name="Processor" verboseLevel="info">
<parameter name="eventsToProcess" value="0"/>
<parameter name="threadNumber" value="2"/>

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

<addProcess type="TRestRawMultiCoBoAsAdToSignalProcess" name="virtualDAQ" value="ON"/>
<addProcess type="TRestRawSignalAnalysisProcess" name="sAna" value="ON">
<parameter name="pointsOverThreshold" value="3"/>
<addProcess type="TRestRawSignalAnalysisProcess" name="sAna" value="ON"><parameter name="pointsOverThreshold" value="3"/>
/// We define all observables except MinValue because it is not yet in validation chain
<observable name="BaseLineMean" value="ON"/>
<observable name="BaseLineSigmaMean" value="ON"/>
Expand Down Expand Up @@ -61,31 +52,20 @@
<parameter name="zeroSuppression" value="true"/>
<parameter name="nPointsOverThreshold" value="3"/>
</addProcess>

<addProcess type="TRestRealTimeDrawingProcess" name="rD" value="ON" drawInterval="1000">
<TRestAnalysisPlot name="TriggerRatePlot" previewPlot="false">
<canvas size="(1000,800)" save="TriggerRate.png"/>
<plot name="TriggerRate" title="Trigger Rate" xlabel="Seconds From Start" ylabel="Counts" value="ON"
stats="ON">
<plot name="TriggerRate" title="Trigger Rate" xlabel="Seconds From Start" ylabel="Counts" value="ON" stats="ON">
<variable name="rateAna_SecondsFromStart" range="auto" nbins="100"/>
</plot>
</TRestAnalysisPlot>
</addProcess>


</TRestProcessRunner>

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


<globals>
<searchPath value="$ENV{REST_INPUTDATA}/definitions/"/>
<parameter name="mainDataPath" value=""/>

<parameter name="pointThreshold" value="3"/>
</globals>

</TRestManager>


<!--parameter here is accessible to all the classes-->
<!--parameter here is accessible to all the classes-->
15 changes: 13 additions & 2 deletions source/bin/restRoot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) {
printf("\n");
printf(" restRoot --m [0,1]\n");
printf("\n");
printf(" Option 0 will disable macro loading. Option 1 is the default.\n");
printf(" Option 0 will disable macro loading. Option 0 is the default.\n");
printf("\n");
exit(0);
}
Expand All @@ -81,7 +81,18 @@ int main(int argc, char* argv[]) {
gROOT->ProcessLine("#include <TRestPhysics.h>");
gROOT->ProcessLine("#include <TRestSystemOfUnits.h>");
if (loadMacros) {
if (!silent) printf("= Loading macros ...\n");
if (!silent) {
printf("= Loading macros ...\n");
printf(
"= HINT. Loading all macros may require a long time till you get access to the interactive "
"shell\n");
printf("= HINT. You may use `restListMacros` outside `restRoot` to check the available macros\n");
printf(
"= HINT. Then, you may execute the macro externally by using: `restManager MacroName "
"[ARGUMENTS]\n");
printf("= HINT. `MacroName` is the name of the macro after removing the macro name header\n");
printf("= HINT. E.g. REST_Detector_XYZ(arg1,arg2) may be called as: restManager XYZ arg1 arg2\n");
}
vector<string> macroFiles;
const vector<string> patterns = {
REST_PATH + "/macros/REST_*.C", // framework
Expand Down
2 changes: 1 addition & 1 deletion source/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ link_libraries("-fPIC")

add_subdirectory(external)

set(contents external/tinyxml tools core analysis masks)
set(contents external/tinyxml tools core analysis masks sensitivity)

file(GLOB_RECURSE addon_src "tiny*cpp" "startup.cpp")

Expand Down
38 changes: 27 additions & 11 deletions source/framework/core/inc/TRestDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class TRestDataSet : public TRestMetadata {
std::map<std::string, RelevantQuantity> fQuantity; //<

/// Parameter cuts over the selected dataset
TRestCut* fCut = nullptr;
TRestCut* fCut = nullptr; //<

/// The total integrated run time of selected files
Double_t fTotalDuration = 0; //<
Expand All @@ -103,12 +103,14 @@ class TRestDataSet : public TRestMetadata {
std::vector<std::string> fImportedFiles; //<

/// A list of new columns together with its corresponding expressions added to the dataset
std::vector<std::pair<std::string, std::string>> fColumnNameExpressions;
std::vector<std::pair<std::string, std::string>> fColumnNameExpressions; //<

/// A flag to enable Multithreading during dataframe generation
Bool_t fMT = false; //<

inline auto GetAddedColumns() const { return fColumnNameExpressions; }
// If the dataframe was defined externally it will be true
Bool_t fExternal = false; //<

/// The resulting RDF::RNode object after initialization
ROOT::RDF::RNode fDataSet = ROOT::RDataFrame(0); //!

Expand All @@ -123,20 +125,28 @@ class TRestDataSet : public TRestMetadata {
public:
/// Gives access to the RDataFrame
ROOT::RDF::RNode GetDataFrame() const {
if (fTree == nullptr) RESTWarning << "DataFrame has not been yet initialized" << RESTendl;
if (!fExternal && fTree == nullptr)
RESTWarning << "DataFrame has not been yet initialized" << RESTendl;
return fDataSet;
}

void SetDataFrame(const ROOT::RDF::RNode& dS) { fDataSet = dS; }

void EnableMultiThreading(Bool_t enable = true) { fMT = enable; }

/// Gives access to the tree
TTree* GetTree() const {
if (fTree == nullptr && fExternal) {
RESTInfo << "The tree is not accessible. Only GetDataFrame can be used in an externally "
"generated dataset"
<< RESTendl;
RESTInfo << "You may write a tree using GetDataFrame()->Snapshot(\"MyTree\", \"output.root\");"
<< RESTendl;
return fTree;
}

if (fTree == nullptr) {
RESTError << "Tree has not been yet initialized" << RESTendl;
RESTError << "You should invoke TRestDataSet::GenerateDataSet() before trying to access the tree"
<< RESTendl;
RESTError << "You should invoke TRestDataSet::GenerateDataSet() or " << RESTendl;
RESTError << "TRestDataSet::Import( fname ) before trying to access the tree" << RESTendl;
}
return fTree;
}
Expand Down Expand Up @@ -167,21 +177,27 @@ class TRestDataSet : public TRestMetadata {
inline auto GetFilterLowerThan() const { return fFilterLowerThan; }
inline auto GetFilterEqualsTo() const { return fFilterEqualsTo; }
inline auto GetQuantity() const { return fQuantity; }
inline auto GetAddedColumns() const { return fColumnNameExpressions; }
inline auto GetCut() const { return fCut; }
inline auto IsMergedDataSet() const { return fMergedDataset; }

inline void SetObservablesList(const std::vector<std::string>& obsList) { fObservablesList = obsList; }
inline void SetFilePattern(const std::string& pattern) { fFilePattern = pattern; }
inline void SetQuantity(const std::map<std::string, RelevantQuantity>& quantity) { fQuantity = quantity; }

void SetTotalTimeInSeconds(Double_t seconds) { fTotalDuration = seconds; }
void SetDataFrame(const ROOT::RDF::RNode& dS) {
fDataSet = dS;
fExternal = true;
}

TRestDataSet& operator=(TRestDataSet& dS);
Bool_t Merge(const TRestDataSet& dS);
void Import(const std::string& fileName);
void Import(std::vector<std::string> fileNames);
void Export(const std::string& filename);
void Export(const std::string& filename, std::vector<std::string> excludeColumns = {});

ROOT::RDF::RNode MakeCut(const TRestCut* cut);

ROOT::RDF::RNode DefineColumn(const std::string& columnName, const std::string& formula);

void PrintMetadata() override;
Expand All @@ -193,6 +209,6 @@ class TRestDataSet : public TRestMetadata {
TRestDataSet(const char* cfgFileName, const std::string& name = "");
~TRestDataSet();

ClassDefOverride(TRestDataSet, 5);
ClassDefOverride(TRestDataSet, 7);
};
#endif
Loading

0 comments on commit 4fbfaca

Please sign in to comment.