Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | List of all members
JFIT::JRegressor< JEnergy > Struct Template Reference

Regressor function object for fit of muon energy. More...

#include <JEnergyRegressor.hh>

Inheritance diagram for JFIT::JRegressor< JEnergy >:
JFIT::JAbstractRegressor< JEnergy > JFIT::JAbstractMinimiser< JEnergy > JEEP::JMessage< T >

Public Types

typedef JTOOLS::JMAPLIST
< JTOOLS::JPolint1FunctionalMap,
JTOOLS::JPolint1FunctionalGridMap,
JTOOLS::JPolint1FunctionalGridMap >
::maplist 
JNPEMaplist_t
 
typedef JPHYSICS::JNPETable
< double, double,
JNPEMaplist_t
JNPE_t
 
typedef JAbstractMinimiser
< JEnergy
minimiser_type
 
typedef JRegressor< JEnergy,
JAbstractMinimiser
regressor_type
 
typedef minimiser_type::result_type result_type
 

Public Member Functions

 JRegressor (const std::string &fileDescriptor)
 Constructor. More...
 
double operator() (const JEnergy &x, const JNPEHit &npe) const
 Fit function. More...
 
JNPE getNPE (const JAxis3D &axis, const double R_Hz) const
 Create data structure for handling light yields for PMT. More...
 
double getRmax () const
 Get maximal road width of NPE. More...
 
result_type operator() (const JEnergy &value, T __begin, T __end)
 Global fit. More...
 
result_type operator() (const JFunction_t &fit, T __begin, T __end)
 Get chi2. More...
 

Public Attributes

std::vector< JNPE_tY1
 light from muon More...
 
std::vector< JNPE_tYA
 light from delta-rays More...
 
std::vector< JNPE_tYB
 light from EM showers More...
 
JLANG::JSinglePointer
< JMEstimator
estimator
 M-Estimator function. More...
 
JEnergy value
 model value More...
 

Static Public Attributes

static JTimeRange T_ns
 Time window with respect to Cherenkov hypothesis [ns]. More...
 
static const int NUMBER_OF_PDFS = 6
 
static const JPDFType_t pdf_t [NUMBER_OF_PDFS]
 PDF types. More...
 
static int debug = 0
 debug level (default is off). More...
 

Static Protected Member Functions

static double getRmax (const std::vector< JNPE_t > &NPE)
 Get maximal road width of PDF. More...
 
static double getNPE (const std::vector< JNPE_t > &NPE, const double R, const double theta, const double phi)
 Get number of photo-electrons. More...
 

Detailed Description

template<>
struct JFIT::JRegressor< JEnergy >

Regressor function object for fit of muon energy.

Definition at line 49 of file JEnergyRegressor.hh.

Member Typedef Documentation

Definition at line 57 of file JEnergyRegressor.hh.

Definition at line 58 of file JEnergyRegressor.hh.

Definition at line 80 of file JRegressor.hh.

Definition at line 81 of file JRegressor.hh.

Definition at line 82 of file JRegressor.hh.

Constructor & Destructor Documentation

JFIT::JRegressor< JEnergy >::JRegressor ( const std::string fileDescriptor)
inline

Constructor.

The PDF file descriptor should contain the wild card character JPHYSICS::WILD_CARD which will be replaced by the PDF types listed in JRegressor<JEnergy, JSimplex>::pdf_t.

Parameters
fileDescriptorPDF file descriptor

Definition at line 69 of file JEnergyRegressor.hh.

69  :
71  {
72  using namespace std;
73  using namespace JPP;
74 
75  typedef JSplineFunction1D_t JFunction1D_t;
76  typedef JPDFTable<JFunction1D_t, JNPEMaplist_t> JPDF_t;
77 
78  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
79 
80  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
81 
82  try {
83 
84  JPDF_t pdf;
85 
86  const JPDFType_t type = pdf_t[i];
87  const string file_name = getFilename(fileDescriptor, type);
88 
89  NOTICE("loading PDF from file " << file_name << "... " << flush);
90 
91  pdf.load(file_name.c_str());
92 
93  NOTICE("OK" << endl);
94 
95  pdf.setExceptionHandler(supervisor);
96 
97  if (is_bremsstrahlung(type))
98  YB.push_back(JNPE_t(pdf));
99  else if (is_deltarays(type))
100  YA.push_back(JNPE_t(pdf));
101  else
102  Y1.push_back(JNPE_t(pdf));
103  }
104  catch(const JLANG::JException& error) {
105  FATAL(error.what() << endl);
106  }
107  }
108 
109  // Add PDFs
110 
111  if (Y1.size() == 2) { Y1[1].add(Y1[0]); Y1.erase(Y1.begin()); }
112  if (YA.size() == 2) { YA[1].add(YA[0]); YA.erase(YA.begin()); }
113  if (YB.size() == 2) { YB[1].add(YB[0]); YB.erase(YB.begin()); }
114  }
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
General exception.
Definition: JException.hh:24
std::vector< JNPE_t > YA
light from delta-rays
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:137
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
std::vector< JNPE_t > Y1
light from muon
#define NOTICE(A)
Definition: JMessage.hh:64
Normal M-estimator.
Definition: JMEstimator.hh:52
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:24
static const JPDFType_t pdf_t[NUMBER_OF_PDFS]
PDF types.
#define FATAL(A)
Definition: JMessage.hh:67
virtual const char * what() const override
Get error message.
Definition: JException.hh:64
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:151
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
std::vector< JNPE_t > YB
light from EM showers

Member Function Documentation

double JFIT::JRegressor< JEnergy >::operator() ( const JEnergy x,
const JNPEHit npe 
) const
inline

Fit function.

This method is used to determine chi2 of given number of photo-electrons for given energy of muon.

Parameters
xenergy
npenpe
Returns
chi2

Definition at line 125 of file JEnergyRegressor.hh.

126  {
127  const double E = x.getE();
128  const double u = npe.getChi2(E);
129 
130  return estimator->getRho(u);
131  }
double getE() const
Get energy.
Definition: JEnergy.hh:170
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
double getChi2(const double E_GeV) const
Get chi2.
Definition: JNPEHit.hh:87
JLANG::JSinglePointer< JMEstimator > estimator
M-Estimator function.
double u[N+1]
Definition: JPolint.hh:865
JNPE JFIT::JRegressor< JEnergy >::getNPE ( const JAxis3D axis,
const double  R_Hz 
) const
inline

Create data structure for handling light yields for PMT.

Note that the PMT geometry should be relative to the muon trajectory, conform method JGEOMETRY3D::JAxis3D::transform.

Parameters
axisPMT axis
R_Hzsingles rate [Hz]
Returns
light yields

Definition at line 143 of file JEnergyRegressor.hh.

145  {
146  using namespace std;
147  using namespace JPP;
148 
149  const double x = axis.getX();
150  const double y = axis.getY();
151  const double R = sqrt(x*x + y*y);
152  const double z = axis.getZ() - R / getTanThetaC();
153 
154  const double theta = axis.getTheta();
155  const double phi = fabs(axis.getPhi());
156 
157  const double y1 = getNPE(Y1, R, theta, phi);
158  const double yA = getNPE(YA, R, theta, phi);
159  const double yB = getNPE(YB, R, theta, phi);
160 
161  return JNPE(getN(T_ns, R_Hz * 1.0e-9), y1, yA, yB, z);
162  }
double getN(const JRange< T > &range, const double R)
Get expected number of occurrences due to given rate within specified interval.
Definition: JRange.hh:704
std::vector< JNPE_t > YA
light from delta-rays
JNPE getNPE(const JAxis3D &axis, const double R_Hz) const
Create data structure for handling light yields for PMT.
std::vector< JNPE_t > Y1
light from muon
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Auxiliary class for handling various light yields.
Definition: JNPE.hh:30
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
std::vector< JNPE_t > YB
light from EM showers
double JFIT::JRegressor< JEnergy >::getRmax ( ) const
inline

Get maximal road width of NPE.

Returns
road width [m]

Definition at line 170 of file JEnergyRegressor.hh.

171  {
172  return std::max(getRmax(Y1), std::max(getRmax(YA), getRmax(YB)));
173  }
std::vector< JNPE_t > YA
light from delta-rays
std::vector< JNPE_t > Y1
light from muon
double getRmax() const
Get maximal road width of NPE.
std::vector< JNPE_t > YB
light from EM showers
static double JFIT::JRegressor< JEnergy >::getRmax ( const std::vector< JNPE_t > &  NPE)
inlinestaticprotected

Get maximal road width of PDF.

Parameters
NPENPE tables
Returns
road width [m]

Definition at line 197 of file JEnergyRegressor.hh.

198  {
199  double xmax = 0.0;
200 
201  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
202  if (!i->empty() && i->getXmax() > xmax) {
203  xmax = i->getXmax();
204  }
205  }
206 
207  return xmax;
208  }
const double xmax
Definition: JQuadrature.cc:24
static double JFIT::JRegressor< JEnergy >::getNPE ( const std::vector< JNPE_t > &  NPE,
const double  R,
const double  theta,
const double  phi 
)
inlinestaticprotected

Get number of photo-electrons.

Parameters
NPENPE tables
Rdistance between muon and PMT [m]
thetazenith angle orientation PMT [rad]
phiazimuth angle orientation PMT [rad]
Returns
number of photo-electrons

Definition at line 220 of file JEnergyRegressor.hh.

224  {
225  using JTOOLS::get_value;
226 
227  double npe = 0.0;
228 
229  for (std::vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
230 
231  if (R <= i->getXmax()) {
232 
233  try {
234 
235  const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
236 
237  if (y > 0.0) {
238  npe += y;
239  }
240  }
241  catch(const JLANG::JException& error) {
242  ERROR(error << std::endl);
243  }
244  }
245  }
246 
247  return npe;
248  }
General exception.
Definition: JException.hh:24
#define ERROR(A)
Definition: JMessage.hh:66
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
result_type JFIT::JAbstractRegressor< JEnergy , JAbstractMinimiser >::operator() ( const JEnergy value,
T  __begin,
T  __end 
)
inlineinherited

Global fit.

Parameters
valuestart value
__beginbegin of data set
__endend of data set
Returns
chi2

Definition at line 94 of file JRegressor.hh.

95  {
96  static_cast<minimiser_type&>(*this).value = value;
97 
98  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
99  }
JAbstractMinimiser< JEnergy > minimiser_type
Definition: JRegressor.hh:80
JRegressor< JEnergy, JAbstractMinimiser > regressor_type
Definition: JRegressor.hh:81
JModel_t value
model value
Definition: JRegressor.hh:59
result_type JFIT::JAbstractMinimiser< JEnergy >::operator() ( const JFunction_t &  fit,
T  __begin,
T  __end 
)
inlineinherited

Get chi2.

Parameters
fitfit function
__beginbegin of data
__endend of data
Returns
chi2

Definition at line 48 of file JRegressor.hh.

49  {
50  double chi2 = 0.0;
51 
52  for (T i = __begin; i != __end; ++i) {
53  chi2 += fit(value, *i);
54  }
55 
56  return chi2;
57  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
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

Member Data Documentation

light from muon

Definition at line 176 of file JEnergyRegressor.hh.

light from delta-rays

Definition at line 177 of file JEnergyRegressor.hh.

light from EM showers

Definition at line 178 of file JEnergyRegressor.hh.

JTimeRange JFIT::JRegressor< JEnergy >::T_ns
static

Time window with respect to Cherenkov hypothesis [ns].

Time range.

Definition at line 180 of file JEnergyRegressor.hh.

const int JFIT::JRegressor< JEnergy >::NUMBER_OF_PDFS = 6
static

Definition at line 183 of file JEnergyRegressor.hh.

const JPDFType_t JFIT::JRegressor< JEnergy >::pdf_t
static

M-Estimator function.

Definition at line 187 of file JEnergyRegressor.hh.

model value

Definition at line 59 of file JRegressor.hh.

template<class T>
int JEEP::JMessage< T >::debug = 0
staticinherited

debug level (default is off).

Definition at line 45 of file JMessage.hh.


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