18#include "CLHEP/Units/SystemOfUnits.h"
19#include "CLHEP/Vector/LorentzVector.h"
29using CLHEP::HepLorentzVector;
33 {
return {
v.x(),
v.y(),
v.z(),
v.t() }; }
39 const std::string& name,
40 const IInterface* parent ) :
49 "Minimum transverse energy of gammas to be taken into "
50 "account into the isolation computation." );
54 "Prefix for the TruthEtIsolations container. This is the "
55 "string which will be prepended to the key of the "
56 "McEventCollection to build the (StoreGate) output "
57 "location for the TruthEtIsolations.\nie: \"GEN_EVENT\" "
58 "--> \"<prefix>_GEN_EVENT\"" );
65 "Name of the McEventCollection we should attach "
71 declareInterface<ITruthIsolationTool>(
this);
80 if ( !
evtStore().retrieve().isSuccess() ) {
82 return StatusCode::FAILURE;
87 return StatusCode::SUCCESS;
93 static const std::string s_emptyString =
"";
94 const EtIsolMap_t::const_iterator i =
m_etIsolMap.find(mcEvtName);
108 if ( !
evtStore()->retrieve( mcEvts, mcEvtName ).isSuccess() ) {
110 << mcEvtName <<
"] !!" <<
endmsg
111 <<
"No Et-isolations will be computed !");
112 return StatusCode::RECOVERABLE;
120 std::ostringstream truthEtIsolName;
125 <<
"_" << outMcEvtName;
128 if ( !
evtStore()->record( etIsolations,
129 truthEtIsolName.str() ).isSuccess() ) {
131 etIsolations =
nullptr;
133 << truthEtIsolName.str() <<
"] !!");
134 return StatusCode::RECOVERABLE;
136 if ( !
evtStore()->setConst( etIsolations ).isSuccess() ) {
137 ATH_MSG_WARNING(
"Could not setConst the TruthEtIsolations container at ["
138 << truthEtIsolName.str() <<
"] !!");
145 for ( std::size_t iMc = 0, iMax = mcEvts->
size(); iMc != iMax; ++iMc ) {
149 *etIsols, partSel ).isSuccess() ) {
151 <<
"Problem encountered while computing Et-isolations for idx=["
152 << iMc <<
"] of McEventCollection [" << mcEvtName <<
"] !!"
157 return allGood ? StatusCode::SUCCESS : StatusCode::RECOVERABLE;
163 const std::size_t genIdx,
167 if (
nullptr == genEvt ) {
169 <<
"Null pointer to GenEvent (idx = [" << genIdx <<
"] from "
170 <<
"McEventCollection [" << mcEvtName <<
"]) !!"
172 return StatusCode::RECOVERABLE;
177 for (
const auto& i: *genEvt) {
179 particles.push_back( i );
183 for (
const auto& i: *genEvt) {
185 const int ida = std::abs(i->pdg_id());
186 const double pt = hlv.perp();
190 const bool doComputeIso = ( ( ida == 22 && pt >
m_ptGamMin ) ||
191 ida == 11 || ida == 13 || ida == 15 ) &&
193 if ( doComputeIso ) {
198 return StatusCode::SUCCESS;
207 const HepLorentzVector hlv = ::svToLv(part->momentum());
208 const int ida = std::abs(part->pdg_id());
216 for (
const auto & particle : particles) {
221 double particleCharge =
MC::charge(particle->pdg_id());
222 if( std::abs(particleCharge)<1.e-2 )
225 const HepLorentzVector itrHlv = ::svToLv(particle->momentum());
226 const double r = hlv.deltaR(itrHlv);
227 for ( std::size_t iCone = 0;
231 pxi[iCone] += itrHlv.px();
232 pyi[iCone] += itrHlv.py();
241 auto decVtx = part->end_vertex();
242 if (ida == 15 && decVtx) {
243 for (
const auto& child: *decVtx) {
246 double particleCharge =
MC::charge(child->pdg_id());
247 if( std::abs(particleCharge)<1.e-2 )
251 pxv += childHlv.px();
252 pyv += childHlv.py();
257 for ( std::size_t i = 0;
262 etIsol[i] = std::sqrt(pxi[i]*pxi[i]+pyi[i]*pyi[i]);
282 const std::string& aliasMcEvtColl )
285 return StatusCode::SUCCESS;
#define ATH_MSG_WARNING(x)
ATLAS-specific HepMC functions.
std::list< HepMC::ConstGenParticlePtr > GenParticles_t
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
container which holds isolation informations for a given HepMC::GenParticle (labelled by barcode) for...
void setEtIsol(const HepMC::ConstGenParticlePtr &genParticle, const TruthParticleParameters::ConeSize coneIdx, const double etIsol)
Set the transverse energy isolation of a HepMC::GenParticle for a given Cone size.
HepMC3::FourVector FourVector
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
HepMC3::GenEvent GenEvent
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
double charge(const T &p)
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
std::array< double, TruthParticleParameters::NbrOfCones > EtIsolations
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
double coneCut(const TruthParticleParameters::ConeSize idx)
The actual definition of delta R cuts for each cone.
ConeSize
Enum for Cone size indexes (for isolation).