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 
16  //region builder
17  edm::ParameterSet regionBuilderPSet = theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
18  //ability to no define a region
19  if (!regionBuilderPSet.empty()){
20  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet);
21  }
22 
23  //seed generator
24  //std::string seedGenPSetLabel = theConfig.getParameter<std::string>("tkSeedGenerator");
25  //edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>(seedGenPSetLabel);
26  edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>("TkSeedGenerator");
27  std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
28 
30  theTkSeedGenerator = TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet,iC);
31 
32  //seed cleaner
33  edm::ParameterSet trackerSeedCleanerPSet = theConfig.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
34  //to activate or not the cleaner
35  if (!trackerSeedCleanerPSet.empty()){
36  theSeedCleaner = new TrackerSeedCleaner(trackerSeedCleanerPSet,iC);
37  }
38 
39 
40  l2muonToken = consumes<reco::TrackCollection>(theL2CollectionLabel);
41 }
42 
44 {
45  delete theService;
46  if (theSeedCleaner) delete theSeedCleaner;
47  delete theTkSeedGenerator;
49 }
50 
52 {
53  //update muon proxy service
54  theService->update(es);
55 
59 
60 }
61 
63 {
64  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
65 
66  //Retrieve tracker topology from geometry
68  es.get<IdealGeometryRecord>().get(tTopoHand);
69  const TrackerTopology *tTopo=tTopoHand.product();
70 
71 
72  //intialize tools
73  theService->update(es);
77 
78  //retrieve L2 track collection
80  ev.getByToken(l2muonToken ,l2muonH);
81 
82  // produce trajectoryseed collection
83  unsigned int imu=0;
84  unsigned int imuMax=l2muonH->size();
85  LogDebug("TSGFromL2Muon")<<imuMax<<" l2 tracks.";
86 
87  for (;imu!=imuMax;++imu){
88  //make a ref to l2 muon
89  reco::TrackRef muRef(l2muonH, imu);
90 
91  // cut on muons with low momenta
92  if ( muRef->pt() < thePtCut
93  || muRef->innerMomentum().Rho() < thePtCut
94  || muRef->innerMomentum().R() < thePCut ) continue;
95 
96  //define the region of interest
97  std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
98  if(theRegionBuilder){
99  region.reset(theRegionBuilder->region(muRef));
100  }
101 
102  //get the seeds
103  std::vector<TrajectorySeed> tkSeeds;
104  //make this stupid TrackCand
105  std::pair<const Trajectory*,reco::TrackRef> staCand((Trajectory*)(0), muRef);
106  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo,tkSeeds);
107 
108  //Seed Cleaner From Direction
109  //clean them internatly
110  if(theSeedCleaner){
111  theSeedCleaner->clean(muRef,*region,tkSeeds);
112  LogDebug("TSGFromL2Muon") << tkSeeds.size() << " seeds for this L2 afther cleaning.";
113  }
114 
115  unsigned int is=0;
116  unsigned int isMax=tkSeeds.size();
117  LogDebug("TSGFromL2Muon")<<isMax<<" seeds for this L2.";
118  for (;is!=isMax;++is){
119  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
120  }//tkseed loop
121 
122  }//l2muon loop
123 
124 
125  //ADDME
126  //remove seed duplicate, keeping the ref to L2
127 
128  LogDebug("TSGFromL2Muon")<<result->size()<<" trajectory seeds to the events";
129 
130  //put in the event
131  ev.put(result);
132 }
133 
#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