62 using namespace KM3NETDAQ;
79 JParser<> zap(
"Example program to test chi2 calculations of co-variance matrix including direction uncertainty.");
84 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
96 catch(
const exception& error) {
97 FATAL(error.what() << endl);
101 using namespace KM3NETDAQ;
106 const unsigned int NUMBER_OF_HITS = 6;
107 const double STANDARD_DEVIATIONS = 3.0;
108 const double HIT_OFF = 1.0e3 * sigma_ns*sigma_ns;
129 TH1D h0(
"h0", NULL, 50, 0.0, 20.0);
130 TH1D h1(
"h1", NULL, 50, 0.0, 20.0);
132 TH1D p0(
"p0", NULL, 50, 0.0, 1.0);
133 TH1D
p1(
"p1", NULL, 50, 0.0, 1.0);
140 for ( ; x < 10.0; x += 1.0) {
X.push_back(x); }
141 for ( ; x < 25.0; x += 2.0) {
X.push_back(x); }
142 for ( ; x < 100.0; x += 5.0) {
X.push_back(x); }
145 TProfile n0(
"n0", NULL,
X.size() - 1,
X.data());
146 TProfile n1(
"n1", NULL,
X.size() - 1,
X.data());
154 JHit::setSlewing(!useTrue);
156 while (inputFile.hasNext()) {
158 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
163 const Evt*
event = ps;
169 if (muon != event->mc_trks.end()) {
178 const double theta = alpha_deg *
PI / 180.0;
179 const double phi = gRandom->Uniform(0.0, 2*
PI);
188 buildL2(*tev, moduleRouter, back_inserter(data));
190 data.erase(unique(data.begin(), data.end(), equal_to<JDAQModuleIdentifier>()), data.end());
200 const JPMTAddress& address = pmtRouter.getAddress(i->pmt_id);
202 const JPMT& pmt = pmtRouter.getPMT(address);
203 const double t1 = converter.putTime(
getTime(*i));
211 sort(i->second.begin(), i->second.end(), less<JHit>());
213 data.push_back(i->second[0]);
220 data.erase(
clusterizeWeight(data.begin(), data.end(), match3B), data.end());
225 for (JData_t::iterator i = data.begin(); i != data.end(); ++i) {
229 data.erase(
clusterizeWeight(data.begin(), data.end(), match1D), data.end());
239 for (JData_t::iterator i = data.begin(); i != data.end(); ++i) {
240 i->sub(tz.getPosition());
248 for (JData_t::iterator i = data.begin(); i != data.end(); ++i) {
253 if (data.size() >= NUMBER_OF_HITS + numberOfOutliers) {
255 JData_t::iterator __end = data.end();
257 for (
int n = 0;
n < numberOfOutliers &&
distance(data.begin(), __end) > NUMBER_OF_HITS; ++
n) {
260 JData_t::iterator kill = __end;
262 for (JData_t::iterator i = data.begin(); i != __end; ++i) {
264 const double y = fabs(i->getT() - tz.getT(*i)) / sigma_ns;
272 if (ymax >= STANDARD_DEVIATIONS)
273 iter_swap(kill, --__end);
278 const double chi2 =
getChi2(tz, data.begin(), __end, sigma_ns);
279 const int N =
distance(data.begin(), __end);
282 p0.Fill(TMath::Prob(chi2, N));
283 n0.Fill((
double) data.size(), (double) N / (
double) data.size());
287 if (data.size() >= NUMBER_OF_HITS + numberOfOutliers) {
292 V.
set(tz, data.begin(), data.end(), alpha_deg, sigma_ns);
293 Y.
set(tz, data.begin(), data.end());
297 unsigned int N = data.size();
299 for (
int n = 0; n < numberOfOutliers && N > NUMBER_OF_HITS; ++
n, --
N) {
304 for (
unsigned int i = 0; i != V.
size(); ++i) {
306 const double y =
getChi2(Y, V, i);
314 if (ymax >= STANDARD_DEVIATIONS * STANDARD_DEVIATIONS)
320 const double chi2 = V.
getDot(Y);
323 p1.Fill(TMath::Prob(chi2, N));
324 n1.Fill((
double) data.size(), (double) N / (
double) data.size());
Router for direct addressing of PMT data in detector data structure.
Data structure for angles in three dimensions.
Utility class to parse command line options.
void set(const JVector3D &pos, T __begin, T __end, const double alpha, const double sigma)
Set co-variance matrix.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
static double getDot(const variance &first, const variance &second)
Get dot product.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
Router for direct addressing of module data in detector data structure.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
JVertex3D & add(const JVertex3D &value)
Addition operator.
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
static struct JTRIGGER::@82 clusterizeWeight
Anonymous struct for weighed clustering of hits.
double getTime(const Hit &hit)
Get true time of hit.
void update(const size_t k, const double value)
Update inverted matrix at given diagonal element.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
bool is_noise(const Hit &hit)
Verify hit origin.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
int first
index of module in detector data structure
Auxiliary class for defining the range of iterations of objects.
Determination of the time residual vector of hits for a track along z-axis (JFIT::JLine1Z).
JDirection3D getDirection(const Vec &dir)
Get direction.
Data structure for vector in three dimensions.
Determination of the co-variance matrix of hits for a track along z-axis (JFIT::JLine1Z).
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Data structure for PMT geometry, calibration and status.
JPosition3D getPosition(const Vec &pos)
Get position.
static const double PI
Mathematical constants.
void set(const JLine1Z &track, T __begin, T __end)
Set time residual vector.
then usage $script[distance] fi case set_variable R
void invert()
Invert matrix according LDU decomposition.
size_t size() const
Get dimension of matrix.
Data structure for L2 parameters.
const double getSpeedOfLight()
Get speed of light.
Address of PMT in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for L0 hit.
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
Data structure for fit of straight line paralel to z-axis.
no fit printf nominal n $STRING awk v X
Data structure for position in three dimensions.
const JLimit & getLimit() const
Get limit.
do set_variable DETECTOR_TXT $WORKDIR detector
General purpose class for multiple pointers.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
3D match criterion with road width.
#define DEBUG(A)
Message macros.