9 #include "CLHEP/Random/RandomEngine.h"
10 #include "GaudiKernel/PhysicalConstants.h"
19 return (
t1->pt() >
t2->pt());
60 return StatusCode::SUCCESS;
66 const EventContext& ctx = Gaudi::Hive::currentContext();
70 ATH_MSG_ERROR(
"Failed to retrieve random number engine xAODVBFMjjIntervalFilter");
71 setFilterPassed(
false);
72 return StatusCode::SUCCESS;
82 setFilterPassed(
false);
83 return StatusCode::SUCCESS;
90 ATH_MSG_ERROR(
"No TruthParticle collection with name " <<
"TruthGen" <<
" found in StoreGate!");
91 return StatusCode::FAILURE;
96 std::vector<const xAOD::TruthParticle *> MCTruthPhotonList;
97 std::vector<const xAOD::TruthParticle *> MCTruthElectronList;
98 std::vector<TLorentzVector> MCTruthTauList;
101 unsigned int nPart = xTruthParticleContainer->
size();
102 for (
unsigned int iPart = 0; iPart < nPart; ++iPart) {
112 MCTruthPhotonList.push_back(pitr);
122 MCTruthElectronList.push_back(pitr);
132 for (
size_t thisChild_id = 0; thisChild_id < tau->decayVtx()->nOutgoingParticles(); thisChild_id++)
135 if (child->prodVtx() != tau->decayVtx())
137 if (std::abs(child->pdgId()) == 12)
139 if (std::abs(child->pdgId()) == 14)
141 if (std::abs(child->pdgId()) == 15)
148 TLorentzVector tauvis = TLorentzVector(tau->px() - nutau.Px(),
149 tau->py() - nutau.Py(),
150 tau->pz() - nutau.Pz(),
151 tau->e() - nutau.E());
152 if (tauvis.Vect().Perp() >=
m_olapPt && std::abs(tauvis.Vect().PseudoRapidity()) <=
m_yMax)
154 MCTruthTauList.push_back(tauvis);
166 if (std::abs((*jitr)->rapidity()) <
m_yMax && (*jitr)->pt() >=
m_olapPt)
168 bool JetOverlapsWithPhoton =
false;
169 bool JetOverlapsWithElectron =
false;
170 bool JetOverlapsWithTau =
false;
174 JetOverlapsWithPhoton =
checkOverlap((*jitr)->rapidity(), (*jitr)->phi(), MCTruthPhotonList);
178 JetOverlapsWithElectron =
checkOverlap((*jitr)->rapidity(), (*jitr)->phi(), MCTruthElectronList);
182 JetOverlapsWithTau =
checkOverlap((*jitr)->rapidity(), (*jitr)->phi(), MCTruthTauList);
185 if (!JetOverlapsWithPhoton && !JetOverlapsWithElectron && !JetOverlapsWithTau)
196 double eventWeight = 1.0;
198 double rnd = rndm->flat();
199 if (1.0 / eventWeight < rnd)
201 setFilterPassed(
false);
202 ATH_MSG_DEBUG(
"Event failed weighting. Weight is " << eventWeight);
203 return StatusCode::SUCCESS;
210 setFilterPassed(
false);
211 ATH_MSG_ERROR(
"Could not retrieve MC Event Collection - weight might not work");
212 return StatusCode::SUCCESS;
217 for (
unsigned int i = 0;
i < mec->
size(); ++
i)
221 double existingWeight = (*mec)[
i]->weights().
size() > 0 ? (*mec)[
i]->weights()[0] : 1.;
222 if ((*mec)[
i]->weights().size() > 0)
224 for (
unsigned int iw = 0; iw < (*mec)[
i]->weights().size(); ++iw) {
225 double existWeight = (*mec)[
i]->weights()[iw];
226 (*mec)[
i]->weights()[iw] = existWeight * eventWeight *
m_norm;
233 (*mec)[
i]->weights().push_back(eventWeight *
m_norm * existingWeight);
237 (*mec)[
i]->add_attribute(
"filterWeight", std::make_shared<HepMC3::DoubleAttribute>(eventWeight*
m_norm));
248 setFilterPassed(
false);
250 return StatusCode::SUCCESS;
256 setFilterPassed(
false);
257 return StatusCode::SUCCESS;
263 setFilterPassed(
false);
264 return StatusCode::SUCCESS;
270 setFilterPassed(
true);
271 return StatusCode::SUCCESS;
276 for (
size_t i = 0;
i <
list.size(); ++
i)
292 double dr = std::sqrt(deta * deta + dphi * dphi);
302 for (
size_t i = 0;
i <
list.size(); ++
i)
304 double pt =
list[
i].Vect().Perp();
309 double deta =
eta -
list[
i].Vect().PseudoRapidity();
318 double dr = std::sqrt(deta * deta + dphi * dphi);
328 if (
jets->size() < 2)
330 double mjj = (
jets->at(0)->p4() +
jets->at(1)->p4()).M();
331 double dphi = std::abs(
jets->at(0)->p4().DeltaPhi(
jets->at(1)->p4()));
347 if (
jets->size() == 0)
352 else if (
jets->size() == 1)
359 double mjj = (
jets->at(0)->p4() +
jets->at(1)->p4()).M();
393 TLorentzVector nu(0, 0, 0, 0);
395 if ((std::abs(
part->pdgId()) == 12) || (std::abs(
part->pdgId()) == 14) || (std::abs(
part->pdgId()) == 16))
397 nu.SetPx(
part->px());
398 nu.SetPy(
part->py());
399 nu.SetPz(
part->pz());
404 if (!
part->decayVtx())
407 for (
size_t thisChild_id = 0; thisChild_id <
part->decayVtx()->nOutgoingParticles(); thisChild_id++)
409 auto daughterparticle =
part->decayVtx()->outgoingParticle(thisChild_id);
417 const EventContext& ctx)
const
421 rngWrapper->
setSeed( rngName, ctx );