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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 23 of file FastTSGFromL2Muon.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file FastTSGFromL2Muon.cc.

References edm::ParameterSet::getParameter(), theL2CollectionLabel, thePtCut, theSeedCollectionLabels, and theSimTrackCollectionLabel.

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

Definition at line 36 of file FastTSGFromL2Muon.cc.

37 {
38 }

Member Function Documentation

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

Definition at line 41 of file FastTSGFromL2Muon.cc.

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

42 {
43 
44  //region builder
45  edm::ParameterSet regionBuilderPSet =
46  theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
47  edm::ConsumesCollector iC = consumesCollector();
48  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,iC);
49 
50 
51  /*
52  if(useTFileService_) {
53  edm::Service<TFileService> fs;
54  h_nSeedPerTrack = fs->make<TH1F>("nSeedPerTrack","nSeedPerTrack",76,-0.5,75.5);
55  h_nGoodSeedPerTrack = fs->make<TH1F>("nGoodSeedPerTrack","nGoodSeedPerTrack",75,-0.5,75.5);
56  h_nGoodSeedPerEvent = fs->make<TH1F>("nGoodSeedPerEvent","nGoodSeedPerEvent",75,-0.5,75.5);
57  } else {
58  h_nSeedPerTrack = 0;
59  h_nGoodSeedPerEvent = 0;
60  h_nGoodSeedPerTrack = 0;
61  }
62  */
63 
64 }
T getParameter(std::string const &) const
MuonTrackingRegionBuilder * theRegionBuilder
edm::ParameterSet theConfig
bool FastTSGFromL2Muon::clean ( reco::TrackRef  muRef,
RectangularEtaPhiTrackingRegion region,
const BasicTrajectorySeed aSeed,
const SimTrack theSimTrack 
)
private

Definition at line 172 of file FastTSGFromL2Muon.cc.

References hiPixelPairStep_cff::deltaPhi, TrackingRegion::direction(), MuonErrorMatrixValues_cff::etaRange, RectangularEtaPhiTrackingRegion::etaRange(), PixelRecoRange< T >::max(), PixelRecoRange< T >::mean(), CoreSimTrack::momentum(), PV3DBase< T, PVType, FrameType >::phi(), RectangularEtaPhiTrackingRegion::phiMargin(), TrackingRegion::ptMin(), ptMin, TkTrackingRegionsMargin< T >::right(), and mathSSE::sqrt().

Referenced by produce().

175  {
176 
177  // Eta cleaner
178  const PixelRecoRange<float>& etaRange = region->etaRange() ;
179  double etaSeed = theSimTrack.momentum().Eta();
180  double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ?
181  0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
182  bool inEtaRange =
183  etaSeed >= (etaRange.mean() - etaLimit) &&
184  etaSeed <= (etaRange.mean() + etaLimit) ;
185  if ( !inEtaRange ) return false;
186 
187  // Phi cleaner
188  const TkTrackingRegionsMargin<float>& phiMargin = region->phiMargin();
189  double phiSeed = theSimTrack.momentum().Phi();
190  double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right();
191  bool inPhiRange =
192  (fabs(deltaPhi(phiSeed,double(region->direction().phi()))) < phiLimit );
193  if ( !inPhiRange ) return false;
194 
195  // pt cleaner
196  double ptSeed = std::sqrt(theSimTrack.momentum().Perp2());
197  double ptMin = (region->ptMin()>3.5) ? 3.5: region->ptMin();
198  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt());
199  return inPtRange;
200 
201 }
T max() const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalVector const & direction() const
the direction around which region is constructed
T sqrt(T t)
Definition: SSEVec.h:18
T mean() const
float ptMin() const
minimal pt of interest
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval
void FastTSGFromL2Muon::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

Definition at line 68 of file FastTSGFromL2Muon.cc.

References clean(), edm::Ref< C, T, F >::get(), edm::Event::getByLabel(), iseed, eostools::move(), edm::Event::put(), TrajectorySeed::recHits(), MuonTrackingRegionBuilder::region(), mps_fire::result, HiRegitMuonMixedTripletStep_cff::seedCollections, MuonTrackingRegionBuilder::setEvent(), FastTrackerRecHit::simTrackId(), theL2CollectionLabel, thePtCut, theRegionBuilder, theSeedCollectionLabels, and theSimTrackCollectionLabel.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

69 {
70 
71  // Initialize the output product
72  std::unique_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
73 
74  // Region builder
76 
77  // Retrieve the Monte Carlo truth (SimTracks)
79  ev.getByLabel(theSimTrackCollectionLabel,theSimTracks);
80 
81  // Retrieve L2 muon collection
83  ev.getByLabel(theL2CollectionLabel ,l2muonH);
84 
85  // Retrieve Seed collection
86  unsigned seedCollections = theSeedCollectionLabels.size();
87  std::vector<edm::Handle<edm::View<TrajectorySeed> > > theSeeds;
88  theSeeds.resize(seedCollections);
89  unsigned seed_size = 0;
90  for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) {
91  ev.getByLabel(theSeedCollectionLabels[iseed], theSeeds[iseed]);
92  seed_size += theSeeds[iseed]->size();
93  }
94 
95  // Loop on L2 muons
96  unsigned int imu=0;
97  unsigned int imuMax=l2muonH->size();
98  // std::cout << "Found " << imuMax << " L2 muons" << std::endl;
99  for (;imu!=imuMax;++imu){
100 
101  // Make a ref to l2 muon
102  reco::TrackRef muRef(l2muonH, imu);
103 
104  // Cut on muons with low momenta
105  if ( muRef->pt() < thePtCut
106  || muRef->innerMomentum().Rho() < thePtCut
107  || muRef->innerMomentum().R() < 2.5 ) continue;
108 
109  // Define the region of interest
110  std::unique_ptr<RectangularEtaPhiTrackingRegion> region = theRegionBuilder->region(muRef);
111 
112  // Copy the collection of seeds (ahem, this is time consuming!)
113  std::vector<TrajectorySeed> tkSeeds;
114  std::set<unsigned> tkIds;
115  tkSeeds.reserve(seed_size);
116  for ( unsigned iseed=0; iseed<seedCollections; ++iseed ) {
117  edm::Handle<edm::View<TrajectorySeed> > aSeedCollection = theSeeds[iseed];
118  unsigned nSeeds = aSeedCollection->size();
119  for (unsigned seednr = 0; seednr < nSeeds; ++seednr) {
120 
121  // The seed
122  const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]);
123 
124  // Find the first hit of the Seed
125  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
126  const FastTrackerRecHit * theFirstSeedingRecHit =
127  (const FastTrackerRecHit*) (&(*(theSeedingRecHitRange.first)));
128 
129  // The SimTrack id associated to that recHit
130  int simTrackId = theFirstSeedingRecHit->simTrackId(0);
131 
132  // Track already associated to a seed
133  std::set<unsigned>::iterator tkId = tkIds.find(simTrackId);
134  if( tkId != tkIds.end() ) continue;
135 
136  const SimTrack& theSimTrack = (*theSimTracks)[simTrackId];
137 
138  if ( clean(muRef,region.get(),aSeed,theSimTrack) ) tkSeeds.push_back(*aSeed);
139  tkIds.insert(simTrackId);
140 
141  } // End loop on seeds
142 
143  } // End loop on seed collections
144 
145  // A plot
146  // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size());
147 
148  // Another plot
149  // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size());
150 
151 
152  // Now create the Muon Trajectory Seed
153  unsigned int is=0;
154  unsigned int isMax=tkSeeds.size();
155  for (;is!=isMax;++is){
156  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
157  } // End of tk seed loop
158 
159  } // End of l2 muon loop
160 
161  // std::cout << "Found " << result->size() << " seeds for muons" << std::endl;
162 
163  // And yet another plot
164  // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size());
165 
166  //put in the event
167  ev.put(std::move(result));
168 
169 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
std::vector< edm::InputTag > theSeedCollectionLabels
virtual void setEvent(const edm::Event &)
Pass the Event to the algo at each event.
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
edm::InputTag theSimTrackCollectionLabel
MuonTrackingRegionBuilder * theRegionBuilder
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
virtual int32_t simTrackId(size_t i) const
bool clean(reco::TrackRef muRef, RectangularEtaPhiTrackingRegion *region, const BasicTrajectorySeed *aSeed, const SimTrack &theSimTrack)
std::pair< const_iterator, const_iterator > range
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
int iseed
Definition: AMPTWrapper.h:124
range recHits() const
edm::InputTag theL2CollectionLabel
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::ParameterSet FastTSGFromL2Muon::theConfig
private

Definition at line 41 of file FastTSGFromL2Muon.h.

Referenced by beginRun().

edm::InputTag FastTSGFromL2Muon::theL2CollectionLabel
private

Definition at line 43 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

double FastTSGFromL2Muon::thePtCut
private

Definition at line 49 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

MuonTrackingRegionBuilder* FastTSGFromL2Muon::theRegionBuilder
private

Definition at line 50 of file FastTSGFromL2Muon.h.

Referenced by beginRun(), and produce().

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

Definition at line 44 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().

MuonServiceProxy* FastTSGFromL2Muon::theService
private

Definition at line 48 of file FastTSGFromL2Muon.h.

edm::InputTag FastTSGFromL2Muon::theSimTrackCollectionLabel
private

Definition at line 42 of file FastTSGFromL2Muon.h.

Referenced by FastTSGFromL2Muon(), and produce().