CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
FastTSGFromL2Muon Class Reference

#include <FastTSGFromL2Muon.h>

Inheritance diagram for FastTSGFromL2Muon:
edm::stream::EDProducer<>

Public Member Functions

 FastTSGFromL2Muon (const edm::ParameterSet &cfg)
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~FastTSGFromL2Muon () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

bool clean (reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
 

Private Attributes

const edm::EDGetTokenT< reco::TrackCollectionl2TrackToken_
 
std::vector< edm::EDGetTokenT< edm::View< TrajectorySeed > > > seedToken_
 
const edm::EDGetTokenT< edm::SimTrackContainersimTrackToken_
 
const edm::InputTag theL2CollectionLabel
 
const double thePtCut
 
std::unique_ptr< MuonTrackingRegionBuildertheRegionBuilder
 
const std::vector< edm::InputTagtheSeedCollectionLabels
 
const edm::InputTag theSimTrackCollectionLabel
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 26 of file FastTSGFromL2Muon.h.

Constructor & Destructor Documentation

◆ FastTSGFromL2Muon()

FastTSGFromL2Muon::FastTSGFromL2Muon ( const edm::ParameterSet cfg)

Definition at line 16 of file FastTSGFromL2Muon.cc.

References looper::cfg, fileCollector::seed, seedToken_, theRegionBuilder, and theSeedCollectionLabels.

17  : thePtCut(cfg.getParameter<double>("PtCut")),
18  theL2CollectionLabel(cfg.getParameter<edm::InputTag>("MuonCollectionLabel")),
19  theSeedCollectionLabels(cfg.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels")),
20  theSimTrackCollectionLabel(cfg.getParameter<edm::InputTag>("SimTrackCollectionLabel")),
21  simTrackToken_(consumes<edm::SimTrackContainer>(theSimTrackCollectionLabel)),
22  l2TrackToken_(consumes<reco::TrackCollection>(theL2CollectionLabel)) {
23  produces<L3MuonTrajectorySeedCollection>();
24 
25  for (auto& seed : theSeedCollectionLabels)
26  seedToken_.emplace_back(consumes<edm::View<TrajectorySeed> >(seed));
27 
28  edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
29  theRegionBuilder = std::make_unique<MuonTrackingRegionBuilder>(regionBuilderPSet, consumesCollector());
30 }
const double thePtCut
const edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken_
std::vector< edm::EDGetTokenT< edm::View< TrajectorySeed > > > seedToken_
const edm::InputTag theL2CollectionLabel
const edm::EDGetTokenT< reco::TrackCollection > l2TrackToken_
std::unique_ptr< MuonTrackingRegionBuilder > theRegionBuilder
const std::vector< edm::InputTag > theSeedCollectionLabels
const edm::InputTag theSimTrackCollectionLabel

◆ ~FastTSGFromL2Muon()

FastTSGFromL2Muon::~FastTSGFromL2Muon ( )
overridedefault

Member Function Documentation

◆ clean()

bool FastTSGFromL2Muon::clean ( reco::TrackRef  muRef,
RectangularEtaPhiTrackingRegion region,
const BasicTrajectorySeed aSeed,
const SimTrack theSimTrack 
)
private

Definition at line 114 of file FastTSGFromL2Muon.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, generateTowerEtThresholdLUT::etaRange, CoreSimTrack::momentum(), ptMin, nano_mu_digi_cff::region, TkTrackingRegionsMargin< T >::right(), and mathSSE::sqrt().

Referenced by produce().

117  {
118  // Eta cleaner
119  const PixelRecoRange<float>& etaRange = region->etaRange();
120  double etaSeed = theSimTrack.momentum().Eta();
121  double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.05)
122  ? 0.05
123  : fabs(fabs(etaRange.max()) - fabs(etaRange.mean()));
124  bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit);
125  if (!inEtaRange)
126  return false;
127 
128  // Phi cleaner
129  const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin();
130  double phiSeed = theSimTrack.momentum().Phi();
131  double phiLimit = (phiMargin.right() < 0.05) ? 0.05 : phiMargin.right();
132  bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region->direction().phi()))) < phiLimit);
133  if (!inPhiRange)
134  return false;
135 
136  // pt cleaner
137  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
138  double ptMin = (region->ptMin() > 3.5) ? 3.5 : region->ptMin();
139  bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muRef->pt());
140  return inPtRange;
141 }
constexpr float ptMin
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
T sqrt(T t)
Definition: SSEVec.h:19

◆ produce()

void FastTSGFromL2Muon::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

Definition at line 32 of file FastTSGFromL2Muon.cc.

References edm::Range< T >::begin(), clean(), runTheMatrix::const, makeMEIFBenchmarkPlots::ev, iseed, l2TrackToken_, eostools::move(), TrajectorySeed::recHits(), nano_mu_digi_cff::region, mps_fire::result, seedmultiplicitymonitor_cfi::seedCollections, seedToken_, simTrackToken_, thePtCut, theRegionBuilder, and theSeedCollectionLabels.

32  {
33  // Initialize the output product
34  std::unique_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
35 
36  // Region builder
37  theRegionBuilder->setEvent(ev, es);
38 
39  // Retrieve the Monte Carlo truth (SimTracks)
40  const edm::Handle<edm::SimTrackContainer>& theSimTracks = ev.getHandle(simTrackToken_);
41 
42  // Retrieve L2 muon collection
43  const edm::Handle<reco::TrackCollection>& l2muonH = ev.getHandle(l2TrackToken_);
44 
45  // Retrieve Seed collection
46  unsigned seedCollections = theSeedCollectionLabels.size();
47  std::vector<edm::Handle<edm::View<TrajectorySeed> > > theSeeds;
48  theSeeds.resize(seedCollections);
49  unsigned seed_size = 0;
50  for (unsigned iseed = 0; iseed < seedCollections; ++iseed) {
51  ev.getByToken(seedToken_[iseed], theSeeds[iseed]);
52  seed_size += theSeeds[iseed]->size();
53  }
54 
55  // Loop on L2 muons
56  unsigned int imu = 0;
57  unsigned int imuMax = l2muonH->size();
58  edm::LogVerbatim("FastTSGFromL2Muon") << "Found " << imuMax << " L2 muons";
59  for (; imu != imuMax; ++imu) {
60  // Make a ref to l2 muon
61  reco::TrackRef muRef(l2muonH, imu);
62 
63  // Cut on muons with low momenta
64  if (muRef->pt() < thePtCut || muRef->innerMomentum().Rho() < thePtCut || muRef->innerMomentum().R() < 2.5)
65  continue;
66 
67  // Define the region of interest
68  std::unique_ptr<RectangularEtaPhiTrackingRegion> region = theRegionBuilder->region(muRef);
69 
70  // Copy the collection of seeds (ahem, this is time consuming!)
71  std::vector<TrajectorySeed> tkSeeds;
72  std::set<unsigned> tkIds;
73  tkSeeds.reserve(seed_size);
74  for (unsigned iseed = 0; iseed < seedCollections; ++iseed) {
75  edm::Handle<edm::View<TrajectorySeed> > aSeedCollection = theSeeds[iseed];
76  unsigned nSeeds = aSeedCollection->size();
77  for (unsigned seednr = 0; seednr < nSeeds; ++seednr) {
78  // The seed
79  const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]);
80 
81  // The SimTrack id associated to the first hit of the Seed
82  int simTrackId = static_cast<FastTrackerRecHit const&>(*aSeed->recHits().begin()).simTrackId(0);
83 
84  // Track already associated to a seed
85  std::set<unsigned>::iterator tkId = tkIds.find(simTrackId);
86  if (tkId != tkIds.end())
87  continue;
88 
89  const SimTrack& theSimTrack = (*theSimTracks)[simTrackId];
90 
91  if (clean(muRef, region.get(), aSeed, theSimTrack))
92  tkSeeds.push_back(*aSeed);
93  tkIds.insert(simTrackId);
94 
95  } // End loop on seeds
96 
97  } // End loop on seed collections
98 
99  // Now create the Muon Trajectory Seed
100  unsigned int is = 0;
101  unsigned int isMax = tkSeeds.size();
102  for (; is != isMax; ++is) {
103  result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef));
104  } // End of tk seed loop
105 
106  } // End of l2 muon loop
107 
108  edm::LogVerbatim("FastTSGFromL2Muon") << "Found " << result->size() << " seeds for muons";
109 
110  //put in the event
111  ev.put(std::move(result));
112 }
Log< level::Info, true > LogVerbatim
const double thePtCut
const edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken_
T begin() const
Definition: Range.h:15
RecHitRange recHits() const
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
std::vector< edm::EDGetTokenT< edm::View< TrajectorySeed > > > seedToken_
const edm::EDGetTokenT< reco::TrackCollection > l2TrackToken_
std::unique_ptr< MuonTrackingRegionBuilder > theRegionBuilder
bool clean(reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
int iseed
Definition: AMPTWrapper.h:134
const std::vector< edm::InputTag > theSeedCollectionLabels
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ l2TrackToken_

const edm::EDGetTokenT<reco::TrackCollection> FastTSGFromL2Muon::l2TrackToken_
private

Definition at line 45 of file FastTSGFromL2Muon.h.

Referenced by produce().

◆ seedToken_

std::vector<edm::EDGetTokenT<edm::View<TrajectorySeed> > > FastTSGFromL2Muon::seedToken_
private

Definition at line 46 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ simTrackToken_

const edm::EDGetTokenT<edm::SimTrackContainer> FastTSGFromL2Muon::simTrackToken_
private

Definition at line 44 of file FastTSGFromL2Muon.h.

Referenced by produce().

◆ theL2CollectionLabel

const edm::InputTag FastTSGFromL2Muon::theL2CollectionLabel
private

Definition at line 40 of file FastTSGFromL2Muon.h.

◆ thePtCut

const double FastTSGFromL2Muon::thePtCut
private

Definition at line 39 of file FastTSGFromL2Muon.h.

Referenced by produce().

◆ theRegionBuilder

std::unique_ptr<MuonTrackingRegionBuilder> FastTSGFromL2Muon::theRegionBuilder
private

Definition at line 48 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theSeedCollectionLabels

const std::vector<edm::InputTag> FastTSGFromL2Muon::theSeedCollectionLabels
private

Definition at line 41 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theSimTrackCollectionLabel

const edm::InputTag FastTSGFromL2Muon::theSimTrackCollectionLabel
private

Definition at line 42 of file FastTSGFromL2Muon.h.