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"
7 
9 
13 #include <vector>
14 
16 
24 
26  : theConfig(cfg), theService(0), theRegionBuilder(0), theTkSeedGenerator(0), theSeedCleaner(0)
27 {
28  produces<L3MuonTrajectorySeedCollection>();
29 
30  edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
31  theService = new MuonServiceProxy(serviceParameters);
32 
33  thePtCut = cfg.getParameter<double>("PtCut");
34  thePCut = cfg.getParameter<double>("PCut");
35 
36  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
37 
38  //region builder
39  edm::ParameterSet regionBuilderPSet = theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
40  //ability to no define a region
41  if (!regionBuilderPSet.empty()){
42  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet);
43  }
44 
45  //seed generator
46  //std::string seedGenPSetLabel = theConfig.getParameter<std::string>("tkSeedGenerator");
47  //edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>(seedGenPSetLabel);
48  edm::ParameterSet seedGenPSet = theConfig.getParameter<edm::ParameterSet>("TkSeedGenerator");
49  std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
50 
51  theTkSeedGenerator = TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet);
52 
53  //seed cleaner
54  edm::ParameterSet trackerSeedCleanerPSet = theConfig.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
55  //to activate or not the cleaner
56  if (!trackerSeedCleanerPSet.empty()){
57  theSeedCleaner = new TrackerSeedCleaner(trackerSeedCleanerPSet);
58  }
59 
60 }
61 
63 {
64  delete theService;
65  if (theSeedCleaner) delete theSeedCleaner;
66  delete theTkSeedGenerator;
68 }
69 
71 {
72  //update muon proxy service
73  theService->update(es);
74 
78 
79 }
80 
82 {
83  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
84 
85  //Retrieve tracker topology from geometry
87  es.get<IdealGeometryRecord>().get(tTopoHand);
88  const TrackerTopology *tTopo=tTopoHand.product();
89 
90 
91  //intialize tools
92  theService->update(es);
96 
97  //retrieve L2 track collection
99  ev.getByLabel(theL2CollectionLabel ,l2muonH);
100 
101  // produce trajectoryseed collection
102  unsigned int imu=0;
103  unsigned int imuMax=l2muonH->size();
104  LogDebug("TSGFromL2Muon")<<imuMax<<" l2 tracks.";
105 
106  for (;imu!=imuMax;++imu){
107  //make a ref to l2 muon
108  reco::TrackRef muRef(l2muonH, imu);
109 
110  // cut on muons with low momenta
111  if ( muRef->pt() < thePtCut
112  || muRef->innerMomentum().Rho() < thePtCut
113  || muRef->innerMomentum().R() < thePCut ) continue;
114 
115  //define the region of interest
116  std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
117  if(theRegionBuilder){
118  region.reset(theRegionBuilder->region(muRef));
119  }
120 
121  //get the seeds
122  std::vector<TrajectorySeed> tkSeeds;
123  //make this stupid TrackCand
124  std::pair<const Trajectory*,reco::TrackRef> staCand((Trajectory*)(0), muRef);
125  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo,tkSeeds);
126 
127  //Seed Cleaner From Direction
128  //clean them internatly
129  if(theSeedCleaner){
130  theSeedCleaner->clean(muRef,*region,tkSeeds);
131  LogDebug("TSGFromL2Muon") << tkSeeds.size() << " seeds for this L2 afther cleaning.";
132  }
133 
134  unsigned int is=0;
135  unsigned int isMax=tkSeeds.size();
136  LogDebug("TSGFromL2Muon")<<isMax<<" seeds for this L2.";
137  for (;is!=isMax;++is){
138  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
139  }//tkseed loop
140 
141  }//l2muon loop
142 
143 
144  //ADDME
145  //remove seed duplicate, keeping the ref to L2
146 
147  LogDebug("TSGFromL2Muon")<<result->size()<<" trajectory seeds to the events";
148 
149  //put in the event
150  ev.put(result);
151 }
152 
#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:219
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
MuonTrackingRegionBuilder * theRegionBuilder
Definition: TSGFromL2Muon.h:33
TrackerSeedCleaner * theSeedCleaner
Definition: TSGFromL2Muon.h:35
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
virtual void trackerSeeds(const TrackCand &, const TrackingRegion &, const TrackerTopology *, BTSeedCollection &)
TSGFromL2Muon(const edm::ParameterSet &cfg)
virtual void setEvent(const edm::Event &)
setEvent
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:29
MuonServiceProxy * theService
Definition: TSGFromL2Muon.h:31
virtual void init(const MuonServiceProxy *service)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
edm::ParameterSet theConfig
Definition: TSGFromL2Muon.h:28
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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:34
virtual void setEvent(const edm::Event &)
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:36
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner