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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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_FULL_cff::MuonTrackingRegionBuilder, theConfig, and theRegionBuilder.

◆ clean()

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

Definition at line 148 of file FastTSGFromL2Muon.cc.

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

References SiPixelRawToDigiRegional_cfi::deltaPhi, generateTowerEtThresholdLUT::etaRange, CoreSimTrack::momentum(), ptMin, HLT_FULL_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  // The SimTrack id associated to the first hit of the Seed
107  int simTrackId = static_cast<FastTrackerRecHit const&>(*aSeed->recHits().begin()).simTrackId(0);
108 
109  // Track already associated to a seed
110  std::set<unsigned>::iterator tkId = tkIds.find(simTrackId);
111  if (tkId != tkIds.end())
112  continue;
113 
114  const SimTrack& theSimTrack = (*theSimTracks)[simTrackId];
115 
116  if (clean(muRef, region.get(), aSeed, theSimTrack))
117  tkSeeds.push_back(*aSeed);
118  tkIds.insert(simTrackId);
119 
120  } // End loop on seeds
121 
122  } // End loop on seed collections
123 
124  // A plot
125  // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size());
126 
127  // Another plot
128  // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size());
129 
130  // Now create the Muon Trajectory Seed
131  unsigned int is = 0;
132  unsigned int isMax = tkSeeds.size();
133  for (; is != isMax; ++is) {
134  result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef));
135  } // End of tk seed loop
136 
137  } // End of l2 muon loop
138 
139  // std::cout << "Found " << result->size() << " seeds for muons" << std::endl;
140 
141  // And yet another plot
142  // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size());
143 
144  //put in the event
145  ev.put(std::move(result));
146 }

References edm::Range< T >::begin(), clean(), ev, iseed, eostools::move(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), HLT_FULL_cff::region, mps_fire::result, seedmultiplicitymonitor_cfi::seedCollections, MuonTrackingRegionBuilder::setEvent(), 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
FastTSGFromL2Muon::theRegionBuilder
MuonTrackingRegionBuilder * theRegionBuilder
Definition: FastTSGFromL2Muon.h:49
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:155
MuonTrackingRegionBuilder::region
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
Definition: MuonTrackingRegionBuilder.cc:117
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:148
PixelRecoRange< float >
edm::ParameterSet
Definition: ParameterSet.h:47
iseed
int iseed
Definition: AMPTWrapper.h:134
edm::Range::begin
T begin() const
Definition: Range.h:15
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88338
TkTrackingRegionsMargin< float >
TrajectorySeed::recHits
RecHitRange recHits() const
Definition: TrajectorySeed.h:52
TkTrackingRegionsMargin::right
const T & right() const
Definition: TkTrackingRegionsMargin.h:19
looper.cfg
cfg
Definition: looper.py:297
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
TrajectorySeed
Definition: TrajectorySeed.h:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
mps_fire.result
result
Definition: mps_fire.py:311
HLT_FULL_cff.MuonTrackingRegionBuilder
MuonTrackingRegionBuilder
Definition: HLT_FULL_cff.py:9733
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:45