303 art::Handle<std::vector<simb::MCTruth>> MCtruthHandle;
305 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
306 art::fill_ptr_vector(MCtruthlist, MCtruthHandle);
307 art::Ptr<simb::MCTruth> MCtruth;
309 int MCinteractions = MCtruthlist.size();
311 for (
int i=0; i<MCinteractions; i++){
312 MCtruth = MCtruthlist[i];
313 if ( MCtruth->NeutrinoSet() ) {
314 simb::MCNeutrino
nu = MCtruth->GetNeutrino();
315 if( nu.CCNC()==0 )
MC_isCC = 1;
316 else if (nu.CCNC()==1)
MC_isCC = 0;
317 simb::MCParticle neutrino = nu.Nu();
323 const TLorentzVector& nu_momentum = nu.Nu().Momentum(0);
325 const TLorentzVector&
vertex =neutrino.Position(0);
327 simb::MCParticle lepton = nu.Lepton();
340 int nParticles = MCtruthlist[0]->NParticles();
342 for (
int i=0; i<nParticles; i++){
343 simb::MCParticle
pi = MCtruthlist[0]->GetParticle(i);
353 simb::MCParticle *MClepton = NULL;
354 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
355 const sim::ParticleList& plist = pi_serv->ParticleList();
356 simb::MCParticle *particle=0;
358 for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar!=plist.end();++ipar){
359 particle = ipar->second;
361 auto & truth = pi_serv->ParticleToMCTruth_P(particle);
362 if ( truth->Origin()==simb::kBeamNeutrino &&
std::abs(particle->PdgCode()) ==
fLeptonPDGcode && particle->Mother()==0){
363 const TLorentzVector& lepton_momentum =particle->Momentum(0);
364 const TLorentzVector& lepton_position =particle->Position(0);
365 const TLorentzVector& lepton_positionEnd = particle->EndPosition();
366 const TLorentzVector& lepton_momentumEnd = particle->EndMomentum();
383 bool isFiducial =
false;
411 art::Handle<std::vector<recob::Hit>> hitHandle;
412 std::vector<art::Ptr<recob::Hit>> all_hits;
414 art::fill_ptr_vector(all_hits, hitHandle);
419 double ehit_total =0.0;
423 std::map<int,double> all_hits_trk_Q;
424 for (
size_t i=0; i < all_hits.size(); ++i) {
425 art::Ptr<recob::Hit>
hit = all_hits[i];
426 auto particles = fmhitmc.at(hit.key());
427 auto hitmatch = fmhitmc.data(hit.key());
428 double maxenergy = -1e9;
430 for (
size_t j = 0; j < particles.size(); ++j){
431 if (!particles[j])
continue;
432 if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))
continue;
433 size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
435 if ( (hitmatch[j]->energy) > maxenergy ){
436 maxenergy = hitmatch[j]->energy;
440 if (hit_TrackId ==
MC_leptonID) ehit_total += hit->Integral();
441 all_hits_trk_Q[hit_TrackId] += hit->Integral();
448 const simb::MCParticle *MClepton_reco = NULL;
450 double temp_sh_ehit_Q = 0.0;
451 double temp_sh_allHit_Q = 0.0;
452 int temp_sh_TrackId = -999;
455 art::Handle<std::vector<recob::Shower>> showerHandle;
456 std::vector<art::Ptr<recob::Shower>> showerlist;
458 art::fill_ptr_vector(showerlist, showerHandle);
466 std::map<int,double> showers_trk_Q;
471 std::map<int,double> sh_hits_trk_Q;
472 sh_hits_trk_Q.clear();
474 art::Ptr<recob::Shower>
shower = showerlist[i];
488 std::vector<art::Ptr<recob::Hit>> sh_hits;
497 art::Handle<std::vector<recob::PFParticle> > pfpHandle;
498 std::vector<art::Ptr<recob::PFParticle> > pfps;
501 art::Handle<std::vector<recob::Cluster> > clusterHandle;
502 std::vector<art::Ptr<recob::Cluster> > clusters;
503 if (
e.getByLabel(
fShowerModuleLabel, clusterHandle)) art::fill_ptr_vector(clusters, clusterHandle);
508 std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
509 for (
size_t ipf = 0; ipf<pfs.size(); ++ipf){
511 std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].key());
512 for (
size_t iclu = 0; iclu<clus.size(); ++iclu){
514 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].key());
515 for (
size_t ihit = 0; ihit<hits.size(); ++ihit){
516 sh_hits.push_back(hits[ihit]);
534 sh_hits = sh_hitsAll.at(i);
539 for (
size_t k=0;
k < sh_hits.size(); ++
k) {
540 art::Ptr<recob::Hit> hit = sh_hits[
k];
541 auto particles = fmhitmc.at(hit.key());
542 auto hitmatch = fmhitmc.data(hit.key());
543 double maxenergy = -1e9;
545 for (
size_t j = 0; j < particles.size(); ++j){
546 if (!particles[j])
continue;
547 if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))
continue;
548 size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
550 if ( (hitmatch[j]->energy) > maxenergy ){
551 maxenergy = hitmatch[j]->energy;
559 sh_hits_trk_Q[hit_TrackId] += hit->Integral();
565 double maxshowerQ = -1.0e9;
567 for(std::map<int,double>::iterator
k = sh_hits_trk_Q.begin();
k != sh_hits_trk_Q.end();
k++) {
569 if (
k->second > maxshowerQ) {
570 maxshowerQ =
k->second;
583 MClepton_reco = pi_serv->TrackIdToParticle_P(
sh_TrackId[i]);
607 if (MClepton_reco && MClepton) {
609 if ((temp_sh_allHit_Q >= temp_sh_ehit_Q) && (temp_sh_ehit_Q > 0.0)) {
630 double temp_esh_1_allhit = -1.0e9;
631 int temp_shower_index = -999;
632 int temp_esh_index = 0;
646 temp_shower_index = i;
double esh_each_purity[MAX_SHOWERS]
double sh_direction_X[MAX_SHOWERS]
double MC_lepton_startEnergy
double esh_1_completeness
double sh_start_Y[MAX_SHOWERS]
int count_primary_e_in_Event
double sh_direction_Y[MAX_SHOWERS]
std::string fMCTruthModuleLabel
double MC_lepton_startMomentum[4]
bool fHitShowerThroughPFParticle
int sh_TrackId[MAX_SHOWERS]
std::string fShowerModuleLabel
std::string fHitModuleLabel
double esh_each_completeness[MAX_SHOWERS]
int sh_hasPrimary_e[MAX_SHOWERS]
bool insideFV(double vertex[4])
The standard subrun data definition.
double sh_start_Z[MAX_SHOWERS]
double sh_purity[MAX_SHOWERS]
double sh_ehit_Q[MAX_SHOWERS]
double MC_lepton_startXYZT[4]
double MC_lepton_endXYZT[4]
double sh_direction_Z[MAX_SHOWERS]
double sh_completeness[MAX_SHOWERS]
double MC_lepton_endMomentum[40]
double sh_allhit_Q[MAX_SHOWERS]
std::string fTruthMatchDataModuleLabel
double sh_start_X[MAX_SHOWERS]
double sh_length[MAX_SHOWERS]