ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
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 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::vector< unsigned long long > m_counter ATLAS_THREAD_SAFE
 
std::vector< unsigned long long > m_counter_picked ATLAS_THREAD_SAFE
 
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 26 of file PixeldEdxTrackParticleThinning.cxx.

28  :
29  base_class(t, n, p)
30 {}

◆ ~PixeldEdxTrackParticleThinning()

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

Member Function Documentation

◆ doThinning()

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

Definition at line 71 of file PixeldEdxTrackParticleThinning.cxx.

72 {
73 
74  const EventContext& ctx = Gaudi::Hive::currentContext();
75 
76  // Retrieve main TrackParticle collection
78  (m_inDetParticlesKey, ctx);
79 
80  // Check the event contains tracks
81  size_t nTracks = importedTrackParticles->size();
82  if (nTracks==0) return StatusCode::SUCCESS;
83 
84  // Set up a mask with the same entries as the full TrackParticle collection
85  std::vector<bool> mask;
86  mask.assign(nTracks,false); // default: don't keep any tracks
87 
88  std::lock_guard<std::mutex> lock(m_mutex);
89 
90  m_ntot += nTracks;
91 
92  // Execute the text parser and update the mask
93  if (m_parser) {
94  std::vector<int> entries = m_parser->evaluateAsVector();
95  unsigned int nEntries = entries.size();
96  // check the sizes are compatible
97  if (nTracks != nEntries ) {
98  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used ID TrackParticles?");
99  return StatusCode::FAILURE;
100  } else {
101  // set mask
102  for (unsigned int i=0; i<nTracks; ++i) if (entries[i]==1) mask[i]=true;
103  }
104  }
105 
106  // Retrieve vertex collection
108  ATH_CHECK( primaryVertices.isValid() );
109 
110  const xAOD::Vertex* priVtx = nullptr;
111 
112  for( const auto* vtx : *primaryVertices ) {
113  if( vtx->vertexType() == xAOD::VxType::PriVtx ) {
114  priVtx = vtx;
115  break;
116  }
117  }
118 
119  if( !priVtx ) return StatusCode::SUCCESS;
120 
121  auto getBin = [&]( const double pT ) -> size_t {
122  for( size_t ip = 0; ip < m_pTbins.size()-1; ip++ ) {
123  if( pT > m_pTbins.at(ip) && pT < m_pTbins.at(ip+1) ) {
124  return ip;
125  }
126  }
127  return 0;
128  };
129 
130  // Count the mask
131  for (size_t i=0; i<nTracks; ++i) {
132 
133  const auto* trk = importedTrackParticles->at(i);
134 
135  // Keep all tracks if IBL is overflow
136  if( trk->numberOfIBLOverflowsdEdx() > 0 ) {
137 
138  mask.at(i) = true; ++m_npass; continue;
139 
140  }
141 
142 
143  // Keep all track for pT above 10 GeV
144  if( std::abs( trk->pt() ) > m_unprescalePtCut ) {
145 
146  mask.at(i) = true; ++m_npass; continue;
147 
148  }
149 
150  // Hereafter only low-pT and no-overflow tracks
151 
152  // Keep only d0 significancd is small enough
153  if( std::abs( xAOD::TrackingHelpers::d0significance( trk ) ) > m_d0SignifCut ) {
154  continue;
155  }
156 
157  // Keep only delta(z0) is less than 10 mm
158  if( std::abs( trk->z0() - priVtx->z() ) > m_z0Cut ) {
159  continue;
160  }
161 
162  // Reject forward low-pT tracks
163  if( std::abs( trk->eta() ) > m_etaCut ) {
164  continue;
165  }
166 
167  // Prescaled track keeping
168  auto bin = getBin( std::abs( trk->pt() ) );
169 
170  const auto preScale = static_cast<unsigned long long>( std::floor( m_preScales.at( bin ) * m_globalScale ) );
171  const auto preScale10 = std::max( static_cast<unsigned long long>( std::floor( m_preScales.at( bin ) * m_globalScale / 10. ) ), 1ull );
172 
173  float dEdx { 0 };
174  trk->summaryValue( dEdx, xAOD::pixeldEdx );
175 
176  // Increment the m_counter
177  m_counter.at(bin)++;
178 
179  // Relatively higher dE/dx tracks
180  static const float dEdxThr { static_cast<float>(pow( 10, 0.1 )) };
181  if( dEdx > dEdxThr ) {
182 
183  mask.at(i) = ( (m_counter.at(bin) % preScale10) == 0 );
184 
185  // There are also tracks with dE/dx == -1.
186  } else if( dEdx > 0. ) {
187 
188  mask.at(i) = ( (m_counter.at(bin) % preScale) == 0 );
189 
190  } else {
191 
192  mask.at(i) = false;
193 
194  }
195 
196  if( mask.back() ) { ++m_npass; m_counter_picked.at(bin)++; }
197 
198  }
199 
200  assert( importedTrackParticles->size() == mask.size() );
201 
202  // Execute the thinning service based on the mask.
203  importedTrackParticles.keep (mask);
204 
205  return StatusCode::SUCCESS;
206 }

◆ finalize()

StatusCode DerivationFramework::PixeldEdxTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 62 of file PixeldEdxTrackParticleThinning.cxx.

63 {
64  ATH_MSG_DEBUG("finalize() ...");
65  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
66  ATH_CHECK( finalizeParser() );
67  return StatusCode::SUCCESS;
68 }

◆ initialize()

StatusCode DerivationFramework::PixeldEdxTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 33 of file PixeldEdxTrackParticleThinning.cxx.

34 {
35  ATH_MSG_DEBUG("initialize() ...");
36 
37  //check xAOD::InDetTrackParticle collection
39  ATH_MSG_INFO("Using " << m_inDetParticlesKey << "as the source collection for inner detector track particles");
40  ATH_CHECK( m_vertexContainerKey.initialize() );
41  //check availability of xAOD::TrackStateValidation and xAOD::TrackMeasurementValidation containers
42 
43  if (!m_selectionString.empty()) {
44  ATH_CHECK(initializeParser(m_selectionString));
45  }
46 
47  m_counter.resize(50);
48  m_counter_picked.resize(50);
50 
51  if( 0 == m_pTbins.size() ) {
52  for( size_t ip = 0; ip <= 50; ++ip ) {
53  m_pTbins.emplace_back( pow( 10, 2.0 + 0.04 * ip ) );
54  }
55  }
56 
58 
59  return StatusCode::SUCCESS;
60 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

std::vector<unsigned long long> m_counter DerivationFramework::PixeldEdxTrackParticleThinning::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 76 of file PixeldEdxTrackParticleThinning.h.

◆ ATLAS_THREAD_SAFE [2/2]

std::vector<unsigned long long> m_counter_picked DerivationFramework::PixeldEdxTrackParticleThinning::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 77 of file PixeldEdxTrackParticleThinning.h.

◆ m_d0SignifCut

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

Definition at line 65 of file PixeldEdxTrackParticleThinning.h.

◆ m_etaCut

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

Definition at line 69 of file PixeldEdxTrackParticleThinning.h.

◆ m_globalScale

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

Definition at line 63 of file PixeldEdxTrackParticleThinning.h.

◆ m_inDetParticlesKey

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

Definition at line 55 of file PixeldEdxTrackParticleThinning.h.

◆ m_mutex

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

Definition at line 78 of file PixeldEdxTrackParticleThinning.h.

◆ m_npass

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

Definition at line 51 of file PixeldEdxTrackParticleThinning.h.

◆ m_ntot

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

Definition at line 51 of file PixeldEdxTrackParticleThinning.h.

◆ 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 73 of file PixeldEdxTrackParticleThinning.h.

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

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

◆ m_unprescalePtCut

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

Definition at line 61 of file PixeldEdxTrackParticleThinning.h.

◆ m_vertexContainerKey

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

Definition at line 57 of file PixeldEdxTrackParticleThinning.h.

◆ m_z0Cut

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

Definition at line 67 of file PixeldEdxTrackParticleThinning.h.


The documentation for this class was generated from the following files:
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
max
#define max(a, b)
Definition: cfImp.cxx:41
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition: TrackParticlexAODHelpers.cxx:42
bin
Definition: BinsDiffFromStripMedian.h:43
DerivationFramework::PixeldEdxTrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: PixeldEdxTrackParticleThinning.h:51
getBin
int getBin(double x, double min, double step, int clamp_max)
Definition: FPGATrackSimSectorSlice.cxx:209
DerivationFramework::PixeldEdxTrackParticleThinning::m_preScales
static const std::vector< double > m_preScales
Definition: PixeldEdxTrackParticleThinning.h:73
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::PixeldEdxTrackParticleThinning::m_unprescalePtCut
DoubleProperty m_unprescalePtCut
Definition: PixeldEdxTrackParticleThinning.h:61
DerivationFramework::PixeldEdxTrackParticleThinning::m_globalScale
DoubleProperty m_globalScale
Definition: PixeldEdxTrackParticleThinning.h:63
DerivationFramework::PixeldEdxTrackParticleThinning::m_z0Cut
DoubleProperty m_z0Cut
Definition: PixeldEdxTrackParticleThinning.h:67
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
DerivationFramework::PixeldEdxTrackParticleThinning::m_d0SignifCut
DoubleProperty m_d0SignifCut
Definition: PixeldEdxTrackParticleThinning.h:65
DerivationFramework::PixeldEdxTrackParticleThinning::m_etaCut
DoubleProperty m_etaCut
Definition: PixeldEdxTrackParticleThinning.h:69
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::PixeldEdxTrackParticleThinning::m_selectionString
StringProperty m_selectionString
Definition: PixeldEdxTrackParticleThinning.h:46
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
DerivationFramework::PixeldEdxTrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: PixeldEdxTrackParticleThinning.h:51
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::Vertex_v1::z
float z() const
Returns the z position.
DerivationFramework::PixeldEdxTrackParticleThinning::m_inDetParticlesKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetParticlesKey
Definition: PixeldEdxTrackParticleThinning.h:55
DerivationFramework::PixeldEdxTrackParticleThinning::m_pTbins
std::vector< double > m_pTbins
Definition: PixeldEdxTrackParticleThinning.h:72
DerivationFramework::PixeldEdxTrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: PixeldEdxTrackParticleThinning.h:53
xAOD::pixeldEdx
@ pixeldEdx
the dE/dx estimate, calculated using the pixel clusters [?]
Definition: TrackingPrimitives.h:304
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
entries
double entries
Definition: listroot.cxx:49
DerivationFramework::PixeldEdxTrackParticleThinning::m_mutex
std::mutex m_mutex
Definition: PixeldEdxTrackParticleThinning.h:78
DerivationFramework::PixeldEdxTrackParticleThinning::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition: PixeldEdxTrackParticleThinning.h:57
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
detail::ull
unsigned long long ull
Definition: PrimitiveHelpers.h:44