diff --git a/macros/REST_MakeMetadata.C b/macros/REST_MakeMetadata.C index ce2a2653f..190dc6982 100644 --- a/macros/REST_MakeMetadata.C +++ b/macros/REST_MakeMetadata.C @@ -20,212 +20,212 @@ Int_t REST_MakeMetadata(TString name) { return -1; } - ofstream headerfile(name + ".h"); - if (headerfile.fail()) { + 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 + 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" + 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 << " // you add/rename/remove the metadata members" << endl; + headerFile << " ClassDef(" << name << ", 1);" << endl; + headerFile << endl; + headerFile << "};" << endl; + headerFile << "#endif" << endl; - headerfile.flush(); - headerfile.close(); + headerFile.flush(); + headerFile.close(); - ofstream sourcefile(name + ".cxx"); - if (headerfile.fail()) { + 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 + 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 + 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 + 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 << "///" << 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(); + sourceFile.flush(); + sourceFile.close(); cout << endl; cout << "--------------------------------" << endl;