CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TSGFromL2Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL2Muon.h"
2 
4  : theConfig(cfg), theService(0), theRegionBuilder(0), theTkSeedGenerator(0), theSeedCleaner(0)
5 {
6  produces<L3MuonTrajectorySeedCollection>();
7 
8  edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
9  theService = new MuonServiceProxy(serviceParameters);
10 
11  thePtCut = cfg.getParameter<double>("PtCut");
12  thePCut = cfg.getParameter<double>("PCut");
13 
14  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
15 
17 
18  //region builder
19  edm::ParameterSet regionBuilderPSet = theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
20  //ability to no define a region
21  if (!regionBuilderPSet.empty()){
22  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC);
23  }
24 
25  //seed generator
26  //std::string seedGenPSetLabel = theConfig.getParameter<std::string>("tkSeedGenerator");
27  //edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>(seedGenPSetLabel);
28  edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>("TkSeedGenerator");
29  std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
30 
31  theTkSeedGenerator = TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet,iC);
32 
33  //seed cleaner
34  edm::ParameterSet trackerSeedCleanerPSet = theConfig.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
35  //to activate or not the cleaner
36  if (!trackerSeedCleanerPSet.empty()){
37  theSeedCleaner = new TrackerSeedCleaner(trackerSeedCleanerPSet,iC);
38  }
39 
40 
41  l2muonToken = consumes<reco::TrackCollection>(theL2CollectionLabel);
42 }
43 
45 {
46  delete theService;
47  if (theSeedCleaner) delete theSeedCleaner;
48  delete theTkSeedGenerator;
50 }
51 
53 {
54  //update muon proxy service
55  theService->update(es);
56 
60 
61 }
62 
64 {
65  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
66 
67  //Retrieve tracker topology from geometry
69  es.get<IdealGeometryRecord>().get(tTopoHand);
70  const TrackerTopology *tTopo=tTopoHand.product();
71 
72 
73  //intialize tools
74  theService->update(es);
78 
79  //retrieve L2 track collection
81  ev.getByToken(l2muonToken ,l2muonH);
82 
83  // produce trajectoryseed collection
84  unsigned int imu=0;
85  unsigned int imuMax=l2muonH->size();
86  LogDebug("TSGFromL2Muon")<<imuMax<<" l2 tracks.";
87 
88  for (;imu!=imuMax;++imu){
89  //make a ref to l2 muon
90  reco::TrackRef muRef(l2muonH, imu);
91 
92  // cut on muons with low momenta
93  if ( muRef->pt() < thePtCut
94  || muRef->innerMomentum().Rho() < thePtCut
95  || muRef->innerMomentum().R() < thePCut ) continue;
96 
97  //define the region of interest
98  std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
99  if(theRegionBuilder){
100  region.reset(theRegionBuilder->region(muRef));
101  }
102 
103  //get the seeds
104  std::vector<TrajectorySeed> tkSeeds;
105  //make this stupid TrackCand
106  std::pair<const Trajectory*,reco::TrackRef> staCand((Trajectory*)(0), muRef);
107  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo,tkSeeds);
108 
109  //Seed Cleaner From Direction
110  //clean them internatly
111  if(theSeedCleaner){
112  theSeedCleaner->clean(muRef,*region,tkSeeds);
113  LogDebug("TSGFromL2Muon") << tkSeeds.size() << " seeds for this L2 afther cleaning.";
114  }
115 
116  unsigned int is=0;
117  unsigned int isMax=tkSeeds.size();
118  LogDebug("TSGFromL2Muon")<<isMax<<" seeds for this L2.";
119  for (;is!=isMax;++is){
120  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
121  }//tkseed loop
122 
123  }//l2muon loop
124 
125 
126  //ADDME
127  //remove seed duplicate, keeping the ref to L2
128 
129  LogDebug("TSGFromL2Muon")<<result->size()<<" trajectory seeds to the events";
130 
131  //put in the event
132  ev.put(result);
133 }
134 
#define LogDebug(id)
void update(const edm::EventSetup &setup)
update the services each event
RectangularEtaPhiTrackingRegion * region(const reco::TrackRef &) const
define tracking region
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:216
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MuonTrackingRegionBuilder * theRegionBuilder
Definition: TSGFromL2Muon.h:54
TrackerSeedCleaner * theSeedCleaner
Definition: TSGFromL2Muon.h:56
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
edm::EDGetTokenT< reco::TrackCollection > l2muonToken
Definition: TSGFromL2Muon.h:59
virtual void trackerSeeds(const TrackCand &, const TrackingRegion &, const TrackerTopology *, BTSeedCollection &)
TSGFromL2Muon(const edm::ParameterSet &cfg)
Definition: TSGFromL2Muon.cc:3
virtual void setEvent(const edm::Event &)
setEvent
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:50
MuonServiceProxy * theService
Definition: TSGFromL2Muon.h:52
virtual void init(const MuonServiceProxy *service)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::ParameterSet theConfig
Definition: TSGFromL2Muon.h:49
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
tuple result
Definition: query.py:137
void init(const MuonServiceProxy *)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
virtual ~TSGFromL2Muon()
virtual void init(const MuonServiceProxy *service)
intizialization
TrackerSeedGenerator * theTkSeedGenerator
Definition: TSGFromL2Muon.h:55
virtual void setEvent(const edm::Event &)
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:41
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner