Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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();
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 outputFile.open();
90
91 {
93
94 // put base class JDAQTimeslice at end of type list
95
97
99
100 for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
101
102 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
103
104 JDAQTimeslice* timeslice = in.next();
105
106 for (JDAQTimeslice::iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
107
108 bool rm = false;
109
110 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
111
112 if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) != PMT.end() ||
113 PMT.find(JDAQPMTIdentifier(-1, pmt)) != PMT.end()) {
114 rm = true;
115 }
116 }
117
118 if (rm) {
119
121
122 for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
123 buffer[hit->getPMT()].push_back(*hit);
124 }
125
127
128 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
129
130 if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) == PMT.end() &&
131 PMT.find(JDAQPMTIdentifier(-1, pmt)) == PMT.end()) {
132 copy(buffer[pmt].begin(), buffer[pmt].end(), back_inserter(data));
133 }
134 }
135
136 sort(data.begin(), data.end());
137
138 frame->clear();
139 frame->add(data.size(), data.data());
140 }
141 }
142
143 out.put(*timeslice);
144 }
145 STATUS(endl);
146 }
147 {
149
150 while (in.hasNext()) {
151
152 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
153
154 JDAQEvent* event = in.next();
155
156 remove(event->getHits<JDAQTriggeredHit>(), PMT);
157 remove(event->getHits<JDAQSnapshotHit> (), PMT);
158
159 outputFile.put(*event);
160 }
161 STATUS(endl);
162 }
163 {
165
166 while (in.hasNext()) {
167
168 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
169
170 JDAQSummaryslice* summaryslice = in.next();
171
172 for (JDAQSummaryslice::iterator frame = summaryslice->begin(); frame != summaryslice->end(); ++frame) {
173
174 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
175
176 if (PMT.find(JDAQPMTIdentifier(frame->getModuleID(), pmt)) != PMT.end() ||
177 PMT.find(JDAQPMTIdentifier(-1, pmt)) != PMT.end()) {
178 (*frame)[pmt].setValue(0.0);
179 }
180 }
181 }
182
184 }
185 STATUS(endl);
186 }
187
189
190 io >> outputFile;
191
192 outputFile.close();
193}
JDAQPMTIdentifier PMT
Command line options.
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Template definition of a multi-dimensional oscillation probability interpolation table.
Hit data structure.
Definition JDAQHit.hh:35
JTriggerCounter_t next()
Increment trigger counter.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128