22 #include <ktracker/SRecEvent.h>
48 #include <boost/lexical_cast.hpp>
51 #define LogDebug(exp) std::cout<<"DEBUG: " <<__FILE__<<": "<<__LINE__<<": "<< exp << std::endl
52 #define LogError(exp) std::cout<<"ERROR: " <<__FILE__<<": "<<__LINE__<<": "<< exp << std::endl
53 #define LogWarning(exp) std::cout<<"WARNING: "<<__FILE__<<": "<<__LINE__<<": "<< exp << std::endl
59 _hit_container_type(
"Vector"),
63 _event_header(nullptr),
66 _out_name(
"eval.root")
82 int ret = GetNodes(topNode);
94 ret = TruthRecoEval(topNode);
117 pid[n_tracks] = par->
get_pid();
121 gvx[n_tracks] = vtx->
get_x();
122 gvy[n_tracks] = vtx->
get_y();
123 gvz[n_tracks] = vtx->
get_z();
126 gpx[n_tracks] = par->
get_px();
127 gpy[n_tracks] = par->
get_py();
128 gpz[n_tracks] = par->
get_pz();
129 gpt[n_tracks] = mom_truth.Pt();
130 geta[n_tracks] = mom_truth.Eta();
131 gphi[n_tracks] = mom_truth.Phi();
136 TLorentzVector g_mom_st1;
137 bool st1hit = FindG4HitAtStation(trk_id, g4hc_d1x, &g_pos_st1, &g_mom_st1);
140 gx_st1[n_tracks] = g_pos_st1.X();
141 gy_st1[n_tracks] = g_pos_st1.Y();
142 gz_st1[n_tracks] = g_pos_st1.Z();
144 gpx_st1[n_tracks] = g_mom_st1.Px();
145 gpy_st1[n_tracks] = g_mom_st1.Py();
146 gpz_st1[n_tracks] = g_mom_st1.Pz();
150 TLorentzVector g_mom_st2;
151 bool st2hit = FindG4HitAtStation(trk_id, g4hc_d2xp, &g_pos_st2, &g_mom_st2);
154 TLorentzVector g_mom_st3;
156 bool st3hit = FindG4HitAtStation(trk_id, g4hc_d3px, &g_pos_st3, &g_mom_st3)|| FindG4HitAtStation(trk_id, g4hc_d3mx, &g_pos_st3, &g_mom_st3);
158 bool prophit = (FindG4HitAtProp(trk_id,g4hc_p1x1)||FindG4HitAtProp(trk_id,g4hc_p1x2)||FindG4HitAtProp(trk_id,g4hc_p1y1)||FindG4HitAtProp(trk_id,g4hc_p1y2)) && (FindG4HitAtProp(trk_id,g4hc_p2x1)||FindG4HitAtProp(trk_id,g4hc_p2x2)||FindG4HitAtProp(trk_id,g4hc_p2y1)||FindG4HitAtProp(trk_id,g4hc_p2y2));
161 if(st1hit && st2hit && st3hit && prophit){
162 ac_gpx[n_tracks] = gpx[n_tracks];
163 ac_gpy[n_tracks] = gpy[n_tracks];
164 ac_gpz[n_tracks] = gpz[n_tracks];
175 vector<int> sqhit_idvec;
176 map<int, vector<int> > rtrkid_hitidvec;
179 for(
int ihit=0; ihit<_hit_vector->
size(); ++ihit) {
180 SQHit *sqhit = _hit_vector->
at(ihit);
182 if(sq_detid >
nChamberPlanes || (sq_detid >= 7 && sq_detid <= 12))
continue;
188 sort(sqhit_idvec.begin(), sqhit_idvec.end());
192 for(
int i = 0; i < n_recTracks; ++i) {
194 rtrkid_hitidvec[i] = vector<int>();
197 for(
int j = 0; j < n_rhits; ++j) {
198 rtrkid_hitidvec[i].push_back(fabs(recTrack->
getHitIndex(j)));
202 sort(rtrkid_hitidvec[i].begin(), rtrkid_hitidvec[i].end());
207 double m_matching_threshold = 0.75;
209 unsigned int n_match = 0;
211 for(
auto it = rtrkid_hitidvec.begin(); it != rtrkid_hitidvec.end(); ++it) {
212 int n_match_new = FindCommonHitIDs(sqhit_idvec, it->second);
213 if(n_match < n_match_new) {
214 n_match = n_match_new;
219 if(rtrkid >= 0 &&
double(n_match)/
double(sqhit_idvec.size()) > m_matching_threshold) {
220 Best_recTrack = &_recEvent->
getTrack(rtrkid);
229 nhits[n_tracks] = Best_recTrack->
getNHits();
230 charge[n_tracks] = Best_recTrack->
getCharge();
234 rec_vx[n_tracks] = rec_vtx.X();
235 rec_vy[n_tracks] = rec_vtx.Y();
236 rec_vz[n_tracks] = rec_vtx.Z();
238 rec_px[n_tracks] = rec_mom.Px();
239 rec_py[n_tracks] = rec_mom.Py();
240 rec_pz[n_tracks] = rec_mom.Pz();
241 rec_pt[n_tracks] = rec_mom.Pt();
242 rec_eta[n_tracks] = rec_mom.Eta();
243 rec_phi[n_tracks] = rec_mom.Phi();
249 chisq_st1[n_tracks] = Best_recTrack->
getChisq();
250 prob_st1[n_tracks] = Best_recTrack->
getProb();
251 quality[n_tracks] = Best_recTrack->
getQuality();
275 for(
int ihit=0; ihit<_hit_vector->
size(); ++ihit) {
276 SQHit *hit = _hit_vector->
at(ihit);
279 if(detid >
nChamberPlanes || (detid >= 7 && detid <= 12))
continue;
291 sq_pos_st1[n_tracks]=hit->
get_pos();
299 double z_rec_st1 = Best_recTrack->
getZ(rec_index_st1);
301 if(fabs(sq_z_st1- z_rec_st1>1.))
continue;
303 double p_rec_st1 = fabs(1./Best_recTrack->
getStateVector(rec_index_st1)[0][0]);
304 double tx_rec_st1 = Best_recTrack->
getStateVector(rec_index_st1)[1][0];
305 double ty_rec_st1 = Best_recTrack->
getStateVector(rec_index_st1)[2][0];
306 double x_rec_st1 = Best_recTrack->
getStateVector(rec_index_st1)[3][0];
307 double y_rec_st1 = Best_recTrack->
getStateVector(rec_index_st1)[4][0];
309 double x0_st1 = x_rec_st1 - tx_rec_st1 *z_rec_st1;
310 double y0_st1 = y_rec_st1 - ty_rec_st1 *z_rec_st1;
312 rec_p_st1[n_tracks] = p_rec_st1;
313 rec_pz_st1[n_tracks] = p_rec_st1/sqrt(1.+tx_rec_st1*tx_rec_st1+ty_rec_st1*ty_rec_st1);
314 rec_px_st1[n_tracks] = rec_pz_st1[n_tracks]* tx_rec_st1;
315 rec_py_st1[n_tracks] = rec_pz_st1[n_tracks]* ty_rec_st1;
317 rec_x_st1[n_tracks] = x_rec_st1;
318 rec_y_st1[n_tracks] = y_rec_st1;
319 rec_z_st1[n_tracks] = z_rec_st1;
323 double cov00_st1 = Best_recTrack->
getCovariance(rec_index_st1)[0][0];
324 double sq_mom_st1 = sqrt(sq_px_st1[n_tracks]*sq_px_st1[n_tracks]+sq_py_st1[n_tracks]*sq_py_st1[n_tracks]+sq_pz_st1[n_tracks]*sq_pz_st1[n_tracks]);
325 pull_q2p_st1[n_tracks] = (fabs(Best_recTrack->
getStateVector(rec_index_st1)[0][0]) - 1./sq_mom_st1)/sqrt(cov00_st1);
344 sq_pos_st2[n_tracks]=hit->
get_pos();
352 double rec_z = Best_recTrack->
getZ(rec_index);
354 if(fabs(sq_z- rec_z>1.))
continue;
356 double p_rec = fabs(1./Best_recTrack->
getStateVector(rec_index)[0][0]);
362 double x0 = x_rec - tx_rec *rec_z;
363 double y0 = y_rec - ty_rec *rec_z;
365 rec_p_st2[n_tracks] = p_rec;
366 rec_pz_st2[n_tracks] = p_rec/sqrt(1.+tx_rec*tx_rec+ty_rec*ty_rec);
367 rec_px_st2[n_tracks] = rec_pz_st2[n_tracks]* tx_rec;
368 rec_py_st2 [n_tracks]= rec_pz_st2[n_tracks]* ty_rec;
371 rec_x_st2[n_tracks] = x_rec;
372 rec_y_st2[n_tracks] = y_rec;
373 rec_z_st2[n_tracks] = rec_z;
378 double cov00_st2 = Best_recTrack->
getCovariance(rec_index)[0][0];
379 double sq_mom_st2 = sqrt(sq_px_st2[n_tracks]*sq_px_st2[n_tracks]+sq_py_st2[n_tracks]*sq_py_st2[n_tracks]+sq_pz_st2[n_tracks]*sq_pz_st2[n_tracks]);
380 pull_q2p_st2[n_tracks] = (fabs(Best_recTrack->
getStateVector(rec_index)[0][0]) - 1./sq_mom_st2)/sqrt(cov00_st2);
398 sq_pos_st3[n_tracks]=hit->
get_pos();
406 double rec_z = Best_recTrack->
getZ(rec_index);
408 if(fabs(sq_z- rec_z>1.))
continue;
410 double p_rec = fabs(1./Best_recTrack->
getStateVector(rec_index)[0][0]);
416 double x0 = x_rec - tx_rec *rec_z;
417 double y0 = y_rec - ty_rec *rec_z;
419 rec_p_st3[n_tracks] = p_rec;
420 rec_pz_st3[n_tracks] = p_rec/sqrt(1.+tx_rec*tx_rec+ty_rec*ty_rec);
421 rec_px_st3[n_tracks] = rec_pz_st3[n_tracks]* tx_rec;
422 rec_py_st3[n_tracks] = rec_pz_st3[n_tracks]* ty_rec;
424 rec_x_st3[n_tracks] = x_rec;
425 rec_y_st3[n_tracks] = y_rec;
426 rec_z_st3[n_tracks] = rec_z;
430 double cov00_st3 = Best_recTrack->
getCovariance(rec_index)[0][0];
431 double sq_mom_st3 = sqrt(sq_px_st3[n_tracks]*sq_px_st3[n_tracks]+sq_py_st3[n_tracks]*sq_py_st3[n_tracks]+sq_pz_st3[n_tracks]*sq_pz_st3[n_tracks]);
432 pull_q2p_st3[n_tracks] = (fabs(Best_recTrack->
getStateVector(rec_index)[0][0]) - 1./sq_mom_st3)/sqrt(cov00_st3);
448 if(n_tracks>=100)
break;
464 std::cout <<
"AnaTrkQA::End" << std::endl;
477 _qa_tree =
new TTree(
"QA_ana",
"QA analsysis of reconstruction and simulation");
479 _qa_tree->Branch(
"n_tracks", &n_tracks,
"n_tracks/I");
480 _qa_tree->Branch(
"n_recTracks", &n_recTracks,
"n_recTracks/I");
483 _qa_tree->Branch(
"pid", pid,
"pid[n_tracks]/I");
484 _qa_tree->Branch(
"gvx", gvx,
"gvx[n_tracks]/F");
485 _qa_tree->Branch(
"gvy", gvy,
"gvy[n_tracks]/F");
486 _qa_tree->Branch(
"gvz", gvz,
"gvz[n_tracks]/F");
487 _qa_tree->Branch(
"gpx", gpx,
"gpx[n_tracks]/F");
488 _qa_tree->Branch(
"gpy", gpy,
"gpy[n_tracks]/F");
489 _qa_tree->Branch(
"gpz", gpz,
"gpz[n_tracks]/F");
490 _qa_tree->Branch(
"gpt", gpt,
"gpt[n_tracks]/F");
491 _qa_tree->Branch(
"geta", geta,
"geta[n_tracks]/F");
492 _qa_tree->Branch(
"gphi", gphi,
"gphi[n_tracks]/F");
502 _qa_tree->Branch(
"ac_gpx", ac_gpx,
"ac_gpx[n_tracks]/F");
503 _qa_tree->Branch(
"ac_gpy", ac_gpy,
"ac_gpy[n_tracks]/F");
504 _qa_tree->Branch(
"ac_gpz", ac_gpz,
"ac_gpz[n_tracks]/F");
508 _qa_tree->Branch(
"rec_vx", rec_vx,
"rec_vx[n_tracks]/F");
509 _qa_tree->Branch(
"rec_vy", rec_vy,
"rec_vy[n_tracks]/F");
510 _qa_tree->Branch(
"rec_vz", rec_vz,
"rec_vz[n_tracks]/F");
511 _qa_tree->Branch(
"rec_px", rec_px,
"rec_px[n_tracks]/F");
512 _qa_tree->Branch(
"rec_py", rec_py,
"rec_py[n_tracks]/F");
513 _qa_tree->Branch(
"rec_pz", rec_pz,
"rec_pz[n_tracks]/F");
514 _qa_tree->Branch(
"rec_pt", rec_pt,
"rec_pt[n_tracks]/F");
515 _qa_tree->Branch(
"rec_eta", rec_eta,
"rec_eta[n_tracks]/F");
516 _qa_tree->Branch(
"rec_phi", rec_phi,
"rec_phi[n_tracks]/F");
520 _qa_tree->Branch(
"sq_pos_st1", sq_pos_st1,
"sq_pos_st1[n_tracks]/F");
521 _qa_tree->Branch(
"sq_drift_st1", sq_drift_st1,
"sq_drift_st1[n_tracks]/F");
522 _qa_tree->Branch(
"sq_x_st1", sq_x_st1,
"sq_x_st1[n_tracks]/F");
523 _qa_tree->Branch(
"sq_y_st1", sq_y_st1,
"sq_y_st1[n_tracks]/F");
524 _qa_tree->Branch(
"sq_z_st1", sq_z_st1,
"sq_z_st1[n_tracks]/F");
525 _qa_tree->Branch(
"sq_px_st1", sq_px_st1,
"sq_px_st1[n_tracks]/F");
526 _qa_tree->Branch(
"sq_py_st1", sq_py_st1,
"sq_py_st1[n_tracks]/F");
527 _qa_tree->Branch(
"sq_pz_st1", sq_pz_st1,
"sq_pz_st1[n_tracks]/F");
529 _qa_tree->Branch(
"rec_drift_st1", rec_drift_st1,
"rec_drift_st1[n_tracks]/F");
530 _qa_tree->Branch(
"rec_px_st1", rec_px_st1,
"rec_px_st1[n_tracks]/F");
531 _qa_tree->Branch(
"rec_py_st1", rec_py_st1,
"rec_py_st1[n_tracks]/F");
532 _qa_tree->Branch(
"rec_pz_st1", rec_pz_st1,
"rec_pz_st1[n_tracks]/F");
533 _qa_tree->Branch(
"rec_x_st1", rec_x_st1,
"rec_x_st1[n_tracks]/F");
534 _qa_tree->Branch(
"rec_y_st1", rec_y_st1,
"rec_y_st1[n_tracks]/F");
535 _qa_tree->Branch(
"rec_z_st1", rec_z_st1,
"rec_z_st1[n_tracks]/F");
539 _qa_tree->Branch(
"sq_pos_st2", sq_pos_st2,
"sq_pos_st2[n_tracks]/F");
540 _qa_tree->Branch(
"sq_drift_st2", sq_drift_st2,
"sq_drift_st2[n_tracks]/F");
541 _qa_tree->Branch(
"sq_x_st2", sq_x_st2,
"sq_x_st2[n_tracks]/F");
542 _qa_tree->Branch(
"sq_y_st2", sq_y_st2,
"sq_y_st2[n_tracks]/F");
543 _qa_tree->Branch(
"sq_z_st2", sq_z_st2,
"sq_z_st2/[n_tracks]F");
544 _qa_tree->Branch(
"sq_px_st2", sq_px_st2,
"sq_px_st2[n_tracks]/F");
545 _qa_tree->Branch(
"sq_py_st2", sq_py_st2,
"sq_py_st2[n_tracks]/F");
546 _qa_tree->Branch(
"sq_pz_st2", sq_pz_st2,
"sq_pz_st2[n_tracks]/F");
548 _qa_tree->Branch(
"rec_drift_st2", rec_drift_st2,
"rec_drift_st2[n_tracks]/F");
549 _qa_tree->Branch(
"rec_px_st2", rec_px_st2,
"rec_px_st2[n_tracks]/F");
550 _qa_tree->Branch(
"rec_py_st2", rec_py_st2,
"rec_py_st2[n_tracks]/F");
551 _qa_tree->Branch(
"rec_pz_st2", rec_pz_st2,
"rec_pz_st2[n_tracks]/F");
552 _qa_tree->Branch(
"rec_x_st2", rec_x_st2,
"rec_x_st2[n_tracks]/F");
553 _qa_tree->Branch(
"rec_y_st2", rec_y_st2,
"rec_y_st2[n_tracks]/F");
554 _qa_tree->Branch(
"rec_z_st2", rec_z_st2,
"rec_z_st2[n_tracks]/F");
558 _qa_tree->Branch(
"sq_pos_st3", sq_pos_st3,
"sq_pos_st3[n_tracks]/F");
559 _qa_tree->Branch(
"sq_drift_st3", sq_drift_st3,
"sq_drift_st3[n_tracks]/F");
560 _qa_tree->Branch(
"sq_x_st3", sq_x_st3,
"sq_x_st3[n_tracks]/F");
561 _qa_tree->Branch(
"sq_y_st3", sq_y_st3,
"sq_y_st3[n_tracks]/F");
562 _qa_tree->Branch(
"sq_z_st3", sq_z_st3,
"sq_z_st3[n_tracks]/F");
563 _qa_tree->Branch(
"sq_px_st3", sq_px_st3,
"sq_px_st3[n_tracks]/F");
564 _qa_tree->Branch(
"sq_py_st3", sq_py_st3,
"sq_py_st3[n_tracks]/F");
565 _qa_tree->Branch(
"sq_pz_st3", sq_pz_st3,
"sq_pz_st3[n_tracks]/F");
567 _qa_tree->Branch(
"rec_drift_st3", rec_drift_st3,
"rec_drift_st3[n_tracks]/F");
568 _qa_tree->Branch(
"rec_px_st3", rec_px_st3,
"rec_px_st3[n_tracks]/F");
569 _qa_tree->Branch(
"rec_py_st3", rec_py_st3,
"rec_py_st3[n_tracks]/F");
570 _qa_tree->Branch(
"rec_pz_st3", rec_pz_st3,
"rec_pz_st3[n_tracks]/F");
571 _qa_tree->Branch(
"rec_x_st3", rec_x_st3,
"rec_x_st3[n_tracks]/F");
572 _qa_tree->Branch(
"rec_y_st3", rec_y_st3,
"rec_y_st3[n_tracks]/F");
573 _qa_tree->Branch(
"rec_z_st3", rec_z_st3,
"rec_z_st3[n_tracks]/F");
577 _qa_tree->Branch(
"pull_q2p_st1", pull_q2p_st1,
"pull_q2p_st1[n_tracks]/F");
578 _qa_tree->Branch(
"pull_q2p_st2", pull_q2p_st2,
"pull_q2p_st2[n_tracks]/F");
579 _qa_tree->Branch(
"pull_q2p_st3", pull_q2p_st3,
"pull_q2p_st3[n_tracks]/F");
581 _qa_tree->Branch(
"chisq_st1", chisq_st1,
"chisq_st1[n_tracks]/F");
582 _qa_tree->Branch(
"prob_st1", prob_st1,
"prob_st1[n_tracks]/F");
583 _qa_tree->Branch(
"quality", quality,
"quality[n_tracks]/F");
585 _qa_tree->Branch(
"nhits", nhits,
"nhits[n_tracks]/I");
586 _qa_tree->Branch(
"nhits_st1", nhits_st1,
"nhits_st1[n_tracks]/I");
587 _qa_tree->Branch(
"nhits_st2", nhits_st2,
"nhits_st2[n_tracks]/I");
588 _qa_tree->Branch(
"nhits_st3", nhits_st3,
"nhits_st3[n_tracks]/I");
589 _qa_tree->Branch(
"charge", charge,
"charge[n_tracks]/I");
599 run_id = std::numeric_limits<int>::max();
600 spill_id = std::numeric_limits<int>::max();
601 target_pos = std::numeric_limits<float>::max();
602 event_id = std::numeric_limits<int>::max();
604 krecstat = std::numeric_limits<int>::max();
607 for(
int i=0; i<100; ++i) {
608 detector_id[i] = std::numeric_limits<short>::max();
609 element_id[i] = std::numeric_limits<short>::max();
610 hodo_mask[i] = std::numeric_limits<short>::max();
611 drift_distance[i] = std::numeric_limits<float>::max();
612 pos[i] = std::numeric_limits<float>::max();
613 detector_z[i] = std::numeric_limits<float>::max();
615 truth_x[i] = std::numeric_limits<float>::max();
616 truth_y[i] = std::numeric_limits<float>::max();
617 truth_z[i] = std::numeric_limits<float>::max();
618 truth_pos[i] = std::numeric_limits<float>::max();
623 for(
int i=0; i<100; ++i) {
624 rec_id[i] = std::numeric_limits<int>::max();
625 par_id[i] = std::numeric_limits<int>::max();
626 pid[i] = std::numeric_limits<int>::max();
627 gvx[i] = std::numeric_limits<float>::max();
628 gvy[i] = std::numeric_limits<float>::max();
629 gvz[i] = std::numeric_limits<float>::max();
630 gpx[i] = std::numeric_limits<float>::max();
631 gpy[i] = std::numeric_limits<float>::max();
632 gpz[i] = std::numeric_limits<float>::max();
633 gpt[i] = std::numeric_limits<float>::max();
634 geta[i] = std::numeric_limits<float>::max();
635 gphi[i] = std::numeric_limits<float>::max();
636 gnhits[i] = std::numeric_limits<int>::max();
637 gx_st1[i] = std::numeric_limits<float>::max();
638 gy_st1[i] = std::numeric_limits<float>::max();
639 gz_st1[i] = std::numeric_limits<float>::max();
640 gpx_st1[i] = std::numeric_limits<float>::max();
641 gpy_st1[i] = std::numeric_limits<float>::max();
642 gpz_st1[i] = std::numeric_limits<float>::max();
643 gndc[i] = std::numeric_limits<int>::max();
644 gnhodo[i] = std::numeric_limits<int>::max();
645 gnprop[i] = std::numeric_limits<int>::max();
646 gndp[i] = std::numeric_limits<int>::max();
649 ac_gpx[i] = std::numeric_limits<float>::max();
650 ac_gpy[i] = std::numeric_limits<float>::max();
651 ac_gpz[i] = std::numeric_limits<float>::max();
660 nhits[i] = std::numeric_limits<int>::max();
661 charge[i] = std::numeric_limits<int>::max();
662 rec_vx[i] = std::numeric_limits<float>::max();
663 rec_vy[i] = std::numeric_limits<float>::max();
664 rec_vz[i] = std::numeric_limits<float>::max();
665 rec_px[i] = std::numeric_limits<float>::max();
666 rec_py[i] = std::numeric_limits<float>::max();
667 rec_pz[i] = std::numeric_limits<float>::max();
668 rec_pt[i] = std::numeric_limits<float>::max();
669 rec_eta[i] = std::numeric_limits<float>::max();
670 rec_phi[i] = std::numeric_limits<float>::max();
677 sq_x_st1[i] = std::numeric_limits<float>::max();
678 sq_y_st1[i] = std::numeric_limits<float>::max();
679 sq_z_st1[i] = std::numeric_limits<float>::max();
680 sq_px_st1[i] = std::numeric_limits<float>::max();
681 sq_py_st1[i] = std::numeric_limits<float>::max();
682 sq_pz_st1[i] = std::numeric_limits<float>::max();
683 sq_pos_st1[i] = std::numeric_limits<float>::max();
684 sq_drift_st1[i] = std::numeric_limits<float>::max();
686 rec_x_st1[i] = std::numeric_limits<float>::max();
687 rec_y_st1[i] = std::numeric_limits<float>::max();
688 rec_z_st1[i] = std::numeric_limits<float>::max();
689 rec_px_st1[i] = std::numeric_limits<float>::max();
690 rec_py_st1[i] = std::numeric_limits<float>::max();
691 rec_pz_st1[i] = std::numeric_limits<float>::max();
692 rec_drift_st1[i] = std::numeric_limits<float>::max();
695 sq_x_st2[i] = std::numeric_limits<float>::max();
696 sq_y_st2[i] = std::numeric_limits<float>::max();
697 sq_z_st2[i] = std::numeric_limits<float>::max();
698 sq_px_st2[i] = std::numeric_limits<float>::max();
699 sq_py_st2[i] = std::numeric_limits<float>::max();
700 sq_pz_st2[i] = std::numeric_limits<float>::max();
701 sq_pos_st2[i] = std::numeric_limits<float>::max();
702 sq_drift_st2[i] = std::numeric_limits<float>::max();
704 rec_x_st2[i] = std::numeric_limits<float>::max();
705 rec_y_st2[i] = std::numeric_limits<float>::max();
706 rec_z_st2[i] = std::numeric_limits<float>::max();
707 rec_px_st2[i] = std::numeric_limits<float>::max();
708 rec_py_st2[i] = std::numeric_limits<float>::max();
709 rec_pz_st2[i] = std::numeric_limits<float>::max();
710 rec_drift_st2[i] = std::numeric_limits<float>::max();
713 sq_x_st3[i] = std::numeric_limits<float>::max();
714 sq_y_st3[i] = std::numeric_limits<float>::max();
715 sq_z_st3[i] = std::numeric_limits<float>::max();
716 sq_px_st3[i] = std::numeric_limits<float>::max();
717 sq_py_st3[i] = std::numeric_limits<float>::max();
718 sq_pz_st3[i] = std::numeric_limits<float>::max();
719 sq_pos_st3[i] = std::numeric_limits<float>::max();
720 sq_drift_st3[i] = std::numeric_limits<float>::max();
722 rec_x_st3[i] = std::numeric_limits<float>::max();
723 rec_y_st3[i] = std::numeric_limits<float>::max();
724 rec_z_st3[i] = std::numeric_limits<float>::max();
725 rec_px_st3[i] = std::numeric_limits<float>::max();
726 rec_py_st3[i] = std::numeric_limits<float>::max();
727 rec_pz_st3[i] = std::numeric_limits<float>::max();
728 rec_drift_st3[i] = std::numeric_limits<float>::max();
730 nhits_st1[i] = std::numeric_limits<float>::max();
731 nhits_st2[i] = std::numeric_limits<float>::max();
732 nhits_st3[i] = std::numeric_limits<float>::max();
741 _run_header = findNode::getClass<SQRun>(topNode,
"SQRun");
747 _spill_map = findNode::getClass<SQSpillMap>(topNode,
"SQSpillMap");
753 _event_header = findNode::getClass<SQEvent>(topNode,
"SQEvent");
754 if (!_event_header) {
759 if(_hit_container_type.find(
"Map") != std::string::npos) {
760 _hit_map = findNode::getClass<SQHitMap>(topNode,
"SQHitMap");
767 if(_hit_container_type.find(
"Vector") != std::string::npos) {
768 _hit_vector = findNode::getClass<SQHitVector>(topNode,
"SQHitVector");
775 _truth = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
781 _recEvent = findNode::getClass<SRecEvent>(topNode,
"SRecEvent");
788 g4hc_d1x = findNode::getClass<PHG4HitContainer >(topNode,
"G4HIT_D1X");
789 g4hc_d2xp = findNode::getClass<PHG4HitContainer >(topNode,
"G4HIT_D2Xp");
790 g4hc_d3px = findNode::getClass<PHG4HitContainer >(topNode,
"G4HIT_D3pXp");
791 g4hc_d3mx = findNode::getClass<PHG4HitContainer >(topNode,
"G4HIT_D3mXp");
792 if (! g4hc_d1x) g4hc_d1x = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_D0X");
794 if ( !g4hc_d1x || !g4hc_d3px || !g4hc_d3mx) {
795 cout <<
"Failed at getting nodes: "<< g4hc_d1x <<
" " << g4hc_d3px <<
" " << g4hc_d3mx << endl;
800 g4hc_h1t = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H1T");
801 g4hc_h1b = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H1B");
802 g4hc_h2t = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H2T");
803 g4hc_h2b = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H2B");
804 g4hc_h3t = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H3T");
805 g4hc_h3b = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H3B");
806 g4hc_h4t = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H4T");
807 g4hc_h4b = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_H4B");
809 if (!g4hc_h1t || !g4hc_h1b || !g4hc_h2t || !g4hc_h2b ||
810 !g4hc_h3t || !g4hc_h3b || !g4hc_h4t || !g4hc_h4b ) {
815 g4hc_p1y1 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P1Y1");
816 g4hc_p1y2 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P1Y2");
817 g4hc_p1x1 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P1X1");
818 g4hc_p1x2 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P1X2");
819 g4hc_p2x1 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P2X1");
820 g4hc_p2x2 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P2X2");
821 g4hc_p2y1 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P2Y1");
822 g4hc_p2y2 = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_P2Y2");
824 if (!g4hc_p1y1 || !g4hc_p1y2 || !g4hc_p1x1 || !g4hc_p1x2 ||
825 !g4hc_p2x1 || !g4hc_p2x2 || !g4hc_p2y1 || !g4hc_p2y2 ) {
836 bool AnaTrkQA::FindG4HitAtStation(
const int trk_id,
const PHG4HitContainer* g4hc, TVector3* pos, TLorentzVector* mom)
853 SRecTrack* AnaTrkQA::FindBestMomRecTrack(
SRecEvent *recEvent,
const float true_TargetP)
856 double hold_dP = 99999.;
859 for(
int itrack=0; itrack<recEvent->
getNTracks(); ++itrack){
860 if (hold_dP>dP) hold_dP = dP;
862 dP = fabs(true_TargetP - recTrack->
getTargetMom().Mag());
865 if(dP-hold_dP<0.) Best_recTrack = recTrack;
867 return Best_recTrack;
873 int AnaTrkQA::FindCommonHitIDs(vector<int>& hitidvec1, vector<int>& hitidvec2)
876 auto iter = hitidvec1.begin();
877 auto jter = hitidvec2.begin();
880 while(iter != hitidvec1.end() && jter != hitidvec2.end()) {
884 if(!(*jter < *iter)) {
897 bool AnaTrkQA::FindG4HitAtHodo(
const int trk_id,
const PHG4HitContainer* g4hc)
911 bool AnaTrkQA::FindG4HitAtProp(
const int trk_id,
const PHG4HitContainer* g4hc)
int process_event(PHCompositeNode *topNode)
AnaTrkQA(const std::string &name="AnaTrkQA.root")
int End(PHCompositeNode *topNode)
===========================
int Init(PHCompositeNode *topNode)
int InitRun(PHCompositeNode *topNode)
@ VERBOSITY_A_LOT
Output a lot of messages.
virtual int Verbosity() const
Gets the verbosity of this module.
static GeomSvc * instance()
singlton instance
double getDCA(int detectorID, int elementID, double tx, double ty, double x0, double y0)
Map::const_iterator ConstIterator
ConstRange getHits(const unsigned int detid) const
return all hits matching a given detid
std::pair< ConstIterator, ConstIterator > ConstRange
virtual float get_py(const int i) const
virtual float get_z(const int i) const
virtual float get_pz(const int i) const
virtual float get_px(const int i) const
virtual float get_y(const int i) const
virtual float get_x(const int i) const
virtual int get_trkid() const
virtual int get_track_id() const
virtual int get_pid() const
virtual double get_px() const
virtual int get_vtx_id() const
virtual double get_py() const
virtual double get_pz() const
Range GetPrimaryParticleRange()
PHG4VtxPoint * GetVtx(const int vtxid)
virtual double get_y() const
virtual double get_x() const
virtual double get_z() const
static PHTFileServer & get(void)
return reference to class singleton
void open(const std::string &filename, const std::string &type="RECREATE")
open a SafeTFile. If filename is not found in the map, create a new TFile and append to the map; incr...
bool cd(const std::string &filename)
change to directory of TFile matching filename
virtual const SQHit * at(const size_t idkey) const =0
virtual size_t size() const =0
An SQ interface class to hold one detector hit.
virtual float get_truth_z() const
Return the true z-position of this hit. Meaningful only if this hit is of MC.
virtual float get_drift_distance() const
Return the drift distance of this hit. Probably the value is not properly set at present....
virtual float get_truth_pz() const
Return the true z-momentum of this hit. Meaningful only if this hit is of MC.
virtual float get_truth_y() const
Return the true y-position of this hit. Meaningful only if this hit is of MC.
virtual float get_truth_px() const
Return the true x-momentum of this hit. Meaningful only if this hit is of MC.
virtual float get_pos() const
Return the absolute position of this hit. Probably the value is not properly set at present.
virtual short get_element_id() const
Return the element ID of this hit.
virtual int get_hit_id() const
Return the ID of this hit.
virtual float get_truth_py() const
Return the true y-momentum of this hit. Meaningful only if this hit is of MC.
virtual float get_truth_x() const
Return the true x-position of this hit. Meaningful only if this hit is of MC.
virtual short get_detector_id() const
Return the detector ID of this hit.
virtual int get_track_id() const
Return the track ID associated with this hit. Probably the value is not properly set at present.
Int_t getNTracks()
Get tracks.
SRecTrack & getTrack(Int_t i)
TMatrixD getCovariance(Int_t i)
Double_t getChisq() const
Int_t getCharge() const
Gets.
TMatrixD getStateVector(Int_t i)
Double_t getQuality() const
Int_t getHitIndex(Int_t i)
Int_t getNHitsInStation(Int_t stationID)
Int_t getNearestNode(Double_t z)