104 using namespace KM3NETDAQ;
107 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
109 JParallelFileScanner_t inputFile;
129 JParser<> zap(
"Program to display hit probabilities.");
131 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(1200, 600);
132 zap[
'f'] =
make_field(inputFile,
"input file (output of JXXXMuonReconstruction.sh)");
134 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
143 zap[
'B'] =
make_field(batch,
"batch processing");
148 catch(
const exception& error) {
149 FATAL(error.what() << endl);
153 FATAL(
"Missing output file name " <<
outputFile <<
" in batch mode." << endl);
188 Vec offset(0.0, 0.0, 0.0);
192 }
catch(
const exception& error) {}
197 gROOT->SetBatch(batch);
199 TApplication* tp =
new TApplication(
"user", NULL, NULL);
200 TCanvas* cv =
new TCanvas(
"display",
"", canvas.x, canvas.y);
202 unique_ptr<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
204 gROOT->SetStyle(
"gplot");
207 const size_t NUMBER_OF_PADS = 3;
209 cv->SetFillStyle(4000);
210 cv->SetFillColor(kWhite);
212 TPad*
p1 =
new TPad(
"p1", NULL, 0.0, 0.00, 1.0, 0.95);
213 TPad*
p2 =
new TPad(
"p2", NULL, 0.0, 0.95, 1.0, 1.00);
215 p1->Divide(NUMBER_OF_PADS, 1);
221 const double Rmin = 0.0;
222 const double Rmax = min(
parameters.roadWidth_m, 0.4 * Dmax);
223 const double Tmin = min(
parameters.TMin_ns, -10.0);
224 const double Tmax = max(
parameters.TMax_ns, +100.0);
225 const double Amin = 0.002 * (Tmax - Tmin);
226 const double Amax = 0.8 * (Tmax - Tmin);
227 const double ymin = min(-Amax, Tmin - 0.3 * Amax);
228 const double ymax = max(+Amax, Tmax + 0.5 * Amax);
230 const string Xlabel[NUMBER_OF_PADS] = {
"R [m]",
"#phi [rad]",
"z [m]" };
231 const double Xmin [NUMBER_OF_PADS] = { Rmin, -
PI, -0.5 * Dmax };
232 const double Xmax [NUMBER_OF_PADS] = { Rmax, +
PI, +0.5 * Dmax };
234 double Xs[NUMBER_OF_PADS];
236 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
240 TH2D H2[NUMBER_OF_PADS];
241 TGraph G2[NUMBER_OF_PADS];
243 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
245 H2[
i] = TH2D(
MAKE_CSTRING(
"h" <<
i), NULL, 100, Xmin[
i] - Xs[
i], Xmax[i] + Xs[i], 100, ymin, ymax);
247 H2[
i].GetXaxis()->SetTitle(Xlabel[
i].c_str());
248 H2[
i].GetYaxis()->SetTitle(
"#Deltat [ns]");
250 H2[
i].GetXaxis()->CenterTitle(
true);
251 H2[
i].GetYaxis()->CenterTitle(
true);
253 H2[
i].SetStats(kFALSE);
257 G2[
i].SetPoint(0, H2[
i].GetXaxis()->GetXmin(), 0.0);
258 G2[
i].SetPoint(1, H2[
i].GetXaxis()->GetXmax(), 0.0);
269 cout <<
"event: " << setw(8) << inputFile.getCounter() << endl;
271 multi_pointer_type ps = inputFile.next();
277 if (mc.getEntries() != 0) {
287 if (!event_selector(*tev, *in, event)) {
294 buildL0(*tev, router,
true, back_inserter(dataL0));
296 summary.update(*tev);
304 for (
const auto& t1 : event->mc_trks) {
306 if (t1.E > muon.getE()) {
313 muon =
getFit(0, ta, 0.0, 0, t1.E, 1);
321 bool monte_carlo =
false;
324 for (
bool next =
false; !next; ) {
347 for (JDataL0_t::const_iterator
i = dataL0.begin();
i != dataL0.end(); ++
i) {
349 JHitW0 hit(*
i, summary.getRate(
i->getPMTIdentifier()));
360 sort(data.begin(), data.end(), JHitW0::compare);
362 JDataW0_t::iterator __end = unique(data.begin(), data.end(), equal_to<JDAQPMTIdentifier>());
375 const double z0 = tz.getZ();
376 const double z1 = 0.5 * (zs.getLowerLimit() + zs.getUpperLimit());
388 marker[2].push_back(TMarker(z0 - tz.getZ(), 0.0, kFullCircle));
389 marker[2].push_back(TMarker(z0 - tz.getZ() + fit.getW(
JSTART_LENGTH_METRES), 0.0, kFullCircle));
391 static_cast<TAttMarker&
>(marker[2][0]) = TAttMarker(kRed, kFullCircle, 0.7);
392 static_cast<TAttMarker&
>(marker[2][1]) = TAttMarker(kRed, kFullCircle, 0.7);
396 <<
FIXED(7,2) << tz.getX() <<
' '
397 <<
FIXED(7,2) << tz.getY() <<
' '
398 <<
FIXED(7,2) << tz.getZ() <<
' '
399 <<
FIXED(12,2) << tz.getT() << endl);
403 for (JDataW0_t::const_iterator hit = data.begin(); hit != __end; ++hit) {
405 const double x = hit->getX() - tz.getX();
406 const double y = hit->getY() - tz.getY();
407 const double z = hit->getZ() - tz.getZ();
408 const double R = sqrt(x*x + y*y);
412 JDirection3D dir(hit->getDX(), hit->getDY(), hit->getDZ());
416 const double theta = dir.
getTheta();
417 const double phi = fabs(dir.getPhi());
420 const double E = E_GeV;
421 const double dt = T_ns.constrain(hit->getT() - t1);
432 chi2 += H1.getChi2() - H0.getChi2();
435 << setw(8) << hit->getModuleID() <<
'.' <<
FILL(2,
'0') << (int) hit->getPMTAddress() <<
FILL() <<
' '
437 <<
FIXED(7,2) << R <<
' '
438 <<
FIXED(7,4) << theta <<
' '
439 <<
FIXED(7,4) << phi <<
' '
440 <<
FIXED(7,3) << dt <<
' '
441 <<
FIXED(7,3) << H1.getChi2() <<
' '
442 <<
FIXED(7,3) << H0.getChi2() << endl);
444 const double derivative = H1.getDerivativeOfChi2() - H0.getDerivativeOfChi2();
446 double size = derivative * arrowScale;
448 if (fabs(size) < Amin) {
449 size = (size > 0.0 ? +Amin : -Amin);
450 }
else if (fabs(size) > Amax) {
451 size = (size > 0.0 ? +Amax : -Amax);
454 const double X[NUMBER_OF_PADS] = {
R, atan2(y,x), z - R/
getTanThetaC() };
458 for (
size_t i = 0;
i != NUMBER_OF_PADS; ++
i) {
459 arrow[
i].push_back(TArrow(X[
i] + xs*Xs[
i], dt, X[i] + xs*Xs[i], dt + size, arrowSize, arrowType.c_str()));
465 os <<
" E = " <<
SCIENTIFIC(7,1) << fit.getE() <<
" [GeV]";
466 os <<
" cos(#theta) = " <<
FIXED(6,3) << fit.getDZ();
469 os <<
" Monte Carlo";
470 else if (muon.getStatus() >= 0)
476 TLatex title(0.05, 0.5, os.str().c_str());
478 title.SetTextAlign(12);
479 title.SetTextFont(42);
480 title.SetTextSize(0.6);
486 for (
int i = 0;
i != NUMBER_OF_PADS; ++
i) {
490 for (
auto& a1 : arrow[
i]) {
494 for (
auto& m1 : marker[i]) {
512 static int count = 0;
515 cout << endl <<
"Type '?' for possible options." << endl;
520 cout <<
"\n> " << flush;
526 cout <<
"possible options: " << endl;
527 cout <<
'q' <<
" -> " <<
"exit application" << endl;
528 cout <<
'u' <<
" -> " <<
"update canvas" << endl;
529 cout <<
's' <<
" -> " <<
"save graphics to file" << endl;
530 cout <<
'+' <<
" -> " <<
"next fit" << endl;
531 cout <<
'-' <<
" -> " <<
"previous fit" << endl;
532 cout <<
'M' <<
" -> " <<
"Monte Carlo true muon information" << endl;
533 cout <<
'F' <<
" -> " <<
"fit information" << endl;
534 if (event_selector.is_valid()) {
535 cout <<
'L' <<
" -> " <<
"reload event selector" << endl;
537 cout <<
'r' <<
" -> " <<
"rewind input file" << endl;
538 cout <<
'R' <<
" -> " <<
"switch to ROOT mode (quit ROOT to continue)" << endl;
539 cout <<
' ' <<
" -> " <<
"next event (as well as any other key)" << endl;
556 index = (index != in->size() - 1 ? index + 1 : 0);
562 index = (index != 0 ? index - 1 : in->size() - 1);
567 if (muon.getStatus() >= 0)
570 ERROR(endl <<
"No Monte Carlo muon available." << endl);
580 if (event_selector.is_valid()) {
581 execute(
MAKE_STRING(
"make -f " <<
getPath(argv[0]) <<
"/JMakeEventSelector libs"), 3);
582 event_selector.reload();
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
Vec getOffset(const JHead &header)
Get offset.
double getQuality(const double chi2, const int NDF)
Get quality of fit.
JTrack3E getTrack(const Trk &track)
Get track.
Template specialisation of L0 builder for JHitL0 data type.
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.
Router for direct addressing of module data in detector data structure.
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
General purpose class for parallel reading of objects from a single file or multiple files...
#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.
int getRunNumber() const
Get run number.
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
#define MAKE_STRING(A)
Make string.
int getFrameIndex() const
Get frame index.
JTime & add(const JTime &value)
Addition operator.
static const char WILDCARD
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
The Vec class is a straightforward 3-d vector, which also works in pyroot.
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.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Auxiliary class to test history.
static const int JMUONGANDALF
double getTheta() const
Get theta angle.
JPosition3D getPosition(const Vec &pos)
Get position.
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.
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.
const double getSpeedOfLight()
Get speed of light.
static const int JSTART_LENGTH_METRES
distance between first and last hits in metres from JStart.cc
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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
const double getInverseSpeedOfLight()
Get inverse speed of light.
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.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
no fit printf nominal n $STRING awk v X
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
const JLimit & getLimit() const
Get limit.
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Auxiliary data structure for floating point format specification.
JTriggerCounter_t getCounter() const
Get trigger counter.
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.