ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DerivationFramework::EGammaTracksThinning Class Reference

#include <EGammaTracksThinning.h>

Inheritance diagram for DerivationFramework::EGammaTracksThinning:
Collaboration diagram for DerivationFramework::EGammaTracksThinning:

Public Member Functions

 EGammaTracksThinning (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~EGammaTracksThinning ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 

Private Member Functions

std::set< int > findGoodTracks (const TrackCollection *trackCont, const TLorentzVector &candHepLorentz, double maxDeltaR) const
 
StatusCode thinTracks (SG::ThinningHandle< TrackCollection > &trackCont, const std::set< int > &goodTracks) const
 

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ReadHandleKey< xAOD::ElectronContainerm_electronsContainerKey { this, "electronContainerName", "Electrons", "" }
 
SG::ReadHandleKey< xAOD::PhotonContainerm_photonsContainerKey { this, "photonContainerName", "Photons", ""}
 
SG::ThinningHandleKey< TrackCollectionm_tracksCollectionName { this, "tracksCollectionName", "Tracks", "" }
 
Gaudi::Property< double > m_dr { this, "deltaR", 0.5, "" }
 
Gaudi::Property< double > m_minEtEg { this, "minEtEg", 0,""}
 

Detailed Description

Definition at line 30 of file EGammaTracksThinning.h.

Constructor & Destructor Documentation

◆ EGammaTracksThinning()

DerivationFramework::EGammaTracksThinning::EGammaTracksThinning ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 10 of file EGammaTracksThinning.cxx.

12  :
13  base_class(type, name, parent)
14 {}

◆ ~EGammaTracksThinning()

virtual DerivationFramework::EGammaTracksThinning::~EGammaTracksThinning ( )
inlinevirtual

Definition at line 38 of file EGammaTracksThinning.h.

38 {}

Member Function Documentation

◆ doThinning()

StatusCode DerivationFramework::EGammaTracksThinning::doThinning ( ) const
overridevirtual

Definition at line 29 of file EGammaTracksThinning.cxx.

30 {
31  const EventContext& ctx = Gaudi::Hive::currentContext();
32 
33  // retrieve the tracks collection
34 
37  ATH_MSG_DEBUG( "Container '" << m_tracksCollectionName.key() << "' retrieved from StoreGate" );
38 
39  // retrieve the electron collection
40 
42  if ( !electronContainer.isValid() )
43  {
44  ATH_MSG_WARNING( "Container '" << m_electronsContainerKey.key()
45  << "' could not be retrieved from StoreGate!" );
46  return StatusCode::FAILURE;
47  }
48  else
49  {
50  ATH_MSG_DEBUG( "Container '" << m_electronsContainerKey.key()
51  << "' retrieved from StoreGate" );
52  }
53 
54  // retrieve the photon collection
55 
57  if ( !photonContainer.isValid() )
58  {
59  ATH_MSG_WARNING( "Container '" << m_photonsContainerKey.key()
60  << "' could not be retrieved from StoreGate!" );
61  return StatusCode::FAILURE;
62  }
63  else
64  {
65  ATH_MSG_DEBUG( "Container '" << m_photonsContainerKey.key()
66  << "' retrieved from StoreGate" );
67  }
68 
69  // loop over electrons and for each electron mark the interesting tracks
70 
71  std::set<int> goodTrackIDs;
72 
75  for (; eleItr != eleItrEnd; ++eleItr)
76  {
77  if ( (*eleItr)->pt() > m_minEtEg )
78  {
79 
80  ATH_MSG_DEBUG( "Electron at eta = " << (*eleItr)->eta() << " phi = " << (*eleItr)->phi() );
81 
82  // get the list of tracks associated to this object
83 
84  std::set<int> eg_trackList = findGoodTracks(trackCollection.cptr(), (*eleItr)->p4(), m_dr );
85 
86  // update the global list of tracks to keep
87 
88  goodTrackIDs.insert(eg_trackList.begin() , eg_trackList.end() ) ;
89 
90  }
91 
92  }
93 
94  // loop over photons and for each photon mark the interesting tracks
95 
98  for (; phoItr != phoItrEnd; ++phoItr)
99  {
100  if ( (*phoItr)->pt() > m_minEtEg )
101  {
102 
103  ATH_MSG_DEBUG( "Photon at eta = " << (*phoItr)->eta() << " phi = " << (*phoItr)->phi() );
104 
105  // get the list of tracks associated to this object
106 
107  std::set<int> eg_trackList = findGoodTracks(trackCollection.cptr(), (*phoItr)->p4(), m_dr );
108 
109  // update the global list of tracks to keep
110 
111  goodTrackIDs.insert(eg_trackList.begin() , eg_trackList.end() ) ;
112 
113  }
114 
115  }
116 
117  // now do the real thinning and keep all marked tracks
118 
119  ATH_CHECK( thinTracks( trackCollection, goodTrackIDs ) );
120 
121  ATH_MSG_DEBUG( "Track thinning : tracks = " << trackCollection->size()
122  << " accepted = " << goodTrackIDs.size() );
123 
124  return StatusCode::SUCCESS;
125 }

◆ finalize()

StatusCode DerivationFramework::EGammaTracksThinning::finalize ( )
overridevirtual

Definition at line 24 of file EGammaTracksThinning.cxx.

24  {
25 
26  return StatusCode::SUCCESS;
27 }

◆ findGoodTracks()

std::set< int > DerivationFramework::EGammaTracksThinning::findGoodTracks ( const TrackCollection trackCont,
const TLorentzVector &  candHepLorentz,
double  maxDeltaR 
) const
private

Definition at line 132 of file EGammaTracksThinning.cxx.

135 {
136 
137  std::set<int> goodTracks;
138 
139  TrackCollection::const_iterator trackItr = trackCont->begin();
140  TrackCollection::const_iterator trackItrEnd = trackCont->end();
141  long int i=0; // This is the counter...
142  for (; trackItr != trackItrEnd; ++trackItr)
143  {
144  const Trk::Track* track = (*trackItr);
145 
146  if (!track){ continue; }
147 
148  // use track eta/phi at perigee
149 
150  double trketa = 0.,trkphi = 0;
151  const Trk::Perigee* startPerigee = track->perigeeParameters();
152  trketa = startPerigee->eta();
153  trkphi = startPerigee->parameters()[Trk::phi0];
154 
155  double deltaEta = trketa - candHepLorentz.Eta() ;
156  double deltaPhi = P4Helpers::deltaPhi(trkphi, candHepLorentz.Phi() );
157  double deltaR = sqrt(deltaEta*deltaEta+deltaPhi*deltaPhi);
158 
159  ATH_MSG_DEBUG( "Thin Tracks: eta = " << trketa << " phi = " << trkphi << " deltaR = " << deltaR );
160  if ( deltaR < maxDeltaR )
161  {
162  goodTracks.insert( i );
163  ATH_MSG_DEBUG( " Track in the cone, adding: " << " eta=" << trketa << " phi=" << trkphi );
164  }
165 
166  ++i; // Increment the counter
167 
168  }
169 
170  return goodTracks;
171 
172 }

◆ initialize()

StatusCode DerivationFramework::EGammaTracksThinning::initialize ( )
overridevirtual

Definition at line 16 of file EGammaTracksThinning.cxx.

16  {
17 
19  ATH_CHECK( m_photonsContainerKey.initialize() );
21  return StatusCode::SUCCESS;
22 }

◆ thinTracks()

StatusCode DerivationFramework::EGammaTracksThinning::thinTracks ( SG::ThinningHandle< TrackCollection > &  trackCont,
const std::set< int > &  goodTracks 
) const
private

Return

Definition at line 179 of file EGammaTracksThinning.cxx.

181 {
182 
183  ATH_MSG_DEBUG( "==> thinTracks " << name() << "..." );
184 
185  // Declare the simple StatusCode
186  StatusCode sc(StatusCode::SUCCESS);
187 
188  // First, create the mask to be used for thinning
189 
190  std::vector<bool> mask(trackCollection->size());
191 
192  // Create also some bookkeeping counters
193  unsigned long nTotal = 0;
194  unsigned long nKeep = 0;
195  unsigned long nReject = 0;
196 
197  // loop over tracks
198 
199  for ( std::size_t i=0; i<trackCollection->size(); ++i )
200  {
201  ++nTotal;
202  if ( goodTrackIDs.find( i ) != goodTrackIDs.end() )
203  {
204  mask[i] = true;
205  ++nKeep;
206  }
207  else
208  {
209  mask[i] = false;
210  ++nReject;
211  }
212  } // End loop over Tracks
213 
214  // Write out a statistics message
215  ATH_MSG_DEBUG( " EGammaTracksThinning statistics: tracks processed " << nTotal
216  << " kept = " << nKeep
217  << " rejected " << nReject );
218 
219  // Perform the actual thinning
220  trackCollection.thin (mask);
221 
223  return sc;
224 
225 }

Member Data Documentation

◆ m_dr

Gaudi::Property<double> DerivationFramework::EGammaTracksThinning::m_dr { this, "deltaR", 0.5, "" }
private

Definition at line 53 of file EGammaTracksThinning.h.

◆ m_electronsContainerKey

SG::ReadHandleKey<xAOD::ElectronContainer> DerivationFramework::EGammaTracksThinning::m_electronsContainerKey { this, "electronContainerName", "Electrons", "" }
private

Definition at line 47 of file EGammaTracksThinning.h.

◆ m_minEtEg

Gaudi::Property<double> DerivationFramework::EGammaTracksThinning::m_minEtEg { this, "minEtEg", 0,""}
private

Definition at line 55 of file EGammaTracksThinning.h.

◆ m_photonsContainerKey

SG::ReadHandleKey<xAOD::PhotonContainer> DerivationFramework::EGammaTracksThinning::m_photonsContainerKey { this, "photonContainerName", "Photons", ""}
private

Definition at line 49 of file EGammaTracksThinning.h.

◆ m_streamName

StringProperty DerivationFramework::EGammaTracksThinning::m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
private

Definition at line 45 of file EGammaTracksThinning.h.

◆ m_tracksCollectionName

SG::ThinningHandleKey<TrackCollection> DerivationFramework::EGammaTracksThinning::m_tracksCollectionName { this, "tracksCollectionName", "Tracks", "" }
private

Definition at line 51 of file EGammaTracksThinning.h.


The documentation for this class was generated from the following files:
electronContainer
xAOD::ElectronContainer * electronContainer
Definition: TrigGlobEffCorrValidation.cxx:187
DerivationFramework::EGammaTracksThinning::m_dr
Gaudi::Property< double > m_dr
Definition: EGammaTracksThinning.h:54
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
DerivationFramework::EGammaTracksThinning::thinTracks
StatusCode thinTracks(SG::ThinningHandle< TrackCollection > &trackCont, const std::set< int > &goodTracks) const
Definition: EGammaTracksThinning.cxx:179
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: P4Helpers.h:29
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:53
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DerivationFramework::EGammaTracksThinning::m_minEtEg
Gaudi::Property< double > m_minEtEg
Definition: EGammaTracksThinning.h:56
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
photonContainer
xAOD::PhotonContainer * photonContainer
Definition: TrigGlobEffCorrValidation.cxx:189
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
DerivationFramework::EGammaTracksThinning::m_streamName
StringProperty m_streamName
Definition: EGammaTracksThinning.h:46
DerivationFramework::EGammaTracksThinning::findGoodTracks
std::set< int > findGoodTracks(const TrackCollection *trackCont, const TLorentzVector &candHepLorentz, double maxDeltaR) const
Definition: EGammaTracksThinning.cxx:132
DerivationFramework::EGammaTracksThinning::m_electronsContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronsContainerKey
Definition: EGammaTracksThinning.h:48
DerivationFramework::EGammaTracksThinning::m_tracksCollectionName
SG::ThinningHandleKey< TrackCollection > m_tracksCollectionName
Definition: EGammaTracksThinning.h:52
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
Trk::phi0
@ phi0
Definition: ParamDefs.h:71
DerivationFramework::EGammaTracksThinning::m_photonsContainerKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonsContainerKey
Definition: EGammaTracksThinning.h:50
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.