ATLAS Offline Software
Loading...
Searching...
No Matches
VP1TruthVertexCollection::Imp::VertexHandle Class Reference
Collaboration diagram for VP1TruthVertexCollection::Imp::VertexHandle:

Public Member Functions

 VertexHandle (HepMC::ConstGenVertexPtr v, VP1TruthVertexCollection::Imp *dd)
 ~VertexHandle ()
void recheckCutStatus ()
void updateShape ()
HepMC::ConstGenVertexPtr vertex () const
SoLineSet * line () const
double quantityVal (const VertexCommonFlags::QUANTITY &q)

Private Member Functions

void ensureAttach (SoSeparator *collsep)
void ensureDetach (SoSeparator *collsep)
bool cut ()

Private Attributes

bool m_attached
HepMC::ConstGenVertexPtr m_vertex
SoLineSet * m_line
VP1TruthVertexCollection::Impm_d

Detailed Description

Definition at line 67 of file VP1TruthVertexCollection.cxx.

Constructor & Destructor Documentation

◆ VertexHandle()

◆ ~VertexHandle()

VP1TruthVertexCollection::Imp::VertexHandle::~VertexHandle ( )
inline

Definition at line 70 of file VP1TruthVertexCollection.cxx.

70{ if (m_line) m_line->unref(); }

Member Function Documentation

◆ cut()

bool VP1TruthVertexCollection::Imp::VertexHandle::cut ( )
inlineprivate

Definition at line 157 of file VP1TruthVertexCollection.cxx.

157 {
158
159 if (m_d->controller->truthCutPrimaryVertexOnly()&&this!=m_d->vertices.at(0))
160 return false;
161
162 if (!m_d->controller->truthCutAllowedEta().contains(m_vertex->position().eta()))
163 return false;
164
165 QPair<VertexCommonFlags::QUANTITY,VP1Interval> p = m_d->controller->truthCutQuantity();
166 if (!p.second.isAllR()) {
167 if (!p.second.contains(quantityVal(p.first)))
168 return false;
169 }
170
171 //We handle phi cut last:
172 double phi(m_vertex->position().phi());
173 for (const VP1Interval& i : m_d->controller->truthCutAllowedPhi()) {
174 if (i.contains(phi)||i.contains(phi+2*M_PI)||i.contains(phi-2*M_PI))
175 return true;
176 }
177 return false;
178 }
#define M_PI
Scalar phi() const
phi method
double quantityVal(const VertexCommonFlags::QUANTITY &q)

◆ ensureAttach()

void VP1TruthVertexCollection::Imp::VertexHandle::ensureAttach ( SoSeparator * collsep)
inlineprivate

Definition at line 140 of file VP1TruthVertexCollection.cxx.

140 {
141 if (m_attached)
142 return;
143 m_attached = true;
144 if (!m_line) {
145 m_line = new SoLineSet;
146 m_line->ref();
147 }
148 updateShape();
149 collsep->addChild(m_line);
150 }

◆ ensureDetach()

void VP1TruthVertexCollection::Imp::VertexHandle::ensureDetach ( SoSeparator * collsep)
inlineprivate

Definition at line 151 of file VP1TruthVertexCollection.cxx.

151 {
152 if (!m_attached)
153 return;
154 m_attached = false;
155 collsep->removeChild(m_line);
156 }

◆ line()

SoLineSet * VP1TruthVertexCollection::Imp::VertexHandle::line ( ) const
inline

Definition at line 113 of file VP1TruthVertexCollection.cxx.

113{ return m_line; }

◆ quantityVal()

double VP1TruthVertexCollection::Imp::VertexHandle::quantityVal ( const VertexCommonFlags::QUANTITY & q)
inline

Definition at line 115 of file VP1TruthVertexCollection.cxx.

115 {
116 //Find total 4-momentum of incoming particles
117 double px(0), py(0), pz(0), e(0);//HepMC::FourVector does NOT support operators + or += !!!!!!
118#ifdef HEPMC3
119 for (const auto& PartIn: m_vertex->particles_in()){
120#else
121 HepMC::GenVertex::particles_in_const_iterator itPartIn,itPartInE(m_vertex->particles_in_const_end());
122 for ( itPartIn = m_vertex->particles_in_const_begin();itPartIn!=itPartInE;++itPartIn) {
123 auto PartIn=*itPartIn;
124#endif
125 px +=PartIn->momentum().px();
126 py +=PartIn->momentum().py();
127 pz +=PartIn->momentum().pz();
128 e += PartIn->momentum().e();
129 }
130 const HepMC::FourVector mom(px,py,pz,e);
131 switch(q) {
132 case VertexCommonFlags::ENERGY: return e;
133 case VertexCommonFlags::MOMENTUM: return m_d->mag(mom);
134 case VertexCommonFlags::TRANSVERSE_MOM: return mom.perp();
135 default: // VertexCommonFlags::MASS:
136 return mom.m();
137 }
138 }

◆ recheckCutStatus()

void VP1TruthVertexCollection::Imp::VertexHandle::recheckCutStatus ( )
inline

Definition at line 72 of file VP1TruthVertexCollection.cxx.

72 {
73 bool cutval(cut());
74 if (cutval!=m_attached) {
75 if (cutval)
76 ensureAttach(m_d->theclass->collSep());
77 else
78 ensureDetach(m_d->theclass->collSep());
79 }
80 }

◆ updateShape()

void VP1TruthVertexCollection::Imp::VertexHandle::updateShape ( )
inline

Definition at line 81 of file VP1TruthVertexCollection.cxx.

81 {
82 if (!m_line)
83 return;
84 if (!m_attached) {
85 //invalidate...
86 }
87
88 SoVertexProperty *vertices = static_cast<SoVertexProperty *>(m_line->vertexProperty.getValue());
89 if (!vertices) {
90 vertices = new SoVertexProperty();
91 m_line->numVertices.set1Value(0,2);
92 m_line->numVertices.set1Value(1,2);
93 m_line->numVertices.set1Value(2,2);
94 m_line->vertexProperty = vertices;
95 }
96
97 QPair<VertexCommonFlags::QUANTITY,double> p = m_d->controller->truthCrossLength();
98 double extent;
99 if (p.second<0)
100 extent = -p.second;
101 else
102 extent = p.second * quantityVal(p.first);
103
104 double x(m_vertex->position().x()), y(m_vertex->position().y()), z(m_vertex->position().z());
105 vertices->vertex.set1Value ( 0,x-extent, y, z );
106 vertices->vertex.set1Value ( 1,x+extent, y,z );
107 vertices->vertex.set1Value ( 2, x,y-extent, z);
108 vertices->vertex.set1Value ( 3, x,y+extent, z );
109 vertices->vertex.set1Value ( 4, x, y,z-extent );
110 vertices->vertex.set1Value ( 5, x, y,z+extent );
111 }
#define y
#define x
#define z

◆ vertex()

HepMC::ConstGenVertexPtr VP1TruthVertexCollection::Imp::VertexHandle::vertex ( ) const
inline

Definition at line 112 of file VP1TruthVertexCollection.cxx.

112{ return m_vertex; }

Member Data Documentation

◆ m_attached

bool VP1TruthVertexCollection::Imp::VertexHandle::m_attached
private

Definition at line 179 of file VP1TruthVertexCollection.cxx.

◆ m_d

VP1TruthVertexCollection::Imp* VP1TruthVertexCollection::Imp::VertexHandle::m_d
private

Definition at line 182 of file VP1TruthVertexCollection.cxx.

◆ m_line

SoLineSet* VP1TruthVertexCollection::Imp::VertexHandle::m_line
private

Definition at line 181 of file VP1TruthVertexCollection.cxx.

◆ m_vertex

HepMC::ConstGenVertexPtr VP1TruthVertexCollection::Imp::VertexHandle::m_vertex
private

Definition at line 180 of file VP1TruthVertexCollection.cxx.


The documentation for this class was generated from the following file: