Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JRECONSTRUCTION::JShowerDirectionPrefit Class Reference

class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA More...

#include <JShowerDirectionPrefit.hh>

Inheritance diagram for JRECONSTRUCTION::JShowerDirectionPrefit:
JRECONSTRUCTION::JShowerDirectionPrefitParameters_t JFIT::JRegressor< JModel_t, JMinimiser_t > TObject

Classes

struct  input_type
 Input data type. More...
 

Public Types

typedef JRegressor< JShower3EZ, JAbstractMinimiserJRegressor_t
 
typedef JModuleL0 module_type
 
typedef std::vector< module_typedetector_type
 

Public Member Functions

 JShowerDirectionPrefit (const JShowerDirectionPrefitParameters_t &parameters, const storage_type &storage, const int debug=0)
 Parameterized constructor.
 
input_type getInput (const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
 Get input data.
 
JEvt operator() (const input_type &input)
 Fit function.
 
void reset ()
 Reset fit parameters.
 
bool equals (const JShowerDirectionPrefitParameters_t &parameters) const
 Equality.
 
 ClassDef (JShowerDirectionPrefitParameters_t, 2)
 

Public Attributes

std::vector< double > Ev
 
size_t numberOfPrefits
 number of prefits

 
double TMax_ns
 maximum time for local coincidences [ns]

 
double TMin_ns
 minimum time for local coincidences [ns]

 
double DMax_m
 maximal distance to optical module [m]
 
double R_Hz
 default rate [Hz]

 
double VMax_npe
 maximum number of of photo-electrons

 
double scanAngle_deg
 scanning angle step in [deg]
 
double Emin_GeV
 minimum energy to scan
 
double Emax_GeV
 maximum energy to scan
 
int En
 number of points to scan in energy range
 

Detailed Description

class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA

Definition at line 77 of file JShowerDirectionPrefit.hh.

Member Typedef Documentation

◆ JRegressor_t

◆ module_type

◆ detector_type

Constructor & Destructor Documentation

◆ JShowerDirectionPrefit()

JRECONSTRUCTION::JShowerDirectionPrefit::JShowerDirectionPrefit ( const JShowerDirectionPrefitParameters_t & parameters,
const storage_type & storage,
const int debug = 0 )
inline

Parameterized constructor.

Parameters
parametersstruct that holds default-optimized parameters for the reconstruction, available in $JPP_DATA.
storagestorage
debugdebug

Definition at line 130 of file JShowerDirectionPrefit.hh.

132 :
134 JRegressor_t(storage)
135 {
136 using namespace JPP;
137
138 JRegressor_t::debug = debug;
139 JRegressor_t::T_ns.setRange(parameters.TMin_ns, parameters.TMax_ns);
140 JRegressor_t::Vmax_npe = VMax_npe;
141
142 if (Emin_GeV > Emax_GeV || En <= 1) {
143 THROW(JException, "Invalid energy input " << Emin_GeV << ' ' << Emax_GeV << ' ' << En);
144 }
145
146 const double base = std::pow((Emax_GeV / Emin_GeV), 1.0 / (En - 1));
147
148 for (int i = 0; i != En; ++i) {
149 Ev.push_back(Emin_GeV * std::pow(base, i));
150 }
151 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
int debug
debug level
Definition JSirene.cc:72
General exception.
Definition JException.hh:24
JRegressor< JShower3EZ, JAbstractMinimiser > JRegressor_t
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

Member Function Documentation

◆ getInput()

input_type JRECONSTRUCTION::JShowerDirectionPrefit::getInput ( const JModuleRouter & router,
const JSummaryRouter & summary,
const JDAQEvent & event,
const JEvt & in,
const coverage_type & coverage ) const
inline

Get input data.

Parameters
routermodule router
summarysummary data
eventevent
instart values
coveragecoverage
Returns
input data

Definition at line 163 of file JShowerDirectionPrefit.hh.

168 {
169 using namespace std;
170 using namespace JTRIGGER;
171
172 input_type input(event.getDAQEventHeader(), in, coverage);
173
174 const JBuildL0 <JHitR0> buildL0;
176
177 const JDAQTimeslice timeslice(event, true);
178
179 JSuperFrame2D<JHit> buffer;
180
181 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
182
183 if (router.hasModule(i->getModuleID())) {
184
185 buffer(*i, router.getModule(i->getModuleID()));
186
187 buildL0(buffer, back_inserter(data[i->getModuleID()]));
188 }
189 }
190
191 for (const auto& module : router.getReference()) {
192 if (!module.empty()) {
193 input.data.push_back(module_type(module, summary.getSummaryFrame(module.getID(), R_Hz), data[module.getID()]));
194 }
195 }
196
197 return input;
198 }
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
const JClass_t & getReference() const
Get reference to object.
Definition JReference.hh:38
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
2-dimensional frame with time calibrated data from one optical module.
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
Auxiliary classes and methods for triggering.

◆ operator()()

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

Fit function.

Parameters
inputinput data
Returns
fit results

Definition at line 206 of file JShowerDirectionPrefit.hh.

207 {
208 using namespace std;
209 using namespace JPP;
210
212
213 JEvt out;
214
215 JEvt in = input.in;
216
217 in.select(numberOfPrefits, qualitySorter);
218
219 if (!in.empty()) {
220 in.select(JHistory::is_event(in.begin()->getHistory()));
221 }
222
223 for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
224
226
227 const JPosition3D vertex(getPosition(*shower));
228 const double time = shower->getT();
229
230 for (const auto& module : input.data) {
231
232 JPosition3D pos(module->getPosition());
233 pos.sub(vertex);
234
235 if(pos.getLength() <= DMax_m){
236
237 const double t1 = time + pos.getLength() * getInverseSpeedOfLight() * getIndexOfRefraction();
238
239 for (size_t i = 0; i != module->size(); ++i) {
240 if (module.getStatus(i)) {
241 struct {
242
243 bool operator()(const JHitR0& hit) const
244 {
245 return (hit.getPMT() == pmt && T_ns(hit.getT()));
246 }
247
248 const JTimeRange T_ns;
249 const size_t pmt;
250
251 } match = { JRegressor_t::T_ns + t1, i };
252
253 JPMT pmt = module->getPMT(i);
254
255 pmt.sub(vertex);
256
257 data.push_back(JPMTW0(pmt, module.frame.getRate(i), count_if(module.begin(), module.end(), match)));
258
259 }
260 }
261 }
262 }
263
264 JVector3D start_dir(0,0,0);
265 for (vector<JPMTW0>::const_iterator i = data.begin(); i != data.end(); ++i) {
266 if (i->getN() != 0) start_dir.add(i->getPosition());
267 }
268
269 JOmega3D scan_directions(JDirection3D(start_dir),
271 scanAngle_deg * JMATH::PI / 180.0);
272
273 const JShower3EZ sh(JVertex3D(JVector3D(0,0,0), shower->getT()), JVersor3Z(), 1);
274
275 for (JOmega3D_t::const_iterator dir = scan_directions.begin(); dir != scan_directions.end(); ++dir) {
276
277 const JRotation3D R(*dir);
278
279 vector<double> chi2(En, 0.0);
280
281 for (vector<JPMTW0>::const_iterator i = data.begin(); i != data.end(); ++i) {
282
283 JPMTW0 pmt = *i;
284 pmt.rotate(R);
285
286 JNPE_t::result_type H1 = (*this).getH1(sh, pmt);
287 JNPE_t::result_type H0 = (*this).getH0(pmt.getR()); // getH0 = Get background hypothesis value for time integrated PDF.
288 const bool hit = pmt.getN() != 0;
289
290 const double chi2_bg = getChi2(get_value(H0), hit);
291
292 for (size_t j=0; j!=chi2.size(); ++j) {
293
294 chi2[j]+= getChi2(get_value(Ev[j] * H1 + H0), hit) - chi2_bg; // H1 is linear with E, -log-lik ratio
295
296 }
297
298 }
299
300 //Store only the lowest chi2 for a given direction
301
302 auto p = std::min_element(chi2.begin(), chi2.end());
303
304 out.push_back(getFit(JHistory(shower->getHistory(), event()),
305 JShower3D(JVertex3D(vertex,time), JDirection3D(*dir)),
306 getQuality(*p),
307 data.size(),
308 Ev[p-chi2.begin()]));
309
310 // set additional values
311 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
312 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
313
314 }
315 }
316
317 // apply default sorter
318
319 sort(out.begin(), out.end(), qualitySorter);
320
321 copy(input.in.begin(), input.in.end(), back_inserter(out));
322
323 return out;
324
325 }
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Data structure for fit of straight line in positive z-direction with energy.
Definition JShower3EZ.hh:30
JAxis3D & rotate(const JRotation3D &R)
Rotate axis.
Definition JAxis3D.hh:225
Data structure for direction in three dimensions.
Direction set covering (part of) solid angle.
Definition JOmega3D.hh:68
Data structure for position in three dimensions.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition JVector3D.hh:158
Data structure for normalised vector in positive z-direction.
Definition JVersor3Z.hh:41
JEvt operator()(const input_type &input)
Fit function.
Reduced data structure for L0 hit.
Definition JHitR0.hh:27
JPMT_t getPMT() const
Get PMT.
Definition JHitR0.hh:60
double getT() const
Get calibrated time of hit.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
double getChi2(const double P)
Get chi2 corresponding to given probability.
static const double PI
Mathematical constants.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
const double getInverseSpeedOfLight()
Get inverse speed of light.
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
JPosition3D getPosition(const JFit &fit)
Get position.
JFIT::JHistory JHistory
Definition JHistory.hh:455
void copy(const JFIT::JEvt::const_iterator __begin, const JFIT::JEvt::const_iterator __end, Evt &out)
Copy tracks.
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.
int j
Definition JPolint.hh:801
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition JResult.hh:998
Acoustic event fit.
Auxiliary class to test history.
Definition JHistory.hh:157
Auxiliary class for handling PMT geometry, rate and response.
Definition JPMTW0.hh:24
int getN() const
Get number of hits.
Definition JPMTW0.hh:67
double getR() const
Get rate.
Definition JPMTW0.hh:56

◆ reset()

void JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 35 of file JShowerDirectionPrefitParameters_t.hh.

36 {
38 TMax_ns = 30;
39 TMin_ns = -30;
40 DMax_m = 80;
41 scanAngle_deg = 10;
42 R_Hz = 10.0e3;
43 VMax_npe = 20.0;
44 Emin_GeV = 1;
45 Emax_GeV = 1000;
46 En = 50;
47 }

◆ equals()

bool JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::equals ( const JShowerDirectionPrefitParameters_t & parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 55 of file JShowerDirectionPrefitParameters_t.hh.

56 {
57 return (this->TMax_ns == parameters.TMax_ns &&
58 this->TMin_ns == parameters.TMin_ns &&
59 this->numberOfPrefits == parameters.numberOfPrefits &&
60 this->DMax_m == parameters.DMax_m &&
61 this->R_Hz == parameters.R_Hz &&
62 this->scanAngle_deg == parameters.scanAngle_deg &&
63 this->VMax_npe == parameters.VMax_npe &&
64 this->Emin_GeV == parameters.Emin_GeV &&
65 this->Emax_GeV == parameters.Emax_GeV &&
66 this->En == parameters.En );
67 }

◆ ClassDef()

JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::ClassDef ( JShowerDirectionPrefitParameters_t ,
2  )
inherited

Member Data Documentation

◆ Ev

std::vector<double> JRECONSTRUCTION::JShowerDirectionPrefit::Ev

Definition at line 87 of file JShowerDirectionPrefit.hh.

◆ numberOfPrefits

size_t JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 71 of file JShowerDirectionPrefitParameters_t.hh.

◆ TMax_ns

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::TMax_ns
inherited

maximum time for local coincidences [ns]

Definition at line 72 of file JShowerDirectionPrefitParameters_t.hh.

◆ TMin_ns

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::TMin_ns
inherited

minimum time for local coincidences [ns]

Definition at line 73 of file JShowerDirectionPrefitParameters_t.hh.

◆ DMax_m

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::DMax_m
inherited

maximal distance to optical module [m]

Definition at line 74 of file JShowerDirectionPrefitParameters_t.hh.

◆ R_Hz

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::R_Hz
inherited

default rate [Hz]

Definition at line 75 of file JShowerDirectionPrefitParameters_t.hh.

◆ VMax_npe

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::VMax_npe
inherited

maximum number of of photo-electrons

Definition at line 76 of file JShowerDirectionPrefitParameters_t.hh.

◆ scanAngle_deg

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::scanAngle_deg
inherited

scanning angle step in [deg]

Definition at line 77 of file JShowerDirectionPrefitParameters_t.hh.

◆ Emin_GeV

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::Emin_GeV
inherited

minimum energy to scan

Definition at line 78 of file JShowerDirectionPrefitParameters_t.hh.

◆ Emax_GeV

double JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::Emax_GeV
inherited

maximum energy to scan

Definition at line 79 of file JShowerDirectionPrefitParameters_t.hh.

◆ En

int JRECONSTRUCTION::JShowerDirectionPrefitParameters_t::En
inherited

number of points to scan in energy range

Definition at line 80 of file JShowerDirectionPrefitParameters_t.hh.


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