6 #include "TLorentzVector.h"
14 std::vector<const HepMC::GenParticle*>& fsrphotons) {
15 std::vector<const HepMC::GenParticle*> status1;
21 const std::vector<const HepMC::GenParticle*>&
all,
23 std::vector<const HepMC::GenParticle*>& fsrphotons) {
25 std::vector<const HepMC::GenParticle*> allphotons;
26 for (
unsigned int i = 0;
i <
all.size(); ++
i) {
28 allphotons.push_back(
all[
i]);
32 for (
unsigned int ipho = 0; ipho < allphotons.size(); ++ipho) {
34 for (
unsigned int ilep = 0; ilep <
leptons.size(); ++ilep) {
35 if (
deltaR(allphotons[ipho]->momentum(),
leptons[ilep]->momentum()) < deltaRcut) {
41 fsrphotons.push_back(allphotons[ipho]);
73 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
74 if ((*iter)->status() == 1)
75 status1.push_back(*iter);
80 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
81 if ((*iter)->status() == 2)
82 status1.push_back(*iter);
87 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
88 if ((*iter)->status() == 3)
89 status1.push_back(*iter);
94 HepMC::GenVertex* decayVertex =
a->end_vertex();
97 HepMC::GenVertex::particles_out_const_iterator ipart;
98 for (ipart = decayVertex->particles_out_const_begin(); ipart != decayVertex->particles_out_const_end(); ++ipart) {
99 if ((*ipart)->status() == 1)
100 descendents.push_back(*ipart);
109 std::vector<const HepMC::GenParticle*>& pruned) {
111 std::vector<const HepMC::GenParticle*> status1;
113 std::vector<const HepMC::GenParticle*> toRemove;
115 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
120 std::vector<const HepMC::GenParticle*>
leptons;
122 std::vector<const HepMC::GenParticle*> removedForIsolation;
123 removedForIsolation.push_back(status1[
i]);
126 #ifdef DEBUG_HepMCValidationHelper
130 std::vector<const HepMC::GenParticle*> forIsolation;
131 std::vector<const HepMC::GenParticle*>::iterator iiso;
132 for (iiso = status1.begin(); iiso != status1.end(); ++iiso) {
133 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
135 for (iremove = removedForIsolation.begin(); iremove != removedForIsolation.end(); ++iremove) {
136 if ((*iiso)->barcode() == (*iremove)->barcode()) {
137 #ifdef DEBUG_HepMCValidationHelper
145 forIsolation.push_back(*iiso);
149 for (iiso = forIsolation.begin(); iiso < forIsolation.end(); ++iiso) {
150 if (
deltaR(
leptons.front()->momentum(), (*iiso)->momentum()) < deltaRcut) {
151 sumIso += (*iiso)->momentum().perp();
155 if (sumIso < sumPtCut) {
156 #ifdef DEBUG_HepMCValidationHelper
157 std::cout <<
"particle " << *status1[
i] <<
" is considered isolated, with sumPt " << sumIso << std::endl;
159 toRemove.insert(toRemove.end(), removedForIsolation.begin(), removedForIsolation.end());
161 #ifdef DEBUG_HepMCValidationHelper
163 std::cout <<
"NOT isolated! " << *status1[
i] <<
" is considered not isolated, with sumPt " << sumIso
171 std::vector<const HepMC::GenParticle*> status2;
173 std::vector<const HepMC::GenParticle*>
taus;
175 for (
unsigned int i = 0;
i < status2.size(); ++
i) {
179 bool duplicate =
false;
180 TLorentzVector taumomentum(status2[
i]->momentum().x(),
181 status2[
i]->momentum().y(),
182 status2[
i]->momentum().z(),
183 status2[
i]->momentum().
t());
184 for (
unsigned int j = 0;
j <
taus.size(); ++
j) {
186 TLorentzVector othermomentum(
188 othermomentum -= taumomentum;
190 othermomentum.E() < 0.1 &&
191 othermomentum.P() < 0.1) {
197 taus.push_back(status2[
i]);
201 for (
unsigned int i = 0;
i <
taus.size(); ++
i) {
202 std::vector<const HepMC::GenParticle*> taudaughters;
204 if (taudaughters.empty()) {
205 edm::LogError(
"HepMCValidationHelper") <<
"Tau with no daughters. This is a bug. Fix it";
208 const HepMC::FourVector& taumom =
taus[
i]->momentum();
210 std::vector<const HepMC::GenParticle*> forIsolation;
211 std::vector<const HepMC::GenParticle*>::iterator iiso;
212 for (iiso = status1.begin(); iiso < status1.end(); ++iiso) {
214 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
215 for (iremove = taudaughters.begin(); iremove != taudaughters.end(); ++iremove) {
216 if ((*iiso)->barcode() == (*iremove)->barcode()) {
217 #ifdef DEBUG_HepMCValidationHelper
225 forIsolation.push_back(*iiso);
229 for (iiso = forIsolation.begin(); iiso < forIsolation.end(); ++iiso) {
230 if (
deltaR(taumom, (*iiso)->momentum()) < deltaRcut) {
231 sumIso += (*iiso)->momentum().perp();
235 if (sumIso < sumPtCut) {
236 #ifdef DEBUG_HepMCValidationHelper
237 std::cout <<
"particle " << *
taus[
i] <<
" is considered isolated, with sumPt " << sumIso << std::endl;
239 toRemove.insert(toRemove.end(), taudaughters.begin(), taudaughters.end());
245 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
247 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
248 for (iremove = toRemove.begin(); iremove != toRemove.end(); ++iremove) {
249 if (status1[
i]->barcode() == (*iremove)->barcode()) {
255 pruned.push_back(status1[
i]);
258 #ifdef DEBUG_HepMCValidationHelper
259 std::cout <<
"list of remaining particles:" << std::endl;
260 for (
unsigned int i = 0;
i < pruned.size(); ++
i) {
268 std::vector<const HepMC::GenParticle*> status1;
271 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
273 visible.push_back(status1[
i]);
279 std::vector<const HepMC::GenParticle*> visible;
281 TLorentzVector momsum(0., 0., 0., 0.);
282 for (
unsigned int i = 0;
i < visible.size(); ++
i) {
283 if (visible[
i]->momentum().eta() >
etamin && visible[
i]->momentum().eta() <
etamax) {
284 TLorentzVector mom(visible[
i]->momentum().x(),
285 visible[
i]->momentum().y(),
286 visible[
i]->momentum().z(),
287 visible[
i]->momentum().
t());
291 TLorentzVector
met(-momsum.Px(), -momsum.Py(), 0., momsum.Pt());