40 inline JDAQHeader getDAQHeader(
const char*
const file_name)
66 int main(
const int argc,
const char *
const argv[])
86 JParser<> zap(
"Auxiliary program to compute the PMT thresholds according to the small time-over-threshold fraction.");
92 zap[
'f'] =
make_field(inputFile,
"list of file names (output of JCalibrateToT)");
95 zap[
't'] =
make_field(fraction,
"maximal fraction of signal allowed for noise.") = 0.5;
96 zap[
'T'] =
make_field(testType,
"test type") =
"TH-TUNING-SEA-v1";
101 catch(
const exception& error) {
102 FATAL(error.what() << endl);
106 if (inputFile.empty()) {
107 FATAL(
"No input files.");
123 catch(
const exception& error) {
124 FATAL(error.what() << endl);
128 const JDAQHeader header = getDAQHeader(inputFile[0].c_str());
129 const int ID = header.getDetectorID();
146 catch(
const exception& error) {
147 FATAL(error.what() << endl);
151 struct parameters_type {
165 const JDAQHeader header = getDAQHeader(
i->c_str());
173 TFile*
in = TFile::Open(
i->c_str(),
"exist");
175 if (in == NULL || !in->IsOpen()) {
176 FATAL(
"File: " << *
i <<
" not opened." << endl);
179 for (detector_type::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
181 if (!module->second.empty()) {
187 for (
int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
192 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
194 const double x = h2s->GetYaxis()->GetBinCenter(iy);
195 const double y = h2s->GetBinContent(ix, iy);
204 const JUPI_t upi = module->second.at(ix-1).PMTUPI;
206 data[upi].push_back({ getPMTThreshold(upi).value, signal, noise});
211 WARNING(
"No histogram for module " << module->first <<
"; skip." << endl);
222 for (map_type::iterator
i =
data.begin();
i !=
data.end(); ++
i) {
224 sort(
i->second.begin(),
i->second.end(),
make_comparator(¶meters_type::threshold));
226 int threshold =
i->second.begin()->threshold;
228 for (data_type::const_iterator p =
i->second.begin(); p !=
i->second.end(); ++p) {
230 if (p->noise <= fraction * p->signal) {
232 threshold = p->threshold;
238 if (
debug >=
debug_t || threshold >
i->second.begin()->threshold) {
240 cout <<
"PMT " << left << setw(32) <<
i->first <<
" -> " << right << setw(3) << threshold <<
" (" <<
i->second.begin()->threshold <<
")" << endl;
242 for (data_type::const_iterator p =
i->second.begin(); p !=
i->second.end(); ++p) {
243 DEBUG(setw(3) << p->threshold <<
' ' <<
FIXED(7,0) << p->noise <<
"/" <<
FIXED(7,0) << p->signal <<
' ' << (p->noise <= fraction * p->signal) << endl);
255 js[
User_t] = person.LOGIN;
264 out << setw(2) << setprecision(8);
Utility class to parse command line options.
static const std::string Start_t
Auxiliary class for PMT thresholds.
static const std::string Location_t
int main(int argc, char *argv[])
Data structure for PMT threshold calibration.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
int getDetectorID() const
Get detector identifier.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
T get(const JHead &header)
Get object from header.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
Universal product identifier (UPI).
Auxiliary data structure for floating point format specification.
int getRunNumber() const
Get run number.
static const std::string Time_t
Type definition of range.
#define ASSERT(A,...)
Assert macro.
static const std::string Test_t
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DETECTOR $JPP_DATA km3net_reference detx set_variable NUMBER_OF_STRINGS set_variable ID if do_usage *then usage $script[detector file[identifier]] fi case set_variable ID
static const std::string End_t
General purpose messaging.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
Auxiliary class to define a range between two values.
Auxiliary class for date and time.
Utility class to parse command line options.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
Wrapper class for server name.
static const char *const _2SToT
Histogram naming.
static const std::string Type_t
do set_variable DETECTOR_TXT $WORKDIR detector
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
static const std::string Tests_t
Template definition for getting table specific selector.
static const std::string OK_t
#define DEBUG(A)
Message macros.
static const std::string User_t