Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:12

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