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