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

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

Private Member Functions

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

Private Attributes

edm::ParameterSet theConfig
 
edm::InputTag theL2CollectionLabel
 
double thePtCut
 
MuonTrackingRegionBuildertheRegionBuilder
 
std::vector< edm::InputTagtheSeedCollectionLabels
 
MuonServiceProxytheService
 
edm::InputTag theSimTrackCollectionLabel
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 26 of file FastTSGFromL2Muon.h.

Constructor & Destructor Documentation

◆ FastTSGFromL2Muon()

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

Definition at line 20 of file FastTSGFromL2Muon.cc.

20  : theConfig(cfg) {
21  produces<L3MuonTrajectorySeedCollection>();
22 
23  edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
24 
25  thePtCut = cfg.getParameter<double>("PtCut");
26 
27  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
28  theSeedCollectionLabels = cfg.getParameter<std::vector<edm::InputTag> >("SeedCollectionLabels");
29  theSimTrackCollectionLabel = cfg.getParameter<edm::InputTag>("SimTrackCollectionLabel");
30  // useTFileService_ = cfg.getUntrackedParameter<bool>("UseTFileService",false);
31 }

References looper::cfg, theL2CollectionLabel, thePtCut, theSeedCollectionLabels, and theSimTrackCollectionLabel.

◆ ~FastTSGFromL2Muon()

FastTSGFromL2Muon::~FastTSGFromL2Muon ( )
override

Definition at line 33 of file FastTSGFromL2Muon.cc.

33 {}

Member Function Documentation

◆ beginRun()

void FastTSGFromL2Muon::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
override

Definition at line 35 of file FastTSGFromL2Muon.cc.

35  {
36  //region builder
37  edm::ParameterSet regionBuilderPSet = theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
38  edm::ConsumesCollector iC = consumesCollector();
39  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC);
40 
41  /*
42  if(useTFileService_) {
43  edm::Service<TFileService> fs;
44  h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5);
45  h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5);
46  h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5);
47  } else {
48  h_nSeedPerTrack = 0;
49  h_nGoodSeedPerEvent = 0;
50  h_nGoodSeedPerTrack = 0;
51  }
52  */
53 }

References edm::ParameterSet::getParameter(), HLT_2018_cff::MuonTrackingRegionBuilder, theConfig, and theRegionBuilder.

◆ clean()

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

Definition at line 152 of file FastTSGFromL2Muon.cc.

155  {
156  // Eta cleaner
157  const PixelRecoRange<float>& etaRange = region->etaRange();
158  double etaSeed = theSimTrack.momentum().Eta();
159  double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.05)
160  ? 0.05
161  : fabs(fabs(etaRange.max()) - fabs(etaRange.mean()));
162  bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit);
163  if (!inEtaRange)
164  return false;
165 
166  // Phi cleaner
167  const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin();
168  double phiSeed = theSimTrack.momentum().Phi();
169  double phiLimit = (phiMargin.right() < 0.05) ? 0.05 : phiMargin.right();
170  bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region->direction().phi()))) < phiLimit);
171  if (!inPhiRange)
172  return false;
173 
174  // pt cleaner
175  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
176  double ptMin = (region->ptMin() > 3.5) ? 3.5 : region->ptMin();
177  bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muRef->pt());
178  return inPtRange;
179 }

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

Referenced by produce().

◆ produce()

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

Definition at line 55 of file FastTSGFromL2Muon.cc.

55  {
56  // Initialize the output product
57  std::unique_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
58 
59  // Region builder
61 
62  // Retrieve the Monte Carlo truth (SimTracks)
64  ev.getByLabel(theSimTrackCollectionLabel, theSimTracks);
65 
66  // Retrieve L2 muon collection
68  ev.getByLabel(theL2CollectionLabel, l2muonH);
69 
70  // Retrieve Seed collection
71  unsigned seedCollections = theSeedCollectionLabels.size();
72  std::vector<edm::Handle<edm::View<TrajectorySeed> > > theSeeds;
73  theSeeds.resize(seedCollections);
74  unsigned seed_size = 0;
75  for (unsigned iseed = 0; iseed < seedCollections; ++iseed) {
76  ev.getByLabel(theSeedCollectionLabels[iseed], theSeeds[iseed]);
77  seed_size += theSeeds[iseed]->size();
78  }
79 
80  // Loop on L2 muons
81  unsigned int imu = 0;
82  unsigned int imuMax = l2muonH->size();
83  // std::cout << "Found " << imuMax << " L2 muons" << std::endl;
84  for (; imu != imuMax; ++imu) {
85  // Make a ref to l2 muon
86  reco::TrackRef muRef(l2muonH, imu);
87 
88  // Cut on muons with low momenta
89  if (muRef->pt() < thePtCut || muRef->innerMomentum().Rho() < thePtCut || muRef->innerMomentum().R() < 2.5)
90  continue;
91 
92  // Define the region of interest
93  std::unique_ptr<RectangularEtaPhiTrackingRegion> region = theRegionBuilder->region(muRef);
94 
95  // Copy the collection of seeds (ahem, this is time consuming!)
96  std::vector<TrajectorySeed> tkSeeds;
97  std::set<unsigned> tkIds;
98  tkSeeds.reserve(seed_size);
99  for (unsigned iseed = 0; iseed < seedCollections; ++iseed) {
100  edm::Handle<edm::View<TrajectorySeed> > aSeedCollection = theSeeds[iseed];
101  unsigned nSeeds = aSeedCollection->size();
102  for (unsigned seednr = 0; seednr < nSeeds; ++seednr) {
103  // The seed
104  const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]);
105 
106  // Find the first hit of the Seed
107  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
108  const FastTrackerRecHit* theFirstSeedingRecHit = (const FastTrackerRecHit*)(&(*(theSeedingRecHitRange.first)));
109 
110  // The SimTrack id associated to that recHit
111  int simTrackId = theFirstSeedingRecHit->simTrackId(0);
112 
113  // Track already associated to a seed
114  std::set<unsigned>::iterator tkId = tkIds.find(simTrackId);
115  if (tkId != tkIds.end())
116  continue;
117 
118  const SimTrack& theSimTrack = (*theSimTracks)[simTrackId];
119 
120  if (clean(muRef, region.get(), aSeed, theSimTrack))
121  tkSeeds.push_back(*aSeed);
122  tkIds.insert(simTrackId);
123 
124  } // End loop on seeds
125 
126  } // End loop on seed collections
127 
128  // A plot
129  // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size());
130 
131  // Another plot
132  // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size());
133 
134  // Now create the Muon Trajectory Seed
135  unsigned int is = 0;
136  unsigned int isMax = tkSeeds.size();
137  for (; is != isMax; ++is) {
138  result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef));
139  } // End of tk seed loop
140 
141  } // End of l2 muon loop
142 
143  // std::cout << "Found " << result->size() << " seeds for muons" << std::endl;
144 
145  // And yet another plot
146  // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size());
147 
148  //put in the event
149  ev.put(std::move(result));
150 }

References clean(), ev, iseed, eostools::move(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), HLT_2018_cff::region, mps_fire::result, seedmultiplicitymonitor_cfi::seedCollections, MuonTrackingRegionBuilder::setEvent(), FastTrackerRecHit::simTrackId(), theL2CollectionLabel, thePtCut, theRegionBuilder, theSeedCollectionLabels, and theSimTrackCollectionLabel.

Member Data Documentation

◆ theConfig

edm::ParameterSet FastTSGFromL2Muon::theConfig
private

Definition at line 40 of file FastTSGFromL2Muon.h.

Referenced by beginRun().

◆ theL2CollectionLabel

edm::InputTag FastTSGFromL2Muon::theL2CollectionLabel
private

Definition at line 42 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ thePtCut

double FastTSGFromL2Muon::thePtCut
private

Definition at line 48 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theRegionBuilder

MuonTrackingRegionBuilder* FastTSGFromL2Muon::theRegionBuilder
private

Definition at line 49 of file FastTSGFromL2Muon.h.

Referenced by beginRun(), and produce().

◆ theSeedCollectionLabels

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

Definition at line 43 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theService

MuonServiceProxy* FastTSGFromL2Muon::theService
private

Definition at line 47 of file FastTSGFromL2Muon.h.

◆ theSimTrackCollectionLabel

edm::InputTag FastTSGFromL2Muon::theSimTrackCollectionLabel
private

Definition at line 41 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

CoreSimTrack::momentum
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
FastTSGFromL2Muon::thePtCut
double thePtCut
Definition: FastTSGFromL2Muon.h:48
FastTSGFromL2Muon::theSimTrackCollectionLabel
edm::InputTag theSimTrackCollectionLabel
Definition: FastTSGFromL2Muon.h:41
generateTowerEtThresholdLUT.etaRange
etaRange
Definition: generateTowerEtThresholdLUT.py:55
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
FastTSGFromL2Muon::theRegionBuilder
MuonTrackingRegionBuilder * theRegionBuilder
Definition: FastTSGFromL2Muon.h:49
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
MuonTrackingRegionBuilder::region
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
Definition: MuonTrackingRegionBuilder.cc:117
FastTrackerRecHit
Definition: FastTrackerRecHit.h:40
edm::Handle< edm::SimTrackContainer >
edm::Ref< TrackCollection >
L3MuonTrajectorySeedCollection
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
Definition: L3MuonTrajectorySeedCollection.h:13
MuonTrackingRegionBuilder::setEvent
virtual void setEvent(const edm::Event &)
Pass the Event to the algo at each event.
Definition: MuonTrackingRegionBuilder.cc:124
seedmultiplicitymonitor_cfi.seedCollections
seedCollections
Definition: seedmultiplicitymonitor_cfi.py:5
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
FastTSGFromL2Muon::theConfig
edm::ParameterSet theConfig
Definition: FastTSGFromL2Muon.h:40
FastTSGFromL2Muon::clean
bool clean(reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
Definition: FastTSGFromL2Muon.cc:152
FastTrackerRecHit::simTrackId
virtual int32_t simTrackId(size_t i) const
Definition: FastTrackerRecHit.h:99
PixelRecoRange< float >
edm::ParameterSet
Definition: ParameterSet.h:36
iseed
int iseed
Definition: AMPTWrapper.h:134
TkTrackingRegionsMargin< float >
TkTrackingRegionsMargin::right
const T & right() const
Definition: TkTrackingRegionsMargin.h:19
HLT_2018_cff.MuonTrackingRegionBuilder
MuonTrackingRegionBuilder
Definition: HLT_2018_cff.py:8346
looper.cfg
cfg
Definition: looper.py:297
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
FastTSGFromL2Muon::theL2CollectionLabel
edm::InputTag theL2CollectionLabel
Definition: FastTSGFromL2Muon.h:42
eostools.move
def move(src, dest)
Definition: eostools.py:511
SimTrack
Definition: SimTrack.h:6
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
TrajectorySeed
Definition: TrajectorySeed.h:17
mps_fire.result
result
Definition: mps_fire.py:303
FastTSGFromL2Muon::theSeedCollectionLabels
std::vector< edm::InputTag > theSeedCollectionLabels
Definition: FastTSGFromL2Muon.h:43
L3MuonTrajectorySeed
Definition: L3MuonTrajectorySeed.h:16
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39