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 Member Functions | Private Attributes
UpdatedMuonInnerTrackRef Class Reference
Inheritance diagram for UpdatedMuonInnerTrackRef:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 UpdatedMuonInnerTrackRef (const edm::ParameterSet &)
 
 ~UpdatedMuonInnerTrackRef ()
 
- 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 Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
reco::TrackRef findNewRef (reco::TrackRef oldTrackRef, edm::Handle< reco::TrackCollection > &newTrackCollection)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double maxInvPtDiff
 
double minDR
 
edm::InputTag muonTag_
 
edm::InputTag newTrackTag_
 
edm::InputTag oldTrackTag_
 

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

Definition at line 19 of file UpdatedMuonInnerTrackRef.cc.

Constructor & Destructor Documentation

UpdatedMuonInnerTrackRef::UpdatedMuonInnerTrackRef ( const edm::ParameterSet pset)
explicit

Definition at line 41 of file UpdatedMuonInnerTrackRef.cc.

References edm::ParameterSet::getUntrackedParameter(), maxInvPtDiff, minDR, muonTag_, newTrackTag_, and oldTrackTag_.

42 {
43  // What is being produced
44  produces<std::vector<reco::Muon> >();
45 
46  // Input products
47  muonTag_ = pset.getUntrackedParameter<edm::InputTag> ("MuonTag" , edm::InputTag("muons"));
48  oldTrackTag_ = pset.getUntrackedParameter<edm::InputTag> ("OldTrackTag", edm::InputTag("generalTracks"));
49  newTrackTag_ = pset.getUntrackedParameter<edm::InputTag> ("NewTrackTag", edm::InputTag("generalTracksSkim"));
50 
51  // matching criteria products
52  maxInvPtDiff=pset.getUntrackedParameter<double>("maxInvPtDiff", 0.005);
53  minDR=pset.getUntrackedParameter<double>("minDR", 0.1);
54 }
T getUntrackedParameter(std::string const &, T const &) const
UpdatedMuonInnerTrackRef::~UpdatedMuonInnerTrackRef ( )

Definition at line 57 of file UpdatedMuonInnerTrackRef.cc.

57  {
58 }

Member Function Documentation

void UpdatedMuonInnerTrackRef::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 61 of file UpdatedMuonInnerTrackRef.cc.

61  {
62 }
void UpdatedMuonInnerTrackRef::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 65 of file UpdatedMuonInnerTrackRef.cc.

65  {
66 }
reco::TrackRef UpdatedMuonInnerTrackRef::findNewRef ( reco::TrackRef  oldTrackRef,
edm::Handle< reco::TrackCollection > &  newTrackCollection 
)
private

Definition at line 117 of file UpdatedMuonInnerTrackRef.cc.

References deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, newFWLiteAna::found, i, edm::Ref< C, T, F >::isNull(), maxInvPtDiff, and minDR.

Referenced by produce().

117  {
118  float dRMin=1000; int found = -1;
119  for(unsigned int i=0;i<newTrackCollection->size();i++){
120  reco::TrackRef newTrackRef = reco::TrackRef( newTrackCollection, i );
121  if(newTrackRef.isNull())continue;
122 
123  if( fabs( (1.0/newTrackRef->pt())-(1.0/oldTrackRef->pt())) > maxInvPtDiff) continue;
124  float dR = deltaR(newTrackRef->momentum(), oldTrackRef->momentum());
125  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = i;}
126  }
127 
128  if(found>=0){
129  return reco::TrackRef( newTrackCollection, found );
130  }else{
131  return reco::TrackRef();
132  }
133 }
int i
Definition: DBlmapReader.cc:9
bool isNull() const
Checks for null.
Definition: Ref.h:247
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
void UpdatedMuonInnerTrackRef::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 69 of file UpdatedMuonInnerTrackRef.cc.

References reco::Muon::clone(), findNewRef(), edm::Event::getByLabel(), i, reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), RPCpg::mu, muonTag_, MuonAlignmentFromReference_cff::newmuons, newTrackTag_, oldTrackTag_, edm::Event::put(), and reco::Muon::setInnerTrack().

70 {
71  // Muon collection
72  edm::Handle<edm::View<reco::Muon> > muonCollectionHandle;
73  if (!ev.getByLabel(muonTag_, muonCollectionHandle)) {
74  edm::LogError("") << ">>> Muon collection does not exist !!!";
75  return;
76  }
77 
78 
79  edm::Handle<reco::TrackCollection> oldTrackCollection;
80  if (!ev.getByLabel(oldTrackTag_, oldTrackCollection)) {
81  edm::LogError("") << ">>> Old Track collection does not exist !!!";
82  return;
83  }
84 
85  edm::Handle<reco::TrackCollection> newTrackCollection;
86  if (!ev.getByLabel(newTrackTag_, newTrackCollection)) {
87  edm::LogError("") << ">>> New Track collection does not exist !!!";
88  return;
89  }
90 
91  unsigned int muonCollectionSize = muonCollectionHandle->size();
92  std::auto_ptr<reco::MuonCollection> newmuons (new reco::MuonCollection);
93 
94 
95  for (unsigned int i=0; i<muonCollectionSize; i++) {
96  edm::RefToBase<reco::Muon> mu = muonCollectionHandle->refAt(i);
97  reco::Muon* newmu = mu->clone();
98 
99  if(mu->innerTrack().isNonnull()){
100  reco::TrackRef newTrackRef = findNewRef(mu->innerTrack(), newTrackCollection);
101 /* printf(" %6.2f %+6.2f %+6.2f --> ",mu->innerTrack()->pt (), mu->innerTrack()->eta(), mu->innerTrack()->phi());
102  if(newTrackRef.isNonnull()){
103  printf(" %6.2f %+6.2f %+6.2f\n",newTrackRef->pt (), newTrackRef->eta(), newTrackRef->phi());
104  }else{
105  printf("\n");
106  }
107 */
108  newmu->setInnerTrack(newTrackRef);
109  }
110 
111  newmuons->push_back(*newmu);
112  }
113 
114  ev.put(newmuons);
115 }
int i
Definition: DBlmapReader.cc:9
virtual TrackRef innerTrack() const
Definition: Muon.h:49
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:846
reco::TrackRef findNewRef(reco::TrackRef oldTrackRef, edm::Handle< reco::TrackCollection > &newTrackCollection)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
const int mu
Definition: Constants.h:23
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Muon * clone() const
create a clone
Definition: Muon.cc:44

Member Data Documentation

double UpdatedMuonInnerTrackRef::maxInvPtDiff
private

Definition at line 35 of file UpdatedMuonInnerTrackRef.cc.

Referenced by findNewRef(), and UpdatedMuonInnerTrackRef().

double UpdatedMuonInnerTrackRef::minDR
private

Definition at line 36 of file UpdatedMuonInnerTrackRef.cc.

Referenced by findNewRef(), and UpdatedMuonInnerTrackRef().

edm::InputTag UpdatedMuonInnerTrackRef::muonTag_
private

Definition at line 31 of file UpdatedMuonInnerTrackRef.cc.

Referenced by produce(), and UpdatedMuonInnerTrackRef().

edm::InputTag UpdatedMuonInnerTrackRef::newTrackTag_
private

Definition at line 33 of file UpdatedMuonInnerTrackRef.cc.

Referenced by produce(), and UpdatedMuonInnerTrackRef().

edm::InputTag UpdatedMuonInnerTrackRef::oldTrackTag_
private

Definition at line 32 of file UpdatedMuonInnerTrackRef.cc.

Referenced by produce(), and UpdatedMuonInnerTrackRef().