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

Public Member Functions

 Imp (TrackHandleBase *tc)
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::unique_ptr< 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 m_objBrowseTree(nullptr),
106 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
TrackCommonFlags::TSOSPartsFlags customColouredTSOSParts
static double unknown()

Member Function Documentation

◆ addPathsToSoLineSetAndSoVertexProperty()

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

Definition at line 619 of file TrackHandleBase.cxx.

622{
623 if ( !paths || ( paths->size()==1 && paths->begin()->empty()) )
624 return;
625 if (!line) {
626 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (2) ERROR: Unexpected null SoLineSet pointer!");
627 return;
628 }
629 if (!vertices) {
630 theclass->collHandle()->systemBase()->message("TrackHandleBase::Imp::addPathToSoLineSetAndSoVertexProperty (2) ERROR: Unexpected null SoVertexPropery pointer!");
631 return;
632 }
633 Amg::SetVectorVector3D::const_iterator itProjPart, itProjPartEnd(paths->end());
634 for (itProjPart = paths->begin();itProjPart!=itProjPartEnd;++itProjPart)
635 addPathToSoLineSetAndSoVertexProperty(*itProjPart,iver,numlines,line,vertices);
636}
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 555 of file TrackHandleBase.cxx.

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

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

◆ attach3DObjects()

void TrackHandleBase::Imp::attach3DObjects ( )

Definition at line 899 of file TrackHandleBase.cxx.

900{
901 VP1Msg::messageDebug("TrackHandleBase::Imp::attach3DObjects() - 1");
902
903 if (!theclass->m_currentmaterial) {
904 theclass->m_currentmaterial = determineMaterial();
905 theclass->m_currentmaterial->ref();
907 }
908 if (line && theclass->m_collhandle->sephelper()) {
909 VP1Msg::messageDebug("TrackHandleBase::Imp::attach3DObjects() - 2");
910 theclass->m_collhandle->sephelper()->addNodeUnderMaterial(line,theclass->m_currentmaterial);
911 double tube_r(theclass->m_collhandle->trackTubeRadius());
912 if (tube_r) {
914 extraRepresentation->removeAllChildren();
915 } else {
916 extraRepresentation = new SoSeparator;
917 extraRepresentation->ref();
918 theclass->common()->registerTrack(extraRepresentation,theclass);
919 }
921 if (!extraRepAttached) {
922 theclass->m_collhandle->sephelper()->addNodeUnderMaterial(extraRepresentation,theclass->m_currentmaterial);
923 extraRepAttached=true;
924 }
925 }
926 }
927 if (label_sep && theclass->common()->textSep() && theclass->common()->controller()->doTrackLabels())
928 theclass->common()->textSep()->addChild(label_sep);
929
930 if (extrapSurfaces_sep) theclass->m_collhandle->sephelper()->addNodeUnderMaterial(extrapSurfaces_sep,theclass->m_currentmaterial);
931}
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 850 of file TrackHandleBase.cxx.

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

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

◆ determineMaterial()

SoMaterial * TrackHandleBase::Imp::determineMaterial ( )

Definition at line 1285 of file TrackHandleBase.cxx.

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

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

◆ ensureInitPointsProjections_InDet()

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

Definition at line 1093 of file TrackHandleBase.cxx.

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

◆ ensureInitPointsProjections_Muon()

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

Definition at line 1155 of file TrackHandleBase.cxx.

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

◆ ensureInitPointsPropagated()

void TrackHandleBase::Imp::ensureInitPointsPropagated ( )

Definition at line 1061 of file TrackHandleBase.cxx.

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

◆ ensureInitPointsRaw()

void TrackHandleBase::Imp::ensureInitPointsRaw ( )

Definition at line 983 of file TrackHandleBase.cxx.

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

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

◆ isSane()

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

Definition at line 163 of file TrackHandleBase.cxx.

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

◆ materialChanged()

void TrackHandleBase::Imp::materialChanged ( )

Definition at line 832 of file TrackHandleBase.cxx.

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

◆ rebuild3DObjects()

void TrackHandleBase::Imp::rebuild3DObjects ( )

Definition at line 657 of file TrackHandleBase.cxx.

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

◆ attachmentHandles

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

Definition at line 154 of file TrackHandleBase.cxx.

◆ charge

double TrackHandleBase::Imp::charge

Definition at line 111 of file TrackHandleBase.cxx.

◆ chargeinit

bool TrackHandleBase::Imp::chargeinit

Definition at line 110 of file TrackHandleBase.cxx.

◆ customColouredTSOSParts

TrackCommonFlags::TSOSPartsFlags TrackHandleBase::Imp::customColouredTSOSParts

Definition at line 176 of file TrackHandleBase.cxx.

◆ extrapSurfaces_sep

SoSeparator* TrackHandleBase::Imp::extrapSurfaces_sep

for debugging.

FIXME!

Definition at line 117 of file TrackHandleBase.cxx.

◆ extraRepAttached

bool TrackHandleBase::Imp::extraRepAttached

Definition at line 118 of file TrackHandleBase.cxx.

◆ extraRepresentation

SoSeparator* TrackHandleBase::Imp::extraRepresentation

Definition at line 116 of file TrackHandleBase.cxx.

◆ inittouchedchambers

bool TrackHandleBase::Imp::inittouchedchambers
mutable

Definition at line 143 of file TrackHandleBase.cxx.

◆ label_sep

SoSeparator* TrackHandleBase::Imp::label_sep

Definition at line 160 of file TrackHandleBase.cxx.

◆ line

SoLineSet* TrackHandleBase::Imp::line

Definition at line 115 of file TrackHandleBase.cxx.

◆ m_objBrowseTree

QTreeWidgetItem* TrackHandleBase::Imp::m_objBrowseTree

Definition at line 180 of file TrackHandleBase.cxx.

◆ mass

double TrackHandleBase::Imp::mass

Definition at line 113 of file TrackHandleBase.cxx.

◆ massinit

bool TrackHandleBase::Imp::massinit

Definition at line 112 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 159 of file TrackHandleBase.cxx.

◆ pathInfo_TrkTrack

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

Used in the case of a Trk::Track.

Definition at line 158 of file TrackHandleBase.cxx.

◆ pathInfoLoaded

bool TrackHandleBase::Imp::pathInfoLoaded

Definition at line 157 of file TrackHandleBase.cxx.

◆ points_propagated

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

Definition at line 124 of file TrackHandleBase.cxx.

◆ points_propagated_id_projections

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

Definition at line 128 of file TrackHandleBase.cxx.

◆ points_propagated_muon_projections

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

Definition at line 129 of file TrackHandleBase.cxx.

◆ points_raw

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

Definition at line 123 of file TrackHandleBase.cxx.

◆ points_raw_id_projections

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

Definition at line 126 of file TrackHandleBase.cxx.

◆ points_raw_muon_projections

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

Definition at line 127 of file TrackHandleBase.cxx.

◆ randommaterial

SoMaterial* TrackHandleBase::Imp::randommaterial

Definition at line 151 of file TrackHandleBase.cxx.

◆ shownTSOSParts

TrackCommonFlags::TSOSPartsFlags TrackHandleBase::Imp::shownTSOSParts

Definition at line 175 of file TrackHandleBase.cxx.

◆ tempMaxPropRadius

float TrackHandleBase::Imp::tempMaxPropRadius

Definition at line 181 of file TrackHandleBase.cxx.

◆ theclass

TrackHandleBase* TrackHandleBase::Imp::theclass

Definition at line 108 of file TrackHandleBase.cxx.

◆ touchedmuonchambers

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

Definition at line 142 of file TrackHandleBase.cxx.

◆ tsos_ascobjs

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

Definition at line 177 of file TrackHandleBase.cxx.


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