101   using namespace KM3NETDAQ;
 
  110   double             laserFrequency_Hz;
 
  111   bool               overwriteDetector;
 
  119     JParser<> zap(
"Application for dark room time calibration.");
 
  121     zap[
'f'] = 
make_field(inputFile,         
"input file (time slice data from laser calibration).");
 
  123     zap[
'a'] = 
make_field(detectorFile,      
"detector file.");
 
  125                           "Set reference PMTs, e.g." 
  126                           "\n-! \"808969848 0 808982077 23\" sets PMT 0 of module 808969848 and PMT 23 of module 808982077 as references.");
 
  127     zap[
'n'] = 
make_field(numberOfEvents)    = JLimit::max(); 
 
  128     zap[
'l'] = 
make_field(laserFrequency_Hz, 
"laser frequency [Hz]")                             = 10000;
 
  129     zap[
'A'] = 
make_field(overwriteDetector, 
"overwrite detector file provided through '-a' with correct time offsets.");
 
  130     zap[
'O'] = 
make_field(option,            
"ROOT fit option, see TH1::Fit.")                   = 
"LS";
 
  131     zap[
'C'] = 
make_field(selector,          
"timeslice selector, e.g. JDAQTimesliceL1.")        = getROOTClassSelection<JDAQTimesliceTypes_t>();
 
  137   catch(
const exception& error) {
 
  138     FATAL(error.what() << endl);
 
  142   for (JTDC_t::iterator tdc = TDC.begin(); tdc != TDC.end(); ) {
 
  146       const int id = tdc->first;
 
  151         tdc = TDC.insert(make_pair(
id,
pmt));
 
  160   for (JTDC_t::const_iterator tdc = TDC.begin(); tdc != TDC.end(); ++tdc) {
 
  162       FATAL(
"Illegal TDC (= readout channel) identifier: " << tdc->second << 
" {0, .., " << 
NUMBER_OF_PMTS - 1 << 
"}" << endl);
 
  166   if (laserFrequency_Hz <= 0.0) {
 
  167     FATAL(
"Invalid laser frequency " << laserFrequency_Hz << endl);
 
  171   const double laserPeriod_ns = 1.0e9 / laserFrequency_Hz;
 
  197   const int    nx   =  2   * (int) laserPeriod_ns;
 
  198   const double xmin = -0.5 * laserPeriod_ns;
 
  199   const double xmax =  0.5 * laserPeriod_ns;
 
  201   TH1D h0(
"h0", NULL, nx, xmin, xmax);
 
  202   TH1D 
h1(
"h1", NULL, 256, -0.5, +255.5);
 
  206   for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  208     const range_type range = get_range(TDC, module->getID());
 
  210     for (JTDC_t::const_iterator i = range.first; i != range.second; ++i) {
 
  213              << 
" string  " << setw(3) << module->getString() 
 
  214              << 
" floor   " << setw(2) << module->getFloor()
 
  215              << 
" module  " << setw(8) << module->getID() 
 
  216              << 
" channel " << setw(2) << i->second << endl);
 
  224       zmap.insert(make_pair(
id, 
new TH1D(os.str().c_str(), NULL, nx, xmin, xmax)));
 
  238   for ( ; 
in.hasNext() && counter != inputFile.getLimit(); ++counter) {
 
  240     STATUS(
"event: " << setw(10) << counter << 
'\r'); 
DEBUG(endl);
 
  244     for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
 
  246       const range_type range = get_range(TDC, frame->getModuleID());
 
  248       if (range.first != range.second) {
 
  250         const double t0 = get_time(
getTimeOfFrame(frame->getFrameIndex()), laserPeriod_ns);
 
  254         buildL0(*frame, moduleRouter.getModule(frame->getModuleID()), back_inserter(dataL0));
 
  256         for (JDataL0_t::const_iterator hit = dataL0.begin(); hit != dataL0.end(); ++hit) {
 
  260           map_type::const_iterator p = zmap.find(
id);
 
  262           if (p != zmap.end()) {
 
  264             const double t1 = get_time(t0 + hit->getT(), laserPeriod_ns);
 
  272               h1.Fill(hit->getToT());
 
  287   TF1 f1(
"f1", 
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
 
  289   for (map_type::iterator it = zmap.begin(); it != zmap.end(); ++it) {
 
  292     TH1D*          
h1  = it->second;
 
  294     if (h1->GetEntries() == 0) {
 
  295       WARNING(
"Histogram " << h1->GetName() << 
" empty" << endl);
 
  299     STATUS(
"--- PMT = " << pmt << 
"; histogram " << h1->GetName() <<  endl);
 
  305     Double_t sigma = 2.0;    
 
  308     for (
int i = 1; i != h1->GetNbinsX(); ++i) {
 
  310       const Double_t x = h1->GetBinCenter (i);
 
  311       const Double_t y = h1->GetBinContent(i);
 
  319     f1.SetParameter(0, ymax);
 
  320     f1.SetParameter(1, x0);
 
  321     f1.SetParameter(2, sigma);
 
  322     f1.SetParameter(3, ymin);
 
  327     TFitResultPtr 
result = h1->Fit(&f1, option.c_str(), 
"same", x0 - 3 * sigma, x0 + 3 * sigma);
 
  331       cout << 
"Histogram " << h1->GetName() << 
" fit " << (result->IsValid() ? 
"" : 
"failed") << endl;
 
  332       cout << 
"\tx0 = " << 
FIXED(12,3) << x0                 << endl;
 
  333       cout << 
"\tt0 = " << 
FIXED(12,3) << f1.GetParameter(1) << endl;
 
  336     t0[
pmt] = f1.GetParameter(1);    
 
  342     const double W = laserFrequency_Hz * counter * 
getFrameTime() * 1.0e-9;
 
  344     NOTICE(
"Expection values [npe]" << endl);
 
  347       NOTICE(i->first << 
' ' << 
FIXED(7,3) << i->second / W << endl);
 
  352   if (overwriteDetector) { 
 
  354     NOTICE(
"Store calibration data on file " << detectorFile << endl);
 
  358     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  360       const range_type range = get_range(TDC, module->getID());
 
  362       if (range.first != range.second) {
 
  365                                             range.first->second)];   
 
  372             module->getPMT(pmt).subT0(p->second);                    
 
  374             module->getPMT(pmt).subT0(t1);                           
 
Utility class to parse command line options. 
 
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications. 
 
Auxiliary class to select ROOT class based on class name. 
 
Router for direct addressing of module data in detector data structure. 
 
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
 
then for HISTOGRAM in h0 h1
 
Long64_t counter_type
Type definition for counter. 
 
Auxiliary data structure for floating point format specification. 
 
Auxiliary class for multiplexing object iterators. 
 
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index. 
 
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
 
Auxiliary class for defining the range of iterations of objects. 
 
Template specialisation of L0 builder for JHitR0 data type. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
double getFrameTime()
Get frame time duration. 
 
void load(const JString &file_name, JDetector &detector)
Load detector from input file. 
 
JRange< Double_t > JRange_t
 
General purpose class for object reading from a list of file names. 
 
static const char WILD_CARD
 
void store(const JString &file_name, const JDetector &detector)
Store detector to output file. 
 
const JLimit & getLimit() const 
Get limit. 
 
static const int NUMBER_OF_PMTS
Total number of PMTs in module. 
 
#define DEBUG(A)
Message macros. 
 
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.