CMS 3D CMS Logo

SegmentToTrackAssociator.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/03/29 13:18:43 $
5  * $Revision: 1.2 $
6  * \author P. Martinez - IFCA
7  */
8 
24 
30 
32 
33 #include <vector>
34 
36  theDTSegmentLabel = iConfig.getParameter<edm::InputTag>("segmentsDT");
37  theCSCSegmentLabel = iConfig.getParameter<edm::InputTag>("segmentsCSC");
38 }
39 
41 
43  indexCollectionDT.clear();
44  indexCollectionCSC.clear();
45 }
46 
48  const edm::EventSetup& iSetup,
49  const reco::Track& track,
50  std::string TrackRefitterType) {
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") {
176  }
177 
178  return SelectedSegments;
179 }
CSCRecHit2DCollection.h
counter
Definition: counter.py:1
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
MuonTransientTrackingRecHit::specificBuild
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
Definition: MuonTransientTrackingRecHit.h:75
GeomDet
Definition: GeomDet.h:27
SegmentToTrackAssociator::indexCollectionCSC
intDVector indexCollectionCSC
Definition: SegmentToTrackAssociator.h:50
DTRecHitCollection.h
SegmentToTrackAssociator.h
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
getRef.h
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
MuonTransientTrackingRecHit::MuonRecHitContainer
std::vector< MuonRecHitPointer > MuonRecHitContainer
Definition: MuonTransientTrackingRecHit.h:26
edm::Handle< DTRecSegment4DCollection >
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
edm::Ref
Definition: AssociativeIterator.h:58
TrackingRecHit.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackFwd.h
reco::Track
Definition: Track.h:27
IdealMagneticFieldRecord.h
edm::ESHandle< GlobalTrackingGeometry >
SegmentToTrackAssociator::SegmentToTrackAssociator
SegmentToTrackAssociator(const edm::ParameterSet &)
Definition: SegmentToTrackAssociator.cc:35
DTLayerId
Definition: DTLayerId.h:12
GeomDetEnumerators::CSC
Definition: GeomDetEnumerators.h:17
segmentTrackAnalyzer_cfi.SelectedSegments
SelectedSegments
Definition: segmentTrackAnalyzer_cfi.py:13
GlobalTrackingGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCRecHitCollection.h
GeomDetEnumerators::DT
Definition: GeomDetEnumerators.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
SegmentToTrackAssociator::~SegmentToTrackAssociator
virtual ~SegmentToTrackAssociator()
Definition: SegmentToTrackAssociator.cc:40
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
DTRecSegment4D.h
get
#define get
TrajectorySeedCollection.h
MuonSubdetId.h
TrackingRecHit
Definition: TrackingRecHit.h:21
GeomDet.h
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DetId.h
LocalPoint.h
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
SegmentToTrackAssociator::associate
MuonTransientTrackingRecHit::MuonRecHitContainer associate(const edm::Event &, const edm::EventSetup &, const reco::Track &, std::string)
Definition: SegmentToTrackAssociator.cc:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SegmentToTrackAssociator::indexCollectionDT
intDVector indexCollectionDT
Definition: SegmentToTrackAssociator.h:49
DTChamberId
Definition: DTChamberId.h:14
SegmentToTrackAssociator::clear
void clear()
Definition: SegmentToTrackAssociator.cc:42
SegmentToTrackAssociator::theCSCSegmentLabel
edm::InputTag theCSCSegmentLabel
Definition: SegmentToTrackAssociator.h:53
GlobalTrackingGeometry.h
edm::Event
Definition: Event.h:73
RecSegment.h
edm::InputTag
Definition: InputTag.h:15
GeomDet::subDetector
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:38
DTRecSegment4DCollection.h
SegmentToTrackAssociator::theDTSegmentLabel
edm::InputTag theDTSegmentLabel
Definition: SegmentToTrackAssociator.h:52
CSCSegmentCollection.h