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()) {
206 std::ostringstream
ss;
209 ss <<
"( " <<
vertex->point3d().x() <<
" " <<
vertex->point3d().y() <<
" " <<
vertex->point3d().z() <<
" )";
211 ss <<
"( did not decay )";
214 <<
" HepMCValidationHelper found no daughters for Tau within index " <<
i <<
" and info \n" 215 << *
taus[
i] <<
" decay point " <<
ss.str()
216 <<
"\n This should not be able to happen and needs to be fixed.";
218 const HepMC::FourVector& taumom =
taus[
i]->momentum();
220 std::vector<const HepMC::GenParticle*> forIsolation;
221 std::vector<const HepMC::GenParticle*>::iterator iiso;
222 for (iiso = status1.begin(); iiso < status1.end(); ++iiso) {
224 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
225 for (iremove = taudaughters.begin(); iremove != taudaughters.end(); ++iremove) {
226 if ((*iiso)->barcode() == (*iremove)->barcode()) {
227 #ifdef DEBUG_HepMCValidationHelper 235 forIsolation.push_back(*iiso);
239 for (iiso = forIsolation.begin(); iiso < forIsolation.end(); ++iiso) {
240 if (
deltaR(taumom, (*iiso)->momentum()) < deltaRcut) {
241 sumIso += (*iiso)->momentum().perp();
245 if (sumIso < sumPtCut) {
246 #ifdef DEBUG_HepMCValidationHelper 247 std::cout <<
"particle " << *
taus[
i] <<
" is considered isolated, with sumPt " << sumIso << std::endl;
249 toRemove.insert(toRemove.end(), taudaughters.begin(), taudaughters.end());
255 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
257 std::vector<const HepMC::GenParticle*>::const_iterator iremove;
258 for (iremove = toRemove.begin(); iremove != toRemove.end(); ++iremove) {
259 if (status1[
i]->barcode() == (*iremove)->barcode()) {
265 pruned.push_back(status1[
i]);
268 #ifdef DEBUG_HepMCValidationHelper 269 std::cout <<
"list of remaining particles:" << std::endl;
270 for (
unsigned int i = 0;
i < pruned.size(); ++
i) {
278 std::vector<const HepMC::GenParticle*> status1;
281 for (
unsigned int i = 0;
i < status1.size(); ++
i) {
283 visible.push_back(status1[
i]);
289 std::vector<const HepMC::GenParticle*> visible;
291 TLorentzVector momsum(0., 0., 0., 0.);
292 for (
unsigned int i = 0;
i < visible.size(); ++
i) {
293 if (visible[
i]->momentum().eta() >
etamin && visible[
i]->momentum().eta() <
etamax) {
294 TLorentzVector mom(visible[
i]->momentum().
x(),
295 visible[
i]->momentum().y(),
296 visible[
i]->momentum().z(),
297 visible[
i]->momentum().
t());
301 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)