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 public:
21  // get parameters from PSet
22  theMuonSource = cfg.getParameter<edm::InputTag>("MuonSrc");
24 
25  // initialize region builder
26  edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
27  theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC);
28 
29  // initialize muon service proxy
30  edm::ParameterSet servicePSet = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
31  theService = new MuonServiceProxy(servicePSet);
32  }
33 
35 
36  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
38 
39  desc.add<edm::InputTag>("MuonSrc", edm::InputTag(""));
40 
43  desc.add("MuonTrackingRegionBuilder", descRegion);
44 
45  edm::ParameterSetDescription descService;
46  descService.setAllowAnything();
47  desc.add<edm::ParameterSetDescription>("ServiceParameters", descService);
48 
49  descriptions.add("HiTrackingRegionEDProducer", desc);
50  }
51 
52  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& ev,
53  const edm::EventSetup& es) const override {
54  // initialize output vector of tracking regions
55  std::vector<std::unique_ptr<TrackingRegion> > result;
56 
57  // initialize the region builder
58  theService->update(es);
60 
61  // get stand-alone muon collection
63  ev.getByToken(theMuonSourceToken, muonH);
64 
65  // loop over all muons and add a tracking region for each
66  // that passes the requirements specified to theRegionBuilder
67  unsigned int nMuons = muonH->size();
68  //std::cout << "there are " << nMuons << " muon(s)" << std::endl;
69 
70  // TO DO: this can be extended further to a double-loop
71  // over all combinations of muons, returning tracking regions
72  // for pairs that pass some loose invariant mass cuts
73  for (unsigned int imu = 0; imu < nMuons; imu++) {
74  reco::TrackRef muRef(muonH, imu);
75  //std::cout << "muon #" << imu << ": pt=" << muRef->pt() << std::endl;
76  result.push_back(theRegionBuilder->region(muRef));
77  }
78 
79  return result;
80  }
81 
82 private:
87 };
88 
89 #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:525
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:14
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)