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 64 of file VP1TruthVertexCollection.cxx.

Constructor & Destructor Documentation

◆ VertexHandle()

◆ ~VertexHandle()

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

Definition at line 67 of file VP1TruthVertexCollection.cxx.

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

Member Function Documentation

◆ cut()

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

Definition at line 148 of file VP1TruthVertexCollection.cxx.

148 {
149
150 if (m_d->controller->truthCutPrimaryVertexOnly()&&this!=m_d->vertices.at(0))
151 return false;
152
153 if (!m_d->controller->truthCutAllowedEta().contains(m_vertex->position().eta()))
154 return false;
155
156 QPair<VertexCommonFlags::QUANTITY,VP1Interval> p = m_d->controller->truthCutQuantity();
157 if (!p.second.isAllR()) {
158 if (!p.second.contains(quantityVal(p.first)))
159 return false;
160 }
161
162 //We handle phi cut last:
163 double phi(m_vertex->position().phi());
164 for (const VP1Interval& i : m_d->controller->truthCutAllowedPhi()) {
165 if (i.contains(phi)||i.contains(phi+2*M_PI)||i.contains(phi-2*M_PI))
166 return true;
167 }
168 return false;
169 }
#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 131 of file VP1TruthVertexCollection.cxx.

131 {
132 if (m_attached)
133 return;
134 m_attached = true;
135 if (!m_line) {
136 m_line = new SoLineSet;
137 m_line->ref();
138 }
139 updateShape();
140 collsep->addChild(m_line);
141 }

◆ ensureDetach()

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

Definition at line 142 of file VP1TruthVertexCollection.cxx.

142 {
143 if (!m_attached)
144 return;
145 m_attached = false;
146 collsep->removeChild(m_line);
147 }

◆ line()

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

Definition at line 110 of file VP1TruthVertexCollection.cxx.

110{ return m_line; }

◆ quantityVal()

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

Definition at line 112 of file VP1TruthVertexCollection.cxx.

112 {
113 //Find total 4-momentum of incoming particles
114 double px(0), py(0), pz(0), e(0);//HepMC::FourVector does NOT support operators + or += !!!!!!
115 for (const auto& PartIn: m_vertex->particles_in()){
116 px +=PartIn->momentum().px();
117 py +=PartIn->momentum().py();
118 pz +=PartIn->momentum().pz();
119 e += PartIn->momentum().e();
120 }
121 const HepMC::FourVector mom(px,py,pz,e);
122 switch(q) {
123 case VertexCommonFlags::ENERGY: return e;
124 case VertexCommonFlags::MOMENTUM: return mom.length();
125 case VertexCommonFlags::TRANSVERSE_MOM: return mom.perp();
126 default: // VertexCommonFlags::MASS:
127 return mom.m();
128 }
129 }
HepMC3::FourVector FourVector

◆ recheckCutStatus()

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

Definition at line 69 of file VP1TruthVertexCollection.cxx.

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

◆ updateShape()

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

Definition at line 78 of file VP1TruthVertexCollection.cxx.

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

◆ vertex()

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

Definition at line 109 of file VP1TruthVertexCollection.cxx.

109{ return m_vertex; }

Member Data Documentation

◆ m_attached

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

Definition at line 170 of file VP1TruthVertexCollection.cxx.

◆ m_d

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

Definition at line 173 of file VP1TruthVertexCollection.cxx.

◆ m_line

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

Definition at line 172 of file VP1TruthVertexCollection.cxx.

◆ m_vertex

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

Definition at line 171 of file VP1TruthVertexCollection.cxx.


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