ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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()

VP1TruthVertexCollection::Imp::VertexHandle::VertexHandle ( HepMC::ConstGenVertexPtr  v,
VP1TruthVertexCollection::Imp dd 
)
inline

Definition at line 69 of file VP1TruthVertexCollection.cxx.

69 : m_attached(false), m_vertex(v), m_line(0),m_d(dd) {}

◆ ~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  }

◆ 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)
77  else
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  }

◆ 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:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
VP1TruthVertexCollection::Imp::mag
double mag(const HepMC::FourVector &v) const
Definition: VP1TruthVertexCollection.cxx:58
VP1TruthVertexCollection::Imp::VertexHandle::m_line
SoLineSet * m_line
Definition: VP1TruthVertexCollection.cxx:181
test_pyathena.px
px
Definition: test_pyathena.py:18
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
VertexCommonFlags::MOMENTUM
@ MOMENTUM
Definition: VertexCommonFlags.h:37
VertexSysController::truthCutQuantity
QPair< VertexCommonFlags::QUANTITY, VP1Interval > truthCutQuantity() const
Definition: VertexSysController.cxx:281
VertexCommonFlags::ENERGY
@ ENERGY
Definition: VertexCommonFlags.h:37
VP1TruthVertexCollection::Imp::VertexHandle::ensureDetach
void ensureDetach(SoSeparator *collsep)
Definition: VP1TruthVertexCollection.cxx:151
VP1TruthVertexCollection::Imp::controller
VertexSysController * controller
Definition: VP1TruthVertexCollection.cxx:63
M_PI
#define M_PI
Definition: ActiveFraction.h:11
VP1TruthVertexCollection::Imp::VertexHandle::m_vertex
HepMC::ConstGenVertexPtr m_vertex
Definition: VP1TruthVertexCollection.cxx:180
x
#define x
VP1TruthVertexCollection::Imp::theclass
VP1TruthVertexCollection * theclass
Definition: VP1TruthVertexCollection.cxx:62
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
VertexSysController::truthCutPrimaryVertexOnly
bool truthCutPrimaryVertexOnly() const
Definition: VertexSysController.cxx:259
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
VP1TruthVertexCollection::Imp::VertexHandle::m_attached
bool m_attached
Definition: VP1TruthVertexCollection.cxx:179
VP1TruthVertexCollection::Imp::VertexHandle::ensureAttach
void ensureAttach(SoSeparator *collsep)
Definition: VP1TruthVertexCollection.cxx:140
VertexSysController::truthCrossLength
QPair< VertexCommonFlags::QUANTITY, double > truthCrossLength() const
Definition: VertexSysController.cxx:262
Amg::py
@ py
Definition: GeoPrimitives.h:39
VertexSysController::truthCutAllowedPhi
QList< VP1Interval > truthCutAllowedPhi() const
Definition: VertexSysController.cxx:258
VP1Interval::contains
bool contains(const double &x) const
VertexSysController::truthCutAllowedEta
VP1Interval truthCutAllowedEta() const
Definition: VertexSysController.cxx:257
library_scraper.dd
list dd
Definition: library_scraper.py:46
VP1TruthVertexCollection::Imp::VertexHandle::cut
bool cut()
Definition: VP1TruthVertexCollection.cxx:157
VertexCommonFlags::TRANSVERSE_MOM
@ TRANSVERSE_MOM
Definition: VertexCommonFlags.h:37
python.PyAthena.v
v
Definition: PyAthena.py:154
VP1Interval
Definition: VP1Interval.h:23
VP1TruthVertexCollection::Imp::VertexHandle::m_d
VP1TruthVertexCollection::Imp * m_d
Definition: VP1TruthVertexCollection.cxx:182
y
#define y
VP1TruthVertexCollection::Imp::vertices
QList< VertexHandle * > vertices
Definition: VP1TruthVertexCollection.cxx:185
VP1StdCollection::collSep
SoSeparator * collSep() const
All 3D objects from this coll.
Definition: VP1StdCollection.cxx:212
extractSporadic.q
list q
Definition: extractSporadic.py:98
VP1TruthVertexCollection::Imp::VertexHandle::quantityVal
double quantityVal(const VertexCommonFlags::QUANTITY &q)
Definition: VP1TruthVertexCollection.cxx:115
VP1TruthVertexCollection::Imp::VertexHandle::updateShape
void updateShape()
Definition: VP1TruthVertexCollection.cxx:81