Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:56

0001 #include "DumpPHG4TruthInfoContainer.h"
0002 
0003 #include <phool/PHIODataNode.h>
0004 
0005 #include <g4main/PHG4Particle.h>
0006 #include <g4main/PHG4Shower.h>
0007 #include <g4main/PHG4TruthInfoContainer.h>
0008 #include <g4main/PHG4VtxPoint.h>
0009 
0010 #include <map>
0011 #include <ostream>
0012 #include <string>
0013 #include <utility>
0014 
0015 using MyNode_t = PHIODataNode<PHG4TruthInfoContainer>;
0016 
0017 DumpPHG4TruthInfoContainer::DumpPHG4TruthInfoContainer(const std::string &NodeName)
0018   : DumpObject(NodeName)
0019 {
0020   return;
0021 }
0022 
0023 int DumpPHG4TruthInfoContainer::process_Node(PHNode *myNode)
0024 {
0025   PHG4TruthInfoContainer *truthcontainer = nullptr;
0026   MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);  // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
0027   if (thisNode)
0028   {
0029     truthcontainer = thisNode->getData();
0030   }
0031   if (truthcontainer)
0032   {
0033     *fout << "number of G4 tracks: " << truthcontainer->size() << std::endl;
0034     *fout << "min trk index: " << truthcontainer->mintrkindex() << std::endl;
0035     *fout << "max trk index: " << truthcontainer->maxtrkindex() << std::endl;
0036     *fout << "number of G4 Vertices: " << truthcontainer->GetNumVertices() << std::endl;
0037     *fout << "min vtx index: " << truthcontainer->minvtxindex() << std::endl;
0038     *fout << "max vtx index: " << truthcontainer->maxvtxindex() << std::endl;
0039     *fout << "number of Showers: " << truthcontainer->shower_size() << std::endl;
0040     *fout << "min shower index: " << truthcontainer->minshowerindex() << std::endl;
0041     *fout << "max shower index: " << truthcontainer->maxshowerindex() << std::endl;
0042 
0043     PHG4TruthInfoContainer::ConstVtxIterator vtxiter;
0044     //      std::pair< std::map<int, PHG4VtxPoint *>::const_iterator, std::map<int, PHG4VtxPoint *>::const_iterator > vtxbegin_end = truthcontainer->GetVtxRange();
0045     PHG4TruthInfoContainer::ConstVtxRange vtxbegin_end = truthcontainer->GetVtxRange();
0046 
0047     for (vtxiter = vtxbegin_end.first; vtxiter != vtxbegin_end.second; vtxiter++)
0048     {
0049       *fout << "vtx number: " << vtxiter->first << std::endl;
0050       (*vtxiter->second).identify(*fout);
0051     }
0052     PHG4TruthInfoContainer::ConstIterator particle_iter;
0053     PHG4TruthInfoContainer::ConstRange particlebegin_end = truthcontainer->GetParticleRange();
0054     for (particle_iter = particlebegin_end.first; particle_iter != particlebegin_end.second; particle_iter++)
0055     {
0056       *fout << "particle number: " << particle_iter->first << std::endl;
0057       (particle_iter->second)->identify(*fout);
0058     }
0059     PHG4TruthInfoContainer::ConstShowerIterator shower_iter;
0060     PHG4TruthInfoContainer::ConstShowerRange showerbegin_end = truthcontainer->GetShowerRange();
0061     for (shower_iter = showerbegin_end.first; shower_iter != showerbegin_end.second; ++shower_iter)
0062     {
0063       *fout << "shower " << shower_iter->first << std::endl;
0064       *fout << "get_id(): " << shower_iter->second->get_id() << std::endl;
0065       *fout << "get_parent_particle_id(): " << shower_iter->second->get_parent_particle_id() << std::endl;
0066       *fout << "get_parent_shower_id(): " << shower_iter->second->get_parent_shower_id() << std::endl;
0067       *fout << "get_x(): " << shower_iter->second->get_x() << std::endl;
0068       *fout << "get_y(): " << shower_iter->second->get_y() << std::endl;
0069       *fout << "get_z(): " << shower_iter->second->get_z() << std::endl;
0070     }
0071     const std::pair<std::map<int, int>::const_iterator,
0072                     std::map<int, int>::const_iterator>
0073         embed_begin_end = truthcontainer->GetEmbeddedVtxIds();
0074     for (auto embed_iter = embed_begin_end.first; embed_iter != embed_begin_end.second; ++embed_iter)
0075     {
0076       *fout << "vtx id " << embed_iter->first << ", embed id: " << embed_iter->second << std::endl;
0077     }
0078     const std::pair<std::map<int, int>::const_iterator,
0079                     std::map<int, int>::const_iterator>
0080         embed_begin_end1 = truthcontainer->GetEmbeddedTrkIds();
0081     for (auto embed_iter = embed_begin_end1.first; embed_iter != embed_begin_end1.second; ++embed_iter)
0082     {
0083       *fout << "track id " << embed_iter->first << ", embed id: " << embed_iter->second << std::endl;
0084     }
0085   }
0086   return 0;
0087 }