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

#include <MuonTrackParticleThinning.h>

Inheritance diagram for DerivationFramework::MuonTrackParticleThinning:
Collaboration diagram for DerivationFramework::MuonTrackParticleThinning:

Public Member Functions

 MuonTrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~MuonTrackParticleThinning ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 

Private Attributes

std::atomic< unsigned int > m_ntot {}
 
std::atomic< unsigned int > m_npass {}
 
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
 
SG::ReadHandleKey< xAOD::MuonContainerm_muonKey { this, "MuonKey", "",""}
 
Gaudi::Property< std::string > m_selectionString { this, "SelectionString","",""}
 
Gaudi::Property< float > m_coneSize { this, "ConeSize", -1.0, ""}
 

Detailed Description

Definition at line 27 of file MuonTrackParticleThinning.h.

Constructor & Destructor Documentation

◆ MuonTrackParticleThinning()

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

Definition at line 22 of file MuonTrackParticleThinning.cxx.

24  :
25 base_class(t,n,p)
26 {
27 }

◆ ~MuonTrackParticleThinning()

DerivationFramework::MuonTrackParticleThinning::~MuonTrackParticleThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 60 of file MuonTrackParticleThinning.cxx.

61 {
62  const EventContext& ctx = Gaudi::Hive::currentContext();
63 
64  // Retrieve main TrackParticle collection
66  (m_inDetSGKey, ctx);
67 
68  // Check the event contains tracks
69  unsigned int nTracks = importedTrackParticles->size();
70  if (nTracks==0) return StatusCode::SUCCESS;
71 
72  // Set up a mask with the same entries as the full TrackParticle collection
73  std::vector<bool> mask;
74  mask.assign(nTracks,false); // default: don't keep any tracks
75  m_ntot += nTracks;
76 
77  // Retrieve containers
78  // ... muons
80  if (!importedMuons.isValid()) {
81  ATH_MSG_ERROR("No muon collection with name " << m_muonKey.key() << " found in StoreGate!");
82  return StatusCode::FAILURE;
83  }
84  unsigned int nMuons(importedMuons->size());
85  std::vector<const xAOD::Muon*> muToCheck; muToCheck.clear();
86  // Execute the text parser if requested
87  if (m_selectionString!="") {
88  std::vector<int> entries = m_parser->evaluateAsVector();
89  unsigned int nEntries = entries.size();
90  // check the sizes are compatible
91  if (nMuons != nEntries ) {
92  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used muons??");
93  return StatusCode::FAILURE;
94  } else {
95  // identify which muons to keep for the thinning check
96  for (unsigned int i=0; i<nMuons; ++i) if (entries[i]==1) muToCheck.push_back((*importedMuons)[i]);
97  }
98  }
99 
101  if (m_selectionString=="") { // check all muons as user didn't provide a selection string
102  for (const auto *muIt : *importedMuons) {
103  if (muIt->inDetTrackParticleLink().isValid()) {
104  //This line prevents SiliconAssociatedForwardMuon from being used unless we're skimming InDetForwardTrackParticles
105  //since their track links point to this container while all others point to InDetTrackParticles
106  if (muIt->muonType()==xAOD::Muon::SiliconAssociatedForwardMuon && m_inDetSGKey.key() != "InDetForwardTrackParticles")
107  {
108  ATH_MSG_DEBUG("Skipping Forward Muon since we are not skimming InDetForwardParticles");
109  }
110  else{
111  ATH_MSG_DEBUG("Simming Muon tracks in " << m_inDetSGKey << " "<< muIt->muonType());
112  int index = muIt->inDetTrackParticleLink().index();
113  mask[index] = true;
114  }
115  }
116  if (m_coneSize>0.0) tInC.select(muIt,m_coneSize,importedTrackParticles.cptr(),mask); // check tracks in a cone around the muon if req'd
117  }
118  } else { // check only muons passing user selection string
119  for (auto & muIt : muToCheck) {
120  if (muIt->inDetTrackParticleLink().isValid()) {
121 
122  if (muIt->muonType()==xAOD::Muon::SiliconAssociatedForwardMuon && m_inDetSGKey.key() != "InDetForwardTrackParticles")
123  {
124  ATH_MSG_DEBUG("Skipping Forward Muon since we are not skimming InDetForwardParticles");
125  }
126  else{
127  ATH_MSG_DEBUG("Simming Muon tracks in " << m_inDetSGKey << " "<< muIt->muonType());
128  int index = muIt->inDetTrackParticleLink().index();
129  mask[index] = true;
130  }
131  }
132  if (m_coneSize>0.0) tInC.select(muIt,m_coneSize,importedTrackParticles.cptr(),mask); // check tracks in a cone around the muon if req'd
133  }
134  }
135 
136  // Count up the mask contents
137  unsigned int n_pass=0;
138  for (unsigned int i=0; i<nTracks; ++i) {
139  if (mask[i]) ++n_pass;
140  }
141  m_npass+=n_pass;
142  // Execute the thinning service based on the mask. Finish.
143  importedTrackParticles.keep (mask);
144 
145  return StatusCode::SUCCESS;
146 }

◆ finalize()

StatusCode DerivationFramework::MuonTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 51 of file MuonTrackParticleThinning.cxx.

52 {
53  ATH_MSG_VERBOSE("finalize() ...");
54  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
55  ATH_CHECK( finalizeParser() );
56  return StatusCode::SUCCESS;
57 }

◆ initialize()

StatusCode DerivationFramework::MuonTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 33 of file MuonTrackParticleThinning.cxx.

34 {
35  // Decide which collections need to be checked for ID TrackParticles
36  ATH_MSG_VERBOSE("initialize() ...");
37  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
38  ATH_MSG_INFO("Using " << m_inDetSGKey.key() << "as the source collection for inner detector track particles");
39  if (m_muonKey.key().empty()) {
40  ATH_MSG_FATAL("No muon collection provided for thinning.");
41  return StatusCode::FAILURE;
42  } else { ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_muonKey.key() << " will be retained in this format with the rest being thinned away");}
43  ATH_CHECK(m_muonKey.initialize());
44  // Set up the text-parsing machinery for selectiong the muon directly according to user cuts
45  if (!m_selectionString.empty()) {
46  ATH_CHECK(initializeParser(m_selectionString) );
47  }
48  return StatusCode::SUCCESS;
49 }

Member Data Documentation

◆ m_coneSize

Gaudi::Property<float> DerivationFramework::MuonTrackParticleThinning::m_coneSize { this, "ConeSize", -1.0, ""}
private

Definition at line 46 of file MuonTrackParticleThinning.h.

◆ m_inDetSGKey

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::MuonTrackParticleThinning::m_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
private

Definition at line 40 of file MuonTrackParticleThinning.h.

◆ m_muonKey

SG::ReadHandleKey<xAOD::MuonContainer> DerivationFramework::MuonTrackParticleThinning::m_muonKey { this, "MuonKey", "",""}
private

Definition at line 42 of file MuonTrackParticleThinning.h.

◆ m_npass

std::atomic<unsigned int> DerivationFramework::MuonTrackParticleThinning::m_npass {}
mutableprivate

Definition at line 37 of file MuonTrackParticleThinning.h.

◆ m_ntot

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

Definition at line 36 of file MuonTrackParticleThinning.h.

◆ m_selectionString

Gaudi::Property<std::string> DerivationFramework::MuonTrackParticleThinning::m_selectionString { this, "SelectionString","",""}
private

Definition at line 44 of file MuonTrackParticleThinning.h.

◆ m_streamName

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

Definition at line 38 of file MuonTrackParticleThinning.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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::MuonTrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: MuonTrackParticleThinning.h:36
DerivationFramework::MuonTrackParticleThinning::m_muonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
Definition: MuonTrackParticleThinning.h:43
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
DerivationFramework::MuonTrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: MuonTrackParticleThinning.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::MuonTrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: MuonTrackParticleThinning.h:37
DeMoScan.index
string index
Definition: DeMoScan.py:364
DerivationFramework::MuonTrackParticleThinning::m_coneSize
Gaudi::Property< float > m_coneSize
Definition: MuonTrackParticleThinning.h:47
entries
double entries
Definition: listroot.cxx:49
DerivationFramework::TracksInCone
Definition: TracksInCone.h:19
DerivationFramework::TracksInCone::select
void select(const xAOD::IParticle *particle, float coneSize, const xAOD::TrackParticleContainer *tracks, std::vector< bool > &mask)
Definition: TracksInCone.h:21
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::MuonTrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: MuonTrackParticleThinning.h:39
DerivationFramework::MuonTrackParticleThinning::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: MuonTrackParticleThinning.h:45