CMS 3D CMS Logo

CSCOverlapsTrackPreparation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CSCOverlapsTrackPreparation
4 // Class: CSCOverlapsTrackPreparation
5 //
13 //
14 // Original Author: Jim Pivarski
15 // Created: Wed Dec 12 13:31:55 CST 2007
16 // $Id: CSCOverlapsTrackPreparation.cc,v 1.8 2011/03/22 09:49:50 innocent Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
31 
32 // references
49 
52 #include "TTree.h"
53 
54 // products
57 
58 //
59 // class decleration
60 //
61 
63 public:
66 
67 private:
69 
70  void beginJob() override;
71  void produce(edm::Event&, const edm::EventSetup&) override;
72  void endJob() override;
73 
74  // ----------member data ---------------------------
76 };
77 
78 //
79 // constants, enums and typedefs
80 //
81 
82 //
83 // static data member definitions
84 //
85 
86 //
87 // constructors and destructor
88 //
90  : m_src(iConfig.getParameter<edm::InputTag>("src")) {
91  produces<std::vector<Trajectory>>();
92  produces<TrajTrackAssociationCollection>();
93 }
94 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 }
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called to produce the data ------------
107  iEvent.getByLabel(m_src, tracks);
108 
109  edm::ESHandle<CSCGeometry> cscGeometry;
110  iSetup.get<MuonGeometryRecord>().get(cscGeometry);
111 
114 
116  iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
117 
118  MuonTransientTrackingRecHitBuilder muonTransBuilder;
119 
120  // Create a collection of Trajectories, to put in the Event
121  auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
122 
123  // Remember which trajectory is associated with which track
124  std::map<edm::Ref<std::vector<Trajectory>>::key_type, edm::Ref<reco::TrackCollection>::key_type> reference_map;
125  edm::Ref<std::vector<Trajectory>>::key_type trajCounter = 0;
127 
128  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
129  trackCounter++;
130 
131  // now we'll actually put hits on the new trajectory
132  // these must be in lock-step
134  std::vector<TrajectoryMeasurement::ConstRecHitPointer> transHits;
135  std::vector<TrajectoryStateOnSurface> TSOSes;
136 
137  for (auto const& hit : track->recHits()) {
138  DetId id = hit->geographicalId();
139  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
140  const Surface& layerSurface = cscGeometry->idToDet(id)->surface();
141  TrajectoryMeasurement::ConstRecHitPointer hitPtr(muonTransBuilder.build(hit, globalGeometry));
142 
143  AlgebraicVector5 params; // meaningless, CSCOverlapsAlignmentAlgorithm does the fit internally
144  params[0] = 1.; // straight-forward direction
145  params[1] = 0.;
146  params[2] = 0.;
147  params[3] = 0.; // center of the chamber
148  params[4] = 0.;
149  LocalTrajectoryParameters localTrajectoryParameters(params, 1., false);
150  LocalTrajectoryError localTrajectoryError(0.001, 0.001, 0.001, 0.001, 0.001);
151 
152  // these must be in lock-step
153  clonedHits.push_back(hit->clone());
154  transHits.push_back(hitPtr);
155  TSOSes.push_back(
156  TrajectoryStateOnSurface(localTrajectoryParameters, localTrajectoryError, layerSurface, &*magneticField));
157  } // end if CSC
158  } // end loop over hits
159 
160  assert(clonedHits.size() == transHits.size());
161  assert(transHits.size() == TSOSes.size());
162 
163  // build the trajectory
164  if (!clonedHits.empty()) {
165  PTrajectoryStateOnDet const PTraj =
166  trajectoryStateTransform::persistentState(*(TSOSes.begin()), clonedHits.begin()->geographicalId().rawId());
167  TrajectorySeed trajectorySeed(PTraj, clonedHits, alongMomentum);
168  Trajectory trajectory(trajectorySeed, alongMomentum);
169 
170  edm::OwnVector<TrackingRecHit>::const_iterator clonedHit = clonedHits.begin();
171  std::vector<TrajectoryMeasurement::ConstRecHitPointer>::const_iterator transHitPtr = transHits.begin();
172  std::vector<TrajectoryStateOnSurface>::const_iterator TSOS = TSOSes.begin();
173  for (; clonedHit != clonedHits.end(); ++clonedHit, ++transHitPtr, ++TSOS) {
174  trajectory.push(TrajectoryMeasurement(*TSOS, *TSOS, *TSOS, (*transHitPtr)));
175  }
176 
177  trajectoryCollection->push_back(trajectory);
178 
179  // Remember which Trajectory is associated with which Track
180  trajCounter++;
181  reference_map[trajCounter] = trackCounter;
182 
183  } // end if there are any clonedHits/TSOSes to work with
184  } // end loop over tracks
185 
186  unsigned int numTrajectories = trajectoryCollection->size();
187 
188  // insert the trajectories into the Event
189  edm::OrphanHandle<std::vector<Trajectory>> ohTrajs = iEvent.put(std::move(trajectoryCollection));
190 
191  // create the trajectory <-> track association map
192  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
193 
194  for (trajCounter = 0; trajCounter < numTrajectories; trajCounter++) {
195  edm::Ref<reco::TrackCollection>::key_type trackCounter = reference_map[trajCounter];
196 
197  trajTrackMap->insert(edm::Ref<std::vector<Trajectory>>(ohTrajs, trajCounter),
198  edm::Ref<reco::TrackCollection>(tracks, trackCounter));
199  }
200  // and put it in the Event, also
201  iEvent.put(std::move(trajTrackMap));
202 }
203 
204 // ------------ method called once each job just before starting event loop ------------
206 
207 // ------------ method called once each job just after ending the event loop ------------
209 
210 //define this as a plug-in
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
CSCOverlapsTrackPreparation
Definition: CSCOverlapsTrackPreparation.cc:62
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
EDProducer.h
ESHandle.h
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm
HLT enums.
Definition: AlignableModifier.h:19
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
CSCGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
CSCOverlapsTrackPreparation::beginJob
void beginJob() override
Definition: CSCOverlapsTrackPreparation.cc:205
cms::cuda::assert
assert(be >=bs)
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
Surface
Definition: Surface.h:36
TrackingRecHitFwd.h
CSCOverlapsTrackPreparation::kNothing
Definition: CSCOverlapsTrackPreparation.cc:68
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
edm::Handle< reco::TrackCollection >
CSCDetId.h
edm::Ref
Definition: AssociativeIterator.h:58
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
edm::OwnVector::empty
bool empty() const
Definition: OwnVector.h:305
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
TrackingRecHit.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Surface.h
CSCOverlapsTrackPreparation::CSCOverlapsTrackPreparation
CSCOverlapsTrackPreparation(const edm::ParameterSet &)
Definition: CSCOverlapsTrackPreparation.cc:89
Service.h
IdealMagneticFieldRecord.h
edm::ESHandle< CSCGeometry >
CSCOverlapsTrackPreparation::~CSCOverlapsTrackPreparation
~CSCOverlapsTrackPreparation() override
Definition: CSCOverlapsTrackPreparation.cc:95
TrajTrackAssociation.h
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
GlobalTrackingGeometryRecord.h
TFileService.h
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CSCOverlapsTrackPreparation::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CSCOverlapsTrackPreparation.cc:105
Definitions.h
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonTransientTrackingRecHitBuilder::build
RecHitPointer build(const TrackingRecHit *p, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
Call the MuonTransientTrackingRecHit::specificBuild.
Definition: MuonTransientTrackingRecHitBuilder.cc:20
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
get
#define get
Trajectory::push
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
MuonSubdetId.h
CSCOverlapsTrackPreparation::endJob
void endJob() override
Definition: CSCOverlapsTrackPreparation.cc:208
CSCOverlapsTrackPreparation::kSimpleFit
Definition: CSCOverlapsTrackPreparation.cc:68
edm::Ref::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
Trajectory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
TrajectoryMeasurement::ConstRecHitPointer
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
Definition: TrajectoryMeasurement.h:28
Trajectory
Definition: Trajectory.h:38
Frameworkfwd.h
MuonTransientTrackingRecHitBuilder.h
CSCOverlapsTrackPreparation::kAllButOne
Definition: CSCOverlapsTrackPreparation.cc:68
TrajectorySeed
Definition: TrajectorySeed.h:18
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
TrajectoryStateTransform.h
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
DetId::Muon
Definition: DetId.h:26
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
ParameterSet.h
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
MuonGeometryRecord.h
GlobalTrackingGeometry.h
edm::Event
Definition: Event.h:73
MuonTransientTrackingRecHitBuilder
Definition: MuonTransientTrackingRecHitBuilder.h:12
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
TSOS
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
edm::InputTag
Definition: InputTag.h:15
alongMomentum
Definition: PropagationDirection.h:4
CSCOverlapsTrackPreparation::m_src
edm::InputTag m_src
Definition: CSCOverlapsTrackPreparation.cc:75
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
CSCGeometry.h
CSCOverlapsTrackPreparation::kExtrapolate
Definition: CSCOverlapsTrackPreparation.cc:68