26#include <Inventor/nodes/SoLineSet.h>
27#include <Inventor/nodes/SoVertexProperty.h>
28#include <Inventor/SoPath.h>
29#include <Inventor/nodes/SoSeparator.h>
38#include "GaudiKernel/SystemOfUnits.h"
45 QList<VP1StdCollection*> l;
58 double mag(
const HepMC::FourVector& v)
const {
59 return std::sqrt( v.x()*v.x() + v.y()*v.y() + v.z()*v.z() );
65 SoLineSet *
createCross(
const double&
x,
const double&
y,
const double&
z,
const double& extent = 10*Gaudi::Units::mm );
88 SoVertexProperty *
vertices =
static_cast<SoVertexProperty *
>(
m_line->vertexProperty.getValue());
91 m_line->numVertices.set1Value(0,2);
92 m_line->numVertices.set1Value(1,2);
93 m_line->numVertices.set1Value(2,2);
97 QPair<VertexCommonFlags::QUANTITY,double> p =
m_d->controller->truthCrossLength();
117 double px(0), py(0), pz(0), e(0);
119 for (
const auto& PartIn:
m_vertex->particles_in()){
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;
125 px +=PartIn->momentum().px();
126 py +=PartIn->momentum().py();
127 pz +=PartIn->momentum().pz();
128 e += PartIn->momentum().e();
130 const HepMC::FourVector mom(px,py,pz,e);
149 collsep->addChild(
m_line);
155 collsep->removeChild(
m_line);
159 if (
m_d->controller->truthCutPrimaryVertexOnly()&&
this!=
m_d->vertices.at(0))
162 if (!
m_d->controller->truthCutAllowedEta().contains(
m_vertex->position().eta()))
165 QPair<VertexCommonFlags::QUANTITY,VP1Interval> p =
m_d->controller->truthCutQuantity();
166 if (!p.second.isAllR()) {
173 for (
const VP1Interval& i :
m_d->controller->truthCutAllowedPhi()) {
194 m_d->theclass =
this;
195 m_d->controller = controller;
197 connect(controller,SIGNAL(truthCutAllowedPhiChanged(
const QList<VP1Interval>&)),
this,SLOT(
recheckAllCuts()));
198 connect(controller,SIGNAL(truthCutPrimaryVertexOnlyChanged(
bool)),
this,SLOT(
recheckAllCuts()));
199 connect(controller,SIGNAL(truthCutQuantityChanged(
const QPair<VertexCommonFlags::QUANTITY,VP1Interval>&)),
this,SLOT(
recheckAllCuts()));
200 connect(controller,SIGNAL(truthCrossLengthChanged(QPair<VertexCommonFlags::QUANTITY,double>)),
this,SLOT(
updateAllShapes()));
226 SoVertexProperty *
vertices =
new SoVertexProperty();
233 SoLineSet * line =
new SoLineSet();
234 line->numVertices.set1Value(0,2);
235 line->numVertices.set1Value(1,2);
236 line->numVertices.set1Value(2,2);
249 if (mcEventColl->
size()<1)
253 for (itEvent = mcEventColl->
begin(); itEvent != itEventEnd; ++itEvent) {
254 const HepMC::GenEvent* genEvent(*itEvent);
259 for (
const auto& vtx: genEvent->vertices()) {
261 HepMC::GenEvent::vertex_const_iterator itVertex, itVertexEnd(genEvent->vertices_end());
262 for (itVertex = genEvent->vertices_begin(); itVertex != itVertexEnd; ++itVertex ) {
280 SoNode * pickedNode = (pickedPath ? (pickedPath->getLength()>0?pickedPath->getNodeFromTail(0):0): 0);
284 if (vh->
line()==pickedNode) {
290 return QStringList() <<
"ERROR: Could not get truth vertex information for picked Node";
294 if (
m_d->controller->printInfoOnClick()) {
297 l <<
"Truth vertex from collection "+
text()+
":" ;
299 for (
const auto& PartIn: vtx->particles_in()) {
301 HepMC::GenVertex::particles_in_const_iterator itPartIn,itPartInE(vtx->particles_in_const_end());
302 for ( itPartIn = vtx->particles_in_const_begin();itPartIn!=itPartInE;++itPartIn) {
303 auto PartIn=*itPartIn;
305 const int pdg = PartIn->pdg_id();
310 l <<
"--> In: "+name+
" ("+
str(pdg)+
") [ P = "+
str(
m_d->mag(PartIn->momentum())/Gaudi::Units::GeV)+
" GeV ]";
313 for (
const auto& PartOut: vtx->particles_out()) {
315 HepMC::GenVertex::particles_out_const_iterator itPartOut,itPartOutE(vtx->particles_out_const_end());
316 for ( itPartOut = vtx->particles_out_const_begin();itPartOut!=itPartOutE;++itPartOut) {
317 auto PartOut=*itPartOut;
319 const int pdg = PartOut->pdg_id();
324 l <<
"--> Out: "+name+
" ("+
str(pdg)+
") [ P = "+
str(
m_d->mag(PartOut->momentum())/Gaudi::Units::GeV)+
" GeV ]";
327 if (
m_d->controller->printVerboseInfoOnClick()) {
328 l <<
"======== Dump ========";
329 std::ostringstream s;
331 l << QString(s.str().c_str()).split(
'\n');
332 l <<
"======================";
336 if (
m_d->controller->zoomOnClick()) {
338 std::set<SoCamera*>::iterator it,itE = cameras.end();
339 for (it=cameras.begin();it!=itE;++it)
Scalar phi() const
phi method
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
static VP1CameraHelper * animatedZoomToPath(SoCamera *camera, SoGroup *sceneroot, SoPath *path, double duration_in_secs=1.0, double clipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
IVP1System * systemBase() const
static QString particleName(const int &pdgcode, bool &ok)
QStringList getKeys() const
virtual void largeChangesEnd()
virtual void init(VP1MaterialButtonBase *button=0)
SoSeparator * collSep() const
All 3D objects from this coll.
virtual void largeChangesBegin()
VP1StdCollection(IVP1System *, const QString &helperClassName)
HepMC::ConstGenVertexPtr vertex() const
double quantityVal(const VertexCommonFlags::QUANTITY &q)
VertexHandle(HepMC::ConstGenVertexPtr v, VP1TruthVertexCollection::Imp *dd)
HepMC::ConstGenVertexPtr m_vertex
void ensureAttach(SoSeparator *collsep)
VP1TruthVertexCollection::Imp * m_d
void ensureDetach(SoSeparator *collsep)
VertexSysController * controller
QList< VertexHandle * > vertices
VP1TruthVertexCollection * theclass
SoLineSet * createCross(const double &x, const double &y, const double &z, const double &extent=10 *Gaudi::Units::mm)
std::map< SoNode *, HepMC::ConstGenVertexPtr > nodeToVertexMap
double mag(const HepMC::FourVector &v) const
void assignDefaultMaterial(SoMaterial *) const
virtual ~VP1TruthVertexCollection()
VP1TruthVertexCollection(VertexSysController *, const QString &key)
QStringList infoOnClicked(SoPath *pickedPath)
QString provideText() const
static QList< VP1StdCollection * > createCollections(VertexSysController *)
void line(std::ostream &os, const GenEvent &e)
const HepMC::GenVertex * ConstGenVertexPtr