Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | 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
 Auxiliary class to match hit to root hit. More...
 

Public Types

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

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, 3)
 

Public Attributes

const JModuleRouterrouter
 
size_t numberOfPrefits
 number of prefits More...
 
int factoryLimit
 factory limit for combinatorics More...
 
double sigma_ns
 time resolution [ns] More...
 
int numberOfOutliers
 maximum number of outliers More...
 
double TMaxLocal_ns
 time window for local coincidences [ns] More...
 
double TMaxExtra_ns
 time window for extra coincidences [ns] More...
 
double ctMin
 minimal cosine space angle between PMT axes More...
 
double DMax_m
 maximal distance to optical module [m] More...
 
size_t numberOfL1
 minimal number of L1 More...
 
int pos_grid_m
 edge [m] of the position grid More...
 
int pos_step_m
 step in [m] of position grid More...
 
int time_grid_ns
 edge [ns] of the time grid More...
 
int time_step_ns
 step in [ns] of time grid More...
 
size_t numberOfGrids
 number of prefits to be used to build a grid around More...
 

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 52 of file JShowerPrefit.hh.

Member Typedef Documentation

Definition at line 57 of file JShowerPrefit.hh.

Definition at line 58 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 68 of file JShowerPrefit.hh.

70  :
71  JShowerPrefitParameters_t(parameters),
72  router(router)
73  {}
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 81 of file JShowerPrefit.hh.

82  {
83 
84  using namespace std;
85  using namespace JPP;
86 
87  const double STANDARD_DEVIATIONS = 3.0;
88 
89  typedef JEstimator<JPoint4D> JEstimator_t;
90 
91  const JBuildL0<hit_type> buildL0;
93  const JMatch3G<hit_type> match3G(DMax_m, TMaxExtra_ns); // causality relation for showers
94 
95  //define empty vectors to be filled with JHitL0 and JHitL1
96  buffer_type dataL0;
97  buffer_type dataL1;
98 
99  JEvt out;
100 
101  buffer_type buffer;
102 
103 
104  buildL0(JDAQTimeslice(event, true), router, back_inserter(buffer)); // true => snapshot
105  buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false => triggered
106 
107  copy(dataL1.begin(), dataL1.end(), back_inserter(dataL0));
108 
109  if(dataL1.size() <= numberOfL1){
110  for (buffer_type::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
111  if (find_if(dataL1.begin(), dataL1.end(), match_t(*i, TMaxExtra_ns)) == dataL1.end()) {
112  dataL0.push_back(*i);
113  }
114  }
115  }
116  for (buffer_type::const_iterator root = dataL1.begin(); root != dataL1.end(); ++root) {
117 
118  buffer_type data(1, *root);
119 
120  JBinder2nd<hit_type> matching = JBind2nd(match3G, *root);
121 
122  for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
123 
124  if(( root->getModuleIdentifier() != i->getModuleIdentifier() ) && matching(*i)){
125  data.push_back(*i);
126  }
127  }
128 
129  buffer_type::iterator __end1 = clusterizeWeight(data.begin() + 1, data.end(), match3G);
130 
131  // 4D fit
132  JEstimator_t fit;
133  JPoint4D vx;
134  double chi2 = numeric_limits<double>::max();
135  int NDF = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS;
136  int N = getCount(data.begin(), __end1);
137 
138  if(NDF > 0){
139  if(distance(data.begin(), __end1) <= factoryLimit){
140 
141  double ymin = numeric_limits<double>::max();
142 
143  buffer_type::iterator __end2 = __end1;
144 
145  for (int n = 0; n <= numberOfOutliers && distance(data.begin(), __end2) >
146  JEstimator_t::NUMBER_OF_PARAMETERS; ++n, --__end2) {
147 
148  sort(data.begin() + 1, __end1, hit_type::compare);
149 
150  do {
151  try {
152 
153  fit(data.begin(), __end2);
154 
155  double y = getChi2(fit, data.begin(), __end2, sigma_ns);
156 
157  if (y < ymin) {
158  ymin = y;
159  vx = fit;
160  chi2 = ymin;
161  NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
162  N = getCount(data.begin(), __end2);
163  }
164  }
165  catch(JException& error) { }
166 
167  } while (next_permutation(data.begin() + 1, __end2, __end1, hit_type::compare));
168 
169  ymin -= STANDARD_DEVIATIONS * STANDARD_DEVIATIONS;
170  }
171 
172  } else {
173 
174  const int number_of_outliers = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS - 1;
175 
176  buffer_type::iterator __end2 = __end1;
177 
178  for (int n = 0; n <= number_of_outliers; ++n) {
179 
180  try{
181 
182  fit(data.begin(), __end2);
183  vx = fit;
184  chi2 = getChi2(fit, data.begin(), __end2, sigma_ns);
185  NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
186  N = getCount(data.begin(), __end2);
187 
188  }
189  catch(const JException& error){ }
190 
191  double ymax = 0;
192  buffer_type::iterator imax = __end2;
193 
194  for (buffer_type::iterator i = data.begin() + 1; i != __end2; ++i) {
195 
196  double y = getChi2(fit, *i, sigma_ns);
197 
198  if (y > ymax) {
199  ymax = y;
200  imax = i;
201  }
202  }
203 
204  if (ymax > STANDARD_DEVIATIONS * STANDARD_DEVIATIONS) {
205  --__end2;
206  swap(*imax, *__end2);
207  } else {
208  break;
209  }
210  }
211  }
212 
213  out.push_back(getFit(JHistory(JSHOWERPREFIT), JTrack3D(vx, JGEOMETRY3D::JVersor3Z()), getQuality(chi2, N), NDF));
214 
215  }
216  }
217 
218  out.select(numberOfGrids, qualitySorter);
219 
220  size_t solutions = out.size();
221 
222  for(size_t i=0; i < solutions; i++){
223  for(int x = -pos_grid_m; x < pos_grid_m + pos_step_m/2.; x += pos_step_m){
224  for(int y = -pos_grid_m; y < pos_grid_m + pos_step_m/2.; y += pos_step_m){
225  for(int z = -pos_grid_m; z < pos_grid_m + pos_step_m/2.; z += pos_step_m){
226  for(int t = -time_grid_ns; t < time_grid_ns + time_step_ns/2.; t += time_step_ns){
227  if (x != 0 || y != 0 || z != 0 || t != 0) {
228 
229  out.push_back(getFit(JHistory(JSHOWERPREFIT),
230  JTrack3D(JPoint4D(getPosition(out[i]) + JPosition3D(x,y,z), out[i].getT()+t), JVersor3Z()),
231  0,
232  0));
233 
234  }
235  }
236  }
237  }
238  }
239  }
240  return out;
241 
242  }
int factoryLimit
factory limit for combinatorics
General exception.
Definition: JException.hh:24
3G match criterion.
Definition: JMatch3G.hh:29
size_t numberOfGrids
number of prefits to be used to build a grid around
static struct JTRIGGER::clusterizeWeight clusterizeWeight
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
Definition: JBind2nd.hh:66
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.
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
Definition: JVectorize.hh:261
Data structure for vertex fit.
Definition: JPoint4D.hh:22
JFit getFit(const JHistory &history, const JTrack3D &track, const double Q, const int NDF, const double energy=0.0, const int status=SINGLE_STAGE)
Get fit.
Auxiliary class to convert binary JMatch operator and given hit to unary match operator.
Definition: JBind2nd.hh:24
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
do JPlot2D f $WORKDIR canberra[${EMITTER}\] root
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
static struct JTRIGGER::JHitR1::compare compare
const int n
Definition: JPolint.hh:786
static const int JSHOWERPREFIT
Template L2 builder.
Definition: JBuildL2.hh:45
const JModuleRouter & router
Acoustic event fit.
double ctMin
minimal cosine space angle between PMT axes
Data time slice.
Data structure for L2 parameters.
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
JFIT::JHistory JHistory
Definition: JHistory.hh:354
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
double DMax_m
maximal distance to optical module [m]
JPosition3D getPosition(const JFit &fit)
Get position.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
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:56
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:39
double TMaxExtra_ns
time window for extra coincidences [ns]
double TMaxLocal_ns
time window for local coincidences [ns]
void JRECONSTRUCTION::JShowerPrefitParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 35 of file JShowerPrefitParameters_t.hh.

36  {
37  factoryLimit = 40;
38  sigma_ns = 3.0;
39  numberOfOutliers = 4;
40  TMaxLocal_ns = 20.0;
41  TMaxExtra_ns = 60.0;
42  ctMin = 0.0;
43  DMax_m = 50.0;
44  numberOfPrefits = 100;
45  numberOfGrids = 2;
46  numberOfL1 = 10;
47  pos_grid_m = 10;
48  pos_step_m = 10;
49  time_grid_ns = 60;
50  time_step_ns = 60;
51  }
int factoryLimit
factory limit for combinatorics
size_t numberOfGrids
number of prefits to be used to build a grid around
double ctMin
minimal cosine space angle between PMT axes
double DMax_m
maximal distance to optical module [m]
double TMaxExtra_ns
time window for extra coincidences [ns]
double TMaxLocal_ns
time window for local coincidences [ns]
bool JRECONSTRUCTION::JShowerPrefitParameters_t::equals ( const JShowerPrefitParameters_t parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 59 of file JShowerPrefitParameters_t.hh.

60  {
61  return (this->factoryLimit == parameters.factoryLimit &&
62  this->sigma_ns == parameters.sigma_ns &&
63  this->numberOfOutliers == parameters.numberOfOutliers &&
64  this->TMaxExtra_ns == parameters.TMaxExtra_ns &&
65  this->TMaxLocal_ns == parameters.TMaxLocal_ns &&
66  this->ctMin == parameters.ctMin &&
67  this->DMax_m == parameters.DMax_m &&
68  this->numberOfPrefits == parameters.numberOfPrefits &&
69  this->numberOfGrids == parameters.numberOfGrids &&
70  this->pos_grid_m == parameters.pos_grid_m &&
71  this->pos_step_m == parameters.pos_step_m &&
72  this->time_grid_ns == parameters.time_grid_ns &&
73  this->time_step_ns == parameters.time_step_ns &&
74  this->numberOfL1 == parameters.numberOfL1);
75  }
int factoryLimit
factory limit for combinatorics
*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
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
JRECONSTRUCTION::JShowerPrefitParameters_t::ClassDef ( JShowerPrefitParameters_t  ,
 
)
inherited

Member Data Documentation

const JModuleRouter& JRECONSTRUCTION::JShowerPrefit::router

Definition at line 244 of file JShowerPrefit.hh.

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 79 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::factoryLimit
inherited

factory limit for combinatorics

Definition at line 80 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::sigma_ns
inherited

time resolution [ns]

Definition at line 81 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfOutliers
inherited

maximum number of outliers

Definition at line 82 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::TMaxLocal_ns
inherited

time window for local coincidences [ns]

Definition at line 83 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::TMaxExtra_ns
inherited

time window for extra coincidences [ns]

Definition at line 84 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::ctMin
inherited

minimal cosine space angle between PMT axes

Definition at line 85 of file JShowerPrefitParameters_t.hh.

double JRECONSTRUCTION::JShowerPrefitParameters_t::DMax_m
inherited

maximal distance to optical module [m]

Definition at line 86 of file JShowerPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfL1
inherited

minimal number of L1

Definition at line 87 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::pos_grid_m
inherited

edge [m] of the position grid

Definition at line 88 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::pos_step_m
inherited

step in [m] of position grid

Definition at line 89 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::time_grid_ns
inherited

edge [ns] of the time grid

Definition at line 90 of file JShowerPrefitParameters_t.hh.

int JRECONSTRUCTION::JShowerPrefitParameters_t::time_step_ns
inherited

step in [ns] of time grid

Definition at line 91 of file JShowerPrefitParameters_t.hh.

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfGrids
inherited

number of prefits to be used to build a grid around

Definition at line 92 of file JShowerPrefitParameters_t.hh.


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