45 metname =
"SegmentsTrackAssociator";
59 iEvent.
getByToken(dtSegmentsToken, dtSegments);
61 iEvent.
getByToken(cscSegmentsToken, cscSegments);
71 for (
auto const& recHit : Track.
recHits()) {
72 if (!recHit->isValid())
78 DetId idRivHit = recHit->geographicalId();
83 LocalPoint posTrackRecHit = recHit->localPosition();
91 range = dtSegments->get(chamberId);
94 for (segment = range.first; segment != range.second; segment++) {
95 DetId id = segment->geographicalId();
96 const GeomDet* det = theTrackingGeometry->idToDet(
id);
97 vector<const TrackingRecHit*> segments2D = (&(*segment))->
recHits();
99 vector<const TrackingRecHit*> dtRecHits;
101 for (vector<const TrackingRecHit*>::const_iterator segm2D = segments2D.begin(); segm2D != segments2D.end();
103 vector<const TrackingRecHit*> rHits1D = (*segm2D)->recHits();
104 for (
int hit = 0;
hit < int(rHits1D.size());
hit++) {
105 dtRecHits.push_back(rHits1D[
hit]);
110 for (
unsigned int hit = 0;
hit < dtRecHits.size();
hit++) {
111 DetId idRivHitSeg = (*dtRecHits[
hit]).geographicalId();
112 LocalPoint posDTSegment = segment->localPosition();
113 LocalPoint posSegDTRecHit = (*dtRecHits[
hit]).localPosition();
115 double rDT =
sqrt(
pow((posSegDTRecHit.
x() - posTrackRecHit.
x()), 2) +
116 pow((posSegDTRecHit.
y() - posTrackRecHit.
y()), 2) +
117 pow((posSegDTRecHit.
z() - posTrackRecHit.
z()), 2));
119 if (idRivHit == idRivHitSeg && rDT < 0.0001) {
120 if (selectedDtSegments.empty()) {
122 LogTrace(
metname) <<
"First selected segment (from DT). Position : " << posDTSegment
123 <<
" Chamber : " << segment->chamberId();
126 for (
int segm = 0; segm < int(selectedDtSegments.size()); ++segm) {
127 double dist =
sqrt(
pow((((*(selectedDtSegments[segm])).localPosition()).
x() - posDTSegment.
x()), 2) +
128 pow((((*(selectedDtSegments[segm])).localPosition()).
y() - posDTSegment.
y()), 2) +
129 pow((((*(selectedDtSegments[segm])).localPosition()).
z() - posDTSegment.
z()), 2));
134 if (check ==
int(selectedDtSegments.size())) {
136 LogTrace(
metname) <<
"New DT selected segment. Position : " << posDTSegment
137 <<
" Chamber : " << segment->chamberId();
150 LocalPoint posTrackRecHit = recHit->localPosition();
158 int ring = tempchamberId.ring();
159 int station = tempchamberId.station();
160 int endcap = tempchamberId.endcap();
161 int chamber = tempchamberId.chamber();
162 CSCDetId chamberId(endcap, station, ring, chamber, 0);
165 range = cscSegments->get(chamberId);
167 for (segment2 = range.first; segment2 != range.second; segment2++) {
168 DetId id2 = segment2->geographicalId();
169 const GeomDet* det2 = theTrackingGeometry->idToDet(id2);
172 vector<const TrackingRecHit*> cscRecHits = (&(*segment2))->
recHits();
175 for (
unsigned int hit = 0;
hit < cscRecHits.size();
hit++) {
176 DetId idRivHitSeg = (*cscRecHits[
hit]).geographicalId();
177 LocalPoint posSegCSCRecHit = (*cscRecHits[
hit]).localPosition();
178 LocalPoint posCSCSegment = segment2->localPosition();
180 double rCSC =
sqrt(
pow((posSegCSCRecHit.
x() - posTrackRecHit.
x()), 2) +
181 pow((posSegCSCRecHit.
y() - posTrackRecHit.
y()), 2) +
182 pow((posSegCSCRecHit.
z() - posTrackRecHit.
z()), 2));
184 if (idRivHit == idRivHitSeg && rCSC < 0.0001) {
185 if (selectedCscSegments.empty()) {
187 LogTrace(
metname) <<
"First selected segment (from CSC). Position: " << posCSCSegment;
190 for (
int n = 0;
n < int(selectedCscSegments.size());
n++) {
191 double dist =
sqrt(
pow(((*(selectedCscSegments[
n])).localPosition().
x() - posCSCSegment.
x()), 2) +
192 pow(((*(selectedCscSegments[n])).localPosition().
y() - posCSCSegment.
y()), 2) +
193 pow(((*(selectedCscSegments[n])).localPosition().
z() - posCSCSegment.
z()), 2));
197 if (check ==
int(selectedCscSegments.size())) {
199 LogTrace(
metname) <<
"New CSC segment selected. Position : " << posCSCSegment;
219 copy(selectedDtSegments.begin(), selectedDtSegments.end(), back_inserter(selectedSegments));
220 LogTrace(
metname) <<
"N selected Dt segments:" << selectedDtSegments.size();
221 copy(selectedCscSegments.begin(), selectedCscSegments.end(), back_inserter(selectedSegments));
222 LogTrace(
metname) <<
"N selected Csc segments:" << selectedCscSegments.size();
223 LogTrace(
metname) <<
"N selected segments:" << selectedSegments.size();
225 return selectedSegments;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
virtual ~SegmentsTrackAssociator()
Destructor.
constexpr uint32_t rawId() const
get the raw id
const uint16_t range(const Frame &aFrame)
SegmentsTrackAssociator(const edm::ParameterSet &, edm::ConsumesCollector &iC)
Constructor.
C::const_iterator const_iterator
constant access iterator type
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
auto recHits() const
Access to reconstructed hits on the track.
MuonTransientTrackingRecHit::MuonRecHitContainer associate(const edm::Event &, const edm::EventSetup &, const reco::Track &)
Get the analysis.
static void check(T const &p, std::string const &id, SelectedProducts const &iProducts, bool iVerbose)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
Power< A, B >::type pow(const A &a, const B &b)
constexpr Detector det() const
get the detector field from this detid