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

Example application to search for sets of consecutive hits on a given PMT,
that are separated in time by a constant value. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JStringRouter.hh"
#include "JDetector/JDAQHitRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "km3net-dataformat/online/JDAQPMTIdentifier.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JROOT/JManager.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JTrigger/JSuperFrame2D.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example application to search for sets of consecutive hits on a given PMT,
that are separated in time by a constant value.

The number of consecutive hits
as well as the time difference are selected from the command line.
The searches are done within the JDAQSnapshotHits from JDAQEvents\ as well as within the JDAQHits from the JDAQTimeslice data.

Author
rgruiz

Definition in file JAnglerFish.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file JAnglerFish.cc.

42 {
43  using namespace std;
44  using namespace JPP;
45  using namespace KM3NETDAQ;
46 
48 
49  string inputFile;
50  JLimit_t numberOfEvents;
52  string detectorFile;
53  int deltaT;
54  int multiplicity;
55  int debug;
56 
57  try {
58 
59  JParser<> zap("Program to search for sets of consecutive hits on a given PMT that are equidistant in time.");
60 
61  zap['f'] = make_field(inputFile);
62  zap['a'] = make_field(detectorFile);
63  zap['t'] = make_field(deltaT) = 255;
64  zap['m'] = make_field(multiplicity) = 3;
65  zap['o'] = make_field(outputFile) = "anglerfish.root";
66  zap['n'] = make_field(numberOfEvents) = JLimit::max();
67  zap['d'] = make_field(debug) = 1;
68 
69  zap(argc, argv);
70  }
71  catch(const exception& error) {
72  FATAL(error.what() << endl);
73  }
74 
75  outputFile.open();
76 
77  if (!outputFile.is_open()) FATAL("Error opening file " << outputFile << endl);
78 
79  outputFile.put(JMeta(argc, argv));
80 
82 
83  try {
84  load (detectorFile, detector);
85  }
86  catch(const JException & error) {
87  cerr << "FATAL ERROR. Could not open detector file '" << detectorFile << "'." << endl;
88  exit(1);
89  }
90 
92 
93  const JStringRouter stringRouter(detector);
94 
95  TH1D h1 ("MEvt", "", 50, 0.5, 50.5);
96 
97  TH2D h2 ("FEvt", NULL,
99  range.getLength() + 1, range.getLowerLimit() - 0.5, range.getUpperLimit() + 0.5);
100 
101  TH1D h3 ("ML0" , "", 50, 0.5, 50.5);
102 
103  TH2D h4 ("FL0", NULL,
105  range.getLength() + 1, range.getLowerLimit() - 0.5, range.getUpperLimit() + 0.5);
106 
107  for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
108  h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(stringRouter.at(i-1)));
109  }
110 
111  for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
112  h4.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(stringRouter.at(i-1)));
113  }
114 
115  const JDAQHitRouter hitRouter(detector);
116 
117  {
118  typedef JDAQSnapshotHit JHit_t;
119  typedef vector<JHit_t> JHitBuffer;
120 
121  for (JMultipleFileScanner<JDAQEvent> in(inputFile, numberOfEvents); in.hasNext(); ){
122 
123  JDAQEvent* event = in.next();
124  JHitBuffer& buffer = event->getHits<JHit_t>();
125 
126  std::sort(buffer.begin(),buffer.end(),less<JDAQKeyHit>());
127 
128  for (JHitBuffer::const_iterator p = buffer.begin() ; p != buffer.end() ; ) {
129 
130  JHitBuffer::const_iterator q = p;
131 
132  for (JDAQHit::JTDC_t t1 = p->getT();
133  (++q != buffer.end() &&
134  q->getModuleID() == p->getModuleID() &&
135  q->getPMT() == p->getPMT() &&
136  q->getT() == t1 + deltaT);
137  t1 = q->getT()) {}
138 
139  int d = distance(p,q);
140 
141  const JPMTChannel& channel = hitRouter.getPMTChannel(*p);
142 
143  if (d >= multiplicity)
144  h2.Fill((double) stringRouter.getIndex(channel.getString()), (double) channel.getFloor());
145 
146  if (d >= 2)
147  h1.Fill(d);
148 
149  p=q;
150  }
151  }
152  }
153 
154  {
155  typedef JDAQHit JHit_t;
156  typedef vector<JHit_t> JHitBuffer;
157  typedef JSuperFrame2D<JHit_t> JSuperFrame2D_t;
158 
159  const JModuleRouter moduleRouter(detector);
160 
161  for (JMultipleFileScanner<JDAQTimeslice> in(inputFile, numberOfEvents); in.hasNext(); ) {
162 
163  JDAQTimeslice* slice = in.next();
164 
165  for(JDAQTimeslice::iterator frame = slice->begin(); frame != slice->end() ; ++frame){
166 
167  const JModule& module = moduleRouter.getModule(frame->getModuleID());
168  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module);
169 
170  for (JSuperFrame2D_t::iterator pmt = buffer.begin() ; pmt != buffer.end() ; ++pmt) {
171 
172  for (JHitBuffer::const_iterator p = pmt->begin() ; p != pmt->end() ;) {
173 
174  JHitBuffer::const_iterator q = p;
175 
176  for (JDAQHit::JTDC_t t1 = p->getT();
177  (++q != pmt->end() &&
178  q->getT() == t1 + deltaT);
179  t1 = q->getT()) {}
180 
181  int d = distance(p,q);
182 
183  const JPMTChannel& channel = hitRouter.getPMTChannel(JDAQKeyHit(frame->getModuleID(),*p));
184 
185  if (d >= multiplicity)
186  h4.Fill((double) stringRouter.getIndex(channel.getString()), (double) channel.getFloor());
187 
188  if (d >= 2)
189  h3.Fill(d);
190 
191  p=q;
192  }
193  }
194  }
195  }
196  }
197 
198  outputFile.put(h1);
199  outputFile.put(h2);
200  outputFile.put(h3);
201  outputFile.put(h4);
202 
203  outputFile.close();
204 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
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:1500
General exception.
Definition: JException.hh:23
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:30
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:68
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
exit
Definition: JPizza.sh:36
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
string outputFile
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
unsigned int JTDC_t
leading edge [ns]
Definition: JDAQHit.hh:39
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
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:224
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
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
Definition: JLocation.hh:134
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Router for mapping of string identifier to index.
General purpose class for object reading from a list of file names.
2-dimensional frame with time calibrated data from one optical module.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42