Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JAcousticsDisable.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <set>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TKey.h"
#include "TString.h"
#include "TRegexp.h"
#include "JAcoustics/JTransmission_t.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
mdejong Auxiliary program to set disable status based on time-of-arrival histograms.

Definition at line 28 of file JAcousticsDisable.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  typedef JContainer< set<JTransmission_t> > disable_container;
34 
35  vector<string> inputFile;
36  int Nmin;
37  double Tmax_us;
38  string disableFile;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Auxiliary program to set disable status based on time-of-arrival histograms.");
44 
45  zap['f'] = make_field(inputFile, "input file (output from JCanberra).");
46  zap['N'] = make_field(Nmin, "minimum number of entries") = 1;
47  zap['T'] = make_field(Tmax_us, "maximal time [us]") = 60.0;
48  zap['!'] = make_field(disableFile, "disable transmission file") = "";
49  zap['d'] = make_field(debug, "debug.") = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  disable_container disable;
59 
60  if (disableFile != "") {
61 
62  ifstream in(disableFile.c_str());
63 
64  in >> disable;
65 
66  in.close();
67  }
68 
69  disable.comment.add(JMeta(argc, argv));
70 
71 
72  const vector<double> Q = { 0.333, 0.666 };
73 
74  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
75 
76  DEBUG("Processing " << *i << endl) ;
77 
78  TFile in(i->c_str(), "read");
79 
80  TIter iter(in.GetListOfKeys());
81 
82  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
83 
84  if (TString(key->GetName()).EndsWith(".toa")) {
85 
86  TH1* h1 = dynamic_cast<TH1*>(key->ReadObj());
87 
88  if (h1 != NULL) {
89 
90  TString buffer(h1->GetName());
91 
92  const char* regexp = "[^0-9][0-9]* [0-9]*[^0-9]";
93 
94  buffer = buffer(TRegexp(regexp));
95  buffer = buffer(1, buffer.Length() - 2);
96 
97  if (buffer.Length() > 0 && buffer.IsDigit()) {
98 
99  JTransmission_t id;
100 
101  istringstream(buffer.Data()) >> id;
102 
103  vector<double> R(Q.size());
104 
105  h1->GetQuantiles(Q.size(), R.data(), Q.data());
106 
107  const int N = h1->GetEntries();
108  const double T_us = (*R.rbegin() - *R.begin()) * 1.0e6;
109 
110  if (N < Nmin || T_us > Tmax_us) {
111 
112  NOTICE("disable: " << id << ' '
113  << setw(6) << N << (N < Nmin ? "*" : "") << " "
114  << FIXED(5,1) << T_us << (T_us > Tmax_us ? "*" : "") << " [us]" << endl);
115 
116  disable.insert(id);
117  }
118 
119  } else {
120 
121  ERROR("Histogram name " << h1->GetName() << " not compatible with regular expression " << regexp << "." << endl);
122  }
123  }
124  }
125  }
126 
127  in.Close();
128  }
129 
130  if (disableFile != "") {
131 
132  ofstream out(disableFile.c_str());
133 
134  out << disable;
135 
136  out.close();
137  }
138 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Q(UTCMax_s-UTCMin_s)-livetime_s
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:63
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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:42