16#include "ui_bphyscontrollerform.h"
24#include <Inventor/nodes/SoBaseColor.h>
25#include <Inventor/nodes/SoDrawStyle.h>
26#include <Inventor/nodes/SoLineSet.h>
27#include <Inventor/nodes/SoMatrixTransform.h>
28#include <Inventor/nodes/SoSeparator.h>
29#include <Inventor/nodes/SoSphere.h>
30#include <Inventor/nodes/SoSwitch.h>
31#include <Inventor/nodes/SoTranslation.h>
32#include <Inventor/nodes/SoVertexProperty.h>
60 if(
tree==
nullptr)
return false;
111 Ui::BPhysControllerForm
ui;
118 "daniel.scheirich@cern.ch") ,
156 QWidget * controller =
new QWidget(
nullptr);
157 m_c->ui.setupUi(controller);
160 connect(
m_c->ui.bLoad,SIGNAL(released()),
this,SLOT(
loadFile()));
163 connect(
m_c->ui.rbSphere,SIGNAL(toggled(
bool)),
this,SLOT(
sphereToggled(
bool)));
164 connect(
m_c->ui.rbCross,SIGNAL(toggled(
bool)),
this,SLOT(
crossToggled(
bool)));
193 m_root->removeAllChildren();
197 message(
"Error: Got null storegate pointer");
202 if(
m_tree==
nullptr)
return;
205 const EventContext& ctx = Gaudi::Hive::currentContext();
206 int evtNum = ctx.eventID().event_number();
207 int runNum = ctx.eventID().run_number();
211 StatusCode status =
m_sg->retrieve(partCont,
"TrackParticleCandidate");
212 if (status != StatusCode::SUCCESS || !partCont) {
213 message(
"Error: Could not retrieve track particle container (used key=TrackParticleCandidate)");
228 std::vector<const Rec::TrackParticle*>* selectedParticles =
new std::vector<const Rec::TrackParticle*>();
235 for(
int i=0; i<
m_tree->GetEntries(); ++i) {
237 if(
m_br->runNum == runNum &&
m_br->evtNum == evtNum) {
244 m_c->ui.lStatus->setText(
"No event to display");
245 message(
"Event is not in the VP1BPhys Display File. Skipping.");
247 m_c->ui.lStatus->setText(
"");
250 for(;
m_br->runNum == runNum &&
m_br->evtNum == evtNum && e<
m_tree->GetEntries();
m_br->GetEntry(++e)) {
255 if(
m_br->track_pt->size() !=
m_br->track_eta->size() ||
256 m_br->track_pt->size() !=
m_br->track_eta->size() ||
257 m_br->track_pt->size() !=
m_br->track_phi->size() ||
258 m_br->track_pt->size() !=
m_br->track_d0->size() ||
259 m_br->track_pt->size() !=
m_br->track_z0->size() ||
260 m_br->track_pt->size() !=
m_br->track_charge->size() ||
261 m_br->track_pt->size() !=
m_br->track_color->size() ||
262 m_br->track_pt->size() !=
m_br->track_refitted_px->size() ||
263 m_br->track_pt->size() !=
m_br->track_refitted_py->size() ||
264 m_br->track_pt->size() !=
m_br->track_refitted_pz->size() ||
265 m_br->track_pt->size() !=
m_br->track_refitted_color->size() ||
266 m_br->neutral_refitted_px->size() !=
m_br->neutral_refitted_py->size() ||
267 m_br->neutral_refitted_px->size() !=
m_br->neutral_refitted_py->size() ||
268 m_br->neutral_refitted_px->size() !=
m_br->neutral_refitted_pz->size() ||
269 m_br->neutral_refitted_px->size() !=
m_br->neutral_length->size() ||
270 m_br->neutral_refitted_px->size() !=
m_br->neutral_color->size())
272 message(
"Different lengths of some filter track collections");
277 for(
uint i=0; i<
m_br->track_pt->size(); ++i) {
280 m_br->track_pt->at(i),
281 m_br->track_eta->at(i),
282 m_br->track_phi->at(i),
283 m_br->track_d0->at(i),
284 m_br->track_z0->at(i),
286 m_br->track_color->at(i),
292 m_br->track_refitted_px->at(i),
293 m_br->track_refitted_py->at(i),
294 m_br->track_refitted_pz->at(i),
295 m_br->track_charge->at(i),
296 m_br->track_refitted_color->at(i));
302 std::vector<double>::iterator neutralPxItr =
m_br->neutral_refitted_px->begin();
303 std::vector<double>::iterator neutralPyItr =
m_br->neutral_refitted_py->begin();
304 std::vector<double>::iterator neutralPzItr =
m_br->neutral_refitted_pz->begin();
305 std::vector<double>::iterator neutralLengthItr =
m_br->neutral_length->begin();
306 std::vector<unsigned long>::iterator neutralColorItr =
m_br->neutral_color->begin();
308 for(; neutralPxItr!=
m_br->neutral_refitted_px->end(); ++neutralPxItr, ++neutralPyItr, ++neutralPzItr, ++neutralLengthItr, ++neutralColorItr) {
310 *neutralPxItr, *neutralPyItr, *neutralPzItr, *neutralLengthItr, *neutralColorItr);
331 delete selectedParticles;
350 double pt,
double eta,
double ,
double ,
double ,
351 double x,
double y,
double z,
unsigned long color,
352 std::vector<const Rec::TrackParticle*>* selectedParticles)
357 for ( partItr = partCont->
begin() ; partItr != partItrEnd; ++partItr) {
359 double trk_qOverP = (*partItr)->measuredPerigee()->parameters()[
Trk::qOverP];
360 double trk_theta = (*partItr)->measuredPerigee()->parameters()[
Trk::theta];
363 double trk_pt = fabs(1./trk_qOverP)*sin(trk_theta);
364 double trk_eta = -log(tan(trk_theta/2));
367 if(fabs(trk_pt - pt)<0.1 && fabs(trk_eta -
eta)<0.01) {
369 if(selectedParticles!=
nullptr) {
370 selectedParticles->push_back(*partItr);
383 StatusCode status = sg->
retrieve(partCont,
"TrackParticleCandidate");
384 if (status != StatusCode::SUCCESS || !partCont) {
385 message(
"Error: Could not retrieve track particle container (used key=TrackParticleCandidate)");
390 for ( partItr = partCont->
begin() ; partItr != partItrEnd; ++partItr) {
392 if(selectedParticles!=
nullptr) {
393 std::vector<const Rec::TrackParticle*>::const_iterator selItr = selectedParticles->begin();
394 for(; selItr!=selectedParticles->end(); ++selItr) {
395 if(*partItr == *selItr) {
402 SoSwitch* trackSwitch =
new SoSwitch();
403 root->addChild(trackSwitch);
404 trackSwitch->whichChild =
m_showAll ? SO_SWITCH_ALL : SO_SWITCH_NONE;
408 SoSwitch* trackSwitch =
new SoSwitch();
409 root->addChild(trackSwitch);
424 std::vector<Amg::Vector3D >* points =
getPoints(part);
440 std::vector<Amg::Vector3D >* points =
getPoints(part);
446 SoSwitch* trackSwitch =
new SoSwitch();
447 root->addChild(trackSwitch);
448 trackSwitch->whichChild =
m_showSignal ? SO_SWITCH_ALL : SO_SWITCH_NONE;
463 std::vector<Amg::Vector3D >* points =
new std::vector<Amg::Vector3D >();
466 CLHEP::Hep3Vector p(px,py,pz);
467 CLHEP::Hep3Vector track = p.unit();
474 SoSwitch* trackSwitch =
new SoSwitch();
475 root->addChild(trackSwitch);
476 trackSwitch->whichChild =
m_showNeutral ? SO_SWITCH_ALL : SO_SWITCH_NONE;
488 double px,
double py,
double pz,
double charge,
unsigned long color)
498 std::vector<Amg::Vector3D >* points =
getPoints(track);
501 SoSwitch* trackSwitch =
new SoSwitch();
502 root->addChild(trackSwitch);
503 trackSwitch->whichChild =
m_showRefitted ? SO_SWITCH_ALL : SO_SWITCH_NONE;
519 if(points ==
nullptr)
return;
521 SoSeparator* sep =
new SoSeparator();
524 SoDrawStyle* drawStyle =
new SoDrawStyle();
525 drawStyle->lineWidth =
width;
527 drawStyle->linePattern = 0x00ff;
529 sep->addChild(drawStyle);
532 SoBaseColor* baseColor =
new SoBaseColor();
535 baseColor->rgb.setValue(
r,g,b);
536 sep->addChild(baseColor);
539 SoVertexProperty *vertices =
new SoVertexProperty();
541 std::vector<Amg::Vector3D >::iterator it, itE = points->end();
542 for(it = points->begin(); it != itE; ++it) {
543 vertices->vertex.set1Value(iver++,(*it).x(),(*it).y(),(*it).z());
547 SoLineSet * line =
new SoLineSet();
548 line->numVertices = iver;
549 line->vertexProperty = vertices;
555 trackSwitch->addChild(sep);
575 if(propagator ==
nullptr) {
576 message(
"Error: propagator Trk::Extrapolator/VP1Extrapolator couldn't be created");
584 std::vector< Amg::Vector3D >* points =
new std::vector<Amg::Vector3D >();
588 if(propagator!=
nullptr && propagationHelper!=
nullptr) {
598 message(
"Error: no track parameters");
601 for (it = params->begin();it!=itE;++it) {
602 points->push_back(
Amg::Vector3D((*it)->position().x(),(*it)->position().y(),(*it)->position().z()));
608 delete propagationHelper;
622 std::vector<Amg::Vector3D >* points =
getPoints(track);
635 std::vector<Amg::Vector3D >* pointsOut =
new std::vector<Amg::Vector3D >();
638 if(points->size()<2)
return pointsOut;
640 double lastDist = 1e10;
642 std::vector<Amg::Vector3D >::iterator startFrom = (points->begin())+1;
645 std::vector<Amg::Vector3D >::iterator it, itE = points->end();
646 for(it = points->begin(); (it+1) != itE; ++it) {
647 CLHEP::Hep3Vector p = CLHEP::Hep3Vector((*(it+1)).
x()-(*it).x(), (*(it+1)).y()-(*it).y(), (*(it+1)).z()-(*it).z());
648 CLHEP::Hep3Vector v = CLHEP::Hep3Vector(
x - (*it).x(),
y - (*it).y(),
z - (*it).z());
651 double proj = v.dot(p.unit());
652 CLHEP::Hep3Vector vect = p.unit();
656 if(proj<0 || proj > p.mag())
continue;
659 double dist = sqrt(p.mag2() - proj*proj);
662 point =
Amg::Vector3D((*it).x() + vect.x(), (*it).y() + vect.y(), (*it).z() + vect.z());
668 pointsOut->push_back(point);
669 for(it = startFrom; it!=itE; ++it) {
670 pointsOut->push_back(*it);
680 double xx,
double xy,
double xz,
double yy,
double yz,
double zz,
unsigned long color,
681 std::vector<SoSwitch*>& vertexSwitches)
685 SoSeparator* sep =
new SoSeparator();
688 SoTranslation * translation =
new SoTranslation;
689 translation->translation.setValue (
x,
y,
z );
690 sep->addChild ( translation );
693 SoBaseColor* baseColor =
new SoBaseColor();
696 baseColor->rgb.setValue(
rr,gg,bb);
697 sep->addChild(baseColor);
700 SoSwitch* vtxSwitch =
new SoSwitch();
702 vtxSwitch->whichChild = SO_SWITCH_NONE;
706 sep->addChild(vtxSwitch);
709 SoSphere * sphere =
new SoSphere;
710 sphere->radius = 2*CLHEP::mm;
711 vtxSwitch->addChild ( sphere );
715 vtxSwitch->addChild ( cross );
718 SoSeparator* sepEllipsoid =
new SoSeparator();
719 vtxSwitch->addChild ( sepEllipsoid );
722 double a=xx*CLHEP::mm;
723 double b=xy*CLHEP::mm;
724 double c=xz*CLHEP::mm;
725 double d=yy*CLHEP::mm;
726 double e=yz*CLHEP::mm;
727 double f=zz*CLHEP::mm;
729 double det =
a*(d*f-e*e) + 2*b*c*e - d*c*c-f*b*b;
731 double sixthrootofdet = exp(log(det)/6.0);
732 double invdet = 1.0/sixthrootofdet;
739 SbMatrix sbMat(
a,b,c,0,
743 SoMatrixTransform * matTrans =
new SoMatrixTransform();
744 matTrans->matrix.setValue(sbMat);
745 sepEllipsoid->addChild (matTrans);
749 SoSphere * ellipsoid =
new SoSphere;
750 ellipsoid->radius = 3;
751 sepEllipsoid->addChild ( sphere );
756 vertexSwitches.push_back(vtxSwitch);
774 QString fileName = QFileDialog::getOpenFileName(
nullptr, tr(
"Open File"),tr(
"."),tr(
"ROOT files (*.root)"));
775 if(fileName.isEmpty())
return;
777 m_c->ui.leFileName->setText(fileName);
799 m_tree->BuildIndex(
"runNum",
"evtNum");
802 m_c->ui.lStatus->setText(
"");
804 m_c->ui.lStatus->setText(
"File doesn't contain vp1bphys tree");
805 message(
"File doesn't contain vp1bphys tree");
808 m_c->ui.lStatus->setText(
"File doesn't exist");
823 if(
state==Qt::Unchecked) {
825 which = SO_SWITCH_NONE;
834 (*it)->whichChild = which;
889 if(
state==Qt::Unchecked)
897 (*it)->whichChild =
m_showAll ? SO_SWITCH_ALL : SO_SWITCH_NONE;
908 if(
state==Qt::Unchecked)
916 (*it)->whichChild =
m_showSignal ? SO_SWITCH_ALL : SO_SWITCH_NONE;
927 if(
state==Qt::Unchecked)
935 (*it)->whichChild =
m_showRefitted ? SO_SWITCH_ALL : SO_SWITCH_NONE;
946 if(
state==Qt::Unchecked)
954 (*it)->whichChild =
m_showNeutral ? SO_SWITCH_ALL : SO_SWITCH_NONE;
966 std::vector< const Trk::TrackParameters* > trackpars;
969 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
972 if (!trackpars.empty()) {
973 bool needresorting = trackpars.at(0)!=trackparticle->
perigee();
986 unsigned limit(needresorting?trackpars.size()-1:trackpars.size());
991 for (
unsigned i = 0; i < limit; ++i) {
1006#ifdef TRKTRACK_TRACKINFO_H
1029 covMtxP.setIdentity();
1040 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
1044#ifdef TRKTRACK_TRACKINFO_H
1062 unsigned long red = icolor/65536;
1063 icolor -=
red*65536;
1065 unsigned long green = icolor/256;
1066 icolor -=
green*256;
1068 unsigned long blue = icolor;
1081 SoVertexProperty *vertices =
new SoVertexProperty();
1082 vertices->vertex.set1Value ( 0,-extent, 0 , 0 );
1083 vertices->vertex.set1Value ( 1, extent, 0 , 0 );
1084 vertices->vertex.set1Value ( 2, 0 ,-extent , 0 );
1085 vertices->vertex.set1Value ( 3, 0 , extent , 0 );
1086 vertices->vertex.set1Value ( 4, 0 , 0 ,-extent );
1087 vertices->vertex.set1Value ( 5, 0 , 0 , extent );
1088 SoLineSet * line =
new SoLineSet();
1089 line->numVertices.set1Value(0,2);
1090 line->numVertices.set1Value(1,2);
1091 line->numVertices.set1Value(2,2);
1092 line->vertexProperty = vertices;
const boost::regex rr(r_r)
Scalar eta() const
pseudorapidity method
double charge(const T &p)
bool isNeutral(const T &p)
#define AmgSymMatrix(dim)
const unsigned int darknes
const unsigned long darkGray
std::vector< double > * neutral_refitted_px
std::vector< double > * track_refitted_pz
std::vector< double > * neutral_refitted_pz
std::vector< unsigned long > * neutral_color
std::vector< int > * vtx_daughters
std::vector< double > * track_d0
std::vector< double > * track_phi
std::vector< double > * track_pt
std::vector< double > * track_refitted_px
std::vector< double > * neutral_refitted_py
std::vector< double > * track_refitted_py
std::vector< double > * track_charge
std::vector< double > * neutral_length
std::vector< double > * track_eta
std::vector< double > * track_z0
std::vector< unsigned long > * track_refitted_color
std::vector< int > * neutral_decay
std::vector< unsigned long > * track_color
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.
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
void messageDebug(const QString &) const
void message(const QString &) const
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
bool makePointsCharged(std::vector< Amg::Vector3D > &points, const Trk::Track *, Trk::IExtrapolator *extrapolator, Trk::ParticleHypothesis hypo=Trk::nonInteracting, bool useMEOT=false, const Trk::Volume *volume=0)
Contains information about the 'fitter' of this track.
@ Unknown
Track fitter not defined.
const Perigee * perigee() const
Attempts to cast the definingParameters() to Perigee.
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
represents the track state (measurement, material, fit parameters and quality) at a surface.
Ui::BPhysControllerForm ui
void drawTrackParticle(SoSwitch *trackSwitch, const Rec::TrackParticle *part, unsigned long color)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
const Trk::Track * getTrack(const Rec::TrackParticle *trackparticle)
utils *****************************************************************************
void displayNeutralChanged(int state)
void ellipsoidToggled(bool checked)
const Trk::Track * getRefittedTrack(const Amg::Vector3D &pos, const Amg::Vector3D &mom, double charge)
void displayOrigSignalChanged(int state)
std::vector< SoSwitch * > m_refittedSwitches
std::vector< SoSwitch * > m_overlapSwitches
void drawAllTrackParticles(StoreGateSvc *sg, SoSeparator *root, std::vector< const Rec::TrackParticle * > *selectedParticles)
SoLineSet * createCross(double extent)
std::vector< SoSwitch * > m_neutralSwitches
std::vector< Amg::Vector3D > * findClosestApproach(std::vector< Amg::Vector3D > *points, double x, double y, double z)
void displayVerticesChanged(int state)
void crossToggled(bool checked)
void loadFile()
slots *****************************************************************************
void drawVertex(SoSeparator *root, double x, double y, double z, double radius, double xx, double xy, double xz, double yy, double yz, double zz, unsigned long color, std::vector< SoSwitch * > &vertexSwitches)
std::vector< Amg::Vector3D > * getPoints(const Trk::Track *track)
std::vector< SoSwitch * > m_signalSwitches
void drawRefittedTrack(SoSeparator *root, double x, double y, double z, double px, double py, double pz, double charge, unsigned long color)
void drawNeutralTrack(SoSeparator *root, double x, double y, double z, double px, double py, double pz, double length, unsigned long color)
std::vector< SoSwitch * > m_trackSwitches
void filterTrack(SoSeparator *root, const Rec::TrackParticleContainer *partCont, double pt, double eta, double phi, double d0, double z0, double x, double y, double z, unsigned long color, std::vector< const Rec::TrackParticle * > *selectedParticles)
drawing methods *******************************************************************
QWidget * buildController()
void sphereToggled(bool checked)
void getColor(unsigned long icolor, double &r, double &g, double &b)
std::vector< SoSwitch * > m_vertexSwitches
void displayRefTracksChanged(int state)
void displayAllTracksChanged(int state)
void drawCutoffTrackParticle(SoSeparator *root, const Rec::TrackParticle *part, double x, double y, double z, unsigned long color)
void drawPoints(SoSwitch *trackSwitch, std::vector< Amg::Vector3D > *points, unsigned long color, double width, bool isNeutral)
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters