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");
23  trackAssociatorParameters_.loadParameters(cfgTrackAssociator);
25 
26  // maps of detId to energy deposit attributed to muon
27  produces<detIdToFloatMap>("energyDepositsMuPlus");
28  produces<detIdToFloatMap>("energyDepositsMuMinus");
29 }
30 
32 {
33 // nothing to be done yet...
34 }
35 
37 {
38  std::auto_ptr<detIdToFloatMap> energyDepositsMuPlus(new detIdToFloatMap());
39  std::auto_ptr<detIdToFloatMap> energyDepositsMuMinus(new detIdToFloatMap());
40 
41  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
42  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
43  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
44 
45  if ( muPlus.isNonnull() ) fillEnergyDepositMap(evt, es, &(*muPlus), *energyDepositsMuPlus);
46  if ( muMinus.isNonnull() ) fillEnergyDepositMap(evt, es, &(*muMinus), *energyDepositsMuMinus);
47 
48  evt.put(energyDepositsMuPlus, "energyDepositsMuPlus");
49  evt.put(energyDepositsMuMinus, "energyDepositsMuMinus");
50 }
51 
53 {
55 
56  for ( std::vector<const EcalRecHit*>::const_iterator rh = trackDetMatchInfo.crossedEcalRecHits.begin();
57  rh != trackDetMatchInfo.crossedEcalRecHits.end(); ++rh ) {
58  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
59  }
60 
61  for ( std::vector<const HBHERecHit*>::const_iterator rh = trackDetMatchInfo.crossedHcalRecHits.begin();
62  rh != trackDetMatchInfo.crossedHcalRecHits.end(); ++rh ) {
63  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
64  }
65 
66  for ( std::vector<const HORecHit*>::const_iterator rh = trackDetMatchInfo.crossedHORecHits.begin();
67  rh != trackDetMatchInfo.crossedHORecHits.end(); ++rh ) {
68  energyDepositMap[(*rh)->detid().rawId()] += (*rh)->energy();
69  }
70 
71  // TF: there exists no better way
73  evt.getByLabel(srcESrecHits_, esRecHits);
74  for ( std::vector<DetId>::const_iterator detId = trackDetMatchInfo.crossedPreshowerIds.begin();
75  detId != trackDetMatchInfo.crossedPreshowerIds.end(); ++detId ) {
76  ESRecHitCollection::const_iterator rh = esRecHits->find(*detId);
77  if ( rh != esRecHits->end() ) {
78  energyDepositMap[rh->detid().rawId()] += rh->energy();
79  }
80  }
81 }
82 
84 
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
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
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
void loadParameters(const edm::ParameterSet &)