CMS 3D CMS Logo

HIMuonTrackingRegionProducer.h
Go to the documentation of this file.
1 #ifndef RecoHI_HiTracking_HIMuonTrackingRegionProducer_H
2 #define RecoHI_HiTracking_HIMuonTrackingRegionProducer_H
3 
6 
11 
14 
17 
19 
20  public:
21 
23 
24  // get parameters from PSet
25  theMuonSource = cfg.getParameter<edm::InputTag>("MuonSrc");
27 
28  // initialize region builder
29  edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
30  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,iC);
31 
32  // initialize muon service proxy
33  edm::ParameterSet servicePSet = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
34  theService = new MuonServiceProxy(servicePSet);
35 
36  }
37 
38 
40 
41 
42  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
44 
45  desc.add<edm::InputTag>("MuonSrc", edm::InputTag(""));
46 
49  desc.add("MuonTrackingRegionBuilder", descRegion);
50 
51  edm::ParameterSetDescription descService;
52  descService.setAllowAnything();
53  desc.add<edm::ParameterSetDescription>("ServiceParameters", descService);
54 
55  descriptions.add("HiTrackingRegionEDProducer", desc);
56  }
57 
58  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& ev, const edm::EventSetup& es) const override {
59 
60  // initialize output vector of tracking regions
61  std::vector<std::unique_ptr<TrackingRegion> > result;
62 
63  // initialize the region builder
64  theService->update(es);
66 
67  // get stand-alone muon collection
69  ev.getByToken(theMuonSourceToken ,muonH);
70 
71  // loop over all muons and add a tracking region for each
72  // that passes the requirements specified to theRegionBuilder
73  unsigned int nMuons = muonH->size();
74  //std::cout << "there are " << nMuons << " muon(s)" << std::endl;
75 
76  // TO DO: this can be extended further to a double-loop
77  // over all combinations of muons, returning tracking regions
78  // for pairs that pass some loose invariant mass cuts
79  for(unsigned int imu=0; imu<nMuons; imu++) {
80  reco::TrackRef muRef(muonH, imu);
81  //std::cout << "muon #" << imu << ": pt=" << muRef->pt() << std::endl;
82  result.push_back(theRegionBuilder->region(muRef));
83  }
84 
85  return result;
86 
87  }
88 
89 
90  private:
91 
96 
97 };
98 
99 #endif
void update(const edm::EventSetup &setup)
update the services each event
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > theMuonSourceToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void setAllowAnything()
allow any parameter label/value pairs
virtual void setEvent(const edm::Event &)
Pass the Event to the algo at each event.
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
bool ev
MuonTrackingRegionBuilder * theRegionBuilder
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &es) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptionsOffline(edm::ParameterSetDescription &descriptions)
HIMuonTrackingRegionProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)