GENIEGenerator
Loading...
Searching...
No Matches
genie::TuneId Class Reference

GENIE tune ID. More...

#include <TuneId.h>

Public Member Functions

 TuneId (const string &id_str, bool failOnInvalid=true)
 TuneId (const TuneId &id)
 ~TuneId ()
string Name (void) const
string Prefix (void) const
string Year (void) const
string ModelId (void) const
string MajorModelId (void) const
string MinorModelId (void) const
string TunedParamSetId (void) const
string FitDataSetId (void) const
bool IsConfigured (void) const
bool IsValidated (void) const
bool IsCustom (void) const
bool OnlyConfiguration () const
string CMC (void) const
string Tail (void) const
string CMCDirectory (void) const
string TuneDirectory (void) const
string BaseDirectory (void) const
string CustomSource (void) const
void Build (const string &name="")
void Decode (string id_str)
void Copy (const TuneId &id)
bool Compare (const TuneId &id) const
void Print (ostream &stream) const

Private Member Functions

 TuneId ()
bool CheckDirectory ()

Private Attributes

string fName
string fPrefix
string fYear
string fModelId
string fMajorModelId
string fMinorModelId
string fTunedParamSetId
string fFitDataSetId
string fBaseDirectory
string fCustomSource
bool fIsConfigured
bool fIsValidated

Friends

ostream & operator<< (ostream &stream, const TuneId &id)

Detailed Description

GENIE tune ID.

Author
Marco Roda <Marco.Roda \at liverpool.ac.uk> University of Liverpool

Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool

Created:\n April 19, 2018
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Definition at line 37 of file TuneId.h.

Constructor & Destructor Documentation

◆ TuneId() [1/3]

TuneId::TuneId ( const string & id_str,
bool failOnInvalid = true )

Definition at line 52 of file TuneId.cxx.

53 : fName(genie::utils::str::TrimSpaces(id_str)) // remove any lead/trailing
54 , fIsConfigured(false)
55 , fIsValidated(false)
56{
57 Build(fName);
58 if ( failOnInvalid && ! fIsValidated ) {
59 // status & 0377 is returned to parent on exit() call e.g. [0:255]
60 // SYSEXITS(3) FreeBSD Library Functions Manual
61 // According to style(9), it is not a good practice to call exit(3) with
62 // arbitrary values to indicate a failure condition when ending a program.
63 // Instead, the pre-defined exit codes from sysexits should be used, so the
64 // caller of the process can get a rough estimation about the failure class
65 // without looking up the source code.
66 // EX_USAGE (64) The command was used incorrectly, e.g., with the
67 // wrong number of arguments, a bad flag, a bad syntax
68 // in a parameter, or whatever.
69 // EX_UNAVAILABLE (69) A service is unavailable. This can occur if a supĀ­
70 // port program or file does not exist. This can also
71 // be used as a catchall message when something you
72 // wanted to do doesn't work, but you don't know why.
73
74 // use 64 when failed Decode name (i.e. ! fIsConfigured )
75 // use 69 when failed to find directory (i.e. ! fIsValidated )
76 if ( fIsConfigured ) exit(69);
77 else exit(64);
78 }
79}
bool fIsConfigured
Definition TuneId.h:106
bool fIsValidated
Definition TuneId.h:107
string fName
Definition TuneId.h:93
void Build(const string &name="")
Definition TuneId.cxx:124
string TrimSpaces(string input)

References Build(), fIsConfigured, fIsValidated, and fName.

Referenced by Compare(), Copy(), operator<<, and TuneId().

◆ TuneId() [2/3]

TuneId::TuneId ( const TuneId & id)

Definition at line 81 of file TuneId.cxx.

82{
83 this->Copy(id);
84
85 if ( ! CheckDirectory() ) {
86 LOG("TuneId", pWARN) << "No valid subdirectory associated with " << Name() ;
87 }
88}
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
bool CheckDirectory()
Definition TuneId.cxx:205
string Name(void) const
Definition TuneId.h:46
void Copy(const TuneId &id)
Definition TuneId.cxx:165

References CheckDirectory(), Copy(), LOG, Name(), pWARN, and TuneId().

◆ ~TuneId()

genie::TuneId::~TuneId ( )
inline

Definition at line 43 of file TuneId.h.

43{;}

◆ TuneId() [3/3]

genie::TuneId::TuneId ( )
inlineprivate

Definition at line 89 of file TuneId.h.

89{;}

Member Function Documentation

◆ BaseDirectory()

string genie::TuneId::BaseDirectory ( void ) const
inline

Definition at line 76 of file TuneId.h.

76{ return fBaseDirectory; }
string fBaseDirectory
Definition TuneId.h:103

References fBaseDirectory.

◆ Build()

void TuneId::Build ( const string & name = "")

Definition at line 124 of file TuneId.cxx.

124 {
125 LOG("TuneId",pDEBUG)<<"Building tune "<<name;
126 if ( name.size() > 0 ) fName = name ;
127
128 this -> Decode( fName );
129 if ( ! fIsConfigured ) return; // no point going on
130
131 if ( this -> CheckDirectory() ) {
132 LOG("TuneId", pINFO) << Name() <<" Tune configured " ;
133 fIsValidated = true;
134 } else {
135 LOG("TuneId", pFATAL) << "No valid tune directory associated with " << Name() ;
136 fIsValidated = false;
137 }
138}
#define pINFO
Definition Messenger.h:62
#define pFATAL
Definition Messenger.h:56
#define pDEBUG
Definition Messenger.h:63
void Decode(string id_str)
Definition TuneId.cxx:140

References CheckDirectory(), Decode(), fIsConfigured, fIsValidated, fName, LOG, Name(), pDEBUG, pFATAL, and pINFO.

Referenced by genie::RunOpt::BuildTune(), and TuneId().

◆ CheckDirectory()

bool TuneId::CheckDirectory ( )
private

Definition at line 205 of file TuneId.cxx.

205 {
206
207 std::string pathlist = utils::xml::GetXMLPathList(false) ;
208 std::vector<std::string> paths = utils::str::Split(pathlist,":;,");
209
210 string top_path = gSystem->ExpandPathName( paths[0].c_str() ) ;
211 string def_path = gSystem->ExpandPathName( utils::xml::GetXMLDefaultPath().c_str() ) ;
212
213 if ( top_path != def_path ) {
214 fCustomSource = top_path ;
215 }
216
217 fBaseDirectory = "" ;
218 LOG("TuneId",pDEBUG) << "Base dir validation " ;
219
220 for ( size_t i=0; i< paths.size(); ++i ) {
221 const char* tmppath = paths[i].c_str();
222 std::string onepath = gSystem->ExpandPathName(tmppath);
223 string test = onepath + "/" + CMC() ;
224 LOG("TuneId", pDEBUG) << " Testing " << test << " directory" ;
225 if ( utils::system::DirectoryExists( test.c_str() ) ) {
226 fBaseDirectory = onepath ;
227 break ;
228 }
229 }
230
231 if ( fBaseDirectory.size() == 0 ) {
232 LOG("TuneId", pWARN) << " No " << CMC() << " subdirectory found in pathlist";
233 return false ;
234 }
235
236 if ( ! OnlyConfiguration() ) {
237 if ( ! utils::system::DirectoryExists( TuneDirectory().c_str() ) ) {
238 LOG("TuneId", pWARN) << "No " << Name() << " subdirectory found in " << CMC() ;
239 return false ;
240 }
241 }
242
243 LOG("TuneId",pDEBUG) << fBaseDirectory ;
244
245 return true ;
246}
string CMC(void) const
Definition TuneId.cxx:90
bool OnlyConfiguration() const
Definition TuneId.h:69
string fCustomSource
Definition TuneId.h:104
string TuneDirectory(void) const
Definition TuneId.cxx:116
vector< string > Split(string input, string delim)
bool DirectoryExists(const char *path)
string GetXMLPathList(bool add_tune=true)
string GetXMLDefaultPath()

References CMC(), genie::utils::system::DirectoryExists(), fBaseDirectory, fCustomSource, genie::utils::xml::GetXMLDefaultPath(), genie::utils::xml::GetXMLPathList(), LOG, Name(), OnlyConfiguration(), pDEBUG, pWARN, genie::utils::str::Split(), and TuneDirectory().

Referenced by Build(), and TuneId().

◆ CMC()

string TuneId::CMC ( void ) const

Definition at line 90 of file TuneId.cxx.

90 {
91
92 string cmc = fPrefix ;
93 cmc += fYear ;
94 cmc += "_" ;
95 cmc += ModelId() ;
96
97 return cmc ;
98}
string fPrefix
Definition TuneId.h:95
string fYear
Definition TuneId.h:96
string ModelId(void) const
Definition TuneId.h:49

References fPrefix, fYear, and ModelId().

Referenced by CheckDirectory(), and CMCDirectory().

◆ CMCDirectory()

string TuneId::CMCDirectory ( void ) const

Definition at line 107 of file TuneId.cxx.

107 {
108
109 string dir = fBaseDirectory ;
110 dir += "/" + CMC() ;
111
112 return dir ;
113
114}
string dir

References CMC(), dir, and fBaseDirectory.

Referenced by TuneDirectory().

◆ Compare()

bool TuneId::Compare ( const TuneId & id) const

Definition at line 179 of file TuneId.cxx.

180{
181 return (this->Name() == id.Name());
182}

References Name(), and TuneId().

Referenced by genie::operator!=(), and genie::operator==().

◆ Copy()

void TuneId::Copy ( const TuneId & id)

Definition at line 165 of file TuneId.cxx.

166{
167 this->fName = id.Name();
168 this->fPrefix = id.Prefix();
169 this->fYear = id.Year();
170 this->fMajorModelId = id.MajorModelId();
171 this->fMinorModelId = id.MinorModelId();
172 this->fTunedParamSetId = id.TunedParamSetId();
173 this->fFitDataSetId = id.FitDataSetId();
174
175 this->fIsConfigured = id.IsConfigured();
176 this->fIsValidated = id.IsValidated();
177}
string fTunedParamSetId
Definition TuneId.h:100
string fMinorModelId
Definition TuneId.h:99
string fFitDataSetId
Definition TuneId.h:101
string fMajorModelId
Definition TuneId.h:98

References fFitDataSetId, fIsConfigured, fIsValidated, fMajorModelId, fMinorModelId, fName, fPrefix, fTunedParamSetId, fYear, and TuneId().

Referenced by TuneId().

◆ CustomSource()

string genie::TuneId::CustomSource ( void ) const
inline

Definition at line 77 of file TuneId.h.

77{ return fCustomSource; }

References fCustomSource.

Referenced by genie::NtpWriter::Initialize().

◆ Decode()

void TuneId::Decode ( string id_str)

Definition at line 140 of file TuneId.cxx.

141{
142 static TPRegexp pattern("^([A-Za-z]+)(\\d{2})_(\\d{2})([a-z])_([a-z0-9]{2})_([a-z0-9]{3})$");
143 // TPRegexp pattern("([A-Za-z]+)(\\d{2})_(\\d{2})([a-z])_(\\d{2})_(\\d{3})");
144
145 TString tstr(id_str.c_str());
146 TObjArray * matches = pattern.MatchS(tstr);
147 if ( matches -> GetEntries() != 7) {
148 LOG("TuneId", pFATAL) << "Bad tune pattern "<<id_str<<" - form is eg G18_01a_00_000";
149 fIsConfigured = false;
150 return;
151 } else {
152 fIsConfigured = true;
153 }
154
155 this -> fPrefix = ((TObjString*)matches->At(1))->String().Data();
156 this -> fYear = ((TObjString*)matches->At(2))->String().Data();
157 this -> fMajorModelId = ((TObjString*)matches->At(3))->String().Data();
158 this -> fMinorModelId = ((TObjString*)matches->At(4))->String().Data();
159 this -> fTunedParamSetId = ((TObjString*)matches->At(5))->String().Data();
160 this -> fFitDataSetId = ((TObjString*)matches->At(6))->String().Data();
161
162 delete matches;
163}

References fFitDataSetId, fIsConfigured, fMajorModelId, fMinorModelId, fPrefix, fTunedParamSetId, fYear, LOG, and pFATAL.

Referenced by Build().

◆ FitDataSetId()

string genie::TuneId::FitDataSetId ( void ) const
inline

Definition at line 53 of file TuneId.h.

53{ return fFitDataSetId; } // xxx

References fFitDataSetId.

Referenced by Print().

◆ IsConfigured()

bool genie::TuneId::IsConfigured ( void ) const
inline

Definition at line 55 of file TuneId.h.

55{ return fIsConfigured; }

References fIsConfigured.

Referenced by Print().

◆ IsCustom()

bool genie::TuneId::IsCustom ( void ) const
inline

Definition at line 62 of file TuneId.h.

62{ return fCustomSource.size() > 0 ; }

References fCustomSource.

Referenced by genie::NtpWriter::Initialize(), and Print().

◆ IsValidated()

bool genie::TuneId::IsValidated ( void ) const
inline

Definition at line 59 of file TuneId.h.

59{ return fIsValidated; }

References fIsValidated.

Referenced by Print().

◆ MajorModelId()

string genie::TuneId::MajorModelId ( void ) const
inline

Definition at line 50 of file TuneId.h.

50{ return fMajorModelId; } // MM

References fMajorModelId.

Referenced by Print().

◆ MinorModelId()

string genie::TuneId::MinorModelId ( void ) const
inline

Definition at line 51 of file TuneId.h.

51{ return fMinorModelId; } // v

References fMinorModelId.

Referenced by Print().

◆ ModelId()

string genie::TuneId::ModelId ( void ) const
inline

Definition at line 49 of file TuneId.h.

49{ return fMajorModelId + fMinorModelId; } // MMv

References fMajorModelId, and fMinorModelId.

Referenced by CMC().

◆ Name()

string genie::TuneId::Name ( void ) const
inline

◆ OnlyConfiguration()

bool genie::TuneId::OnlyConfiguration ( ) const
inline

Definition at line 69 of file TuneId.h.

69{ return (TunedParamSetId() == "00") ; }
string TunedParamSetId(void) const
Definition TuneId.h:52

References TunedParamSetId().

Referenced by CheckDirectory(), and TuneDirectory().

◆ Prefix()

string genie::TuneId::Prefix ( void ) const
inline

Definition at line 47 of file TuneId.h.

47{ return fPrefix; } // G

References fPrefix.

Referenced by Print().

◆ Print()

void TuneId::Print ( ostream & stream) const

Definition at line 184 of file TuneId.cxx.

185{
186 std::string status = "Standard";
187 if ( IsCustom() ) status = "Custom";
188 if ( ! IsValidated() ) status = "BadDirectory";
189 if ( ! IsConfigured() ) status = "BadConfig";
190 stream << status << " GENIE tune: " << this -> Name() << std::endl;
191 stream << " - Prefix ............... : " << this->Prefix() << std::endl;
192 stream << " - Year ................. : " << this->Year() << std::endl;
193 stream << " - Major model ID ....... : " << this->MajorModelId() << std::endl;
194 stream << " - Minor model ID ....... : " << this->MinorModelId() << std::endl;
195 stream << " - Tuned param set ID ... : " << this->TunedParamSetId() << std::endl;
196 stream << " - Fit dataset ID ....... : " << this->FitDataSetId() << std::endl;
197 stream << " - Tune directory ....... : " << this->TuneDirectory() << std::endl;
198 stream << " - Base directory ....... : " << this->fBaseDirectory << std::endl;
199 if ( IsCustom() )
200 stream << " - Custom directory ..... : " << this -> fCustomSource << std::endl;
201
202 stream << std::flush;
203}
string Prefix(void) const
Definition TuneId.h:47
string FitDataSetId(void) const
Definition TuneId.h:53
string Year(void) const
Definition TuneId.h:48
bool IsCustom(void) const
Definition TuneId.h:62
bool IsValidated(void) const
Definition TuneId.h:59
bool IsConfigured(void) const
Definition TuneId.h:55
string MajorModelId(void) const
Definition TuneId.h:50
string MinorModelId(void) const
Definition TuneId.h:51

References fBaseDirectory, fCustomSource, FitDataSetId(), IsConfigured(), IsCustom(), IsValidated(), MajorModelId(), MinorModelId(), Name(), Prefix(), TuneDirectory(), TunedParamSetId(), and Year().

◆ Tail()

string TuneId::Tail ( void ) const

Definition at line 100 of file TuneId.cxx.

100 {
101
102 string tail = fTunedParamSetId ;
103 tail += "_" + fFitDataSetId ;
104 return tail ;
105}

References fFitDataSetId, and fTunedParamSetId.

◆ TuneDirectory()

string TuneId::TuneDirectory ( void ) const

Definition at line 116 of file TuneId.cxx.

116 {
117
118 string dir = CMCDirectory() ;
119 if ( ! OnlyConfiguration() ) dir += "/" + Name() ;
120
121 return dir ;
122}
string CMCDirectory(void) const
Definition TuneId.cxx:107

References CMCDirectory(), dir, Name(), and OnlyConfiguration().

Referenced by CheckDirectory(), genie::NtpWriter::Initialize(), and Print().

◆ TunedParamSetId()

string genie::TuneId::TunedParamSetId ( void ) const
inline

Definition at line 52 of file TuneId.h.

52{ return fTunedParamSetId; } // PP

References fTunedParamSetId.

Referenced by OnlyConfiguration(), and Print().

◆ Year()

string genie::TuneId::Year ( void ) const
inline

Definition at line 48 of file TuneId.h.

48{ return fYear; } // dd

References fYear.

Referenced by Print().

◆ operator<<

ostream & operator<< ( ostream & stream,
const TuneId & id )
friend

Definition at line 35 of file TuneId.cxx.

36 {
37 id.Print(stream);
38 return stream;
39 }

References TuneId().

Member Data Documentation

◆ fBaseDirectory

string genie::TuneId::fBaseDirectory
private

Definition at line 103 of file TuneId.h.

Referenced by BaseDirectory(), CheckDirectory(), CMCDirectory(), and Print().

◆ fCustomSource

string genie::TuneId::fCustomSource
private

Definition at line 104 of file TuneId.h.

Referenced by CheckDirectory(), CustomSource(), IsCustom(), and Print().

◆ fFitDataSetId

string genie::TuneId::fFitDataSetId
private

Definition at line 101 of file TuneId.h.

Referenced by Copy(), Decode(), FitDataSetId(), and Tail().

◆ fIsConfigured

bool genie::TuneId::fIsConfigured
private

Definition at line 106 of file TuneId.h.

Referenced by Build(), Copy(), Decode(), IsConfigured(), and TuneId().

◆ fIsValidated

bool genie::TuneId::fIsValidated
private

Definition at line 107 of file TuneId.h.

Referenced by Build(), Copy(), IsValidated(), and TuneId().

◆ fMajorModelId

string genie::TuneId::fMajorModelId
private

Definition at line 98 of file TuneId.h.

Referenced by Copy(), Decode(), MajorModelId(), and ModelId().

◆ fMinorModelId

string genie::TuneId::fMinorModelId
private

Definition at line 99 of file TuneId.h.

Referenced by Copy(), Decode(), MinorModelId(), and ModelId().

◆ fModelId

string genie::TuneId::fModelId
private

Definition at line 97 of file TuneId.h.

◆ fName

string genie::TuneId::fName
private

Definition at line 93 of file TuneId.h.

Referenced by Build(), Copy(), Name(), and TuneId().

◆ fPrefix

string genie::TuneId::fPrefix
private

Definition at line 95 of file TuneId.h.

Referenced by CMC(), Copy(), Decode(), and Prefix().

◆ fTunedParamSetId

string genie::TuneId::fTunedParamSetId
private

Definition at line 100 of file TuneId.h.

Referenced by Copy(), Decode(), Tail(), and TunedParamSetId().

◆ fYear

string genie::TuneId::fYear
private

Definition at line 96 of file TuneId.h.

Referenced by CMC(), Copy(), Decode(), and Year().


The documentation for this class was generated from the following files: