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
 
 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

edm::InputTag theL2CollectionLabel
 
double thePtCut
 
std::unique_ptr< MuonTrackingRegionBuildertheRegionBuilder
 
std::vector< edm::InputTagtheSeedCollectionLabels
 
MuonServiceProxytheService
 
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 20 of file FastTSGFromL2Muon.cc.

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

20  {
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  edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
32  theRegionBuilder = std::make_unique<MuonTrackingRegionBuilder>(regionBuilderPSet, consumesCollector());
33 }
std::vector< edm::InputTag > theSeedCollectionLabels
edm::InputTag theSimTrackCollectionLabel
std::unique_ptr< MuonTrackingRegionBuilder > theRegionBuilder
edm::InputTag theL2CollectionLabel

◆ ~FastTSGFromL2Muon()

FastTSGFromL2Muon::~FastTSGFromL2Muon ( )
override

Definition at line 35 of file FastTSGFromL2Muon.cc.

35 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 37 of file FastTSGFromL2Muon.cc.

37  {
38  //region builder
39 
40  /*
41  if(useTFileService_) {
42  edm::Service<TFileService> fs;
43  h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5);
44  h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5);
45  h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5);
46  } else {
47  h_nSeedPerTrack = 0;
48  h_nGoodSeedPerEvent = 0;
49  h_nGoodSeedPerTrack = 0;
50  }
51  */
52 }

◆ clean()

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

Definition at line 147 of file FastTSGFromL2Muon.cc.

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

Referenced by produce().

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

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

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

Member Data Documentation

◆ theL2CollectionLabel

edm::InputTag FastTSGFromL2Muon::theL2CollectionLabel
private

Definition at line 41 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ thePtCut

double FastTSGFromL2Muon::thePtCut
private

Definition at line 47 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theRegionBuilder

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

Definition at line 48 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theSeedCollectionLabels

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

Definition at line 42 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

◆ theService

MuonServiceProxy* FastTSGFromL2Muon::theService
private

Definition at line 46 of file FastTSGFromL2Muon.h.

◆ theSimTrackCollectionLabel

edm::InputTag FastTSGFromL2Muon::theSimTrackCollectionLabel
private

Definition at line 40 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().