ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual Amg::Vector3D findSeed (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const=0
 Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object. More...
 
virtual Amg::Vector3D findSeed (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const=0
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object. More...
 
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. More...
 
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. More...
 

Private Member Functions

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

Private Attributes

SG::ReadHandleKey< McEventCollectionm_mcEventCollectionKey
 
ServiceHandle< IPartPropSvc > m_partPropSvc
 Get particle properties. More...
 
bool m_removeInTimePileUp
 Flag to consider in-time pile-up interactions. More...
 
bool m_removeHardScattering
 Flag to consider hard-scattering interaction. More...
 

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 ),
53  m_removeInTimePileUp(false),
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  }

◆ ~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  }

◆ 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/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed
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  }

◆ findSeed() [2/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed
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/6]

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  }

◆ findSeed() [4/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed

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.

◆ findSeed() [5/6]

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  }

◆ findSeed() [6/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed

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.

◆ initialize()

StatusCode Trk::MCTrueSeedFinder::initialize ( )
overridevirtual

Definition at line 66 of file MCTrueSeedFinder.cxx.

67  {
69  return StatusCode::SUCCESS;
70  }

◆ 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  }

◆ 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  }

◆ 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;
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  }

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.

◆ 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:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadHandle< McEventCollection >
HepMC::signal_process_id
int signal_process_id(const GenEvent &e)
Definition: GenEvent.h:635
Trk::MCTrueSeedFinder::findMultiSeeds
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 ...
Definition: MCTrueSeedFinder.cxx:108
makeDTCalibBlob_pickPhase.pd
pd
Definition: makeDTCalibBlob_pickPhase.py:342
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::MCTrueSeedFinder::m_mcEventCollectionKey
SG::ReadHandleKey< McEventCollection > m_mcEventCollectionKey
Definition: MCTrueSeedFinder.h:95
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
MC::isGenStable
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
Definition: HepMCHelpers.h:54
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
HepMC::is_simulation_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...
Definition: MagicNumbers.h:355
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::MCTrueSeedFinder::pass
bool pass(const HepMC::GenEvent *evt, const McEventCollection *coll=0) const
Function selecting GenEvent objects.
Definition: MCTrueSeedFinder.cxx:179
Trk::MCTrueSeedFinder::m_partPropSvc
ServiceHandle< IPartPropSvc > m_partPropSvc
Get particle properties.
Definition: MCTrueSeedFinder.h:103
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
Trk::MCTrueSeedFinder::m_removeInTimePileUp
bool m_removeInTimePileUp
Flag to consider in-time pile-up interactions.
Definition: MCTrueSeedFinder.h:106
Trk::MCTrueSeedFinder::m_removeHardScattering
bool m_removeHardScattering
Flag to consider hard-scattering interaction.
Definition: MCTrueSeedFinder.h:107
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trk::MCTrueSeedFinder::findSeed
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.
Definition: MCTrueSeedFinder.cxx:74
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::MCTrueSeedFinder::retrieveInteractionsInfo
StatusCode retrieveInteractionsInfo(std::vector< Amg::Vector3D > &interactions) const
Definition: MCTrueSeedFinder.cxx:119
MC::isSimInteracting
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
Definition: HepMCHelpers.h:60
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.