ATLAS Offline Software
Loading...
Searching...
No Matches
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
35 SG::ThinningHandle<TrackCollection> trackCollection
37 ATH_MSG_DEBUG( "Container '" << m_tracksCollectionName.key() << "' retrieved from StoreGate" );
38
39 // retrieve the electron collection
40
41 SG::ReadHandle<xAOD::ElectronContainer> electronContainer(m_electronsContainerKey, ctx);
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
56 SG::ReadHandle<xAOD::PhotonContainer> photonContainer(m_photonsContainerKey,ctx);
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
xAOD::ElectronContainer * electronContainer
xAOD::PhotonContainer * photonContainer
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.
SG::ThinningHandleKey< TrackCollection > m_tracksCollectionName
std::set< int > findGoodTracks(const TrackCollection *trackCont, const TLorentzVector &candHepLorentz, double maxDeltaR) const
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronsContainerKey
StatusCode thinTracks(SG::ThinningHandle< TrackCollection > &trackCont, const std::set< int > &goodTracks) const
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonsContainerKey

◆ 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}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
double eta() const
Access method for pseudorapidity - from momentum.
double deltaR(double eta1, double eta2, double phi1, double phi2)
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition P4Helpers.h:66
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ phi0
Definition ParamDefs.h:65

◆ initialize()

StatusCode DerivationFramework::EGammaTracksThinning::initialize ( )
overridevirtual

Definition at line 16 of file EGammaTracksThinning.cxx.

16 {
17
18 ATH_CHECK( m_electronsContainerKey.initialize() );
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}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

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.

54{ this, "deltaR", 0.5, "" };

◆ m_electronsContainerKey

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

Definition at line 47 of file EGammaTracksThinning.h.

48{ this, "electronContainerName", "Electrons", "" };

◆ m_minEtEg

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

Definition at line 55 of file EGammaTracksThinning.h.

56{ this, "minEtEg", 0,""};

◆ m_photonsContainerKey

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

Definition at line 49 of file EGammaTracksThinning.h.

50{ this, "photonContainerName", "Photons", ""};

◆ m_streamName

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

Definition at line 45 of file EGammaTracksThinning.h.

46{ this, "StreamName", "", "Name of the stream being thinned" };

◆ m_tracksCollectionName

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

Definition at line 51 of file EGammaTracksThinning.h.

52{ this, "tracksCollectionName", "Tracks", "" };

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