198 using namespace KM3NETDAQ;
210 double arrowSize = 0.003;
211 string arrowType =
"|->";
212 double arrowScale = 250.0;
213 Width_t lineWidth = 2;
214 Style_t lineStyle = 1;
236 JParser<> zap(
"Program to display hit probabilities.");
238 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(1200, 600);
239 zap[
'f'] =
make_field(inputFile,
"input file (output of JXXXMuonReconstruction.sh)");
240 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
247 zap[
'O'] =
make_field(option,
"draw option") = arrow_t, histogram_t;
248 zap[
'B'] =
make_field(batch,
"batch processing");
253 catch(
const exception& error) {
254 FATAL(error.what() << endl);
258 FATAL(
"Missing output file name " <<
outputFile <<
" in batch mode." << endl);
269 JHit::setSlewing(
false);
283 gROOT->SetBatch(batch);
285 TApplication* tp =
new TApplication(
"user", NULL, NULL);
286 TCanvas* cv =
new TCanvas(
"display",
"", canvas.x, canvas.y);
288 unique_ptr<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh(), graphics));
290 gROOT->SetStyle(
"gplot");
293 const size_t NUMBER_OF_PADS = 3;
295 cv->SetFillStyle(4000);
296 cv->SetFillColor(kWhite);
298 TPad*
p1 =
new TPad(
"p1", NULL, 0.0, 0.00, 1.0, 0.95);
299 TPad*
p2 =
new TPad(
"p2", NULL, 0.0, 0.95, 1.0, 1.00);
301 p1->Divide(NUMBER_OF_PADS, 1);
306 const double Dmax = 1000.0;
307 const double Rmin = 0.0;
308 const double Rmax = min(
parameters.roadWidth_m, 0.4 * Dmax);
309 const double Tmin = min(
parameters.TMin_ns, -10.0);
310 const double Tmax = max(
parameters.TMax_ns, +100.0);
311 const double Amin = 0.002 * (Tmax - Tmin);
312 const double Amax = 0.8 * (Tmax - Tmin);
313 const double ymin = Tmin - (option == arrow_t ? 0.2 * Amax : 0.0);
314 const double ymax = Tmax + (option == arrow_t ? 0.5 * Amax : 0.0);
316 const string Xlabel[NUMBER_OF_PADS] = {
"R [m]",
"#phi [rad]",
"z [m]" };
317 const double Xmin [NUMBER_OF_PADS] = { Rmin, -
PI, -0.3 * Dmax };
318 const double Xmax [NUMBER_OF_PADS] = { Rmax, +
PI, +0.3 * Dmax };
320 double Xs[NUMBER_OF_PADS];
322 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
326 TH2D H2[NUMBER_OF_PADS];
327 TGraph G2[NUMBER_OF_PADS];
329 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
331 H2[
i] = TH2D(
MAKE_CSTRING(
"h" <<
i), NULL, graphics.nbinsX, Xmin[
i] - Xs[
i], Xmax[i] + Xs[i], graphics.nbinsY, ymin, ymax);
333 H2[
i].GetXaxis()->SetTitle(Xlabel[
i].c_str());
334 H2[
i].GetYaxis()->SetTitle(
"#Deltat [ns]");
336 H2[
i].GetXaxis()->CenterTitle(
true);
337 H2[
i].GetYaxis()->CenterTitle(
true);
339 H2[
i].SetStats(kFALSE);
343 G2[
i].SetPoint(0, H2[
i].GetXaxis()->GetXmin(), 0.0);
344 G2[
i].SetPoint(1, H2[
i].GetXaxis()->GetXmax(), 0.0);
353 while (inputFile.hasNext()) {
355 cout <<
"event: " << setw(8) << inputFile.getCounter() << endl;
357 const Evt* evt = inputFile.next();
359 if (has_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt,
rec_stages_range(application))) {
361 Trk fit = get_best_reconstructed_track<JPP_RECONSTRUCTION_TYPE>(*evt,
rec_stages_range(application));
363 if (!event_selector(fit, *evt)) {
369 for (
const Hit& hit : evt->hits) {
386 for (
const auto& trk : evt->mc_trks) {
388 if (trk.E > muon.
E) {
400 bool monte_carlo =
false;
402 for (
bool next =
false; !next; ) {
404 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
429 for (JDataL0_t::const_iterator
i = dataL0.begin();
i != dataL0.end(); ++
i) {
431 JHitW0 hit(*
i, summary.getRate(
i->getPMTIdentifier()));
442 sort(data.begin(), data.end(), JHitW0::compare);
444 JDataW0_t::iterator __end = unique(data.begin(), data.end(), equal_to<JDAQPMTIdentifier>());
457 for (JDataW0_t::iterator hit = data.begin(); hit != __end; ++hit) {
459 const double x = hit->getX() - tz.getX();
460 const double y = hit->getY() - tz.getY();
461 const double z = hit->getZ();
462 const double R = sqrt(x*x + y*y);
467 const double z0 = tz.getZ();
481 marker[2].push_back(TMarker(z0 - tz.getZ(), 0.0, kFullCircle));
484 static_cast<TAttMarker&
>(marker[2][0]) = TAttMarker(kRed, kFullCircle, 0.7);
485 static_cast<TAttMarker&
>(marker[2][1]) = TAttMarker(kRed, kFullCircle, 0.7);
489 <<
FIXED(7,2) << tz.getX() <<
' '
490 <<
FIXED(7,2) << tz.getY() <<
' '
491 <<
FIXED(7,2) << tz.getZ() <<
' '
492 <<
FIXED(12,2) << tz.getT() << endl);
496 for (JDataW0_t::const_iterator hit = data.begin(); hit != __end; ++hit) {
498 const double x = hit->getX() - tz.getX();
499 const double y = hit->getY() - tz.getY();
500 const double z = hit->getZ() - tz.getZ();
501 const double R = sqrt(x*x + y*y);
505 JDirection3D dir(hit->getDX(), hit->getDY(), hit->getDZ());
509 const double theta = dir.
getTheta();
510 const double phi = fabs(dir.getPhi());
513 const double E = E_GeV;
514 const double dt = T_ns.constrain(hit->getT() - t1);
525 chi2 += H1.getChi2() - H0.getChi2();
528 << setw(8) << hit->getModuleID() <<
'.' <<
FILL(2,
'0') << (int) hit->getPMTAddress() <<
FILL() <<
' '
530 <<
FIXED(7,2) << R <<
' '
531 <<
FIXED(7,4) << theta <<
' '
532 <<
FIXED(7,4) << phi <<
' '
533 <<
FIXED(7,3) << dt <<
' '
534 <<
FIXED(7,3) << H1.getChi2() <<
' '
535 <<
FIXED(7,3) << H0.getChi2() << endl);
537 const double derivative = H1.getDerivativeOfChi2() - H0.getDerivativeOfChi2();
539 double size = derivative * graphics.arrowScale;
541 if (fabs(size) < Amin) {
542 size = (size > 0.0 ? +Amin : -Amin);
543 }
else if (fabs(size) > Amax) {
544 size = (size > 0.0 ? +Amax : -Amax);
547 const double X[NUMBER_OF_PADS] = {
R, atan2(y,x), z - R/
getTanThetaC() };
551 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
553 TArrow a1(X[
i] + xs*Xs[
i], dt + graphics.T_ns, X[i] + xs*Xs[i], dt + graphics.T_ns + size, graphics.arrowSize, graphics.arrowType.c_str());
555 a1.SetLineWidth(graphics.lineWidth);
556 a1.SetLineStyle(graphics.lineStyle);
558 arrow[
i].push_back(a1);
560 H2[
i].Fill(X[i], dt + graphics.T_ns);
564 os <<
FILL(6,
'0') << evt->run_id <<
":" << evt->frame_index <<
"/" << evt->trigger_counter <<
FILL();
565 os <<
" Q = " <<
FIXED(4,0) << trk.
lik;
566 os <<
" E = " <<
SCIENTIFIC(7,1) << trk.
E <<
" [GeV]";
567 os <<
" cos(#theta) = " <<
FIXED(6,3) << trk.
dir.
z;
570 os <<
" Monte Carlo";
577 TLatex title(0.05, 0.5, os.str().c_str());
579 title.SetTextAlign(12);
580 title.SetTextFont(42);
581 title.SetTextSize(0.6);
587 for (
int i = 0; i != NUMBER_OF_PADS; ++
i) {
591 if (option == arrow_t) {
593 for (
auto& a1 : arrow[i]) {
597 for (
auto& m1 : marker[i]) {
602 if (option == histogram_t) {
620 static int count = 0;
623 cout << endl <<
"Type '?' for possible options." << endl;
628 cout <<
"\n> " << flush;
634 cout <<
"possible options: " << endl;
635 cout <<
'q' <<
" -> " <<
"exit application" << endl;
636 cout <<
'u' <<
" -> " <<
"update canvas" << endl;
637 cout <<
's' <<
" -> " <<
"save graphics to file" << endl;
638 cout <<
'M' <<
" -> " <<
"Monte Carlo true muon information" << endl;
639 cout <<
'F' <<
" -> " <<
"fit information" << endl;
640 if (event_selector.is_valid()) {
641 cout <<
'L' <<
" -> " <<
"reload event selector" << endl;
643 cout <<
'r' <<
" -> " <<
"rewind input file" << endl;
644 cout <<
'R' <<
" -> " <<
"switch to ROOT mode (quit ROOT to continue)" << endl;
645 cout <<
'p' <<
" -> " <<
"print event information" << endl;
646 cout <<
' ' <<
" -> " <<
"next event (as well as any other key)" << endl;
665 ERROR(endl <<
"No Monte Carlo muon available." << endl);
675 if (event_selector.is_valid()) {
676 execute(
MAKE_STRING(
"make -f " <<
getPath(argv[0]) <<
"/JMakeEventSelector libs"), 3);
677 event_selector.reload();
689 for (
const auto& trk : evt->mc_trks) {
690 cout <<
"MC "; trk.
print(cout); cout << endl;
692 for (
const auto& trk : evt->trks) {
693 cout <<
"fit "; trk.
print(cout); cout << endl;
695 for (
const auto& hit : evt->hits) {
696 cout <<
"hit "; hit.
print(cout); cout << endl;
static const int JMUONSTART
Utility class to parse command line options.
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
TString replace(const TString &target, const TRegexp ®exp, const T &replacement)
Replace regular expression in input by given replacement.
Data structure for direction in three dimensions.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
double t
track time [ns] (when the particle is at pos )
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
then wget no check certificate user
std::string getPath(const std::string &file_name)
Get path, i.e. part before last JEEP::PATHNAME_SEPARATOR if any.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
void setW(Trk &trk, const int i, const double value)
Set associated value.
Utility class to parse parameter values.
then usage $script< input file >[option] nPossible options count
*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
#define MAKE_CSTRING(A)
Make C-string.
Template specialisation of class JModel to match hit with muon trajectory along z-axis.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
Auxiliary data structure for floating point format specification.
Data structure for UTC time.
double E
Energy [GeV] (either MC truth or reconstructed)
Range of reconstruction stages.
#define MAKE_STRING(A)
Make string.
void print(std::ostream &out=std::cout) const
Print hit.
static const char WILDCARD
double getW(const Trk &track, const size_t index, const double value)
Get track information.
Auxiliary class for defining the range of iterations of objects.
static const int JMUONPREFIT
char get()
Get single character.
JDirection3D getDirection(const Vec &dir)
Get direction.
JFunction1D_t::result_type result_type
JDirection3D & rotate(const JRotation3D &R)
Rotate.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Enable unbuffered terminal input.
static const int JMUONGANDALF
double getTheta() const
Get theta angle.
JPosition3D getPosition(const Vec &pos)
Get position.
double len
length, if applicable [m]
double putTime() const
Get Monte Carlo time minus DAQ/trigger time.
static const double PI
Mathematical constants.
File router for fast addressing of summary data.
Vec dir
hit direction; i.e. direction of the PMT
Data structure for fit parameters.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for muon PDF.
then JCookie sh JDataQuality D $DETECTOR_ID R
Auxiliary class for a hit with background rate value.
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
const double getSpeedOfLight()
Get speed of light.
static const int JSTART_LENGTH_METRES
distance between first and last hits in metres from JStart.cc
bool has_muon(const Evt &evt)
Test whether given event has a muon.
static const int JMUONSIMPLEX
double lik
likelihood or lambda value (for aafit, lambda)
double t
hit time (from tdc+calibration or MC truth)
Data structure for L0 hit.
const double getInverseSpeedOfLight()
Get inverse speed of light.
int dom_id
module identifier from the data (unique in the detector).
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.
unsigned int tot
tot value as stored in raw data (int for pyroot)
no fit printf nominal n $STRING awk v X
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
unsigned int channel_id
PMT channel id {0,1, .., 30} local to moduke.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
void print(std::ostream &out=std::cout) const
Print track.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Auxiliary data structure for floating point format specification.
Wrapper class around ROOT TStyle.
static const int JMUONENERGY
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Data structure for size of TCanvas.
#define DEBUG(A)
Message macros.
bool hasW(const Trk &trk, const int i)
Check availability of value.