test
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 
17 
19 {
20 
21  theCategory = "FastSimulation|Muons||FastTSGFromIOHit";
22 
23  thePtCut = iConfig.getParameter<double>("PtCut");
24 
25  simTracksTk = iC.consumes<edm::SimTrackContainer>(iConfig.getParameter<edm::InputTag>("SimTrackCollectionLabel"));
26  const auto & seedLabels = iConfig.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels");
27  for(const auto & seedLabel : seedLabels)
28  {
29  seedsTks.push_back(iC.consumes<TrajectorySeedCollection>(seedLabel));
30  }
31 
32 }
33 
35 {
36 
37  LogTrace(theCategory) << " FastTSGFromIOHit dtor called ";
38 
39 }
40 
41 void FastTSGFromIOHit::trackerSeeds(const TrackCand& staMuon, const TrackingRegion& region, const TrackerTopology *tTopo, std::vector<TrajectorySeed> & result)
42 {
43  // Make a ref to l2 muon
44  reco::TrackRef muRef(staMuon.second);
45 
46  // Cut on muons with low momenta
47  if ( muRef->pt() < thePtCut
48  || muRef->innerMomentum().Rho() < thePtCut
49  || muRef->innerMomentum().R() < 2.5 )
50  {
51  return;
52  }
53 
54  // Retrieve the Monte Carlo truth (SimTracks)
56  getEvent()->getByToken(simTracksTk,simTracks);
57 
58  // Retrieve Seed collection
59  std::vector<edm::Handle<TrajectorySeedCollection> > seedCollections;
60  seedCollections.resize(seedsTks.size());
61  for ( unsigned iSeed = 0 ; iSeed < seedsTks.size() ; iSeed++)
62  {
63  getEvent()->getByToken(seedsTks[iSeed],seedCollections[iSeed]);
64  }
65 
66  // cast the tracking region
67  const RectangularEtaPhiTrackingRegion & regionRef = dynamic_cast<const RectangularEtaPhiTrackingRegion & > (region);
68 
69  // select and store seeds
70  std::set<unsigned> simTrackIds;
71  for ( const auto & seeds : seedCollections)
72  {
73  for ( const auto & seed : *seeds)
74  {
75  // Find the simtrack corresponding to the seed
76  TrajectorySeed::range recHitRange = seed.recHits();
77  const FastTrackerRecHit * firstRecHit = (const FastTrackerRecHit*) (&(*(recHitRange.first)));
78  int simTrackId = firstRecHit->simTrackId(0);
79  const SimTrack & simTrack = (*simTracks)[simTrackId];
80 
81  // skip if simTrack already associated to a seed
82  if( simTrackIds.find(simTrackId) != simTrackIds.end() )
83  {
84  continue;
85  }
86  simTrackIds.insert(simTrackId);
87 
88  // filter seed
89  if( !clean(muRef,regionRef,&seed,simTrack) )
90  {
91  continue;
92  }
93 
94  // store results
95  result.push_back(L3MuonTrajectorySeed(seed,muRef));
96  }
97  }
98 }
99 
100 bool
103  const TrajectorySeed* aSeed,
104  const SimTrack& theSimTrack)
105 {
106 
107  // Eta cleaner
108  const PixelRecoRange<float>& etaRange = region.etaRange() ;
109 
110  double etaSeed = theSimTrack.momentum().Eta();
111  double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ?
112  0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
113  bool inEtaRange =
114  etaSeed >= (etaRange.mean() - etaLimit) &&
115  etaSeed <= (etaRange.mean() + etaLimit) ;
116  if ( !inEtaRange )
117  {
118  return false;
119  }
120 
121  // Phi cleaner
122  const TkTrackingRegionsMargin<float>& phiMargin = region.phiMargin();
123  double phiSeed = theSimTrack.momentum().Phi();
124  double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right();
125  bool inPhiRange =
126  (fabs(deltaPhi(phiSeed,double(region.direction().phi()))) < phiLimit );
127  if ( !inPhiRange )
128  {
129  return false;
130  }
131 
132  // pt cleaner
133  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
134  double ptMin = (region.ptMin()>3.5) ? 3.5: region.ptMin();
135  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt());
136  if ( !inPtRange )
137  {
138  return false;
139  }
140  return true;
141 
142 }
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
tuple result
Definition: mps_fire.py:84
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
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)
std::string theCategory
edm::EDGetTokenT< edm::SimTrackContainer > simTracksTk
std::vector< SimTrack > SimTrackContainer
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval