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

Example program to remove PMT(s) from data (and set corresponding rate to 0). More...

#include <string>
#include <iostream>
#include <iomanip>
#include <set>
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQPMTIdentifier.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JLang/JTypeSelector.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JLang/JObjectDemultiplexer.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 remove PMT(s) from data (and set corresponding rate to 0).

Author
mdejong

Definition in file JRemovePMT.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 60 of file JRemovePMT.cc.

61 {
62  using namespace std;
63  using namespace JPP;
64  using namespace KM3NETDAQ;
65 
67  JLimit_t& numberOfEvents = inputFile.getLimit();
70  int debug;
71 
72  try {
73 
74  JParser<> zap("Example program to remove PMT(s) from data (and set corresponding rate to 0).");
75 
76  zap['f'] = make_field(inputFile);
77  zap['o'] = make_field(outputFile) = "abc.root";
78  zap['n'] = make_field(numberOfEvents) = JLimit::max();
79  zap['P'] = make_field(PMT) = JPARSER::initialised();
80  zap['d'] = make_field(debug) = 1;
81 
82  zap(argc, argv);
83  }
84  catch(const exception& error) {
85  FATAL(error.what() << endl);
86  }
87 
88 
89  cout.tie(&cerr);
90 
91  outputFile.open();
92 
93  {
95 
96  // put base class JDAQTimeslice at end of type list
97 
99 
101 
102  for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
103 
104  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
105 
106  JDAQTimeslice* timeslice = in.next();
107 
108  for (JDAQTimeslice::iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
109 
110  bool rm = false;
111 
112  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
113 
114  if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) != PMT.end() ||
115  PMT.find(JDAQPMTIdentifier(-1, pmt)) != PMT.end()) {
116  rm = true;
117  }
118  }
119 
120  if (rm) {
121 
123 
124  for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
125  buffer[hit->getPMT()].push_back(*hit);
126  }
127 
128  vector<JDAQHit> data;
129 
130  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
131 
132  if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) == PMT.end() &&
133  PMT.find(JDAQPMTIdentifier(-1, pmt)) == PMT.end()) {
134  copy(buffer[pmt].begin(), buffer[pmt].end(), back_inserter(data));
135  }
136  }
137 
138  sort(data.begin(), data.end());
139 
140  frame->clear();
141  frame->add(data.size(), data.data());
142  }
143  }
144 
145  out.put(*timeslice);
146  }
147  STATUS(endl);
148  }
149  {
151 
152  while (in.hasNext()) {
153 
154  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
155 
156  JDAQEvent* event = in.next();
157 
158  remove(event->getHits<JDAQTriggeredHit>(), PMT);
159  remove(event->getHits<JDAQSnapshotHit> (), PMT);
160 
161  outputFile.put(*event);
162  }
163  STATUS(endl);
164  }
165  {
167 
168  while (in.hasNext()) {
169 
170  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
171 
172  JDAQSummaryslice* summaryslice = in.next();
173 
174  for (JDAQSummaryslice::iterator frame = summaryslice->begin(); frame != summaryslice->end(); ++frame) {
175 
176  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
177 
178  if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) != PMT.end() ||
179  PMT.find(JDAQPMTIdentifier(-1, pmt)) != PMT.end()) {
180  (*frame)[pmt].setValue(0.0);
181  }
182  }
183  }
184 
185  outputFile.put(*summaryslice);
186  }
187  STATUS(endl);
188  }
189 
191 
192  io >> outputFile;
193 
194  outputFile.close();
195 }
Template specialisation of JMultipleFileScanner for trigger parameters.
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Append to type list.
Definition: JTypeList.hh:61
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
#define STATUS(A)
Definition: JMessage.hh:63
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Data time slice.
int debug
debug level
Definition: JSirene.cc:63
Auxiliary class for demultiplexing object outputs.
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41