diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b113cc2e..c995d191e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics -variables: +# variables: # GIT_SUBMODULE_STRATEGY: recursive stages: @@ -13,7 +13,7 @@ stages: # Project compilation validation - build - # REST libraries installed as sub-modules + # REST libraries installed as submodules - libraries # Basic validation tests of installation @@ -34,7 +34,7 @@ stages: # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). - restManager_process - # Stage to validate tasks or executions over preprocessed data filesx + # Stage to validate tasks or executions over preprocessed data files - postProcessing # Stage to validate other restManager tasks (metadata generation, script loading, etc). @@ -85,7 +85,7 @@ Build and Test: - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - cmake ${CI_PROJECT_DIR} - -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + -DTEST=ON -DREST_GARFIELD=OFF -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - ctest --verbose -O ${CI_PROJECT_DIR}/build/Testing/summary.txt @@ -152,7 +152,7 @@ List REST Macros: expire_in: 1 day 08_alphas: - type: restG4 + stage: restG4 script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/install/examples/restG4/08.Alphas/ @@ -166,8 +166,8 @@ List REST Macros: expire_in: 1 day 01_alphaTrack: - type: examples - script: + stage: examples + script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/install/examples/01.alphaTrack/ - mkdir data @@ -219,11 +219,9 @@ Basic Readout: stage: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ - - ls - - git status - - git log - - restRoot --m 1 -b -q GenerateReadouts.C'("basic.root")' + - cd ${CI_PROJECT_DIR}/projects/basic-readouts + - git submodule update --init . + - restRoot -b -q GenerateReadouts.C'("basic.root")' - restRoot -b -q BasicValidation.C'("basic.root", "pixelDecoding")' Test Metadata: diff --git a/macros/REST_MakeMetadata.C b/macros/REST_MakeMetadata.C new file mode 100644 index 000000000..190dc6982 --- /dev/null +++ b/macros/REST_MakeMetadata.C @@ -0,0 +1,243 @@ + +#include +#include +#include + +#include + +#ifndef RESTTask_MakeMetadata +#define RESTTask_MakeMetadata + +//******************************************************************************************************* +//*** +//*** This macro will generate a source .cxx and a header file serving as a template for new +//*** metadata classes. Please, replace any REMOVE comment with useful information. +//*** +//******************************************************************************************************* +Int_t REST_MakeMetadata(TString name) { + if (name.First("TRest") != 0) { + ferr << "invalid process name! REST process name must be start with \"TRest\" " << endl; + return -1; + } + + ofstream headerFile(name + ".h"); + if (headerFile.fail()) { + ferr << "failed to create file!" << endl; + return -1; + } + + headerFile << "/*************************************************************************" << endl; + headerFile << " * This file is part of the REST software framework. *" << endl; + headerFile << " * *" << endl; + headerFile << " * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *" << endl; + headerFile << " * For more information see https://gifna.unizar.es/trex *" << endl; + headerFile << " * *" << endl; + headerFile << " * REST is free software: you can redistribute it and/or modify *" << endl; + headerFile << " * it under the terms of the GNU General Public License as published by *" << endl; + headerFile << " * the Free Software Foundation, either version 3 of the License, or *" << endl; + headerFile << " * (at your option) any later version. *" << endl; + headerFile << " * *" << endl; + headerFile << " * REST is distributed in the hope that it will be useful, *" << endl; + headerFile << " * but WITHOUT ANY WARRANTY; without even the implied warranty of *" << endl; + headerFile << " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *" << endl; + headerFile << " * GNU General Public License for more details. *" << endl; + headerFile << " * *" << endl; + headerFile << " * You should have a copy of the GNU General Public License along with *" << endl; + headerFile << " * REST in $REST_PATH/LICENSE. *" << endl; + headerFile << " * If not, see https://www.gnu.org/licenses/. *" << endl; + headerFile << " * For the list of contributors see $REST_PATH/CREDITS. *" << endl; + headerFile << " *************************************************************************/" << endl; + headerFile << endl; + headerFile << "#ifndef REST_" << name << endl; + headerFile << "#define REST_" << name << endl; + headerFile << endl; + headerFile << "#include \"TRestMetadata.h\"" << endl; + headerFile << endl; + headerFile << "/// UPDATE Write here a brief description. Just one line!" << endl; + headerFile << "class " << name << " : public TRestMetadata {" << endl; + headerFile << "private:" << endl; + headerFile << "" << endl; + headerFile << " // REMOVE COMMENT. Add here the members/parameters for your metadata class." << endl; + headerFile << " // You can set their default values here together. " << endl; + headerFile << " // Note: add \"//!\" mark at the end of the member definition" << endl; + headerFile + << " // if you don't want to save them to disk. The following dummy member are given as examples." + << endl; + headerFile << "" << endl; + headerFile << " /// REMOVE MEMBER. A dummy member that will be written to the ROOT file." << endl; + headerFile << " Double_t fDummy = 3.14; //<" << endl; + headerFile << "" << endl; + headerFile << " /// REMOVE MEMBER. A dummy member that will be NOT written to the ROOT file." << endl; + headerFile << " Double_t fDummyVar = 3.14; //!" << endl; + headerFile << endl; + headerFile << " void Initialize();" << endl; + headerFile << endl; + headerFile << "public:" << endl; + headerFile << " void PrintMetadata();" << endl; + headerFile << endl; + headerFile << " " << name << "();" << endl; + headerFile << " " << name << "(const char* cfgFileName, std::string name = \"\")" << endl; + headerFile << " ~" << name << "();" << endl; + headerFile << endl; + headerFile << " // REMOVE COMMENT. ROOT class definition helper. Increase the number in it every time" + << endl; + headerFile << " // you add/rename/remove the metadata members" << endl; + headerFile << " ClassDef(" << name << ", 1);" << endl; + headerFile << endl; + headerFile << "};" << endl; + headerFile << "#endif" << endl; + + headerFile.flush(); + headerFile.close(); + + ofstream sourceFile(name + ".cxx"); + if (headerFile.fail()) { + ferr << "failed to create file!" << endl; + return -1; + } + + sourceFile << "/*************************************************************************" << endl; + sourceFile << " * This file is part of the REST software framework. *" << endl; + sourceFile << " * *" << endl; + sourceFile << " * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *" << endl; + sourceFile << " * For more information see https://gifna.unizar.es/trex *" << endl; + sourceFile << " * *" << endl; + sourceFile << " * REST is free software: you can redistribute it and/or modify *" << endl; + sourceFile << " * it under the terms of the GNU General Public License as published by *" << endl; + sourceFile << " * the Free Software Foundation, either version 3 of the License, or *" << endl; + sourceFile << " * (at your option) any later version. *" << endl; + sourceFile << " * *" << endl; + sourceFile << " * REST is distributed in the hope that it will be useful, *" << endl; + sourceFile << " * but WITHOUT ANY WARRANTY; without even the implied warranty of *" << endl; + sourceFile << " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *" << endl; + sourceFile << " * GNU General Public License for more details. *" << endl; + sourceFile << " * *" << endl; + sourceFile << " * You should have a copy of the GNU General Public License along with *" << endl; + sourceFile << " * REST in $REST_PATH/LICENSE. *" << endl; + sourceFile << " * If not, see https://www.gnu.org/licenses/. *" << endl; + sourceFile << " * For the list of contributors see $REST_PATH/CREDITS. *" << endl; + sourceFile << " *************************************************************************/" << endl; + sourceFile << "" << endl; + sourceFile << "/////////////////////////////////////////////////////////////////////////" << endl; + sourceFile << "/// Write the class description Here " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// ### Parameters" << endl; + sourceFile << "/// Describe any parameters this process receives: " << endl; + sourceFile << "/// * **parameter1**: This parameter ..." << endl; + sourceFile << "/// * **parameter2**: This parameter is ..." << endl; + sourceFile << "/// " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// ### Examples" << endl; + sourceFile << "/// Give examples of usage and RML descriptions that can be tested. " << endl; + sourceFile << "/// \\code" << endl; + sourceFile << "/// " << endl; + sourceFile << "/// \\endcode" << endl; + sourceFile << "/// " << endl; + sourceFile << "/// ### Running pipeline example" << endl; + sourceFile << "/// Add the examples to a pipeline to guarantee the code will be running " << endl; + sourceFile << "/// on future framework upgrades. " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// Please, add any figure that may help to illustrate the process " << endl; + sourceFile << "/// " << endl; + sourceFile + << "/// \\htmlonly \\endhtmlonly" + << endl; + sourceFile << "/// ![An illustration of the trigger definition](trigger.png) " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// The png image should be uploaded to the ./images/ directory " << endl; + sourceFile << "/// " << endl; + sourceFile << "///----------------------------------------------------------------------" << endl; + sourceFile << "/// " << endl; + sourceFile << "/// REST-for-Physics - Software for Rare Event Searches Toolkit " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// History of developments: " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// YEAR-Month: First implementation of " << name << endl; + sourceFile << "/// WRITE YOUR FULL NAME " << endl; + sourceFile << "/// " << endl; + sourceFile << "/// \\class " << name << " " << endl; + sourceFile << "/// \\author: TODO. Write full name and e-mail: " << getenv("USER") << endl; + sourceFile << "/// " << endl; + sourceFile << "///
" << endl; + sourceFile << "/// " << endl; + sourceFile << endl; + sourceFile << "#include \"" << name << ".h\"" << endl; + sourceFile << endl; + sourceFile << "ClassImp(" << name << ");" << endl; + sourceFile << endl; + sourceFile << "/////////////////////////////////////////////// " << endl; + sourceFile << "/// \\brief Default constructor " << endl; + sourceFile << "/// " << endl; + sourceFile << name << "::" << name << "() {" << endl; + sourceFile << " Initialize();" << endl; + sourceFile << "}" << endl; + sourceFile << endl; + sourceFile << "/////////////////////////////////////////////" << endl; + sourceFile << "/// \\brief Constructor loading data from a config file" << endl; + sourceFile << "///" << endl; + sourceFile << "/// If no configuration path is defined using TRestMetadata::SetConfigFilePath" << endl; + sourceFile << "/// the path to the config file must be specified using full path, absolute or" << endl; + sourceFile << "/// relative." << endl; + sourceFile << "///" << endl; + sourceFile << "/// The default behaviour is that the config file must be specified with" << endl; + sourceFile << "/// full path, absolute or relative." << endl; + sourceFile << "///" << endl; + sourceFile << "/// \\param cfgFileName A const char* giving the path to an RML file." << endl; + sourceFile << "/// \\param name The name of the specific metadata. It will be used to find the" << endl; + sourceFile << "/// corresponding TRestAxionMagneticField section inside the RML." << endl; + sourceFile << "///" << endl; + sourceFile << name << "::" << name + << "(const char* cfgFileName, string name) : TRestMetadata(cfgFileName) {" << endl; + sourceFile << " LoadConfigFromFile(fConfigFileName, name);" << endl; + sourceFile << "" << endl; + sourceFile << " if (GetVerboseLevel() >= REST_Info) PrintMetadata();" << endl; + sourceFile << "}" << endl; + sourceFile << endl; + sourceFile << "/////////////////////////////////////////////// " << endl; + sourceFile << "/// \\brief Default destructor " << endl; + sourceFile << "/// " << endl; + sourceFile << name << "::~" << name << "() {" << endl; + sourceFile << "}" << endl; + sourceFile << endl; + sourceFile << "/////////////////////////////////////////////// " << endl; + sourceFile << "/// \\brief Function to initialize input/output event members and define " << endl; + sourceFile << "/// the section name " << endl; + sourceFile << "/// " << endl; + sourceFile << "void " << name << "::Initialize() {" << endl; + sourceFile << " SetSectionName(this->ClassName());" << endl; + sourceFile << " SetLibraryVersion(LIBRARY_VERSION);" << endl; + sourceFile << endl; + sourceFile << " // REMOVE COMMENT. Initialize here any special data members if needed" << endl; + sourceFile << endl; + sourceFile << "}" << endl; + sourceFile << endl; + sourceFile << "/////////////////////////////////////////////" << endl; + sourceFile + << "/// \\brief Prints on screen the information about the metadata members of TRestAxionSolarFlux" + << endl; + sourceFile << "///" << endl; + sourceFile << "void " << name << "::PrintMetadata() {" << endl; + sourceFile << " TRestMetadata::PrintMetadata();" << endl; + sourceFile << endl; + sourceFile << " metadata << \" - Dummy member : \" << fDummy << endl;" << endl; + sourceFile << "}" << endl; + sourceFile << endl; + + sourceFile.flush(); + sourceFile.close(); + + cout << endl; + cout << "--------------------------------" << endl; + cout << "Metadata class code generation complete!" << endl; + cout << "* " << name << ".h" << endl; + cout << "* " << name << ".cxx" << endl; + cout << endl; + cout << "Put the two files into proper directories and re-run cmake/make" << endl; + cout << "Remember to replace REMOVE/UPDATE statements by meaningful documentation" << endl; + cout << "--------------------------------" << endl; + cout << endl; + + return 0; +} +#endif