ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::PixeldEdxTrackParticleThinning Class Reference

#include <PixeldEdxTrackParticleThinning.h>

Inheritance diagram for DerivationFramework::PixeldEdxTrackParticleThinning:
Collaboration diagram for DerivationFramework::PixeldEdxTrackParticleThinning:

Public Member Functions

 PixeldEdxTrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
virtual ~PixeldEdxTrackParticleThinning ()=default
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode doThinning (const EventContext &ctx) const override

Private Attributes

StringProperty m_selectionString
std::atomic< unsigned int > m_ntot {0}
std::atomic< unsigned int > m_npass {0}
StringProperty m_streamName
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetParticlesKey
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainerKey
DoubleProperty m_unprescalePtCut
DoubleProperty m_globalScale
DoubleProperty m_d0SignifCut
DoubleProperty m_z0Cut
DoubleProperty m_etaCut
std::vector< double > m_pTbins
std::mutex m_mutex

Static Private Attributes

static const std::vector< double > m_preScales

Detailed Description

Definition at line 36 of file PixeldEdxTrackParticleThinning.h.

Constructor & Destructor Documentation

◆ PixeldEdxTrackParticleThinning()

DerivationFramework::PixeldEdxTrackParticleThinning::PixeldEdxTrackParticleThinning ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 47 of file PixeldEdxTrackParticleThinning.cxx.

49 :
50 base_class(t, n, p)
51{}

◆ ~PixeldEdxTrackParticleThinning()

virtual DerivationFramework::PixeldEdxTrackParticleThinning::~PixeldEdxTrackParticleThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

StatusCode DerivationFramework::PixeldEdxTrackParticleThinning::doThinning ( const EventContext & ctx) const
overridevirtual

Definition at line 91 of file PixeldEdxTrackParticleThinning.cxx.

92{
93
94
95 // Retrieve main TrackParticle collection
96 SG::ThinningHandle<xAOD::TrackParticleContainer> importedTrackParticles
98
99 // Check the event contains tracks
100 size_t nTracks = importedTrackParticles->size();
101 if (nTracks==0) return StatusCode::SUCCESS;
102
103 // Set up a mask with the same entries as the full TrackParticle collection
104 std::vector<bool> mask;
105 mask.assign(nTracks,false); // default: don't keep any tracks
106
107 std::lock_guard<std::mutex> lock(m_mutex);
108
109 m_ntot += nTracks;
110
111 // Execute the text parser and update the mask
112 if (m_parser) {
113 std::vector<int> entries = m_parser->evaluateAsVector();
114 unsigned int nEntries = entries.size();
115 // check the sizes are compatible
116 if (nTracks != nEntries ) {
117 ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used ID TrackParticles?");
118 return StatusCode::FAILURE;
119 } else {
120 // set mask
121 for (unsigned int i=0; i<nTracks; ++i) if (entries[i]==1) mask[i]=true;
122 }
123 }
124
125 // Retrieve vertex collection
126 SG::ReadHandle<xAOD::VertexContainer> primaryVertices(m_vertexContainerKey,ctx);
127 ATH_CHECK( primaryVertices.isValid() );
128
129 const xAOD::Vertex* priVtx = nullptr;
130
131 for( const auto* vtx : *primaryVertices ) {
132 if( vtx->vertexType() == xAOD::VxType::PriVtx ) {
133 priVtx = vtx;
134 break;
135 }
136 }
137
138 if( !priVtx ) return StatusCode::SUCCESS;
139
140 auto getBin = [&]( const double pT ) -> size_t {
141 for( size_t ip = 0; ip < m_pTbins.size()-1; ip++ ) {
142 if( pT > m_pTbins.at(ip) && pT < m_pTbins.at(ip+1) ) {
143 return ip;
144 }
145 }
146 return 0;
147 };
148
149 // Count the mask
150 for (size_t i=0; i<nTracks; ++i) {
151
152 const auto* trk = importedTrackParticles->at(i);
153
154 // Keep all tracks if IBL is overflow
155 if( trk->numberOfIBLOverflowsdEdx() > 0 ) {
156
157 mask.at(i) = true; ++m_npass; continue;
158
159 }
160
161
162 // Keep all track for pT above 10 GeV
163 if( std::abs( trk->pt() ) > m_unprescalePtCut ) {
164
165 mask.at(i) = true; ++m_npass; continue;
166
167 }
168
169 // Hereafter only low-pT and no-overflow tracks
170
171 // Keep only d0 significancd is small enough
172 if( std::abs( xAOD::TrackingHelpers::d0significance( trk ) ) > m_d0SignifCut ) {
173 continue;
174 }
175
176 // Keep only delta(z0) is less than 10 mm
177 if( std::abs( trk->z0() - priVtx->z() + trk->vz() ) > m_z0Cut ) {
178 continue;
179 }
180
181 // Reject forward low-pT tracks
182 if( std::abs( trk->eta() ) > m_etaCut ) {
183 continue;
184 }
185
186 // Prescaled track keeping
187 auto bin = getBin( std::abs( trk->pt() ) );
188
189 const auto preScale = static_cast<unsigned long long>( std::floor( m_preScales.at( bin ) * m_globalScale ) );
190 const auto preScale10 = std::max( static_cast<unsigned long long>( std::floor( m_preScales.at( bin ) * m_globalScale / 10. ) ), 1ull );
191
192 float dEdx { 0 };
193 trk->summaryValue( dEdx, xAOD::pixeldEdx );
194
195 // Order-free per-track keep key: a deterministic hash of the event number and
196 // the track's perigee parameters. Each track is kept with probability ~1/preScale
197 // (statistical prescale, replacing the old exact 1-in-N running-counter keep),
198 // independent of the order tracks are encountered -> reproducible under AthenaMP.
199 const uint64_t keepHash = track_keep_hash(
200 static_cast<uint64_t>( ctx.eventID().event_number() ),
201 trk->d0(), trk->z0(), trk->phi0(), trk->theta(), trk->qOverP() );
202
203 // Relatively higher dE/dx tracks
204 static const float dEdxThr { static_cast<float>(pow( 10, 0.1 )) };
205 if( dEdx > dEdxThr ) {
206
207 mask.at(i) = ( (keepHash % preScale10) == 0 );
208
209 // There are also tracks with dE/dx == -1.
210 } else if( dEdx > 0. ) {
211
212 mask.at(i) = ( (keepHash % preScale) == 0 );
213
214 } else {
215
216 mask.at(i) = false;
217
218 }
219
220 if( mask.back() ) { ++m_npass; }
221
222 }
223
224 assert( importedTrackParticles->size() == mask.size() );
225
226 // Execute the thinning service based on the mask.
227 importedTrackParticles.keep (mask);
228
229 return StatusCode::SUCCESS;
230}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
int getBin(double x, double min, double step, int clamp_max)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetParticlesKey
float z() const
Returns the z position.
double entries
Definition listroot.cxx:49
constexpr int pow(int x)
Definition conifer.h:27
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ pixeldEdx
the dE/dx estimate, calculated using the pixel clusters [?

◆ finalize()

StatusCode DerivationFramework::PixeldEdxTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 81 of file PixeldEdxTrackParticleThinning.cxx.

82{
83 ATH_MSG_DEBUG("finalize() ...");
84 ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained "
85 << "("<< (m_ntot ? 100.0 * m_npass / m_ntot : 0.0) <<"%)");
86 ATH_CHECK( finalizeParser() );
87 return StatusCode::SUCCESS;
88}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)

◆ initialize()

StatusCode DerivationFramework::PixeldEdxTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 54 of file PixeldEdxTrackParticleThinning.cxx.

55{
56 ATH_MSG_DEBUG("initialize() ...");
57
58 //check xAOD::InDetTrackParticle collection
60 ATH_MSG_INFO("Using " << m_inDetParticlesKey << "as the source collection for inner detector track particles");
61 ATH_CHECK( m_vertexContainerKey.initialize() );
62 //check availability of xAOD::TrackStateValidation and xAOD::TrackMeasurementValidation containers
63
64 if (!m_selectionString.empty()) {
65 ATH_CHECK(initializeParser(m_selectionString));
66 }
67
69
70 if( 0 == m_pTbins.size() ) {
71 for( size_t ip = 0; ip <= 50; ++ip ) {
72 m_pTbins.emplace_back( pow( 10, 2.0 + 0.04 * ip ) );
73 }
74 }
75
77
78 return StatusCode::SUCCESS;
79}

Member Data Documentation

◆ m_d0SignifCut

DoubleProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_d0SignifCut
private
Initial value:
{
this, "d0SignifCut", 5.}

Definition at line 65 of file PixeldEdxTrackParticleThinning.h.

65 {
66 this, "d0SignifCut", 5.};

◆ m_etaCut

DoubleProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_etaCut
private
Initial value:
{
this, "EtaCut", 2.}

Definition at line 69 of file PixeldEdxTrackParticleThinning.h.

69 {
70 this, "EtaCut", 2.};

◆ m_globalScale

DoubleProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_globalScale
private
Initial value:
{
this, "GlobalScale", 1.}

Definition at line 63 of file PixeldEdxTrackParticleThinning.h.

63 {
64 this, "GlobalScale", 1.};

◆ m_inDetParticlesKey

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::PixeldEdxTrackParticleThinning::m_inDetParticlesKey
private
Initial value:
{
this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }

Definition at line 55 of file PixeldEdxTrackParticleThinning.h.

55 {
56 this, "InDetTrackParticlesKey", "InDetTrackParticles", "" };

◆ m_mutex

std::mutex DerivationFramework::PixeldEdxTrackParticleThinning::m_mutex
mutableprivate

Definition at line 75 of file PixeldEdxTrackParticleThinning.h.

◆ m_npass

std::atomic<unsigned int> DerivationFramework::PixeldEdxTrackParticleThinning::m_npass {0}
private

Definition at line 51 of file PixeldEdxTrackParticleThinning.h.

51{0}, m_npass{0};

◆ m_ntot

std::atomic<unsigned int> DerivationFramework::PixeldEdxTrackParticleThinning::m_ntot {0}
mutableprivate

Definition at line 51 of file PixeldEdxTrackParticleThinning.h.

51{0}, m_npass{0};

◆ m_preScales

const std::vector< double > DerivationFramework::PixeldEdxTrackParticleThinning::m_preScales
staticprivate
Initial value:
= {
150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 124.261, 111.448, 97.7357, 85.5616, 72.3294,
61.0017, 50.8592, 41.6827, 33.7413, 26.9884, 21.3822, 16.8352, 13.1081, 10.2368, 7.96723,
6.23636, 4.91757, 3.91519, 3.15519, 2.57768, 2.13622, 1.80524, 1.53102, 1.30677, 1.13582
}

Definition at line 38 of file PixeldEdxTrackParticleThinning.h.

44 :
45

◆ m_pTbins

std::vector<double> DerivationFramework::PixeldEdxTrackParticleThinning::m_pTbins
private

Definition at line 72 of file PixeldEdxTrackParticleThinning.h.

◆ m_selectionString

StringProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_selectionString
private
Initial value:
{
this, "SelectionString", "", "track selections"}

Definition at line 46 of file PixeldEdxTrackParticleThinning.h.

46 {
47 this, "SelectionString", "", "track selections"};

◆ m_streamName

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

Definition at line 53 of file PixeldEdxTrackParticleThinning.h.

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

◆ m_unprescalePtCut

DoubleProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_unprescalePtCut
private
Initial value:
{
this, "UnprescalePtCut", 10.e3}

Definition at line 61 of file PixeldEdxTrackParticleThinning.h.

61 {
62 this, "UnprescalePtCut", 10.e3};

◆ m_vertexContainerKey

SG::ReadHandleKey< xAOD::VertexContainer > DerivationFramework::PixeldEdxTrackParticleThinning::m_vertexContainerKey
private
Initial value:
{
this, "VertexContainerKey", "PrimaryVertices"}

Definition at line 57 of file PixeldEdxTrackParticleThinning.h.

57 {
58 this, "VertexContainerKey", "PrimaryVertices"};

◆ m_z0Cut

DoubleProperty DerivationFramework::PixeldEdxTrackParticleThinning::m_z0Cut
private
Initial value:
{
this, "z0Cut", 3.}

Definition at line 67 of file PixeldEdxTrackParticleThinning.h.

67 {
68 this, "z0Cut", 3.};

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