Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "PHNodeDump.h"
0002 #include "DumpObject.h"
0003 
0004 #include "DumpBbcPmtInfoContainer.h"
0005 #include "DumpBbcVertexMap.h"
0006 #include "DumpCaloPacket.h"
0007 #include "DumpCaloPacketContainer.h"
0008 #include "DumpCaloTriggerInfo.h"
0009 #include "DumpCdbUrlSave.h"
0010 #include "DumpCentralityInfo.h"
0011 #include "DumpEpdGeom.h"
0012 #include "DumpEventHeader.h"
0013 #include "DumpFlagSave.h"
0014 #include "DumpGl1Packet.h"
0015 #include "DumpGl1RawHit.h"
0016 #include "DumpGlobalVertexMap.h"
0017 #include "DumpInttDeadMap.h"
0018 #include "DumpInttRawHitContainer.h"
0019 #include "DumpJetContainer.h"
0020 #include "DumpJetMap.h"
0021 #include "DumpMbdGeom.h"
0022 #include "DumpMbdOut.h"
0023 #include "DumpMbdPmtContainer.h"
0024 #include "DumpMbdVertexMap.h"
0025 #include "DumpMicromegasRawHitContainer.h"
0026 #include "DumpMvtxRawEvtHeader.h"
0027 #include "DumpMvtxRawHitContainer.h"
0028 #include "DumpPHFieldConfig.h"
0029 #include "DumpPHG4BlockCellGeomContainer.h"
0030 #include "DumpPHG4BlockGeomContainer.h"
0031 #include "DumpPHG4CellContainer.h"
0032 #include "DumpPHG4CylinderCellContainer.h"
0033 #include "DumpPHG4CylinderCellGeomContainer.h"
0034 #include "DumpPHG4CylinderGeomContainer.h"
0035 #include "DumpPHG4HitContainer.h"
0036 #include "DumpPHG4InEvent.h"
0037 #include "DumpPHG4ParticleSvtxMap.h"
0038 #include "DumpPHG4ScintillatorSlatContainer.h"
0039 #include "DumpPHG4TpcCylinderGeomContainer.h"
0040 #include "DumpPHG4TruthInfoContainer.h"
0041 #include "DumpPHGenIntegral.h"
0042 #include "DumpPHHepMCGenEventMap.h"
0043 #include "DumpParticleFlowElementContainer.h"
0044 #include "DumpPdbParameterMap.h"
0045 #include "DumpPdbParameterMapContainer.h"
0046 #include "DumpRawClusterContainer.h"
0047 #include "DumpRawTowerContainer.h"
0048 #include "DumpRawTowerGeomContainer.h"
0049 #include "DumpRunHeader.h"
0050 #include "DumpSvtxPHG4ParticleMap.h"
0051 #include "DumpSvtxTrackMap.h"
0052 #include "DumpSvtxVertexMap.h"
0053 #include "DumpSyncObject.h"
0054 #include "DumpTowerBackground.h"
0055 #include "DumpTowerInfoContainer.h"
0056 #include "DumpTpcRawHitContainer.h"
0057 #include "DumpTpcSeedTrackMap.h"
0058 #include "DumpTrackSeedContainer.h"
0059 #include "DumpTrkrClusterContainer.h"
0060 #include "DumpTrkrClusterCrossingAssoc.h"
0061 #include "DumpTrkrClusterHitAssoc.h"
0062 #include "DumpTrkrHitSetContainer.h"
0063 #include "DumpTrkrHitTruthAssoc.h"
0064 #include "DumpZdcinfo.h"
0065 
0066 #include <ffaobjects/EventHeader.h>
0067 #include <ffaobjects/RunHeader.h>
0068 
0069 #include <phool/PHIODataNode.h>
0070 #include <phool/PHNode.h>
0071 #include <phool/getClass.h>
0072 #include <phool/phool.h>
0073 
0074 #include <TObject.h>
0075 
0076 #include <iostream>
0077 #include <string>
0078 #include <utility>
0079 
0080 PHNodeDump::~PHNodeDump()
0081 {
0082   ignore.clear();
0083   exclusive.clear();
0084   while (dumpthis.begin() != dumpthis.end())
0085   {
0086     delete dumpthis.begin()->second;
0087     dumpthis.erase(dumpthis.begin());
0088   }
0089   return;
0090 }
0091 
0092 int PHNodeDump::AddIgnore(const std::string &name)
0093 {
0094   if (ignore.find(name) != ignore.end())
0095   {
0096     std::cout << PHWHERE << " "
0097               << name << "already in ignore list" << std::endl;
0098     return -1;
0099   }
0100   ignore.insert(name);
0101   return 0;
0102 }
0103 
0104 int PHNodeDump::Select(const std::string &name)
0105 {
0106   if (exclusive.find(name) != exclusive.end())
0107   {
0108     std::cout << PHWHERE << " "
0109               << name << "already in exclusive list" << std::endl;
0110     return -1;
0111   }
0112   exclusive.insert(name);
0113   return 0;
0114 }
0115 
0116 int PHNodeDump::GetGlobalVars(PHCompositeNode *topNode)
0117 {
0118   RunHeader *runheader = findNode::getClass<RunHeader>(topNode, "RunHeader");
0119   if (runheader)
0120   {
0121     runnumber = runheader->get_RunNumber();
0122   }
0123   EventHeader *eventheader = findNode::getClass<EventHeader>(topNode, "EventHeader");
0124   if (eventheader)
0125   {
0126     evtsequence = eventheader->get_EvtSequence();
0127   }
0128   return 0;
0129 }
0130 
0131 void PHNodeDump::perform(PHNode *node)
0132 {
0133   std::map<std::string, DumpObject *>::iterator iter;
0134   if (node->getType() == "PHIODataNode")
0135   {
0136     std::string NodeName = node->getName();
0137     iter = dumpthis.find(NodeName);
0138     if (iter == dumpthis.end())
0139     {
0140       std::cout << "Adding Dump Object for " << NodeName << std::endl;
0141       AddDumpObject(NodeName, node);
0142       iter = dumpthis.find(NodeName);  // update iterator
0143     }
0144 
0145     if (iter != dumpthis.end())
0146     {
0147       iter->second->process_event(node);
0148     }
0149     else
0150     {
0151       //           for (iter = dumpthis.begin(); iter != dumpthis.end(); iter++)
0152       //             {
0153       //               std::cout << "registered: " << iter->second->Name() << std::endl;
0154       //             }
0155       std::cout << "Something went wrong with adding Dump Object for " << NodeName
0156                 << ", it should exist !! Trying to create it again" << std::endl;
0157       AddDumpObject(NodeName, node);
0158     }
0159   }
0160   return;
0161 }
0162 
0163 int PHNodeDump::CloseOutputFiles()
0164 {
0165   std::map<std::string, DumpObject *>::iterator iter;
0166   for (iter = dumpthis.begin(); iter != dumpthis.end(); ++iter)
0167   {
0168     iter->second->CloseOutputFile();
0169   }
0170   return 0;
0171 }
0172 
0173 int PHNodeDump::AddDumpObject(const std::string &NodeName, PHNode *node)
0174 {
0175   DumpObject *newdump;
0176   if (!exclusive.empty())
0177   {
0178     if (exclusive.find(NodeName) == exclusive.end())
0179     {
0180       std::cout << "Exclusive find: Ignoring " << NodeName << std::endl;
0181       newdump = new DumpObject(NodeName);
0182       newdump->NoOutput();
0183       return initdump(NodeName, newdump);
0184     }
0185   }
0186   if (ignore.find(NodeName) != ignore.end())
0187   {
0188     std::cout << "Ignoring " << NodeName << std::endl;
0189     newdump = new DumpObject(NodeName);
0190     newdump->NoOutput();
0191   }
0192   else
0193   {
0194     if (node->getType() == "PHIODataNode")
0195     {
0196       // need a static cast since only from DST these guys are of type PHIODataNode<TObject*>
0197       // when created they are normally  PHIODataNode<PHObject*> but can be anything else as well
0198       TObject *tmp = static_cast<TObject *>((static_cast<PHIODataNode<TObject> *>(node))->getData());  // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
0199       if (tmp->InheritsFrom("BbcPmtInfoContainerV1"))
0200       {
0201         newdump = new DumpBbcPmtInfoContainer(NodeName);
0202       }
0203       else if (tmp->InheritsFrom("BbcVertexMap"))
0204       {
0205         newdump = new DumpBbcVertexMap(NodeName);
0206       }
0207       else if (tmp->InheritsFrom("CaloPacket"))
0208       {
0209         newdump = new DumpCaloPacket(NodeName);
0210       }
0211       else if (tmp->InheritsFrom("CaloPacketContainer"))
0212       {
0213         newdump = new DumpCaloPacketContainer(NodeName);
0214       }
0215       else if (tmp->InheritsFrom("CaloTriggerInfo"))
0216       {
0217         newdump = new DumpCaloTriggerInfo(NodeName);
0218       }
0219       else if (tmp->InheritsFrom("CdbUrlSave"))
0220       {
0221         newdump = new DumpCdbUrlSave(NodeName);
0222       }
0223       else if (tmp->InheritsFrom("CentralityInfo"))
0224       {
0225         newdump = new DumpCentralityInfo(NodeName);
0226       }
0227       else if (tmp->InheritsFrom("EpdGeom"))
0228       {
0229         newdump = new DumpEpdGeom(NodeName);
0230       }
0231       else if (tmp->InheritsFrom("EventHeader"))
0232       {
0233         newdump = new DumpEventHeader(NodeName);
0234       }
0235       else if (tmp->InheritsFrom("FlagSave"))
0236       {
0237         newdump = new DumpFlagSave(NodeName);
0238       }
0239       else if (tmp->InheritsFrom("Gl1Packet"))
0240       {
0241         newdump = new DumpGl1Packet(NodeName);
0242       }
0243       else if (tmp->InheritsFrom("Gl1RawHit"))
0244       {
0245         newdump = new DumpGl1RawHit(NodeName);
0246       }
0247       else if (tmp->InheritsFrom("GlobalVertexMap"))
0248       {
0249         newdump = new DumpGlobalVertexMap(NodeName);
0250       }
0251       else if (tmp->InheritsFrom("InttDeadMap"))
0252       {
0253         newdump = new DumpInttDeadMap(NodeName);
0254       }
0255       else if (tmp->InheritsFrom("InttRawHitContainer"))
0256       {
0257         newdump = new DumpInttRawHitContainer(NodeName);
0258       }
0259       else if (tmp->InheritsFrom("JetMap"))
0260       {
0261         newdump = new DumpJetMap(NodeName);
0262       }
0263       else if (tmp->InheritsFrom("JetContainer"))
0264       {
0265         newdump = new DumpJetContainer(NodeName);
0266       }
0267       else if (tmp->InheritsFrom("MbdGeom"))
0268       {
0269         newdump = new DumpMbdGeom(NodeName);
0270       }
0271       else if (tmp->InheritsFrom("MbdOut"))
0272       {
0273         newdump = new DumpMbdOut(NodeName);
0274       }
0275       else if (tmp->InheritsFrom("MbdPmtContainer"))
0276       {
0277         newdump = new DumpMbdPmtContainer(NodeName);
0278       }
0279       else if (tmp->InheritsFrom("MbdVertexMap"))
0280       {
0281         newdump = new DumpMbdVertexMap(NodeName);
0282       }
0283       else if (tmp->InheritsFrom("MicromegasRawHitContainer"))
0284       {
0285         newdump = new DumpMicromegasRawHitContainer(NodeName);
0286       }
0287       else if (tmp->InheritsFrom("MvtxRawEvtHeader"))
0288       {
0289         newdump = new DumpMvtxRawEvtHeader(NodeName);
0290       }
0291       else if (tmp->InheritsFrom("MvtxRawHitContainer"))
0292       {
0293         newdump = new DumpMvtxRawHitContainer(NodeName);
0294       }
0295       else if (tmp->InheritsFrom("ParticleFlowElementContainer"))
0296       {
0297         newdump = new DumpParticleFlowElementContainer(NodeName);
0298       }
0299       else if (tmp->InheritsFrom("PdbParameterMap"))
0300       {
0301         newdump = new DumpPdbParameterMap(NodeName);
0302       }
0303       else if (tmp->InheritsFrom("PdbParameterMapContainer"))
0304       {
0305         newdump = new DumpPdbParameterMapContainer(NodeName);
0306       }
0307       else if (tmp->InheritsFrom("PHFieldConfig"))
0308       {
0309         newdump = new DumpPHFieldConfig(NodeName);
0310       }
0311       else if (tmp->InheritsFrom("PHG4BlockGeomContainer"))
0312       {
0313         newdump = new DumpPHG4BlockGeomContainer(NodeName);
0314       }
0315       else if (tmp->InheritsFrom("PHG4BlockCellGeomContainer"))
0316       {
0317         newdump = new DumpPHG4BlockCellGeomContainer(NodeName);
0318       }
0319       else if (tmp->InheritsFrom("PHG4CellContainer"))
0320       {
0321         newdump = new DumpPHG4CellContainer(NodeName);
0322       }
0323       else if (tmp->InheritsFrom("PHG4CylinderCellContainer"))
0324       {
0325         newdump = new DumpPHG4CylinderCellContainer(NodeName);
0326       }
0327       else if (tmp->InheritsFrom("PHG4CylinderGeomContainer"))
0328       {
0329         newdump = new DumpPHG4CylinderGeomContainer(NodeName);
0330       }
0331       else if (tmp->InheritsFrom("PHG4CylinderCellGeomContainer"))
0332       {
0333         newdump = new DumpPHG4CylinderCellGeomContainer(NodeName);
0334       }
0335       else if (tmp->InheritsFrom("PHG4HitContainer"))
0336       {
0337         newdump = new DumpPHG4HitContainer(NodeName);
0338       }
0339       else if (tmp->InheritsFrom("PHG4InEvent"))
0340       {
0341         newdump = new DumpPHG4InEvent(NodeName);
0342       }
0343       else if (tmp->InheritsFrom("PHG4ParticleSvtxMap"))
0344       {
0345         newdump = new DumpPHG4ParticleSvtxMap(NodeName);
0346       }
0347       else if (tmp->InheritsFrom("PHG4ScintillatorSlatContainer"))
0348       {
0349         newdump = new DumpPHG4ScintillatorSlatContainer(NodeName);
0350       }
0351       else if (tmp->InheritsFrom("PHG4TpcCylinderGeomContainer"))
0352       {
0353         newdump = new DumpPHG4TpcCylinderGeomContainer(NodeName);
0354       }
0355       else if (tmp->InheritsFrom("PHG4TruthInfoContainer"))
0356       {
0357         newdump = new DumpPHG4TruthInfoContainer(NodeName);
0358       }
0359       else if (tmp->InheritsFrom("PHGenIntegral"))
0360       {
0361         newdump = new DumpPHGenIntegral(NodeName);
0362       }
0363       else if (tmp->InheritsFrom("PHHepMCGenEventMap"))
0364       {
0365         newdump = new DumpPHHepMCGenEventMap(NodeName);
0366       }
0367       else if (tmp->InheritsFrom("RawClusterContainer"))
0368       {
0369         newdump = new DumpRawClusterContainer(NodeName);
0370       }
0371       else if (tmp->InheritsFrom("RawTowerContainer"))
0372       {
0373         newdump = new DumpRawTowerContainer(NodeName);
0374       }
0375       else if (tmp->InheritsFrom("RawTowerGeomContainer"))
0376       {
0377         newdump = new DumpRawTowerGeomContainer(NodeName);
0378       }
0379       else if (tmp->InheritsFrom("RunHeader"))
0380       {
0381         newdump = new DumpRunHeader(NodeName);
0382       }
0383       else if (tmp->InheritsFrom("SvtxPHG4ParticleMap"))
0384       {
0385         newdump = new DumpSvtxPHG4ParticleMap(NodeName);
0386       }
0387       else if (tmp->InheritsFrom("SvtxTrackMap"))
0388       {
0389         newdump = new DumpSvtxTrackMap(NodeName);
0390       }
0391       else if (tmp->InheritsFrom("SvtxVertexMap"))
0392       {
0393         newdump = new DumpSvtxVertexMap(NodeName);
0394       }
0395       else if (tmp->InheritsFrom("SyncObject"))
0396       {
0397         newdump = new DumpSyncObject(NodeName);
0398       }
0399       else if (tmp->InheritsFrom("TowerBackground"))
0400       {
0401         newdump = new DumpTowerBackground(NodeName);
0402       }
0403       else if (tmp->InheritsFrom("TowerInfoContainer"))
0404       {
0405         newdump = new DumpTowerInfoContainer(NodeName);
0406       }
0407       else if (tmp->InheritsFrom("TpcRawHitContainer"))
0408       {
0409         newdump = new DumpTpcRawHitContainer(NodeName);
0410       }
0411       else if (tmp->InheritsFrom("TpcSeedTrackMap"))
0412       {
0413         newdump = new DumpTpcSeedTrackMap(NodeName);
0414       }
0415       else if (tmp->InheritsFrom("TrackSeedContainer"))
0416       {
0417         newdump = new DumpTrackSeedContainer(NodeName);
0418       }
0419       else if (tmp->InheritsFrom("TrkrClusterContainer"))
0420       {
0421         newdump = new DumpTrkrClusterContainer(NodeName);
0422       }
0423       else if (tmp->InheritsFrom("TrkrClusterCrossingAssoc"))
0424       {
0425         newdump = new DumpTrkrClusterCrossingAssoc(NodeName);
0426       }
0427       else if (tmp->InheritsFrom("TrkrClusterHitAssoc"))
0428       {
0429         newdump = new DumpTrkrClusterHitAssoc(NodeName);
0430       }
0431       else if (tmp->InheritsFrom("TrkrHitSetContainer"))
0432       {
0433         newdump = new DumpTrkrHitSetContainer(NodeName);
0434       }
0435       else if (tmp->InheritsFrom("TrkrHitTruthAssoc"))
0436       {
0437         newdump = new DumpTrkrHitTruthAssoc(NodeName);
0438       }
0439       else if (tmp->InheritsFrom("Zdcinfo"))
0440       {
0441         newdump = new DumpZdcinfo(NodeName);
0442       }
0443       else
0444       {
0445         std::cout << "Registering Dummy for " << NodeName
0446                   << ", Class: " << tmp->ClassName() << std::endl;
0447         newdump = new DumpObject(NodeName);
0448       }
0449     }
0450     else
0451     {
0452       std::cout << "ignoring PHDataNode: " << NodeName << std::endl;
0453       newdump = new DumpObject(NodeName);
0454     }
0455   }
0456   newdump->PrintEvtSeq(print_evtseq);
0457   return initdump(NodeName, newdump);
0458 }
0459 
0460 int PHNodeDump::initdump(const std::string &newnode, DumpObject *dmp)
0461 {
0462   dmp->SetParentNodeDump(this);
0463   dmp->SetOutDir(outdir);
0464   dmp->SetPrecision(fp_precision);
0465   dmp->Init();
0466   dumpthis[newnode] = dmp;
0467   return 0;
0468 }