Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Public Attributes | List of all members
JRECONSTRUCTION::JShowerPrefit Class Reference

class to handle first step of the shower reconstruction in ORCA: it reconstructs the shower vertex, intended as the shower brightest point, as the barycenter of the hits More...

#include <JShowerPrefit.hh>

Inheritance diagram for JRECONSTRUCTION::JShowerPrefit:
JRECONSTRUCTION::JShowerPrefitParameters_t TObject

Classes

struct  match_t
 

Public Member Functions

 JShowerPrefit (const JShowerPrefitParameters_t &parameters, const JModuleRouter &router, const int debug=0)
 Parameterized constructor. More...
 
JEvt operator() (const KM3NETDAQ::JDAQEvent &event) const
 Declaration of the operator that performs the reconstruction. More...
 
void reset ()
 Reset fit parameters. More...
 
bool equals (const JShowerPrefitParameters_t &parameters) const
 Equality. More...
 
 ClassDef (JShowerPrefitParameters_t, 2)
 

Public Attributes

const JModuleRouterrouter
 
int factoryLimit
 
size_t NMaxHits
 
double sigma_ns
 
int numberOfOutliers
 
double TMaxLocal_ns
 
double ctMin
 
double roadWidth_m
 
size_t numberOfPrefits
 

Detailed Description

class to handle first step of the shower reconstruction in ORCA: it reconstructs the shower vertex, intended as the shower brightest point, as the barycenter of the hits

Definition at line 50 of file JShowerPrefit.hh.

Constructor & Destructor Documentation

JRECONSTRUCTION::JShowerPrefit::JShowerPrefit ( const JShowerPrefitParameters_t parameters,
const JModuleRouter router,
const int  debug = 0 
)
inline

Parameterized constructor.

Parameters
parametersstruct that holds default-optimized parameters for the reconstruction.
routermodule router, this is built via detector file.
debugdebug

Definition at line 63 of file JShowerPrefit.hh.

65  :
66  JShowerPrefitParameters_t(parameters),
67  router(router)
68  {}
const JModuleRouter & router

Member Function Documentation

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

Declaration of the operator that performs the reconstruction.

Parameters
eventwhich is a JDAQEvent

Definition at line 76 of file JShowerPrefit.hh.

77  {
78 
79  using namespace std;
80  using namespace JPP;
81 
82  const double STANDARD_DEVIATIONS = 3.0;
83 
84  typedef JHitR1 hit_type;
85  typedef vector<hit_type> buffer_type;
86 
87  typedef JEstimator<JPoint4D> JEstimator_t;
88 
89  const JBuildL0<hit_type> buildL0;
91  const JMatch3G<hit_type> match3G(roadWidth_m, TMaxLocal_ns); // causality relation for showers
92  const JHitL1Comparator compare;
93 
94  //define empty vectors to be filled with JHitL0 and JHitL1
95  buffer_type dataL0;
96  buffer_type dataL1;
97 
98  JEvt out;
99 
100  buffer_type buffer;
101 
102  buildL0(JDAQTimeslice(event, true), router, back_inserter(buffer)); // true = snapshot
103  buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false = triggered
104 
105  copy(dataL1.begin(), dataL1.end(), back_inserter(dataL0));
106 
107  for (buffer_type::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
108 
109  if (find_if(dataL1.begin(), dataL1.end(), match_t(*i, TMaxLocal_ns)) == dataL1.end()) {
110  dataL0.push_back(*i);
111  }
112  }
113 
114  for (buffer_type::const_iterator root = dataL1.begin(); root != dataL1.end(); ++root) {
115 
116  buffer_type data(1, *root);
117 
118  JBinder2nd<hit_type> matching = JBind2nd(match3G, *root);
119 
120  for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
121 
122  if(( root->getModuleIdentifier() != i->getModuleIdentifier() ) && matching(*i)){
123  data.push_back(*i);
124  }
125  }
126 
127  buffer_type::iterator __end1 = clusterizeWeight(data.begin() + 1, data.end(), match3G);
128 
129  // 4D fit
130  JEstimator_t fit;
131  JPoint4D vx;
132  double chi2 = numeric_limits<double>::max();
133  int NDF = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS;
134  int N = getCount(data.begin(), __end1);
135 
136  if(distance(data.begin(), __end1) <= factoryLimit){
137 
138  double ymin = numeric_limits<double>::max();
139 
140  buffer_type::iterator __end2 = __end1;
141 
142  for (int n = 0; n <= numberOfOutliers && distance(data.begin(), __end2) >
143  JEstimator_t::NUMBER_OF_PARAMETERS; ++n, --__end2) {
144 
145  sort(data.begin() + 1, __end1, compare);
146 
147  do {
148  try {
149 
150  fit(data.begin(), __end2);
151 
152  double y = getChi2(fit, data.begin(), __end2, sigma_ns);
153 
154  if (y < ymin) {
155  ymin = y;
156  vx = fit;
157  chi2 = ymin;
158  NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
159  N = getCount(data.begin(), __end2);
160  }
161  }
162  catch(JException& error) { }
163 
164  } while (next_permutation(data.begin() + 1, __end2, __end1, compare));
165 
166  ymin -= STANDARD_DEVIATIONS * STANDARD_DEVIATIONS;
167  }
168 
169  } else {
170 
171  const int number_of_outliers = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS - 1;
172 
173  buffer_type::iterator __end2 = __end1;
174 
175  for (int n = 0; n <= number_of_outliers; ++n) {
176 
177  try{
178 
179  fit(data.begin(), __end2);
180  vx = fit;
181  chi2 = getChi2(fit, data.begin(), __end2, sigma_ns);
182  NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
183  N = getCount(data.begin(), __end2);
184 
185  }
186  catch(const JException& error){ }
187 
188  double ymax = 0;
189  buffer_type::iterator imax = __end2;
190 
191  for (buffer_type::iterator i = data.begin() + 1; i != __end2; ++i) {
192 
193  double y = getChi2(fit, *i, sigma_ns);
194 
195  if (y > ymax) {
196  ymax = y;
197  imax = i;
198  }
199  }
200 
201  if (ymax > STANDARD_DEVIATIONS * STANDARD_DEVIATIONS) {
202  --__end2;
203  swap(*imax, *__end2);
204  } else {
205  break;
206  }
207  }
208  }
209 
210  if (NDF >= 0) {
211 
212  const JGEOMETRY3D::JTrack3D fitResult(vx, JGEOMETRY3D::JVersor3Z());
213 
214  out.push_back(getFit(JHistory(JSHOWERPREFIT), fitResult, getQuality(chi2, N), NDF));
215 
216  out.rbegin()->setW(13, chi2);
217  out.rbegin()->setW(14, N);
218  }
219  }
220 
221  return out;
222 
223  }
General exception.
Definition: JException.hh:23
3G match criterion.
Definition: JMatch3G.hh:29
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
Definition: JBind2nd.hh:70
Linear fit of bright point (position and time) between hits (objects with position and time)...
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Data structure for vertex fit.
Definition: JPoint4D.hh:22
then JPlot1D f $WORKDIR postfit[prefit\] root
Auxiliary class to convert binary JMatch operator and given hit to unary match operator.
Definition: JBind2nd.hh:26
static struct JTRIGGER::@76 clusterizeWeight
Anonymous struct for weighed clustering of hits.
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
static const int JSHOWERPREFIT
Template L2 builder.
Definition: JBuildL2.hh:45
const JModuleRouter & router
Acoustic event fit.
Data time slice.
Data structure for L2 parameters.
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.
Auxiliary class for permutations of L1 hits.
JFIT::JHistory JHistory
Definition: JHistory.hh:283
alias put_queue eval echo n
Definition: qlib.csh:19
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
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
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
Template L0 hit builder.
Definition: JBuildL0.hh:35
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:79
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:39
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
void JRECONSTRUCTION::JShowerPrefitParameters_t::reset ( )
inlineinherited
bool JRECONSTRUCTION::JShowerPrefitParameters_t::equals ( const JShowerPrefitParameters_t parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 53 of file JShowerPrefitParameters_t.hh.

54  {
55  return (this->factoryLimit == parameters.factoryLimit &&
56  this->NMaxHits == parameters.NMaxHits &&
57  this->sigma_ns == parameters.sigma_ns &&
58  this->numberOfOutliers == parameters.numberOfOutliers &&
59  this->TMaxLocal_ns == parameters.TMaxLocal_ns &&
60  this->ctMin == parameters.ctMin &&
61  this->roadWidth_m == parameters.roadWidth_m &&
62  this->numberOfPrefits == parameters.numberOfPrefits);
63  }
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
JRECONSTRUCTION::JShowerPrefitParameters_t::ClassDef ( JShowerPrefitParameters_t  ,
 
)
inherited

Member Data Documentation

const JModuleRouter& JRECONSTRUCTION::JShowerPrefit::router

Definition at line 225 of file JShowerPrefit.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::factoryLimit
inherited

Definition at line 67 of file JShowerPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::NMaxHits
inherited

Definition at line 68 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::sigma_ns
inherited

Definition at line 69 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfOutliers
inherited

Definition at line 70 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::TMaxLocal_ns
inherited

Definition at line 71 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::ctMin
inherited

Definition at line 72 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::roadWidth_m
inherited

Definition at line 73 of file JShowerPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfPrefits
inherited

Definition at line 74 of file JShowerPrefitParameters_t.hh.


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