CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
SegmentToTrackAssociator Class Reference

#include <SegmentToTrackAssociator.h>

Public Types

typedef std::vector< std::vector< int > > intDVector
 

Public Member Functions

MuonTransientTrackingRecHit::MuonRecHitContainer associate (const edm::Event &, const edm::EventSetup &, const reco::Track &, std::string)
 
void clear ()
 
 SegmentToTrackAssociator (const edm::ParameterSet &, const GlobalTrackingGeometry *GlobalTrackingGeometry, edm::ConsumesCollector &)
 
virtual ~SegmentToTrackAssociator ()=default
 

Private Attributes

const GlobalTrackingGeometryglobalTrackingGeometry_
 
intDVector indexCollectionCSC
 
intDVector indexCollectionDT
 
const edm::InputTag theCSCSegmentLabel
 
const edm::InputTag theDTSegmentLabel
 
const edm::EDGetTokenT< CSCSegmentCollectiontokenCSCSegment_
 
const edm::EDGetTokenT< DTRecSegment4DCollectiontokenDTSegment_
 

Detailed Description

Definition at line 32 of file SegmentToTrackAssociator.h.

Member Typedef Documentation

◆ intDVector

typedef std::vector<std::vector<int> > SegmentToTrackAssociator::intDVector

Definition at line 34 of file SegmentToTrackAssociator.h.

Constructor & Destructor Documentation

◆ SegmentToTrackAssociator()

SegmentToTrackAssociator::SegmentToTrackAssociator ( const edm::ParameterSet iConfig,
const GlobalTrackingGeometry GlobalTrackingGeometry,
edm::ConsumesCollector iC 
)

Definition at line 33 of file SegmentToTrackAssociator.cc.

37  theDTSegmentLabel(iConfig.getParameter<edm::InputTag>("segmentsDT")),
38  theCSCSegmentLabel(iConfig.getParameter<edm::InputTag>("segmentsCSC")),
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< CSCSegmentCollection > tokenCSCSegment_
const GlobalTrackingGeometry * globalTrackingGeometry_
const edm::InputTag theDTSegmentLabel
const edm::InputTag theCSCSegmentLabel
const edm::EDGetTokenT< DTRecSegment4DCollection > tokenDTSegment_

◆ ~SegmentToTrackAssociator()

virtual SegmentToTrackAssociator::~SegmentToTrackAssociator ( )
virtualdefault

Member Function Documentation

◆ associate()

MuonTransientTrackingRecHit::MuonRecHitContainer SegmentToTrackAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Track track,
std::string  TrackRefitterType 
)

Definition at line 47 of file SegmentToTrackAssociator.cc.

References GeomDetEnumerators::CSC, GeomDetEnumerators::DT, TrackingRecHit::geographicalId(), edm::Ref< C, T, F >::get(), globalTrackingGeometry_, GlobalTrackingGeometry::idToDet(), iEvent, indexCollectionCSC, indexCollectionDT, DetId::rawId(), groupFilesInBlocks::reverse, segmentTrackAnalyzer_cfi::SelectedSegments, MuonTransientTrackingRecHit::specificBuild(), GeomDet::subDetector(), tokenCSCSegment_, tokenDTSegment_, HLT_2024v14_cff::track, and trackerHitRTTI::vector.

Referenced by SequenceTypes._ModuleSequenceType::remove(), and SequenceTypes._ModuleSequenceType::replace().

50  {
51  // The segment collections
52  const edm::Handle<DTRecSegment4DCollection>& DTSegments = iEvent.getHandle(tokenDTSegment_);
53 
54  const edm::Handle<CSCSegmentCollection>& CSCSegments = iEvent.getHandle(tokenCSCSegment_);
55 
57 
60 
61  std::vector<int> positionDT;
62  std::vector<int> positionCSC;
63  std::vector<TrackingRecHit*> my4DTrack;
64 
65  //Loop over the hits of the track
66  for (unsigned int counter = 0; counter != track.recHitsSize() - 1; counter++) {
67  TrackingRecHitRef myRef = track.recHit(counter);
68 
69  const TrackingRecHit* rechit = myRef.get();
70  const GeomDet* geomDet = globalTrackingGeometry_->idToDet(rechit->geographicalId());
71 
72  //It's a DT Hit
73  if (geomDet->subDetector() == GeomDetEnumerators::DT) {
74  //Take the layer associated to this hit
75  DTLayerId myLayer(rechit->geographicalId().rawId());
76 
77  int NumberOfDTSegment = 0;
78  //Loop over segments
79  for (segmentDT = DTSegments->begin(); segmentDT != DTSegments->end(); ++segmentDT) {
80  //By default the chamber associated to this Segment is new
81  bool isNewChamber = true;
82 
83  //Loop over segments already included in the vector of segments in the actual track
84  for (std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
85  //If this segment has been used before isNewChamber = false
86  if (NumberOfDTSegment == *positionIt)
87  isNewChamber = false;
88  }
89 
90  //Loop over vectors of segments associated to previous tracks
91  for (std::vector<std::vector<int> >::iterator collect = indexCollectionDT.begin();
92  collect != indexCollectionDT.end();
93  ++collect) {
94  //Loop over segments associated to a track
95  for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
96  positionIt++) {
97  //If this segment was used in a previos track then isNewChamber = false
98  if (NumberOfDTSegment == *positionIt)
99  isNewChamber = false;
100  }
101  }
102 
103  //If the chamber is new
104  if (isNewChamber) {
105  DTChamberId myChamber((*segmentDT).geographicalId().rawId());
106  //If the layer of the hit belongs to the chamber of the 4D Segment
107  if (myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() &&
108  myLayer.sector() == myChamber.sector()) {
109  //push position of the segment and tracking rechit
110  positionDT.push_back(NumberOfDTSegment);
111  const GeomDet* DTgeomDet = globalTrackingGeometry_->idToDet(myChamber);
112  SelectedSegments.push_back(
114 
115  //edm::LogWarning("Alignment") << "TagSeg: " << "NumberOfDTSegment " << NumberOfDTSegment << " Wheel " << myChamber.wheel() << " Sector " << myChamber.sector() << " Chamber " << myChamber.station() << std::endl;
116  }
117  }
118  NumberOfDTSegment++;
119  }
120  //In case is a CSC
121  } else if (geomDet->subDetector() == GeomDetEnumerators::CSC) {
122  //Take the layer associated to this hit
123  CSCDetId myLayer(rechit->geographicalId().rawId());
124 
125  int NumberOfCSCSegment = 0;
126  //Loop over 4Dsegments
127  for (segmentCSC = CSCSegments->begin(); segmentCSC != CSCSegments->end(); segmentCSC++) {
128  //By default the chamber associated to the segment is new
129  bool isNewChamber = true;
130  //Loop over segments in the current track
131  for (std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end();
132  positionIt++) {
133  //If this segment has been used then newchamber = false
134  if (NumberOfCSCSegment == *positionIt)
135  isNewChamber = false;
136  }
137  //Loop over vectors of segments in previous tracks
138  for (std::vector<std::vector<int> >::iterator collect = indexCollectionCSC.begin();
139  collect != indexCollectionCSC.end();
140  ++collect) {
141  //Loop over segments in a track
142  for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
143  positionIt++) {
144  //If the segment was used in a previous track isNewChamber = false
145  if (NumberOfCSCSegment == *positionIt)
146  isNewChamber = false;
147  }
148  }
149  //If the chamber is new
150  if (isNewChamber) {
151  CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
152  //If the chambers are the same
153  if (myLayer.chamberId() == myChamber.chamberId()) {
154  //push
155  positionCSC.push_back(NumberOfCSCSegment);
156  const GeomDet* CSCgeomDet = globalTrackingGeometry_->idToDet(myChamber);
157  SelectedSegments.push_back(
158  MuonTransientTrackingRecHit::specificBuild(CSCgeomDet, (TrackingRecHit*)&*segmentCSC));
159  }
160  }
161  NumberOfCSCSegment++;
162  }
163  }
164  }
165 
166  indexCollectionDT.push_back(positionDT);
167  indexCollectionCSC.push_back(positionCSC);
168 
169  if (TrackRefitterType == "CosmicLike") {
171  }
172 
173  return SelectedSegments;
174 }
const edm::EDGetTokenT< CSCSegmentCollection > tokenCSCSegment_
const GeomDet * idToDet(DetId) const override
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
int iEvent
Definition: GenABIO.cc:224
DetId geographicalId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const GlobalTrackingGeometry * globalTrackingGeometry_
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:38
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:226
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
const edm::EDGetTokenT< DTRecSegment4DCollection > tokenDTSegment_

◆ clear()

void SegmentToTrackAssociator::clear ( )

Definition at line 42 of file SegmentToTrackAssociator.cc.

References indexCollectionCSC, and indexCollectionDT.

42  {
43  indexCollectionDT.clear();
44  indexCollectionCSC.clear();
45 }

Member Data Documentation

◆ globalTrackingGeometry_

const GlobalTrackingGeometry* SegmentToTrackAssociator::globalTrackingGeometry_
private

Definition at line 57 of file SegmentToTrackAssociator.h.

Referenced by associate().

◆ indexCollectionCSC

intDVector SegmentToTrackAssociator::indexCollectionCSC
private

Definition at line 55 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

◆ indexCollectionDT

intDVector SegmentToTrackAssociator::indexCollectionDT
private

Definition at line 54 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

◆ theCSCSegmentLabel

const edm::InputTag SegmentToTrackAssociator::theCSCSegmentLabel
private

Definition at line 60 of file SegmentToTrackAssociator.h.

◆ theDTSegmentLabel

const edm::InputTag SegmentToTrackAssociator::theDTSegmentLabel
private

Definition at line 59 of file SegmentToTrackAssociator.h.

◆ tokenCSCSegment_

const edm::EDGetTokenT<CSCSegmentCollection> SegmentToTrackAssociator::tokenCSCSegment_
private

Definition at line 62 of file SegmentToTrackAssociator.h.

Referenced by associate().

◆ tokenDTSegment_

const edm::EDGetTokenT<DTRecSegment4DCollection> SegmentToTrackAssociator::tokenDTSegment_
private

Definition at line 61 of file SegmentToTrackAssociator.h.

Referenced by associate().