19 #include "fastjet/PseudoJet.hh"
20 #include "fastjet/ClusterSequence.hh"
34 declareInterface<DerivationFramework::IAugmentationTool>(
this);
46 ATH_CHECK(m_dressParticlesKey.initialize());
47 m_decorator_eKey = m_dressParticlesKey.key() +
".e_dressed";
49 m_decorator_ptKey = m_dressParticlesKey.key() +
".pt_dressed";
50 ATH_CHECK(m_decorator_ptKey.initialize());
51 m_decorator_etaKey= m_dressParticlesKey.key() +
".eta_dressed";
52 ATH_CHECK(m_decorator_etaKey.initialize());
53 m_decorator_phiKey= m_dressParticlesKey.key() +
".phi_dressed";
54 ATH_CHECK(m_decorator_phiKey.initialize());
55 m_decorator_pt_visKey = m_dressParticlesKey.key() +
".pt_vis_dressed";
56 ATH_CHECK(m_decorator_pt_visKey.initialize());
57 m_decorator_eta_visKey= m_dressParticlesKey.key() +
".eta_vis_dressed";
58 ATH_CHECK(m_decorator_eta_visKey.initialize());
59 m_decorator_phi_visKey= m_dressParticlesKey.key() +
".phi_vis_dressed";
60 ATH_CHECK(m_decorator_phi_visKey.initialize());
61 m_decorator_m_visKey= m_dressParticlesKey.key() +
".m_vis_dressed";
62 ATH_CHECK(m_decorator_m_visKey.initialize());
63 m_decorator_nphotonKey = m_dressParticlesKey.key() +
".nPhotons_dressed";
64 ATH_CHECK(m_decorator_nphotonKey.initialize());
65 if (!m_decorationName.empty()) {m_decorationKey = m_particlesKey.key()+
"."+m_decorationName;}
66 else {m_decorationKey = m_particlesKey.key()+
".unusedPhotonDecoration";}
70 return StatusCode::SUCCESS;
77 const EventContext& ctx = Gaudi::Hive::currentContext();
81 if (!truthParticles.
isValid()) {
82 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
83 return StatusCode::FAILURE;
87 if (!dressTruthParticles.
isValid()) {
88 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_dressParticlesKey);
89 return StatusCode::FAILURE;
107 if (!m_decorationKey.key().empty()){
109 for (
const auto *
particle : *truthParticles){
118 std::vector<const xAOD::TruthParticle*> listOfParticlesToDress;
119 std::vector<xAOD::TruthParticle::FourMom_t> listOfDressedParticles;
120 std::vector<int> dressedParticlesNPhot;
122 if(m_listOfPIDs.size()==1 && abs(m_listOfPIDs[0])==15) {
125 for (
auto *pItr : *dressTruthParticles) {
126 listOfParticlesToDress.push_back(pItr);
137 for (
const auto&
part : listOfParticlesToDress) {
138 listOfDressedParticles.push_back(
part->p4());
139 dressedParticlesNPhot.push_back(0);
143 std::vector<const xAOD::TruthParticle*> photonsFSRList;
144 std::vector<int> photonPID{22};
146 photonPID, m_usePhotonsFromHadrons);
148 ATH_MSG_WARNING(
"Cannot construct the list of final state particles "<<m_truthClassKey.fullKey());
159 for (
const auto& phot : photonsFSRList ) {
160 double dRmin = m_coneSize;
163 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
164 if (!m_useLeptonsFromHadrons) {
165 if (!acc_origin.isAvailable(*listOfParticlesToDress[
i])) {
166 ATH_MSG_WARNING(
"MCTruthClassifier "<<m_truthClassKey.fullKey() <<
" not available, cannot apply notFromHadron veto!");
168 unsigned int result = acc_origin(*listOfParticlesToDress[
i]);
173 if(listOfParticlesToDress[
i]->
isTau()) {
175 if( !pt_visAcc.
isAvailable(*listOfParticlesToDress[
i]) ||
179 ATH_MSG_ERROR(
"Visible momentum not available for truth taus, cannot perform dressing!");
180 return StatusCode::FAILURE;
183 bare_part.SetPtEtaPhiM(pt_visAcc(*listOfParticlesToDress[
i]),
184 eta_visAcc(*listOfParticlesToDress[
i]),
185 phi_visAcc(*listOfParticlesToDress[
i]),
186 mvisAcc(*listOfParticlesToDress[
i]));
189 bare_part = listOfParticlesToDress[
i]->p4();
192 double dR = bare_part.DeltaR(phot->p4());
200 listOfDressedParticles[
idx] += phot->p4();
201 dressedParticlesNPhot[
idx]++;
202 if (!m_decorationName.empty()){
210 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
215 decorator_pt_vis(*
part) = dressedVec.Pt();
216 decorator_eta_vis(*
part) = dressedVec.Eta();
217 decorator_phi_vis(*
part) = dressedVec.Phi();
218 decorator_m_vis(*
part) = dressedVec.M();
221 decorator_e(*
part) = dressedVec.E();
222 decorator_pt(*
part) = dressedVec.Pt();
223 decorator_eta(*
part) = dressedVec.Eta();
224 decorator_phi(*
part) = dressedVec.Phi();
226 decorator_nphoton(*
part) = dressedParticlesNPhot[
i];
232 std::vector<fastjet::PseudoJet> sorted_jets;
233 std::vector<fastjet::PseudoJet> fj_particles;
234 for (
const auto&
part : listOfParticlesToDress) {
239 ATH_MSG_ERROR(
"Visible momentum not available for truth taus, cannot perform dressing!");
240 return StatusCode::FAILURE;
243 TLorentzVector tauvis;
244 tauvis.SetPtEtaPhiM(pt_visAcc(*
part),
248 fj_particles.emplace_back(tauvis.Px(), tauvis.Py(), tauvis.Pz(), tauvis.E());
256 for (
const auto&
part : photonsFSRList) {
263 const fastjet::JetDefinition jet_def(
alg, m_coneSize);
265 sorted_jets = sorted_by_pt(cseq.inclusive_jets(0));
267 std::vector<int> photon_uniqueIDs(50);
268 photon_uniqueIDs.clear();
269 for (
const auto&
part : listOfParticlesToDress) {
272 auto pjItr=sorted_jets.begin();
273 while(!
found && pjItr!=sorted_jets.end()) {
274 std::vector<fastjet::PseudoJet> constituents = pjItr->constituents();
275 for(
const auto& constit : constituents) {
282 decorator_pt_vis(*
part) = pjItr->pt();
283 decorator_eta_vis(*
part) = pjItr->pseudorapidity();
284 decorator_phi_vis(*
part) = pjItr->phi_std();
285 decorator_m_vis(*
part) = pjItr->m();
288 decorator_e(*
part) = pjItr->e();
289 decorator_pt(*
part) = pjItr->pt();
290 decorator_eta(*
part) = pjItr->pseudorapidity();
291 decorator_phi(*
part) = pjItr->phi_std();
298 for(
const auto& constit : constituents) {
299 photon_uniqueIDs.push_back(constit.user_index());
306 decorator_pt_vis(*
part) = 0.;
307 decorator_eta_vis(*
part) = 0.;
308 decorator_phi_vis(*
part) = 0.;
309 decorator_m_vis(*
part) = 0.;
312 decorator_e(*
part) = 0;
313 decorator_pt(*
part) = 0;
314 decorator_eta(*
part) = 0;
315 decorator_phi(*
part) = 0;
321 if (!m_decorationName.empty()){
323 for (
const auto& phot : photonsFSRList ) {
332 return StatusCode::SUCCESS;