ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::MCTrueSeedFinder Class Referencefinal

#include <MCTrueSeedFinder.h>

Inheritance diagram for Trk::MCTrueSeedFinder:
Collaboration diagram for Trk::MCTrueSeedFinder:

Public Member Functions

 MCTrueSeedFinder (const std::string &t, const std::string &n, const IInterface *p)
virtual ~MCTrueSeedFinder ()
virtual StatusCode initialize () override
virtual Amg::Vector3D findSeed (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual std::vector< Amg::Vector3DfindMultiSeeds (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
 Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D object.
virtual std::vector< Amg::Vector3DfindMultiSeeds (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds full vector of linearization points from a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const double, const double, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const double, const double, std::unique_ptr< Trk::IMode3dInfo > &, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

Private Member Functions

bool pass (const HepMC::GenEvent *evt, const McEventCollection *coll=0) const
 Function selecting GenEvent objects.
bool pass (const HepMC::ConstGenParticlePtr &part, const McEventCollection *coll=0) const
 Function selecting GenParticle objects.
StatusCode retrieveInteractionsInfo (std::vector< Amg::Vector3D > &interactions) const

Private Attributes

SG::ReadHandleKey< McEventCollectionm_mcEventCollectionKey
bool m_removeInTimePileUp
 Flag to consider in-time pile-up interactions.
bool m_removeHardScattering
 Flag to consider hard-scattering interaction.

Detailed Description

Definition at line 34 of file MCTrueSeedFinder.h.

Constructor & Destructor Documentation

◆ MCTrueSeedFinder()

Trk::MCTrueSeedFinder::MCTrueSeedFinder ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 44 of file MCTrueSeedFinder.cxx.

44 :
45 base_class(t,n,p),
48 {
49 declareProperty("RemoveHardScattering", m_removeHardScattering, "Do not consider hard-scattering");
50 declareProperty("RemoveInTimePileUp", m_removeInTimePileUp, "Do not consider in-time pile-up");
51 }
bool m_removeHardScattering
Flag to consider hard-scattering interaction.
bool m_removeInTimePileUp
Flag to consider in-time pile-up interactions.

◆ ~MCTrueSeedFinder()

Trk::MCTrueSeedFinder::~MCTrueSeedFinder ( )
virtualdefault

Member Function Documentation

◆ findMultiSeeds() [1/2]

std::vector< Amg::Vector3D > Trk::MCTrueSeedFinder::findMultiSeeds ( const std::vector< const Trk::Track * > & vectorTrk,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D object.

Intended for seed finders that produce all at once. If you want an additional constraint can be taken into account.

Definition at line 100 of file MCTrueSeedFinder.cxx.

101 {
102 std::vector<Amg::Vector3D> seeds;
103 if( retrieveInteractionsInfo (seeds).isFailure() ) {
104 seeds.clear();
105 }
106
107 return seeds;
108 }
StatusCode retrieveInteractionsInfo(std::vector< Amg::Vector3D > &interactions) const

◆ findMultiSeeds() [2/2]

std::vector< Amg::Vector3D > Trk::MCTrueSeedFinder::findMultiSeeds ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds full vector of linearization points from a vector of TrackParameters and returns it as an Amg::Vector3D object.

Intended for seed finders that produce all at once. If you want an additional constraint can be taken into account.

Definition at line 89 of file MCTrueSeedFinder.cxx.

90 {
91 std::vector<Amg::Vector3D> seeds;
92 if( retrieveInteractionsInfo (seeds).isFailure() ) {
93 seeds.clear();
94 }
95
96 return seeds;
97 }

◆ findSeed() [1/4]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed ( const double ,
const double ,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
inline

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account. Must specify the primary vertex position.

Definition at line 79 of file IVertexSeedFinder.h.

83 {
84 return findSeed (perigeeList, constraint);
85 }
virtual Amg::Vector3D findSeed(const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.

◆ findSeed() [2/4]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed ( const double ,
const double ,
std::unique_ptr< Trk::IMode3dInfo > & ,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
inline

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account. Must specify the primary vertex position. Allows returning additional diagnostic information.

Definition at line 96 of file IVertexSeedFinder.h.

101 {
102 return findSeed (perigeeList, constraint);
103 }

◆ findSeed() [3/4]

Amg::Vector3D Trk::MCTrueSeedFinder::findSeed ( const std::vector< const Trk::Track * > & vectorTrk,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account.

Definition at line 66 of file MCTrueSeedFinder.cxx.

68 {
69 std::vector<Amg::Vector3D> seeds = findMultiSeeds (perigeeList, constraint);
70 if (seeds.empty()) {
71 return Amg::Vector3D(0.,0.,0.);
72 }
73 return seeds[0];
74 }
virtual std::vector< Amg::Vector3D > findMultiSeeds(const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D ...
Eigen::Matrix< double, 3, 1 > Vector3D

◆ findSeed() [4/4]

Amg::Vector3D Trk::MCTrueSeedFinder::findSeed ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account.

Definition at line 78 of file MCTrueSeedFinder.cxx.

80 {
81 std::vector<Amg::Vector3D> seeds = findMultiSeeds (vectorTrk, constraint);
82 if (seeds.empty()) {
83 return Amg::Vector3D(0.,0.,0.);
84 }
85 return seeds[0];
86 }

◆ initialize()

StatusCode Trk::MCTrueSeedFinder::initialize ( )
overridevirtual

Definition at line 58 of file MCTrueSeedFinder.cxx.

59 {
60 ATH_CHECK( m_mcEventCollectionKey.initialize() );
61 return StatusCode::SUCCESS;
62 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< McEventCollection > m_mcEventCollectionKey

◆ pass() [1/2]

bool Trk::MCTrueSeedFinder::pass ( const HepMC::ConstGenParticlePtr & part,
const McEventCollection * coll = 0 ) const
private

Function selecting GenParticle objects.

remove gluons and quarks of status 2 that pass IsGenStable!!!

Definition at line 209 of file MCTrueSeedFinder.cxx.

210 {
211
212 // Check if the particle is coming from a "good" GenEvent:
213 if( ! pass( part->parent_event(), coll ) ) return false;
214
215 // Now check for stable particles
217 if( ! MC::isGenStable( part ) ) return false;
218 if( ! MC::isSimInteracting( part ) ) return false;
219 }
220
221 // finally require it to be charged
222 int pdg = part->pdg_id();
223
225 if( std::abs(pdg) < 7 || std::abs(pdg) == 21 ) return false;
226
227 float charge = MC::charge(pdg);
228
229 return std::abs( charge ) >= 1E-5;
230 }
double charge(const T &p)
Definition AtlasPID.h:997
bool pass(const HepMC::GenEvent *evt, const McEventCollection *coll=0) const
Function selecting GenEvent objects.
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 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,.

◆ pass() [2/2]

bool Trk::MCTrueSeedFinder::pass ( const HepMC::GenEvent * evt,
const McEventCollection * coll = 0 ) const
private

Function selecting GenEvent objects.

Definition at line 167 of file MCTrueSeedFinder.cxx.

168 {
169
170 //we select in-time pile-up interactions and hard-scattering, if valid
171
172
173 bool isEmpty = ( evt->particles_size() == 0 );
174 bool isDummy = ( ( evt->event_number() == -1 ) &&
175 ( HepMC::signal_process_id(evt) == 0 ) );
176 if( isDummy ) isEmpty = false;
177
178 if( isEmpty ) return false;
179 if( isDummy ) return false;
180
181 // We can't do the further selection without the full truth record:
182 if( ! coll ) return true;
183
186
187 if( *iter == evt ) {
188 //this is the hard-scattering event (first of the collection)
189 return ! m_removeHardScattering;
190 }
191
192 int gotzero = 1;
193 for( ; iter != end; ++iter ) {
194 if( ( ( ( *iter )->event_number() == -1 ) &&
195 ( HepMC::signal_process_id( *iter ) == 0 ) ) ) {
196 ++gotzero;
197 }
198 if( evt == *iter ) break;
199 }
200
201 if( gotzero == 1 && m_removeInTimePileUp ) return false;
202 if( gotzero == 2 ) return false; //remove2BCPileUp
203 if( gotzero == 3 ) return false; //remove800nsPileUp
204 if( gotzero == 4 ) return false; //removeCavernBkg
205
206 return true;
207 }
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
int signal_process_id(const GenEvent &evt)
Definition GenEvent.h:572

◆ retrieveInteractionsInfo()

StatusCode Trk::MCTrueSeedFinder::retrieveInteractionsInfo ( std::vector< Amg::Vector3D > & interactions) const
private

Definition at line 111 of file MCTrueSeedFinder.cxx.

112 {
113 ATH_MSG_DEBUG("Retrieving interactions information");
114 msg(MSG::DEBUG) << "StoreGate Step: MCTrueSeedFinder retrieves -- " << m_mcEventCollectionKey.key() << endmsg;
115 SG::ReadHandle<McEventCollection> mcEventCollection( m_mcEventCollectionKey );
116 if ( !mcEventCollection.isValid() ) {
117 msg(MSG::DEBUG)
118 << "Could not retrieve McEventCollection/" << m_mcEventCollectionKey.key() << " from StoreGate." << endmsg;
119 return StatusCode::FAILURE;
120 }
121
122 interactions.clear();
123 std::vector<Interactions_pair> interactionsColl;
124 McEventCollection::const_iterator itr = mcEventCollection->begin();
125 for ( ; itr != mcEventCollection->end(); ++itr ) {
126 const HepMC::GenEvent* myEvent=(*itr);
127 if(!pass( myEvent, mcEventCollection.cptr())) continue; //checked if events is acceptable
128
129
130 //get "intensity" (scalar sum ot p_T^2)
131 double sum_pt2(0.0);
132 for (const auto& part: *myEvent) {
133 if(!pass(part, mcEventCollection.cptr())) continue; //select stable charged particles
134 sum_pt2 += part->momentum().perp2();
135 }
136 ATH_MSG_DEBUG("Calculated Sum P_T^2 = " << sum_pt2);
137
138 //get position of interaction from first non-zero vertex
139 Amg::Vector3D vtxPosition;
140 auto Vert = myEvent->vertices().begin();
141 msg(MSG::DEBUG) << "Retrieved position x: " << (*Vert)->position().x() <<
142 " y: " << (*Vert)->position().y() <<
143 " z: " << (*Vert)->position().z() << endmsg;
144 vtxPosition = Amg::Vector3D((*Vert)->position().x(),
145 (*Vert)->position().y(),
146 (*Vert)->position().z());
147
148 //now store info about position and "intensity" (here: scalar sum of p_T^2)
149 interactionsColl.emplace_back(sum_pt2, vtxPosition );
150 } // end loop over GenEvent
151
152 //now sort the container and store results to interactions
153 std::sort(interactionsColl.begin(), interactionsColl.end());
154 std::vector<Interactions_pair>::iterator itIp = interactionsColl.begin();
155 ATH_MSG_DEBUG("Sorted collection:");
156 for (; itIp < interactionsColl.end(); ++itIp) {
157 interactions.push_back(itIp->second);
158 ATH_MSG_DEBUG("(" << itIp->second.x() << ", " << itIp->second.y() << ", "
159 << itIp->second.z() << "), SumPt2 = " << itIp->first);
160 }
161
162 ATH_MSG_DEBUG("New interactions info stored successfully: " << interactions.size() << " interactions found.");
163 return StatusCode::SUCCESS;
164
165 }
#define endmsg
#define ATH_MSG_DEBUG(x)
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
MsgStream & msg
Definition testRead.cxx:32

Member Data Documentation

◆ m_mcEventCollectionKey

SG::ReadHandleKey<McEventCollection> Trk::MCTrueSeedFinder::m_mcEventCollectionKey
private
Initial value:
{
this,
"McTruthCollection",
"G4Truth",
"MC Event Collection Name"
}

Definition at line 94 of file MCTrueSeedFinder.h.

94 {
95 this,
96 "McTruthCollection",
97 "G4Truth",
98 "MC Event Collection Name"
99 };

◆ m_removeHardScattering

bool Trk::MCTrueSeedFinder::m_removeHardScattering
private

Flag to consider hard-scattering interaction.

Definition at line 103 of file MCTrueSeedFinder.h.

◆ m_removeInTimePileUp

bool Trk::MCTrueSeedFinder::m_removeInTimePileUp
private

Flag to consider in-time pile-up interactions.

Definition at line 102 of file MCTrueSeedFinder.h.


The documentation for this class was generated from the following files: