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)
 
virtual ~SegmentToTrackAssociator ()
 

Private Attributes

const GlobalTrackingGeometryglobalTrackingGeometry_
 
intDVector indexCollectionCSC
 
intDVector indexCollectionDT
 
edm::InputTag theCSCSegmentLabel
 
edm::InputTag theDTSegmentLabel
 

Detailed Description

Definition at line 31 of file SegmentToTrackAssociator.h.

Member Typedef Documentation

◆ intDVector

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

Definition at line 33 of file SegmentToTrackAssociator.h.

Constructor & Destructor Documentation

◆ SegmentToTrackAssociator()

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

◆ ~SegmentToTrackAssociator()

SegmentToTrackAssociator::~SegmentToTrackAssociator ( )
virtual

Definition at line 42 of file SegmentToTrackAssociator.cc.

42 {}

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 49 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(), theCSCSegmentLabel, theDTSegmentLabel, HLT_2022v12_cff::track, and trackerHitRTTI::vector.

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

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

◆ clear()

void SegmentToTrackAssociator::clear ( )

Definition at line 44 of file SegmentToTrackAssociator.cc.

References indexCollectionCSC, and indexCollectionDT.

44  {
45  indexCollectionDT.clear();
46  indexCollectionCSC.clear();
47 }

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 52 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

◆ indexCollectionDT

intDVector SegmentToTrackAssociator::indexCollectionDT
private

Definition at line 51 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

◆ theCSCSegmentLabel

edm::InputTag SegmentToTrackAssociator::theCSCSegmentLabel
private

Definition at line 55 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().

◆ theDTSegmentLabel

edm::InputTag SegmentToTrackAssociator::theDTSegmentLabel
private

Definition at line 54 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().