Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerBjorkenY.hh
Go to the documentation of this file.
1 #ifndef JSHOWERBJORKENY_INCLUDE
2 #define JSHOWERBJORKENY_INCLUDE
3 
4 #include <string>
5 #include <iostream>
6 #include <set>
7 #include <vector>
8 #include <algorithm>
9 #include <memory>
10 
13 
14 #include "JTrigger/JHit.hh"
15 #include "JTrigger/JTimeslice.hh"
16 #include "JTrigger/JHitL0.hh"
17 #include "JTrigger/JHitL1.hh"
18 #include "JTrigger/JHitR1.hh"
19 #include "JTrigger/JBuildL0.hh"
20 #include "JTrigger/JBuildL2.hh"
21 #include "JTrigger/JAlgorithm.hh"
22 #include "JTrigger/JMatch3G.hh"
23 #include "JTrigger/JBind2nd.hh"
24 
26 
28 #include "JFit/JFitToolkit.hh"
29 #include "JFit/JPoint4D.hh"
30 #include "JFit/JModel.hh"
31 #include "JFit/JSimplex.hh"
32 #include "JFit/JShowerEH.hh"
33 
34 #include "JAAnet/JAAnetToolkit.hh"
35 
37 #include "JReconstruction/JEvt.hh"
41 
42 #include "JDetector/JDetector.hh"
44 
45 #include "JGeometry3D/JVector3D.hh"
47 #include "JGeometry3D/JOmega3D.hh"
48 #include "JGeometry3D/JTrack3D.hh"
49 #include "JGeometry3D/JTrack3E.hh"
51 
52 #include "JLang/JSharedPointer.hh"
53 
54 
55 /**
56  * \author adomi
57  */
58 namespace JRECONSTRUCTION {}
59 namespace JPP { using namespace JRECONSTRUCTION; }
60 
61 namespace JRECONSTRUCTION {
62 
66  using JFIT::JRegressor;
67  using JFIT::JEnergy;
68  using JFIT::JShowerEH;
69  using JFIT::JSimplex;
70 
71  /**
72  * class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA
73  */
74  class JShowerBjorkenY :
76  public JRegressor<JShowerEH, JSimplex>
77  {
78 
80  using JRegressor_t::operator();
81 
82  public:
83 
84  /**
85  * Parameterized constructor
86  *
87  * \param parameters struct that holds default-optimized parameters for the reconstruction, available in $JPP_DATA.
88  * \param router module router, this is built via detector file.
89  * \param summary summary router
90  * \param pdfFile PDF file
91  * \param correct energy correction
92  * \param debug debug
93  */
95  const JModuleRouter& router,
96  const JSummaryRouter& summary,
97  const std::string pdfFile,
99  const int debug = 0):
100  JShowerBjorkenYParameters_t(parameters),
101  JRegressor_t(pdfFile),
102  router(router),
103  summary(summary),
104  correct(correct)
105  {
106  using namespace JPP;
107 
109  JRegressor_t::T_ns.setRange(parameters.TMin_ns, parameters.TMax_ns);
112 
113  this->estimator.reset(getMEstimator(parameters.mestimator));
114  }
115 
116  /**
117  * Declaration of the member function that actually performs the reconstruction
118  *
119  * \param event = JDAQEvent
120  * \param in = input fits
121  */
123  {
124  using namespace std;
125  using namespace JPP;
126 
127  typedef vector<JHitL0> JDataL0_t;
128  JBuildL0<JHitL0> buildL0;
129 
130  JEvt out;
131 
133 
134  JDataL0_t dataL0;
135  buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
136 
137  for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
138 
139  JShower3EY sh(getPosition(*shower), getDirection(*shower), shower->getT(),
140  shower->getE(), 0.0);
141 
143 
145 
146  for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
147 
148  if (match(*i)) {
149  top.insert(i->getPMTIdentifier());
150  }
151  }
152 
154 
155  const JDirection3D conversion(sh.getDirection());
156  const JRotation3D R(conversion);
157 
158  vector<JPMTW0> buffer;
159 
160  for (JDetectorSubset_t::iterator module = subdetector.begin();
161  module != subdetector.end(); ++module) {
162 
163  const JDAQSummaryFrame& frame = summary.getSummaryFrame(module->getID());
164 
165  JModule dom(*module);
166 
167  dom.rotate(R);
168 
169  for (unsigned int i = 0; i != dom.size(); ++i) {
170 
171  if (getDAQStatus(frame, *module, i) &&
172  getPMTStatus(frame, *module, i) &&
173  frame[i].is_valid() &&
174  !module->getPMT(i).has(PMT_DISABLE)) {
175 
176  const JDAQPMTIdentifier id(module->getID(), i);
177 
178  const double rate_Hz = summary.getRate(id);
179  const size_t count = top.count(id);
180 
181  buffer.push_back(JPMTW0(dom.getPMT(i), rate_Hz, count));
182  }
183  }
184  }
185 
186  this->step.resize(2);
187  this->step[0] = JShowerEH(JPoint4D(JVector3D(), 0.0), JVersor3Z(), fit_step, 0.0, 0.0);
188  this->step[1] = JShowerEH(JPoint4D(JVector3D(), 0.0), JVersor3Z(), 0.0, fit_step, 0.0);
189 
190  double f_h = 1 - 0.681 * (std::pow(shower->getE()/0.863, -0.207));
191 
192  double chi2 = (*this)(JShowerEH(JVertex3D(JVector3D(0,0,0), sh.getT()), JVersor3Z(),
193  log10(sh.getE()), log10(f_h*sh.getE()), sh.getBjY()),
194  buffer.begin(), buffer.end());
195 
196  double NDF = getCount(buffer.begin(), buffer.end()) - this->step.size();
197 
198  JShower3EY sh_fit(this->value.getPosition(), this->value.getDirection(),
199  this->value.getT(), correct(this->value.getEem() + this->value.getEh()), this->value.getBy());
200 
201  double y = getFinalBjY(this->value.getEem(), this->value.getEh());
202 
203  sh_fit.rotate_back(R);
204 
205  sh_fit.add(sh.getPosition());
206 
207  out.push_back(getFit(JHistory(shower->getHistory()).add(JSHOWER_BJORKEN_Y), sh_fit, getQuality(chi2),
208  NDF, sh_fit.getE()));
209 
210  out.rbegin()->setW(5, y);
211  out.rbegin()->setW(6, this->value.getEem());
212  out.rbegin()->setW(7, this->value.getEh());
213 
214  }
215 
216  return out;
217  }
218 
222 
223  /*
224  * Function to get the reconstructed Bjorken Y from reconstructed energies.
225  *
226  * \param E_em reconstructed EM shower energy
227  * \param E_h reconstructed Hadronic shower energy
228  */
229  double getFinalBjY(double E_em, double E_h){
230  return E_h / (E_em + E_h);
231  }
232 
233  };
234 }
235 
236 #endif
237 
Auxiliary methods to evaluate Poisson probabilities and chi2.
double VMax_npe
maximum number of of photo-electrons
static int debug
debug level (default is off).
Definition: JMessage.hh:45
Template definition of a data regressor of given model.
Definition: JRegressor.hh:70
double getBjY() const
Get Bjorken Y.
Definition: JTrack3EY.hh:96
Regressor function object for JShowerEH fit using JSimplex minimiser.
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:33
Data structure for a composite optical module.
Definition: JModule.hh:67
double getQuality(const double chi2, const int NDF)
Get quality of fit.
Algorithms for hit clustering and sorting.
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:102
Auxiliary class for handling PMT geometry, rate and response.
Definition: JPMTW0.hh:22
Data structure for vertex fit.
Definition: JPoint4D.hh:22
Detector data structure.
Definition: JDetector.hh:89
Auxiliary class for correction of energy determined by JShowerEnergy.cc.
Router for direct addressing of module data in detector data structure.
Rotation matrix.
Definition: JRotation3D.hh:111
double getRate() const
Get default rate.
then usage $script< input file >[option] nPossible options count
Definition: JVolume1D.sh:31
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
double TMin_ns
minimum time for local coincidences [ns]
const JDAQSummaryFrame & getSummaryFrame() const
Get default summary frame.
3D track with energy and Bjorken Y.
Definition: JTrack3EY.hh:29
Basic data structure for time and time over threshold information of hit.
Data structure for detector geometry and calibration.
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JTrack3D.hh:147
JEvt operator()(const KM3NETDAQ::JDAQEvent &event, const JFIT::JEvt &in)
Declaration of the member function that actually performs the reconstruction.
Basic data structure for L0 hit.
JShowerBjorkenY(const JShowerBjorkenYParameters_t &parameters, const JModuleRouter &router, const JSummaryRouter &summary, const std::string pdfFile, const JShowerEnergyCorrection &correct, const int debug=0)
Parameterized constructor.
double TMax_ns
maximum time for local coincidences [ns]
Auxiliary class to extract a subset of optical modules from a detector.
const JSummaryRouter & summary
Detector file.
Definition: JHead.hh:226
JDirection3D getDirection(const Vec &dir)
Get direction.
double getE() const
Get energy.
Definition: JTrack3E.hh:93
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
set_variable E_E log10(E_{fit}/E_{#mu})"
Data storage class for rate measurements of all PMTs in one module.
static JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
static const int PMT_DISABLE
KM3NeT Data Definitions v3.3.0-2-g5cc95cf https://git.km3net.de/common/km3net-dataformat.
Definition: pmt_status.hh:12
JPosition3D getPosition(const Vec &pos)
Get position.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
Data regression method for JFIT::JShowerEH.
Data time slice.
static double Vmax_npe
Maximal integral of PDF [npe].
static const int JSHOWER_BJORKEN_Y
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:172
void rotate(const JRotation3D &R)
Rotate module.
Definition: JModule.hh:314
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JTrack3D.hh:126
Detector subset without binary search functionality.
Data structure for fit of straight line in positive z-direction with energy.
Definition: JShowerEH.hh:28
Reduced data structure for L1 hit.
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
bool getPMTStatus(const JStatus &status)
Test status of PMT.
JFIT::JHistory JHistory
Definition: JHistory.hh:354
const JClass_t & getReference() const
Get reference to object.
Definition: JReference.hh:38
Data structure for set of track fit results.
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Simple fit method based on Powell&#39;s algorithm, see reference: Numerical Recipes in C++...
double getFinalBjY(double E_em, double E_h)
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
int getCount(const T &hit)
Get hit count.
Data structure for fit of energy.
Definition: JEnergy.hh:28
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:237
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
Definition: JMEstimator.hh:203
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
Template specialisation of class JModel to match hit with bright point.
Definition: JFit/JModel.hh:121
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:39
const JShowerEnergyCorrection & correct
Match operator for Cherenkov light from shower in any direction.
Basic data structure for L1 hit.
int debug
debug level
class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA ...
JRegressor< JShowerEH, JSimplex > JRegressor_t