CMS 3D CMS Logo

ZMuMuOneTrackUserData.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  if (!evt.getByToken(beamSpotToken_, beamSpotHandle)) {
63  std::cout << ">>> No beam spot found !!!" << std::endl;
64  }
65 
66  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
68  std::cout << ">>> No primary vertices found !!!" << std::endl;
69  }
70 
71  bool isMCMatchTrue = false;
72 
75  isMCMatchTrue = true;
76  }
77 
78  //cout<<"isMCMatchTrue"<<isMCMatchTrue <<endl;
79  unique_ptr<vector<pat::CompositeCandidate> > dimuonColl(new vector<pat::CompositeCandidate>());
80 
81  for (unsigned int i = 0; i < dimuons->size(); ++i) {
82  const CompositeCandidate &z = (*dimuons)[i];
83  //CandidateBaseRef zRef = dimuons ->refAt(i);
85  pat::CompositeCandidate dimuon(z);
86 
87  float trueMass, truePt, trueEta, truePhi, trueY;
88  if (isMCMatchTrue) {
89  GenParticleRef trueZRef = (*zGenParticlesMatch)[zRef];
90  //CandidateRef trueZRef = trueZIter->val;
91  if (trueZRef.isNonnull()) {
92  const Candidate &z = *trueZRef;
93  trueMass = z.mass();
94  truePt = z.pt();
95  trueEta = z.eta();
96  truePhi = z.phi();
97  trueY = z.rapidity();
98  } else {
99  trueMass = -100;
100  truePt = -100;
101  trueEta = -100;
102  truePhi = -100;
103  trueY = -100;
104  }
105 
106  dimuon.addUserFloat("TrueMass", trueMass);
107  dimuon.addUserFloat("TruePt", truePt);
108  dimuon.addUserFloat("TrueEta", trueEta);
109  dimuon.addUserFloat("TruePhi", truePhi);
110  dimuon.addUserFloat("TrueY", trueY);
111  }
112 
113  dimuonColl->push_back(dimuon);
114  }
115 
116  evt.put(std::move(dimuonColl));
117 }
118 
120 
ZMuMuUserDataOneTrack
Definition: ZMuMuOneTrackUserData.cc:29
Handle.h
CompositeCandidate.h
mps_fire.i
i
Definition: mps_fire.py:355
IsoDepositVetos.h
EDProducer.h
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::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ZMuMuUserDataOneTrack::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition: ZMuMuOneTrackUserData.cc:39
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
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
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
reco::BeamSpot
Definition: BeamSpot.h:21
DDAxes::z
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Isolation.h
IsoDeposit.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TFileService.h
edm::ParameterSet
Definition: ParameterSet.h:36
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition: zMuMuMuonUserData.py:12
Event.h
ZMuMuUserDataOneTrack::Vector
math::XYZVector Vector
Definition: ZMuMuOneTrackUserData.cc:32
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
ZMuMuUserDataOneTrack::beta_
double beta_
Definition: ZMuMuOneTrackUserData.cc:41
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
edm::Association
Definition: Association.h:18
edm::EventSetup
Definition: EventSetup.h:57
ZMuMuUserDataOneTrack::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition: ZMuMuOneTrackUserData.cc:38
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ZMuMuUserDataOneTrack::hltPath_
string hltPath_
Definition: ZMuMuOneTrackUserData.cc:42
edm::EDProducer
Definition: EDProducer.h:36
ZMuMuUserDataOneTrack::ZMuMuUserDataOneTrack
ZMuMuUserDataOneTrack(const edm::ParameterSet &)
Definition: ZMuMuOneTrackUserData.cc:46
IsoDepositFwd.h
ParameterSet.h
ZMuMuUserDataOneTrack::counter
int counter
Definition: ZMuMuOneTrackUserData.cc:43
edm::Event
Definition: Event.h:73
ZMuMuUserDataOneTrack::zGenParticlesMatchToken_
EDGetTokenT< GenParticleMatch > zGenParticlesMatchToken_
Definition: ZMuMuOneTrackUserData.cc:40
edm::InputTag
Definition: InputTag.h:15
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
ZMuMuUserDataOneTrack::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ZMuMuOneTrackUserData.cc:57
ZMuMuUserDataOneTrack::srcToken_
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_
Definition: ZMuMuOneTrackUserData.cc:37