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

Example program to select events based on hits in strings. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDAQHitRouter.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.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

Example program to select events based on hits in strings.

Author
mdejong

Definition in file JDAQFilter.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JDAQFilter.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33  using namespace KM3NETDAQ;
34 
35  typedef map<int, int> map_type;
36 
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  string detectorFile;
41  map_type selector;
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Example program to select events based on hits in strings.");
47 
48  zap['f'] = make_field(inputFile, "input file.");
49  zap['o'] = make_field(outputFile, "output file.") = "filter.root";
50  zap['n'] = make_field(numberOfEvents) = JLimit::max();
51  zap['a'] = make_field(detectorFile, "detector file.");
52  zap['S'] = make_field(selector, "selection: pairs of <string number> <minimum number of triggered hits>");
53  zap['d'] = make_field(debug) = 2;
54 
55  zap(argc, argv);
56  }
57  catch(const exception& error) {
58  FATAL(error.what() << endl);
59  }
60 
61 
62  cout.tie(&cerr);
63 
64 
66 
67  try {
68  load(detectorFile, detector);
69  }
70  catch(const JException& error) {
71  FATAL(error);
72  }
73 
74  const JDAQHitRouter router(detector);
75 
76 
77  outputFile.open();
78 
79  outputFile.put(JMeta(argc, argv));
80 
81  while (inputFile.hasNext()) {
82 
83  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
84 
85  JDAQEvent* event = inputFile.next();
86 
87  map_type response;
88 
89  typedef JDAQTriggeredHit JHit_t;
90 
91  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
92 
93  const JPMTChannel& channel = router.getPMTChannel(*hit);
94 
95  response[channel.getString()] += 1;
96  }
97 
98  bool status = false;
99 
100  for (map_type::const_iterator i = selector.begin(); i != selector.end() && !status; ++i) {
101  status = response[i->first] >= i->second;
102  }
103 
104  if (status) {
105  outputFile.put(*event);
106  }
107  }
108  STATUS(endl);
109 
110 
112 
113  io >> outputFile;
114 
115  outputFile.close();
116 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:28
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
Template const_iterator.
Definition: JDAQEvent.hh:68
string outputFile
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
int getString() const
Get string number.
Definition: JLocation.hh:134
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
char response[100000]
Definition: elog.cc:330
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62