Create the Pandora MC particles from the MC particles.
400 mf::LogDebug(
"LArPandora") <<
" *** LArPandoraInput::CreatePandoraMCParticles(...) *** " 404 if (!settings.m_pPrimaryPandora)
406 <<
"CreatePandoraMCParticles - primary Pandora instance does not exist ";
408 const pandora::Pandora* pPandora(settings.m_pPrimaryPandora);
414 iterEnd = particleToTruthMap.end();
418 particleMap[particle->
TrackId()] = particle;
422 int neutrinoCounter(0);
427 iterEnd1 = truthToParticleMap.end();
436 if (neutrinoCounter >= settings.m_uidOffset)
438 <<
"CreatePandoraMCParticles - detected an excessive number of mc neutrinos (" 439 << neutrinoCounter <<
")";
441 const int neutrinoID(neutrinoCounter + 9 * settings.m_uidOffset);
447 mcParticleParameters.
m_nuanceCode = neutrino.InteractionType();
449 mcParticleParameters.m_energy = neutrino.Nu().E();
450 mcParticleParameters.m_momentum =
451 pandora::CartesianVector(neutrino.Nu().Px(), neutrino.Nu().Py(), neutrino.Nu().Pz());
452 mcParticleParameters.m_vertex =
453 pandora::CartesianVector(neutrino.Nu().Vx(), neutrino.Nu().Vy(), neutrino.Nu().Vz());
454 mcParticleParameters.m_endpoint =
455 pandora::CartesianVector(neutrino.Nu().Vx(), neutrino.Nu().Vy(), neutrino.Nu().Vz());
456 mcParticleParameters.m_particleId = neutrino.Nu().PdgCode();
457 mcParticleParameters.m_mcParticleType = pandora::MC_3D;
458 mcParticleParameters.m_pParentAddress = (
void*)((intptr_t)neutrinoID);
460 catch (
const pandora::StatusCodeException&) {
462 <<
"CreatePandoraMCParticles - invalid mc neutrino parameter provided, all assigned " 463 "values must be finite, mc neutrino omitted " 469 PANDORA_THROW_RESULT_IF(
470 pandora::STATUS_CODE_SUCCESS,
472 PandoraApi::MCParticle::Create(*pPandora, mcParticleParameters, mcParticleFactory));
474 catch (
const pandora::StatusCodeException&) {
475 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc " 476 "neutrino, insufficient or invalid information supplied " 485 iterEnd2 = particleVector.end();
489 const int trackID(particle->
TrackId());
492 if (particle->
Mother() == 0) {
494 PANDORA_THROW_RESULT_IF(
495 pandora::STATUS_CODE_SUCCESS,
497 PandoraApi::SetMCParentDaughterRelationship(
498 *pPandora, (
void*)((intptr_t)neutrinoID), (
void*)((intptr_t)trackID)));
500 catch (
const pandora::StatusCodeException&) {
501 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc " 502 "particle relationship, invalid information supplied " 511 mf::LogDebug(
"LArPandora") <<
" Number of Pandora neutrinos: " << neutrinoCounter
515 int particleCounter(0);
518 std::map<const simb::MCParticle, bool> primaryGeneratorMCParticleMap;
526 if (particle->
TrackId() != iterI->first)
527 throw cet::exception(
"LArPandora") <<
"CreatePandoraMCParticles - mc truth information " 528 "appears to be scrambled in this event";
530 if (particle->
TrackId() >= settings.m_uidOffset)
532 <<
"CreatePandoraMCParticles - detected an excessive number of MC particles (" 538 int firstT(-1), lastT(-1);
541 if (firstT < 0 && lastT < 0) {
547 const float vtxX(particle->
Vx(firstT));
548 const float vtxY(particle->
Vy(firstT));
549 const float vtxZ(particle->
Vz(firstT));
551 const float endX(particle->
Vx(lastT));
552 const float endY(particle->
Vy(lastT));
553 const float endZ(particle->
Vz(lastT));
555 const float pX(particle->
Px(firstT));
556 const float pY(particle->
Py(firstT));
557 const float pZ(particle->
Pz(firstT));
558 const float E(particle->
E(firstT));
562 const int trackID(particle->
TrackId());
582 if (processMap.find(particle->
Process()) != processMap.end()) {
588 <<
"CreatePandoraMCParticles - found an unknown process" <<
std::endl;
590 mcParticleParameters.m_energy =
E;
591 mcParticleParameters.m_particleId = particle->
PdgCode();
592 mcParticleParameters.m_momentum = pandora::CartesianVector(pX, pY, pZ);
593 mcParticleParameters.m_vertex = pandora::CartesianVector(vtxX, vtxY, vtxZ);
594 mcParticleParameters.m_endpoint = pandora::CartesianVector(endX, endY, endZ);
595 mcParticleParameters.m_mcParticleType = pandora::MC_3D;
596 mcParticleParameters.m_pParentAddress = (
void*)((intptr_t)particle->
TrackId());
598 catch (
const pandora::StatusCodeException&) {
600 <<
"CreatePandoraMCParticles - invalid mc particle parameter provided, all assigned " 601 "values must be finite, mc particle omitted " 607 PANDORA_THROW_RESULT_IF(
608 pandora::STATUS_CODE_SUCCESS,
610 PandoraApi::MCParticle::Create(*pPandora, mcParticleParameters, mcParticleFactory));
612 catch (
const pandora::StatusCodeException&) {
613 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - unable to create mc particle, " 614 "insufficient or invalid information supplied " 620 const int id_mother(particle->
Mother());
623 if (iterJ != particleMap.end()) {
625 PANDORA_THROW_RESULT_IF(
626 pandora::STATUS_CODE_SUCCESS,
628 PandoraApi::SetMCParentDaughterRelationship(
629 *pPandora, (
void*)((intptr_t)id_mother), (
void*)((intptr_t)particle->
TrackId())));
631 catch (
const pandora::StatusCodeException&) {
632 mf::LogWarning(
"LArPandora") <<
"CreatePandoraMCParticles - Unable to create mc particle " 633 "relationship, invalid information supplied " double E(const int i=0) const
simb::MCTruth TrackIdToMCTruth(int const id) const
const simb::MCNeutrino & GetNeutrino() const
double Py(const int i=0) const
simb::Origin_t Origin() const
enum simb::_ev_origin Origin_t
event origin types
double Px(const int i=0) const
std::unordered_map< std::string, int > processMap
std::string Process() const
pandora::InputInt m_process
The process creating the particle.
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
single particles thrown at the detector
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
LArMCParticleFactory responsible for object creation.
LAr mc particle parameters.
double Vx(const int i=0) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
pandora::InputInt m_nuanceCode
The nuance code.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double Pz(const int i=0) const
double Vz(const int i=0) const
Event generator information.
double Vy(const int i=0) const
constexpr Point origin()
Returns a origin position with a point of the specified type.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)