Create the Pandora MC particles from the MC particles.
402 mf::LogDebug(
"LArPandora") <<
" *** LArPandoraInput::CreatePandoraMCParticles(...) *** "
404 art::ServiceHandle<cheat::ParticleInventoryService const> particleInventoryService;
406 if (!settings.m_pPrimaryPandora)
407 throw cet::exception(
"LArPandora")
408 <<
"CreatePandoraMCParticles - primary Pandora instance does not exist ";
410 const pandora::Pandora* pPandora(settings.m_pPrimaryPandora);
415 for (MCParticlesToMCTruth::const_iterator iter = particleToTruthMap.begin(),
416 iterEnd = particleToTruthMap.end();
419 const art::Ptr<simb::MCParticle> particle = iter->first;
420 particleMap[particle->TrackId()] = particle;
424 int neutrinoCounter(0);
428 for (MCTruthToMCParticles::const_iterator iter1 = truthToParticleMap.begin(),
429 iterEnd1 = truthToParticleMap.end();
432 const art::Ptr<simb::MCTruth> truth = iter1->first;
434 if (truth->NeutrinoSet()) {
435 const simb::MCNeutrino neutrino(truth->GetNeutrino());
438 if (neutrinoCounter >= settings.m_uidOffset)
439 throw cet::exception(
"LArPandora")
440 <<
"CreatePandoraMCParticles - detected an excessive number of mc neutrinos ("
441 << neutrinoCounter <<
")";
443 const int neutrinoID(neutrinoCounter + 9 * settings.m_uidOffset);
449 mcParticleParameters.
m_nuanceCode = neutrino.InteractionType();
451 mcParticleParameters.m_energy = neutrino.Nu().E();
452 mcParticleParameters.m_momentum =
453 pandora::CartesianVector(neutrino.Nu().Px(), neutrino.Nu().Py(), neutrino.Nu().Pz());
454 mcParticleParameters.m_vertex =
455 pandora::CartesianVector(neutrino.Nu().Vx(), neutrino.Nu().Vy(), neutrino.Nu().Vz());
456 mcParticleParameters.m_endpoint =
457 pandora::CartesianVector(neutrino.Nu().Vx(), neutrino.Nu().Vy(), neutrino.Nu().Vz());
458 mcParticleParameters.m_particleId = neutrino.Nu().PdgCode();
459 mcParticleParameters.m_mcParticleType = pandora::MC_3D;
460 mcParticleParameters.m_pParentAddress = (
void*)((intptr_t)neutrinoID);
462 catch (
const pandora::StatusCodeException&) {
463 mf::LogWarning(
"LArPandora")
464 <<
"CreatePandoraMCParticles - invalid mc neutrino parameter provided, all assigned "
465 "values must be finite, mc neutrino omitted "
471 PANDORA_THROW_RESULT_IF(
472 pandora::STATUS_CODE_SUCCESS,
474 PandoraApi::MCParticle::Create(*pPandora, mcParticleParameters, mcParticleFactory));
476 catch (
const pandora::StatusCodeException&) {
477 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc "
478 "neutrino, insufficient or invalid information supplied "
486 for (MCParticleVector::const_iterator iter2 = particleVector.begin(),
487 iterEnd2 = particleVector.end();
490 const art::Ptr<simb::MCParticle> particle = *iter2;
491 const int trackID(particle->TrackId());
494 if (particle->Mother() == 0) {
496 PANDORA_THROW_RESULT_IF(
497 pandora::STATUS_CODE_SUCCESS,
499 PandoraApi::SetMCParentDaughterRelationship(
500 *pPandora, (
void*)((intptr_t)neutrinoID), (
void*)((intptr_t)trackID)));
502 catch (
const pandora::StatusCodeException&) {
503 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc "
504 "particle relationship, invalid information supplied "
513 mf::LogDebug(
"LArPandora") <<
" Number of Pandora neutrinos: " << neutrinoCounter
517 int particleCounter(0);
520 std::map<const simb::MCParticle, bool> primaryGeneratorMCParticleMap;
523 for (MCParticleMap::const_iterator iterI = particleMap.begin(), iterEndI = particleMap.end();
526 const art::Ptr<simb::MCParticle> particle = iterI->second;
528 if (particle->TrackId() != iterI->first)
529 throw cet::exception(
"LArPandora") <<
"CreatePandoraMCParticles - mc truth information "
530 "appears to be scrambled in this event";
532 if (particle->TrackId() >= settings.m_uidOffset)
533 throw cet::exception(
"LArPandora")
534 <<
"CreatePandoraMCParticles - detected an excessive number of MC particles ("
535 << particle->TrackId() <<
")";
540 int firstT(-1), lastT(-1);
543 if (firstT < 0 && lastT < 0) {
549 const float vtxX(particle->Vx(firstT));
550 const float vtxY(particle->Vy(firstT));
551 const float vtxZ(particle->Vz(firstT));
553 const float endX(particle->Vx(lastT));
554 const float endY(particle->Vy(lastT));
555 const float endZ(particle->Vz(lastT));
557 const float pX(particle->Px(firstT));
558 const float pY(particle->Py(firstT));
559 const float pZ(particle->Pz(firstT));
560 const float E(particle->E(firstT));
564 const int trackID(particle->TrackId());
565 const simb::Origin_t
origin(particleInventoryService->TrackIdToMCTruth(trackID).Origin());
573 else if (simb::kSingleParticle ==
origin) {
584 if (processMap.find(particle->Process()) != processMap.end()) {
585 mcParticleParameters.
m_process = processMap[particle->Process()];
589 mf::LogWarning(
"LArPandora")
590 <<
"CreatePandoraMCParticles - found an unknown process" << std::endl;
592 mcParticleParameters.m_energy =
E;
593 mcParticleParameters.m_particleId = particle->PdgCode();
594 mcParticleParameters.m_momentum = pandora::CartesianVector(pX, pY, pZ);
595 mcParticleParameters.m_vertex = pandora::CartesianVector(vtxX, vtxY, vtxZ);
596 mcParticleParameters.m_endpoint = pandora::CartesianVector(endX, endY, endZ);
597 mcParticleParameters.m_mcParticleType = pandora::MC_3D;
598 mcParticleParameters.m_pParentAddress = (
void*)((intptr_t)particle->TrackId());
600 catch (
const pandora::StatusCodeException&) {
601 mf::LogWarning(
"LArPandora")
602 <<
"CreatePandoraMCParticles - invalid mc particle parameter provided, all assigned "
603 "values must be finite, mc particle omitted "
609 PANDORA_THROW_RESULT_IF(
610 pandora::STATUS_CODE_SUCCESS,
612 PandoraApi::MCParticle::Create(*pPandora, mcParticleParameters, mcParticleFactory));
614 catch (
const pandora::StatusCodeException&) {
615 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc particle, "
616 "insufficient or invalid information supplied "
622 const int id_mother(particle->Mother());
623 MCParticleMap::const_iterator iterJ = particleMap.find(id_mother);
625 if (iterJ != particleMap.end()) {
627 PANDORA_THROW_RESULT_IF(
628 pandora::STATUS_CODE_SUCCESS,
630 PandoraApi::SetMCParentDaughterRelationship(
631 *pPandora, (
void*)((intptr_t)id_mother), (
void*)((intptr_t)particle->TrackId())));
633 catch (
const pandora::StatusCodeException&) {
634 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - Unable to create mc particle "
635 "relationship, invalid information supplied "
642 mf::LogDebug(
"LArPandora") <<
"Number of mc particles: " << particleCounter << std::endl;
pandora::InputInt m_process
The process creating the particle.
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
LArMCParticleFactory responsible for object creation.
LAr mc particle parameters.
pandora::InputInt m_nuanceCode
The nuance code.
constexpr Point origin()
Returns a origin position with a point of the specified type.