|
ATLAS Offline Software
|
#include <HardTruthThinning.h>
|
SG::ReadHandleKey< xAOD::EventInfo > | m_evt {this, "EvtInfo", "EventInfo", "EventInfo 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" } |
|
std::string | m_hardParticleName |
|
std::string | m_jetName |
|
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 49 of file HardTruthThinning.h.
◆ HardTruthThinning()
DerivationFramework::HardTruthThinning::HardTruthThinning |
( |
const std::string & |
t, |
|
|
const std::string & |
n, |
|
|
const IInterface * |
p |
|
) |
| |
Definition at line 45 of file HardTruthThinning.cxx.
57 "hard particle container name");
60 "truth jet container name");
63 "truth jet minumum pt");
66 "truth jet maximum abs(eta)");
69 "jet constituent minimum pt");
72 "jet constituent photon minimum pt");
75 "list of abs(pdgID) to keep");
77 declareProperty(
"IsolRadius",
m_isolR,
78 "isolation radius for leptons and photons");
81 "isolation particle minimum pt");
83 declareProperty(
"MaxCount",
85 "maximum number of events to print");
◆ ~HardTruthThinning()
DerivationFramework::HardTruthThinning::~HardTruthThinning |
( |
| ) |
|
|
virtual |
◆ doThinning()
StatusCode DerivationFramework::HardTruthThinning::doThinning |
( |
| ) |
const |
|
overridevirtual |
Definition at line 134 of file HardTruthThinning.cxx.
136 const EventContext& ctx = Gaudi::Hive::currentContext();
146 return StatusCode::FAILURE;
148 long long int evtNum =
evt->eventNumber();
164 return StatusCode::FAILURE;
172 std::vector<const xAOD::TruthParticle*> hardPart;
173 std::vector<TLorentzVector> pLepGam;
175 pItr = inHardParts->
begin();
176 pItrE = inHardParts->
end();
177 for(; pItr!=pItrE; ++pItr){
179 hardPart.push_back(*pItr);
181 int ida = abs( (*pItr)->pdgId() );
182 if( ida==11 || ida==13 || ida==15 || ida==22 ){
183 pLepGam.push_back( (*pItr)->p4() );
199 std::vector<bool> partMask;
200 std::vector<bool> vertMask;
201 unsigned int inPartNum = inTruthParts->size();
202 unsigned int inVertNum = inTruthVerts->size();
203 partMask.assign(inPartNum,
false);
204 vertMask.assign(inVertNum,
false);
206 ATH_MSG_DEBUG(
"Initial particles/vertices = " <<inPartNum <<
" " <<inVertNum);
215 pItr = inTruthParts->begin();
216 pItrE = inTruthParts->end();
217 std::vector<const xAOD::TruthParticle*> kids;
219 for(; pItr!=pItrE; ++pItr){
224 for(
unsigned int i=0;
i<hardPart.size(); ++
i){
227 if( (*pItr)->pdgId() != (hardPart[
i])->pdgId() ){
231 <<
" " <<(hardPart[
i])->pdgId());
239 partMask[ (*pItr)->index() ] =
true;
243 int ida = abs((*pItr)->pdgId());
253 partMask[(*pItr)->index()] =
true;
256 for(
int i=0;
i<nkids; ++
i){
259 partMask[ (kids[
i])->
index() ] =
true;
261 if(
v ) vertMask[
v->index() ] =
true;
266 if( !pLepGam.empty() && (*pItr)->pt() >
m_isolPtCut ){
267 TLorentzVector pp4 = (*pItr)->p4();
268 for(
unsigned int lep=0; lep<pLepGam.size(); ++lep){
269 double r = pp4.DeltaR( pLepGam[lep] );
272 partMask[ (*pItr)->index() ] =
true;
290 return StatusCode::FAILURE;
293 std::vector<int> uidJetConst;
295 for(
unsigned int j=0; j<inJets->
size(); ++j){
303 for( ; aItr != aItrE; ++aItr){
321 pItr = inTruthParts->begin();
322 pItrE = inTruthParts->end();
323 for(; pItr!=pItrE; ++pItr){
326 for(
unsigned int i=0;
i<uidJetConst.size(); ++
i){
327 if( uid == uidJetConst[
i] ){
334 partMask[ (*pItr)->index() ] =
true;
342 inTruthParts.keep (partMask);
343 inTruthVerts.keep (vertMask);
347 for(
unsigned int i=0;
i<partMask.size(); ++
i){
348 if( partMask[
i] ) ++outPartNum;
351 for(
unsigned int i=0;
i<vertMask.size(); ++
i){
352 if( vertMask[
i] ) ++outVertNum;
355 ATH_MSG_DEBUG(
"Final particles/vertices = " <<outPartNum <<
" " <<outVertNum);
358 std::cout <<
"======================================================================================" <<std::endl;
359 std::cout <<
"HardTruthThinning complete for event " <<evtNum <<std::endl;
360 std::cout <<
"Saved " <<outPartNum <<
" particles" <<std::endl;
361 std::cout <<
"Particle unique IDs = ";
362 for(
unsigned int i=0;
i<partMask.size(); ++
i){
365 std::cout <<std::endl;
367 std::cout <<
"Saved " <<outVertNum <<
" vertices" <<std::endl;
368 std::cout <<
"Vertex unique IDs = ";
369 for(
unsigned int i=0;
i<vertMask.size(); ++
i){
372 std::cout <<std::endl;
373 std::cout <<
"======================================================================================" <<std::endl;
376 return StatusCode::SUCCESS;
◆ finalize()
StatusCode DerivationFramework::HardTruthThinning::finalize |
( |
| ) |
|
|
overridevirtual |
◆ getDescendants()
Definition at line 390 of file HardTruthThinning.cxx.
394 if( ! (
p->hasDecayVtx()) )
return 0;
396 if( !dvtx )
return 0;
399 const std::vector< ElementLink< xAOD::TruthParticleContainer > >& outPart =
401 for(
unsigned int k=0;
k<outPart.size(); ++
k){
402 if( ! (outPart[
k]).
isValid() )
continue;
404 descendants.push_back(kid);
408 int nstop = descendants.size();
410 while( nstop > nstart ){
411 for(
int i=nstart;
i<nstop; ++
i){
418 const std::vector< ElementLink< xAOD::TruthParticleContainer > >&
420 for(
unsigned int k=0;
k<outPart2.size(); ++
k){
421 if( ! (outPart2[
k]).isValid() )
continue;
425 for(
unsigned int kk=0;
kk<descendants.size(); ++
kk){
426 if(kpp==descendants[
kk]) isIn =
true;
428 if( !isIn ) descendants.push_back(kpp);
432 nstop = descendants.size();
◆ initialize()
StatusCode DerivationFramework::HardTruthThinning::initialize |
( |
| ) |
|
|
overridevirtual |
◆ printxAODTruth()
Definition at line 442 of file HardTruthThinning.cxx.
447 std::vector<int> uidPars;
448 std::vector<int> uidKids;
450 std::cout <<
"======================================================================================" <<std::endl;
451 std::cout <<
"xAODTruth Event " <<evnum <<std::endl;
452 std::cout <<
" Unique ID PDG Id Status px(GeV) py(GeV) pz(GeV) E(GeV) Parent: Decay" <<std::endl;
453 std::cout <<
" -----------------------------------------------------------------------------------" <<std::endl;
455 for(; tpItr != tpItrE; ++tpItr ) {
458 int id = (*tpItr)->pdgId();
459 int stat = (*tpItr)->status();
460 float px = (*tpItr)->px()/1000.;
461 float py = (*tpItr)->py()/1000.;
462 float pz = (*tpItr)->pz()/1000.;
463 float e = (*tpItr)->e()/1000.;
467 if( (*tpItr)->hasProdVtx() ){
470 const std::vector< ElementLink< xAOD::TruthParticleContainer > >&
pars =
472 for(
unsigned int k=0;
k<
pars.size(); ++
k){
479 if( (*tpItr)->hasDecayVtx() ){
482 const std::vector< ElementLink< xAOD::TruthParticleContainer > >& kids =
484 for(
unsigned int k=0;
k<kids.size(); ++
k){
485 if( ! (kids[
k]).isValid() )
continue;
492 std::cout <<std::setw(10)<<uid <<std::setw(12)<<
id
494 <<std::setprecision(2)<<std::fixed
495 <<std::setw(10)<<
px <<std::setw(10)<<
py
496 <<std::setw(10)<<
pz <<std::setw(10)<<
e <<
" ";
498 for(
unsigned int k=0;
k<uidPars.size(); ++
k){
499 std::cout <<uidPars[
k] <<
" ";
502 for(
unsigned int k=0;
k<uidKids.size(); ++
k){
503 std::cout <<uidKids[
k] <<
" ";
505 std::cout <<std::endl;
507 std::cout <<
"======================================================================================" <<std::endl;
◆ m_errCount
std::atomic<int> DerivationFramework::HardTruthThinning::m_errCount {} |
|
mutableprivate |
◆ m_evt
◆ m_evtCount
std::atomic<int> DerivationFramework::HardTruthThinning::m_evtCount {} |
|
mutableprivate |
◆ m_hardParticleName
std::string DerivationFramework::HardTruthThinning::m_hardParticleName |
|
private |
◆ 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_jetName
std::string DerivationFramework::HardTruthThinning::m_jetName |
|
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_truthParticleName
◆ m_truthVertexName
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
size_t nOutgoingParticles() const
Get the number of outgoing particles.
Const iterator class for DataVector/DataList.
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)
SG::ReadHandleKey< xAOD::EventInfo > m_evt
std::atomic< int > m_errCount
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
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...
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.
virtual double eta() const
The pseudorapidity ( ) of the particle.
std::string m_hardParticleName
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
Class describing a truth vertex in the MC record.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
#define ATH_MSG_WARNING(x)
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
int pdgId() const
PDG ID code.
virtual double pt() const
The transverse momentum ( ) of the particle.
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const TPLinks_t & incomingParticleLinks() const
Get all the incoming particles.