Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hits associated to DT segments. Fix DT segments in RhoZ view, ... #1092

Merged
merged 1 commit into from Oct 21, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 48 additions & 3 deletions Fireworks/Muons/plugins/FWDTSegmentProxyBuilder.cc
Expand Up @@ -12,33 +12,39 @@

#include "TEveGeoNode.h"
#include "TEveStraightLineSet.h"
#include "TEvePointSet.h"
#include "TGeoArb8.h"

#include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
#include "Fireworks/Core/interface/FWEventItem.h"
#include "Fireworks/Core/interface/FWGeometry.h"
#include "Fireworks/Core/interface/fwLog.h"

#include "DataFormats/MuonDetId/interface/DTChamberId.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"

#include <vector>

class FWDTSegmentProxyBuilder : public FWSimpleProxyBuilderTemplate<DTRecSegment4D>
{
public:
FWDTSegmentProxyBuilder( void ) {}
virtual ~FWDTSegmentProxyBuilder( void ) {}

virtual bool haveSingleProduct() const override { return false; }

REGISTER_PROXYBUILDER_METHODS();

private:
FWDTSegmentProxyBuilder( const FWDTSegmentProxyBuilder& );
const FWDTSegmentProxyBuilder& operator=( const FWDTSegmentProxyBuilder& );

void build( const DTRecSegment4D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
void buildViewType( const DTRecSegment4D& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type, const FWViewContext* ) override;
};

void
FWDTSegmentProxyBuilder::build( const DTRecSegment4D& iData,
unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
FWDTSegmentProxyBuilder::buildViewType( const DTRecSegment4D& iData,
unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type, const FWViewContext* )
{
unsigned int rawid = iData.chamberId().rawId();
const FWGeometry *geom = item()->getGeom();
Expand Down Expand Up @@ -68,6 +74,14 @@ FWDTSegmentProxyBuilder::build( const DTRecSegment4D& iData,
double localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
double localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };

// In RhoZ view, draw segments at the middle of the chamber, otherwise they won't align with 1D rechits,
// for which only one coordinate is known.
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;
Expand All @@ -89,6 +103,37 @@ FWDTSegmentProxyBuilder::build( const DTRecSegment4D& iData,

segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );


// Draw hits included in the segment
TEvePointSet* pointSet = new TEvePointSet;
// FIXME: This should be set elsewhere.
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) {
// In RhoZ view, draw theta SL hits at the middle of the chamber, otherwise they won't align with 1D rechits,
// for which only one coordinate is known.
hitLocalPos[1]=0;
}
float hitGlobalPoint[3];
geom->localToGlobal(layerId, hitLocalPos, hitGlobalPoint);
pointSet->SetNextPoint(hitGlobalPoint[0], hitGlobalPoint[1], hitGlobalPoint[2]);
}
}
}
}
Expand Down