23 #include "nusimdata/SimulationBase/MCParticle.h"
24 #include "nusimdata/SimulationBase/MCTruth.h"
27 #include "art/Framework/Core/EDAnalyzer.h"
28 #include "art/Framework/Core/ModuleMacros.h"
29 #include "art/Framework/Principal/Event.h"
30 #include "art/Framework/Principal/Handle.h"
31 #include "art/Framework/Services/Registry/ServiceHandle.h"
32 #include "art_root_io/TFileService.h"
33 #include "canvas/Persistency/Common/FindManyP.h"
34 #include "fhiclcpp/ParameterSet.h"
35 #include "messagefacility/MessageLogger/MessageLogger.h"
38 #include "TEfficiency.h"
39 #include "TGraphAsymmErrors.h"
44 #define MAX_TRACKS 1000
58 void beginRun(
const art::Run& run);
61 void processEff(
const art::Event& evt);
65 const simb::MCParticle*& MCparticle,
70 const simb::MCParticle* MCparticle);
71 bool insideFV(
double vertex[4]);
72 void doEfficiencies();
85 double MC_incoming_P[4];
87 double MC_lepton_startMomentum[4];
138 TEfficiency* h_Eff_Ev = 0;
139 TEfficiency* h_Eff_Pmu = 0;
140 TEfficiency* h_Eff_theta = 0;
141 TEfficiency* h_Eff_Pproton = 0;
142 TEfficiency* h_Eff_Ppion_plus = 0;
143 TEfficiency* h_Eff_Ppion_minus = 0;
145 TEfficiency* h_Eff_Lmuon = 0;
146 TEfficiency* h_Eff_Lproton = 0;
147 TEfficiency* h_Eff_Lpion_plus = 0;
148 TEfficiency* h_Eff_Lpion_minus = 0;
165 TEfficiency* h_Eff_Pkaon = 0;
166 TEfficiency* h_Eff_Pmichel = 0;
167 TEfficiency* h_Eff_Lkaon = 0;
168 TEfficiency* h_Eff_Lmichel = 0;
182 art::ServiceHandle<geo::Geometry const>
geom;
187 NeutrinoTrackingEff::NeutrinoTrackingEff(fhicl::ParameterSet
const&
p) : EDAnalyzer(p)
201 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
208 std::cout <<
"job begin..." << std::endl;
209 auto const* geo = lar::providerFrom<geo::Geometry>();
218 for (
size_t i = 0; i < geo->NTPC(); ++i) {
219 double local[3] = {0., 0., 0.};
220 double world[3] = {0., 0., 0.};
223 if (minx > world[0] - geo->DetHalfWidth(i)) minx = world[0] - geo->DetHalfWidth(i);
224 if (maxx < world[0] + geo->DetHalfWidth(i)) maxx = world[0] + geo->DetHalfWidth(i);
225 if (miny > world[1] - geo->DetHalfHeight(i)) miny = world[1] - geo->DetHalfHeight(i);
226 if (maxy < world[1] + geo->DetHalfHeight(i)) maxy = world[1] + geo->DetHalfHeight(i);
227 if (minz > world[2] - geo->DetLength(i) / 2.) minz = world[2] - geo->DetLength(i) / 2.;
228 if (maxz < world[2] + geo->DetLength(i) / 2.) maxz = world[2] + geo->DetLength(i) / 2.;
244 art::ServiceHandle<art::TFileService const>
tfs;
246 double E_bins[21] = {0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4, 4.5, 5.0,
247 5.5, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0, 17.0, 20.0, 25.0};
248 double theta_bin[44] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.,
249 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 22.,
250 24., 26., 28., 30., 32., 34., 36., 38., 40., 42., 44.,
251 46., 48., 50., 55., 60., 65., 70., 75., 80., 85., 90.};
253 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0};
255 for (
int i = 0; i < 21; ++i)
257 for (
int i = 0; i < 18; ++i)
261 "h_Ev_den",
"Neutrino Energy; Neutrino Energy (GeV); Tracking Efficiency", 20, E_bins);
263 "h_Ev_num",
"Neutrino Energy; Neutrino Energy (GeV); Tracking Efficiency", 20, E_bins);
265 "h_Pmu_den",
"Muon Momentum; Muon Momentum (GeV); Tracking Efficiency", 20, E_bins);
267 "h_Pmu_num",
"Muon Momentum; Muon Momentum (GeV); Tracking Efficiency", 20, E_bins);
269 tfs->make<TH1D>(
"h_theta_den",
270 "Theta; Theta w.r.t beam direction (Degrees); Tracking Efficiency",
274 tfs->make<TH1D>(
"h_theta_num",
275 "Theta; Theta w.r.t beam direction (Degrees); Tracking Efficiency",
279 "h_Pproton_den",
"Protons; Proton Momentum (GeV); Tracking Efficiency", 17, Pbins);
281 "h_Pproton_num",
"Protons; Proton Momentum (GeV); Tracking Efficiency", 17, Pbins);
283 "h_Ppion_plus_den",
"Pions Plus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
285 "h_Ppion_plus_num",
"Pions Plus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
287 "h_Ppion_minus_den",
"Pions Minus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
289 "h_Ppion_minus_num",
"Pions Minus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
294 h_theta_den->Sumw2();
295 h_theta_num->Sumw2();
296 h_Pproton_den->Sumw2();
297 h_Pproton_num->Sumw2();
298 h_Ppion_plus_den->Sumw2();
299 h_Ppion_plus_num->Sumw2();
300 h_Ppion_minus_den->Sumw2();
301 h_Ppion_minus_num->Sumw2();
303 h_Efrac_lepton = tfs->make<TH1D>(
"h_Efrac_lepton",
"Efrac Lepton; Track Purity;", 60, 0, 1.2);
305 tfs->make<TH1D>(
"h_Ecomplet_lepton",
"Ecomplet Lepton; Track Completeness;", 60, 0, 1.2);
306 h_Efrac_proton = tfs->make<TH1D>(
"h_Efrac_proton",
"Efrac Proton; Track Purity;", 60, 0, 1.2);
308 tfs->make<TH1D>(
"h_Ecomplet_proton",
"Ecomplet Proton; Track Completeness;", 60, 0, 1.2);
310 tfs->make<TH1D>(
"h_Efrac_pion_plus",
"Efrac Pion +; Track Purity;", 60, 0, 1.2);
312 tfs->make<TH1D>(
"h_Ecomplet_pion_plus",
"Ecomplet Pion +; Track Completeness;", 60, 0, 1.2);
314 tfs->make<TH1D>(
"h_Efrac_pion_minus",
"Efrac Pion -; Track Purity;", 60, 0, 1.2);
316 tfs->make<TH1D>(
"h_Ecomplet_pion_minus",
"Ecomplet Pion -; Track Completeness;", 60, 0, 1.2);
318 "h_trackRes_lepton",
"Muon Residual; Truth length - Reco length (cm);", 200, -100, 100);
320 "h_trackRes_proton",
"Proton Residual; Truth length - Reco length (cm);", 200, -100, 100);
322 "h_trackRes_pion_plus",
"Pion + Residual; Truth length - Reco length (cm);", 200, -100, 100);
324 "h_trackRes_pion_minus",
"Pion - Residual; Truth length - Reco length (cm);", 200, -100, 100);
334 h_trackRes_proton->Sumw2();
335 h_trackRes_pion_plus->Sumw2();
336 h_trackRes_pion_minus->Sumw2();
339 tfs->make<TH1D>(
"h_muon_length",
"Muon Length; Muon Truth Length (cm)", 40, 0, 100);
341 tfs->make<TH1D>(
"h_proton_length",
"Proton Length; Proton Truth Length (cm)", 40, 0, 100);
343 tfs->make<TH1D>(
"h_pionp_length",
"Pion + Length; Pion^{+} Truth Length (cm)", 40, 0, 100);
345 tfs->make<TH1D>(
"h_pionm_length",
"Pion - Length; Pion^{-} Truth Length (cm)", 40, 0, 100);
348 tfs->make<TH1D>(
"h_muonwtrk_length",
"Muon Length; Muon Truth Length (cm)", 40, 0, 100);
350 tfs->make<TH1D>(
"h_protonwtrk_length",
"Proton Length; Proton Truth Length (cm)", 40, 0, 100);
352 "h_pionpwtrk_length",
"Pion + Length; Pion^{+} Truth Length (cm)", 40, 0, 100);
354 "h_pionmwtrk_length",
"Pion - Length; Pion^{-} Truth Length (cm)", 40, 0, 100);
357 h_muonwtrk_length->Sumw2();
358 h_proton_length->Sumw2();
359 h_protonwtrk_length->Sumw2();
360 h_pionp_length->Sumw2();
361 h_pionpwtrk_length->Sumw2();
362 h_pionm_length->Sumw2();
363 h_pionmwtrk_length->Sumw2();
366 tfs->make<TH1D>(
"h_Pkaon_den",
"Kaon; Kaon Momentum (GeV); Tracking Efficiency", 17, Pbins);
368 tfs->make<TH1D>(
"h_Pkaon_num",
"Kaon; Kaon Momentum (GeV); Tracking Efficiency", 17, Pbins);
370 tfs->make<TH1D>(
"h_Pmichel_e_den",
371 "Michel Electron; Michele e Momentum (GeV); Tracking Efficiency",
375 tfs->make<TH1D>(
"h_Pmichel_e_num",
376 "Michel Electron; Michele e Momentum (GeV); Tracking Efficiency",
380 h_Pkaon_num->Sumw2();
381 h_Pmichel_e_den->Sumw2();
382 h_Pmichel_e_num->Sumw2();
383 h_Efrac_kaon = tfs->make<TH1D>(
"h_Efrac_kaon",
"Efrac Kaon; Track Purity;", 60, 0, 1.2);
385 tfs->make<TH1D>(
"h_Ecomplet_kaon",
"Ecomplet Kaon; Track Completeness;", 60, 0, 1.2);
387 "h_trackRes_kaon",
"Kaon Residual; Truth length - Reco length (cm);", 200, -100, 100);
389 tfs->make<TH1D>(
"h_Efrac_michel",
"Efrac Michel; Track Energy fraction;", 60, 0, 1.2);
391 tfs->make<TH1D>(
"h_Ecomplet_michel",
"Ecomplet Michel; Track Completeness;", 60, 0, 1.2);
393 "h_trackRes_michel",
"Michel Residual; Truth length - Reco length (cm);", 200, -100, 100);
395 tfs->make<TH1D>(
"h_kaon_length",
"Kaon Length; Kaon Truth Length (cm)", 40, 0, 100);
397 tfs->make<TH1D>(
"h_kaonwtrk_length",
"Kaon Length; Kaon Truth Length (cm)", 40, 0, 100);
399 tfs->make<TH1D>(
"h_michel_length",
"Michel Length; Michel e Truth Length (cm)", 40, 0, 100);
401 "h_michelwtrk_length",
"Michel Length; Michel e Truth Length (cm)", 40, 0, 100);
406 h_Efrac_michel->Sumw2();
409 h_kaon_length->Sumw2();
410 h_kaonwtrk_length->Sumw2();
411 h_michel_length->Sumw2();
412 h_michelwtrk_length->Sumw2();
424 mf::LogInfo(
"NeutrinoTrackingEff") <<
"begin run..." << std::endl;
430 if (event.isRealData())
return;
439 art::Handle<std::vector<simb::MCTruth>> MCtruthHandle;
441 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
442 art::fill_ptr_vector(MCtruthlist, MCtruthHandle);
443 art::Ptr<simb::MCTruth> MCtruth;
446 MCtruth = MCtruthlist[0];
447 if (MCtruth->NeutrinoSet()) {
448 simb::MCNeutrino
nu = MCtruth->GetNeutrino();
451 else if (nu.CCNC() == 1)
453 simb::MCParticle neutrino = nu.Nu();
455 const TLorentzVector& nu_momentum = nu.Nu().Momentum(0);
457 const TLorentzVector&
vertex = neutrino.Position(0);
463 double tmp_leadingPionPlusE = 0.0;
464 double tmp_leadingPionMinusE = 0.0;
465 double tmp_leadingProtonE = 0.0;
467 simb::MCParticle* MClepton =
nullptr;
468 simb::MCParticle* MCproton =
nullptr;
469 simb::MCParticle* MCpion_plus =
nullptr;
470 simb::MCParticle* MCpion_minus =
nullptr;
471 simb::MCParticle* MCkaon =
nullptr;
472 simb::MCParticle* MCmichel =
nullptr;
474 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
475 const sim::ParticleList& plist = pi_serv->ParticleList();
476 simb::MCParticle* particle = 0;
479 auto const clockData =
480 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
482 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event);
484 for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar != plist.end(); ++ipar) {
485 particle = ipar->second;
486 if (particle->PdgCode() ==
fLeptonPDGcode && particle->Mother() == 0) {
487 const TLorentzVector& lepton_momentum = particle->Momentum(0);
490 MC_leptonP = sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
491 pow(particle->Momentum().Pz(), 2));
494 if (particle->Mother() == 0) {
496 if (particle->PdgCode() == 2212) {
497 if (particle->Momentum().E() > tmp_leadingProtonE) {
498 tmp_leadingProtonE = particle->Momentum().E();
501 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
502 pow(particle->Momentum().Pz(), 2));
506 else if (particle->PdgCode() == 211) {
507 if (particle->Momentum().E() > tmp_leadingPionPlusE) {
508 tmp_leadingPionPlusE = particle->Momentum().E();
511 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
512 pow(particle->Momentum().Pz(), 2));
513 MCpion_plus = particle;
516 else if (particle->PdgCode() == -211) {
517 if (particle->Momentum().E() > tmp_leadingPionMinusE) {
518 tmp_leadingPionMinusE = particle->Momentum().E();
521 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
522 pow(particle->Momentum().Pz(), 2));
523 MCpion_minus = particle;
533 if (particle->Mother() == 0) {
534 const TLorentzVector& positionStart = particle->Position(0);
537 if (particle->PdgCode() == 321) {
539 MC_kaonP = sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
540 pow(particle->Momentum().Pz(), 2));
545 MC_leptonP = sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
546 pow(particle->Momentum().Pz(), 2));
549 else if (particle->PdgCode() == 2212) {
550 if (particle->Momentum().E() > tmp_leadingProtonE) {
551 tmp_leadingProtonE = particle->Momentum().E();
554 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
555 pow(particle->Momentum().Pz(), 2));
559 else if (particle->PdgCode() == 211) {
560 if (particle->Momentum().E() > tmp_leadingPionPlusE) {
561 tmp_leadingPionPlusE = particle->Momentum().E();
564 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
565 pow(particle->Momentum().Pz(), 2));
566 MCpion_plus = particle;
569 else if (particle->PdgCode() == -211) {
570 if (particle->Momentum().E() > tmp_leadingPionMinusE) {
571 tmp_leadingPionMinusE = particle->Momentum().E();
574 sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
575 pow(particle->Momentum().Pz(), 2));
576 MCpion_minus = particle;
579 else if (particle->Process() ==
"Decay" &&
580 particle->PdgCode() == -11) {
582 MC_michelP = sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
583 pow(particle->Momentum().Pz(), 2));
586 else if (TMath::Abs(particle->PdgCode() == 321)) {
588 MC_kaonP = sqrt(pow(particle->Momentum().Px(), 2) + pow(particle->Momentum().Py(), 2) +
589 pow(particle->Momentum().Pz(), 2));
604 theta_mu *= (180.0 / 3.14159);
670 art::Handle<std::vector<recob::Track>> trackListHandle;
672 std::vector<art::Ptr<recob::Track>> tracklist;
673 art::fill_ptr_vector(tracklist, trackListHandle);
674 int n_recoTrack = tracklist.size();
676 art::FindManyP<recob::Hit> track_hits(trackListHandle, event,
fTrackModuleLabel);
677 if (n_recoTrack == 0) {
678 MF_LOG_DEBUG(
"NeutrinoTrackingEff") <<
"There are no reco tracks... bye";
681 MF_LOG_DEBUG(
"NeutrinoTrackingEff") <<
"Found this many reco tracks " << n_recoTrack;
683 double Efrac_lepton = 0.0;
684 double Ecomplet_lepton = 0.0;
685 double Efrac_proton = 0.0;
686 double Ecomplet_proton = 0.0;
687 double Efrac_pionplus = 0.0;
688 double Ecomplet_pionplus = 0.0;
689 double Efrac_pionminus = 0.0;
690 double Ecomplet_pionminus = 0.0;
691 double Efrac_kaon = 0.0;
692 double Ecomplet_kaon = 0.0;
693 double Efrac_michel = 0.0;
694 double Ecomplet_michel = 0.0;
695 double trackLength_lepton = 0.0;
696 double trackLength_proton = 0.0;
697 double trackLength_pion_plus = 0.0;
698 double trackLength_pion_minus = 0.0;
699 double trackLength_kaon = 0.0;
700 double trackLength_michel = 0.0;
701 const simb::MCParticle* MClepton_reco =
nullptr;
702 const simb::MCParticle* MCproton_reco =
nullptr;
703 const simb::MCParticle* MCpion_plus_reco =
nullptr;
704 const simb::MCParticle* MCpion_minus_reco =
nullptr;
705 const simb::MCParticle* MCkaon_reco =
nullptr;
706 const simb::MCParticle* MCmichel_reco =
nullptr;
708 std::vector<art::Ptr<recob::Hit>> tmp_all_trackHits = track_hits.at(0);
709 std::vector<art::Ptr<recob::Hit>> all_hits;
710 art::Handle<std::vector<recob::Hit>> hithandle;
711 auto const pd =
event.getProductDescription(tmp_all_trackHits[0].
id());
712 if (pd && event.getByLabel(pd->inputTag(), hithandle)) {
713 art::fill_ptr_vector(all_hits, hithandle);
716 for (
int i = 0; i < n_recoTrack; i++) {
717 art::Ptr<recob::Track>
track = tracklist[i];
718 std::vector<art::Ptr<recob::Hit>> all_trackHits = track_hits.at(i);
720 double tmpEcomplet = 0;
721 const simb::MCParticle* particle;
722 truthMatcher(clockData, all_hits, all_trackHits, particle, tmpEfrac, tmpEcomplet);
723 if (!particle)
continue;
727 if (tmpEcomplet > Ecomplet_lepton) {
728 Ecomplet_lepton = tmpEcomplet;
729 Efrac_lepton = tmpEfrac;
730 trackLength_lepton = track->Length();
731 MClepton_reco = particle;
736 if (tmpEcomplet > Ecomplet_proton) {
737 Ecomplet_proton = tmpEcomplet;
738 Efrac_proton = tmpEfrac;
739 trackLength_proton = track->Length();
740 MCproton_reco = particle;
745 if (tmpEcomplet > Ecomplet_pionplus) {
746 Ecomplet_pionplus = tmpEcomplet;
747 Efrac_pionplus = tmpEfrac;
748 trackLength_pion_plus = track->Length();
749 MCpion_plus_reco = particle;
754 if (tmpEcomplet > Ecomplet_pionminus) {
755 Ecomplet_pionminus = tmpEcomplet;
756 Efrac_pionminus = tmpEfrac;
757 trackLength_pion_minus = track->Length();
758 MCpion_minus_reco = particle;
762 else if ((TMath::Abs(particle->PdgCode()) == 321) && (particle->TrackId() ==
MC_kaonID)) {
764 if (tmpEcomplet > Ecomplet_kaon) {
765 Ecomplet_kaon = tmpEcomplet;
766 Efrac_kaon = tmpEfrac;
767 trackLength_kaon = track->Length();
768 MCkaon_reco = particle;
772 else if ((particle->PdgCode() == -11) && (particle->TrackId() ==
MC_michelID)) {
774 if (tmpEcomplet > Ecomplet_michel) {
775 Ecomplet_michel = tmpEcomplet;
776 Efrac_michel = tmpEfrac;
777 trackLength_michel = track->Length();
778 MCmichel_reco = particle;
783 double Reco_LengthRes = truth_lengthLepton - trackLength_lepton;
784 double Reco_LengthResProton = proton_length - trackLength_proton;
785 double Reco_LengthResPionPlus = pion_plus_length - trackLength_pion_plus;
786 double Reco_LengthResPionMinus = pion_minus_length - trackLength_pion_minus;
788 if (MClepton_reco && MClepton) {
799 if (MCproton_reco && MCproton) {
808 if (MCpion_plus_reco && MCpion_plus) {
817 if (MCpion_minus_reco && MCpion_minus) {
826 if (MCkaon_reco && MCkaon) {
838 if (MClepton_reco && MClepton) {
845 if (MCkaon_reco && MCkaon) {
852 if (MCproton_reco && MCproton) {
859 if (MCpion_plus_reco && MCpion_plus) {
866 if (MCpion_minus_reco && MCpion_minus) {
873 if (MCmichel_reco && MCmichel) {
887 const simb::MCParticle*& MCparticle,
891 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
892 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
893 std::map<int, double> trkID_E;
894 for (
size_t j = 0; j < track_hits.size(); ++j) {
895 art::Ptr<recob::Hit>
hit = track_hits[j];
896 std::vector<sim::TrackIDE>
TrackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
897 for (
size_t k = 0;
k < TrackIDs.size();
k++) {
898 trkID_E[TrackIDs[
k].trackID] += TrackIDs[
k].energy;
902 double max_E = -999.0;
903 double total_E = 0.0;
911 if (!trkID_E.size()) {
915 for (std::map<int, double>::iterator ii = trkID_E.begin(); ii != trkID_E.end(); ++ii) {
916 total_E += ii->second;
917 if ((ii->second) > max_E) {
918 partial_E = ii->second;
921 if (TrackID < 0) E_em += ii->second;
924 MCparticle = pi_serv->TrackIdToParticle_P(TrackID);
932 if (TrackID < 0)
return;
934 Efrac = (partial_E) / total_E;
937 double totenergy = 0;
938 for (
size_t k = 0;
k < all_hits.size(); ++
k) {
939 art::Ptr<recob::Hit>
hit = all_hits[
k];
940 std::vector<sim::TrackIDE>
TrackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
941 for (
size_t l = 0; l < TrackIDs.size(); ++l) {
942 if (TrackIDs[l].trackID == TrackID) totenergy += TrackIDs[l].energy;
945 Ecomplet = partial_E / totenergy;
951 const simb::MCParticle* MCparticle)
957 if (!MCparticle)
return -999.0;
958 int numberTrajectoryPoints = MCparticle->NumberTrajectoryPoints();
959 std::vector<double> TPCLengthHits(numberTrajectoryPoints, 0.0);
960 int FirstHit = 0, LastHit = 0;
961 double TPCLength = 0.0;
962 bool BeenInVolume =
false;
966 for (
unsigned int MCHit = 0; MCHit < TPCLengthHits.size(); ++MCHit) {
967 const TLorentzVector& tmpPosition = MCparticle->Position(MCHit);
968 double const tmpPosArray[] = {tmpPosition[0], tmpPosition[1], tmpPosition[2]};
970 TPCLengthHits[MCHit] = sqrt(pow((MCparticle->Vx(MCHit - 1) - MCparticle->Vx(MCHit)), 2) +
971 pow((MCparticle->Vy(MCHit - 1) - MCparticle->Vy(MCHit)), 2) +
972 pow((MCparticle->Vz(MCHit - 1) - MCparticle->Vz(MCHit)), 2));
979 double DriftTimeCorrection = fabs(tmpPosition[0] - XPlanePosition) /
fDriftVelocity;
980 double TimeAtPlane = MCparticle->T() + DriftTimeCorrection;
992 for (
int Hit = FirstHit + 1; Hit <= LastHit; ++Hit)
993 TPCLength += TPCLengthHits[Hit];
1000 double const x = vertex[0];
1001 double const y = vertex[1];
1002 double const z = vertex[2];
1011 art::ServiceHandle<art::TFileService const>
tfs;
1015 TGraphAsymmErrors* grEff_Ev =
h_Eff_Ev->CreateGraph();
1016 grEff_Ev->Write(
"grEff_Ev");
1021 TGraphAsymmErrors* grEff_Pmu =
h_Eff_Pmu->CreateGraph();
1022 grEff_Pmu->Write(
"grEff_Pmu");
1027 TGraphAsymmErrors* grEff_theta =
h_Eff_theta->CreateGraph();
1028 grEff_theta->Write(
"grEff_theta");
1033 TGraphAsymmErrors* grEff_Pproton =
h_Eff_Pproton->CreateGraph();
1034 grEff_Pproton->Write(
"grEff_Pproton");
1040 grEff_Ppion_plus->Write(
"grEff_Ppion_plus");
1046 grEff_Ppion_minus->Write(
"grEff_Ppion_minus");
1051 TGraphAsymmErrors* grEff_Lmuon =
h_Eff_Lmuon->CreateGraph();
1052 grEff_Lmuon->Write(
"grEff_Lmuon");
1057 TGraphAsymmErrors* grEff_Lproton =
h_Eff_Lproton->CreateGraph();
1058 grEff_Lproton->Write(
"grEff_Lproton");
1064 grEff_Lpion_plus->Write(
"grEff_Lpion_plus");
1070 grEff_Lpion_minus->Write(
"grEff_Lpion_minus");
1075 TGraphAsymmErrors* grEff_Pkaon =
h_Eff_Pkaon->CreateGraph();
1076 grEff_Pkaon->Write(
"grEff_Pkaon");
1081 TGraphAsymmErrors* grEff_Lkaon =
h_Eff_Lkaon->CreateGraph();
1082 grEff_Lkaon->Write(
"grEff_Lkaon");
1087 TGraphAsymmErrors* grEff_Pmichel =
h_Eff_Pmichel->CreateGraph();
1088 grEff_Pmichel->Write(
"grEff_Pmichel");
1093 TGraphAsymmErrors* grEff_Lmichel =
h_Eff_Lmichel->CreateGraph();
1094 grEff_Lmichel->Write(
"grEff_Lmichel");
process_name opflash particleana ie ie ie z
process_name opflashCryo1 flashfilter analyze
art::ServiceHandle< geo::Geometry const > geom
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Utilities related to art service access.
TEfficiency * h_Eff_Lpion_minus
TEfficiency * h_Eff_Lmuon
process_name opflash particleana ie x
std::string fTrackModuleLabel
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
std::vector< TrackID > TrackIDs
std::string fMCTruthModuleLabel
TH1D * h_michelwtrk_length
Geometry information for a single TPC.
process_name use argoneut_mc_hitfinder track
TEfficiency * h_Eff_Ppion_minus
Geometry information for a single cryostat.
TH1D * h_protonwtrk_length
TH1D * h_trackRes_pion_plus
TEfficiency * h_Eff_Lpion_plus
void truthMatcher(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> track_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
void processEff(const art::Event &evt)
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
TEfficiency * h_Eff_theta
process_name opflash particleana ie ie y
TEfficiency * h_Eff_Pproton
TEfficiency * h_Eff_Lproton
void analyze(const art::Event &evt)
double MC_lepton_startMomentum[4]
TEfficiency * h_Eff_Pmichel
unsigned int NumberTimeSamples() const
TH1D * h_Efrac_pion_minus
void beginRun(const art::Run &run)
The data type to uniquely identify a TPC.
double truthLength(const detinfo::DetectorClocksData &clockData, detinfo::DetectorPropertiesData const &detProp, const simb::MCParticle *MCparticle)
Definition of data types for geometry description.
Provides recob::Track data product.
BEGIN_PROLOG triggeremu_data_config_icarus settings sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds WindowSize
double MC_leading_PionPlusP
TH1D * h_Ecomplet_pion_plus
int MC_leading_PionMinusID
Contains all timing reference information for the detector.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
TH1D * h_trackRes_pion_minus
int MC_leading_PionPlusID
TH1D * h_pionmwtrk_length
TEfficiency * h_Eff_Lkaon
int trigger_offset(DetectorClocksData const &data)
art::ServiceHandle< art::TFileService > tfs
double MC_leading_ProtonP
TH1D * h_pionpwtrk_length
double MC_leading_PionMinusP
TH1D * h_Ecomplet_pion_minus
TEfficiency * h_Eff_Lmichel
TEfficiency * h_Eff_Pkaon
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
const double * PlaneLocation(unsigned int p) const
bool insideFV(double vertex[4])
art framework interface to geometry description
BEGIN_PROLOG could also be cout
TEfficiency * h_Eff_Ppion_plus
Encapsulate the construction of a single detector plane.