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
ServiceHandle< IPartPropSvc > m_partPropSvc
 Get particle properties.
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 35 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 50 of file MCTrueSeedFinder.cxx.

50 :
51 base_class(t,n,p),
52 m_partPropSvc( "PartPropSvc", n ),
55 {
56 declareProperty("RemoveHardScattering", m_removeHardScattering, "Do not consider hard-scattering");
57 declareProperty("RemoveInTimePileUp", m_removeInTimePileUp, "Do not consider in-time pile-up");
58 declareProperty( "PartPropSvc", m_partPropSvc, "Handle to the particle property service" );
59 }
bool m_removeHardScattering
Flag to consider hard-scattering interaction.
ServiceHandle< IPartPropSvc > m_partPropSvc
Get particle properties.
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 108 of file MCTrueSeedFinder.cxx.

109 {
110 std::vector<Amg::Vector3D> seeds;
111 if( retrieveInteractionsInfo (seeds).isFailure() ) {
112 seeds.clear();
113 }
114
115 return seeds;
116 }
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 97 of file MCTrueSeedFinder.cxx.

98 {
99 std::vector<Amg::Vector3D> seeds;
100 if( retrieveInteractionsInfo (seeds).isFailure() ) {
101 seeds.clear();
102 }
103
104 return seeds;
105 }

◆ 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 74 of file MCTrueSeedFinder.cxx.

76 {
77 std::vector<Amg::Vector3D> seeds = findMultiSeeds (perigeeList, constraint);
78 if (seeds.empty()) {
79 return Amg::Vector3D(0.,0.,0.);
80 }
81 return seeds[0];
82 }
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 86 of file MCTrueSeedFinder.cxx.

88 {
89 std::vector<Amg::Vector3D> seeds = findMultiSeeds (vectorTrk, constraint);
90 if (seeds.empty()) {
91 return Amg::Vector3D(0.,0.,0.);
92 }
93 return seeds[0];
94 }

◆ initialize()

StatusCode Trk::MCTrueSeedFinder::initialize ( )
overridevirtual

Definition at line 66 of file MCTrueSeedFinder.cxx.

67 {
68 ATH_CHECK( m_mcEventCollectionKey.initialize() );
69 return StatusCode::SUCCESS;
70 }
#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 221 of file MCTrueSeedFinder.cxx.

222 {
223
224 // Check if the particle is coming from a "good" GenEvent:
225 if( ! pass( part->parent_event(), coll ) ) return false;
226
227 // Now check for stable particles
229 if( ! MC::isGenStable( part ) ) return false;
230 if( ! MC::isSimInteracting( part ) ) return false;
231 }
232
233 // finally require it to be charged
234 int pdg = part->pdg_id();
235
237 if( std::abs(pdg) < 7 || std::abs(pdg) == 21 ) return false;
238
239 const HepPDT::ParticleData* pd = m_partPropSvc->PDT()->particle( std::abs( pdg ) );
240 if( ! pd ) {
241 ATH_MSG_DEBUG( "Could not get particle data for = " << part
242 << " process id " <<HepMC::signal_process_id(part->parent_event()));
243 return false;
244 }
245 float charge = pd->charge();
246
247 return std::abs( charge ) >= 1E-5;
248 }
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
bool pass(const HepMC::GenEvent *evt, const McEventCollection *coll=0) const
Function selecting GenEvent objects.
int signal_process_id(const GenEvent &e)
Definition GenEvent.h:636
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....
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 179 of file MCTrueSeedFinder.cxx.

180 {
181
182 //we select in-time pile-up interactions and hard-scattering, if valid
183
184
185 bool isEmpty = ( evt->particles_size() == 0 );
186 bool isDummy = ( ( evt->event_number() == -1 ) &&
187 ( HepMC::signal_process_id(evt) == 0 ) );
188 if( isDummy ) isEmpty = false;
189
190 if( isEmpty ) return false;
191 if( isDummy ) return false;
192
193 // We can't do the further selection without the full truth record:
194 if( ! coll ) return true;
195
198
199 if( *iter == evt ) {
200 //this is the hard-scattering event (first of the collection)
201 return ! m_removeHardScattering;
202 }
203
204 int gotzero = 1;
205 for( ; iter != end; ++iter ) {
206 if( ( ( ( *iter )->event_number() == -1 ) &&
207 ( HepMC::signal_process_id( *iter ) == 0 ) ) ) {
208 ++gotzero;
209 }
210 if( evt == *iter ) break;
211 }
212
213 if( gotzero == 1 && m_removeInTimePileUp ) return false;
214 if( gotzero == 2 ) return false; //remove2BCPileUp
215 if( gotzero == 3 ) return false; //remove800nsPileUp
216 if( gotzero == 4 ) return false; //removeCavernBkg
217
218 return true;
219 }
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.

◆ retrieveInteractionsInfo()

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

Definition at line 119 of file MCTrueSeedFinder.cxx.

120 {
121 ATH_MSG_DEBUG("Retrieving interactions information");
122 msg(MSG::DEBUG) << "StoreGate Step: MCTrueSeedFinder retrieves -- " << m_mcEventCollectionKey.key() << endmsg;
123 SG::ReadHandle<McEventCollection> mcEventCollection( m_mcEventCollectionKey );
124 if ( !mcEventCollection.isValid() ) {
125 msg(MSG::DEBUG)
126 << "Could not retrieve McEventCollection/" << m_mcEventCollectionKey.key() << " from StoreGate." << endmsg;
127 return StatusCode::FAILURE;
128 }
129
130 interactions.clear();
131 std::vector<Interactions_pair> interactionsColl;
132 McEventCollection::const_iterator itr = mcEventCollection->begin();
133 for ( ; itr != mcEventCollection->end(); ++itr ) {
134 const HepMC::GenEvent* myEvent=(*itr);
135 if(!pass( myEvent, mcEventCollection.cptr())) continue; //checked if events is acceptable
136
137
138 //get "intensity" (scalar sum ot p_T^2)
139 double sum_pt2(0.0);
140 for (const auto& part: *myEvent) {
141 if(!pass(part, mcEventCollection.cptr())) continue; //select stable charged particles
142 sum_pt2 += part->momentum().perp2();
143 }
144 ATH_MSG_DEBUG("Calculated Sum P_T^2 = " << sum_pt2);
145
146 //get position of interaction from first non-zero vertex
147 Amg::Vector3D vtxPosition;
148#ifdef HEPMC3
149 auto Vert = myEvent->vertices().begin();
150#else
151 HepMC::GenEvent::vertex_const_iterator Vert = myEvent->vertices_begin();
152#endif
153 msg(MSG::DEBUG) << "Retrieved position x: " << (*Vert)->position().x() <<
154 " y: " << (*Vert)->position().y() <<
155 " z: " << (*Vert)->position().z() << endmsg;
156 vtxPosition = Amg::Vector3D((*Vert)->position().x(),
157 (*Vert)->position().y(),
158 (*Vert)->position().z());
159
160 //now store info about position and "intensity" (here: scalar sum of p_T^2)
161 interactionsColl.emplace_back(sum_pt2, vtxPosition );
162 } // end loop over GenEvent
163
164 //now sort the container and store results to interactions
165 std::sort(interactionsColl.begin(), interactionsColl.end());
166 std::vector<Interactions_pair>::iterator itIp = interactionsColl.begin();
167 ATH_MSG_DEBUG("Sorted collection:");
168 for (; itIp < interactionsColl.end(); ++itIp) {
169 interactions.push_back(itIp->second);
170 ATH_MSG_DEBUG("(" << itIp->second.x() << ", " << itIp->second.y() << ", "
171 << itIp->second.z() << "), SumPt2 = " << itIp->first);
172 }
173
174 ATH_MSG_DEBUG("New interactions info stored successfully: " << interactions.size() << " interactions found.");
175 return StatusCode::SUCCESS;
176
177 }
#define endmsg
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 95 of file MCTrueSeedFinder.h.

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

◆ m_partPropSvc

ServiceHandle< IPartPropSvc > Trk::MCTrueSeedFinder::m_partPropSvc
private

Get particle properties.

Definition at line 103 of file MCTrueSeedFinder.h.

◆ m_removeHardScattering

bool Trk::MCTrueSeedFinder::m_removeHardScattering
private

Flag to consider hard-scattering interaction.

Definition at line 107 of file MCTrueSeedFinder.h.

◆ m_removeInTimePileUp

bool Trk::MCTrueSeedFinder::m_removeInTimePileUp
private

Flag to consider in-time pile-up interactions.

Definition at line 106 of file MCTrueSeedFinder.h.


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