Jpp
Functions
JVeto.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "evt/Head.hh"
#include "evt/Evt.hh"
#include "JDAQ/JDAQEvent.hh"
#include "JDAQ/JDAQTimeslice.hh"
#include "JDAQ/JDAQSummaryslice.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JHit.hh"
#include "JTrigger/JFrame.hh"
#include "JTrigger/JTimeslice.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JHitL1.hh"
#include "JTrigger/JHitR1.hh"
#include "JTrigger/JBuildL0.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JFit/JLine1Z.hh"
#include "JFit/JFitToolkit.hh"
#include "JFit/JFitParameters.hh"
#include "JFit/JTimeRange.hh"
#include "JFit/JEvt.hh"
#include "JFit/JEvtToolkit.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

Program to determine veto of muon trajectory.

Author
mdejong

Definition in file JVeto.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file JVeto.cc.

51 {
52  using namespace std;
53  using namespace JPP;
54  using namespace KM3NETDAQ;
55 
56  typedef vector<JTimeRange> JVeto_t;
57  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
58  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
60 
61  JParallelFileScanner_t inputFile;
62  JFileRecorder<typelist> outputFile;
63  JLimit_t& numberOfEvents = inputFile.getLimit();
64  string detectorFile;
65  double roadWidth_m;
66  double R_Hz;
67  size_t numberOfPrefits;
68  JVeto_t veto;
69  bool reprocess;
70  int debug;
71 
72  try {
73 
74  JParser<> zap("Program to determine veto of muon trajectory.");
75 
76  zap['f'] = make_field(inputFile);
77  zap['o'] = make_field(outputFile) = "veto.root";
78  zap['a'] = make_field(detectorFile);
79  zap['n'] = make_field(numberOfEvents) = JLimit::max();
80  zap['R'] = make_field(roadWidth_m) = numeric_limits<double>::max();
81  zap['B'] = make_field(R_Hz) = 6.0e3;
82  zap['N'] = make_field(numberOfPrefits) = 1;
83  zap['V'] = make_field(veto);
84  zap['r'] = make_field(reprocess);
85  zap['d'] = make_field(debug) = 1;
86 
87  zap(argc, argv);
88  }
89  catch(const exception& error) {
90  FATAL(error.what() << endl);
91  }
92 
93 
94  cout.tie(&cerr);
95 
96  JDetector detector;
97 
98  try {
99  load(detectorFile, detector);
100  }
101  catch(const JException& error) {
102  FATAL(error);
103  }
104 
105  const JModuleRouter moduleRouter(detector);
106 
107  typedef vector<JHitL0> JDataL0_t;
108  const JBuildL0<JHitL0> buildL0;
109 
110  double VS = 0.0; // veto [s]
111 
112  for (vector<JTimeRange>::const_iterator vs = veto.begin(); vs != veto.end(); ++vs) {
113  VS += vs->getLength() * 1.0e-9;
114  }
115 
116 
117  outputFile.open();
118 
119  outputFile.put(JMeta(argc, argv));
120 
121  while (inputFile.hasNext()) {
122 
123  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
124 
125  multi_pointer_type ps = inputFile.next();
126 
127  JDAQEvent* tev = ps;
128  JEvt* evt = ps;
129  JEvt out = *evt;
130 
131  JEvt::iterator __end = evt->end();
132 
133  if (reprocess) {
134  __end = partition(evt->begin(), __end, JHistory::is_not_event(JMUONVETO));
135  }
136 
137  if (evt->begin() != __end) {
138 
139  copy(evt->begin(), __end, back_inserter(out));
140 
141  if (numberOfPrefits > 0) {
142  advance(__end = evt->begin(), min(numberOfPrefits, out.size()));
143  }
144 
145  partial_sort(evt->begin(), __end, evt->end(), qualitySorter);
146 
147  __end = partition(evt->begin(), __end, JHistory::is_event(evt->begin()->getHistory()));
148 
149 
150  JDataL0_t dataL0;
151 
152  buildL0(*tev, moduleRouter, true, back_inserter(dataL0));
153 
154 
155  for (JEvt::iterator track = evt->begin(); track != __end; ++track) {
156 
157  const JRotation3D R (getDirection(*track));
158  const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
159 
160  // hit selection based on start value
161 
163 
164  for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
165 
166  JHitL0 hit(*i);
167 
168  hit.rotate(R);
169 
170  bool is_veto = false;
171 
172  if (tz.getDistance(hit) <= roadWidth_m) {
173 
174  const double t1 = hit.getT() - tz.getT(hit);
175 
176  for (vector<JTimeRange>::const_iterator vs = veto.begin(); vs != veto.end() && !is_veto; ++vs) {
177  is_veto = (*vs)(t1);
178  }
179  }
180 
181  if (is_veto) {
182  top.insert(hit.getPMTIdentifier());
183  }
184  }
185 
186 
187  double npe = 0.0;
188  int count = 0;
189 
190  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
191 
192  JPosition3D pos(module->getPosition());
193 
194  pos.rotate(R);
195 
196  if (tz.getDistance(pos) <= roadWidth_m) {
197 
198  for (unsigned int i = 0; i != module->size(); ++i) {
199 
200  const JDAQPMTIdentifier id(module->getID(), i);
201 
202  npe += R_Hz * VS;
203  count += top.count(id);
204  }
205  }
206  }
207 
208  out.push_back(JFit(*track).add(JMUONVETO));
209 
210  out.rbegin()->setW(track->getW());
211  out.rbegin()->setW(JVETO_NPE, npe);
212  out.rbegin()->setW(JVETO_NUMBER_OF_HITS, count);
213  }
214 
215  // apply default sorter
216 
217  sort(out.begin(), out.end(), qualitySorter);
218  }
219 
220  outputFile.put(out);
221  }
222  STATUS(endl);
223 
224  JSingleFileScanner<JRemove<typelist, JEvt>::typelist> io(inputFile);
225 
226  io >> outputFile;
227 
228  outputFile.close();
229 }
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:34
JFIT::JMUONVETO
JVeto.cc.
Definition: JFitApplications.hh:39
JROOT::advance
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Definition: JCounter.hh:35
qualitySorter
bool qualitySorter(const JFIT::JFit &first, const JFIT::JFit &second)
Comparison of fit results.
Definition: quality_sorter.cc:10
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
std::vector
Definition: JSTDTypes.hh:12
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JAANET::copy
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:152
JFIT::JVETO_NUMBER_OF_HITS
number of hits from JVeto.cc
Definition: JFitParameters.hh:29
JGEOMETRY3D::JPosition3D::rotate
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Definition: JPosition3D.hh:185
KM3NETDAQ::JDAQEvent::end
const_iterator< T > end() const
Get end of data.
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
std::multiset
Definition: JSTDTypes.hh:14
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JAANET::getDirection
JDirection3D getDirection(const Vec &v)
Get direction.
Definition: JAAnetToolkit.hh:221
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
KM3NETDAQ::JDAQPMTIdentifier
PMT identifier.
Definition: JDAQPMTIdentifier.hh:25
JAANET::getPosition
JPosition3D getPosition(const Vec &v)
Get position.
Definition: JAAnetToolkit.hh:197
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
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JFIT::JVETO_NPE
number of photo-electrons from JVeto.cc
Definition: JFitParameters.hh:28