ATLAS Offline Software
Loading...
Searching...
No Matches
TrackHandleBase::Imp Class Reference
Collaboration diagram for TrackHandleBase::Imp:

Public Member Functions

 Imp (TrackHandleBase *tc)
 ~Imp ()
void ensureInitPointsRaw ()
void ensureInitPointsPropagated ()
void ensureInitPointsProjections_InDet (bool raw)
void ensureInitPointsProjections_Muon (bool raw)
void materialChanged ()
void rebuild3DObjects ()
void attach3DObjects ()
void detach3DObjects ()
void addPathToSoLineSetAndSoVertexProperty (const std::vector< Amg::Vector3D > &points, int &iver, int &numlines, SoLineSet *, SoVertexProperty *) const
void addPathsToSoLineSetAndSoVertexProperty (const Amg::SetVectorVector3D *paths, int &iver, int &numlines, SoLineSet *, SoVertexProperty *) const
SoMaterial * determineMaterial ()
void ensureLoadPathInfo ()
AscObj_TSOSaddTSOS (const Trk::TrackStateOnSurface *tsos, unsigned index) const

Static Public Member Functions

static void convertLineSetToCylinders (SoLineSet *line, SoSeparator *sep, const double &cylradius)
static double dist (const SbVec3f &p1, const SbVec3f &p2)
static bool isSane (const Amg::Vector3D &p)

Public Attributes

TrackHandleBasetheclass
bool chargeinit
double charge
bool massinit
double mass
SoLineSet * line
SoSeparator * extraRepresentation
SoSeparator * extrapSurfaces_sep
 for debugging.
bool extraRepAttached
std::vector< Amg::Vector3D > * points_raw
std::vector< Amg::Vector3D > * points_propagated
Amg::SetVectorVector3Dpoints_raw_id_projections
Amg::SetVectorVector3Dpoints_raw_muon_projections
Amg::SetVectorVector3Dpoints_propagated_id_projections
Amg::SetVectorVector3Dpoints_propagated_muon_projections
std::set< GeoPVConstLink > touchedmuonchambers
bool inittouchedchambers
SoMaterial * randommaterial
QList< AssociatedObjectHandleBase * > associatedObjects
std::map< std::pair< int, double >, AssocObjAttachmentHandle * > attachmentHandles
bool pathInfoLoaded
const Trk::TrackpathInfo_TrkTrack
 Used in the case of a Trk::Track.
const std::vector< Amg::Vector3D > * pathInfo_Points
 Used in all other cases.
SoSeparator * label_sep
TrackCommonFlags::TSOSPartsFlags shownTSOSParts
TrackCommonFlags::TSOSPartsFlags customColouredTSOSParts
std::vector< AssociatedObjectHandleBase * > * tsos_ascobjs
QTreeWidgetItem * m_objBrowseTree
float tempMaxPropRadius

Static Public Attributes

static int ntrackhandles = 0

Detailed Description

Definition at line 76 of file TrackHandleBase.cxx.

Constructor & Destructor Documentation

◆ Imp()

TrackHandleBase::Imp::Imp ( TrackHandleBase * tc)
inline

Definition at line 83 of file TrackHandleBase.cxx.

83 : theclass(tc),
84 chargeinit(false),
86 massinit(false),
88 line(nullptr),
89 extraRepresentation(nullptr),
90 extrapSurfaces_sep(nullptr),
91 extraRepAttached(false),
92 points_raw(nullptr), points_propagated(nullptr),
98 randommaterial(nullptr),
99 pathInfoLoaded(false),
100 pathInfo_TrkTrack(nullptr),
101 pathInfo_Points(nullptr),
102 label_sep(nullptr),
105 tsos_ascobjs(nullptr),
106 m_objBrowseTree(nullptr),
107 tempMaxPropRadius(0.0){}
static Double_t tc
const std::vector< Amg::Vector3D > * pathInfo_Points
Used in all other cases.
Amg::SetVectorVector3D * points_propagated_id_projections
SoSeparator * extrapSurfaces_sep
for debugging.
TrackCommonFlags::TSOSPartsFlags shownTSOSParts
const Trk::Track * pathInfo_TrkTrack
Used in the case of a Trk::Track.
Amg::SetVectorVector3D * points_raw_id_projections
SoSeparator * extraRepresentation
TrackHandleBase * theclass
std::vector< Amg::Vector3D > * points_propagated
std::vector< Amg::Vector3D > * points_raw
QTreeWidgetItem * m_objBrowseTree
Amg::SetVectorVector3D * points_raw_muon_projections
Amg::SetVectorVector3D * points_propagated_muon_projections
std::vector< AssociatedObjectHandleBase * > * tsos_ascobjs
TrackCommonFlags::TSOSPartsFlags customColouredTSOSParts
static double unknown()

◆ ~Imp()

TrackHandleBase::Imp::~Imp ( )
inline

Definition at line 108 of file TrackHandleBase.cxx.

108{ delete tsos_ascobjs; }

Member Function Documentation

◆ addPathsToSoLineSetAndSoVertexProperty()

void TrackHandleBase::Imp::addPathsToSoLineSetAndSoVertexProperty ( const Amg::SetVectorVector3D * paths,
int & iver,
int & numlines,
SoLineSet * line,
SoVertexProperty * vertices ) const

Definition at line 620 of file TrackHandleBase.cxx.

623{
624 if ( !paths || ( paths->size()==1 && paths->begin()->empty()) )
625 return;
626 if (!line) {
627 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (2) ERROR: Unexpected null SoLineSet pointer!");
628 return;
629 }
630 if (!vertices) {
631 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (2) ERROR: Unexpected null SoVertexPropery pointer!");
632 return;
633 }
634 Amg::SetVectorVector3D::const_iterator itProjPart, itProjPartEnd(paths->end());
635 for (itProjPart = paths->begin();itProjPart!=itProjPartEnd;++itProjPart)
636 addPathToSoLineSetAndSoVertexProperty(*itProjPart,iver,numlines,line,vertices);
637}
void addPathToSoLineSetAndSoVertexProperty(const std::vector< Amg::Vector3D > &points, int &iver, int &numlines, SoLineSet *, SoVertexProperty *) const

◆ addPathToSoLineSetAndSoVertexProperty()

void TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty ( const std::vector< Amg::Vector3D > & points,
int & iver,
int & numlines,
SoLineSet * line,
SoVertexProperty * vertices ) const

Definition at line 556 of file TrackHandleBase.cxx.

559{
560 if (points.size()<2)
561 return;
562 if (!line) {
563 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (1) ERROR: Unexpected null SoLineSet pointer!");
564 return;
565 }
566 if (!vertices) {
567 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (1) ERROR: Unexpected null SoVertexPropery pointer!");
568 return;
569 }
570 std::vector<Amg::Vector3D >::const_iterator pointsIt, pointsItEnd(points.end());
571 unsigned npointsused(0);
572
573
574 float maxR2=theclass->common()->controller()->propMaxRadius()>0.0?theclass->common()->controller()->propMaxRadius():std::numeric_limits<float>::max();
575 if (tempMaxPropRadius>0.0){
577 theclass->collHandle()->systemBase()->messageVerbose("maxR2 is set to "+VP1Msg::str(maxR2));
578 }
579 float vertexPlanePhi = (theclass->common()->controller()->vertexProjectionAngle())*M_PI/180;// angle of plane to use for vertex projection
580 vertexPlanePhi-=M_PI; // ATLAS range is -PI to PI
581
582 // debug msgs:
583 // theclass->collHandle()->systemBase()->messageVerbose("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty - adding "
584 // +VP1Msg::str(points.size())+" points up to R2 of "+VP1Msg::str(maxR2));
585 theclass->collHandle()->systemBase()->messageVerbose("Vertex projection is set to "+VP1Msg::str(vertexPlanePhi));
586
587 // unsigned int count=0; // for the debug msgs below
588
589 //For vertex projection
590 Amg::Vector3D tempPoint;
591
592 double trkPhi = theclass->momentum().phi(); // some tracks curve between sections otherwise.
593 double newPhi= vertexPlanePhi+M_PI;
594 if (cos(vertexPlanePhi-trkPhi)>0) newPhi=vertexPlanePhi;
595 // theclass->collHandle()->systemBase()->messageVerbose("Vertex projection is set to "+VP1Msg::str(vertexPlanePhi)+" trkPhi= "+VP1Msg::str(trkPhi)+" newPhi="+VP1Msg::str(newPhi)); // debug msg
596
597 for (pointsIt = points.begin();pointsIt!=pointsItEnd && pointsIt->mag2()<maxR2; ++pointsIt) {
598 // theclass->collHandle()->systemBase()->messageVerbose(VP1Msg::str(count++)+": point has perp2="+VP1Msg::str(pointsIt->perp2())); // debug msg
599 if (!isSane(*pointsIt)) {
600 theclass->collHandle()->systemBase()->message("WARNING: Ignoring point on track:"+VP1Msg::str( *pointsIt ) );
601 continue;
602 }
603
604 if (theclass->collHandle()->parts() & TrackCommonFlags::VertexProjections){
605 tempPoint = *pointsIt;
606 Amg::setPhi(tempPoint, newPhi);
607
608 // std::cout<<trkPhi<<"\t"<<phi<<"\t"<<r0<<"\t"<<r1<<"\t"<<r2<<"\t"<<r3<<"\t"<<rotatePhi<<"\t"<<tempPoint.getPhi()<<std::endl; // debug msg
609
610 vertices->vertex.set1Value(iver++,tempPoint.x(),tempPoint.y(),tempPoint.z());
611 } else {
612 vertices->vertex.set1Value(iver++,pointsIt->x(),pointsIt->y(),pointsIt->z());
613 }
614 ++npointsused;
615 }
616 line->numVertices.set1Value(numlines++,npointsused);
617}
#define M_PI
static bool isSane(const Amg::Vector3D &p)
static QString str(const QString &s)
Definition VP1String.h:49
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Eigen::Matrix< double, 3, 1 > Vector3D

◆ addTSOS()

AscObj_TSOS * TrackHandleBase::Imp::addTSOS ( const Trk::TrackStateOnSurface * tsos,
unsigned index ) const

Definition at line 423 of file TrackHandleBase.cxx.

424{
425 AscObj_TSOS* ao = new AscObj_TSOS(theclass,tsos,index);
426 theclass->registerAssocObject(ao);
427 tsos_ascobjs->push_back(ao);
428 if (ao->parts()&shownTSOSParts)
429 ao->setVisible(true);
430 return ao;
431}
virtual TrackCommonFlags::TSOSPartsFlags parts() const
Definition AscObj_TSOS.h:59
virtual void setVisible(bool)

◆ attach3DObjects()

void TrackHandleBase::Imp::attach3DObjects ( )

Definition at line 900 of file TrackHandleBase.cxx.

901{
902 VP1Msg::messageDebug("TrackHandleBase::Imp::attach3DObjects() - 1");
903
904 if (!theclass->m_currentmaterial) {
905 theclass->m_currentmaterial = determineMaterial();
906 theclass->m_currentmaterial->ref();
908 }
909 if (line && theclass->m_collhandle->sephelper()) {
910 VP1Msg::messageDebug("TrackHandleBase::Imp::attach3DObjects() - 2");
911 theclass->m_collhandle->sephelper()->addNodeUnderMaterial(line,theclass->m_currentmaterial);
912 double tube_r(theclass->m_collhandle->trackTubeRadius());
913 if (tube_r) {
915 extraRepresentation->removeAllChildren();
916 } else {
917 extraRepresentation = new SoSeparator;
918 extraRepresentation->ref();
919 theclass->common()->registerTrack(extraRepresentation,theclass);
920 }
922 if (!extraRepAttached) {
923 theclass->m_collhandle->sephelper()->addNodeUnderMaterial(extraRepresentation,theclass->m_currentmaterial);
924 extraRepAttached=true;
925 }
926 }
927 }
928 if (label_sep && theclass->common()->textSep() && theclass->common()->controller()->doTrackLabels())
929 theclass->common()->textSep()->addChild(label_sep);
930
931 if (extrapSurfaces_sep) theclass->m_collhandle->sephelper()->addNodeUnderMaterial(extrapSurfaces_sep,theclass->m_currentmaterial);
932}
SoMaterial * determineMaterial()
static void convertLineSetToCylinders(SoLineSet *line, SoSeparator *sep, const double &cylradius)
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39

◆ convertLineSetToCylinders()

void TrackHandleBase::Imp::convertLineSetToCylinders ( SoLineSet * line,
SoSeparator * sep,
const double & cylradius )
static

Definition at line 851 of file TrackHandleBase.cxx.

852{
853 //TODO: belongs in VP1Utils
854 SoVertexProperty *vertices = static_cast<SoVertexProperty *>(line->vertexProperty.getValue());
855 if (!vertices)
856 return;
857 int ivert(0);
858 SbMatrix lastTransf;
859 lastTransf.makeIdentity();
860
861 for (int iline=0;iline<line->numVertices.getNum();++iline) {
862 int nvert=line->numVertices[iline];
863 if (nvert<2) {
864 ivert += nvert;
865 continue;
866 }
867 for (int jvert= ivert; jvert<ivert+nvert-1;++jvert) {
868 SbVec3f p1 = vertices->vertex[jvert].getValue();
869 SbVec3f p2 = vertices->vertex[jvert+1].getValue();
870 SoCylinder * cyl = new SoCylinder;
871 cyl->radius = cylradius;
872 const double l(dist(p1,p2));
873 cyl->height = l;
874 //First translate (0,l/2,0), then rotate (0,1,0) into (p2-p1), then translate p1.:
875 SbMatrix m;
876 m.setTranslate(SbVec3f(0,0.5*l,0));
877 SbVec3f v(p2); v -= p1;
878 SbRotation rot(SbVec3f(0,1,0),v);
879 SbMatrix m2; m2.setRotate(rot);
880 m.multRight(m2);
881 SbMatrix m3;
882 m3.setTranslate(p1);
883 m.multRight(m3);
884 //m is the transform we need in front of our cylinder.
885 //However, we need to first add the inverse of all previous transforms.
886 SbMatrix mat;
887 mat = m;
888 mat.multRight(lastTransf.inverse());
889 SoMatrixTransform * mt = new SoMatrixTransform;
890 mt->matrix.setValue(mat);
891 sep->addChild(mt);
892 sep->addChild(cyl);
893 lastTransf = m;
894 }
895 ivert += nvert;
896 }
897}
static double dist(const SbVec3f &p1, const SbVec3f &p2)
l
Printing final latex table to .tex output file.

◆ detach3DObjects()

void TrackHandleBase::Imp::detach3DObjects ( )

Definition at line 935 of file TrackHandleBase.cxx.

936{
937 if (!theclass->m_currentmaterial)
938 return;//Can never have been attached!
939 if (line && theclass->m_collhandle->sephelper()) {
940 theclass->m_collhandle->sephelper()->removeNodeUnderMaterial(line,theclass->m_currentmaterial);
942 theclass->m_collhandle->sephelper()->removeNodeUnderMaterial(extraRepresentation,theclass->m_currentmaterial);
943 extraRepAttached=false;
944 }
945 }
946 if (label_sep && theclass->common()->textSep())
947 theclass->common()->textSep()->removeChild(label_sep);
948
950 theclass->m_collhandle->sephelper()->removeNodeUnderMaterial(extrapSurfaces_sep,theclass->m_currentmaterial);
951}

◆ determineMaterial()

SoMaterial * TrackHandleBase::Imp::determineMaterial ( )

Definition at line 1286 of file TrackHandleBase.cxx.

1287{
1288 // debug msg:
1289 // theclass->collHandle()->systemBase()->message("determineMaterial with material = "+QString::number(static_cast<unsigned int>(theclass->collHandle()->colourBy()))); //too verbose. EJWM.
1290
1291 int pdgcode(0);
1292 switch(theclass->collHandle()->colourBy()) {
1293
1295 pdgcode = theclass->pdgCode();
1296 return theclass->common()->controller()->getMaterialForPDGCode(pdgcode == SimBarCode::unknownPDG ? 0 : pdgcode);
1297
1299 if (!randommaterial) {
1300 randommaterial = new SoMaterial;
1301 randommaterial->ref();
1302 theclass->rerandomiseRandomMaterial();
1303 }
1304 return randommaterial;
1305
1307 return theclass->common()->controller()->getMaterialForCharge(theclass->hasCharge()?theclass->charge():0.0);
1309 return theclass->common()->controller()->getMaterialForMomentum(theclass->momentum().mag());
1310
1312 {
1313 // debug code:
1314 // AscObjSelectionManager* selManager= theclass->common()->ascObjSelectionManager();
1315 // TrackHandleBase* handle = 0;
1316 // if ( selManager ) {
1317 // QList<AssociatedObjectHandleBase*> selection = selManager->currentSelection();
1318 // if (!selection.empty()) handle = selection[0]->trackHandle(); // Take first at the moment, but should loop and colour by all. FIXME!
1319 // else theclass->collHandle()->systemBase()->message("Empty selection!");
1320 // } else {
1321 // theclass->collHandle()->systemBase()->message("No AscObjSelectionManager");
1322 // }
1323
1324 TrackHandleBase* handle = theclass->common()->lastSelectedTrackHandle();
1325 if (handle==nullptr) {
1326 //theclass->collHandle()->systemBase()->message("No previously selected track.");
1327 return theclass->collHandle()->material(); // use collection colouring
1328 }
1329
1330 Amg::Vector3D selectedTrackMom = handle->momentum();
1331 Amg::Vector3D thisTrackMom = theclass->momentum();
1332
1333 float phiDistance = sqrt ( pow( selectedTrackMom.phi() - thisTrackMom.phi(),2) );
1334 float etaDistance = sqrt ( pow( selectedTrackMom.eta() - thisTrackMom.eta(),2) );
1335
1336 //theclass->collHandle()->systemBase()->message("Distance "+QString::number(distance)); // debug msg
1337 float colScale=std::max(0.0, std::min(1.0,phiDistance/(M_PI))); // means that min scale is reached 0.5 of total possible distance away.
1338 float brightness= std::max(0.2, 1.0-(etaDistance/5.0) );
1339 //theclass->collHandle()->systemBase()->message("Distance "+QString::number(distance)+"\t brightness "+QString::number(brightness)); // debug msg
1340
1341 SoMaterial* mat = new SoMaterial;
1342 mat->ref();
1343
1344 // get colour of collection.
1345 const SbColor& col=theclass->collHandle()->material()->diffuseColor[0];
1346 float r,g,b;
1347 col.getValue(r,g,b);
1348
1349 double r3,g3,b3;
1350 if (colScale>0.01) {
1351
1352 //Use QColor to get HSL
1353 QColor tempCol = QColor::fromRgbF( r,g,b );
1354 double h,s,v;
1355 tempCol.getHsvF(&h,&s,&v);
1356
1357 //get opposite hue for farthest away points.
1358 h+=0.5;
1359 if (h>1.0) h-=1.0;
1360 tempCol.setHsvF(h,s,v);
1361 double r2,g2,b2;
1362 tempCol.getRgbF(&r2,&g2,&b2);
1363
1364 // closest will have collection colour - far away will have opposite colour
1365 r3 = r+(r2-r)*colScale;
1366 b3 = b+(b2-b)*colScale;
1367 g3 = g+(g2-g)*colScale;
1368
1369 } else {
1370 // too close - take default values
1371 r3=r;b3=b;g3=g;
1372 }
1373
1374 VP1MaterialButton::setMaterialParameters(mat,r3*brightness,g3*brightness,b3*brightness,
1375 theclass->collHandle()->collMaterialBrightness(),
1376 theclass->collHandle()->collMaterialTransparency());
1377
1378 return mat;
1379 }
1381 {
1382 SoMaterial* mat = theclass->common()->system()->materialFromVertex(theclass);
1383 if (mat)
1384 return mat;
1385 else
1386 return theclass->collHandle()->material();
1387 }
1389 default:
1390 return theclass->collHandle()->material();
1391 }
1392}
constexpr int pow(int base, int exp) noexcept
static const int unknownPDG
Definition SimBarCode.h:25
TrackHandleBase(TrackCollHandleBase *)
virtual Amg::Vector3D momentum() const
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
int r
Definition globals.cxx:22

◆ dist()

double TrackHandleBase::Imp::dist ( const SbVec3f & p1,
const SbVec3f & p2 )
static

Definition at line 842 of file TrackHandleBase.cxx.

843{
844 float x1,x2,y1,y2,z1,z2;
845 p1.getValue(x1,y1,z1);
846 p2.getValue(x2,y2,z2);
847 return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
848}

◆ ensureInitPointsProjections_InDet()

void TrackHandleBase::Imp::ensureInitPointsProjections_InDet ( bool raw)

Definition at line 1094 of file TrackHandleBase.cxx.

1095{
1097 return;
1098
1100
1101 //First check if we use same points for raw/propagated modes:
1103 if (raw) {
1106 return;
1107 }
1108 } else {
1111 return;
1112 }
1113 }
1114 }
1115
1116 //Time for the hard work:
1117 std::vector<Amg::Vector3D > * points=nullptr;
1118 Amg::SetVectorVector3D* projections=nullptr;
1119 if (raw) {
1121 points = points_raw;
1122 projections = points_raw_id_projections;
1123 } else {
1125 points = points_propagated;
1127 }
1128
1129 if ( !points || points->empty() || points->size()<2 ) {
1130 projections->clear();
1131 projections->insert(std::vector<Amg::Vector3D >());//error signature
1132 return;
1133 }
1134
1135 bool oneok(false);
1136 if (theclass->common()->indetProjHelper_Pixel()) {
1137 theclass->common()->indetProjHelper_Pixel()->projectPath(*points,*projections);
1138 oneok = true;
1139 }
1140 if (theclass->common()->indetProjHelper_SCT()) {
1141 theclass->common()->indetProjHelper_SCT()->projectPath(*points,*projections);
1142 oneok = true;
1143 }
1144 if (theclass->common()->indetProjHelper_TRT()) {
1145 theclass->common()->indetProjHelper_TRT()->projectPath(*points,*projections);
1146 oneok = true;
1147 }
1148
1149 if (!oneok) {
1150 projections->clear();
1151 projections->insert(std::vector<Amg::Vector3D >());//error signature
1152 }
1153}
if(febId1==febId2)
std::set< std::vector< Amg::Vector3D >, VectorVector3DComparer > SetVectorVector3D

◆ ensureInitPointsProjections_Muon()

void TrackHandleBase::Imp::ensureInitPointsProjections_Muon ( bool raw)

Definition at line 1156 of file TrackHandleBase.cxx.

1157{
1159 return;
1160
1162
1163 //First check if we use same points for raw/propagated modes:
1165 if (raw) {
1168 return;
1169 }
1170 } else {
1173 return;
1174 }
1175 }
1176 }
1177
1178 //Time for the hard work:
1179 std::vector<Amg::Vector3D > * points;
1180 Amg::SetVectorVector3D * projections;
1181 if (raw) {
1183 points = points_raw;
1184 projections = points_raw_muon_projections;
1185 } else {
1187 points = points_propagated;
1189 }
1190
1191 MuonChamberProjectionHelper * projhelper = theclass->common()->muonChamberProjectionHelper();
1192 if ( !VP1JobConfigInfo::hasMuonGeometry() || !projhelper || !points || points->empty() ) {
1193 projections->insert(std::vector<Amg::Vector3D >());//error signature
1194 return;
1195 }
1196
1197 //Temporary variables:
1198 Amg::Vector3D firstEndWall_pointA, firstEndWall_pointB;
1199 Amg::Vector3D secondEndWall_pointA, secondEndWall_pointB;
1200 bool outsidechamber;
1201 std::vector<Amg::Vector3D > proj1, proj2;
1202
1203 //For each (MDT) chamber we try to project all line segments on "points" to the ends of that chamber.
1204 for (std::set<GeoPVConstLink>::iterator it=theclass->touchedMuonChambers().begin(); it!=theclass->touchedMuonChambers().end(); ++it){
1205
1206 //For now, only project to end of MDT chambers:
1207 if (!projhelper->isKnownMDTChamber(*it))
1208 continue;
1209
1210 proj1.clear();
1211 proj2.clear();
1212
1213 // now loop over the stored points
1214 std::vector<Amg::Vector3D >::const_iterator pointsIt=points->begin(), pointsItEnd=points->end()-1;
1215 for (;pointsIt!=pointsItEnd; ++pointsIt) {
1216
1217 // Do projections
1218 bool ok = projhelper->projectAndConstrainLineSegmentToMDTChamberEndWalls( *it, *pointsIt, *(pointsIt+1),
1219 firstEndWall_pointA, firstEndWall_pointB,
1220 secondEndWall_pointA, secondEndWall_pointB,
1221 outsidechamber );
1222
1223 if (!ok) {
1224 theclass->collHandle()->systemBase()->message("TrackHandleBase Error: "
1225 "Problems with projectAndConstrainLineSegmentToMDTChamberEndWalls(..)");
1226 // projections->clear();
1227 // projections->push_back(std::vector<Amg::Vector3D >);//error signature
1228 continue;
1229 }
1230
1231 if (!outsidechamber){
1232 if ( proj1.empty() ) {
1233 proj1.push_back(firstEndWall_pointA); proj1.push_back(firstEndWall_pointB);
1234 } else {
1235 if ( proj1[proj1.size()-1] == firstEndWall_pointA ) {
1236 proj1.push_back(firstEndWall_pointB);//Keep adding to line part
1237 } else {
1238 //Start new line.
1239 projections->insert(proj1); proj1.clear();
1240 proj1.push_back(firstEndWall_pointA); proj1.push_back(firstEndWall_pointB);
1241 }
1242 }
1243 if ( proj2.empty() ) {
1244 proj2.push_back(secondEndWall_pointA); proj2.push_back(secondEndWall_pointB);
1245 } else {
1246 // unsure about this change...coverity 16206, sroe
1247 // if ( proj2[proj2.size()-1] == firstEndWall_pointA ) {
1248 if ( proj2[proj2.size()-1] == secondEndWall_pointA ) {
1249 proj2.push_back(secondEndWall_pointB);//Keep adding to line part
1250 } else {
1251 //Start new line.
1252 projections->insert(proj2); proj2.clear();
1253 proj2.push_back(secondEndWall_pointA); proj2.push_back(secondEndWall_pointB);
1254 }
1255 }
1256 }
1257 //proj2 fixme
1258 }
1259 if ( !proj1.empty() ) {
1260 projections->insert(proj1);
1261 }
1262 if ( !proj2.empty() ) {
1263 projections->insert(proj2);
1264 }
1265 }
1266}
static bool hasMuonGeometry()

◆ ensureInitPointsPropagated()

void TrackHandleBase::Imp::ensureInitPointsPropagated ( )

Definition at line 1062 of file TrackHandleBase.cxx.

1063{
1065 return;
1066
1068
1069 if (pathInfo_TrkTrack) {
1070 points_propagated = new std::vector<Amg::Vector3D >();
1071 bool ok (false);
1072 if (theclass->hasCharge()&&theclass->charge()!=0.0)
1073 ok = theclass->common()->trackPropagationHelper()->makePointsCharged(*points_propagated,pathInfo_TrkTrack,
1074 theclass->collHandle()->propagator(),
1075 theclass->extrapolationParticleHypothesis(),
1076 !theclass->collHandle()->ignoreMEOTinProp(),
1077 theclass->collHandle()->extendTracks() ? theclass->common()->controller()->extrapolateToThisVolume() : nullptr );
1078 else
1079 ok = theclass->common()->trackPropagationHelper()->makePointsNeutral(*points_propagated,pathInfo_TrkTrack);
1080
1081 if (!ok) {
1082 delete points_propagated;
1085 }
1086 } else {
1087 //We just use the raw points:
1090 }
1091}

◆ ensureInitPointsRaw()

void TrackHandleBase::Imp::ensureInitPointsRaw ( )

Definition at line 984 of file TrackHandleBase.cxx.

985{
986 // debug msg:
987 // theclass->collHandle()->systemBase()->message("ensureInitPointsRaw start" );
988
989 if (points_raw)
990 return;
991 points_raw = new std::vector<Amg::Vector3D >;
992
994 // Get information about this path //
996
998
999 if (pathInfo_TrkTrack) {
1000 Amg::Vector3D * firstmomentum(nullptr);
1001 if (pathInfo_TrkTrack->trackParameters())
1002 points_raw->reserve(pathInfo_TrkTrack->trackParameters()->size());
1003 bool unsafeparts(false);
1004 Trk::TrackStates::const_iterator tsos_iter = pathInfo_TrkTrack->trackStateOnSurfaces()->begin();
1005 Trk::TrackStates::const_iterator tsos_end = pathInfo_TrkTrack->trackStateOnSurfaces()->end();
1006 const Trk::TrackParameters* trackParam;
1007 for (; tsos_iter != tsos_end; ++tsos_iter) {
1008 if (!VP1TrackSanity::isSafe(*tsos_iter)) {
1009 unsafeparts = true;
1010 continue;
1011 }
1012 if (theclass->collHandle()->ignoreMEOTinProp() && (*tsos_iter)->materialEffectsOnTrack())
1013 continue;
1014 trackParam = (*tsos_iter)->trackParameters();
1015 if (trackParam) {
1016 if (!VP1TrackSanity::isSafe(trackParam)) {
1017 unsafeparts = true;
1018 continue;
1019 }
1020 trackParam->position();//test
1021 points_raw->push_back( trackParam->position() );
1022 if (!firstmomentum) {
1023 firstmomentum = new Amg::Vector3D(trackParam->momentum());
1024 }
1025 }
1026 }
1027 if (unsafeparts)
1028 theclass->collHandle()->systemBase()->message("WARNING: Ignored unsafe parts of track!");
1029 if (points_raw->size()==1) {
1030 if (!firstmomentum) {
1031 theclass->collHandle()->systemBase()->message(" TrackHandleBase ERROR: Unexpected null firstmomentum!");
1032 firstmomentum = new Amg::Vector3D(0,0,0);
1033 }
1034 if (firstmomentum->mag()==0.0) {
1035 theclass->collHandle()->systemBase()->message("TrackHandleBase ERROR: Only point on track had zero momentum. Can't add second point.");
1036 points_raw->clear();
1037 } else {
1038 VP1Msg::messageVerbose("TrackHandleBase: Adding second point in direction of initial momentum.");
1039 points_raw->push_back(points_raw->front()+(*firstmomentum)*(100.0/firstmomentum->mag()));
1040 }
1041 } else if (points_raw->empty()) {
1042 theclass->collHandle()->systemBase()->message("TrackHandleBase ERROR: No points on track.");
1043 }
1044
1045 delete firstmomentum;
1046 firstmomentum = nullptr;
1047 return;
1048 }
1049 if (pathInfo_Points)
1050 std::copy(pathInfo_Points->begin(), pathInfo_Points->end(), std::back_inserter(*points_raw));
1051 if (points_raw->size()<2) {
1052 theclass->collHandle()->systemBase()->message("TrackHandleBase ERROR: Less than two points on track provided.");
1053 points_raw->clear();
1054 } else {
1055 VP1Msg::messageVerbose( "TrackHandleBase: Created raw data "
1056 + QString::number(points_raw->size())
1057 + " points for track.");
1058 }
1059}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static bool isSafe(const Trk::TrackStateOnSurface *)
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ ensureLoadPathInfo()

void TrackHandleBase::Imp::ensureLoadPathInfo ( )

Definition at line 189 of file TrackHandleBase.cxx.

190{
191 if (pathInfoLoaded)
192 return;
193 pathInfoLoaded = true;
194 pathInfo_TrkTrack = theclass->provide_pathInfoTrkTrack();
196 return;
197 pathInfo_Points = theclass->provide_pathInfoPoints();
198 if (!pathInfo_Points) {
199 theclass->collHandle()->systemBase()->message("ERROR: No path information for track in collection "+theclass->collHandle()->name());
200 }
201}

◆ isSane()

bool TrackHandleBase::Imp::isSane ( const Amg::Vector3D & p)
inlinestatic

Definition at line 164 of file TrackHandleBase.cxx.

165 {
166 if (p.x()!=p.x()||fabs(p.x())>1.0*CLHEP::km)
167 return false;
168 if (p.y()!=p.y()||fabs(p.y())>1.0*CLHEP::km)
169 return false;
170 if (p.z()!=p.z()||fabs(p.z())>1.0*CLHEP::km)
171 return false;
172 return true;
173 }

◆ materialChanged()

void TrackHandleBase::Imp::materialChanged ( )

Definition at line 833 of file TrackHandleBase.cxx.

834{
835 theclass->currentMaterialChanged();
836 std::map<std::pair<int,double>,AssocObjAttachmentHandle *>::iterator it,itE(attachmentHandles.end());
837 for (it = attachmentHandles.begin();it!=itE;++it)
838 it->second->trackMaterialChanged();
839}
std::map< std::pair< int, double >, AssocObjAttachmentHandle * > attachmentHandles
friend class AssocObjAttachmentHandle

◆ rebuild3DObjects()

void TrackHandleBase::Imp::rebuild3DObjects ( )

Definition at line 658 of file TrackHandleBase.cxx.

659{
660 //Ensure we are always detached while updating.
661 if (theclass->m_visible)
663
664 // Make sure we're not going to redraw old surfaces, for this debug mode.
665 if (theclass->common()->trackPropagationHelper()->showExtrapolationSurfaces())
666 theclass->common()->trackPropagationHelper()->getExtrapolationSurfaces().clear();
667
668 Trk::IExtrapolator * propagator = theclass->collHandle()->propagator();
669
670 if (propagator)
672 else
674
675 bool id_proj = theclass->collHandle()->parts() & TrackCommonFlags::InDetProjections;
676 if (id_proj)
678
679 bool muon_proj = theclass->collHandle()->parts() & TrackCommonFlags::MuonProjections;
680 if (muon_proj)
682
683 std::vector<Amg::Vector3D > * points;
684 Amg::SetVectorVector3D *proj_id, *proj_muon;
685 if (propagator) {
686 points = points_propagated;
689 } else {
690 points = points_raw;
692 proj_muon = points_raw_muon_projections;
693 }
694
695 //Put points into an appropriate vertex property.
696 theclass->clearLine(); //FIXME: Since we are just changing shape - no need to delete line and take it
697 //out of the tree first. Just edit lineset properties instead.
698 line = new SoLineSet();
699 line->ref();
700 theclass->registerTrack();
701
702 SoVertexProperty * vertices = new SoVertexProperty();
703
704 int iver(0), numlines(0);
705
706 //Add various parts to these vertices as appropriate:
707 if (theclass->collHandle()->parts() & TrackCommonFlags::ActualPath)
708 addPathToSoLineSetAndSoVertexProperty(*points,iver,numlines,line,vertices);
709 if (id_proj)
710 addPathsToSoLineSetAndSoVertexProperty( proj_id, iver, numlines, line, vertices );
711 if (muon_proj)
712 addPathsToSoLineSetAndSoVertexProperty( proj_muon, iver, numlines, line, vertices );
713
714 line->vertexProperty = vertices;
715
717
718
719// Add debugging surfaces.
720 if (theclass->common()->trackPropagationHelper()->showExtrapolationSurfaces()){
721 std::vector<Trk::PlaneSurface>& surfaces = theclass->common()->trackPropagationHelper()->getExtrapolationSurfaces();
722 std::vector<Trk::PlaneSurface>::const_iterator surfIt=surfaces.begin(), surfEnd=surfaces.end();
723 SurfaceToSoNode surfCnv;//fixme: check if need in common()
724 extrapSurfaces_sep=new SoSeparator;
725 for (;surfIt!=surfEnd;++surfIt){
726 SoNode* theSurfSep = surfCnv.translateSurface(*surfIt);
727 if (theSurfSep) {
728 SoNode * nodeToAdd = theSurfSep;
729 extrapSurfaces_sep->addChild(nodeToAdd);
730 }
731 }
732 }
733
734// Add labels
735 if (!points->empty() && theclass->common()->controller()->doTrackLabels() ){
736
737 // should detach first? This is all fairly suboptimal I'm sure... EJWM.
738 if (!label_sep){
739 label_sep = new SoSeparator;
740 label_sep->ref();
741 }
742 label_sep->removeAllChildren ();
743
744 SoText2 *labelText = new SoText2;
745 labelText->ref();
746 QStringList text;
747 TrackSystemController::TrackLabelModes labels=theclass->common()->controller()->trackLabels();
748 if (labels&TrackSystemController::P){
749 text << "P="+VP1Msg::str(theclass->momentum().mag())+" MeV";
750 }
751
752 if (labels&TrackSystemController::Pt){
753 text << "|Pt|="+VP1Msg::str(theclass->momentum().perp())+" MeV";
754 }
755
756 if (labels&TrackSystemController::Pid){
757 int pdg = theclass->pdgCode();
758 if (pdg) {
759 bool ok;
760 QString name = VP1ParticleData::particleName(pdg,ok);
761 if (ok)
762 text << "pdg: "+QString::number(pdg)+" ["+name+"]";
763 else
764 text << "pdg: "+QString::number(pdg);
765 }
766 }
767
768 if (labels&TrackSystemController::FitQuality && theclass->getFitQuality()){
769 text << TrkObjToString::shortInfo(*theclass->getFitQuality());
770 }
771
772 if (labels&TrackSystemController::Hits){
773 text <<"Pix["+VP1Msg::str(theclass->getNPixelHits())+"], SCT["+VP1Msg::str(theclass->getNSCTHits())+"], TRT["+VP1Msg::str(theclass->getNTRTHits())+"],"
774 <<" MDT["+QString::number(theclass->getNMDTHits())+"], RPC["+QString::number(theclass->getNRPCHits())+"], TGC["+QString::number(theclass->getNTGCHits())+"], CSC["+QString::number(theclass->getNCSCHits())+"] MM["+QString::number(theclass->getNMMHits())+"], sTGC["+QString::number(theclass->getNsTGCHits())+"]";
775 }
776
778 Amg::Vector3D mom = theclass->momentum();
779 mom /= CLHEP::GeV;
780 if (mom.mag2()==0.0) {
781 text << "Momentum : 0 (undefined)";
782 } else {
783 // current SoCoin classes don't support Unincode here, apparently.
784 // text << VP1Msg::str("(")+QChar(0x03B7)+","+QChar(0x03D5)+VP1Msg::str(")=(")
785 // +VP1Msg::str(mom.pseudoRapidity())+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")");
786 double pseudoRapidity = mom.eta();
787 text << VP1Msg::str("(eta,phi)=(")
788 +VP1Msg::str(pseudoRapidity)+VP1Msg::str(",")+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")");
789 }
790 }
791
792 unsigned int row=0;
793 for(const QString& str : text){
794 QByteArray array = str.toLatin1();
795 labelText->string.set1Value(row++,array.data());
796 }
797
798 //Position
799 float labelTrackOffset = theclass->common()->controller()->trackLabelTrkOffset();
800 unsigned int point=(points->size()-1)*labelTrackOffset;
801 Amg::Vector3D labelPos = (*points)[point] ;
802
803// NOTE: those options can be used if we want different label positions:
804// if (labels&TrackSystemController::PosEndOfTrack)
805// labelPos= points->back();
806// else if (labels&TrackSystemController::PosBeginOfTrack)
807// labelPos= points->front ();
808// else if (labels&TrackSystemController::PosMidOfTrack)
809// labelPos= (*points)[points->size()/2];
810
811 SoTranslation *labelTranslate = new SoTranslation;
812 float offScale=10.0;
813 int xOffset = theclass->common()->controller()->labelXOffset() ;
814 int yOffset = theclass->common()->controller()->labelYOffset() ;
815 int zOffset = theclass->common()->controller()->labelZOffset() ;
816 labelTranslate->translation.setValue(labelPos.x()+(xOffset*offScale),labelPos.y()+(yOffset*offScale),labelPos.z()+(zOffset*offScale));
817
818 SoMaterial *sMat = new SoMaterial();
819 SoMFColor sColor;
820 sColor.setValue(SbColor(0, 0, 1));
821 sMat->diffuseColor = sColor;
822
823 label_sep->addChild(labelTranslate);
824 label_sep->addChild(labelText);
825 }
826
827 //Attach if visible:
828 if (theclass->m_visible)
830}
SoNode * translateSurface(const Trk::Surface &sf, const bool &simple=false) const
void addPathsToSoLineSetAndSoVertexProperty(const Amg::SetVectorVector3D *paths, int &iver, int &numlines, SoLineSet *, SoVertexProperty *) const
void ensureInitPointsProjections_Muon(bool raw)
void ensureInitPointsProjections_InDet(bool raw)
static QString shortInfo(const Trk::MeasurementBase &mb)
static double phiFromXY(const double &x, const double &y)
static QString particleName(const int &pdgcode, bool &ok)
row
Appending html table to final .html summary file.

Member Data Documentation

◆ associatedObjects

QList<AssociatedObjectHandleBase*> TrackHandleBase::Imp::associatedObjects

Definition at line 154 of file TrackHandleBase.cxx.

◆ attachmentHandles

std::map<std::pair<int,double>,AssocObjAttachmentHandle *> TrackHandleBase::Imp::attachmentHandles

Definition at line 155 of file TrackHandleBase.cxx.

◆ charge

double TrackHandleBase::Imp::charge

Definition at line 112 of file TrackHandleBase.cxx.

◆ chargeinit

bool TrackHandleBase::Imp::chargeinit

Definition at line 111 of file TrackHandleBase.cxx.

◆ customColouredTSOSParts

TrackCommonFlags::TSOSPartsFlags TrackHandleBase::Imp::customColouredTSOSParts

Definition at line 177 of file TrackHandleBase.cxx.

◆ extrapSurfaces_sep

SoSeparator* TrackHandleBase::Imp::extrapSurfaces_sep

for debugging.

FIXME!

Definition at line 118 of file TrackHandleBase.cxx.

◆ extraRepAttached

bool TrackHandleBase::Imp::extraRepAttached

Definition at line 119 of file TrackHandleBase.cxx.

◆ extraRepresentation

SoSeparator* TrackHandleBase::Imp::extraRepresentation

Definition at line 117 of file TrackHandleBase.cxx.

◆ inittouchedchambers

bool TrackHandleBase::Imp::inittouchedchambers
mutable

Definition at line 144 of file TrackHandleBase.cxx.

◆ label_sep

SoSeparator* TrackHandleBase::Imp::label_sep

Definition at line 161 of file TrackHandleBase.cxx.

◆ line

SoLineSet* TrackHandleBase::Imp::line

Definition at line 116 of file TrackHandleBase.cxx.

◆ m_objBrowseTree

QTreeWidgetItem* TrackHandleBase::Imp::m_objBrowseTree

Definition at line 181 of file TrackHandleBase.cxx.

◆ mass

double TrackHandleBase::Imp::mass

Definition at line 114 of file TrackHandleBase.cxx.

◆ massinit

bool TrackHandleBase::Imp::massinit

Definition at line 113 of file TrackHandleBase.cxx.

◆ ntrackhandles

int TrackHandleBase::Imp::ntrackhandles = 0
static

Definition at line 81 of file TrackHandleBase.cxx.

◆ pathInfo_Points

const std::vector< Amg::Vector3D >* TrackHandleBase::Imp::pathInfo_Points

Used in all other cases.

Definition at line 160 of file TrackHandleBase.cxx.

◆ pathInfo_TrkTrack

const Trk::Track* TrackHandleBase::Imp::pathInfo_TrkTrack

Used in the case of a Trk::Track.

Definition at line 159 of file TrackHandleBase.cxx.

◆ pathInfoLoaded

bool TrackHandleBase::Imp::pathInfoLoaded

Definition at line 158 of file TrackHandleBase.cxx.

◆ points_propagated

std::vector<Amg::Vector3D >* TrackHandleBase::Imp::points_propagated

Definition at line 125 of file TrackHandleBase.cxx.

◆ points_propagated_id_projections

Amg::SetVectorVector3D* TrackHandleBase::Imp::points_propagated_id_projections

Definition at line 129 of file TrackHandleBase.cxx.

◆ points_propagated_muon_projections

Amg::SetVectorVector3D* TrackHandleBase::Imp::points_propagated_muon_projections

Definition at line 130 of file TrackHandleBase.cxx.

◆ points_raw

std::vector< Amg::Vector3D >* TrackHandleBase::Imp::points_raw

Definition at line 124 of file TrackHandleBase.cxx.

◆ points_raw_id_projections

Amg::SetVectorVector3D* TrackHandleBase::Imp::points_raw_id_projections

Definition at line 127 of file TrackHandleBase.cxx.

◆ points_raw_muon_projections

Amg::SetVectorVector3D* TrackHandleBase::Imp::points_raw_muon_projections

Definition at line 128 of file TrackHandleBase.cxx.

◆ randommaterial

SoMaterial* TrackHandleBase::Imp::randommaterial

Definition at line 152 of file TrackHandleBase.cxx.

◆ shownTSOSParts

TrackCommonFlags::TSOSPartsFlags TrackHandleBase::Imp::shownTSOSParts

Definition at line 176 of file TrackHandleBase.cxx.

◆ tempMaxPropRadius

float TrackHandleBase::Imp::tempMaxPropRadius

Definition at line 182 of file TrackHandleBase.cxx.

◆ theclass

TrackHandleBase* TrackHandleBase::Imp::theclass

Definition at line 109 of file TrackHandleBase.cxx.

◆ touchedmuonchambers

std::set<GeoPVConstLink> TrackHandleBase::Imp::touchedmuonchambers
mutable

Definition at line 143 of file TrackHandleBase.cxx.

◆ tsos_ascobjs

std::vector<AssociatedObjectHandleBase*>* TrackHandleBase::Imp::tsos_ascobjs

Definition at line 178 of file TrackHandleBase.cxx.


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