Jpp
JDAQFilter.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <map>
6 
7 #include "JDAQ/JDAQEventIO.hh"
10 #include "JDetector/JDetector.hh"
13 
16 #include "JSupport/JMeta.hh"
17 #include "JSupport/JSupport.hh"
18 
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 
23 /**
24  * \file
25  *
26  * Example program to select events based on hits in strings.
27  * \author mdejong
28  */
29 int main(int argc, char **argv)
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 }
JMeta.hh
JDETECTOR::JPMTChannel
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:28
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:30
JAANET::JHit_t
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
JTriggerParameters.hh
JFileRecorder.hh
main
int main(int argc, char **argv)
Definition: JDAQFilter.cc:29
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JMessage.hh
JDAQHitRouter.hh
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:476
JDETECTOR::JDAQHitRouter::getPMTChannel
JPMTChannel getPMTChannel(const JDAQKeyHit &hit) const
Get PMT channel.
Definition: JDAQHitRouter.hh:71
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQTriggeredHit
DAQ triggered hit.
Definition: JDAQTriggeredHit.hh:20
JSUPPORT::JMultipleFileScanner::getCounter
counter_type getCounter() const
Get counter.
Definition: JMultipleFileScanner.hh:323
JDAQEventIO.hh
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JMultipleFileScanner::next
virtual const pointer_type & next()
Get next element.
Definition: JMultipleFileScanner.hh:398
KM3NETDAQ::JDAQEvent::const_iterator
Template const_iterator.
Definition: JDAQEvent.hh:68
JMultipleFileScanner.hh
std::map
Definition: JSTDTypes.hh:16
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JSUPPORT::JMultipleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMultipleFileScanner.hh:350
JParser.hh
JDetectorToolkit.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDAQSummarysliceIO.hh
response
char response[100000]
Definition: elog.cc:330
JDetector.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JSUPPORT::JFileRecorder
Object writing to file.
Definition: JFileRecorder.hh:41
JLANG::JException
General exception.
Definition: JException.hh:23
JDETECTOR::JModuleLocation::getString
int getString() const
Get string number.
Definition: JModuleLocation.hh:133
JDETECTOR::JDAQHitRouter
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Definition: JDAQHitRouter.hh:24