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

Member Typedef Documentation

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

Definition at line 28 of file SegmentToTrackAssociator.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file SegmentToTrackAssociator.cc.

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

40 {
41 
42  theDTSegmentLabel = iConfig.getParameter<edm::InputTag>( "segmentsDT" );
43  theCSCSegmentLabel = iConfig.getParameter<edm::InputTag>( "segmentsCSC" );
44 
45 }
T getParameter(std::string const &) const
SegmentToTrackAssociator::~SegmentToTrackAssociator ( )
virtual

Definition at line 48 of file SegmentToTrackAssociator.cc.

48 {}

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 58 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, MuonTransientTrackingRecHit::specificBuild(), GeomDet::subDetector(), theCSCSegmentLabel, and theDTSegmentLabel.

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

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

Referenced by associate(), and clear().

intDVector SegmentToTrackAssociator::indexCollectionDT
private

Definition at line 45 of file SegmentToTrackAssociator.h.

Referenced by associate(), and clear().

edm::InputTag SegmentToTrackAssociator::theCSCSegmentLabel
private

Definition at line 49 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().

edm::InputTag SegmentToTrackAssociator::theDTSegmentLabel
private

Definition at line 48 of file SegmentToTrackAssociator.h.

Referenced by associate(), and SegmentToTrackAssociator().