CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastTSGFromIOHit.cc
Go to the documentation of this file.
2 
18 
20 {
21 
22  theCategory = "FastSimulation|Muons||FastTSGFromIOHit";
23 
24  thePtCut = iConfig.getParameter<double>("PtCut");
25 
26  simTracksTk = iC.consumes<edm::SimTrackContainer>(iConfig.getParameter<edm::InputTag>("SimTrackCollectionLabel"));
27  const auto & seedLabels = iConfig.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels");
28  for(const auto & seedLabel : seedLabels)
29  {
30  seedsTks.push_back(iC.consumes<TrajectorySeedCollection>(seedLabel));
31  }
32 
33 }
34 
36 {
37 
38  LogTrace(theCategory) << " FastTSGFromIOHit dtor called ";
39 
40 }
41 
42 void FastTSGFromIOHit::trackerSeeds(const TrackCand& staMuon, const TrackingRegion& region, const TrackerTopology *tTopo, std::vector<TrajectorySeed> & result)
43 {
44  // Make a ref to l2 muon
45  reco::TrackRef muRef(staMuon.second);
46 
47  // Cut on muons with low momenta
48  if ( muRef->pt() < thePtCut
49  || muRef->innerMomentum().Rho() < thePtCut
50  || muRef->innerMomentum().R() < 2.5 )
51  {
52  return;
53  }
54 
55  // Retrieve the Monte Carlo truth (SimTracks)
57  getEvent()->getByToken(simTracksTk,simTracks);
58 
59  // Retrieve Seed collection
60  std::vector<edm::Handle<TrajectorySeedCollection> > seedCollections;
61  seedCollections.resize(seedsTks.size());
62  for ( unsigned iSeed = 0 ; iSeed < seedsTks.size() ; iSeed++)
63  {
64  getEvent()->getByToken(seedsTks[iSeed],seedCollections[iSeed]);
65  }
66 
67  // cast the tracking region
68  const RectangularEtaPhiTrackingRegion & regionRef = dynamic_cast<const RectangularEtaPhiTrackingRegion & > (region);
69 
70  // select and store seeds
71  std::set<unsigned> simTrackIds;
72  for ( const auto & seeds : seedCollections)
73  {
74  for ( const auto & seed : *seeds)
75  {
76  // Find the simtrack corresponding to the seed
77  TrajectorySeed::range recHitRange = seed.recHits();
78  const FastTrackerRecHit * firstRecHit = (const FastTrackerRecHit*) (&(*(recHitRange.first)));
79  int simTrackId = firstRecHit->simTrackId(0);
80  const SimTrack & simTrack = (*simTracks)[simTrackId];
81 
82  // skip if simTrack already associated to a seed
83  if( simTrackIds.find(simTrackId) != simTrackIds.end() )
84  {
85  continue;
86  }
87  simTrackIds.insert(simTrackId);
88 
89  // filter seed
90  if( !clean(muRef,regionRef,&seed,simTrack) )
91  {
92  continue;
93  }
94 
95  // store results
96  result.push_back(L3MuonTrajectorySeed(seed,muRef));
97  }
98  }
99 }
100 
101 bool
104  const TrajectorySeed* aSeed,
105  const SimTrack& theSimTrack)
106 {
107 
108  // Eta cleaner
109  const PixelRecoRange<float>& etaRange = region.etaRange() ;
110 
111  double etaSeed = theSimTrack.momentum().Eta();
112  double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ?
113  0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
114  bool inEtaRange =
115  etaSeed >= (etaRange.mean() - etaLimit) &&
116  etaSeed <= (etaRange.mean() + etaLimit) ;
117  if ( !inEtaRange )
118  {
119  return false;
120  }
121 
122  // Phi cleaner
123  const TkTrackingRegionsMargin<float>& phiMargin = region.phiMargin();
124  double phiSeed = theSimTrack.momentum().Phi();
125  double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right();
126  bool inPhiRange =
127  (fabs(deltaPhi(phiSeed,double(region.direction().phi()))) < phiLimit );
128  if ( !inPhiRange )
129  {
130  return false;
131  }
132 
133  // pt cleaner
134  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
135  double ptMin = (region.ptMin()>3.5) ? 3.5: region.ptMin();
136  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt());
137  if ( !inPtRange )
138  {
139  return false;
140  }
141  return true;
142 
143 }
std::vector< edm::EDGetTokenT< TrajectorySeedCollection > > seedsTks
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T max() const
FastTSGFromIOHit(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
constructor
std::pair< const Trajectory *, reco::TrackRef > TrackCand
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual ~FastTSGFromIOHit()
destructor
GlobalVector const & direction() const
the direction around which region is constructed
std::vector< TrajectorySeed > TrajectorySeedCollection
T sqrt(T t)
Definition: SSEVec.h:18
const edm::Event * getEvent() const
void trackerSeeds(const TrackCand &, const TrackingRegion &, const TrackerTopology *tTopo, std::vector< TrajectorySeed > &) override
generate seed(s) for a track
tuple result
Definition: query.py:137
virtual int32_t simTrackId(size_t i) const
std::pair< const_iterator, const_iterator > range
#define LogTrace(id)
T mean() const
float ptMin() const
minimal pt of interest
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
bool clean(reco::TrackRef muRef, const RectangularEtaPhiTrackingRegion &region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
tuple seedCollections
std::string theCategory
edm::EDGetTokenT< edm::SimTrackContainer > simTracksTk
std::vector< SimTrack > SimTrackContainer
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval