CMS 3D CMS Logo

FSimTrack.cc
Go to the documentation of this file.
2 
3 //C++ Headers
4 #include <iomanip>
5 #include <string>
6 
7 //using namespace HepPDT;
8 
10  SimTrack(), mom_(nullptr), id_(-1), charge_(-999), endv_(-1),
11  layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), hcalexit(0), hoentr(0),
12  prop(false), closestDaughterId_(-1), info_(nullptr),
13  properDecayTime(1E99) {;}
14 
16  int iv, int ig, int id,
17  FBaseSimEvent* mom,
18  double dt) :
19  // SimTrack(p->pid(),*p,iv,ig), // to uncomment once Mathcore is installed
20  SimTrack(p->pid(),p->momentum(),iv,ig),
21  mom_(mom), id_(id), charge_(-999), endv_(-1),
22  layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), hcalexit(0), hoentr(0), prop(false),
24  properDecayTime(dt)
25 {
26  setTrackId(id);
27  info_ = mom_->theTable()->particle(HepPDT::ParticleID(type()));
28 }
29 
30 
32 FSimTrack::FSimTrack(int ipart, const math::XYZTLorentzVector& p, int iv, int ig, int id, double charge, const math::XYZTLorentzVector& tkp, const math::XYZTLorentzVector& tkm, const SimVertex& tkv) :
33  SimTrack(ipart, p, iv, ig, math::XYZVectorD(tkp.X(), tkp.Y(), tkp.Z()), tkm), vertex_(tkv),
34  mom_(nullptr), id_(id), charge_(charge), endv_(-1),
35  layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), hcalexit(0), hoentr(0), prop(false),
37  properDecayTime(-1)
38  {
39  setTrackId(id);
40  }
41 
43 
44 bool
46  // If there is no end vertex, nothing to compare to
47  if ( noEndVertex() ) return true;
48  // If the particle immediately decays, no need to propagate
49  if ( (endVertex().position()-vertex().position()).Vect().Mag2() < 1e-4 )
50  return false;
51  // If the end vertex has a larger radius, not yet there
52  if ( endVertex().position().Perp2() > pos.Perp2()+1e-10 ) return true;
53  // If the end vertex has a larger z, not yet there
54  if ( fabs(endVertex().position().Z()) > fabs(pos.Z())+1e-5 ) return true;
55  // Otherwise, the end vertex is overtaken already
56  return false;
57 }
58 
60 void
62  prop=true;
63 }
64 
66 void
69  layer1=success;
70 }
71 
73 void
76  layer2=success;
77 }
78 
80 void
83  ecal=success;
84 }
85 
87 void
90  hcal=success;
91 }
92 
94 void
97  vfcal=success;
98 }
99 
101 void
103  HCAL_Exit=pp;
104  hcalexit=success;
105 }
106 
107 void
109  HO_Entrance=pp;
110  hoentr=success;
111 }
112 
113 
114 
115 
116 
117 
118 std::ostream& operator <<(std::ostream& o , const FSimTrack& t) {
119  std::string name = t.particleInfo() ? t.particleInfo()->name() : "Unknown";
120  const XYZTLorentzVector& momentum1 = t.momentum();
121  XYZVector vertex1 = t.vertex().position().Vect();
122  int vertexId1 = t.vertex().id();
123 
124  o.setf(std::ios::fixed, std::ios::floatfield);
125  o.setf(std::ios::right, std::ios::adjustfield);
126 
127  o << std::setw(4) << t.id() << "; "
128  << std::setw(4) << t.genpartIndex() << "; "
129  << name << "\n\t\t";
130 
131  //for(unsigned int k=0;k<11-name.length() && k<12; k++) o << "; ";
132 
133  o << "Position: "
134  << std::setw(6) << std::setprecision(2) << momentum1.eta() << "; "
135  << std::setw(6) << std::setprecision(2) << momentum1.phi() << "; "
136  << std::setw(6) << std::setprecision(2) << momentum1.pt() << "; "
137  << std::setw(6) << std::setprecision(2) << momentum1.e() << "; "
138  << std::setw(4) << vertexId1 << "; "
139  << std::setw(6) << std::setprecision(1) << vertex1.x() << "; "
140  << std::setw(6) << std::setprecision(1) << vertex1.y() << "; "
141  << std::setw(6) << std::setprecision(1) << vertex1.z() << "; "
142  << std::setw(4) << (t.particleInfo() ? (t.noMother() ? -1 :t.mother().id()) :-1) << "; " << "\n\t\t";
143 
144  if ( !t.noEndVertex() ) {
145  XYZTLorentzVector vertex2 = t.endVertex().position();
146  int vertexId2 = t.endVertex().id();
147 
148  o << "Decayed particle: "
149  << std::setw(4) << vertexId2 << "; "
150  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
151  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
152  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
153  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; ";
154  for (int i=0; i<t.nDaughters(); ++i)
155  o << std::setw(4) << t.daughter(i).id() << "; " << "\n\t\t";
156 
157  } else {
158 
159  if ( t.onLayer1() ) {
160 
161  XYZTLorentzVector vertex2 = t.layer1Entrance().vertex();
162 
163  o << "Layer 1: "
164  << std::setw(4) << -t.onLayer1() << "; "
165  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
166  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
167  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
168  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "
169  << std::setw(6) << std::setprecision(2) << t.layer1Entrance().pt() << "; "
170  << std::setw(6) << std::setprecision(2) << t.layer1Entrance().e() << "; " << "\n\t\t";
171 
172  } if ( t.onLayer2() ) {
173 
174  XYZTLorentzVector vertex2 = t.layer2Entrance().vertex();
175 
176  o << "Layer 2: "
177  << std::setw(4) << -t.onLayer2() << "; "
178  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
179  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
180  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
181  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "
182  << std::setw(6) << std::setprecision(2) << t.layer2Entrance().pt() << "; "
183  << std::setw(6) << std::setprecision(2) << t.layer2Entrance().e() << "; " << "\n\t\t";
184 
185  }
186  //if ( t.onEcal() ) {
187 
188  XYZTLorentzVector vertex2 = t.ecalEntrance().vertex();
189 
190  o << "ECAL: "
191  << std::setw(4) << -t.onEcal() << "; "
192  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
193  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
194  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
195  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "
196  << std::setw(6) << std::setprecision(2) << t.ecalEntrance().pt() << "; "
197  << std::setw(6) << std::setprecision(2) << t.ecalEntrance().e() << "; " << "\n\t\t";
198  //}
199  //if ( t.onHcal() ) {
200 
201  vertex2 = t.hcalEntrance().vertex();
202 
203  o << "HCAL: "
204  << std::setw(4) << -t.onHcal() << "; "
205  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
206  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
207  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
208  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "
209  << std::setw(6) << std::setprecision(2) << t.hcalEntrance().pt() << "; "
210  << std::setw(6) << std::setprecision(2) << t.hcalEntrance().e() << "; " << "\n\t\t";
211  //}
212  //if ( t.onVFcal() ) {
213 
214  vertex2 = t.vfcalEntrance().vertex();
215 
216  o << "VFCAL: "
217  << std::setw(4) << -t.onVFcal() << "; "
218  << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; "
219  << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; "
220  << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; "
221  << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "
222  << std::setw(6) << std::setprecision(2) << t.vfcalEntrance().pt() << "; "
223  << std::setw(6) << std::setprecision(2) << t.vfcalEntrance().e() << "; " << "\n\t\t";
224  //}
225  }
226  return o;
227 }
int id() const
the index in FBaseSimEvent
Definition: FSimVertex.h:44
SimVertex vertex_
Definition: FSimTrack.h:212
float dt
Definition: AMPTWrapper.h:126
bool noEndVertex() const
no end vertex
int endv_
Definition: FSimTrack.h:219
float charge() const
charge
Definition: FSimTrack.h:51
const HepPDT::ParticleData * particleInfo() const
particle info...
Definition: FSimTrack.h:46
const RawParticle & vfcalEntrance() const
The particle at VFCAL entrance.
Definition: FSimTrack.h:144
int onLayer2() const
Definition: FSimTrack.h:101
int layer2
Definition: FSimTrack.h:222
const FSimVertex & endVertex() const
end vertex
int ecal
Definition: FSimTrack.h:223
RawParticle Layer1_Entrance
Definition: FSimTrack.h:232
double charge_
Definition: FSimTrack.h:217
const HepPDT::ParticleData * info_
Definition: FSimTrack.h:244
RawParticle VFCAL_Entrance
Definition: FSimTrack.h:236
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
Definition: FSimTrack.h:198
virtual ~FSimTrack()
Destructor.
Definition: FSimTrack.cc:42
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
Definition: FBaseSimEvent.h:57
int hoentr
Definition: FSimTrack.h:227
const RawParticle & layer1Entrance() const
The particle at Preshower Layer 1.
Definition: FSimTrack.h:132
const FSimTrack & daughter(int i) const
Ith daughter.
void setEcal(const RawParticle &pp, int success)
Set the ecal variables.
Definition: FSimTrack.cc:81
#define X(str)
Definition: MuonsGrabber.cc:48
RawParticle HO_Entrance
Definition: FSimTrack.h:238
void setPropagate()
The particle has been propgated through the tracker.
Definition: FSimTrack.cc:61
RawParticle HCAL_Exit
Definition: FSimTrack.h:237
int nDaughters() const
Number of daughters.
void setLayer2(const RawParticle &pp, int success)
Set the preshower layer2 variables.
Definition: FSimTrack.cc:74
#define nullptr
bool notYetToEndVertex(const XYZTLorentzVector &pos) const
Compare the end vertex position with another position.
Definition: FSimTrack.cc:45
int onEcal() const
Definition: FSimTrack.h:106
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setLayer1(const RawParticle &pp, int success)
Set the preshower layer1 variables.
Definition: FSimTrack.cc:67
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
math::XYZVector XYZVector
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
Definition: FSimVertex.h:49
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
Definition: SimTrack.h:33
int closestDaughterId_
Definition: FSimTrack.h:242
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
Definition: FSimTrack.h:138
int onVFcal() const
Definition: FSimTrack.h:116
int vfcal
Definition: FSimTrack.h:225
FSimTrack()
Default constructor.
Definition: FSimTrack.cc:9
int layer1
Definition: FSimTrack.h:221
Definition: Error.h:16
FBaseSimEvent * mom_
Definition: FSimTrack.h:214
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:285
RawParticle HCAL_Entrance
Definition: FSimTrack.h:235
void setTrackId(unsigned int t)
Definition: CoreSimTrack.h:33
void setHcalExit(const RawParticle &pp, int success)
Set the hcal exit variables.
Definition: FSimTrack.cc:102
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
XYZTLorentzVector momentum_
Definition: FSimTrack.h:246
static int position[264][3]
Definition: ReadPGInfo.cc:509
int id() const
the index in FBaseSimEvent and other vectors
Definition: FSimTrack.h:91
const RawParticle & layer2Entrance() const
The particle at Preshower Layer 2.
Definition: FSimTrack.h:135
int onLayer1() const
Definition: FSimTrack.h:96
void setHO(const RawParticle &pp, int success)
Set the ho variables.
Definition: FSimTrack.cc:108
int onHcal() const
Definition: FSimTrack.h:111
void setVFcal(const RawParticle &pp, int success)
Set the hcal variables.
Definition: FSimTrack.cc:95
bool noMother() const
no mother particle
const RawParticle & hcalEntrance() const
The particle at HCAL entrance.
Definition: FSimTrack.h:141
RawParticle Layer2_Entrance
Definition: FSimTrack.h:233
void setHcal(const RawParticle &pp, int success)
Set the hcal variables.
Definition: FSimTrack.cc:88
const FSimVertex vertex() const
Origin vertex.
double properDecayTime
Definition: FSimTrack.h:248
int hcalexit
Definition: FSimTrack.h:226
bool prop
Definition: FSimTrack.h:230
RawParticle ECAL_Entrance
Definition: FSimTrack.h:234
const FSimTrack & mother() const
mother
std::ostream & operator<<(std::ostream &o, const FSimTrack &t)
Definition: FSimTrack.cc:118
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15