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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file ZMuMuUserData.cc.

Member Typedef Documentation

◆ Vector

Definition at line 32 of file ZMuMuUserData.cc.

Constructor & Destructor Documentation

◆ ZMuMuUserData()

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

Definition at line 46 of file ZMuMuUserData.cc.

47  : srcToken_(consumes<std::vector<reco::CompositeCandidate> >(cfg.getParameter<InputTag>("src"))),
48  beamSpotToken_(consumes<BeamSpot>(cfg.getParameter<InputTag>("beamSpot"))),
49  primaryVerticesToken_(consumes<VertexCollection>(cfg.getParameter<InputTag>("primaryVertices"))),
50  zGenParticlesMatchToken_(consumes<GenParticleMatch>(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 }

Member Function Documentation

◆ produce()

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.

57  {
60 
61  Handle<BeamSpot> beamSpotHandle;
62  evt.getByToken(beamSpotToken_, beamSpotHandle);
63 
64  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
66 
67  bool isMCMatchTrue = false;
68 
71  isMCMatchTrue = true;
72  }
73 
74  //cout<<"isMCMatchTrue"<<isMCMatchTrue <<endl;
75  unique_ptr<vector<pat::CompositeCandidate> > dimuonColl(new vector<pat::CompositeCandidate>());
76 
77  for (unsigned int i = 0; i < dimuons->size(); ++i) {
78  const CompositeCandidate &z = (*dimuons)[i];
79  //CandidateBaseRef zRef = dimuons ->refAt(i);
81  pat::CompositeCandidate dimuon(z);
82 
83  float trueMass, truePt, trueEta, truePhi, trueY;
84  if (isMCMatchTrue) {
85  GenParticleRef trueZRef = (*zGenParticlesMatch)[zRef];
86  //CandidateRef trueZRef = trueZIter->val;
87  if (trueZRef.isNonnull()) {
88  const Candidate &z = *trueZRef;
89  trueMass = z.mass();
90  truePt = z.pt();
91  trueEta = z.eta();
92  truePhi = z.phi();
93  trueY = z.rapidity();
94  } else {
95  trueMass = -100;
96  truePt = -100;
97  trueEta = -100;
98  truePhi = -100;
99  trueY = -100;
100  }
101 
102  dimuon.addUserFloat("TrueMass", trueMass);
103  dimuon.addUserFloat("TruePt", truePt);
104  dimuon.addUserFloat("TrueEta", trueEta);
105  dimuon.addUserFloat("TruePhi", truePhi);
106  dimuon.addUserFloat("TrueY", trueY);
107  }
108  const Candidate *dau1 = z.daughter(0);
109  const Candidate *dau2 = z.daughter(1);
110  const pat::Muon &mu1 = dynamic_cast<const pat::Muon &>(*dau1->masterClone());
111  const pat::Muon &mu2 = dynamic_cast<const pat::Muon &>(*dau2->masterClone());
112 
113  /*cout<<"mu1 is null? "<<mu1.isMuon()<<endl;
114  cout<<"mu2 is null? "<<mu2.isMuon()<<endl;
115  cout<<"mu1 is global?"<<mu1.isGlobalMuon()<<endl;
116  cout<<"mu2 is global?"<<mu2.isGlobalMuon()<<endl;
117  */
118 
119  if (mu1.isGlobalMuon() == true && mu2.isGlobalMuon() == true) {
120  TrackRef stAloneTrack1;
121  TrackRef stAloneTrack2;
122  Vector momentum;
124  double mu_mass;
125  stAloneTrack1 = dau1->get<TrackRef, reco::StandAloneMuonTag>();
126  stAloneTrack2 = dau2->get<TrackRef, reco::StandAloneMuonTag>();
127  float zDau1SaEta = stAloneTrack1->eta();
128  float zDau2SaEta = stAloneTrack2->eta();
129  float zDau1SaPhi = stAloneTrack1->phi();
130  float zDau2SaPhi = stAloneTrack2->phi();
131  float zDau1SaPt, zDau2SaPt;
132  if (counter % 2 == 0) {
133  momentum = stAloneTrack1->momentum();
134  p4_1 = dau2->polarP4();
135  mu_mass = dau1->mass();
137  zDau1SaPt = stAloneTrack1->pt();
138  zDau2SaPt = -stAloneTrack2->pt();
139  } else {
140  momentum = stAloneTrack2->momentum();
141  p4_1 = dau1->polarP4();
142  mu_mass = dau2->mass();
144  zDau1SaPt = -stAloneTrack1->pt();
145  zDau2SaPt = stAloneTrack2->pt();
146  }
147 
148  Candidate::PolarLorentzVector p4_2(momentum.rho(), momentum.eta(), momentum.phi(), mu_mass);
149  double mass = (p4_1 + p4_2).mass();
150  float zMassSa = mass;
151  //cout<<"zMassSa "<<zMassSa;
152  dimuon.addUserFloat("MassSa", zMassSa);
153  dimuon.addUserFloat("Dau1SaPt", zDau1SaPt);
154  dimuon.addUserFloat("Dau2SaPt", zDau2SaPt);
155  dimuon.addUserFloat("Dau1SaPhi", zDau1SaPhi);
156  dimuon.addUserFloat("Dau2SaPhi", zDau2SaPhi);
157  dimuon.addUserFloat("Dau1SaEta", zDau1SaEta);
158  dimuon.addUserFloat("Dau2SaEta", zDau2SaEta);
159  ++counter;
160  }
161  dimuonColl->push_back(dimuon);
162  }
163 
164  evt.put(std::move(dimuonColl));
165 }

References pat::PATObject< ObjectType >::addUserFloat(), beamSpotToken_, counter, WZMuSkim_cff::dimuons, reco::Candidate::get(), edm::Event::getByToken(), mps_fire::i, reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), EgHLTOffHistBins_cfi::mass, reco::Candidate::mass(), reco::Candidate::masterClone(), eostools::move(), mu_mass, reco::Candidate::polarP4(), zMuMuMuonUserData::primaryVertices, primaryVerticesToken_, edm::Event::put(), srcToken_, z, zMuMu_SubskimPathsWithMCTruth_cff::zGenParticlesMatch, and zGenParticlesMatchToken_.

Member Data Documentation

◆ alpha_

double ZMuMuUserData::alpha_
private

Definition at line 41 of file ZMuMuUserData.cc.

◆ beamSpotToken_

EDGetTokenT<BeamSpot> ZMuMuUserData::beamSpotToken_
private

Definition at line 38 of file ZMuMuUserData.cc.

Referenced by produce().

◆ beta_

double ZMuMuUserData::beta_
private

Definition at line 41 of file ZMuMuUserData.cc.

◆ counter

int ZMuMuUserData::counter
private

Definition at line 43 of file ZMuMuUserData.cc.

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

◆ hltPath_

string ZMuMuUserData::hltPath_
private

Definition at line 42 of file ZMuMuUserData.cc.

◆ primaryVerticesToken_

EDGetTokenT<VertexCollection> ZMuMuUserData::primaryVerticesToken_
private

Definition at line 39 of file ZMuMuUserData.cc.

Referenced by produce().

◆ srcToken_

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

Definition at line 37 of file ZMuMuUserData.cc.

Referenced by produce().

◆ zGenParticlesMatchToken_

EDGetTokenT<GenParticleMatch> ZMuMuUserData::zGenParticlesMatchToken_
private

Definition at line 40 of file ZMuMuUserData.cc.

Referenced by produce().

counter
Definition: counter.py:1
mps_fire.i
i
Definition: mps_fire.py:428
ZMuMuUserData::beta_
double beta_
Definition: ZMuMuUserData.cc:41
reco::Candidate::mass
virtual double mass() const =0
mass
pat::CompositeCandidate
Analysis-level particle class.
Definition: CompositeCandidate.h:31
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
ZMuMuUserData::hltPath_
string hltPath_
Definition: ZMuMuUserData.cc:42
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
ZMuMuUserData::counter
int counter
Definition: ZMuMuUserData.cc:43
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref
Definition: AssociativeIterator.h:58
WZMuSkim_cff.dimuons
dimuons
Definition: WZMuSkim_cff.py:26
reco::StandAloneMuonTag
stand alone muon component tag
Definition: RecoCandidate.h:77
ZMuMuUserData::zGenParticlesMatchToken_
EDGetTokenT< GenParticleMatch > zGenParticlesMatchToken_
Definition: ZMuMuUserData.cc:40
DDAxes::z
reco::Candidate::polarP4
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
ZMuMuUserData::alpha_
double alpha_
Definition: ZMuMuUserData.cc:41
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition: zMuMuMuonUserData.py:12
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
zMuMu_SubskimPathsWithMCTruth_cff.zGenParticlesMatch
zGenParticlesMatch
Definition: zMuMu_SubskimPathsWithMCTruth_cff.py:23
math::Vector
fixed size vector
Definition: Vector.h:24
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ZMuMuUserData::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition: ZMuMuUserData.cc:38
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
mu_mass
static constexpr float mu_mass
Definition: L1TkMuonProducer.cc:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
ZMuMuUserData::srcToken_
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_
Definition: ZMuMuUserData.cc:37
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::InputTag
Definition: InputTag.h:15
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
ZMuMuUserData::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition: ZMuMuUserData.cc:39