Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Conversion.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Conversion.h
1 
9 #ifndef CONVERSION_H__
10 #define CONVERSION_H__
11 
12 #include <g4main/PHG4Particle.h>
13 #include <g4main/PHG4VtxPoint.h>
15 #include <trackbase_historic/SvtxClusterMap.h>
16 #include <trackbase_historic/SvtxVertex.h>
17 #include <g4eval/SvtxTrackEval.h>
18 #include <GenFit/GFRaveVertex.h>
19 #include <TLorentzVector.h>
20 #include <TVector3.h>
21 #include <utility>
22 
23 namespace PHGenFit {
24  class Track;
25 } /* namespace PHGenFit */
26 
27 
28 class SvtxTrackEval;
29 class PHCompositeNode;
31 class TLorentzVector;
32 class SvtxHitMap;
33 class SVReco;
34 class VtxRegressor;
35 
36 //TODO check function to see ifthey can be made const
38 {
39  public:
44  ~Conversion();
48  void setElectron(PHG4Particle* e);
49  inline void setTrackEval(SvtxTrackEval *trackeval){this->trackeval=trackeval;}
50  inline void setVtx(PHG4VtxPoint* vtx){this->vtx=vtx;}
51  inline PHG4VtxPoint* getVtx()const{return vtx;}
53  inline bool isComplete()const{
54  if (e1&&e2&&photon)
55  {
56  return true;
57  }
58  else{
59  return false;
60  }
61  }
63  inline bool hasPair()const{
64  if (e1&&e2)
65  {
66  return true;
67  }
68  else{
69  return false;
70  }
71  }
73  bool setParent(PHG4Particle* parent);
74 
76  void setPrimaryPhoton(PHG4Particle* parent,PHG4TruthInfoContainer* truthinfo);
77 
79  inline int recoCount()const{
80  int r=0;
81  if (reco1)
82  {
83  r++;
84  }
85  if (reco2)
86  {
87  r++;
88  }
89  return r;
90  }
94  inline PHG4Particle* getElectron()const{return e1;}
98  inline PHG4Particle* getPositron()const{return e2;}
99  inline PHG4Particle* getPhoton()const{return photon;}
101  inline int getEmbed() const {return embedID;}
102 
103  inline void setEmbed(int embedID) {this->embedID=embedID;}
104  inline void setSourceId(int source){sourceId=source;}
105  inline int getSourceId()const{return sourceId;}
109  float trackDEta()const;
110  static float trackDEta(SvtxTrack* reco1, SvtxTrack* reco2);
113  inline float trackDPhi()const{
114  if (recoCount()==2)
115  {
116  return DeltaPhi(reco1->get_phi(),reco2->get_phi());
117  }
118  else return -1.;
119  }
120  inline static float trackDPhi(SvtxTrack* reco1, SvtxTrack* reco2){
121  return DeltaPhi(reco1->get_phi(),reco2->get_phi());
122  }
124  float minTrackpT();
125  std::pair<float,float> getTrackpTs();
126  std::pair<float,float> getTrackEtas();
127  std::pair<float,float> getTrackPhis();
128  inline std::pair<SvtxTrack*,SvtxTrack*> getRecoTracks()const{
129  return std::pair<SvtxTrack*,SvtxTrack*>(reco1,reco2);
130  }
132  SvtxTrack* getRecoTrack(unsigned truthID) const;
135  inline void setClusterMap(SvtxClusterMap* cmap){
136  _svtxClusterMap=cmap;
137  }
138  inline int setVerbosity(int v){
139  verbosity=v;
140  return verbosity;
141  }
146  int get_cluster_id();
149  int get_cluster_id()const;
157  std::pair<int,int> get_cluster_ids();
162  int setRecoTracks();
166  void setRecoTrack(int truthID, SvtxTrack* recoTrack);
171  bool setElectron();
174  int trackDLayer(SvtxClusterMap* cmap,SvtxHitMap *hitmap);
178  int firstLayer(SvtxClusterMap* cmap,SvtxHitMap *hitmap);
181  bool hasSilicon(SvtxClusterMap* );
184  double approachDistance()const;
185  static double approachDistance(SvtxTrack*,SvtxTrack*);
187  double dist(PHG4VtxPoint* vtx, SvtxClusterMap* cmap);
188  double dist(TVector3* vtx, SvtxClusterMap* cmap);
189  double dist(TVector3* vtx, TrkrClusterContainer* cmap);
191  float minDca();
193  float vtxTrackRPhi(TVector3 vertpos);
194  static float vtxTrackRPhi(TVector3 vertpos,SvtxTrack*,SvtxTrack*);
196  float vtxTrackRZ(TVector3 vertpos);
197  static float vtxTrackRZ(TVector3 vertpos,SvtxTrack*,SvtxTrack*);
198 
199  //Deprecated
200  //float setRecoVtx(SvtxVertex* recovtx,SvtxClusterMap* cmap);
201  TLorentzVector* setRecoPhoton();
202  TLorentzVector* getRecoPhoton();
203  static TLorentzVector* getRecoPhoton(SvtxTrack* reco1, SvtxTrack* reco2);
204 
205  TLorentzVector* getRefitRecoPhoton();
207 
208  std::pair<PHGenFit::Track*,PHGenFit::Track*> refitTracks(SVReco* vertexer, SvtxVertex* recoVtx);
210  std::pair<PHGenFit::Track*,PHGenFit::Track*> refitTracks(SVReco* vertexer);
211 
213  std::pair<PHGenFit::Track*,PHGenFit::Track*> refitTracksTruthVtx(SVReco* vertexer);
215  std::pair<PHGenFit::Track*,PHGenFit::Track*> refitTracksTruthVtx(SVReco* vertexer,SvtxVertex* seedVtx);
216  //TODO Set {@link recoVertex} to the vertex reconstructed from {@link SVReco} using the reco tracks and @return {@link recoVertex}. @return NULL if {@link recoCount()}!=2. Delete any existing {@link recoVertex}
220  std::pair<PHGenFit::Track*,PHGenFit::Track*> getPHGFTracks(SVReco* vertexer);
221  /*Convertes {@link reco1} and {@link reco2} into a pair of TLorentzVector* using the electron mass.
222  * references {@link recoCount()} to determine which NULL values to @return
223  * Ownership is returned.**/
224  std::pair<TLorentzVector*,TLorentzVector*> getRecoTlvs();
225  /*Convertes {@link _refit_phgf_tracks} into a pair of TLorentzVector* using the electron mass.
226  * If either refit track is not defined @return will be a pair of NULL vectors
227  * Ownership is returned.**/
228  std::pair<TLorentzVector*,TLorentzVector*> getRefitRecoTlvs();
232  std::pair<PHG4Particle*,PHG4Particle*> getParticlesMissingTrack();
239  inline static double InTwoPi (double phi) {
240  while (phi < 0 || 2*TMath::Pi() <= phi) {
241  if (phi < 0) phi += 2*TMath::Pi();
242  else phi -= 2*TMath::Pi();
243  }
244  return phi;
245  }
246 
250  inline static double DeltaPhi (double phi1, double phi2) {
251  phi1 = InTwoPi(phi1);
252  phi2 = InTwoPi(phi2);
253  double dphi = abs(phi1 - phi2);
254  while (dphi > TMath::Pi()) dphi = abs (dphi - 2*TMath::Pi());
255  return dphi;
256  }
257 
259  void printTruth();
261  void printReco();
263  void PrintPhotonRecoInfo();
264  void PrintPhotonRecoInfo(TLorentzVector *tlv_photon,TLorentzVector *tlv_electron, TLorentzVector *tlv_positron,float mass);
265  private:
275  SvtxClusterMap* _svtxClusterMap=NULL;
277  TLorentzVector *recoPhoton=NULL;
278  std::pair<PHGenFit::Track*,PHGenFit::Track*> _refit_phgf_tracks;
279  std::pair<unsigned,unsigned> pairTruthReco1;
280  std::pair<unsigned,unsigned> pairTruthReco2;
281 
282  static const int _kNSiliconLayer =7;
283  int embedID=0;
285  int sourceId;
286  static const float _kElectronRestM;
288  static float vtxTrackRZ(TVector3 recoVertPos,SvtxTrack *track);
290  static float vtxTrackRPhi(TVector3 recoVertPos,SvtxTrack *track);
300  void PHG4VtxPointToSvtxVertex(SvtxVertex* seedVtx);
301 
302 };
303 #endif //CONVERSION_H__