 |
ATLAS Offline Software
|
#include <HardTruthThinning.h>
|
SG::ReadHandleKey< xAOD::EventInfo > | m_eventInfoKey {this, "EvtInfo", "EventInfo", "EventInfo name"} |
|
SG::ReadHandleKey< xAOD::TruthParticleContainer > | m_hardParticleKey {this, "HardParticles", "", "Hard particle container name"} |
|
SG::ReadHandleKey< xAOD::JetContainer > | m_truthJetsKey {this, "JetName", "", "Truth jet container name"} |
|
StringProperty | m_streamName { this, "StreamName", "", "Name of the stream being thinned" } |
|
SG::ThinningHandleKey< xAOD::TruthParticleContainer > | m_truthParticleName { this, "TruthParticles", "", "truth particle container name" } |
|
SG::ThinningHandleKey< xAOD::TruthVertexContainer > | m_truthVertexName { this, "TruthVertices", "", "truth vertex container name" } |
|
float | m_jetPtCut |
|
float | m_jetEtaCut |
|
float | m_jetConstPtCut |
|
float | m_jetPhotonPtCut |
|
float | m_isolR |
|
float | m_isolPtCut |
|
std::atomic< int > | m_evtCount {} |
|
int | m_maxCount |
|
std::atomic< int > | m_errCount {} |
|
std::vector< int > | m_keepIds |
|
Definition at line 48 of file HardTruthThinning.h.
◆ HardTruthThinning()
DerivationFramework::HardTruthThinning::HardTruthThinning |
( |
const std::string & |
t, |
|
|
const std::string & |
n, |
|
|
const IInterface * |
p |
|
) |
| |
Definition at line 42 of file HardTruthThinning.cxx.
54 "truth jet minumum pt");
57 "truth jet maximum abs(eta)");
60 "jet constituent minimum pt");
63 "jet constituent photon minimum pt");
66 "list of abs(pdgID) to keep");
68 declareProperty(
"IsolRadius",
m_isolR,
69 "isolation radius for leptons and photons");
72 "isolation particle minimum pt");
74 declareProperty(
"MaxCount",
76 "maximum number of events to print");
◆ ~HardTruthThinning()
DerivationFramework::HardTruthThinning::~HardTruthThinning |
( |
| ) |
|
|
virtual |
◆ doThinning()
StatusCode DerivationFramework::HardTruthThinning::doThinning |
( |
| ) |
const |
|
overridevirtual |
Definition at line 127 of file HardTruthThinning.cxx.
129 const EventContext& ctx = Gaudi::Hive::currentContext();
141 if (!inHardParts.isValid()) {
143 return StatusCode::FAILURE;
151 std::vector<const xAOD::TruthParticle*> hardPart;
152 std::vector<TLorentzVector> pLepGam;
154 for (
const auto* pItr : *inHardParts) {
156 hardPart.push_back(pItr);
158 int ida = pItr->absPdgId();
160 pLepGam.push_back( pItr->p4() );
167 long long int evtNum{};
172 return StatusCode::FAILURE;
174 evtNum =
evt->eventNumber();
183 std::vector<bool> partMask;
184 std::vector<bool> vertMask;
185 unsigned int inPartNum = inTruthParts->size();
186 unsigned int inVertNum = inTruthVerts->size();
187 partMask.assign(inPartNum,
false);
188 vertMask.assign(inVertNum,
false);
190 ATH_MSG_DEBUG(
"Initial particles/vertices = " <<inPartNum <<
" " <<inVertNum);
199 std::vector<const xAOD::TruthParticle*> kids;
201 for (
const auto* pItr : *inTruthParts) {
205 for(
unsigned int i=0;
i<hardPart.size(); ++
i){
208 if( pItr->pdgId() != (hardPart[
i])->pdgId() ){
212 <<
" " <<(hardPart[
i])->pdgId());
220 partMask[ pItr->index() ] =
true;
224 int ida = pItr->absPdgId();
234 partMask[pItr->index()] =
true;
236 for(
int i=0;
i<nkids; ++
i){
239 partMask[ (kids[
i])->
index() ] =
true;
241 if(
v ) vertMask[
v->index() ] =
true;
246 if( !pLepGam.empty() && pItr->pt() >
m_isolPtCut ){
247 TLorentzVector pp4 = pItr->p4();
248 for(
unsigned int lep=0; lep<pLepGam.size(); ++lep){
249 double r = pp4.DeltaR( pLepGam[lep] );
252 partMask[ pItr->index() ] =
true;
266 if (!inJets.isValid()) {
268 return StatusCode::FAILURE;
271 std::vector<int> uidJetConst;
273 for(
const auto* ajet : *inJets){
275 if( std::abs(ajet->eta()) >
m_jetEtaCut )
continue;
280 for( ; aItr != aItrE; ++aItr){
298 for (
const auto* pItr : *inTruthParts) {
301 for(
unsigned int i=0;
i<uidJetConst.size(); ++
i){
302 if(
uid == uidJetConst[
i] ){
309 partMask[ pItr->index() ] =
true;
317 inTruthParts.keep (partMask);
318 inTruthVerts.keep (vertMask);
322 for(
unsigned int i=0;
i<partMask.size(); ++
i){
323 if( partMask[
i] ) ++outPartNum;
326 for(
unsigned int i=0;
i<vertMask.size(); ++
i){
327 if( vertMask[
i] ) ++outVertNum;
330 ATH_MSG_DEBUG(
"Final particles/vertices = " <<outPartNum <<
" " <<outVertNum);
333 std::cout <<
"======================================================================================" <<std::endl;
334 std::cout <<
"HardTruthThinning complete for event " <<evtNum <<std::endl;
335 std::cout <<
"Saved " <<outPartNum <<
" particles" <<std::endl;
336 std::cout <<
"Particle unique IDs = ";
337 for(
unsigned int i=0;
i<partMask.size(); ++
i){
340 std::cout <<std::endl;
342 std::cout <<
"Saved " <<outVertNum <<
" vertices" <<std::endl;
343 std::cout <<
"Vertex unique IDs = ";
344 for(
unsigned int i=0;
i<vertMask.size(); ++
i){
347 std::cout <<std::endl;
348 std::cout <<
"======================================================================================" <<std::endl;
351 return StatusCode::SUCCESS;
◆ finalize()
StatusCode DerivationFramework::HardTruthThinning::finalize |
( |
| ) |
|
|
overridevirtual |
◆ getDescendants()
Definition at line 365 of file HardTruthThinning.cxx.
369 if( ! (
p->hasDecayVtx()) )
return 0;
371 if( !dvtx )
return 0;
374 const std::vector< ElementLink< xAOD::TruthParticleContainer > >& outPart =
376 for(
unsigned int k=0;
k<outPart.size(); ++
k){
377 if( ! (outPart[
k]).
isValid() )
continue;
379 descendants.push_back(kid);
383 int nstop = descendants.size();
385 while( nstop > nstart ){
386 for(
int i=nstart;
i<nstop; ++
i){
393 const std::vector< ElementLink< xAOD::TruthParticleContainer > >&
395 for(
unsigned int k=0;
k<outPart2.size(); ++
k){
396 if( ! (outPart2[
k]).isValid() )
continue;
400 for(
unsigned int kk=0;
kk<descendants.size(); ++
kk){
401 if(kpp==descendants[
kk]) isIn =
true;
403 if( !isIn ) descendants.push_back(kpp);
407 nstop = descendants.size();
◆ initialize()
StatusCode DerivationFramework::HardTruthThinning::initialize |
( |
| ) |
|
|
overridevirtual |
◆ printxAODTruth()
Definition at line 417 of file HardTruthThinning.cxx.
420 std::vector<int> uidPars;
421 std::vector<int> uidKids;
423 std::cout <<
"======================================================================================\n" ;
424 std::cout <<
"xAODTruth Event " <<evnum <<
"\n";
425 std::cout <<
" Unique ID PDG Id Status px(GeV) py(GeV) pz(GeV) E(GeV) Parent: Decay\n" ;
426 std::cout <<
" -----------------------------------------------------------------------------------\n" ;
428 for (
const auto* tpItr : *truths) {
431 int id = tpItr->pdgId();
432 int stat = tpItr->status();
433 float px = tpItr->px()/
GeV;
434 float py = tpItr->py()/
GeV;
435 float pz = tpItr->pz()/
GeV;
436 float e = tpItr->e()/
GeV;
440 if( tpItr->hasProdVtx() ){
443 const std::vector< ElementLink< xAOD::TruthParticleContainer > >&
pars =
445 for(
unsigned int k=0;
k<
pars.size(); ++
k){
452 if( tpItr->hasDecayVtx() ){
455 const std::vector< ElementLink< xAOD::TruthParticleContainer > >& kids =
457 for(
unsigned int k=0;
k<kids.size(); ++
k){
458 if( ! (kids[
k]).isValid() )
continue;
465 std::cout <<
std::format(
"{:>10}{:>12}{:>8}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f} P: ",
467 for(
unsigned int k=0;
k<uidPars.size(); ++
k){
468 std::cout <<uidPars[
k] <<
" ";
471 for(
unsigned int k=0;
k<uidKids.size(); ++
k){
472 std::cout <<uidKids[
k] <<
" ";
476 std::cout <<
"======================================================================================" <<std::endl;
◆ m_errCount
std::atomic<int> DerivationFramework::HardTruthThinning::m_errCount {} |
|
mutableprivate |
◆ m_eventInfoKey
◆ m_evtCount
std::atomic<int> DerivationFramework::HardTruthThinning::m_evtCount {} |
|
mutableprivate |
◆ m_hardParticleKey
◆ m_isolPtCut
float DerivationFramework::HardTruthThinning::m_isolPtCut |
|
private |
◆ m_isolR
float DerivationFramework::HardTruthThinning::m_isolR |
|
private |
◆ m_jetConstPtCut
float DerivationFramework::HardTruthThinning::m_jetConstPtCut |
|
private |
◆ m_jetEtaCut
float DerivationFramework::HardTruthThinning::m_jetEtaCut |
|
private |
◆ m_jetPhotonPtCut
float DerivationFramework::HardTruthThinning::m_jetPhotonPtCut |
|
private |
◆ m_jetPtCut
float DerivationFramework::HardTruthThinning::m_jetPtCut |
|
private |
◆ m_keepIds
std::vector<int> DerivationFramework::HardTruthThinning::m_keepIds |
|
private |
◆ m_maxCount
int DerivationFramework::HardTruthThinning::m_maxCount |
|
private |
◆ m_streamName
StringProperty DerivationFramework::HardTruthThinning::m_streamName { this, "StreamName", "", "Name of the stream being thinned" } |
|
private |
◆ m_truthJetsKey
◆ m_truthParticleName
◆ m_truthVertexName
The documentation for this class was generated from the following files:
size_t nOutgoingParticles() const
Get the number of outgoing particles.
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetsKey
static void printxAODTruth(long long evnum, const xAOD::TruthParticleContainer *truths)
iterator end() const
iterator after the last constituent
std::atomic< int > m_evtCount
StringProperty m_streamName
static int getDescendants(const xAOD::TruthParticle *p, std::vector< const xAOD::TruthParticle * > &d)
std::atomic< int > m_errCount
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
bool empty() const
Test if the key is blank.
Class providing the definition of the 4-vector interface.
const TPLinks_t & outgoingParticleLinks() const
Get all the outgoing particles.
Handle for requesting thinning for a data object.
iterator begin() const
iterator on the first constituent
bool hasDecayVtx() const
Check for a decay vertex on this particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Class describing a truth particle in the MC record.
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
const IParticle * rawConstituent() const
Access the real underlying IParticle.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_hardParticleKey
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
Class describing a truth vertex in the MC record.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
#define ATH_MSG_WARNING(x)
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
SG::ThinningHandleKey< xAOD::TruthVertexContainer > m_truthVertexName
virtual double pt() const override final
The transverse momentum ( ) of the particle.
4-vector of jet constituent at the scale used during jet finding.
A vector of jet constituents at the scale used during jet finding.
SG::ThinningHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
std::vector< int > m_keepIds
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
const TPLinks_t & incomingParticleLinks() const
Get all the incoming particles.