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

Private Attributes

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

Detailed Description

Definition at line 29 of file SegmentToTrackAssociator.h.

Member Typedef Documentation

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

Definition at line 31 of file SegmentToTrackAssociator.h.

Constructor & Destructor Documentation

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

Definition at line 35 of file SegmentToTrackAssociator.cc.

References edm::ParameterSet::getParameter(), theCSCSegmentLabel, and theDTSegmentLabel.

35  {
36  theDTSegmentLabel = iConfig.getParameter<edm::InputTag>("segmentsDT");
37  theCSCSegmentLabel = iConfig.getParameter<edm::InputTag>("segmentsCSC");
38 }
T getParameter(std::string const &) const
SegmentToTrackAssociator::~SegmentToTrackAssociator ( )
virtual

Definition at line 40 of file SegmentToTrackAssociator.cc.

40 {}

Member Function Documentation

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::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByLabel(), GlobalTrackingGeometry::idToDet(), indexCollectionCSC, indexCollectionDT, DetId::rawId(), reco::Track::recHit(), reco::Track::recHitsSize(), groupFilesInBlocks::reverse, segmentTrackAnalyzer_cfi::SelectedSegments, MuonTransientTrackingRecHit::specificBuild(), GeomDet::subDetector(), theCSCSegmentLabel, and theDTSegmentLabel.

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

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

Member Data Documentation

intDVector SegmentToTrackAssociator::indexCollectionCSC
private

Definition at line 50 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

intDVector SegmentToTrackAssociator::indexCollectionDT
private

Definition at line 49 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

edm::InputTag SegmentToTrackAssociator::theCSCSegmentLabel
private

Definition at line 53 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().

edm::InputTag SegmentToTrackAssociator::theDTSegmentLabel
private

Definition at line 52 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().