Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   VtxInterfaces.cc
0003  *  \author Derek Anderson
0004  *  \date   03.05.2024
0005  *
0006  *  Vertex-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_VTXINTERFACES_CC
0011 
0012 // namespace definition
0013 #include "VtxInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 using namespace findNode;
0018 
0019 
0020 
0021 // vertex interfaces ==========================================================
0022 
0023 namespace SColdQcdCorrelatorAnalysis {
0024 
0025   // --------------------------------------------------------------------------
0026   //! Get vertex map from node tree
0027   // --------------------------------------------------------------------------
0028   GlobalVertexMap* Interfaces::GetVertexMap(PHCompositeNode* topNode) {
0029 
0030     // get vertex map
0031     GlobalVertexMap* mapVtx = getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
0032 
0033     // check if good
0034     const bool isVtxMapGood = (mapVtx && !(mapVtx -> empty()));
0035     if (!isVtxMapGood) {
0036       cerr << PHWHERE
0037            << "PANIC: GlobalVertexMap node is missing or empty!\n"
0038            << "       Please turn on the do_global flag in the main macro in order to reconstruct the global vertex!"
0039            << endl;
0040       assert(isVtxMapGood);
0041     }
0042     return mapVtx;
0043 
0044   }  // end 'GetVertexMap(PHCompositeNode*)'
0045 
0046 
0047 
0048   // --------------------------------------------------------------------------
0049   //! Get a specific vertex from vertex map
0050   // -------------------------------------------------------------------------
0051   /*! If no index is provided, returns the primary
0052    *  vertex (stored as the 1st vertex in the map)
0053    */ 
0054   GlobalVertex* Interfaces::GetGlobalVertex(PHCompositeNode* topNode, optional<int> iVtxToGrab) {
0055 
0056     // get vertex map
0057     GlobalVertexMap* mapVtx = GetVertexMap(topNode);
0058 
0059     // get specified vertex
0060     GlobalVertex* vtx = NULL;
0061     if (iVtxToGrab.has_value()) {
0062       vtx = mapVtx -> get(iVtxToGrab.value());
0063     } else {
0064       vtx = mapVtx -> begin() -> second;
0065     }
0066 
0067     // check if good
0068     if (!vtx) {
0069       cerr << PHWHERE
0070            << "PANIC: no vertex!"
0071            << endl;
0072       assert(vtx);
0073     }
0074     return vtx;
0075 
0076   }  // end 'GetGlobalVertex(PHCompositeNode*, optional<int>)'
0077 
0078 
0079 
0080   // --------------------------------------------------------------------------
0081   //! Get primary vertex as a ROOT XYZVector
0082   // --------------------------------------------------------------------------
0083   ROOT::Math::XYZVector Interfaces::GetRecoVtx(PHCompositeNode* topNode) {
0084 
0085     const GlobalVertex* vtx = GetGlobalVertex(topNode);
0086     return ROOT::Math::XYZVector(vtx -> get_x(), vtx -> get_y(), vtx -> get_z());
0087 
0088   }  // end 'GetRecoVtx(PHCompositeNode*)'
0089 
0090 }  // end SColdQcdCorrealtorAnalysis namespace
0091 
0092 // end ------------------------------------------------------------------------