1#ifndef __JFIT__JSHOWERBJORKENYREGRESSOR__
2#define __JFIT__JSHOWERBJORKENYREGRESSOR__
4#include "JPhysics/JPDFTypes.hh"
5#include "JPhysics/JPDFTable.hh"
6#include "JPhysics/JPDFToolkit.hh"
7#include "JPhysics/JNPETable.hh"
9#include "JTools/JFunction1D_t.hh"
10#include "JTools/JFunctionalMap_t.hh"
11#include "JPhysics/JConstants.hh"
12#include "JTools/JRange.hh"
13#include "JTools/JResult.hh"
14#include "JTools/JFunction1D_t.hh"
15#include "JTools/JFunctionalMap_t.hh"
16#include "JTools/JAbstractHistogram.hh"
18#include "JGeometry3D/JVector3D.hh"
19#include "JGeometry3D/JVersor3D.hh"
20#include "JGeometry3D/JDirection3D.hh"
22#include "JLang/JSharedPointer.hh"
23#include "JMath/JZero.hh"
33#include "Jeep/JMessage.hh"
43 using JPHYSICS::JPDFType_t;
44 using JPHYSICS::DIRECT_LIGHT_FROM_EMSHOWER;
45 using JPHYSICS::SCATTERED_LIGHT_FROM_EMSHOWER;
46 using JPHYSICS::DIRECT_LIGHT_FROM_BRIGHT_POINT;
47 using JPHYSICS::SCATTERED_LIGHT_FROM_BRIGHT_POINT;
48 using JTOOLS::get_value;
60 typedef JTOOLS::JMapList<JTOOLS::JPolint0FunctionalMap,
61 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalMap,
62 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalGridMap,
63 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalGridMap> > > >
JPDFMaplist_t;
64 typedef JPHYSICS::JPDFTable<JFunction1D_t, JPDFMaplist_t>
JPDF_t;
66 typedef JTOOLS::JMapList<JTOOLS::JPolint0FunctionalMap,
67 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalMap,
68 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalGridMap,
69 JTOOLS::JMapList<JTOOLS::JPolint0FunctionalGridMap> > > >
JNPEMaplist_t;
70 typedef JPHYSICS::JNPETable<double, double, JNPEMaplist_t>
JNPE_t;
74 typedef JTOOLS::JMAPLIST<JTOOLS::JPolint1FunctionalMap,
76 typedef JPHYSICS::JPDFTable<JFunction1D_t, JMapList_t2>
JPDF_t2;
78 typedef JTOOLS::JMAPLIST<JTOOLS::JPolint1FunctionalMap,
80 typedef JPHYSICS::JNPETable<double, double, JNPEMapList_t2>
JNPE_t2;
98 const JPDF_t::JSupervisor supervisor(
new JPDF_t::JDefaultResult(JMATH::zero));
99 const JPDF_t2::JSupervisor supervisor2(
new JPDF_t2::JDefaultResult(JMATH::zero));
101 for (
int i = 0; i != NUMBER_OF_PDFS; ++i) {
108 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
110 NOTICE(
"loading PDF from file " << file_name <<
"... " << flush);
114 pdf.load(file_name.c_str());
116 pdf.setExceptionHandler(supervisor);
122 pdf2.load(file_name.c_str());
124 NOTICE(
"OK" << endl);
126 pdf2.setExceptionHandler(supervisor2);
132 catch(
const JException& error) {
133 FATAL(error.what() << endl);
138 for (
int i = 1; i < (NUMBER_OF_PDFS-2); i += 2) {
140 npe[ i ].add(npe[i-1]);
144 npe[i-1].swap(buffer);
146 npe2[ i ].add(npe2[i-1]);
150 npe2[i-1].swap(buffer2);
168 JPosition3D D(pmt.getPosition());
169 JDirection3D U(pmt.getDirection());
171 D.sub(shower.getPosition());
173 double ct = U.getDot(D) / D.getLength();
175 JVersor3D shower_dir(shower.getDirection());
177 const double z = D.getDot(shower_dir);
178 const double x = D.getX() - z * shower.getDX();
179 const double y = D.getY() - z * shower.getDY();
180 const double cosDelta = z/D.getLength();
182 U.rotate(JRotation3Z(-atan2(y,x)));
184 const double theta = U.getTheta();
185 const double phi = fabs(U.getPhi());
187 double H0 = getH0(pmt.
getR());
188 double H1 = getH1(D.getLength(), ct, cosDelta, theta, phi,
191 if (H1 >= Vmax_npe) {
197 const bool hit = pmt.
getN() != 0;
198 const double u =
getChi2(H1, hit);
200 return estimator->getRho(u);
209 double getH0(
const double R_Hz)
const
211 return get_value(JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength()));
229 const double cosDelta,
234 const double Y)
const
239 for (
int i = 0; i != (NUMBER_OF_PDFS-1); ++i) {
241 if (!npe[i].empty() && D <= npe[i].getXmax() && !npe2[i].empty() && D <= npe2[i].getXmax()) {
245 JNPE_t::result_type P_em;
246 JNPE_t2::result_type P_h;
248 P_em = fabs(Eem) * npe[i](std::max(D, npe[i].getXmin()), cosDelta, theta, phi);
250 P_h = fabs(Eh) * npe2[i](std::max(D, npe2[i].getXmin()), ct);
252 double y1 = get_value(P_em) + get_value(P_h);
259 catch(JLANG::JException& error) {
260 ERROR(error << std::endl);
271 static const int NUMBER_OF_PDFS = 4;
273 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
285 SCATTERED_LIGHT_FROM_EMSHOWER,
286 DIRECT_LIGHT_FROM_BRIGHT_POINT,
287 SCATTERED_LIGHT_FROM_BRIGHT_POINT };
Maximum likelihood estimator (M-estimators).
General purpose data regression method.
Data structure for fit of straight line in positive z-direction with energy.
double getEem() const
Get EM energy.
double getEh() const
Get Hadronic energy.
double getBy() const
Get bjorken y.
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
Auxiliary classes and methods for linear and iterative data regression.
double getChi2(const double P)
Get chi2 corresponding to given probability.
Abstract class for global fit method.
Auxiliary class for handling PMT geometry, rate and response.
int getN() const
Get number of hits.
double getR() const
Get rate.
JPHYSICS::JPDFTable< JFunction1D_t, JMapList_t2 > JPDF_t2
double getH1(const double D, const double ct, const double cosDelta, const double theta, const double phi, const double Eem, const double Eh, const double Y) const
Get signal hypothesis value for time integrated PDF.
JRegressor(const std::string &fileDescriptor)
Parameterized constructor.
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
double operator()(const JShowerEH &shower, const JPMTW0 &pmt) const
Fit function.
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
JPHYSICS::JNPETable< double, double, JNPEMapList_t2 > JNPE_t2
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
double getH0(const double R_Hz) const
Get background hypothesis value for time integrated PDF.
static double Vmax_npe
Maximal integral of PDF [npe].
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JNPEMaplist_t
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JNPEMapList_t2
JTOOLS::JSplineFunction1S_t JFunction1D_t
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JMapList_t2
Template definition of a data regressor of given model.