CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CaloMuonMerger Class Reference

Merges reco::CaloMuons, reco::Muons and optionally reco::Tracks avoiding innerTrack duplications in a single reco::Muon collection. More...

#include "RecoMuon/MuonIdentification/plugins/CaloMuonMerger.cc"

Inheritance diagram for CaloMuonMerger:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CaloMuonMerger (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~CaloMuonMerger ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::InputTag caloMuons_
 
StringCutObjectSelector
< reco::CaloMuon, false > 
caloMuonsCut_
 
bool mergeCaloMuons_
 
bool mergeTracks_
 
double minCaloCompatibility_
 
edm::InputTag muons_
 
StringCutObjectSelector
< reco::Muon, false > 
muonsCut_
 
edm::InputTag tracks_
 
StringCutObjectSelector
< reco::TrackRef, false > 
tracksCut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Merges reco::CaloMuons, reco::Muons and optionally reco::Tracks avoiding innerTrack duplications in a single reco::Muon collection.

Author
Giovanni Petrucciani
Version
Id:
CaloMuonMerger.cc,v 1.6 2011/01/06 13:26:53 gpetrucc Exp

Definition at line 25 of file CaloMuonMerger.cc.

Constructor & Destructor Documentation

CaloMuonMerger::CaloMuonMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 45 of file CaloMuonMerger.cc.

45  :
46  muons_(iConfig.getParameter<edm::InputTag>("muons")),
47  muonsCut_(iConfig.existsAs<std::string>("muonsCut") ? iConfig.getParameter<std::string>("muonsCut") : ""),
48  mergeCaloMuons_(iConfig.existsAs<bool>("mergeCaloMuons") ? iConfig.getParameter<bool>("mergeCaloMuons") : true),
49  caloMuons_(iConfig.getParameter<edm::InputTag>("caloMuons")),
50  caloMuonsCut_(iConfig.existsAs<std::string>("caloMuonsCut") ? iConfig.getParameter<std::string>("caloMuonsCut") : ""),
51  minCaloCompatibility_(mergeCaloMuons_ ? iConfig.getParameter<double>("minCaloCompatibility") : 0),
52  mergeTracks_(iConfig.existsAs<bool>("mergeTracks") ? iConfig.getParameter<bool>("mergeTracks") : false),
54  tracksCut_(iConfig.existsAs<std::string>("tracksCut") ? iConfig.getParameter<std::string>("tracksCut") : "")
55 {
56  produces<std::vector<reco::Muon> >();
57 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
StringCutObjectSelector< reco::CaloMuon, false > caloMuonsCut_
double minCaloCompatibility_
StringCutObjectSelector< reco::TrackRef, false > tracksCut_
edm::InputTag tracks_
edm::InputTag muons_
StringCutObjectSelector< reco::Muon, false > muonsCut_
edm::InputTag caloMuons_
virtual CaloMuonMerger::~CaloMuonMerger ( )
inlinevirtual

Definition at line 28 of file CaloMuonMerger.cc.

28 { }

Member Function Documentation

void CaloMuonMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 60 of file CaloMuonMerger.cc.

References reco::Muon::caloCompatibility(), reco::Muon::CaloMuon, caloMuons_, caloMuonsCut_, relval_parameters_module::energy, reco::LeafCandidate::eta(), edm::hlt::Exception, edm::Event::getByLabel(), i, reco::Muon::isCaloCompatibilityValid(), reco::isMuon(), edm::Ref< C, T, F >::isNonnull(), mergeCaloMuons_, mergeTracks_, minCaloCompatibility_, RPCpg::mu, metsig::muon, patZpeak::muons, muons_, muonsCut_, dbtoconf::out, p4, reco::LeafCandidate::pt(), edm::Event::put(), reco::Muon::setCalEnergy(), reco::Muon::setCaloCompatibility(), reco::Muon::setInnerTrack(), reco::Muon::setType(), mathSSE::sqrt(), reco::Muon::track(), testEve_cfg::tracks, tracks_, tracksCut_, and reco::Muon::type().

60  {
64 
65  iEvent.getByLabel(muons_, muons);
66  if(mergeCaloMuons_) iEvent.getByLabel(caloMuons_, caloMuons);
67  if(mergeTracks_) iEvent.getByLabel(tracks_, tracks);
68 
69  std::auto_ptr<std::vector<reco::Muon> > out(new std::vector<reco::Muon>());
70  out->reserve(muons->size() + (mergeTracks_?tracks->size():0));
71 
72  // copy reco::Muons, turning on the CaloCompatibility flag if enabled and possible
73  for (std::vector<reco::Muon>::const_iterator it = muons->begin(), ed = muons->end(); it != ed; ++it) {
74  if(!muonsCut_(*it)) continue;
75  out->push_back(*it);
76  reco::Muon & mu = out->back();
77  if (mergeCaloMuons_ && mu.track().isNonnull()) {
78  if (mu.isCaloCompatibilityValid()) {
81  }
82  } else throw cms::Exception("Boh") << "Muon with track and no CaloCompatibility; pt = " << mu.pt() << ", eta = " << mu.eta() << ", type = " << mu.type() << "\n";
83  }
84  }
85 
86  if (mergeCaloMuons_) {
87  // copy reco::CaloMuon
88  for (std::vector<reco::CaloMuon>::const_iterator it = caloMuons->begin(), ed = caloMuons->end(); it != ed; ++it) {
89  if(!caloMuonsCut_(*it)) continue;
90  // make a reco::Muon
91  reco::TrackRef track = it->track();
92  double energy = sqrt(track->p() * track->p() + 0.011163691);
93  math::XYZTLorentzVector p4(track->px(), track->py(), track->pz(), energy);
94  out->push_back(reco::Muon(track->charge(), p4, track->vertex()));
95  reco::Muon & mu = out->back();
96  // fill info
97  mu.setCalEnergy( it->calEnergy() );
98  mu.setCaloCompatibility( it->caloCompatibility() );
99  mu.setInnerTrack( track );
101  }
102  }
103 
104  // merge reco::Track avoiding duplication of innerTracks
105  if(mergeTracks_){
106  for (size_t i = 0; i < tracks->size(); i++) {
107  reco::TrackRef track(tracks, i);
108  if(!tracksCut_(track)) continue;
109  // check if it is a muon or calomuon
110  bool isMuon = false;
111  for(std::vector<reco::Muon>::const_iterator muon = muons->begin(); muon < muons->end(); muon++){
112  if(muon->innerTrack() == track){
113  isMuon = true;
114  break;
115  }
116  }
117  if(isMuon) continue;
118  if (mergeCaloMuons_) {
119  bool isCaloMuon = false;
120  for(std::vector<reco::CaloMuon>::const_iterator muon = caloMuons->begin(); muon < caloMuons->end(); muon++){
121  if(muon->innerTrack() == track){
122  isCaloMuon = true;
123  break;
124  }
125  }
126  if(isCaloMuon) continue;
127  }
128  // make a reco::Muon
129  double energy = sqrt(track->p() * track->p() + 0.011163691);
130  math::XYZTLorentzVector p4(track->px(), track->py(), track->pz(), energy);
131  out->push_back(reco::Muon(track->charge(), p4, track->vertex()));
132  reco::Muon & mu = out->back();
133  // fill info
134  mu.setInnerTrack( track );
135  }
136  }
137 
138  iEvent.put(out);
139 }
int i
Definition: DBlmapReader.cc:9
void setType(unsigned int type)
Definition: Muon.h:215
bool isMuon(const Candidate &part)
Definition: pdgIdUtils.h:11
bool isCaloCompatibilityValid() const
Definition: Muon.h:153
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:846
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:50
void setCalEnergy(const MuonEnergy &calEnergy)
set energy deposition information
Definition: Muon.h:114
StringCutObjectSelector< reco::CaloMuon, false > caloMuonsCut_
double minCaloCompatibility_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
StringCutObjectSelector< reco::TrackRef, false > tracksCut_
edm::InputTag tracks_
void setCaloCompatibility(float input)
Definition: Muon.h:152
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
T sqrt(T t)
Definition: SSEVec.h:48
double p4[4]
Definition: TauolaWrapper.h:92
const int mu
Definition: Constants.h:23
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
tuple out
Definition: dbtoconf.py:99
edm::InputTag muons_
tuple tracks
Definition: testEve_cfg.py:39
StringCutObjectSelector< reco::Muon, false > muonsCut_
static const unsigned int CaloMuon
Definition: Muon.h:211
tuple muons
Definition: patZpeak.py:38
edm::InputTag caloMuons_
unsigned int type() const
Definition: Muon.h:216
virtual float pt() const GCC11_FINAL
transverse momentum
float caloCompatibility() const
Definition: Muon.h:151

Member Data Documentation

edm::InputTag CaloMuonMerger::caloMuons_
private

Definition at line 36 of file CaloMuonMerger.cc.

Referenced by produce().

StringCutObjectSelector<reco::CaloMuon, false> CaloMuonMerger::caloMuonsCut_
private

Definition at line 37 of file CaloMuonMerger.cc.

Referenced by produce().

bool CaloMuonMerger::mergeCaloMuons_
private

Definition at line 35 of file CaloMuonMerger.cc.

Referenced by produce().

bool CaloMuonMerger::mergeTracks_
private

Definition at line 39 of file CaloMuonMerger.cc.

Referenced by produce().

double CaloMuonMerger::minCaloCompatibility_
private

Definition at line 38 of file CaloMuonMerger.cc.

Referenced by produce().

edm::InputTag CaloMuonMerger::muons_
private

Definition at line 33 of file CaloMuonMerger.cc.

Referenced by produce().

StringCutObjectSelector<reco::Muon, false> CaloMuonMerger::muonsCut_
private

Definition at line 34 of file CaloMuonMerger.cc.

Referenced by produce().

edm::InputTag CaloMuonMerger::tracks_
private

Definition at line 40 of file CaloMuonMerger.cc.

Referenced by produce().

StringCutObjectSelector<reco::TrackRef, false> CaloMuonMerger::tracksCut_
private

Definition at line 41 of file CaloMuonMerger.cc.

Referenced by produce().