|
ATLAS Offline Software
|
Go to the documentation of this file.
13 #include "GaudiKernel/IPartPropSvc.h"
21 #include "CLHEP/Units/SystemOfUnits.h"
22 #include "CLHEP/Vector/LorentzVector.h"
32 using CLHEP::HepLorentzVector;
35 HepLorentzVector svToLv(
const HepMC::FourVector&
v )
36 {
return {
v.x(),
v.y(),
v.z(),
v.t() }; }
42 const std::string&
name,
43 const IInterface*
parent ) :
53 "Minimum transverse energy of gammas to be taken into "
54 "account into the isolation computation." );
58 "Prefix for the TruthEtIsolations container. This is the "
59 "string which will be prepended to the key of the "
60 "McEventCollection to build the (StoreGate) output "
61 "location for the TruthEtIsolations.\nie: \"GEN_EVENT\" "
62 "--> \"<prefix>_GEN_EVENT\"" );
69 "Name of the McEventCollection we should attach "
75 declareInterface<ITruthIsolationTool>(
this);
86 return StatusCode::FAILURE;
93 if ( !partPropSvc.retrieve().isSuccess() ) {
94 ATH_MSG_ERROR(
" Could not initialize Particle Properties Service");
95 return StatusCode::FAILURE;
98 m_pdt = partPropSvc->PDT();
99 if (
nullptr ==
m_pdt ) {
100 ATH_MSG_ERROR(
"Could not retrieve HepPDT::ParticleDataTable from "\
101 "ParticleProperties Service !!");
102 return StatusCode::FAILURE;
105 return StatusCode::SUCCESS;
111 static const std::string s_emptyString =
"";
112 const EtIsolMap_t::const_iterator
i =
m_etIsolMap.find(mcEvtName);
117 return s_emptyString;
128 << mcEvtName <<
"] !!" <<
endmsg
129 <<
"No Et-isolations will be computed !");
130 return StatusCode::RECOVERABLE;
138 std::ostringstream truthEtIsolName;
143 <<
"_" << outMcEvtName;
146 if ( !
evtStore()->record( etIsolations,
147 truthEtIsolName.str() ).isSuccess() ) {
149 etIsolations =
nullptr;
151 << truthEtIsolName.str() <<
"] !!");
152 return StatusCode::RECOVERABLE;
154 if ( !
evtStore()->setConst( etIsolations ).isSuccess() ) {
155 ATH_MSG_WARNING(
"Could not setConst the TruthEtIsolations container at ["
156 << truthEtIsolName.str() <<
"] !!");
163 for ( std::size_t iMc = 0, iMax = mcEvts->
size(); iMc != iMax; ++iMc ) {
167 *etIsols, partSel ).isSuccess() ) {
169 <<
"Problem encountered while computing Et-isolations for idx=["
170 << iMc <<
"] of McEventCollection [" << mcEvtName <<
"] !!"
175 return allGood ? StatusCode::SUCCESS : StatusCode::RECOVERABLE;
180 const HepMC::GenEvent* genEvt,
181 const std::size_t genIdx,
185 if (
nullptr == genEvt ) {
187 <<
"Null pointer to GenEvent (idx = [" << genIdx <<
"] from "
188 <<
"McEventCollection [" << mcEvtName <<
"]) !!"
190 return StatusCode::RECOVERABLE;
195 for (
const auto&
i: *genEvt) {
201 for (
const auto&
i: *genEvt) {
202 const HepMC::FourVector hlv =
i->momentum();
203 const int ida = std::abs(
i->pdg_id());
204 const double pt = hlv.perp();
208 const bool doComputeIso = ( ( ida == 22 &&
pt >
m_ptGamMin ) ||
209 ida == 11 || ida == 13 || ida == 15 ) &&
211 if ( doComputeIso ) {
216 return StatusCode::SUCCESS;
225 const HepLorentzVector hlv = ::svToLv(
part->momentum());
226 const int ida = std::abs(
part->pdg_id());
240 if( std::abs(particleCharge)<1.
e-2 )
243 const HepLorentzVector itrHlv = ::svToLv(
particle->momentum());
244 const double r = hlv.deltaR(itrHlv);
245 for ( std::size_t iCone = 0;
249 pxi[iCone] += itrHlv.px();
250 pyi[iCone] += itrHlv.py();
259 auto decVtx =
part->end_vertex();
260 if (ida == 15 && decVtx) {
261 for (
const auto& child: *decVtx) {
264 double particleCharge =
MC::charge(child->pdg_id());
265 if( std::abs(particleCharge)<1.
e-2 )
268 const HepMC::FourVector childHlv = child->momentum();
269 pxv += childHlv.px();
270 pyv += childHlv.py();
275 for ( std::size_t
i = 0;
280 etIsol[
i] = std::sqrt(pxi[
i]*pxi[
i]+pyi[
i]*pyi[
i]);
300 const std::string& aliasMcEvtColl )
303 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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.
ConeSize
Enum for Cone size indexes (for isolation)
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
std::array< double, TruthParticleParameters::NbrOfCones > EtIsolations
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
::StatusCode StatusCode
StatusCode definition for legacy code.
double coneCut(const TruthParticleParameters::ConeSize idx)
The actual definition of delta R cuts for each cone.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
bool allGood
Loop over the SDOs & Digits.
const GenParticle * ConstGenParticlePtr
double charge(const T &p)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
#define ATH_MSG_WARNING(x)
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
TruthEtIsolationsContainer
size_type size() const noexcept
Returns the number of elements in the collection.
std::list< HepMC::ConstGenParticlePtr > GenParticles_t