Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:07

0001 #ifndef G4EVAL_DSTEMULATOR_H
0002 #define G4EVAL_DSTEMULATOR_H
0003 
0004 /*!
0005  * \file TrackEvaluation.h
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  */
0008 
0009 #include "DSTCompressor.h"
0010 
0011 #include <trackbase/ActsGeometry.h>
0012 #include <trackbase/TrkrDefs.h>
0013 #include <trackbase_historic/ActsTransformations.h>
0014 
0015 #include <fun4all/SubsysReco.h>
0016 
0017 #include <TRandom.h>
0018 
0019 #include <map>
0020 #include <set>
0021 #include <string>
0022 #include <vector>
0023 
0024 class PHG4Hit;
0025 class PHG4HitContainer;
0026 class PHG4Particle;
0027 class PHG4TruthInfoContainer;
0028 class SvtxTrack;
0029 class SvtxTrackMap;
0030 class TrackEvaluationContainerv1;
0031 class TrkrCluster;
0032 class TrkrClusterContainer;
0033 class TrkrClusterHitAssoc;
0034 class TrkrHitSetContainer;
0035 class TrkrHitTruthAssoc;
0036 
0037 class TFile;
0038 class TNtuple;
0039 
0040 class DSTEmulator : public SubsysReco
0041 {
0042  public:
0043   //! constructor
0044   DSTEmulator(const std::string& = "DSTEmulator",
0045               const std::string& filename = "DSTana.root",
0046               int nBits = 8,
0047               int sabotage = 0,
0048               bool compress = true);
0049 
0050   //! global initialization
0051   int Init(PHCompositeNode*) override;
0052 
0053   //! run initialization
0054   int InitRun(PHCompositeNode*) override;
0055 
0056   //! event processing
0057   int process_event(PHCompositeNode*) override;
0058 
0059   //! end of processing
0060   int End(PHCompositeNode*) override;
0061 
0062  private:
0063   //! load nodes
0064   int load_nodes(PHCompositeNode*);
0065 
0066   //! evaluate tracks
0067   void evaluate_tracks();
0068   float compress_dx(float in_val);
0069   float compress_dy(float in_val);
0070   // get geant hits associated to a cluster
0071   using G4HitSet = std::set<PHG4Hit*>;
0072   G4HitSet find_g4hits(TrkrDefs::cluskey) const;
0073   Acts::Vector3 getGlobalPosition(TrkrDefs::cluskey, TrkrCluster*) const;
0074   //! get G4Particle id of max contributor to a given track
0075   std::pair<int, int> get_max_contributor(SvtxTrack*) const;
0076 
0077   //! get embedded id for given g4track
0078   int get_embed(PHG4Particle*) const;
0079 
0080   //! evaluation node
0081   TrackEvaluationContainerv1* m_container = nullptr;
0082 
0083   //! hits
0084   TrkrHitSetContainer* m_hitsetcontainer = nullptr;
0085 
0086   //! clusters
0087   TrkrClusterContainer* m_cluster_map = nullptr;
0088 
0089   //! cluster to hit association
0090   TrkrClusterHitAssoc* m_cluster_hit_map = nullptr;
0091 
0092   //! hit to truth association
0093   TrkrHitTruthAssoc* m_hit_truth_map = nullptr;
0094 
0095   //! tracks
0096   SvtxTrackMap* m_track_map = nullptr;
0097 
0098   //!@name geant4 hits
0099   //@{
0100   PHG4HitContainer* m_g4hits_tpc = nullptr;
0101   PHG4HitContainer* m_g4hits_intt = nullptr;
0102   PHG4HitContainer* m_g4hits_mvtx = nullptr;
0103   PHG4HitContainer* m_g4hits_micromegas = nullptr;
0104   //@}
0105 
0106   //! truth information
0107   PHG4TruthInfoContainer* m_g4truthinfo = nullptr;
0108 
0109   // map cluster keys to g4hits
0110   using G4HitMap = std::map<TrkrDefs::cluskey, G4HitSet>;
0111   mutable G4HitMap m_g4hit_map;
0112 
0113   ActsGeometry* m_tGeometry = nullptr;
0114   ActsTransformations m_transform;
0115 
0116   TNtuple* _dst_data{};
0117 
0118   // output file
0119   std::string _filename;
0120   TFile* _tfile;
0121 
0122   DSTCompressor* m_compressor{};
0123 
0124   // Number of bits for the integer representation after compression
0125   int nBits = 8;
0126   // replace the decompressed residuals by a large number
0127   int sabotage = 0;
0128   // random seed
0129   TRandom rnd;
0130   // switch to apply the compressed residuals to cluster positions
0131   bool apply_compression = true;
0132 };
0133 
0134 #endif  // G4EVAL_DSTEMULATOR_H