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>
33 #include <QFileDialog>
60 if(
tree==
nullptr)
return false;
111 Ui::BPhysControllerForm
ui;
118 "daniel.scheirich@cern.ch") ,
132 m_refittedSwitches{},
136 messageDebug(
"in BPhysSystem");
138 m_rootFile =
nullptr;
148 messageDebug(
"leaving VP1BPhysSystem");
156 QWidget * controller =
new QWidget(
nullptr);
157 m_c->
ui.setupUi(controller);
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();
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) {
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(
"");
272 message(
"Different lengths of some filter track collections");
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);
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);
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 >();
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;
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();
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");
602 points->push_back(
Amg::Vector3D((*it)->position().x(),(*it)->position().y(),(*it)->position().z()));
608 delete propagationHelper;
635 std::vector<Amg::Vector3D >* pointsOut =
new std::vector<Amg::Vector3D >();
638 if(
points->size()<2)
return pointsOut;
640 double lastDist = 1e10;
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);
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;
711 vtxSwitch->addChild ( sphere );
715 vtxSwitch->addChild ( cross );
718 SoSeparator* sepEllipsoid =
new SoSeparator();
719 vtxSwitch->addChild ( sepEllipsoid );
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)"));
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;