CMS 3D CMS Logo

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 ZMuMuUserData (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

double alpha_
 
EDGetTokenT< BeamSpotbeamSpotToken_
 
double beta_
 
int counter
 
string hltPath_
 
EDGetTokenT< VertexCollectionprimaryVerticesToken_
 
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_
 
EDGetTokenT< GenParticleMatchzGenParticlesMatchToken_
 

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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 49 of file ZMuMuUserData.cc.

49  :
50  srcToken_(consumes<std::vector<reco::CompositeCandidate> > ( cfg.getParameter<InputTag>( "src" ) ) ),
51  beamSpotToken_(consumes<BeamSpot> (cfg.getParameter<InputTag>( "beamSpot" ) ) ),
52  primaryVerticesToken_(consumes<VertexCollection> (cfg.getParameter<InputTag>( "primaryVertices" ) ) ),
53  zGenParticlesMatchToken_(consumes<GenParticleMatch> (cfg.getParameter<InputTag>( "zGenParticlesMatch" ) ) ),
54  alpha_(cfg.getParameter<double>("alpha") ),
55  beta_(cfg.getParameter<double>("beta") ),
56  hltPath_(cfg.getParameter<std::string >("hltPath") ){
57  produces<vector<pat::CompositeCandidate> >();
58 }
T getParameter(std::string const &) const
EDGetTokenT< BeamSpot > beamSpotToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
EDGetTokenT< GenParticleMatch > zGenParticlesMatchToken_
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_

Member Function Documentation

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

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

Definition at line 60 of file ZMuMuUserData.cc.

References pat::PATObject< ObjectType >::addUserFloat(), beamSpotToken_, counter, reco::CompositeCandidate::daughter(), DEFINE_FWK_MODULE, reco::Candidate::eta(), reco::Candidate::get(), edm::Event::getByToken(), mps_fire::i, reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), ResonanceBuilder::mass, reco::Candidate::mass(), reco::Candidate::masterClone(), eostools::move(), reco::Candidate::phi(), reco::Candidate::polarP4(), jets_cff::primaryVertices, primaryVerticesToken_, reco::Candidate::pt(), edm::Event::put(), reco::Candidate::rapidity(), srcToken_, z, and zGenParticlesMatchToken_.

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

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

Member Data Documentation

double ZMuMuUserData::alpha_
private

Definition at line 40 of file ZMuMuUserData.cc.

EDGetTokenT<BeamSpot> ZMuMuUserData::beamSpotToken_
private

Definition at line 37 of file ZMuMuUserData.cc.

Referenced by produce().

double ZMuMuUserData::beta_
private

Definition at line 40 of file ZMuMuUserData.cc.

int ZMuMuUserData::counter
private

Definition at line 42 of file ZMuMuUserData.cc.

Referenced by counter.Counters::__getitem__(), and produce().

string ZMuMuUserData::hltPath_
private

Definition at line 41 of file ZMuMuUserData.cc.

EDGetTokenT<VertexCollection> ZMuMuUserData::primaryVerticesToken_
private

Definition at line 38 of file ZMuMuUserData.cc.

Referenced by produce().

EDGetTokenT<std::vector<reco::CompositeCandidate> > ZMuMuUserData::srcToken_
private

Definition at line 36 of file ZMuMuUserData.cc.

Referenced by produce().

EDGetTokenT<GenParticleMatch> ZMuMuUserData::zGenParticlesMatchToken_
private

Definition at line 39 of file ZMuMuUserData.cc.

Referenced by produce().