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

Program to determine veto of muon trajectory. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/definitions/fitparameters.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.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/JSingleFileScanner.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/JTimeRange.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/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 JMuonVeto.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file JMuonVeto.cc.

54 {
55  using namespace std;
56  using namespace JPP;
57  using namespace KM3NETDAQ;
58 
59  typedef vector<JTimeRange> JVeto_t;
60  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
61  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
63 
64  JParallelFileScanner_t inputFile;
66  JLimit_t& numberOfEvents = inputFile.getLimit();
67  string detectorFile;
68  double roadWidth_m;
69  double R_Hz;
70  size_t numberOfPrefits;
71  JVeto_t veto;
72  bool reprocess;
73  int debug;
74 
75  try {
76 
77  JParser<> zap("Program to determine veto of muon trajectory.");
78 
79  zap['f'] = make_field(inputFile);
80  zap['o'] = make_field(outputFile) = "veto.root";
81  zap['a'] = make_field(detectorFile);
82  zap['n'] = make_field(numberOfEvents) = JLimit::max();
83  zap['R'] = make_field(roadWidth_m) = numeric_limits<double>::max();
84  zap['B'] = make_field(R_Hz) = 6.0e3;
85  zap['N'] = make_field(numberOfPrefits) = 1;
86  zap['V'] = make_field(veto);
87  zap['r'] = make_field(reprocess);
88  zap['d'] = make_field(debug) = 1;
89 
90  zap(argc, argv);
91  }
92  catch(const exception& error) {
93  FATAL(error.what() << endl);
94  }
95 
96 
97  cout.tie(&cerr);
98 
100 
101  try {
102  load(detectorFile, detector);
103  }
104  catch(const JException& error) {
105  FATAL(error);
106  }
107 
108  const JModuleRouter router(detector);
109 
110  typedef vector<JHitL0> JDataL0_t;
111  const JBuildL0<JHitL0> buildL0;
112 
113  double VS = 0.0; // veto [s]
114 
115  for (vector<JTimeRange>::const_iterator vs = veto.begin(); vs != veto.end(); ++vs) {
116  VS += vs->getLength() * 1.0e-9;
117  }
118 
119 
120  outputFile.open();
121 
122  outputFile.put(JMeta(argc, argv));
123 
124  while (inputFile.hasNext()) {
125 
126  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
127 
128  multi_pointer_type ps = inputFile.next();
129 
130  const JDAQEvent* tev = ps;
131  const JEvt* in = ps;
132 
133  JEvt cp = *in;
134  JEvt out;
135 
136  cp.select(numberOfPrefits, qualitySorter);
137 
138 
139  JDataL0_t dataL0;
140 
141  buildL0(*tev, router, true, back_inserter(dataL0));
142 
143 
144  for (JEvt::iterator track = cp.begin(); track != cp.end(); ++track) {
145 
146  const JRotation3D R (getDirection(*track));
147  const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
148 
149  // hit selection based on start value
150 
152 
153  for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
154 
155  JHitL0 hit(*i);
156 
157  hit.rotate(R);
158 
159  bool is_veto = false;
160 
161  if (tz.getDistance(hit) <= roadWidth_m) {
162 
163  const double t1 = hit.getT() - tz.getT(hit);
164 
165  for (vector<JTimeRange>::const_iterator vs = veto.begin(); vs != veto.end() && !is_veto; ++vs) {
166  is_veto = (*vs)(t1);
167  }
168  }
169 
170  if (is_veto) {
171  top.insert(hit.getPMTIdentifier());
172  }
173  }
174 
175 
176  double npe = 0.0;
177  int count = 0;
178 
179  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
180 
181  JPosition3D pos(module->getPosition());
182 
183  pos.rotate(R);
184 
185  if (tz.getDistance(pos) <= roadWidth_m) {
186 
187  for (unsigned int i = 0; i != module->size(); ++i) {
188 
189  const JDAQPMTIdentifier id(module->getID(), i);
190 
191  npe += R_Hz * VS;
192  count += top.count(id);
193  }
194  }
195  }
196 
197  out.push_back(JFit(*track).add(JMUONVETO));
198 
199  out.rbegin()->setW(track->getW());
200  out.rbegin()->setW(JVETO_NPE, npe);
201  out.rbegin()->setW(JVETO_NUMBER_OF_HITS, count);
202  }
203 
204  // apply default sorter
205 
206  sort(out.begin(), out.end(), qualitySorter);
207 
208  outputFile.put(out);
209  }
210  STATUS(endl);
211 
213 
214  io >> outputFile;
215 
216  outputFile.close();
217 }
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:1517
General exception.
Definition: JException.hh:23
static const int JVETO_NPE
number of photo-electrons from JVeto.cc
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:102
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
Rotation matrix.
Definition: JRotation3D.hh:111
General purpose class for parallel reading of objects from a single file or multiple files...
static const int JMUONVETO
JFit & add(const int type)
Add event to history.
string outputFile
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:226
JDirection3D getDirection(const Vec &dir)
Get direction.
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
JPosition3D getPosition(const Vec &pos)
Get position.
static const int JVETO_NUMBER_OF_HITS
number of hits from JVeto.cc
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
std::vector< int > count
Definition: JAlgorithm.hh:180
Data structure for L0 hit.
Definition: JHitL0.hh:27
Data structure for fit of straight line paralel to z-axis.
Definition: JLine1Z.hh:27
then cp
Object reading from a list of files.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Definition: JPosition3D.hh:186
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62