Jpp  16.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
JRECONSTRUCTION::JMuonPrefit Struct Reference

Wrapper class to make pre-fit of muon trajectory. More...

#include <JMuonPrefit.hh>

Inheritance diagram for JRECONSTRUCTION::JMuonPrefit:
JRECONSTRUCTION::JMuonPrefitParameters_t JFIT::JEstimator< JModel_t > TObject

Public Types

typedef JEstimator< JLine1ZJEstimator_t
 
typedef JTRIGGER::JHitR1 hit_type
 
typedef std::vector< hit_typebuffer_type
 

Public Member Functions

 JMuonPrefit (const JMuonPrefitParameters_t &parameters, const JModuleRouter &router, const int debug=0)
 Constructor. More...
 
 JMuonPrefit (const JMuonPrefitParameters_t &parameters, const JModuleRouter &router, const JOmega3D &omega, const int debug=0)
 Constructor. More...
 
JEvt operator() (const KM3NETDAQ::JDAQEvent &event)
 Fit function. More...
 
JEvt operator() (const buffer_type &dataL0, const buffer_type &dataL1)
 Fit function. More...
 
void reset ()
 Reset fit parameters. More...
 
bool equals (const JMuonPrefitParameters_t &parameters) const
 Equality. More...
 
 ClassDef (JMuonPrefitParameters_t, 1)
 

Public Attributes

const JModuleRouterrouter
 
JOmega3D omega
 
int debug
 
int factoryLimit
 factory limit for combinatorics More...
 
int NMaxHits
 maximal number of hits More...
 
double sigma_ns
 time resolution [ns] More...
 
double gridAngle_deg
 grid angle for directions [deg] More...
 
bool useL0
 option for L0 hit use More...
 
int numberOfOutliers
 maximum number of outliers More...
 
size_t numberOfPrefits
 number of prefits More...
 
double DZMax
 maximal slope for downward pointing solutions More...
 
size_t numberOfDZMax
 additional number of downward pointing solutions More...
 
double TMaxLocal_ns
 time window for local coincidences [ns] More...
 
double ctMin
 minimal cosine space angle between PMT axes More...
 
double roadWidth_m
 road width [m] More...
 

Static Public Attributes

struct {
cmz
 Auxiliary data structure for sorting of hits. More...
 

Private Member Functions

void configure ()
 Configure internal buffer(s). More...
 

Private Attributes

buffer_type data
 
JMatrixNZ V
 
JVectorNZ Y
 

Detailed Description

Wrapper class to make pre-fit of muon trajectory.

The JMuonPrefit fit is used to generate start values for subsequent fits (usually JMuonSimplex and JMuonGandalf).
To this end, a scan of directions is made and the time and transverse positions of the track are fitted for each direction (JFIT::JEstimator<JLine1Z>).
The directions are spaced by the parameters JMuonPrefitParameters_t::gridAngle_deg.
This angle corresponds to the envisaged angular accuracy of the result.
The probability that one of the results is less than this angle away from the correct value, multiple start values should be considered (JMuonPrefitParameters_t::numberOfPrefits).
Note that the CPU time scales with the inverse of the square of this angle.
The chi-squared is based on the time residuals.

Definition at line 73 of file JMuonPrefit.hh.

Member Typedef Documentation

Definition at line 77 of file JMuonPrefit.hh.

Definition at line 78 of file JMuonPrefit.hh.

Definition at line 79 of file JMuonPrefit.hh.

Constructor & Destructor Documentation

JRECONSTRUCTION::JMuonPrefit::JMuonPrefit ( const JMuonPrefitParameters_t parameters,
const JModuleRouter router,
const int  debug = 0 
)
inline

Constructor.

Parameters
parametersparameters
routermodule router
debugdebug

Definition at line 90 of file JMuonPrefit.hh.

92  :
93  JMuonPrefitParameters_t(parameters),
94  router(router),
95  omega (parameters.gridAngle_deg * JMATH::PI/180.0),
96  debug (debug)
97  {
98  configure();
99  }
double gridAngle_deg
grid angle for directions [deg]
static const double PI
Mathematical constants.
const JModuleRouter & router
Definition: JMuonPrefit.hh:403
void configure()
Configure internal buffer(s).
Definition: JMuonPrefit.hh:411
JRECONSTRUCTION::JMuonPrefit::JMuonPrefit ( const JMuonPrefitParameters_t parameters,
const JModuleRouter router,
const JOmega3D omega,
const int  debug = 0 
)
inline

Constructor.

Parameters
routermodule router
parametersparameters
omegadirections
debugdebug

Definition at line 110 of file JMuonPrefit.hh.

113  :
114  JMuonPrefitParameters_t(parameters),
115  router(router),
116  omega (omega),
117  debug (debug)
118  {
119  configure();
120  }
const JModuleRouter & router
Definition: JMuonPrefit.hh:403
void configure()
Configure internal buffer(s).
Definition: JMuonPrefit.hh:411

Member Function Documentation

JEvt JRECONSTRUCTION::JMuonPrefit::operator() ( const KM3NETDAQ::JDAQEvent event)
inline

Fit function.

Parameters
eventevent
Returns
fit results

Definition at line 129 of file JMuonPrefit.hh.

130  {
131  using namespace std;
132  using namespace JPP;
133 
134  const JBuildL0<hit_type> buildL0;
136 
137  buffer_type dataL0;
138  buffer_type dataL1;
139 
140  buildL2(event, router, !useL0, back_inserter(dataL1));
141 
142  // 3D cluster of unique optical modules
143 
145 
146  sort(dataL1.begin(), dataL1.end(), hit_type::compare);
147 
148  buffer_type::iterator __end = dataL1.end();
149 
150  __end = unique(dataL1.begin(), __end, equal_to<JDAQModuleIdentifier>());
151 
152  __end = clusterizeWeight(dataL1.begin(), __end, match3B);
153 
154  dataL1.erase(__end, dataL1.end());
155 
156 
157  if (useL0) {
158 
159  buildL0(event, router, true, back_inserter(dataL0));
160 
161  __end = dataL0.end();
162 
163  for (buffer_type::iterator i = dataL0.begin(); i != __end; ) {
164 
165  if (match3B.count(*i, dataL1.begin(), dataL1.end()) != 0)
166  ++i;
167  else
168  swap(*i, *--__end);
169  }
170 
171  dataL0.erase(__end, dataL0.end());
172  }
173 
174  return (*this)(dataL0, dataL1);
175  }
static struct JTRIGGER::@82 clusterizeWeight
Anonymous struct for weighed clustering of hits.
Template L2 builder.
Definition: JBuildL2.hh:45
double TMaxLocal_ns
time window for local coincidences [ns]
Data structure for L2 parameters.
static struct JTRIGGER::JHitR1::@86 compare
Auxiliary data structure for sorting of hits.
const JModuleRouter & router
Definition: JMuonPrefit.hh:403
Template L0 hit builder.
Definition: JBuildL0.hh:35
std::vector< hit_type > buffer_type
Definition: JMuonPrefit.hh:79
double ctMin
minimal cosine space angle between PMT axes
3D match criterion with road width.
Definition: JMatch3B.hh:34
JEvt JRECONSTRUCTION::JMuonPrefit::operator() ( const buffer_type dataL0,
const buffer_type dataL1 
)
inline

Fit function.

Parameters
dataL0L0 hit data
dataL1L1 hit data
Returns
fit results

Definition at line 185 of file JMuonPrefit.hh.

187  {
188  using namespace std;
189  using namespace JPP;
190 
191  const double STANDARD_DEVIATIONS = 3.0; // [unit]
192  const double HIT_OFF = 1.0e3 * sigma_ns * sigma_ns; // [ns^2]
193 
195 
196  data.reserve(dataL0.size() +
197  dataL1.size());
198 
199  JEvt out;
200 
201  for (JOmega3D_t::const_iterator dir = omega.begin(); dir != omega.end(); ++dir) {
202 
203  const JRotation3D R(*dir);
204 
205 
206  buffer_type::iterator __end = copy(dataL1.begin(), dataL1.end(), data.begin());
207 
208  for (buffer_type::iterator i = data.begin(); i != __end; ++i) {
209  i->rotate(R);
210  }
211 
212 
213  // reduce data
214 
215  if (distance(data.begin(), __end) > NMaxHits) {
216 
217  advance(__end = data.begin(), NMaxHits);
218 
219  partial_sort(data.begin(), __end, data.end(), cmz);
220  }
221 
222 
223  // 1D cluster
224 
225  __end = clusterizeWeight(data.begin(), __end, match1D);
226 
227  if (useL0) {
228 
229  buffer_type::iterator p = __end; // begin L0 data
230  buffer_type::iterator q = copy(dataL0.begin(), dataL0.end(), p); // end L0 data
231 
232  for (buffer_type::iterator i = p; i != q; ++i) {
233 
234  if (find_if(data.begin(), __end, bind2nd(equal_to<JDAQModuleIdentifier>(), i->getModuleID())) == __end) {
235 
236  i->rotate(R);
237 
238  if (match1D.count(*i, data.begin(), __end) != 0) {
239  *p = *i;
240  ++p;
241  }
242  }
243  }
244 
245  __end = clusterize(__end, p, match1D);
246  }
247 
248 
249  if (distance(data.begin(), __end) <= NUMBER_OF_PARAMETERS) {
250  continue;
251  }
252 
253 
254  // 1D fit
255 
256  JLine1Z tz;
257  double chi2 = numeric_limits<double>::max();
258  int NDF = distance(data.begin(), __end) - NUMBER_OF_PARAMETERS;
259  int N = getCount(data.begin(), __end);
260 
261 
262  if (distance(data.begin(), __end) <= factoryLimit) {
263 
264  int number_of_outliers = numberOfOutliers;
265 
266  if (number_of_outliers > NDF - 1) {
267  number_of_outliers = NDF - 1;
268  }
269 
270  double ymin = numeric_limits<double>::max();
271 
272  buffer_type::iterator __end1 = __end;
273 
274  for (int n = 0; n <= number_of_outliers; ++n, --__end1) {
275 
276  sort(data.begin(), __end, hit_type::compare);
277 
278  do {
279  /*
280  if (getNumberOfStrings(router, data.begin(), __end1) < 2) {
281  continue;
282  }
283  */
284  try {
285 
286  (*this)(data.begin(), __end1);
287 
288  V.set(*this, data.begin(), __end1, gridAngle_deg, sigma_ns);
289  Y.set(*this, data.begin(), __end1);
290 
291  V.invert();
292 
293  double y = getChi2(Y, V);
294 
295  if (y <= -(STANDARD_DEVIATIONS * STANDARD_DEVIATIONS)) {
296 
297  WARNING(endl << "chi2(1) " << y << endl);
298 
299  } else {
300 
301  if (y < 0.0) {
302  y = 0.0;
303  }
304 
305  if (y < ymin) {
306  ymin = y;
307  tz = *this;
308  chi2 = ymin;
309  NDF = distance(data.begin(), __end1) - NUMBER_OF_PARAMETERS;
310  N = getCount(data.begin(), __end1);
311  }
312  }
313  }
314  catch(const JException& error) {}
315 
316  } while (next_permutation(data.begin(), __end1, __end, hit_type::compare));
317 
318  ymin -= STANDARD_DEVIATIONS * STANDARD_DEVIATIONS;
319  }
320 
321  } else {
322 
323  const int number_of_outliers = NDF - 1;
324 
325  try {
326 
327  (*this)(data.begin(), __end);
328 
329  V.set(*this, data.begin(), __end, gridAngle_deg, sigma_ns);
330  Y.set(*this, data.begin(), __end);
331 
332  V.invert();
333 
334  for (int n = 0; n <= number_of_outliers; ++n) {
335 
336  double ymax = 0.0;
337  int k = -1;
338 
339  for (size_t i = 0; i != Y.size(); ++i) {
340 
341  double y = getChi2(Y, V, i);
342 
343  if (y > ymax) {
344  ymax = y;
345  k = i;
346  }
347  }
348 
349  if (ymax < STANDARD_DEVIATIONS * STANDARD_DEVIATIONS) {
350  break;
351  }
352 
353  V.update(k, HIT_OFF);
354 
355  this->update(data.begin(), __end, V);
356 
357  Y.set(*this, data.begin(), __end);
358 
359  NDF -= 1;
360  N -= getCount(data[k]);
361  }
362 
363  chi2 = getChi2(Y, V);
364  tz = *this;
365  }
366  catch(const JException& error) {}
367  }
368 
369  if (chi2 != numeric_limits<double>::max()) {
370 
371  tz.rotate_back(R);
372 
373  out.push_back(getFit(JHistory(JMUONPREFIT), tz, *dir, getQuality(chi2, N, NDF), NDF));
374  }
375  }
376 
377  return out;
378  }
General exception.
Definition: JException.hh:23
#define WARNING(A)
Definition: JMessage.hh:65
1D match criterion.
Definition: JMatch1D.hh:31
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
void set(const JVector3D &pos, T __begin, T __end, const double alpha, const double sigma)
Set co-variance matrix.
Definition: JMatrixNZ.hh:85
JPosition3D & rotate_back(const JRotation3D &R)
Rotate back.
Definition: JPosition3D.hh:200
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Rotation matrix.
Definition: JRotation3D.hh:111
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
static struct JTRIGGER::@82 clusterizeWeight
Anonymous struct for weighed clustering of hits.
void update(const size_t k, const double value)
Update inverted matrix at given diagonal element.
Definition: JMatrixNS.hh:457
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
static struct JRECONSTRUCTION::JMuonPrefit::@64 cmz
Auxiliary data structure for sorting of hits.
int numberOfOutliers
maximum number of outliers
const int n
Definition: JPolint.hh:676
static const int JMUONPREFIT
Acoustic event fit.
static struct JTRIGGER::@80 clusterize
Anonymous structure for clustering of hits.
double gridAngle_deg
grid angle for directions [deg]
void set(const JLine1Z &track, T __begin, T __end)
Set time residual vector.
Definition: JVectorNZ.hh:68
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
double TMaxLocal_ns
time window for local coincidences [ns]
void invert()
Invert matrix according LDU decomposition.
Definition: JMatrixNS.hh:80
JFit getFit(const JHistory &history, const JTrack3D &track, const double Q, const int NDF, const double energy=0.0, const int status=0)
Get fit.
int factoryLimit
factory limit for combinatorics
JFIT::JHistory JHistory
Definition: JHistory.hh:301
Data structure for fit of straight line paralel to z-axis.
Definition: JLine1Z.hh:27
int getCount(const T &hit)
Get hit count.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
static struct JTRIGGER::JHitR1::@86 compare
Auxiliary data structure for sorting of hits.
bool next_permutation(T __begin, T __last, T __end, JComparator_t compare, std::bidirectional_iterator_tag)
Implementation of method next_permutation for bidirectional iterators.
Definition: JPermutation.hh:20
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:56
void JRECONSTRUCTION::JMuonPrefit::configure ( )
inlineprivate

Configure internal buffer(s).

Definition at line 411 of file JMuonPrefit.hh.

412  {
413  using namespace JPP;
414 
417  }
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
const JClass_t & getReference() const
Get reference to object.
Definition: JReference.hh:38
const JModuleRouter & router
Definition: JMuonPrefit.hh:403
void JRECONSTRUCTION::JMuonPrefitParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 39 of file JMuonPrefitParameters_t.hh.

40  {
41  factoryLimit = 8;
42  NMaxHits = 50;
43  sigma_ns = 5;
44  gridAngle_deg = 1;
45  useL0 = false;
46  numberOfOutliers = 3;
47  numberOfPrefits = 12;
48  DZMax = 0.0;
49  numberOfDZMax = 1;
50  TMaxLocal_ns = 18.0;
51  ctMin = 0;
52  roadWidth_m = 200;
53  }
int numberOfOutliers
maximum number of outliers
double gridAngle_deg
grid angle for directions [deg]
double TMaxLocal_ns
time window for local coincidences [ns]
int factoryLimit
factory limit for combinatorics
double DZMax
maximal slope for downward pointing solutions
size_t numberOfDZMax
additional number of downward pointing solutions
double ctMin
minimal cosine space angle between PMT axes
bool JRECONSTRUCTION::JMuonPrefitParameters_t::equals ( const JMuonPrefitParameters_t parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 61 of file JMuonPrefitParameters_t.hh.

62  {
63  return (this->factoryLimit == parameters.factoryLimit &&
64  this->NMaxHits == parameters.NMaxHits &&
65  this->sigma_ns == parameters.sigma_ns &&
66  this->gridAngle_deg == parameters.gridAngle_deg &&
67  this->useL0 == parameters.useL0 &&
68  this->numberOfOutliers == parameters.numberOfOutliers &&
69  this->numberOfPrefits == parameters.numberOfPrefits &&
70  this->DZMax == parameters.DZMax &&
71  this->numberOfDZMax == parameters.numberOfDZMax &&
72  this->TMaxLocal_ns == parameters.TMaxLocal_ns &&
73  this->roadWidth_m == parameters.roadWidth_m);
74  }
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
int numberOfOutliers
maximum number of outliers
double gridAngle_deg
grid angle for directions [deg]
double TMaxLocal_ns
time window for local coincidences [ns]
int factoryLimit
factory limit for combinatorics
double DZMax
maximal slope for downward pointing solutions
size_t numberOfDZMax
additional number of downward pointing solutions
JRECONSTRUCTION::JMuonPrefitParameters_t::ClassDef ( JMuonPrefitParameters_t  ,
 
)
inherited

Member Data Documentation

struct { ... } JRECONSTRUCTION::JMuonPrefit::cmz

Auxiliary data structure for sorting of hits.

const JModuleRouter& JRECONSTRUCTION::JMuonPrefit::router

Definition at line 403 of file JMuonPrefit.hh.

JOmega3D JRECONSTRUCTION::JMuonPrefit::omega

Definition at line 404 of file JMuonPrefit.hh.

int JRECONSTRUCTION::JMuonPrefit::debug

Definition at line 405 of file JMuonPrefit.hh.

buffer_type JRECONSTRUCTION::JMuonPrefit::data
private

Definition at line 419 of file JMuonPrefit.hh.

JMatrixNZ JRECONSTRUCTION::JMuonPrefit::V
private

Definition at line 420 of file JMuonPrefit.hh.

JVectorNZ JRECONSTRUCTION::JMuonPrefit::Y
private

Definition at line 421 of file JMuonPrefit.hh.

int JRECONSTRUCTION::JMuonPrefitParameters_t::factoryLimit
inherited

factory limit for combinatorics

Definition at line 78 of file JMuonPrefitParameters_t.hh.

int JRECONSTRUCTION::JMuonPrefitParameters_t::NMaxHits
inherited

maximal number of hits

Definition at line 79 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::sigma_ns
inherited

time resolution [ns]

Definition at line 80 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::gridAngle_deg
inherited

grid angle for directions [deg]

Definition at line 81 of file JMuonPrefitParameters_t.hh.

bool JRECONSTRUCTION::JMuonPrefitParameters_t::useL0
inherited

option for L0 hit use

Definition at line 82 of file JMuonPrefitParameters_t.hh.

int JRECONSTRUCTION::JMuonPrefitParameters_t::numberOfOutliers
inherited

maximum number of outliers

Definition at line 83 of file JMuonPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JMuonPrefitParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 84 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::DZMax
inherited

maximal slope for downward pointing solutions

Definition at line 85 of file JMuonPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JMuonPrefitParameters_t::numberOfDZMax
inherited

additional number of downward pointing solutions

Definition at line 86 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::TMaxLocal_ns
inherited

time window for local coincidences [ns]

Definition at line 87 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::ctMin
inherited

minimal cosine space angle between PMT axes

Definition at line 88 of file JMuonPrefitParameters_t.hh.

double JRECONSTRUCTION::JMuonPrefitParameters_t::roadWidth_m
inherited

road width [m]

Definition at line 89 of file JMuonPrefitParameters_t.hh.


The documentation for this struct was generated from the following file: