Reimplemented from FWSimpleProxyBuilderTemplate< DTRecSegment4D >.
Definition at line 46 of file FWDTSegmentProxyBuilder.cc.
References DTRecSegment4D::chamberId(), FWGeometry::contains(), dir, fwLog, relativeConstraints::geom, FWGeometry::getEveShape(), FWEventItem::getGeom(), FWProxyBuilderBase::item(), FWViewType::kAll3DBits, FWViewType::kAllRPZBits, fwlog::kError, FWViewType::kRhoPhi, FWViewType::kRhoZ, DTRecSegment4D::localDirection(), DTRecSegment4D::localPosition(), FWGeometry::localToGlobal(), DTRecSegment4D::phiSegment(), pos, DetId::rawId(), REGISTER_FWPROXYBUILDER, FWProxyBuilderBase::setupAddElement(), DTRecSegment2D::specificRecHits(), DTSuperLayerId::superLayer(), csvLumiCalc::unit, Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and DTRecSegment4D::zSegment().
{
unsigned int rawid = iData.chamberId().rawId();
const FWGeometry *geom = item()->getGeom();
if( ! geom->contains( rawid ))
{
fwLog( fwlog::kError ) << "failed to get geometry of DT chamber with detid: "
<< rawid << std::endl;
return;
}
TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
segmentSet->SetLineWidth( 3 );
setupAddElement( segmentSet, &oItemHolder );
TEveGeoShape* shape = item()->getGeom()->getEveShape( rawid );
if( shape )
{
if( TGeoBBox* box = dynamic_cast<TGeoBBox*>( shape->GetShape()))
{
LocalPoint pos = iData.localPosition();
LocalVector dir = iData.localDirection();
LocalVector unit = dir.unit();
double localPosition[3] = { pos.x(), pos.y(), pos.z() };
double localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
double localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
if (type == FWViewType::kRhoZ) {
localPosition[0]=0;
localDirectionIn[0]=0;
localDirectionOut[0]=0;
}
Double_t distIn = box->DistFromInside( localPosition, localDirectionIn );
Double_t distOut = box->DistFromInside( localPosition, localDirectionOut );
LocalVector vIn = unit * distIn;
LocalVector vOut = -unit * distOut;
float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
static_cast<float>(localPosition[1] + vIn.y()),
static_cast<float>(localPosition[2] + vIn.z())
};
float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
static_cast<float>(localPosition[1] + vOut.y()),
static_cast<float>(localPosition[2] + vOut.z())
};
float globalSegmentInnerPoint[3];
float globalSegmentOuterPoint[3];
geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
TEvePointSet* pointSet = new TEvePointSet;
pointSet->SetMarkerSize(1.5);
setupAddElement( pointSet, &oItemHolder );
std::vector<DTRecHit1D> recHits;
const DTChamberRecSegment2D* phiSeg = iData.phiSegment();
const DTSLRecSegment2D* zSeg = iData.zSegment();
if (type == FWViewType::kRhoPhi && phiSeg) {
recHits = phiSeg->specificRecHits();
}
if (type == FWViewType::kRhoZ && zSeg) {
recHits = zSeg->specificRecHits();
}
for (std::vector<DTRecHit1D>::const_iterator rh=recHits.begin(); rh!=recHits.end(); ++rh){
DTLayerId layerId = (*rh).wireId().layerId();
LocalPoint hpos = (*rh).localPosition();
float hitLocalPos[3]= {hpos.x(), hpos.y(), hpos.z()};
if (layerId.superLayer()==2 && type == FWViewType::kRhoZ) {
hitLocalPos[1]=0;
}
float hitGlobalPoint[3];
geom->localToGlobal(layerId, hitLocalPos, hitGlobalPoint);
pointSet->SetNextPoint(hitGlobalPoint[0], hitGlobalPoint[1], hitGlobalPoint[2]);
}
}
}
}