Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:02

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_PHG4VTXPOINTV2_H
0004 #define G4MAIN_PHG4VTXPOINTV2_H
0005 
0006 #include "PHG4VtxPointv1.h"
0007 
0008 #include "PHG4MCProcessDefs.h"
0009 
0010 #include <iostream>  // for cout, ostream
0011 
0012 class PHG4VtxPointv2 : public PHG4VtxPointv1
0013 {
0014  public:
0015   PHG4VtxPointv2() = default;
0016   PHG4VtxPointv2(const PHG4VtxPointv2& rhs) = default;
0017   PHG4VtxPointv2& operator=(const PHG4VtxPointv2&) = default;
0018   PHG4VtxPointv2(PHG4VtxPointv2&& rhs) = default;
0019   PHG4VtxPointv2& operator=(PHG4VtxPointv2&&) = default;
0020   explicit PHG4VtxPointv2(const PHG4VtxPoint* vtx)
0021     : PHG4VtxPointv1(vtx)
0022   {
0023   }
0024 
0025   PHG4VtxPointv2(const double x, const double y, const double z, const double t,
0026                  const int id_value = std::numeric_limits<int>::min(),
0027                  const PHG4MCProcess process = PHG4MCProcess::kPNoProcess)
0028     : PHG4VtxPointv1(x, y, z, t, id_value)
0029   {
0030     set_process(process);
0031   };
0032 
0033   ~PHG4VtxPointv2() override = default;
0034 
0035   // from PHObject
0036   void identify(std::ostream& os = std::cout) const override;
0037 
0038   /// set process property
0039   void set_process(int proc) override
0040   {
0041     auto prop = ((PropEncoding) mProp);
0042     prop.properties.process = proc;
0043     mProp = prop.i;
0044   }
0045 
0046   /// get the production process (id) of this track
0047   int get_process() const override { return ((PropEncoding) mProp).properties.process; }
0048   std::string_view getProdProcessAsString() const;
0049 
0050  protected:
0051   // internal structure to allow convenient manipulation
0052   // of properties as bits on an int
0053   union PropEncoding
0054   {
0055     explicit PropEncoding(int a)
0056       : i(a)
0057     {
0058     }
0059     int i;
0060     struct
0061     {
0062       int storage : 1;           // encoding whether to store this track to the output
0063       unsigned int process : 6;  // encoding process that created this track (enough to store TMCProcess from ROOT)
0064     } properties;
0065   };
0066 
0067  private:
0068   int mProp = 0;
0069 
0070   ClassDefOverride(PHG4VtxPointv2, 1)
0071 };
0072 
0073 inline std::string_view PHG4VtxPointv2::getProdProcessAsString() const
0074 {
0075   auto procID = get_process();
0076   if (procID >= 0)
0077   {
0078     return PHG4MCProcessName[procID];
0079   }
0080   else
0081   {
0082     return PHG4MCProcessName[PHG4MCProcess::kPNoProcess];
0083   }
0084 }
0085 
0086 #endif