CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ZMuMuUserData Class Reference
Inheritance diagram for ZMuMuUserData:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef math::XYZVector Vector
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 ZMuMuUserData (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double alpha_
 
InputTag beamSpot_
 
double beta_
 
int counter
 
string hltPath_
 
InputTag primaryVertices_
 
InputTag src_
 
InputTag zGenParticlesMatch_
 

Additional Inherited Members

- 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::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 29 of file ZMuMuUserData.cc.

Member Typedef Documentation

Definition at line 32 of file ZMuMuUserData.cc.

Constructor & Destructor Documentation

ZMuMuUserData::ZMuMuUserData ( const edm::ParameterSet cfg)

Definition at line 46 of file ZMuMuUserData.cc.

46  :
47  src_( cfg.getParameter<InputTag>( "src" ) ),
48  beamSpot_(cfg.getParameter<InputTag>( "beamSpot" ) ),
49  primaryVertices_(cfg.getParameter<InputTag>( "primaryVertices" ) ),
50  zGenParticlesMatch_(cfg.getParameter<InputTag>( "zGenParticlesMatch" ) ),
51  alpha_(cfg.getParameter<double>("alpha") ),
52  beta_(cfg.getParameter<double>("beta") ),
53  hltPath_(cfg.getParameter<std::string >("hltPath") ){
54  produces<vector<pat::CompositeCandidate> >();
55 }
T getParameter(std::string const &) const
InputTag primaryVertices_
InputTag beamSpot_
InputTag zGenParticlesMatch_

Member Function Documentation

void ZMuMuUserData::produce ( edm::Event evt,
const edm::EventSetup  
)
overrideprivatevirtual

I fill the dau1 with positive and dau2 with negatove values for the pt, in order to flag the muons used for building zMassSa

I fill the dau1 with negatove and dau2 with positive values for the pt

Implements edm::EDProducer.

Definition at line 57 of file ZMuMuUserData.cc.

References pat::PATObject< ObjectType >::addUserFloat(), beamSpot_, counter, reco::CompositeCandidate::daughter(), WZMuSkim_cff::dimuons, reco::Candidate::eta(), reco::Candidate::get(), edm::Event::getByLabel(), i, reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), reco::Candidate::mass(), reco::Candidate::masterClone(), reco::Candidate::phi(), reco::Candidate::polarP4(), primaryVertices_, reco::Candidate::pt(), edm::Event::put(), reco::Candidate::rapidity(), src_, detailsBasic3DVector::z, and zGenParticlesMatch_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

57  {
59  evt.getByLabel(src_,dimuons);
60 
61  Handle<BeamSpot> beamSpotHandle;
62  evt.getByLabel(beamSpot_, beamSpotHandle);
63 
64  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
65  evt.getByLabel(primaryVertices_, primaryVertices);
66 
67 
68  bool isMCMatchTrue=false;
69 
70  Handle<GenParticleMatch> zGenParticlesMatch;
71  if(evt.getByLabel( zGenParticlesMatch_, zGenParticlesMatch )){
72  isMCMatchTrue=true;
73  }
74 
75  //cout<<"isMCMatchTrue"<<isMCMatchTrue <<endl;
76  auto_ptr<vector<pat::CompositeCandidate> > dimuonColl( new vector<pat::CompositeCandidate> () );
77 
78 
79  for (unsigned int i = 0; i< dimuons->size();++i){
80  const CompositeCandidate & z = (*dimuons)[i];
81  //CandidateBaseRef zRef = dimuons ->refAt(i);
83  pat::CompositeCandidate dimuon(z);
84 
85  float trueMass,truePt,trueEta,truePhi,trueY;
86  if (isMCMatchTrue){
87  GenParticleRef trueZRef = (*zGenParticlesMatch)[zRef];
88  //CandidateRef trueZRef = trueZIter->val;
89  if( trueZRef.isNonnull() ) {
90  const Candidate & z = * trueZRef;
91  trueMass = z.mass();
92  truePt = z.pt();
93  trueEta = z.eta();
94  truePhi = z.phi();
95  trueY = z.rapidity();
96  } else {
97  trueMass = -100;
98  truePt = -100;
99  trueEta = -100;
100  truePhi = -100;
101  trueY = -100;
102  }
103 
104  dimuon.addUserFloat("TrueMass",trueMass);
105  dimuon.addUserFloat("TruePt",truePt);
106  dimuon.addUserFloat("TrueEta",trueEta);
107  dimuon.addUserFloat("TruePhi",truePhi);
108  dimuon.addUserFloat("TrueY",trueY);
109 
110  }
111  const Candidate * dau1 = z.daughter(0);
112  const Candidate * dau2 = z.daughter(1);
113  const pat::Muon & mu1 = dynamic_cast<const pat::Muon&>(*dau1->masterClone());
114  const pat::Muon & mu2 = dynamic_cast<const pat::Muon&>(*dau2->masterClone());
115 
116  /*cout<<"mu1 is null? "<<mu1.isMuon()<<endl;
117  cout<<"mu2 is null? "<<mu2.isMuon()<<endl;
118  cout<<"mu1 is global?"<<mu1.isGlobalMuon()<<endl;
119  cout<<"mu2 is global?"<<mu2.isGlobalMuon()<<endl;
120  */
121 
122  if(mu1.isGlobalMuon()==true && mu2.isGlobalMuon()==true){
123  TrackRef stAloneTrack1;
124  TrackRef stAloneTrack2;
125  Vector momentum;
127  double mu_mass;
128  stAloneTrack1 = dau1->get<TrackRef,reco::StandAloneMuonTag>();
129  stAloneTrack2 = dau2->get<TrackRef,reco::StandAloneMuonTag>();
130  float zDau1SaEta = stAloneTrack1->eta();
131  float zDau2SaEta = stAloneTrack2->eta();
132  float zDau1SaPhi = stAloneTrack1->phi();
133  float zDau2SaPhi = stAloneTrack2->phi();
134  float zDau1SaPt,zDau2SaPt;
135  if(counter % 2 == 0) {
136  momentum = stAloneTrack1->momentum();
137  p4_1 = dau2->polarP4();
138  mu_mass = dau1->mass();
140  zDau1SaPt = stAloneTrack1->pt();
141  zDau2SaPt = - stAloneTrack2->pt();
142  }else{
143  momentum = stAloneTrack2->momentum();
144  p4_1= dau1->polarP4();
145  mu_mass = dau2->mass();
147  zDau1SaPt = - stAloneTrack1->pt();
148  zDau2SaPt = stAloneTrack2->pt();
149  }
150 
151  Candidate::PolarLorentzVector p4_2(momentum.rho(), momentum.eta(),momentum.phi(), mu_mass);
152  double mass = (p4_1+p4_2).mass();
153  float zMassSa = mass;
154  //cout<<"zMassSa "<<zMassSa;
155  dimuon.addUserFloat("MassSa",zMassSa);
156  dimuon.addUserFloat("Dau1SaPt",zDau1SaPt);
157  dimuon.addUserFloat("Dau2SaPt",zDau2SaPt);
158  dimuon.addUserFloat("Dau1SaPhi",zDau1SaPhi);
159  dimuon.addUserFloat("Dau2SaPhi",zDau2SaPhi);
160  dimuon.addUserFloat("Dau1SaEta",zDau1SaEta);
161  dimuon.addUserFloat("Dau2SaEta",zDau2SaEta);
162  ++counter;
163  }
164  dimuonColl->push_back(dimuon);
165 
166  }
167 
168 
169  evt.put( dimuonColl);
170 }
Analysis-level particle class.
int i
Definition: DBlmapReader.cc:9
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual float mass() const =0
mass
virtual float eta() const =0
momentum pseudorapidity
stand alone muon component tag
Definition: RecoCandidate.h:72
bool isGlobalMuon() const
Definition: Muon.h:218
virtual float phi() const =0
momentum azimuthal angle
virtual double rapidity() const =0
rapidity
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
float float float z
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
InputTag primaryVertices_
virtual float pt() const =0
transverse momentum
fixed size vector
Definition: Vector.h:22
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
InputTag beamSpot_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
InputTag zGenParticlesMatch_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T get() const
get a component
Definition: Candidate.h:219
Analysis-level muon class.
Definition: Muon.h:49
virtual const CandidateBaseRef & masterClone() const =0
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43

Member Data Documentation

double ZMuMuUserData::alpha_
private

Definition at line 37 of file ZMuMuUserData.cc.

InputTag ZMuMuUserData::beamSpot_
private

Definition at line 36 of file ZMuMuUserData.cc.

Referenced by produce().

double ZMuMuUserData::beta_
private

Definition at line 37 of file ZMuMuUserData.cc.

int ZMuMuUserData::counter
private

Definition at line 39 of file ZMuMuUserData.cc.

Referenced by produce().

string ZMuMuUserData::hltPath_
private

Definition at line 38 of file ZMuMuUserData.cc.

InputTag ZMuMuUserData::primaryVertices_
private

Definition at line 36 of file ZMuMuUserData.cc.

Referenced by produce().

InputTag ZMuMuUserData::src_
private

Definition at line 36 of file ZMuMuUserData.cc.

Referenced by produce().

InputTag ZMuMuUserData::zGenParticlesMatch_
private

Definition at line 36 of file ZMuMuUserData.cc.

Referenced by produce().