CMS 3D CMS Logo

TSGFromL2Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL2Muon.h"
8 
10  : theConfig(cfg), theService(0), theRegionBuilder(0), theTkSeedGenerator(0), theSeedCleaner(0){
11  produces<L3MuonTrajectorySeedCollection>();
12 
14 
15  edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
16  theService = new MuonServiceProxy(serviceParameters);
17 
18  //Pt and P cuts
19  thePtCut = cfg.getParameter<double>("PtCut");
20  thePCut = cfg.getParameter<double>("PCut");
21 
22  //Region builder
23  edm::ParameterSet regionBuilderPSet = theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
24  //ability to no define a region
25  if (!regionBuilderPSet.empty()){
26  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC);
27  }
28 
29  //Seed generator
30  edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>("TkSeedGenerator");
31  std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
32  theTkSeedGenerator = TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet,iC);
33 
34  //Seed cleaner
35  edm::ParameterSet trackerSeedCleanerPSet = theConfig.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
36  //To activate or not the cleaner
37  if (!trackerSeedCleanerPSet.empty()){
38  theSeedCleaner = new TrackerSeedCleaner(trackerSeedCleanerPSet,iC);
39  }
40 
41  //L2 collection
42  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
43  l2muonToken = consumes<reco::TrackCollection>(theL2CollectionLabel);
44 }
45 
46 
48  delete theService;
49  if (theSeedCleaner) delete theSeedCleaner;
50  delete theTkSeedGenerator;
52 }
53 
54 
56  //update muon proxy service
57  theService->update(es);
60 }
61 
62 
64  auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
65 
66  //Retrieve tracker topology from geometry
68  es.get<TrackerTopologyRcd>().get(tTopoHand);
69  const TrackerTopology *tTopo=tTopoHand.product();
70 
71  //intialize tools
72  theService->update(es);
76 
77  //retrieve L2 track collection
79  ev.getByToken(l2muonToken ,l2muonH);
80 
81  // produce trajectory seed collection
82  LogDebug("TSGFromL2Muon")<<l2muonH->size()<<" l2 tracks.";
83 
84  for (unsigned int imu=0; imu != l2muonH->size(); ++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
90  || muRef->innerMomentum().Rho() < thePtCut
91  || muRef->innerMomentum().R() < thePCut ) continue;
92 
93  //define the region of interest
94  std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
95  if(theRegionBuilder){
96  region = theRegionBuilder->region(muRef);
97  }
98 
99  //Make seeds container
100  std::vector<TrajectorySeed> tkSeeds;
101 
102  //Make TrackCand
103  std::pair<const Trajectory*,reco::TrackRef> staCand((Trajectory*)(0), muRef);
104 
105  //Run seed generator to fill seed container
106  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo,tkSeeds);
107 
108  //Seed Cleaner From Direction
109  if(theSeedCleaner){
110  theSeedCleaner->clean(muRef,*region,tkSeeds);
111  }
112 
113  for (unsigned int is=0; is != tkSeeds.size(); ++is){
114  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
115  }
116 
117  }
118 
119 
120  //ADDME: remove seed duplicate, keeping the ref to L2
121 
122  LogDebug("TSGFromL2Muon")<<result->size()<<" trajectory seeds to the events";
123 
124  //put in the event
125  ev.put(std::move(result));
126 }
127 
128 // FillDescription generated from hltL3TrajSeedOIState with additions from OIHit and IOHit
129 void
132  desc.setAllowAnything();
133 }
134 
#define LogDebug(id)
void update(const edm::EventSetup &setup)
update the services each event
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:218
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
MuonTrackingRegionBuilder * theRegionBuilder
Definition: TSGFromL2Muon.h:37
void setAllowAnything()
allow any parameter label/value pairs
TrackerSeedCleaner * theSeedCleaner
Definition: TSGFromL2Muon.h:39
virtual void setEvent(const edm::Event &)
Pass the Event to the algo at each event.
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
edm::EDGetTokenT< reco::TrackCollection > l2muonToken
Definition: TSGFromL2Muon.h:40
virtual void trackerSeeds(const TrackCand &, const TrackingRegion &, const TrackerTopology *, BTSeedCollection &)
bool ev
TSGFromL2Muon(const edm::ParameterSet &cfg)
Definition: TSGFromL2Muon.cc:9
virtual void setEvent(const edm::Event &)
setEvent
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:34
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
MuonServiceProxy * theService
Definition: TSGFromL2Muon.h:35
virtual void init(const MuonServiceProxy *service)
edm::ParameterSet theConfig
Definition: TSGFromL2Muon.h:33
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const T & get() const
Definition: EventSetup.h:56
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual ~TSGFromL2Muon()
virtual void init(const MuonServiceProxy *service)
intizialization
TrackerSeedGenerator * theTkSeedGenerator
Definition: TSGFromL2Muon.h:38
virtual void setEvent(const edm::Event &)
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:42
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner