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 EventContext &ctx) 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 EventContext & ctx) const
overridevirtual

Definition at line 29 of file EGammaTracksThinning.cxx.

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

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

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