Skip to content

Commit

Permalink
remove invalid usage of TrajectorySeed::recHits()
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Jun 6, 2020
1 parent 96a951e commit 38b49a2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 122 deletions.
5 changes: 1 addition & 4 deletions RecoEgamma/EgammaPhotonAlgos/src/ConversionSeedFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Geometry
#include "Geometry/Records/interface/IdealGeometryRecord.h"
//
#include "RecoTracker/MeasurementDet/interface/StartingLayerFinder.h"
#include "RecoTracker/MeasurementDet/interface/LayerCollector.h"
//

Expand Down Expand Up @@ -111,9 +110,7 @@ void ConversionSeedFinder::findLayers(const FreeTrajectoryState& traj) {

StraightLinePropagator prop(&(*theMF_), alongMomentum);

StartingLayerFinder starter(&prop, this->getMeasurementTracker());

LayerCollector collector(theNavigationSchool_, &prop, &starter, 5., 5.);
LayerCollector collector(theNavigationSchool_, &prop, this->getMeasurementTracker(), 5., 5.);

theLayerList_ = collector.allLayers(traj);

Expand Down
2 changes: 0 additions & 2 deletions RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.h"

#include <Geometry/Records/interface/GlobalTrackingGeometryRecord.h>
//#include <RecoTracker/Record/interface/TrackerRecoGeometryRecord.h>
#include <RecoTracker/Record/interface/CkfComponentsRecord.h>
#include <MagneticField/Records/interface/IdealMagneticFieldRecord.h>
#include <TrackingTools/Records/interface/TrackingComponentsRecord.h>
Expand All @@ -15,7 +14,6 @@

#include <RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h>

#include "RecoTracker/MeasurementDet/interface/StartingLayerFinder.h"
#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"

#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
Expand Down
13 changes: 7 additions & 6 deletions RecoTracker/MeasurementDet/interface/LayerCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ class LayerCollector {
public:
LayerCollector(NavigationSchool const* aSchool,
const Propagator* aPropagator,
const StartingLayerFinder* aFinder,
const MeasurementTracker* tracker,
float dr,
float dz)
: theSchool(aSchool), thePropagator(aPropagator), theStartingLayerFinder(aFinder), theDeltaR(dr), theDeltaZ(dz) {}

~LayerCollector() {}
: theSchool(aSchool),
thePropagator(aPropagator),
theStartingLayerFinder{*aPropagator, *tracker},
theDeltaR(dr),
theDeltaZ(dz) {}

std::vector<const DetLayer*> allLayers(const FTS& aFts) const;
std::vector<const BarrelDetLayer*> barrelLayers(const FTS& aFts) const;
std::vector<const ForwardDetLayer*> forwardLayers(const FTS& aFts) const;

const Propagator* propagator() const { return thePropagator; }
const StartingLayerFinder* finder() const { return theStartingLayerFinder; }
float deltaR() const { return theDeltaR; }
float deltaZ() const { return theDeltaZ; }

private:
NavigationSchool const* theSchool;
const Propagator* thePropagator;
const StartingLayerFinder* theStartingLayerFinder;
const StartingLayerFinder theStartingLayerFinder;
float theDeltaR;
float theDeltaZ;

Expand Down
43 changes: 10 additions & 33 deletions RecoTracker/MeasurementDet/interface/StartingLayerFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,29 @@
* have a DetLayer
*/

class PTrajectoryStateOnDet;

class StartingLayerFinder {
private:
typedef FreeTrajectoryState FTS;
typedef TrajectoryStateOnSurface TSOS;
typedef std::pair<float, float> Range;

public:
StartingLayerFinder(const Propagator* aPropagator, const MeasurementTracker* tracker)
:

thePropagator(aPropagator),
StartingLayerFinder(Propagator const& aPropagator, MeasurementTracker const& tracker)
: thePropagator(aPropagator),
theMeasurementTracker(tracker),
thePixelLayersValid(false),
theFirstPixelBarrelLayer(nullptr),
theFirstNegPixelFwdLayer(0),
theFirstPosPixelFwdLayer(0) {}

~StartingLayerFinder() {}

std::vector<const DetLayer*> startingLayers(const FTS& aFts, float dr, float dz) const;

std::vector<const DetLayer*> startingLayers(const TrajectorySeed& aSeed) const;
std::vector<const DetLayer*> operator()(const FreeTrajectoryState& aFts, float dr, float dz) const;

private:
const BarrelDetLayer* firstPixelBarrelLayer() const;
const std::vector<const ForwardDetLayer*> firstNegPixelFwdLayer() const;
const std::vector<const ForwardDetLayer*> firstPosPixelFwdLayer() const;

const Propagator* propagator() const { return thePropagator; }

private:
const Propagator* thePropagator;
const MeasurementTracker* theMeasurementTracker;
mutable bool thePixelLayersValid;
mutable const BarrelDetLayer* theFirstPixelBarrelLayer;
Propagator const& thePropagator;
MeasurementTracker const& theMeasurementTracker;
mutable bool thePixelLayersValid = false;
mutable const BarrelDetLayer* theFirstPixelBarrelLayer = nullptr;
mutable std::vector<const ForwardDetLayer*> theFirstNegPixelFwdLayer;
mutable std::vector<const ForwardDetLayer*> theFirstPosPixelFwdLayer;

void checkPixelLayers() const;

inline bool rangesIntersect(const Range& a, const Range& b) const {
if (a.first > b.second || b.first > a.second)
return false;
else
return true;
}
};
#endif //TR_StartingLayerFinder_H_

#endif
2 changes: 1 addition & 1 deletion RecoTracker/MeasurementDet/src/LayerCollector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vector<const DetLayer*> LayerCollector::allLayers(const FTS& aFts) const {

FTS myFts(aFts.parameters());

vector<const DetLayer*> nextLayers = finder()->startingLayers(myFts, deltaR(), deltaZ());
vector<const DetLayer*> nextLayers = theStartingLayerFinder(myFts, deltaR(), deltaZ());

vector<const DetLayer*> dummy;

Expand Down
65 changes: 18 additions & 47 deletions RecoTracker/MeasurementDet/src/StartingLayerFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@

using namespace std;

vector<const DetLayer*> StartingLayerFinder::startingLayers(const FTS& aFts, float dr, float dz) const {
namespace {

typedef std::pair<float, float> Range;

inline bool rangesIntersect(const Range& a, const Range& b) {
if (a.first > b.second || b.first > a.second)
return false;
else
return true;
}
}; // namespace

vector<const DetLayer*> StartingLayerFinder::operator()(const FreeTrajectoryState& aFts, float dr, float dz) const {
vector<const DetLayer*> mylayers;
mylayers.reserve(3);

FTS fastFts(aFts.parameters());
FreeTrajectoryState fastFts(aFts.parameters());

//barrel pixel
TSOS pTsos = propagator()->propagate(fastFts, firstPixelBarrelLayer()->surface());
TrajectoryStateOnSurface pTsos = thePropagator.propagate(fastFts, firstPixelBarrelLayer()->surface());

if (pTsos.isValid()) {
Range barrZRange(
Expand All @@ -38,7 +50,7 @@ vector<const DetLayer*> StartingLayerFinder::startingLayers(const FTS& aFts, flo
//negative fwd pixel

for (auto infwd : firstPosPixelFwdLayer()) {
pTsos = propagator()->propagate(fastFts, infwd->surface());
pTsos = thePropagator.propagate(fastFts, infwd->surface());
if (pTsos.isValid()) {
Range nfwdRRange(infwd->specificSurface().innerRadius(), infwd->specificSurface().outerRadius());
Range trajRRange(pTsos.globalPosition().perp() - dr, pTsos.globalPosition().perp() + dr);
Expand All @@ -50,7 +62,7 @@ vector<const DetLayer*> StartingLayerFinder::startingLayers(const FTS& aFts, flo

//positive fwd pixel
for (auto ipfwd : firstPosPixelFwdLayer()) {
pTsos = propagator()->propagate(fastFts, ipfwd->surface());
pTsos = thePropagator.propagate(fastFts, ipfwd->surface());
if (pTsos.isValid()) {
Range pfwdRRange(ipfwd->specificSurface().innerRadius(), ipfwd->specificSurface().outerRadius());
Range trajRRange(pTsos.globalPosition().perp() - dr, pTsos.globalPosition().perp() + dr);
Expand All @@ -63,47 +75,6 @@ vector<const DetLayer*> StartingLayerFinder::startingLayers(const FTS& aFts, flo
return mylayers;
}

vector<const DetLayer*> StartingLayerFinder::startingLayers(const TrajectorySeed& aSeed) const {
float dr = 0., dz = 0.;

if (propagator()->propagationDirection() != aSeed.direction())
return vector<const DetLayer*>();

if (aSeed.nHits() != 2)
return vector<const DetLayer*>();

auto firstHit = aSeed.recHits().begin();
const TrackingRecHit* recHit1 = &(*firstHit);
const DetLayer* hit1Layer = theMeasurementTracker->geometricSearchTracker()->detLayer(recHit1->geographicalId());

auto secondHit = aSeed.recHits().end();
const TrackingRecHit* recHit2 = &(*secondHit);
const DetLayer* hit2Layer = theMeasurementTracker->geometricSearchTracker()->detLayer(recHit2->geographicalId());

GeomDetEnumerators::Location p1 = hit1Layer->location();
GeomDetEnumerators::Location p2 = hit2Layer->location();

if (p1 == GeomDetEnumerators::barrel && p2 == GeomDetEnumerators::barrel) {
dr = 0.1;
dz = 5.;
} else if (p1 == GeomDetEnumerators::endcap && p2 == GeomDetEnumerators::endcap) {
dr = 5.;
dz = 0.1;
} else {
dr = 0.1;
dz = 0.1;
}

const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet(DetId(aSeed.startingState().detId()));

TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(
aSeed.startingState(), &(gdet->surface()), thePropagator->magneticField());

const FreeTrajectoryState* fts = tsos.freeTrajectoryState();

return startingLayers(*fts, dr, dz);
}

const BarrelDetLayer* StartingLayerFinder::firstPixelBarrelLayer() const {
checkPixelLayers();
return theFirstPixelBarrelLayer;
Expand All @@ -121,7 +92,7 @@ const vector<const ForwardDetLayer*> StartingLayerFinder::firstPosPixelFwdLayer(

void StartingLayerFinder::checkPixelLayers() const {
if (!thePixelLayersValid) {
const GeometricSearchTracker* theGeometricSearchTracker = theMeasurementTracker->geometricSearchTracker();
const GeometricSearchTracker* theGeometricSearchTracker = theMeasurementTracker.geometricSearchTracker();

theFirstPixelBarrelLayer = theGeometricSearchTracker->pixelBarrelLayers().front();
theFirstNegPixelFwdLayer = theGeometricSearchTracker->negPixelForwardLayers();
Expand Down
26 changes: 0 additions & 26 deletions Validation/RecoMuon/src/MuonSeedTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,36 +189,10 @@ pair<bool, reco::Track> MuonSeedTrack::buildTrackAtPCA(const TrajectorySeed& see
math::XYZVector persistentMomentum(p.x(), p.y(), p.z());

double dummyNDOF = 1.0;
//double ndof = computeNDOF(seed);
double dummyChi2 = 1.0;

reco::Track track(
dummyChi2, dummyNDOF, persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError());

return pair<bool, reco::Track>(true, track);
}

/*!
* Calculates number of degrees of freedom for the TrajectorySeed
*/
double MuonSeedTrack::computeNDOF(const TrajectorySeed& trajectory) const {
const string metname = "MuonSeedTrack";

auto recHits1 = (trajectory.recHits().begin());
auto recHits2 = (trajectory.recHits().end());

double ndof = 0.;

if ((*recHits1).isValid())
ndof += (*recHits1).dimension();
if ((*recHits2).isValid())
ndof += (*recHits2).dimension();

//const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
//for(Trajectory::RecHitContainer::const_iterator rechit = transRecHits.begin();
// rechit != transRecHits.end(); ++rechit)
//if ((*rechit)->isValid()) ndof += (*rechit)->dimension();

// FIXME! in case of Boff is dof - 4
return max(ndof - 5., 0.);
}
3 changes: 0 additions & 3 deletions Validation/RecoMuon/src/MuonSeedTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class MuonSeedTrack : public edm::EDProducer {
theAlias = alias;
}

/// compute the TrajectorySeed's degree of freedom
double computeNDOF(const TrajectorySeed&) const;

/// Build a track at the PCA WITHOUT any vertex constriant
std::pair<bool, reco::Track> buildTrackAtPCA(const TrajectorySeed&) const;

Expand Down

0 comments on commit 38b49a2

Please sign in to comment.