64{
65
66
67
68 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticles(
m_particlesKey,ctx);
69 if (!truthParticles.isValid()) {
71 return StatusCode::FAILURE;
72 }
73
75 if (!dressTruthParticles.isValid()) {
77 return StatusCode::FAILURE;
78 }
79
80
81 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_e(
m_decorator_eKey, ctx);
82 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_pt(
m_decorator_ptKey, ctx);
83 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_eta(
m_decorator_etaKey, ctx);
84 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_phi(
m_decorator_phiKey, ctx);
85
86
87 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_pt_vis(
m_decorator_pt_visKey, ctx);
90 SG::WriteDecorHandle< xAOD::TruthParticleContainer,float > decorator_m_vis(
m_decorator_m_visKey, ctx);
92 SG::WriteDecorHandle< xAOD::TruthParticleContainer,char > dressDec(
m_decorationKey, ctx);
93
95 for (const auto * particle : *truthParticles){
96 dressDec(*particle) = 0;
97 }
98 }
99
100
101 static const SG::ConstAccessor<double> pt_visAcc("pt_vis");
102 static const SG::ConstAccessor<double> eta_visAcc("eta_vis");
103 static const SG::ConstAccessor<double> phi_visAcc("phi_vis");
104 static const SG::ConstAccessor<double> mvisAcc("m_vis");
105
106
107 DerivationFramework::DecayGraphHelper decayHelper;
108
109 std::vector<const xAOD::TruthParticle*> listOfParticlesToDress;
110 std::vector<xAOD::TruthParticle::FourMom_t> listOfDressedP4;
111 std::vector<xAOD::TruthParticle::FourMom_t> listOfBareP4;
112
114
115 for (auto *pItr : *dressTruthParticles) {
116 if (!pItr->isTau()) {
118 return StatusCode::FAILURE;
119 }
120 if (!pt_visAcc.isAvailable(*pItr) || !eta_visAcc.isAvailable(*pItr) || !phi_visAcc.isAvailable(*pItr) || !mvisAcc.isAvailable(*pItr)) {
121 ATH_MSG_ERROR(
"Visible momentum not available for truth taus, cannot perform dressing!");
122 return StatusCode::FAILURE;
123 }
124
125 listOfParticlesToDress.push_back(pItr);
126
127
129 bare_part.SetPtEtaPhiM(pt_visAcc(*pItr), eta_visAcc(*pItr), phi_visAcc(*pItr), mvisAcc(*pItr));
130 listOfDressedP4.push_back(bare_part);
131 }
132
134 listOfBareP4 = listOfDressedP4;
135 }
136 }
137 else {
138
139
140
142
143 for (const auto* part : listOfParticlesToDress) {
144 listOfDressedP4.push_back(
part->p4());
145 }
146 }
147
148 std::vector<int> dressedParticlesNPhot(listOfParticlesToDress.size(), 0);
149
150
151 std::vector<const xAOD::TruthParticle*> photonsFSRList;
152 std::vector<int> photonPID{22};
155 if (!pass) {
157 }
158
159
161
162 for (const auto* phot : photonsFSRList) {
165
166 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
168 if (!acc_origin.isAvailable(*listOfParticlesToDress[i])) {
170 }
171 unsigned int result = acc_origin(*listOfParticlesToDress[i]);
174 }
176 if (listOfParticlesToDress[i]->
isTau()) {
177 bare_part = listOfBareP4[
i];
178 }
179 else {
180 bare_part = listOfParticlesToDress[
i]->p4();
181 }
182
183 double dR = bare_part.DeltaR(phot->p4());
184 if (dR < dRmin) {
185 dRmin = dR;
187 }
188 }
189
190 if(idx > -1) {
191 listOfDressedP4[
idx] += phot->p4();
192 dressedParticlesNPhot[
idx]++;
194 dressDec(*phot) = 1;
195 }
196 }
197 }
198
199
200 for (
size_t i = 0;
i < listOfParticlesToDress.size(); ++
i) {
203
205 decorator_pt_vis(*part) = dressedVec.Pt();
206 decorator_eta_vis(*part) = dressedVec.Eta();
207 decorator_phi_vis(*part) = dressedVec.Phi();
208 decorator_m_vis(*part) = dressedVec.M();
209 }
210 else {
211 decorator_e(*part) = dressedVec.E();
212 decorator_pt(*part) = dressedVec.Pt();
213 decorator_eta(*part) = dressedVec.Eta();
214 decorator_phi(*part) = dressedVec.Phi();
215 }
216 decorator_nphoton(*part) = dressedParticlesNPhot[
i];
217 }
218 }
219
220
222 std::vector<fastjet::PseudoJet> sorted_jets;
223 std::vector<fastjet::PseudoJet> fj_particles;
224 for (const auto* part : listOfParticlesToDress) {
227 fj_particles.emplace_back(tauvis.Px(), tauvis.Py(), tauvis.Pz(), tauvis.E());
228 }
229 else {
231 }
232
234 }
235 for (const auto* part : photonsFSRList) {
238 }
239
240
241 fastjet::JetAlgorithm
alg=fastjet::antikt_algorithm;
242 const fastjet::JetDefinition jet_def(alg,
m_coneSize);
243 fastjet::ClusterSequence cseq(fj_particles, jet_def);
244 sorted_jets = sorted_by_pt(cseq.inclusive_jets(0));
245
246 std::vector<int> photon_uniqueIDs(50);
247 photon_uniqueIDs.clear();
248 for (const auto* part : listOfParticlesToDress) {
249
251 auto pjItr=sorted_jets.begin();
252 while(!found && pjItr!=sorted_jets.end()) {
253 std::vector<fastjet::PseudoJet> constituents = pjItr->constituents();
254 for(const auto& constit : constituents) {
256
257
258
259
261 decorator_pt_vis(*part) = pjItr->pt();
262 decorator_eta_vis(*part) = pjItr->pseudorapidity();
263 decorator_phi_vis(*part) = pjItr->phi_std();
264 decorator_m_vis(*part) = pjItr->m();
265 }
266 else {
267 decorator_e(*part) = pjItr->e();
268 decorator_pt(*part) = pjItr->pt();
269 decorator_eta(*part) = pjItr->pseudorapidity();
270 decorator_phi(*part) = pjItr->phi_std();
271 }
273 break;
274 }
275 }
276 if (found){
277 for(const auto& constit : constituents) {
278 photon_uniqueIDs.push_back(constit.user_index());
279 }
280 }
281 ++pjItr;
282 }
283 if (!found) {
285 decorator_pt_vis(*part) = 0.;
286 decorator_eta_vis(*part) = 0.;
287 decorator_phi_vis(*part) = 0.;
288 decorator_m_vis(*part) = 0.;
289 }
290 else {
291 decorator_e(*part) = 0;
292 decorator_pt(*part) = 0;
293 decorator_eta(*part) = 0;
294 decorator_phi(*part) = 0;
295 }
297 }
298 }
299
301
302 for (const auto* phot : photonsFSRList ) {
303 bool found = std::find(photon_uniqueIDs.begin(), photon_uniqueIDs.end(),
HepMC::uniqueID(phot)) != photon_uniqueIDs.end();
304 if (found) {
305 dressDec(*phot) = 1;
306 }
307 }
308 }
309 }
310
311 return StatusCode::SUCCESS;
312}
#define ATH_MSG_WARNING(x)
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
int isPrompt(const unsigned int classify, bool allow_prompt_tau_decays=true)
TruthParticle_v1 TruthParticle
Typedef to implementation.
bool constructListOfFinalParticles(const xAOD::TruthParticleContainer *allParticles, std::vector< const xAOD::TruthParticle * > &selectedlist, const std::vector< int > &pdgId, bool allowFromHadron=false, bool chargedOnly=false) const