Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions
JPulseFinder_IO.hh File Reference
#include <iostream>
#include "JDAQ/JDAQTimeslice.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JModuleLocation.hh"
#include "TVector.h"

Go to the source code of this file.

Classes

struct  IO
 Structure to store the different command line arguments for JRunAnalyzer. More...
 

Functions

int read_user_options (IO &options, int argc, char **argv)
 Parses the command line options and fills an IO structure with them. More...
 
void write_output (IO options, vector< vector< TH2D * > > ToT_vs_time, vector< vector< TH1D * > > ToT, vector< vector< TH1D * > > time)
 Writes a .root file with the nanobeacon pulses found by JPulseFinder. More...
 

Function Documentation

int read_user_options ( IO options,
int  argc,
char **  argv 
)
inline

Parses the command line options and fills an IO structure with them.

Parameters
optionsan option structure
argcthe number of command line arguments
argvthe command line arguments
Returns
1 if works 2 if it doesn't work

Definition at line 74 of file JPulseFinder_IO.hh.

74  {
75 
76  int a = 0;
77 
78  try {
79 
80  JParser<string> zap;
81 
82  zap["o"] = make_field(options.ofname) = "out.root" ;
83 
84  zap["f"] = make_field(options.ifnames) ;
85 
86  zap["a"] = make_field(options.detector_file) ;
87 
88  zap["V"] = make_field(options.voltage) = 0;
89 
90  zap["s"] = make_field(options.string_number) ;
91 
92  zap["p"] = make_field(options.pulse_period_16ns) ;
93 
94  zap["n"] = make_field(options.number_neighbors) = 2 ;
95 
96  zap["t"] = make_field(options.up_pmts) = 1 ;
97 
98  zap["b"] = make_field(options.down_pmts) = 4 ;
99 
100  zap["d"] = make_field(options.overall_delay_16ns) = 0;
101 
102  zap["stagger"] = make_field(options.stagger_16ns) = 0;
103 
104  if (zap.read(argc, argv) != 0)
105 
106  a = 1;
107 
108  }
109 
110  catch(const exception &error) {
111 
112  ERROR(error.what() << endl);
113 
114  a = 2;
115 
116  }
117 
118  return a;
119 
120 }
unsigned int pulse_period_16ns
int up_pmts
Utility class to parse command line options.
Definition: JParser.hh:1410
int string_number
int stagger_16ns
int down_pmts
string ofname
Definition: JRunAnalyzer.cc:44
int overall_delay_16ns
JMultipleFileScanner ifnames
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define ERROR(A)
Definition: JMessage.hh:64
double voltage
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1673
int number_neighbors
string detector_file
Definition: JRunAnalyzer.cc:46
void write_output ( IO  options,
vector< vector< TH2D * > >  ToT_vs_time,
vector< vector< TH1D * > >  ToT,
vector< vector< TH1D * > >  time 
)

Writes a .root file with the nanobeacon pulses found by JPulseFinder.

Parameters
optionsan IO structure
ToT_vs_timevector of TH2D with the nanobeacon pulses
ToTvector of TH1 with the ToT distribution of the nanobeacon pulses
timevector of TH1 with the time distribution of the nanobeacon pulses

Definition at line 132 of file JPulseFinder_IO.hh.

132  {
133 
134  JMultipleFileScanner<JDAQTimeslice> inputFile(options.ifnames) ;
135 
136  int run_number = 0 ;
137 
138  inputFile.rewind() ;
139 
140  if(inputFile.hasNext()){
141 
142  run_number = inputFile.next()->getRunNumber() ;
143 
144  }
145 
146  TFile* f = new TFile(options.ofname.c_str(),"RECREATE") ;
147 
148  TVectorD Run (2) ;
149 
150  Run[0] = run_number ;
151 
152  Run[1] = options.voltage ;
153 
154  Run.Write("Run_Info") ;
155 
156  for( int i = 0 ; i < (int)ToT_vs_time.size() ; ++i ) {
157 
158  char dirname[200] ;
159 
160  sprintf(dirname, "S%iF%i", options.string_number, i + 1 ) ;
161 
162  f->mkdir(dirname)->cd() ;
163 
164  for( int j = 0 ; j < (int)ToT_vs_time[0].size() ; ++j ) {
165 
166  if (ToT_vs_time[i][j]==NULL) continue ;
167 
168  if( ToT_vs_time[i][j]->Integral(1 , ToT_vs_time[i][j]->GetNbinsX() - 1 , 1 , ToT_vs_time[i][j]->GetNbinsY() - 1)>0 ) {
169 
170  ToT_vs_time[i][j]->Write() ;
171 
172  ToT[i][j]->Write() ;
173 
174  time[i][j]->Write() ;
175 
176  }
177 
178  }
179 
180  f->cd() ;
181 
182  }
183 
184  f->Close() ;
185 
186  delete (f) ;
187 
188 }
int string_number
string ofname
Definition: JRunAnalyzer.cc:44
JMultipleFileScanner ifnames
double voltage
General purpose class for object reading from a list of file names.