26 #include <CLHEP/Vector/LorentzVector.h> 36 outputFile =
new TFile(theGenInfoRootFileName.c_str(),
"RECREATE");
51 std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> muFromRes;
54 int mothersFound[] = {0, 0, 0, 0, 0, 0};
56 for (reco::GenParticleCollection::const_iterator mcIter = genParticles.begin(); mcIter != genParticles.end();
58 int status = mcIter->status();
62 (pdgId == 23 || pdgId == 443 || pdgId == 100443 || pdgId == 553 || pdgId == 100553 || pdgId == 200553)) {
63 genRes = mcIter->p4();
67 else if (pdgId == 443 || pdgId == 100443)
68 mapHisto[
"hGenResJPsi"]->Fill(genRes);
69 else if (pdgId == 553 || pdgId == 100553 || pdgId == 200553)
70 mapHisto[
"hGenResUpsilon1S"]->Fill(genRes);
73 if (status == 1 && pdgId == 13 && !PATmuons) {
74 int momPdgId =
std::abs(mcIter->mother()->pdgId());
75 if (momPdgId == 23 || momPdgId == 443 || momPdgId == 100443 || momPdgId == 553 || momPdgId == 100553 ||
79 if (momPdgId == 443 || momPdgId == 100443)
81 if (momPdgId == 553 || momPdgId == 100553 || momPdgId == 200553)
83 mapHisto[
"hGenMu"]->Fill(mcIter->p4());
84 std::cout <<
"genmu " << mcIter->p4() << std::endl;
85 if (mcIter->charge() > 0) {
86 muFromRes.first = mcIter->p4();
89 muFromRes.second = mcIter->p4();
92 if (status == 1 && pdgId == 13 && PATmuons) {
94 mapHisto[
"hGenMu"]->Fill(mcIter->p4());
95 std::cout <<
"genmu " << mcIter->p4() << std::endl;
96 if (mcIter->charge() > 0) {
97 muFromRes.first = mcIter->p4();
100 muFromRes.second = mcIter->p4();
106 if (mothersFound[0] == 1) {
107 mapHisto[
"hGenMuMuZ"]->Fill(muFromRes.first + muFromRes.second);
108 mapHisto[
"hGenResVSMuZ"]->Fill(muFromRes.first, genRes, 1);
109 mapHisto[
"hGenResVSMuZ"]->Fill(muFromRes.second, genRes, -1);
111 if (mothersFound[3] == 1) {
112 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(muFromRes.first + muFromRes.second);
113 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(muFromRes.first, genRes, 1);
114 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(muFromRes.second, genRes, -1);
116 if (mothersFound[5] == 1) {
117 mapHisto[
"hGenMuMuJPsi"]->Fill(muFromRes.first + muFromRes.second);
118 mapHisto[
"hGenResVSMuJPsi"]->Fill(muFromRes.first, genRes, 1);
119 mapHisto[
"hGenResVSMuJPsi"]->Fill(muFromRes.second, genRes, -1);
122 mapHisto[
"hGenResVsSelf"]->Fill(genRes, genRes, 1);
130 std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> muFromRes;
133 int mothersFound[] = {0, 0, 0, 0, 0, 0};
136 for (HepMC::GenEvent::particle_const_iterator
part = Evt->particles_begin();
part != Evt->particles_end();
part++) {
137 if (
std::abs((*part)->pdg_id()) == 13 && (*part)->status() == 1) {
138 bool fromRes =
false;
139 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(
141 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors);
143 unsigned int motherPdgId = (*mother)->pdg_id();
144 if (motherPdgId == 13 && (*mother)->status() == 3)
148 if ((*part)->pdg_id() == 13) {
150 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
151 }
else if ((*part)->pdg_id() == -13) {
153 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
158 mapHisto[
"hGenResZ"]->Fill(muFromRes.first + muFromRes.second);
160 for (HepMC::GenEvent::particle_const_iterator
part = Evt->particles_begin();
part != Evt->particles_end();
part++) {
161 int status = (*part)->status();
169 if (pdgId == 13 && status == 1) {
171 (pdgId == 23 || pdgId == 443 || pdgId == 100443 || pdgId == 553 || pdgId == 100553 || pdgId == 200553)) {
173 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e());
178 mapHisto[
"hGenResJPsi"]->Fill(genRes);
181 mapHisto[
"hGenResUpsilon1S"]->Fill(genRes);
186 if (pdgId == 13 && status == 1) {
187 bool fromRes =
false;
188 for (HepMC::GenVertex::particle_iterator mother =
189 (*part)->production_vertex()->particles_begin(HepMC::ancestors);
190 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors);
192 int motherPdgId = (*mother)->pdg_id();
193 if (motherPdgId == 23 || motherPdgId == 443 || motherPdgId == 100443 || motherPdgId == 553 ||
194 motherPdgId == 100553 || motherPdgId == 200553) {
196 if (motherPdgId == 23)
198 if (motherPdgId == 443)
200 if (motherPdgId == 553)
207 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
209 (*part)->momentum().px(), (*part)->momentum().py(), (*part)->momentum().pz(), (*part)->momentum().e()));
210 if ((*part)->pdg_id() == -13)
212 (*part)->momentum().py(),
213 (*part)->momentum().pz(),
214 (*part)->momentum().e()));
217 (*part)->momentum().py(),
218 (*part)->momentum().pz(),
219 (*part)->momentum().e()));
225 if (mothersFound[0] == 1) {
226 mapHisto[
"hGenMuMuZ"]->Fill(muFromRes.first + muFromRes.second);
227 mapHisto[
"hGenResVSMuZ"]->Fill(muFromRes.first, genRes, 1);
228 mapHisto[
"hGenResVSMuZ"]->Fill(muFromRes.second, genRes, -1);
230 if (mothersFound[3] == 1) {
231 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(muFromRes.first + muFromRes.second);
232 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(muFromRes.first, genRes, 1);
233 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(muFromRes.second, genRes, -1);
235 if (mothersFound[5] == 1) {
236 mapHisto[
"hGenMuMuJPsi"]->Fill(muFromRes.first + muFromRes.second);
237 mapHisto[
"hGenResVSMuJPsi"]->Fill(muFromRes.first, genRes, 1);
238 mapHisto[
"hGenResVSMuJPsi"]->Fill(muFromRes.second, genRes, -1);
240 mapHisto[
"hGenResVsSelf"]->Fill(genRes, genRes, 1);
246 std::vector<SimTrack> simMuons;
249 for (edm::SimTrackContainer::const_iterator
simTrack = simTracks->begin();
simTrack != simTracks->end(); ++
simTrack) {
251 if (
std::abs((*simTrack).type()) == 13) {
253 mapHisto[
"hSimMu"]->Fill((*simTrack).momentum());
256 mapHisto[
"hSimMu"]->Fill(simMuons.size());
259 if (simMuons.size() >= 2) {
260 for (std::vector<SimTrack>::const_iterator imu = simMuons.begin(); imu != simMuons.end(); ++imu) {
261 for (std::vector<SimTrack>::const_iterator imu2 = imu + 1; imu2 != simMuons.end(); ++imu2) {
266 if (((*imu).charge() * (*imu2).charge()) < 0) {
276 mapHisto[
"hSimBestRes"]->Fill(bestSimZ);
277 if (
std::abs(simMuFromBestRes.first.momentum().eta()) < 2.5 &&
278 std::abs(simMuFromBestRes.second.momentum().eta()) < 2.5 && simMuFromBestRes.first.momentum().pt() > 2.5 &&
279 simMuFromBestRes.second.momentum().pt() > 2.5) {
281 simMuFromBestRes.first.momentum(), bestSimZ,
int(simMuFromBestRes.first.charge()));
283 simMuFromBestRes.second.momentum(), bestSimZ,
int(simMuFromBestRes.second.charge()));
291 std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> simMuFromRes =
295 mapHisto[
"hSimRightRes"]->Fill(rightSimRes);
320 for (std::vector<MuScleFitMuon>::const_iterator mu1 = muons.begin(); mu1 != muons.end(); mu1++) {
321 mapHisto[
"hRecMu"]->Fill(mu1->p4());
322 mapHisto[
"hRecMuVSEta"]->Fill(mu1->p4());
323 for (std::vector<MuScleFitMuon>::const_iterator mu2 = muons.begin(); mu2 != muons.end(); mu2++) {
324 if (mu1->charge() < 0 || mu2->charge() > 0)
330 mapHisto[
"hRecMu"]->Fill(muons.size());
335 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& savedPairs) {
336 std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >::const_iterator muonPair =
338 for (; muonPair != savedPairs.end(); ++muonPair) {
339 mapHisto[
"hRecMu"]->Fill(muonPair->first);
340 mapHisto[
"hRecMuVSEta"]->Fill(muonPair->first);
341 mapHisto[
"hRecMu"]->Fill(muonPair->second);
342 mapHisto[
"hRecMuVSEta"]->Fill(muonPair->second);
345 mapHisto[
"hRecMu"]->Fill(savedPairs.size());
355 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& genPairs) {
356 std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >::const_iterator genPair =
358 for (; genPair != genPairs.end(); ++genPair) {
361 mapHisto[
"hGenMu"]->Fill(genPair->first);
362 mapHisto[
"hGenMuVSEta"]->Fill(genPair->first);
363 mapHisto[
"hGenMuMuZ"]->Fill(genRes);
364 mapHisto[
"hGenResVSMuZ"]->Fill(genPair->first, genRes, 1);
365 mapHisto[
"hGenResVSMuZ"]->Fill(genPair->second, genRes, -1);
366 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(genRes);
367 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(genPair->first, genRes, 1);
368 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill(genPair->second, genRes, -1);
369 mapHisto[
"hGenMuMuJPsi"]->Fill(genRes);
370 mapHisto[
"hGenResVSMuJPsi"]->Fill(genPair->first, genRes, 1);
371 mapHisto[
"hGenResVSMuJPsi"]->Fill(genPair->second, genRes, -1);
372 mapHisto[
"hGenResVsSelf"]->Fill(genRes, genRes, 1);
420 (*histo).second->Write();
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::map< std::string, Histograms * > mapHisto
static std::pair< lorentzVector, lorentzVector > findSimMuFromRes(const edm::Handle< edm::HepMCProduct > &evtMC, const edm::Handle< edm::SimTrackContainer > &simTracks)
void fillGenSim(edm::Handle< edm::HepMCProduct > evtMC, edm::Handle< edm::SimTrackContainer > simTracks)
void fillTreeRec(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &savedPairs)
Used when running on the root tree containing preselected muon pairs.
virtual ~MuScleFitPlotter()
MuScleFitPlotter(std::string)
reco::Particle::LorentzVector lorentzVector
static std::pair< SimTrack, SimTrack > findBestSimuRes(const std::vector< SimTrack > &simMuons)
void fillRec(std::vector< MuScleFitMuon > &muons)
Used when running on the root tree containing preselected muon pairs.
void fillSim(edm::Handle< edm::SimTrackContainer > simTracks)
Abs< T >::type abs(const T &t)
const HepMC::GenEvent * GetEvent() const
void fillTreeGen(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &genPairs)
void fillGen(const reco::GenParticleCollection &genParticles, bool=false)
math::XYZTLorentzVector LorentzVector
Lorentz vector.