Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JRECONSTRUCTION::JMuonEnergy Class Reference

Auxiliary class to to determine muon energy. More...

#include <JMuonEnergy.hh>

Inheritance diagram for JRECONSTRUCTION::JMuonEnergy:
JRECONSTRUCTION::JMuonEnergyParameters_t JFIT::JRegressor< JModel_t, JMinimiser_t > TObject

Classes

struct  JResult
 Auxiliary class for energy estimation. More...
 

Public Types

typedef JRegressor< JEnergyJRegressor_t
 
typedef JTRIGGER::JHitR1 hit_type
 
typedef std::vector< hit_typebuffer_type
 
typedef JTOOLS::JRange< JEnergyJEnergyRange
 

Public Member Functions

 JMuonEnergy (const JMuonEnergyParameters_t &parameters, const JModuleRouter &router, const JSummaryRouter &summary, const std::string &pdfFile, const int debug=0)
 Constructor.
 
JEvt operator() (const KM3NETDAQ::JDAQEvent &event, const JEvt &in)
 Fit function.
 
void reset ()
 Reset fit parameters.
 
bool equals (const JMuonEnergyParameters_t &parameters) const
 Equality.
 
 ClassDef (JMuonEnergyParameters_t, 1)
 

Public Attributes

double roadWidth_m
 road width [m]
 
double R_Hz
 default rate [Hz]
 
size_t numberOfPrefits
 number of prefits
 
double EMin_log
 minimal energy [log10(GeV)]
 
double EMax_log
 maximal energy [log10(GeV)]
 
double TMin_ns
 minimal time w.r.t. Cherenkov hypothesis [ns]
 
double TMax_ns
 maximal time w.r.t. Cherenkov hypothesis [ns]
 
double ZMin_m
 minimal z-position [m]
 
double resolution
 energy resolution [log10(GeV)]
 
int mestimator
 M-estimator.
 
bool reprocess
 reprocess
 

Private Attributes

const JModuleRouterrouter
 
const JSummaryRoutersummary
 
int debug
 

Detailed Description

Auxiliary class to to determine muon energy.

Definition at line 58 of file JMuonEnergy.hh.

Member Typedef Documentation

◆ JRegressor_t

◆ hit_type

◆ buffer_type

◆ JEnergyRange

Constructor & Destructor Documentation

◆ JMuonEnergy()

JRECONSTRUCTION::JMuonEnergy::JMuonEnergy ( const JMuonEnergyParameters_t & parameters,
const JModuleRouter & router,
const JSummaryRouter & summary,
const std::string & pdfFile,
const int debug = 0 )
inline

Constructor.

Parameters
parametersparameters
routermodule router
summarysummary router
pdfFilePDF file
debugdebug

Definition at line 79 of file JMuonEnergy.hh.

83 :
84 JMuonEnergyParameters_t(parameters),
85 JRegressor_t(pdfFile),
86 router(router),
89 {
90 using namespace JPP;
91
92 JRegressor_t::debug = debug;
93 JRegressor_t::T_ns.setRange(TMin_ns, TMax_ns);
94
95 if (this->getRmax() < roadWidth_m) {
96 roadWidth_m = this->getRmax();
97 }
98
99 this->estimator.reset(getMEstimator(mestimator));
100
101 if (!this->estimator.is_valid()) {
102 FATAL("Invalid M-Estimator." << endl);
103 }
104 }
#define FATAL(A)
Definition JMessage.hh:67
JRegressor< JEnergy > JRegressor_t
const JModuleRouter & router
const JSummaryRouter & summary
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]

Member Function Documentation

◆ operator()()

JEvt JRECONSTRUCTION::JMuonEnergy::operator() ( const KM3NETDAQ::JDAQEvent & event,
const JEvt & in )
inline

Fit function.

Parameters
eventevent
instart values
Returns
fit results

Definition at line 146 of file JMuonEnergy.hh.

147 {
148 using namespace std;
149 using namespace JPP;
150
151 JEvt out;
152
153 typedef vector<JHitL0> JDataL0_t;
154 const JBuildL0<JHitL0> buildL0;
155
157
158 JDataL0_t dataL0;
159
160 buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
161
162 for (JEvt::const_iterator track = in.begin(); track != in.end(); ++track) {
163
164 const JRotation3D R (getDirection(*track));
165 const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
166 const JFIT::JModel<JLine1Z> match(tz, roadWidth_m, JRegressor_t::T_ns);
167
169
171
172 for (JDataL0_t::const_iterator i = dataL0.begin(); i !=dataL0.end(); ++i) {
173
174 JHitR1 hit(*i);
175
176 hit.rotate(R);
177
178 if (match(hit)) {
179 top.insert(i->getPMTIdentifier());
180 }
181 }
182
183 JRange<double> Z_m;
184
185 if ( track->hasW(JSTART_LENGTH_METRES) && track->getW(JSTART_LENGTH_METRES) > 0.0 ) {
186 Z_m.setLowerLimit(this->ZMin_m);
187 }
188
189 const JDetectorSubset_t subdetector(detector, getAxis(*track), roadWidth_m, Z_m);
190
191 for (JDetector::const_iterator module = subdetector.begin(); module != subdetector.end(); ++module) {
192
193 if (summary.hasSummaryFrame(module->getID())) {
194
195 const JDAQSummaryFrame& frame = summary.getSummaryFrame(module->getID());
196
197 for (size_t i = 0; i != module->size(); ++i) {
198
199 if (getDAQStatus(frame, *module, i) &&
200 getPMTStatus(frame, *module, i) &&
201 frame[i].is_valid() &&
202 !module->getPMT(i).has(PMT_DISABLE)) {
203
204 const JDAQPMTIdentifier id(module->getID(), i);
205
206 const double rate_Hz = summary.getRate(id);
207 const size_t count = top.count(id);
208
209 data.push_back(JNPEHit(this->getNPE(module->getPMT(i), rate_Hz), count));
210 }
211 }
212 }
213 }
214
215 const int NDF = distance(data.begin(), data.end()) - 1;
216
217 if( NDF >= 0 ) {
218
219 // 5-point search between given limits
220
221 const int N = 5;
222
223 JResult result[N];
224
225 for (int i = 0; i != N; ++i) {
226 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
227 }
228
229 map<double, double> buffer;
230
231 do {
232
233 int j = 0;
234
235 for (int i = 0; i != N; ++i) {
236
237 if (!result[i]) {
238
239 const JEnergy x = result[i].x;
240 const double chi2 = (*this)(x, data.begin(), data.end());
241
242 result[i].chi2 = chi2;
243 buffer[chi2] = x.getE();
244 }
245
246 if (result[i].chi2 < result[j].chi2) {
247 j = i;
248 }
249 }
250
251
252 for (int i = 0; i != N; ++i) {
253 DEBUG(' ' << FIXED(5,2) << result[i].x << ' ' << FIXED(9,3) << result[i].chi2);
254 }
255 DEBUG(endl);
256
257 // squeeze range
258
259 switch (j) {
260
261 case 0:
262 result[4] = result[1];
263 result[2] = result[0];
264 result[0] = JResult(2*result[2].x - result[4].x);
265 break;
266
267 case 1:
268 result[4] = result[2];
269 result[2] = result[1];
270 break;
271
272 case 2:
273 result[0] = result[1];
274 result[4] = result[3];
275 break;
276
277 case 3:
278 result[0] = result[2];
279 result[2] = result[3];
280 break;
281
282 case 4:
283 result[0] = result[3];
284 result[2] = result[4];
285 result[4] = JResult(2*result[2].x - result[0].x);
286 break;
287 }
288
289 result[1] = JResult(0.5 * (result[0].x + result[2].x));
290 result[3] = JResult(0.5 * (result[2].x + result[4].x));
291
292 } while (result[4].x - result[0].x > resolution);
293
294
295 if (result[1].chi2 != result[3].chi2) {
296
297 result[2].x += 0.25 * (result[3].x - result[1].x) * (result[1].chi2 - result[3].chi2) / (result[1].chi2 + result[3].chi2 - 2*result[2].chi2);
298 result[2].chi2 = (*this)(result[2].x, data.begin(), data.end());
299
300 }
301
302 const double chi2 = result[2].chi2;
303 const double E = result[2].x.getE();
304
305 // calculate additional variables
306
307 double Emin = numeric_limits<double>::max();
308 double Emax = numeric_limits<double>::lowest();
309
310 for (map<double, double>::const_iterator i = buffer.begin(); i != buffer.end() && i->first <= chi2 + 1.0; ++i) {
311 if (i->second < Emin) { Emin = i->second; }
312 if (i->second > Emax) { Emax = i->second; }
313 }
314
315 const double mu_range = gWater(E); // range of a muon with the reconstructed energy
316
317 double noise_likelihood = 0.0; // log-likelihood of every hit being from K40
318 int number_of_hits = 0; // number of hits selected for JEnergy
319
320 for (vector<JNPEHit>::const_iterator i = data.begin(); i != data.end(); ++i) {
321 noise_likelihood += log10(getP(i->getY0(), i->getN())); // probability of getting the observed multiplicity with K40
322 number_of_hits += i->getN(); // hit multiplicity
323 }
324
325 out.push_back(JFit(*track).add(JMUONENERGY));
326
327 out.rbegin()->setE(E);
328
329 out.rbegin()->setW(track->getW());
330 out.rbegin()->setW(JENERGY_ENERGY, E);
331 out.rbegin()->setW(JENERGY_CHI2, chi2);
332 out.rbegin()->setW(JENERGY_MUON_RANGE_METRES, mu_range);
333 out.rbegin()->setW(JENERGY_NOISE_LIKELIHOOD, noise_likelihood);
334 out.rbegin()->setW(JENERGY_NDF, NDF);
335 out.rbegin()->setW(JENERGY_NUMBER_OF_HITS, number_of_hits);
336 out.rbegin()->setW(JENERGY_MINIMAL_ENERGY, Emin);
337 out.rbegin()->setW(JENERGY_MAXIMAL_ENERGY, Emax);
338 }
339 }
340
341 return out;
342 }
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Detector subset without binary search functionality.
Detector data structure.
Definition JDetector.hh:96
Data structure for fit of energy.
Definition JEnergy.hh:31
JFit & add(const int type)
Add event to history.
Data structure for fit of straight line paralel to z-axis.
Definition JLine1Z.hh:29
JPosition3D & rotate(const JRotation3D &R)
Rotate.
const JClass_t & getReference() const
Get reference to object.
Definition JReference.hh:38
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
double getRate() const
Get default rate.
const JDAQSummaryFrame & getSummaryFrame() const
Get default summary frame.
Range of values.
Definition JRange.hh:42
void setLowerLimit(argument_type x)
Set lower limit.
Definition JRange.hh:224
Template L0 hit builder.
Definition JBuildL0.hh:38
Reduced data structure for L1 hit.
Definition JHitR1.hh:35
Data storage class for rate measurements of all PMTs in one module.
static const int JMUONENERGY
static const int JENERGY_NDF
number of degrees of freedom from JEnergy.cc
static const int JENERGY_ENERGY
uncorrected energy [GeV] from JEnergy.cc
static const int JENERGY_NOISE_LIKELIHOOD
log likelihood of every hit being K40 from JEnergy.cc
static const int JENERGY_CHI2
chi2 from JEnergy.cc
static const int JENERGY_MUON_RANGE_METRES
range of a muon with the reconstructed energy [m] from JEnergy.cc
static const int JENERGY_NUMBER_OF_HITS
number of hits from JEnergy.cc
static const int JSTART_LENGTH_METRES
distance between first and last hits in metres from JStart.cc
static const int JENERGY_MINIMAL_ENERGY
minimal energy [GeV] from JEnergy.cc
static const int JENERGY_MAXIMAL_ENERGY
maximal energy [GeV] from JEnergy.cc
double getNPE(const Hit &hit)
Get true charge of hit.
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits.
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition JGeane.hh:381
JPosition3D getPosition(const JFit &fit)
Get position.
JAxis3D getAxis(const JFit &fit)
Get axis.
JDirection3D getDirection(const JFit &fit)
Get direction.
bool is_valid(const json &js)
Check validity of JSon data.
return result
Definition JPolint.hh:853
int j
Definition JPolint.hh:792
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
static const int PMT_DISABLE
KM3NeT Data Definitions v3.4.0-8-ge14cb17 https://git.km3net.de/common/km3net-dataformat.
Definition pmt_status.hh:12
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Detector file.
Definition JHead.hh:227
Acoustic event fit.
Auxiliary class to match data points with given model.
Auxiliary class for simultaneously handling light yields and response of PMT.
Definition JNPEHit.hh:21
double resolution
energy resolution [log10(GeV)]
double EMin_log
minimal energy [log10(GeV)]
double EMax_log
maximal energy [log10(GeV)]

◆ reset()

void JRECONSTRUCTION::JMuonEnergyParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 44 of file JMuonEnergyParameters_t.hh.

45 {
46 roadWidth_m = std::numeric_limits<double>::max();
47 R_Hz = 6.0e3;
49 EMin_log = 1.0;
50 EMax_log = 8.0;
51 TMin_ns = -50.0;
52 TMax_ns = +450.0;
53 ZMin_m = std::numeric_limits<double>::lowest();
54 resolution = 0.01;
56 reprocess = false;
57 }
@ EM_NORMAL

◆ equals()

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

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 65 of file JMuonEnergyParameters_t.hh.

66 {
67 return (this->roadWidth_m == parameters.roadWidth_m &&
68 this->R_Hz == parameters.R_Hz &&
69 this->numberOfPrefits == parameters.numberOfPrefits &&
70 this->EMin_log == parameters.EMin_log &&
71 this->EMax_log == parameters.EMax_log &&
72 this->TMin_ns == parameters.TMin_ns &&
73 this->TMax_ns == parameters.TMax_ns &&
74 this->ZMin_m == parameters.ZMin_m &&
75 this->resolution == parameters.resolution &&
76 this->mestimator == parameters.mestimator &&
77 this->reprocess == parameters.reprocess);
78 }

◆ ClassDef()

JRECONSTRUCTION::JMuonEnergyParameters_t::ClassDef ( JMuonEnergyParameters_t ,
1  )
inherited

Member Data Documentation

◆ router

const JModuleRouter& JRECONSTRUCTION::JMuonEnergy::router
private

Definition at line 345 of file JMuonEnergy.hh.

◆ summary

const JSummaryRouter& JRECONSTRUCTION::JMuonEnergy::summary
private

Definition at line 346 of file JMuonEnergy.hh.

◆ debug

int JRECONSTRUCTION::JMuonEnergy::debug
private

Definition at line 347 of file JMuonEnergy.hh.

◆ roadWidth_m

double JRECONSTRUCTION::JMuonEnergyParameters_t::roadWidth_m
inherited

road width [m]

Definition at line 82 of file JMuonEnergyParameters_t.hh.

◆ R_Hz

double JRECONSTRUCTION::JMuonEnergyParameters_t::R_Hz
inherited

default rate [Hz]

Definition at line 83 of file JMuonEnergyParameters_t.hh.

◆ numberOfPrefits

size_t JRECONSTRUCTION::JMuonEnergyParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 84 of file JMuonEnergyParameters_t.hh.

◆ EMin_log

double JRECONSTRUCTION::JMuonEnergyParameters_t::EMin_log
inherited

minimal energy [log10(GeV)]

Definition at line 85 of file JMuonEnergyParameters_t.hh.

◆ EMax_log

double JRECONSTRUCTION::JMuonEnergyParameters_t::EMax_log
inherited

maximal energy [log10(GeV)]

Definition at line 86 of file JMuonEnergyParameters_t.hh.

◆ TMin_ns

double JRECONSTRUCTION::JMuonEnergyParameters_t::TMin_ns
inherited

minimal time w.r.t. Cherenkov hypothesis [ns]

Definition at line 87 of file JMuonEnergyParameters_t.hh.

◆ TMax_ns

double JRECONSTRUCTION::JMuonEnergyParameters_t::TMax_ns
inherited

maximal time w.r.t. Cherenkov hypothesis [ns]

Definition at line 88 of file JMuonEnergyParameters_t.hh.

◆ ZMin_m

double JRECONSTRUCTION::JMuonEnergyParameters_t::ZMin_m
inherited

minimal z-position [m]

Definition at line 89 of file JMuonEnergyParameters_t.hh.

◆ resolution

double JRECONSTRUCTION::JMuonEnergyParameters_t::resolution
inherited

energy resolution [log10(GeV)]

Definition at line 90 of file JMuonEnergyParameters_t.hh.

◆ mestimator

int JRECONSTRUCTION::JMuonEnergyParameters_t::mestimator
inherited

M-estimator.

Definition at line 91 of file JMuonEnergyParameters_t.hh.

◆ reprocess

bool JRECONSTRUCTION::JMuonEnergyParameters_t::reprocess
inherited

reprocess

Definition at line 92 of file JMuonEnergyParameters_t.hh.


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