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) {
27 if (all[
i]->
status() == 1 && all[
i]->pdg_id() == 22)
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]);
47 int status = part->status();
48 unsigned int pdg_id =
abs(part->pdg_id());
52 return status == 1 && (pdg_id == 11 || pdg_id == 13);
57 int status = part->status();
58 unsigned int pdg_id =
abs(part->pdg_id());
59 return status == 1 && (pdg_id == 12 || pdg_id == 14 || pdg_id == 16);
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;
121 leptons.push_back(status1[i]);
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(
187 taus[j]->momentum().x(), taus[j]->momentum().y(), taus[j]->momentum().z(), taus[j]->momentum().
t());
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());
bool isTau(const HepMC::GenParticle *part)
void allStatus3(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle * > &status3)
void findFSRPhotons(const std::vector< const HepMC::GenParticle * > &leptons, const std::vector< const HepMC::GenParticle * > &all, double deltaR, std::vector< const HepMC::GenParticle * > &photons)
bool isChargedLepton(const HepMC::GenParticle *part)
void allStatus1(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle * > &status1)
void removeIsolatedLeptons(const HepMC::GenEvent *all, double deltaR, double sumPt, std::vector< const HepMC::GenParticle * > &pruned)
void allStatus2(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle * > &status2)
Abs< T >::type abs(const T &t)
void allVisibleParticles(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle * > &visible)
void findDescendents(const HepMC::GenParticle *a, std::vector< const HepMC::GenParticle * > &descendents)
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
bool isNeutrino(const HepMC::GenParticle *part)