CMS 3D CMS Logo

ZMuMuUserData.cc
Go to the documentation of this file.
10 
16 
20 
21 #include <vector>
22 
23 using namespace edm;
24 using namespace std;
25 using namespace reco;
26 using namespace isodeposit;
27 //using namespace pat;
28 
30 public:
33 
34 private:
35  void produce(edm::Event &, const edm::EventSetup &) override;
36 
41  double alpha_, beta_;
42  string hltPath_;
43  int counter;
44 };
45 
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 }
56 
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 }
166 
168 
counter
Definition: counter.py:1
Handle.h
CompositeCandidate.h
mps_fire.i
i
Definition: mps_fire.py:355
IsoDepositVetos.h
EDProducer.h
ZMuMuUserData::beta_
double beta_
Definition: ZMuMuUserData.cc:41
ZMuMuUserData::Vector
math::XYZVector Vector
Definition: ZMuMuUserData.cc:32
reco::Candidate::mass
virtual double mass() const =0
mass
edm::EDGetTokenT
Definition: EDGetToken.h:33
pat::CompositeCandidate
Analysis-level particle class.
Definition: CompositeCandidate.h:31
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
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
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
edm::Handle
Definition: AssociativeIterator.h:50
IsoDepositDirection.h
edm::Ref
Definition: AssociativeIterator.h:58
EDMException.h
WZMuSkim_cff.dimuons
dimuons
Definition: WZMuSkim_cff.py:26
ZMuMuUserData
Definition: ZMuMuUserData.cc:29
MakerMacros.h
reco::StandAloneMuonTag
stand alone muon component tag
Definition: RecoCandidate.h:77
ZMuMuUserData::zGenParticlesMatchToken_
EDGetTokenT< GenParticleMatch > zGenParticlesMatchToken_
Definition: ZMuMuUserData.cc:40
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
reco::BeamSpot
Definition: BeamSpot.h:21
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:528
Isolation.h
IsoDeposit.h
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TFileService.h
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
edm::ParameterSet
Definition: ParameterSet.h:36
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition: zMuMuMuonUserData.py:12
Event.h
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::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
ZMuMuUserData::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ZMuMuUserData.cc:57
pat::PATObject::addUserFloat
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:897
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
ZMuMuUserData::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition: ZMuMuUserData.cc:38
edm::Association
Definition: Association.h:18
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
VertexFwd.h
mu_mass
static constexpr float mu_mass
Definition: L1TkMuonProducer.cc:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ZMuMuUserData::ZMuMuUserData
ZMuMuUserData(const edm::ParameterSet &)
Definition: ZMuMuUserData.cc:46
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::EDProducer
Definition: EDProducer.h:36
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
ZMuMuUserData::srcToken_
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_
Definition: ZMuMuUserData.cc:37
IsoDepositFwd.h
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
ZMuMuUserData::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition: ZMuMuUserData.cc:39