CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonCaloCleanerAllCrossed.cc
Go to the documentation of this file.
2 
4 
6 
12 
14 
15 #include <string>
16 #include <vector>
17 
19  : srcSelectedMuons_(cfg.getParameter<edm::InputTag>("selectedMuons")),
20  srcESrecHits_(cfg.getParameter<edm::InputTag>("esRecHits"))
21 {
22  edm::ParameterSet cfgTrackAssociator = cfg.getParameter<edm::ParameterSet>("trackAssociator");
24  trackAssociatorParameters_.loadParameters(cfgTrackAssociator, iC);
26 
27  // maps of detId to energy deposit attributed to muon
28  produces<detIdToFloatMap>("energyDepositsMuPlus");
29  produces<detIdToFloatMap>("energyDepositsMuMinus");
30 }
31 
33 {
34 // nothing to be done yet...
35 }
36 
38 {
39  std::auto_ptr<detIdToFloatMap> energyDepositsMuPlus(new detIdToFloatMap());
40  std::auto_ptr<detIdToFloatMap> energyDepositsMuMinus(new detIdToFloatMap());
41 
42  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
43  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
44  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
45 
46  if ( muPlus.isNonnull() ) fillEnergyDepositMap(evt, es, &(*muPlus), *energyDepositsMuPlus);
47  if ( muMinus.isNonnull() ) fillEnergyDepositMap(evt, es, &(*muMinus), *energyDepositsMuMinus);
48 
49  evt.put(energyDepositsMuPlus, "energyDepositsMuPlus");
50  evt.put(energyDepositsMuMinus, "energyDepositsMuMinus");
51 }
52 
54 {
56 
57  for ( std::vector<const EcalRecHit*>::const_iterator rh = trackDetMatchInfo.crossedEcalRecHits.begin();
58  rh != trackDetMatchInfo.crossedEcalRecHits.end(); ++rh ) {
59  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
60  }
61 
62  for ( std::vector<const HBHERecHit*>::const_iterator rh = trackDetMatchInfo.crossedHcalRecHits.begin();
63  rh != trackDetMatchInfo.crossedHcalRecHits.end(); ++rh ) {
64  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
65  }
66 
67  for ( std::vector<const HORecHit*>::const_iterator rh = trackDetMatchInfo.crossedHORecHits.begin();
68  rh != trackDetMatchInfo.crossedHORecHits.end(); ++rh ) {
69  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
70  }
71 
72  // TF: there exists no better way
74  evt.getByLabel(srcESrecHits_, esRecHits);
75  for ( std::vector<DetId>::const_iterator detId = trackDetMatchInfo.crossedPreshowerIds.begin();
76  detId != trackDetMatchInfo.crossedPreshowerIds.end(); ++detId ) {
77  ESRecHitCollection::const_iterator rh = esRecHits->find(*detId);
78  if ( rh != esRecHits->end() ) {
79  energyDepositMap[rh->detid().rawId()] += rh->energy();
80  }
81  }
82 }
83 
85 
std::vector< DetId > crossedPreshowerIds
T getParameter(std::string const &) const
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
std::vector< const HBHERecHit * > crossedHcalRecHits
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void useDefaultPropagator()
use the default propagator
std::vector< EcalRecHit >::const_iterator const_iterator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
TrackDetMatchInfo getTrackDetMatchInfo(const edm::Event &, const edm::EventSetup &, TrackDetectorAssociator &, const TrackAssociatorParameters &, const reco::Candidate *)
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
MuonCaloCleanerAllCrossed(const edm::ParameterSet &)
void fillEnergyDepositMap(edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &)
TrackAssociatorParameters trackAssociatorParameters_
std::map< uint32_t, float > detIdToFloatMap
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackDetectorAssociator trackAssociator_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::vector< const HORecHit * > crossedHORecHits
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:279