JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwRunCondition.cc
Go to the documentation of this file.
1/*!
2 * \file QwRunCondition.cc
3 * \brief Implementation for run condition management and metadata
4 * \author jhlee@jlab.org
5 * \date 2010-09-09
6 */
7
8#include "QwRunCondition.h"
9#include "version-config.h"
10
11// External objects
12extern const char* const gGitInfo;
13
14const Int_t QwRunCondition::fCharLength = 127;
15
16QwRunCondition::QwRunCondition(Int_t argc, Char_t* argv[], TString name)
17{
18
19 fROCFlagFileName = "qwvmets.flags";
20
21 fRunConditionList = new TList;
22 fRunConditionList -> SetOwner(true);
23 this->SetArgs(argc, argv);
24 this->SetName(name);
25
26}
27
28
33
34
35void
36QwRunCondition::SetArgs(Int_t argc, Char_t* argv[])
37{
38
39 // get ROOT release version, date, svn revision and branch
40 // TROOT.h (ROOT)
41 TString root_version = gROOT->GetVersion();
42 root_version += ", Date : ";
43 root_version += gROOT->GetVersionDate();
44#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
45 root_version += ", SVN : ";
46 root_version += gROOT->GetSvnRevision();
47 root_version += " ";
48 root_version += gROOT->GetSvnBranch();
49#else // ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
50 root_version += ", GIT : ";
51 root_version += gROOT->GetGitCommit();
52 root_version += " ";
53 root_version += gROOT->GetGitBranch();
54#endif
55
56 // get hostname and user name
57 char host_string[fCharLength];
58 char user_string[fCharLength];
59
60 gethostname(host_string, fCharLength);
61 getlogin_r (user_string, fCharLength);
62
63 TString host_name = host_string;
64 TString user_name = user_string;
65
66 // get program name and its arguments (options)
67 TString QwVersion = Form("%d.%d.%d",QWANALYSIS_VERSION_MAJOR, QWANALYSIS_VERSION_MINOR, QWANALYSIS_VERSION_PATCH);
68 TString program_name = argv[0];
69 TString argv_list;
70 for (Int_t i=1; i<argc; i++) argv_list += argv[i];
71
72 // get current time when a ROOT file is created
73 TTimeStamp time_stamp;
74 TString current_time = time_stamp.AsString("l"); // local time
75
76 // get current ROC flags
77 TString roc_flags;
78 // if one of the cdaq cluster AND the user must be a "cdaq",
79 if( (host_name.Contains("cdaql")) and (not user_name.CompareTo("cdaq", TString::kExact)) ) {
80 roc_flags = this->GetROCFlags();
81 }
82 else {
83 roc_flags = "Invalid, because the system is not cdaqlx and the user is not cdaq.";
84 }
85
86 // insert some comments at the beginning of strings...
87 root_version.Insert (0, "ROOT Version : ");
88 current_time.Insert (0, "ROOT file creating time : ");
89 host_name.Insert (0, "ROOT file created on Hostname : ");
90 user_name.Insert (0, "ROOT file created by the user : ");
91
92 program_name.Insert (0, "QwAnalyzer Name : ");
93 QwVersion.Insert (0, "Version : ");
94 argv_list.Insert (0, "QwAnalyzer Options : ");
95
96 roc_flags.Insert (0, "DAQ ROC flags when QwAnalyzer runs : ");
97
98 // add them into list to be returned to main program.
99
100 this -> Add(root_version);
101 this -> Add(program_name);
102 this -> Add(QwVersion);
103 this -> Add(host_name);
104 this -> Add(user_name);
105 this -> Add(argv_list);
106 this -> Add(current_time);
107 this -> Add(gGitInfo);
108 this -> Add(roc_flags);
109
110 return;
111}
112
113
114void
116{
117 fRunConditionList -> AddLast(new TObjString(in));
118 return;
119}
120
121
122TList *
127
128
129
130TString
132{
133 TString name = fRunConditionList->GetName();
134 return name;
135}
136
137
138void
140{
141 fRunConditionList->SetName(name);
142 return;
143}
144
145
146
147TString
149{
150
151 Bool_t local_debug = false;
152 TString flags;
153
154 std::ifstream flag_file;
155 flag_file.clear();
156
157 fROCFlagFileName.Insert(0, "/home/cdaq/qweak/Settings/");
158
159 flag_file.open(fROCFlagFileName);
160
161 if(not flag_file.is_open()) {
162 std::cout << "There is no flag file, which you try to access "
164 << std::endl;
165 flags = fROCFlagFileName;
166 flags += " is not found";
167
168 }
169 else {
170 while (not flag_file.eof() )
171 {
172 TString line;
173 line.ReadLine(flag_file);
174 if(not line.IsNull()) {
175 if(local_debug) {
176 std::cout << line << std::endl;
177 }
178 if(not line.Contains(";")) {
179 flags = line;
180 }
181 } // if(not line.IsNull()) {
182 } // while (not flag_file.eof() ) {
183 }
184 flag_file.close();
185
186 return flags;
187
188}
Run condition management and metadata.
const char *const gGitInfo
TString GetROCFlags()
void SetArgs(Int_t argc, Char_t *argv[])
TList * fRunConditionList
virtual ~QwRunCondition()
void Add(TString in)
void SetName(const TString name)
TString fROCFlagFileName
static const Int_t fCharLength