Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
getUUID.cc File Reference

Auxiliary program to print UUID. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include "TFile.h"
#include "TError.h"
#include "JLang/JUUID.hh"
#include "Jeep/JComment.hh"
#include "JIO/JFileStreamIO.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSupport/JFilenameSupportkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print UUID.

Author
mdejong

Definition in file getUUID.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file getUUID.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27 
28  string inputFile;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Auxiliary program to print UUID.");
34 
35  zap['f'] = make_field(inputFile) = "";
36  zap['d'] = make_field(debug) = 1;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44  if (inputFile != "") {
45 
46  if (getFilenameExtension(inputFile) == ROOT_FILE_FORMAT) {
47 
48  gErrorIgnoreLevel = kError;
49 
50  TFile* file = TFile::Open(inputFile.c_str(), "EXISTS");
51 
52  if (file != NULL) {
53  file->GetUUID().Print();
54  file->Close();
55  }
56 
57 
58  } else if (getFilenameExtension(inputFile) == ASCII_FILE_FORMAT ||
60 
61  ifstream in(inputFile.c_str());
62 
63  JComment comment;
64 
65  if (in >> comment && comment.hasUUID()) {
66  cout << comment.getUUID() << endl;
67  }
68 
69  in.close();
70 
71  } else if (getFilenameExtension(inputFile) == BINARY_DETECTOR_FILE_FORMAT[0] ||
73 
74  JFileStreamReader in(inputFile.c_str());
75 
76  JComment comment;
77 
78  char c;
79 
80  for (string buffer; in >> c && c == JComment::START_COMMENT; ) {
81 
82  in >> buffer;
83 
84  comment.add(buffer);
85  }
86 
87  if (comment.hasUUID()) {
88  cout << comment.getUUID() << endl;
89  }
90 
91  in.close();
92  }
93 
94  } else {
95 
96  cout << JUUID::rndm() << endl;
97  }
98 }
Utility class to parse command line options.
Definition: JParser.hh:1500
static const char *const BINARY_DETECTOR_FILE_FORMAT[]
JIO binary file format.
then usage $script< string identifier >< detectorfile > input file(toashort file)+" "\nNote that the input files and toashort files should be one-to-one related." fi if (( $
static const char *const ASCII_FILE_FORMAT
ASCII file name extension.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
JUUID getUUID() const
Get UUID.
Definition: JComment.hh:140
#define FATAL(A)
Definition: JMessage.hh:67
static const char *const KM3NET_DETECTOR_FILE_FORMAT
KM3NeT standard ASCII format
Auxiliary class for comment.
Definition: JComment.hh:41
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
Definition: JeepToolkit.hh:69
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40
static const char *const ROOT_FILE_FORMAT
ROOT file name extension.
Binary buffered file input.