Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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  input_type
 Input data type. More...
 
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 int debug=0)
 Parameterized constructor.
 
input_type getInput (const JModuleRouter &router, const KM3NETDAQ::JDAQEvent &event, const coverage_type &coverage) const
 Get input data.
 
JEvt operator() (const input_type &input)
 Fit function.
 
void reset ()
 Reset fit parameters.
 
bool equals (const JShowerPrefitParameters_t &parameters) const
 Equality.
 
 ClassDef (JShowerPrefitParameters_t, 3)
 

Public Attributes

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

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

Member Typedef Documentation

◆ hit_type

◆ buffer_type

Constructor & Destructor Documentation

◆ JShowerPrefit()

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

Parameterized constructor.

Parameters
parametersstruct that holds default-optimized parameters for the reconstruction.
debugdebug

Definition at line 96 of file JShowerPrefit.hh.

97 :
99 {}

Member Function Documentation

◆ getInput()

input_type JRECONSTRUCTION::JShowerPrefit::getInput ( const JModuleRouter & router,
const KM3NETDAQ::JDAQEvent & event,
const coverage_type & coverage ) const
inline

Get input data.

Parameters
routermodule router
eventevent
coveragecoverage
Returns
input data

Definition at line 109 of file JShowerPrefit.hh.

110 {
111 using namespace std;
112 using namespace JTRIGGER;
113 using namespace KM3NETDAQ;
114
115
116 const JBuildL0<hit_type> buildL0;
118
119 input_type input(event.getDAQEventHeader(), coverage);
120
121 buffer_type& dataL0 = input.dataL0;
122 buffer_type& dataL1 = input.dataL1;
123
124 buffer_type buffer;
125
126
127 buildL0(JDAQTimeslice(event, true), router, back_inserter(buffer)); // true => snapshot
128 buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false => triggered
129
130 copy(dataL1.begin(), dataL1.end(), back_inserter(dataL0));
131
132 if(dataL1.size() <= numberOfL1){
133 for (buffer_type::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
134 if (find_if(dataL1.begin(), dataL1.end(), match_t(*i, TMaxExtra_ns)) == dataL1.end()) {
135 dataL0.push_back(*i);
136 }
137 }
138 }
139 return input;
140 }
Template L0 hit builder.
Definition JBuildL0.hh:38
Template L2 builder.
Definition JBuildL2.hh:49
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
void copy(const JFIT::JEvt::const_iterator __begin, const JFIT::JEvt::const_iterator __end, Evt &out)
Copy tracks.
Auxiliary classes and methods for triggering.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double ctMin
minimal cosine space angle between PMT axes
double TMaxLocal_ns
time window for local coincidences [ns]
double TMaxExtra_ns
time window for extra coincidences [ns]
Data structure for L2 parameters.

◆ operator()()

JEvt JRECONSTRUCTION::JShowerPrefit::operator() ( const input_type & input)
inline

Fit function.

Parameters
inputinput data
Returns
fit results

Definition at line 147 of file JShowerPrefit.hh.

148 {
149 using namespace std;
150 using namespace JPP;
151
152 const double STANDARD_DEVIATIONS = 3.0;
153
154 typedef JEstimator<JPoint4D> JEstimator_t;
155
156 JEvent event(JSHOWERPREFIT);
157
158 JEvt out;
159
160 const buffer_type& dataL0 = input.dataL0;
161 const buffer_type& dataL1 = input.dataL1;
162
163 const JMatch3G<hit_type> match3G(DMax_m, TMaxExtra_ns); // causality relation for showers
164
165 for (buffer_type::const_iterator root = dataL1.begin(); root != dataL1.end(); ++root) {
166
167 buffer_type data(1, *root);
168
169 JBinder2nd<hit_type> matching = JBind2nd(match3G, *root);
170
171 for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
172
173 if(( root->getModuleIdentifier() != i->getModuleIdentifier() ) && matching(*i)){
174 data.push_back(*i);
175 }
176 }
177
178 buffer_type::iterator __end1 = clusterizeWeight(data.begin() + 1, data.end(), match3G);
179
180 // 4D fit
181 JEstimator_t fit;
182 JPoint4D vx;
183 double chi2 = numeric_limits<double>::max();
184 int NDF = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS;
185 int N = getCount(data.begin(), __end1);
186
187 if(NDF > 0){
188 if(distance(data.begin(), __end1) <= factoryLimit){
189
190 double ymin = numeric_limits<double>::max();
191
192 buffer_type::iterator __end2 = __end1;
193
194 for (int n = 0; n <= numberOfOutliers && distance(data.begin(), __end2) >
195 JEstimator_t::NUMBER_OF_PARAMETERS; ++n, --__end2) {
196
197 sort(data.begin() + 1, __end1, hit_type::compare);
198
199 do {
200 try {
201
202 fit(data.begin(), __end2);
203
204 double y = getChi2(fit, data.begin(), __end2, sigma_ns);
205
206 if (y < ymin) {
207 ymin = y;
208 vx = fit;
209 chi2 = ymin;
210 NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
211 N = getCount(data.begin(), __end2);
212 }
213 }
214 catch(JException& error) { }
215
216 } while (next_permutation(data.begin() + 1, __end2, __end1, hit_type::compare));
217
218 ymin -= STANDARD_DEVIATIONS * STANDARD_DEVIATIONS;
219 }
220
221 } else {
222
223 const int number_of_outliers = distance(data.begin(), __end1) - JEstimator_t::NUMBER_OF_PARAMETERS - 1;
224
225 buffer_type::iterator __end2 = __end1;
226
227 for (int n = 0; n <= number_of_outliers; ++n) {
228
229 try{
230
231 fit(data.begin(), __end2);
232 vx = fit;
233 chi2 = getChi2(fit, data.begin(), __end2, sigma_ns);
234 NDF = distance(data.begin(), __end2) - JEstimator_t::NUMBER_OF_PARAMETERS;
235 N = getCount(data.begin(), __end2);
236
237 }
238 catch(const JException& error){ }
239
240 double ymax = 0;
241 buffer_type::iterator imax = __end2;
242
243 for (buffer_type::iterator i = data.begin() + 1; i != __end2; ++i) {
244
245 double y = getChi2(fit, *i, sigma_ns);
246
247 if (y > ymax) {
248 ymax = y;
249 imax = i;
250 }
251 }
252
253 if (ymax > STANDARD_DEVIATIONS * STANDARD_DEVIATIONS) {
254 --__end2;
255 swap(*imax, *__end2);
256 } else {
257 break;
258 }
259 }
260 }
261
262 out.push_back(getFit(event(), JShower3D(vx, JGEOMETRY3D::JVersor3Z()), getQuality(chi2, N), NDF));
263
264 // set additional values
265
266 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
267 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
268
269 }
270 }
271
272 out.select(numberOfGrids, qualitySorter);
273
274 size_t solutions = out.size();
275
276 for(size_t i=0; i < solutions; i++){
277 for(int x = -pos_grid_m; x < pos_grid_m + pos_step_m/2.; x += pos_step_m){
278 for(int y = -pos_grid_m; y < pos_grid_m + pos_step_m/2.; y += pos_step_m){
279 for(int z = -pos_grid_m; z < pos_grid_m + pos_step_m/2.; z += pos_step_m){
280 for(int t = -time_grid_ns; t < time_grid_ns + time_step_ns/2.; t += time_step_ns){
281 if (x != 0 || y != 0 || z != 0 || t != 0) {
282
283 out.push_back(getFit(event(),
284 JShower3D(JPoint4D(getPosition(out[i]) + JPosition3D(x,y,z), out[i].getT()+t), JVersor3Z()),
285 0,
286 0));
287
288 // set additional values
289
290 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
291 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
292
293 }
294 }
295 }
296 }
297 }
298 }
299 //sorting
300
301 if (numberOfPrefits > 0) {
302
303 // apply default sorter
304
305 JFIT::JEvt::iterator __end = out.end();
306
307 if (numberOfPrefits < out.size()) {
308
309 advance(__end = out.begin(), numberOfPrefits);
310
311 partial_sort(out.begin(), __end, out.end(), qualitySorter);
312
313 out.erase(__end, out.end());
314
315 } else {
316
317 sort(out.begin(), __end, qualitySorter);
318 }
319
320 } else {
321
322 sort(out.begin(), out.end(), qualitySorter);
323 }
324
325 return out;
326 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Template definition of linear fit.
Definition JEstimator.hh:25
Data structure for vertex fit.
Definition JPoint4D.hh:24
Data structure for position in three dimensions.
Data structure for normalised vector in positive z-direction.
Definition JVersor3Z.hh:41
General exception.
Definition JException.hh:25
Auxiliary class to convert binary JMatch operator and given hit to unary match operator.
Definition JBind2nd.hh:24
static const struct JTRIGGER::JHitR1::compare compare
3G match criterion.
Definition JMatch3G.hh:31
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration of this event
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration of this event
double getChi2(const double P)
Get chi2 corresponding to given probability.
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
JPosition3D getPosition(const JFit &fit)
Get position.
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
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.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
const int n
Definition JPolint.hh:791
bool next_permutation(T __begin, T __last, T __end, JComparator_t compare, std::bidirectional_iterator_tag)
Implementation of method next_permutation for bidirectional iterators.
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
Definition JBind2nd.hh:66
JHitIterator_t clusterizeWeight(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match)
Partition data according given binary match operator.
Definition root.py:1
Acoustic event fit.
int factoryLimit
factory limit for combinatorics
double DMax_m
maximal distance to optical module [m]
size_t numberOfGrids
number of prefits to be used to build a grid around

◆ reset()

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;
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 }

◆ equals()

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 }

◆ ClassDef()

JRECONSTRUCTION::JShowerPrefitParameters_t::ClassDef ( JShowerPrefitParameters_t ,
3  )
inherited

Member Data Documentation

◆ numberOfPrefits

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 79 of file JShowerPrefitParameters_t.hh.

◆ factoryLimit

int JRECONSTRUCTION::JShowerPrefitParameters_t::factoryLimit
inherited

factory limit for combinatorics

Definition at line 80 of file JShowerPrefitParameters_t.hh.

◆ sigma_ns

double JRECONSTRUCTION::JShowerPrefitParameters_t::sigma_ns
inherited

time resolution [ns]

Definition at line 81 of file JShowerPrefitParameters_t.hh.

◆ numberOfOutliers

int JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfOutliers
inherited

maximum number of outliers

Definition at line 82 of file JShowerPrefitParameters_t.hh.

◆ TMaxLocal_ns

double JRECONSTRUCTION::JShowerPrefitParameters_t::TMaxLocal_ns
inherited

time window for local coincidences [ns]

Definition at line 83 of file JShowerPrefitParameters_t.hh.

◆ TMaxExtra_ns

double JRECONSTRUCTION::JShowerPrefitParameters_t::TMaxExtra_ns
inherited

time window for extra coincidences [ns]

Definition at line 84 of file JShowerPrefitParameters_t.hh.

◆ ctMin

double JRECONSTRUCTION::JShowerPrefitParameters_t::ctMin
inherited

minimal cosine space angle between PMT axes

Definition at line 85 of file JShowerPrefitParameters_t.hh.

◆ DMax_m

double JRECONSTRUCTION::JShowerPrefitParameters_t::DMax_m
inherited

maximal distance to optical module [m]

Definition at line 86 of file JShowerPrefitParameters_t.hh.

◆ numberOfL1

size_t JRECONSTRUCTION::JShowerPrefitParameters_t::numberOfL1
inherited

minimal number of L1

Definition at line 87 of file JShowerPrefitParameters_t.hh.

◆ pos_grid_m

int JRECONSTRUCTION::JShowerPrefitParameters_t::pos_grid_m
inherited

edge [m] of the position grid

Definition at line 88 of file JShowerPrefitParameters_t.hh.

◆ pos_step_m

int JRECONSTRUCTION::JShowerPrefitParameters_t::pos_step_m
inherited

step in [m] of position grid

Definition at line 89 of file JShowerPrefitParameters_t.hh.

◆ time_grid_ns

int JRECONSTRUCTION::JShowerPrefitParameters_t::time_grid_ns
inherited

edge [ns] of the time grid

Definition at line 90 of file JShowerPrefitParameters_t.hh.

◆ time_step_ns

int JRECONSTRUCTION::JShowerPrefitParameters_t::time_step_ns
inherited

step in [ns] of time grid

Definition at line 91 of file JShowerPrefitParameters_t.hh.

◆ numberOfGrids

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: