GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TRunInfo.cxx
Go to the documentation of this file.
1#include "TRunInfo.h"
2#include "TMnemonic.h"
3
4#include <fstream>
5#include <sstream>
6#include <algorithm>
7#include <iostream>
8
9#include "TROOT.h"
10
11#include "TGRSIOptions.h"
12#include "GVersion.h"
13#include "TGRSIUtilities.h"
14
15Bool_t TRunInfo::ReadInfoFromFile(TFile* tempf)
16{
17 TDirectory* savdir = gDirectory;
18 if(tempf != nullptr) {
19 tempf->cd();
20 }
21
22 if((gDirectory->GetFile()) == nullptr) {
23 std::cout << "File does not exist" << std::endl;
24 savdir->cd();
25 return false;
26 }
27
28 tempf = gDirectory->GetFile();
29
30 // try and read the run info directly
31 if(tempf->FindObjectAny("TRunInfo") != nullptr) {
32 Get()->fDetectorInformation = static_cast<TDetectorInformation*>(tempf->Get("TRunInfo"));
33 savdir->cd();
34 return true;
35 }
36
37 // if the above failed we try all keys to find a run info
38 TList* list = tempf->GetListOfKeys();
39 TIter iter(list);
40 TKey* key = nullptr;
41 while((key = static_cast<TKey*>(iter.Next())) != nullptr) {
42 if(strcmp(key->GetClassName(), "TRunInfo") != 0) {
43 continue;
44 }
45
46 Set(static_cast<TRunInfo*>(key->ReadObj()));
47 Get()->fDetectorInformation = nullptr; // just to be safe
48 // see if we can find detector information
49 while((key = static_cast<TKey*>(iter.Next())) != nullptr) {
50 // for some reason the classic way of using TClass::InheritsFrom fails in grsiproof
51 // so instead we just try to dynamically cast every key into TDetectorInformation
52 Get()->fDetectorInformation = dynamic_cast<TDetectorInformation*>(key->ReadObj());
53 if(Get()->fDetectorInformation != nullptr) { break; }
54 }
55 savdir->cd();
56 return true;
57 }
58 savdir->cd();
59
60 return false;
61}
62
64{
65 /// Default ctor for TRunInfo. The default values are:
66 ///
67 /// fHPGeArrayPosition = 110.0;
68
69 Clear();
70}
71
72void TRunInfo::Print(Option_t* opt) const
73{
74 /// Prints the TRunInfo. Options:
75 /// a: Print out more details (array position and detector information).
77 std::ostringstream str;
78 str << "Title: " << RunTitle() << std::endl;
79 str << "Comment: " << RunComment() << std::endl;
80 auto tmpStart = static_cast<time_t>(RunStart());
81 auto tmpStop = static_cast<time_t>(RunStop());
82 struct tm runStart = *localtime(&tmpStart);
83 struct tm runStop = *localtime(&tmpStop);
84 str << std::setfill('0');
85 if(RunNumber() != 0 && SubRunNumber() != -1) {
86 str << "\t\tRunNumber: " << std::setw(5) << RunNumber() << std::endl;
87 str << "\t\tSubRunNumber: " << std::setw(3) << SubRunNumber() << std::endl;
88 } else if(RunNumber() != 0) {
89 str << "\t\tRunNumber: " << std::setw(5) << RunNumber() << std::endl;
90 str << "\t\tSubRunNumbers: " << std::setw(3) << FirstSubRunNumber() << "-" << std::setw(3) << LastSubRunNumber() << std::endl;
91 } else if(FirstRunNumber() != LastRunNumber()) {
92 str << "\t\tRunNumbers: " << std::setw(5) << FirstRunNumber() << "-" << std::setw(5) << LastRunNumber() << std::endl;
93 str << "\t\tNo missing runs" << std::endl;
94 } else if(!fRunList.empty()) {
95 str << "\t\tRunNumbers: " << std::setw(5) << fRunList.begin()->first << "-" << std::setw(5) << fRunList.rbegin()->first << std::endl;
96 str << "\t\tMissing runs: " << ListOfMissingRuns() << std::endl;
97 } else {
98 str << "\t\tNo runs in list?" << std::endl;
99 }
100 str << std::setfill(' ');
101 if(RunStart() != 0 && RunStop() != 0) {
102 str << "\t\tRunStart: " << asctime(&runStart);
103 str << "\t\tRunStop: " << asctime(&runStop);
104 str << "\t\tRunLength: " << RunLength() << " s" << std::endl;
105 } else {
106 str << "\t\tCombined RunLength: " << RunLength() << " s" << std::endl;
107 }
108 if(strchr(opt, 'a') != nullptr) {
109 str << std::endl;
110 str << "\t==============================" << std::endl;
111 str << DBLUE "\t\tArray Position (mm) = " << DRED << TRunInfo::HPGeArrayPosition() << RESET_COLOR << std::endl;
112 if(fDetectorInformation != nullptr) {
114 } else {
115 str << "no detector information" << std::endl;
116 }
117 str << "\t==============================" << std::endl;
118 }
119 std::cout << str.str();
120}
121
122void TRunInfo::Clear(Option_t*)
123{
124 // Clears the TRunInfo. Currently, there are no available
125 // options.
126
127 fHPGeArrayPosition = 110.0;
128
129 fBadCycleList.clear();
130
132 fDetectorInformation = nullptr;
133}
134
135void TRunInfo::SetRunInfo(int runnum, int subrunnum)
136{
137 /// Sets the run info. This figures out what systems are available.
138
139 std::cout << "found " << TChannel::GetNumberOfChannels() << " channels" << std::endl;
140 if(runnum != 0) {
141 if(RunNumber() != 0 && RunNumber() != runnum) {
142 std::cout << "Warning, overwriting non-default run-number " << RunNumber() << " with " << runnum << std::endl;
143 }
144 SetRunNumber(runnum);
145 }
146 if(subrunnum != -1) {
147 if(SubRunNumber() != -1 && SubRunNumber() != subrunnum) {
148 std::cout << "Warning, overwriting non-default sub-run-number " << SubRunNumber() << " with " << subrunnum
149 << std::endl;
150 }
151 SetSubRunNumber(subrunnum);
152 }
153
154 if(Get()->fRunInfoFile.length() != 0u) {
155 ParseInputData(Get()->fRunInfoFile.c_str());
156 }
157
158 // set version of GRSISort
160 TRunInfo::SetVersion(GRSI_RELEASE);
161
163 TRunInfo::SetFullVersion(GRSI_GIT_COMMIT);
164
166 TRunInfo::SetDate(GRSI_GIT_COMMIT_TIME);
167}
168
170{
171 // Currently does nothing.
172}
173
174Bool_t TRunInfo::ReadInfoFile(const char* filename)
175{
176 /// Read in a run info file. These files have the extension .info.
177 std::string infilename;
178 infilename.append(filename);
179 std::cout << "Reading info from file: " << CYAN << filename << RESET_COLOR << std::endl;
180 if(infilename.length() == 0) {
181 std::cout << "Bad file name length" << std::endl;
182 return false;
183 }
184
185 std::ifstream infile;
186 infile.open(infilename.c_str());
187 if(!infile) {
188 std::cout << "could not open file." << std::endl;
189 return false;
190 }
191 infile.seekg(0, std::ios::end);
192 auto length = infile.tellg();
193 if(length < 1) {
194 std::cout << "file is empty." << std::endl;
195 return false;
196 }
197 auto* buffer = new char[length];
198 infile.seekg(0, std::ios::beg);
199 infile.read(buffer, length);
200
201 SetRunInfoFileName(filename);
202 SetRunInfoFile(buffer);
203
204 return ParseInputData(buffer);
205}
206
207Bool_t TRunInfo::ParseInputData(const char* inputdata, Option_t* opt)
208{
209 // A helper function to parse the run info file.
210
211 std::istringstream infile(inputdata);
212 std::string line;
213 int linenumber = 0;
214
215 // Parse the info file.
216 while(!std::getline(infile, line).fail()) {
217 linenumber++;
218 trim(line);
219 size_t comment = line.find("//");
220 if(comment != std::string::npos) {
221 line = line.substr(0, comment);
222 }
223 if(line.length() == 0u) {
224 continue;
225 }
226
227 size_t ntype = line.find(':');
228 if(ntype == std::string::npos) {
229 continue; // no seperator, not useful.
230 }
231
232 std::string type = line.substr(0, ntype);
233 line = line.substr(ntype + 1, line.length());
234 trim(line);
235 std::transform(type.begin(), type.end(), type.begin(), ::toupper);
236 if(type == "CAL" || type == "CALFILE") {
237 // TODO Make this work again, using priorities
238 // TGRSIOptions::AddInputCalFile(line);
239 } else if(type == "MID" || type == "MIDAS" || type == "MIDASFILE") {
240 // TODO Make this work again, using priorities
241 // TGRSIOptions::AddInputMidasFile(line);
242 } else if(type == "ARRAYPOS" || type == "HPGEPOS") {
243 std::istringstream str(line);
244 double temp_double = 0.;
245 str >> temp_double;
247 } else if(type == "BADCYCLE") {
248 std::istringstream str(line);
249 int tmp_int = 0;
250 while(!(str >> tmp_int).fail()) {
251 TRunInfo::AddBadCycle(tmp_int);
252 }
253 }
254 }
255
256 if(strcmp(opt, "q") != 0) {
257 std::cout << "parsed " << linenumber << " lines." << std::endl;
258 std::cout << DBLUE "\tArray Position (mm) = " << DRED << TRunInfo::HPGeArrayPosition() << RESET_COLOR << std::endl;
259 }
260 return true;
261}
262
263Long64_t TRunInfo::Merge(TCollection* list)
264{
265 // Loop through the TCollection of TRunInfos, and add each entry to the original TRunInfo List
266 TIter iter(list);
267 // The TCollection will be filled by something like hadd. Each element in the list will be a TRunInfo from
268 // an individual file that was submitted to hadd.
269 TRunInfo* runinfo = nullptr;
270
271 while((runinfo = static_cast<TRunInfo*>(iter.Next())) != nullptr) {
272 Add(runinfo);
273 }
274 return 0;
275}
276
278{
279 std::cout << "Bad Cycles:\t";
280 if(Get()->fBadCycleList.empty()) {
281 std::cout << "NONE" << std::endl;
282 } else {
283 for(int item : Get()->fBadCycleList) {
284 std::cout << " " << item;
285 }
286 std::cout << std::endl;
287 }
288}
289
290void TRunInfo::AddBadCycle(int bad_cycle)
291{
292 if(!(std::binary_search(Get()->fBadCycleList.begin(), Get()->fBadCycleList.end(), bad_cycle))) {
293 Get()->fBadCycleList.push_back(bad_cycle);
294 std::sort(Get()->fBadCycleList.begin(), Get()->fBadCycleList.end());
295 }
296}
297
299{
300 Get()->fBadCycleList.erase(std::remove(Get()->fBadCycleList.begin(), Get()->fBadCycleList.end(), cycle), Get()->fBadCycleList.end());
301 std::sort(Get()->fBadCycleList.begin(), Get()->fBadCycleList.end());
302}
303
304bool TRunInfo::IsBadCycle(int cycle)
305{
306 return std::binary_search(Get()->fBadCycleList.begin(), Get()->fBadCycleList.end(), cycle);
307}
308
309bool TRunInfo::WriteToRoot(TFile* fileptr)
310{
311 /// Writes Info File information to the tree
312 // Maintain old gDirectory info
313 bool bool2return = true;
314 TDirectory* savdir = gDirectory;
315 gROOT->cd();
316 TRunInfo* runInfo = Get();
317
318 if(fileptr == nullptr) {
319 fileptr = gDirectory->GetFile();
320 }
321 fileptr->cd();
322 std::string oldoption = std::string(fileptr->GetOption());
323 if(oldoption == "READ") {
324 fileptr->ReOpen("UPDATE");
325 }
326 if(!gDirectory) {
327 std::cout << "No file opened to write TRunInfo to." << std::endl;
328 bool2return = false;
329 } else {
330 runInfo->Write("RunInfo", TObject::kOverwrite);
331 if(runInfo->fDetectorInformation != nullptr) { runInfo->fDetectorInformation->Write("DetectorInformation", TObject::kOverwrite); }
332 }
333
334 std::cout << "Writing TRunInfo to " << gDirectory->GetFile()->GetName() << std::endl;
335 if(oldoption == "READ") {
336 std::cout << " Returning " << gDirectory->GetFile()->GetName() << " to \"" << oldoption << "\" mode." << std::endl;
337 fileptr->ReOpen("READ");
338 }
339 savdir->cd(); // Go back to original gDirectory
340
341 return bool2return;
342}
343
344bool TRunInfo::WriteInfoFile(const std::string& filename)
345{
346
347 if(filename.length() > 0) {
348 std::ofstream infoout;
349 infoout.open(filename.c_str());
350 std::string infostr = TRunInfo::PrintToString();
351 infoout << infostr.c_str();
352 infoout << std::endl;
353 infoout << std::endl;
354 infoout.close();
355 } else {
356 std::cout << "Please enter a file name" << std::endl;
357 return false;
358 }
359
360 return true;
361}
362
363std::string TRunInfo::PrintToString(Option_t*)
364{
365 std::string buffer;
366 buffer.append("//The Array Position in mm.\n");
367 buffer.append(Form("HPGePos: %lf\n", HPGeArrayPosition()));
368 buffer.append("\n\n");
369 if(!Get()->fBadCycleList.empty()) {
370 buffer.append("//A List of bad cycles.\n");
371 buffer.append("BadCycle:");
372 for(int& item : Get()->fBadCycleList) {
373 buffer.append(Form(" %d", item));
374 }
375 buffer.append("\n\n");
376 }
377
378 return buffer;
379}
380
382{
383 std::cout << this << ": default build mode " << static_cast<int>(TEventBuildingLoop::EBuildMode::kDefault) << std::endl;
385}
386
387void TRunInfo::Add(TRunInfo* runinfo, bool verbose)
388{
389 // add new run to list of runs (and check if the current run needs to be added)
390 //if(fRunList.empty()) {
391 // fRunList.emplace(fRunNumber, fSubRunNumber);
392 //}
393 std::pair<int, int> newPair = std::make_pair(runinfo->fRunNumber, runinfo->fSubRunNumber);
394 // check for dual entries
395 if(fRunList.find(newPair) != fRunList.end()) {
396 std::cerr << DYELLOW << "Warning, adding run " << std::setfill('0') << std::setw(5) << newPair.first << "_" << std::setw(3) << newPair.second << std::setfill(' ') << " again!" << RESET_COLOR << std::endl;
397 return;
398 }
399 fRunList.insert(newPair);
400
401 if(verbose) { std::cout << "adding run " << runinfo->fRunNumber << ", sub run " << runinfo->fSubRunNumber << " to run " << fRunNumber << ", sub run " << fSubRunNumber << std::endl; }
402 // add the run length together
403 if(runinfo->fRunLength > 0) {
404 if(fRunLength > 0) {
405 fRunLength += runinfo->fRunLength;
406 } else {
407 fRunLength = runinfo->fRunLength;
408 }
409 }
410
411 if(runinfo->fRunNumber != fRunNumber) {
412 // check if the added run is an increment of the current run number (if the run number is set)
413 if(fRunNumber != 0) {
414 if(runinfo->fRunNumber + 1 == fRunNumber) {
415 if(verbose) { std::cout << "found second run (" << runinfo->fRunNumber << ") before current run (" << fRunNumber << ")" << std::endl; }
416 // use runinfo as first run and the current run as last
417 fFirstRunNumber = runinfo->fRunNumber;
419 fRunStart = runinfo->fRunStart; // no need to set run stop
420 } else if(runinfo->fRunNumber - 1 == fRunNumber) {
421 if(verbose) { std::cout << "found second run (" << runinfo->fRunNumber << ") after current run (" << fRunNumber << ")" << std::endl; }
422 // use runinfo as last run and the current run as first
424 fLastRunNumber = runinfo->fRunNumber;
425 fRunStop = runinfo->fRunStop; // no need to set run start
426 } else {
427 if(verbose) { std::cout << "found second run (" << runinfo->fRunNumber << ") non-consecutive to run (" << fRunNumber << ")" << std::endl; }
428 // run start and stop don't make a lot of sense with non-consecutive runs (?)
429 fRunStart = 0.;
430 fRunStop = 0.;
431 // still need to keep some kind of information about the runs (e.g. to create filenames)
432 // by keeping first and last the exact same it is still obvious that these are not consecutive runs
435 }
436 // the run number is meaningful only when the run numbers are the same
437 fRunNumber = 0;
438 fSubRunNumber = -1;
439 } else if(fFirstRunNumber != 0 && fLastRunNumber != 0 && fFirstRunNumber != fLastRunNumber) {
440 // if we already have a (good) range of runs, check if runinfo fits at the beginning or the end
441 if(runinfo->fRunNumber + 1 == fFirstRunNumber) {
442 if(verbose) { std::cout << "found another run (" << runinfo->fRunNumber << ") before first run (" << fFirstRunNumber << ")" << std::endl; }
443 // use runinfo as first run
444 fFirstRunNumber = runinfo->fRunNumber;
445 fRunStart = runinfo->fRunStart;
446 } else if(runinfo->fRunNumber - 1 == fLastRunNumber) {
447 if(verbose) { std::cout << "found another run (" << runinfo->fRunNumber << ") after last run (" << fLastRunNumber << ")" << std::endl; }
448 // use runinfo as last run
449 fLastRunNumber = runinfo->fRunNumber;
450 fRunStop = runinfo->fRunStop;
451 } else if(runinfo->fRunNumber == fFirstRunNumber || runinfo->fRunNumber == fLastRunNumber) {
452 if(verbose) { std::cout << "found another sub(?) run part of runs (" << fFirstRunNumber << " - " << fLastRunNumber << ")" << std::endl; }
453 // found probably another subrun of a run already added
454 // since we do not keep track of all subruns we have to assume this is in order
455 // so we only update the run start or stop if necessary
456 if(verbose) { std::cout << "changing run start/stop from " << std::setw(16) << fRunStart << "/" << std::setw(16) << fRunStop << " to "; }
458 if(fRunStart > runinfo->fRunStart) { fRunStart = runinfo->fRunStart; }
459 if(verbose) { std::cout << std::setw(16) << fRunStart << "/" << std::setw(16) << fRunStop << std::endl; }
460 } else {
461 if(verbose) { std::cout << "found another run (" << runinfo->fRunNumber << ") non-consecutive to runs (" << fFirstRunNumber << " - " << fLastRunNumber << ")" << std::endl; }
462 // run start and stop don't make a lot of sense with non-consecutive runs (?)
463 fRunStart = 0.;
464 fRunStop = 0.;
465 // still need to keep some kind of information about the runs (e.g. to create filenames)
466 // by keeping first and last the exact same it is still obvious that these are not consecutive runs
468 }
469 } else {
470 // the run number is zero, and we do not have a (good) range, so there is nothing to do.
471 if(verbose) { std::cout << "found another run (" << runinfo->fRunNumber << ") non-consecutive run (" << fFirstRunNumber << " - " << fLastRunNumber << ")" << std::endl; }
472 }
473 } else if(fSubRunNumber != -1) {
474 // check if the added sub run is an increment of the current run number
475 if(runinfo->fSubRunNumber + 1 == fSubRunNumber) {
476 if(verbose) { std::cout << "found second sub run (" << runinfo->fSubRunNumber << ") before current sub run (" << fSubRunNumber << ")" << std::endl; }
477 // if the run numbers are the same and we have subsequent sub runs we can update the run start
478 fRunStart = runinfo->fRunStart;
481 } else if(runinfo->fSubRunNumber - 1 == fSubRunNumber) {
482 if(verbose) { std::cout << "found second sub run (" << runinfo->fSubRunNumber << ") after current sub run (" << fSubRunNumber << ")" << std::endl; }
483 // if the run numbers are the same and we have subsequent sub runs we can update the run stop
484 fRunStop = runinfo->fRunStop;
487 } else {
488 if(verbose) { std::cout << "found second sub run (" << runinfo->fSubRunNumber << ") non-consecutive to current sub run (" << fSubRunNumber << ")" << std::endl; }
489 // with multiple non-sequential subruns added, the sub run number and start/stop have no meaning anymore
490 fRunStart = 0.;
491 fRunStop = 0.;
494 }
495 // sub run number is only meaningful if it's the only sub run
496 fSubRunNumber = -1;
497 } else {
498 // we have the same run with a range of sub-runs already added, so check if this one fits at the end or the beginning
499 if(runinfo->fSubRunNumber + 1 == fFirstSubRunNumber) {
500 if(verbose) { std::cout << "found another sub run (" << runinfo->fSubRunNumber << ") before first sub run (" << fFirstSubRunNumber << ")" << std::endl; }
501 // use runinfo as first run
503 fRunStart = runinfo->fRunStart;
504 } else if(runinfo->fSubRunNumber - 1 == fLastSubRunNumber) {
505 if(verbose) { std::cout << "found another sub run (" << runinfo->fSubRunNumber << ") after last sub run (" << fLastSubRunNumber << ")" << std::endl; }
506 // use runinfo as last run
508 fRunStop = runinfo->fRunStop;
509 } else {
510 if(verbose) { std::cout << "found another sub run (" << runinfo->fSubRunNumber << ") non-consecutive to sub runs (" << fFirstSubRunNumber << " - " << fLastSubRunNumber << ")" << std::endl; }
511 // with multiple non-sequential subruns added, the sub run number and start/stop have no meaning anymore
512 fRunStart = 0.;
513 fRunStop = 0.;
516 }
517 }
518}
519
521{
522 if(fRunList.empty()) {
523 std::cout << "No runs added to list of runs!" << std::endl;
524 return;
525 }
526 std::cout << "Got " << fRunList.size() << " runs:" << std::endl;
527 for(auto pair : fRunList) {
528 std::cout << std::setw(5) << std::setfill('0') << pair.first << "_" << std::setw(3) << pair.second << std::setfill(' ') << std::endl;
529 }
530}
531
532std::string TRunInfo::ListOfMissingRuns(bool all) const
533{
534 /// Outputs a comma separated list of all runs missing between fFirstRunNumber and fLastRunNumber.
535 /// If no runs are missing prints "none".
536
537 if(fRunList.empty()) {
538 return {"no run list -> none missing?"};
539 }
540
541 std::ostringstream result;
542
543 // loop over all runs between the first and the last one (we know that these two are included)
544 // and check if the run is in the list of runs (or any subrun that is part of this run)
545 for(int run = fRunList.begin()->first; run < fRunList.rbegin()->first; ++run) {
546 if(std::find_if(fRunList.begin(), fRunList.end(), [&run](std::pair<int, int> i) { return run == i.first; }) == fRunList.end()) {
547 if(!result.str().empty()) {
548 result << ", ";
549 }
550 result << std::setw(5) << std::setfill('0') << run;
551 }
552 }
553
554 // if we found no missing runs, we print "none"
555 if(result.str().empty()) {
556 return {"none"};
557 }
558
559 // unless the "all" flag is set, we limit ourself to printing 140 characters (should be 20 runs?)
560 std::cout << " current string length is " << result.str().length() << " and all is set to " << (all ? "true" : "false") << std::endl;
561 if(!all && result.str().length() > 140) {
562 result.str(result.str().substr(0, 140));
563 result.seekp(0, std::ios_base::end);
564 result << " ... and more";
565 std::cout << " limited string length is " << result.str().length() << std::endl;
566 }
567 return result.str();
568}
569
571{
572 if(fVersion.empty()) {
573 std::cout << YELLOW << "Unknown version, this file was probably generated with TRunInfo version 17 or older" << RESET_COLOR << std::endl;
574 } else {
575 std::cout << "This file was generated with GRSISort version " << fVersion << " (" << fFullVersion << ")" << std::endl
576 << "From " << fDate << std::endl
577 << "Using the parser library version " << fLibraryVersion << " from " << fLibraryPath << std::endl;
578 }
579}
580
581std::string TRunInfo::CreateLabel(bool quiet)
582{
583 /// This function creates a label/string based on the run number and the subrun number.
584 Int_t runNumber = RunNumber();
585 Int_t subRunNumber = SubRunNumber();
586
587 std::string result;
588 if(!quiet) { std::cout << "Using run number " << runNumber << ", sub run number " << subRunNumber << ", first/last run number " << FirstRunNumber() << "/" << LastRunNumber() << ", and first/last sub run number" << FirstSubRunNumber() << "/" << LastSubRunNumber() << std::endl; }
589 if(runNumber != 0 && subRunNumber != -1) {
590 // both run and subrun number set => single file processed
591 result = Form("%05d_%03d", runNumber, subRunNumber);
592 } else if(runNumber != 0) {
593 // multiple subruns of a single run
594 // we could check if first and last sub run number are both -1 (which is non-consecutive runs or not initialized, the latter would mean single file w/o a subrun number, like ILL data)
595 result = Form("%05d_%03d-%03d", runNumber, FirstSubRunNumber(), LastSubRunNumber());
596 } else {
597 // multiple runs
598 result = Form("%05d-%05d", FirstRunNumber(), LastRunNumber());
599 }
600 if(!quiet) { std::cout << "Created label " << result << std::endl; }
601
602 return result;
603}
604
605//void TRunInfo::Streamer(TBuffer &R__b)
606//{
607// /// Stream an object of class TRunInfo.
608// /// Explicitly writes and reads the static members as well!
609//
610// if(R__b.IsReading()) {
611// R__b.ReadClassBuffer(TRunInfo::Class(),this);
612// Version_t R__v = R__b.ReadVersion();
613// std::cout << "Got R__v = " << R__v << std::endl;
614// if(R__v > 17) {
615// R__b.ReadStdString(fVersion);
616// R__b.ReadStdString(fFullVersion);
617// R__b.ReadStdString(fDate);
618// R__b.ReadStdString(fLibraryVersion);
619// R__b.ReadStdString(fLibraryPath);
620// } else {
621// fVersion = "unknown";
622// fFullVersion = "unknown";
623// fDate = "unknown";
624// fLibraryVersion = "unknown";
625// fLibraryPath = "unknown";
626// }
627// } else {
628// R__b.WriteClassBuffer(TRunInfo::Class(),this);
629// R__b.WriteVersion(TRunInfo::Class(), true);
630// R__b.WriteStdString(fVersion);
631// R__b.WriteStdString(fFullVersion);
632// R__b.WriteStdString(fDate);
633// R__b.WriteStdString(fLibraryVersion);
634// R__b.WriteStdString(fLibraryPath);
635// }
636//}
#define DYELLOW
Definition Globals.h:16
#define DRED
Definition Globals.h:18
#define DBLUE
Definition Globals.h:15
#define YELLOW
Definition Globals.h:7
#define CYAN
Definition Globals.h:12
#define RESET_COLOR
Definition Globals.h:5
void trim(std::string &line, const std::string &trimChars=" \f\n\r\t\v")
static size_t GetNumberOfChannels()
Definition TChannel.h:68
void Print(Option_t *="") const override
std::string fDate
The date of the last commit used in this version - GRSI_GIT_COMMIT_TIME from GVersion....
Definition TRunInfo.h:298
static void ClearVersion()
Definition TRunInfo.h:136
static void SetRunInfoFile(const char *ffile)
Definition TRunInfo.h:250
int fFirstSubRunNumber
The first sub run number (for combined subruns)
Definition TRunInfo.h:287
double fRunStart
The start of the current run in seconds - no idea why we store this as double?
Definition TRunInfo.h:292
std::vector< int > fBadCycleList
!List of bad cycles to be used for cycle rejection
Definition TRunInfo.h:317
static double RunStop()
Definition TRunInfo.h:228
static int LastRunNumber()
Definition TRunInfo.h:207
int fLastSubRunNumber
The last sub run number (for combined subruns)
Definition TRunInfo.h:289
static double RunStart()
Definition TRunInfo.h:227
static void SetDate(const char *ver)
Definition TRunInfo.h:161
static std::string PrintToString(Option_t *opt="")
Definition TRunInfo.cxx:363
void PrintRunList() const
Definition TRunInfo.cxx:520
std::string fFullVersion
The full version of GRSISort that generated the file (includes last commit) - GRSI_GIT_COMMIT from GV...
Definition TRunInfo.h:297
std::string fRunInfoFile
The contents of the run info file.
Definition TRunInfo.h:313
int fLastRunNumber
The last run number (for combined runs)
Definition TRunInfo.h:288
static void RemoveBadCycle(int cycle)
Definition TRunInfo.cxx:298
static void SetFullVersion(const char *ver)
Definition TRunInfo.h:149
Long64_t Merge(TCollection *list)
Definition TRunInfo.cxx:263
static int SubRunNumber()
Definition TRunInfo.h:202
std::string fLibraryPath
The path of the parser/file library that generated the file.
Definition TRunInfo.h:300
static Bool_t ReadInfoFile(const char *filename="")
Definition TRunInfo.cxx:174
void Clear(Option_t *opt="") override
Definition TRunInfo.cxx:122
static Bool_t ParseInputData(const char *inputdata="", Option_t *opt="q")
Definition TRunInfo.cxx:207
void Add(TRunInfo *runinfo, bool verbose=false)
Definition TRunInfo.cxx:387
static int LastSubRunNumber()
Definition TRunInfo.h:208
static int RunNumber()
Definition TRunInfo.h:201
static std::string RunComment()
Definition TRunInfo.h:220
static void AddBadCycle(int bad_cycle)
Definition TRunInfo.cxx:290
static bool WriteToRoot(TFile *fileptr=nullptr)
Definition TRunInfo.cxx:309
static std::string RunTitle()
Definition TRunInfo.h:219
static int FirstSubRunNumber()
Definition TRunInfo.h:205
static void SetSubRunNumber(int tmp)
Definition TRunInfo.h:199
static void ClearFullVersion()
Definition TRunInfo.h:148
void Print(Option_t *opt="") const override
Definition TRunInfo.cxx:72
static double HPGeArrayPosition()
Definition TRunInfo.h:253
int fRunNumber
The current run number.
Definition TRunInfo.h:284
static int FirstRunNumber()
Definition TRunInfo.h:204
static double RunLength()
Definition TRunInfo.h:229
static void SetRunNumber(int tmp)
Definition TRunInfo.h:198
TDetectorInformation * fDetectorInformation
! pointer to detector specific information (set by each parser library)
Definition TRunInfo.h:319
static void ClearDate()
Definition TRunInfo.h:160
static void SetHPGeArrayPosition(const double arr_pos)
Definition TRunInfo.h:252
double fRunStop
The stop of the current run in seconds - no idea why we store this as double?
Definition TRunInfo.h:293
static void SetRunInfo(int runnum=0, int subrunnum=-1)
Definition TRunInfo.cxx:135
std::string ListOfMissingRuns(bool all=false) const
Definition TRunInfo.cxx:532
static std::string CreateLabel(bool quiet=false)
Definition TRunInfo.cxx:581
int fFirstRunNumber
The first run number (for combined runs)
Definition TRunInfo.h:286
static void SetAnalysisTreeBranches(TTree *)
Definition TRunInfo.cxx:169
static void SetVersion(const char *ver)
Definition TRunInfo.h:137
std::string fLibraryVersion
The version of the parser/file library that generated the file.
Definition TRunInfo.h:299
virtual TEventBuildingLoop::EBuildMode BuildMode() const
Definition TRunInfo.cxx:381
void PrintVersion() const
Definition TRunInfo.cxx:570
double fHPGeArrayPosition
Position of the HPGe Array (default = 110.0 mm );.
Definition TRunInfo.h:315
std::string fVersion
The version of GRSISort that generated the file - GRSI_RELEASE from GVersion.h.
Definition TRunInfo.h:296
static Bool_t ReadInfoFromFile(TFile *tempf=nullptr)
Definition TRunInfo.cxx:15
static bool WriteInfoFile(const std::string &filename)
Definition TRunInfo.cxx:344
double fRunLength
The length of the current run in seconds - no idea why we store this as double?
Definition TRunInfo.h:294
std::set< std::pair< int, int > > fRunList
List of all runs added to this run info.
Definition TRunInfo.h:290
static bool IsBadCycle(int cycle)
Definition TRunInfo.cxx:304
static void PrintBadCycles()
Definition TRunInfo.cxx:277
static void SetRunInfoFileName(const char *fname)
Definition TRunInfo.h:249
int fSubRunNumber
The current sub run number.
Definition TRunInfo.h:285
static void PrintDirectory()
Definition TSingleton.h:171
static TRunInfo * Get(bool verbose=false)
Definition TSingleton.h:33
static void Set(TRunInfo *val)
Definition TSingleton.h:133