20 #include "fastjet/PseudoJet.hh"
21 #include "fastjet/ClusterSequence.hh"
35 declareInterface<DerivationFramework::IAugmentationTool>(
this);
47 ATH_CHECK(m_dressParticlesKey.initialize());
48 m_decorator_eKey = m_dressParticlesKey.key() +
".e_dressed";
50 m_decorator_ptKey = m_dressParticlesKey.key() +
".pt_dressed";
51 ATH_CHECK(m_decorator_ptKey.initialize());
52 m_decorator_etaKey= m_dressParticlesKey.key() +
".eta_dressed";
53 ATH_CHECK(m_decorator_etaKey.initialize());
54 m_decorator_phiKey= m_dressParticlesKey.key() +
".phi_dressed";
55 ATH_CHECK(m_decorator_phiKey.initialize());
56 m_decorator_pt_visKey = m_dressParticlesKey.key() +
".pt_vis_dressed";
57 ATH_CHECK(m_decorator_pt_visKey.initialize());
58 m_decorator_eta_visKey= m_dressParticlesKey.key() +
".eta_vis_dressed";
59 ATH_CHECK(m_decorator_eta_visKey.initialize());
60 m_decorator_phi_visKey= m_dressParticlesKey.key() +
".phi_vis_dressed";
61 ATH_CHECK(m_decorator_phi_visKey.initialize());
62 m_decorator_m_visKey= m_dressParticlesKey.key() +
".m_vis_dressed";
63 ATH_CHECK(m_decorator_m_visKey.initialize());
64 m_decorator_nphotonKey = m_dressParticlesKey.key() +
".nPhotons_dressed";
65 ATH_CHECK(m_decorator_nphotonKey.initialize());
66 if (!m_decorationName.empty()) {m_decorationKey = m_particlesKey.key()+
"."+m_decorationName;}
67 else {m_decorationKey = m_particlesKey.key()+
".unusedPhotonDecoration";}
71 return StatusCode::SUCCESS;
78 const EventContext& ctx = Gaudi::Hive::currentContext();
82 if (!truthParticles.
isValid()) {
83 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
84 return StatusCode::FAILURE;
88 if (!dressTruthParticles.
isValid()) {
89 ATH_MSG_ERROR(
"Couldn't retrieve TruthParticle collection with name " << m_dressParticlesKey);
90 return StatusCode::FAILURE;
112 if (!m_decorationName.empty()){
114 for (
const auto *
particle : *truthParticles){
123 std::vector<const xAOD::TruthParticle*> listOfParticlesToDress;
124 std::vector<xAOD::TruthParticle::FourMom_t> listOfDressedParticles;
125 std::vector<int> dressedParticlesNPhot;
127 if(m_listOfPIDs.size()==1 && abs(m_listOfPIDs[0])==15) {
130 for (
auto *pItr : *dressTruthParticles) {
131 listOfParticlesToDress.push_back(pItr);
142 for (
const auto&
part : listOfParticlesToDress) {
143 listOfDressedParticles.push_back(
part->p4());
144 dressedParticlesNPhot.push_back(0);
148 std::vector<const xAOD::TruthParticle*> photonsFSRList;
149 std::vector<int> photonPID{22};
151 photonPID, m_usePhotonsFromHadrons);
153 ATH_MSG_WARNING(
"Cannot construct the list of final state particles "<<m_truthClassKey.fullKey());
164 for (
const auto& phot : photonsFSRList ) {
165 double dRmin = m_coneSize;
168 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
169 if (!m_useLeptonsFromHadrons) {
170 if (!acc_origin.isAvailable(*listOfParticlesToDress[
i])) {
171 ATH_MSG_WARNING(
"MCTruthClassifier "<<m_truthClassKey.fullKey() <<
" not available, cannot apply notFromHadron veto!");
173 unsigned int result = acc_origin(*listOfParticlesToDress[
i]);
178 if(listOfParticlesToDress[
i]->
isTau()) {
180 if( !pt_visAcc.
isAvailable(*listOfParticlesToDress[
i]) ||
184 ATH_MSG_ERROR(
"Visible momentum not available for truth taus, cannot perform dressing!");
185 return StatusCode::FAILURE;
188 bare_part.SetPtEtaPhiM(pt_visAcc(*listOfParticlesToDress[
i]),
189 eta_visAcc(*listOfParticlesToDress[
i]),
190 phi_visAcc(*listOfParticlesToDress[
i]),
191 mvisAcc(*listOfParticlesToDress[
i]));
194 bare_part = listOfParticlesToDress[
i]->p4();
197 double dR = bare_part.DeltaR(phot->p4());
205 listOfDressedParticles[
idx] += phot->p4();
206 dressedParticlesNPhot[
idx]++;
207 if (!m_decorationName.empty()){
215 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
220 decorator_pt_vis(*
part) = dressedVec.Pt();
221 decorator_eta_vis(*
part) = dressedVec.Eta();
222 decorator_phi_vis(*
part) = dressedVec.Phi();
223 decorator_m_vis(*
part) = dressedVec.M();
226 decorator_e(*
part) = dressedVec.E();
227 decorator_pt(*
part) = dressedVec.Pt();
228 decorator_eta(*
part) = dressedVec.Eta();
229 decorator_phi(*
part) = dressedVec.Phi();
231 decorator_nphoton(*
part) = dressedParticlesNPhot[
i];
237 std::vector<fastjet::PseudoJet> sorted_jets;
238 std::vector<fastjet::PseudoJet> fj_particles;
239 for (
const auto&
part : listOfParticlesToDress) {
244 ATH_MSG_ERROR(
"Visible momentum not available for truth taus, cannot perform dressing!");
245 return StatusCode::FAILURE;
248 TLorentzVector tauvis;
249 tauvis.SetPtEtaPhiM(pt_visAcc(*
part),
253 fj_particles.emplace_back(tauvis.Px(), tauvis.Py(), tauvis.Pz(), tauvis.E());
261 for (
const auto&
part : photonsFSRList) {
268 const fastjet::JetDefinition jet_def(
alg, m_coneSize);
270 sorted_jets = sorted_by_pt(cseq.inclusive_jets(0));
272 std::vector<int> photon_uniqueIDs(50);
273 photon_uniqueIDs.clear();
274 for (
const auto&
part : listOfParticlesToDress) {
277 auto pjItr=sorted_jets.begin();
278 while(!
found && pjItr!=sorted_jets.end()) {
279 std::vector<fastjet::PseudoJet> constituents = pjItr->constituents();
280 for(
const auto& constit : constituents) {
287 decorator_pt_vis(*
part) = pjItr->pt();
288 decorator_eta_vis(*
part) = pjItr->pseudorapidity();
289 decorator_phi_vis(*
part) = pjItr->phi_std();
290 decorator_m_vis(*
part) = pjItr->m();
293 decorator_e(*
part) = pjItr->e();
294 decorator_pt(*
part) = pjItr->pt();
295 decorator_eta(*
part) = pjItr->pseudorapidity();
296 decorator_phi(*
part) = pjItr->phi_std();
303 for(
const auto& constit : constituents) {
304 photon_uniqueIDs.push_back(constit.user_index());
311 decorator_pt_vis(*
part) = 0.;
312 decorator_eta_vis(*
part) = 0.;
313 decorator_phi_vis(*
part) = 0.;
314 decorator_m_vis(*
part) = 0.;
317 decorator_e(*
part) = 0;
318 decorator_pt(*
part) = 0;
319 decorator_eta(*
part) = 0;
320 decorator_phi(*
part) = 0;
326 if (!m_decorationName.empty()){
328 for (
const auto& phot : photonsFSRList ) {
337 return StatusCode::SUCCESS;