HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hparticlegeant.cc
Go to the documentation of this file.
1 #include "hparticlegeant.h"
2 #include "hparticlegeantdecay.h"
3 #include "hparticlecandsim.h"
4 
5 #include <algorithm>
6 #include <iostream>
7 #include <iomanip>
8 
9 using namespace std;
10 
11 
13 
14 //_HADES_CLASS_DESCRIPTION
15 ////////////////////////////////////////////////////////////////////////////////
16 //
17 //
18 // HParticleGeant
19 //
20 // Simulation object keeping HGeant pointers and pointers to decays and
21 // reconstructed HParticleCand objects for this geant track.
22 // For documentation of use case see the documentation of
23 // HParticleGeantEvent.
24 ////////////////////////////////////////////////////////////////////////////////
25 
27 {
28  clear();
29 }
31 {
32  ;
33 }
34 
36 {
37  // sets kine pointer of particle
38  // the vertex and the acceptance flag
39  fparticle = part;
40  part->getVertex(fdecayVertex);
41  fInAcceptance = part->isInAcceptance();
42 }
44 {
45  if(!primVer) return fdecayVertex.length();
46  else {
47  HGeomVector diff = *primVer + fdecayVertex;
48  return diff.length();
49  }
50 }
51 
53 {
54  // adds a candidate to the list of recontructed
55  // candidates if it is not already in the list
56  if(find(vReco.begin(),vReco.end(),c)==vReco.end()) vReco.push_back(c);
57 }
58 
60 {
61  return vReco.size();
62 }
63 
65 {
66 
67  // return the number of reconstructed candidates matching
68  // this geant object which are flagged kIsUsed
69  Int_t ct = 0 ;
70  for(UInt_t i =0; i < vReco.size(); i++){
71  if(!vReco[i]->isFlagBit(kIsUsed)) continue; // only count used particles
72  ct++;
73  }
74  return ct;
75 }
76 
77 UInt_t HParticleGeant::getNGhosts(Bool_t isUsed)
78 {
79  // return the number of reconstructed candidates matching
80  // this geant object which are flagged kIsUsed (if isUsed=kTRUE, default=kFALSE)
81  // and are marked as Ghosts
82  Int_t ct = 0 ;
83  for(UInt_t i =0; i < vReco.size(); i++){
84  if(isUsed && !vReco[i]->isFlagBit(kIsUsed)) continue; // only count used particles
85  if(vReco[i]->isGhostTrack()) ct++;
86  }
87  return ct;
88 }
89 
90 UInt_t HParticleGeant::getNTrueReco(Bool_t isUsed,UInt_t detbits)
91 {
92  // return the number of reconstructed candidates matching
93  // this geant object which are flagged kIsUsed (if isUsed=kTRUE, default=kTRUE)
94  // and are not marked as Ghosts and fullfill the detector bits
95  // (default == kIsInInnerMDC|kIsInOuterMDC|kIsInMETA, = 0 will ignore)
96  Int_t ct = 0 ;
97  for(UInt_t i =0; i < vReco.size(); i++){
98  if(isUsed && !vReco[i]->isFlagBit(kIsUsed)) continue; // only count used particles
99  if( (detbits==0 || vReco[i]->isInDetectors(detbits)) && !vReco[i]->isGhostTrack()) ct++;
100  }
101  return ct;
102 }
103 
105 {
106  // prints some basic infos about this particle
107  cout<<"HParticleGeant: generation "<< setw(3)<<fgeneration<< " ##################################"<<endl;
108  if(fparticle) fparticle->print();
109  if(fmotherDecay) cout<<"mother ID "<< setw(3)<<fmotherDecay->getMotherID() ;
110  cout<<"n reco "<< setw(3)<<vReco.size()<<"n reco used "<<setw(3)<<getNRecoUsedCand()<<" n true "<<setw(3)<<getNTrueReco()<<" n ghost "<<setw(3)<<getNGhosts()<<endl;
111 }
112 
114 {
115  // resets all internal varibales
116  fparticle = 0;
117  fmother = 0;
118  fgeneration = 0;
119  fmotherDecay= 0;
120  fdecayVertex.setXYZ(-1000,-1000,-1000);
121  vReco.clear();
122  fInAcceptance = kFALSE;
123 
124 }
void getVertex(Float_t &ax, Float_t &ay, Float_t &az)
Definition: hgeantkine.cc:210
void addRecoCand(HParticleCandSim *c)
UInt_t getNTrueReco(Bool_t isUsed=kTRUE, UInt_t detbits=kIsInInnerMDC|kIsInOuterMDC|kIsInMETA)
Float_t getDistFromVertex(HGeomVector *primVer=0)
Bool_t isInAcceptance(Int_t m0=4, Int_t m1=4, Int_t m2=4, Int_t m3=4, Int_t sys0=1, Int_t sys1=1)
Definition: hgeantkine.cc:991
void setParticle(HGeantKine *part)
Double_t length() const
Definition: hgeomvector.h:53
UInt_t getNGhosts(Bool_t isUsed=kFALSE)
UInt_t getNRecoUsedCand()
UInt_t getNRecoCand()
ClassImp(HParticleGeant) HParticleGeant