7 #include "TLorentzVector.h" 15 std::vector<const HepMC::GenParticle*>& fsrphotons) {
16 std::vector<const HepMC::GenParticle*> status1;
22 const std::vector<const HepMC::GenParticle*>&
all,
24 std::vector<const HepMC::GenParticle*>& fsrphotons) {
26 std::vector<const HepMC::GenParticle*> allphotons;
27 for (
unsigned int i = 0;
i <
all.size(); ++
i) {
29 allphotons.push_back(
all[
i]);
33 for (
unsigned int ipho = 0; ipho < allphotons.size(); ++ipho) {
35 for (
unsigned int ilep = 0; ilep <
leptons.size(); ++ilep) {
36 if (
deltaR(allphotons[ipho]->momentum(),
leptons[ilep]->momentum()) < deltaRcut) {
42 fsrphotons.push_back(allphotons[ipho]);
74 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
75 if ((*iter)->status() == 1)
76 status1.push_back(*iter);
81 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
82 if ((*iter)->status() == 2)
83 status1.push_back(*iter);
88 for (HepMC::GenEvent::particle_const_iterator iter =
all->particles_begin(); iter !=
all->particles_end(); ++iter) {
89 if ((*iter)->status() == 3)
90 status1.push_back(*iter);
95 HepMC::GenVertex* decayVertex =
a->end_vertex();
98 HepMC::GenVertex::particles_out_const_iterator ipart;
99 for (ipart = decayVertex->particles_out_const_begin(); ipart != decayVertex->particles_out_const_end(); ++ipart) {
100 if ((*ipart)->status() == 1)
101 descendents.push_back(*ipart);
110 std::vector<const HepMC::GenParticle*>& pruned) {
112 std::vector<const HepMC::GenParticle*> status1;
114 std::vector<const HepMC::GenParticle*> toRemove;
116 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
121 std::vector<const HepMC::GenParticle*>
leptons;
123 std::vector<const HepMC::GenParticle*> removedForIsolation;
124 removedForIsolation.push_back(status1[
i]);
127 #ifdef DEBUG_HepMCValidationHelper 131 std::vector<const HepMC::GenParticle*> forIsolation;
132 std::vector<const HepMC::GenParticle*>::iterator iiso;
133 for (iiso = status1.begin(); iiso != status1.end(); ++iiso) {
134 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
136 for (iremove = removedForIsolation.begin(); iremove != removedForIsolation.end(); ++iremove) {
137 if ((*iiso)->barcode() == (*iremove)->barcode()) {
138 #ifdef DEBUG_HepMCValidationHelper 146 forIsolation.push_back(*iiso);
150 for (iiso = forIsolation.begin(); iiso < forIsolation.end(); ++iiso) {
151 if (
deltaR(
leptons.front()->momentum(), (*iiso)->momentum()) < deltaRcut) {
152 sumIso += (*iiso)->momentum().perp();
156 if (sumIso < sumPtCut) {
157 #ifdef DEBUG_HepMCValidationHelper 158 std::cout <<
"particle " << *status1[
i] <<
" is considered isolated, with sumPt " << sumIso << std::endl;
160 toRemove.insert(toRemove.end(), removedForIsolation.begin(), removedForIsolation.end());
162 #ifdef DEBUG_HepMCValidationHelper 164 std::cout <<
"NOT isolated! " << *status1[
i] <<
" is considered not isolated, with sumPt " << sumIso
172 std::vector<const HepMC::GenParticle*> status2;
174 std::vector<const HepMC::GenParticle*>
taus;
176 for (
unsigned int i = 0;
i < status2.size(); ++
i) {
180 bool duplicate =
false;
181 TLorentzVector taumomentum(status2[
i]->momentum().
x(),
182 status2[
i]->momentum().y(),
183 status2[
i]->momentum().z(),
184 status2[
i]->momentum().
t());
185 for (
unsigned int j = 0;
j <
taus.size(); ++
j) {
187 TLorentzVector othermomentum(
189 othermomentum -= taumomentum;
191 othermomentum.E() < 0.1 &&
192 othermomentum.P() < 0.1) {
198 taus.push_back(status2[
i]);
202 for (
unsigned int i = 0;
i <
taus.size(); ++
i) {
203 std::vector<const HepMC::GenParticle*> taudaughters;
205 if (taudaughters.empty()) {
207 <<
" HepMCValidationHelper found no daughters for Tau within index " <<
i <<
" and info \n" 208 << *
taus[
i] <<
"\n This should not be able to happen and needs to be fixed.";
210 const HepMC::FourVector& taumom =
taus[
i]->momentum();
212 std::vector<const HepMC::GenParticle*> forIsolation;
213 std::vector<const HepMC::GenParticle*>::iterator iiso;
214 for (iiso = status1.begin(); iiso < status1.end(); ++iiso) {
216 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
217 for (iremove = taudaughters.begin(); iremove != taudaughters.end(); ++iremove) {
218 if ((*iiso)->barcode() == (*iremove)->barcode()) {
219 #ifdef DEBUG_HepMCValidationHelper 227 forIsolation.push_back(*iiso);
231 for (iiso = forIsolation.begin(); iiso < forIsolation.end(); ++iiso) {
232 if (
deltaR(taumom, (*iiso)->momentum()) < deltaRcut) {
233 sumIso += (*iiso)->momentum().perp();
237 if (sumIso < sumPtCut) {
238 #ifdef DEBUG_HepMCValidationHelper 239 std::cout <<
"particle " << *
taus[
i] <<
" is considered isolated, with sumPt " << sumIso << std::endl;
241 toRemove.insert(toRemove.end(), taudaughters.begin(), taudaughters.end());
247 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
249 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
250 for (iremove = toRemove.begin(); iremove != toRemove.end(); ++iremove) {
251 if (status1[
i]->barcode() == (*iremove)->barcode()) {
257 pruned.push_back(status1[
i]);
260 #ifdef DEBUG_HepMCValidationHelper 261 std::cout <<
"list of remaining particles:" << std::endl;
262 for (
unsigned int i = 0;
i < pruned.size(); ++
i) {
270 std::vector<const HepMC::GenParticle*> status1;
273 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
275 visible.push_back(status1[
i]);
281 std::vector<const HepMC::GenParticle*> visible;
283 TLorentzVector momsum(0., 0., 0., 0.);
284 for (
unsigned int i = 0;
i < visible.size(); ++
i) {
285 if (visible[
i]->momentum().eta() >
etamin && visible[
i]->momentum().eta() <
etamax) {
286 TLorentzVector mom(visible[
i]->momentum().
x(),
287 visible[
i]->momentum().y(),
288 visible[
i]->momentum().z(),
289 visible[
i]->momentum().
t());
293 TLorentzVector
met(-momsum.Px(), -momsum.Py(), 0., momsum.Pt());
bool isTau(const HepMC::GenParticle *part)
void removeIsolatedLeptons(const HepMC::GenEvent *all, double deltaR, double sumPt, std::vector< const HepMC::GenParticle *> &pruned)
bool isChargedLepton(const HepMC::GenParticle *part)
void findFSRPhotons(const std::vector< const HepMC::GenParticle *> &leptons, const std::vector< const HepMC::GenParticle *> &all, double deltaR, std::vector< const HepMC::GenParticle *> &photons)
void findDescendents(const HepMC::GenParticle *a, std::vector< const HepMC::GenParticle *> &descendents)
void allVisibleParticles(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &visible)
Abs< T >::type abs(const T &t)
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
void allStatus3(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status3)
bool isNeutrino(const HepMC::GenParticle *part)
void allStatus1(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status1)
void allStatus2(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status2)