Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:20

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   CstInterfaces.cc
0003  *  \author Derek Anderson
0004  *  \date   08.15.2024
0005  *
0006  *  Jet constituent-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_CSTINTERFACES_CC
0011 
0012 // namespace definition 
0013 #include "CstInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 using namespace findNode;
0018 
0019 
0020 
0021 // cst interfaces =============================================================
0022 
0023 namespace SColdQcdCorrelatorAnalysis {
0024 
0025   // --------------------------------------------------------------------------
0026   //! Find SvtxTrack based on provided ID
0027   // --------------------------------------------------------------------------
0028   SvtxTrack* Interfaces::FindTrack(const uint32_t idToFind, PHCompositeNode* topNode) {
0029 
0030     // grab track map
0031     SvtxTrackMap* map = Interfaces::GetTrackMap(topNode);
0032 
0033     // hunt down track
0034     SvtxTrack* trkToFind = nullptr;
0035     for (
0036       SvtxTrackMap::Iter itTrk = map -> begin();
0037       itTrk != map -> end();
0038       ++itTrk
0039     ) {
0040 
0041       // grab track
0042       SvtxTrack* track = itTrk -> second;
0043       if (!track) continue;
0044 
0045       // check id, break if found
0046       if (idToFind == track -> get_id()) {
0047         trkToFind = track;
0048         break;
0049       }
0050     }  // end track loop
0051     return trkToFind;
0052 
0053   }  // end 'FindTrack(uint32_t, PHCompositeNode*)'
0054 
0055 
0056 
0057   // --------------------------------------------------------------------------
0058   //! Find PFO based on provided ID
0059   // --------------------------------------------------------------------------
0060   ParticleFlowElement* Interfaces::FindFlow(const uint32_t idToFind, PHCompositeNode* topNode) {
0061 
0062     // grab pfo container
0063     ParticleFlowElementContainer* flows = Interfaces::GetFlowStore(topNode);
0064 
0065     // hunt down pfo
0066     ParticleFlowElement* pfoToFind = nullptr;
0067     for (
0068       ParticleFlowElementContainer::ConstIterator itFlow = flows -> getParticleFlowElements().first;
0069       itFlow != flows -> getParticleFlowElements().second;
0070       ++itFlow
0071     ) {
0072 
0073       // get pf element
0074       ParticleFlowElement* flow = itFlow -> second;
0075       if (!flow) continue;
0076 
0077       // check id, break if found
0078       if (idToFind == flow -> get_id()) {
0079         pfoToFind = flow;
0080         break;
0081       }
0082     }  // end pfo loop
0083     return pfoToFind;
0084 
0085   }  // end 'FindFlow(uint32_t, PHCompositeNode*)'
0086 
0087 
0088 
0089   // --------------------------------------------------------------------------
0090   //! Find RawTower based on provided ID
0091   // --------------------------------------------------------------------------
0092   RawTower* Interfaces::FindRawTower(const uint32_t idToFind, const Jet::SRC source, PHCompositeNode* topNode) {
0093 
0094     // grab relevant raw towers
0095     RawTowerContainer::ConstRange towers = Interfaces::GetRawTowers(topNode, Const::MapSrcOntoNode()[source]);
0096 
0097     // hunt down tower
0098     RawTower* twrToFind = nullptr;
0099     for (
0100       RawTowerContainer::ConstIterator itTwr = towers.first;
0101       itTwr != towers.second;
0102       ++itTwr
0103     ) {
0104 
0105       // get tower
0106       RawTower* tower = itTwr -> second;
0107       if (!tower) continue;
0108 
0109       // check id, break if found
0110       if (idToFind == tower -> get_id()) {
0111         twrToFind = tower;
0112         break;
0113       }
0114     }  // end tower loop
0115     return twrToFind;
0116 
0117   }  // end 'FindRawTower(uint32_t, Jet::SRC, PHCompositeNode*)'
0118 
0119 
0120 
0121   // --------------------------------------------------------------------------
0122   //! Find TowerInfo based on provided ID
0123   // --------------------------------------------------------------------------
0124   TowerInfo* Interfaces::FindTowerInfo(const uint32_t idToFind, const Jet::SRC source, PHCompositeNode* topNode) {
0125 
0126     // grab relevant tower info container
0127     TowerInfoContainer* towers = Interfaces::GetTowerInfoStore(topNode, Const::MapSrcOntoNode()[source]);
0128 
0129     // hunt down tower
0130     TowerInfo* twrToFind = nullptr;
0131     for (uint32_t channel = 0; channel < towers -> size(); channel++) {
0132 
0133       // get tower
0134       TowerInfo* tower = towers -> get_tower_at_channel(channel);
0135       if (!tower) continue;
0136 
0137       // check id (channel), break if found
0138       if (idToFind == channel) {
0139         twrToFind = tower;
0140         break;
0141       }
0142     }  // end tower loop
0143     return twrToFind;
0144 
0145   }  // end 'FindTowerInfo(uint32_t, Jet::SRC, PHCompositeNode*)'
0146 
0147 
0148 
0149   // --------------------------------------------------------------------------
0150   //! Find RawCluster based on provided ID
0151   // --------------------------------------------------------------------------
0152   RawCluster* Interfaces::FindCluster(const uint32_t idToFind, const Jet::SRC source, PHCompositeNode* topNode) {
0153 
0154     // grab relevant clusters
0155     RawClusterContainer::ConstRange clusters = Interfaces::GetClusters(topNode, Const::MapSrcOntoNode()[source]);
0156 
0157     // hunt down cluster
0158     RawCluster* clustToFind = nullptr;
0159     for (
0160       RawClusterContainer::ConstIterator itClust = clusters.first;
0161       itClust != clusters.second;
0162       ++itClust
0163     ) {
0164 
0165       // get cluster
0166       RawCluster* cluster = itClust -> second;
0167       if (!cluster) continue;
0168 
0169       // check id, break if found
0170       if (idToFind == cluster -> get_id()) {
0171         clustToFind = cluster;
0172         break;
0173       }
0174     }  // end cluster loop
0175     return clustToFind;
0176 
0177   }  // end 'FindCluster(uint32_t, Jet::SRC, PHCompositeNode*)'
0178 
0179 
0180 
0181   // --------------------------------------------------------------------------
0182   //! Find PHG4Particle based on provided ID
0183   // --------------------------------------------------------------------------
0184   PHG4Particle* Interfaces::FindParticle(const int32_t idToFind, PHCompositeNode* topNode) {
0185 
0186     // grab primary particles
0187     PHG4TruthInfoContainer::ConstRange primaries = Interfaces::GetPrimaries(topNode);
0188 
0189     // hunt down particle
0190     PHG4Particle* parToFind = nullptr;
0191     for (
0192       PHG4TruthInfoContainer::ConstIterator itPar = primaries.first;
0193       itPar != primaries.second;
0194       ++itPar
0195     ) {
0196 
0197       // grab particle
0198       PHG4Particle* particle = itPar -> second;
0199       if (!particle) continue;
0200 
0201       // check id, break if found
0202       if (idToFind == particle -> get_track_id()) {
0203         parToFind = particle;
0204         break;
0205       }
0206     }  // end particle loop
0207     return parToFind;
0208 
0209   }  // end 'FindParticle(uint32_t, PHCompositeNode*)'
0210 
0211 }  // end SColdQcdCorrealtorAnalysis namespace
0212 
0213 // end ------------------------------------------------------------------------