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

#include <TauJets_LepRMParticleThinning.h>

Inheritance diagram for DerivationFramework::TauJets_LepRMParticleThinning:
Collaboration diagram for DerivationFramework::TauJets_LepRMParticleThinning:

Public Member Functions

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

Private Attributes

std::atomic< unsigned int > m_ntot_taus {0}
 
std::atomic< unsigned int > m_ntot_trks {0}
 
std::atomic< unsigned int > m_ntot_ID_trks {0}
 
std::atomic< unsigned int > m_npass_taus {0}
 
std::atomic< unsigned int > m_npass_trks {0}
 
std::atomic< unsigned int > m_npass_ID_trks {0}
 
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ReadHandleKey< xAOD::TauJetContainerm_originalTauKey { this, "originalTauKey", "", ""}
 
SG::ThinningHandleKey< xAOD::TauJetContainerm_LepRMTauKey { this, "LepRMTauKey", "TauJets_LepRM", "where Lep can be Muon or Elec" }
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
 
SG::ThinningHandleKey< xAOD::TauTrackContainerm_tauTracksSGKey { this, "TauTracksKey", "TauTracks_LepRM", "where Lep can be Muon or Elec" }
 
Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "",""}
 

Detailed Description

Definition at line 28 of file TauJets_LepRMParticleThinning.h.

Constructor & Destructor Documentation

◆ TauJets_LepRMParticleThinning()

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

Definition at line 19 of file TauJets_LepRMParticleThinning.cxx.

21  :
22 base_class(t,n,p) {}

Member Function Documentation

◆ doThinning()

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

Definition at line 72 of file TauJets_LepRMParticleThinning.cxx.

73 {
74  const EventContext& ctx = Gaudi::Hive::currentContext();
75  // Retrieve main TrackParticle collection
77  if (!TrackParticles.isValid()) {
78  ATH_MSG_ERROR("No tau collection with name " << m_inDetSGKey.key() << " found in StoreGate!");
79  return StatusCode::FAILURE;
80  }
82  if (!TauTracks.isValid()) {
83  ATH_MSG_ERROR("No tau collection with name " << m_tauTracksSGKey.key() << " found in StoreGate!");
84  return StatusCode::FAILURE;
85  }
87  if (!LepRMTaus.isValid()) {
88  ATH_MSG_ERROR("No tau collection with name " << m_LepRMTauKey.key() << " found in StoreGate!");
89  return StatusCode::FAILURE;
90  }
92  if (!OriTaus.isValid()) {
93  ATH_MSG_ERROR("No tau collection with name " << m_originalTauKey.key() << " found in StoreGate!");
94  return StatusCode::FAILURE;
95  }
96 
97  //Thin tauJets_LepRM
98  std::vector<int> tau_kine_mask = m_parser->evaluateAsVector();
99  std::vector<bool> tau_lep_remove_mask(OriTaus->size(), false);
100  static const SG::AuxElement::ConstAccessor<char> acc_modified("ModifiedInAOD");
101  std::transform(LepRMTaus->cbegin(), LepRMTaus->cend(), tau_lep_remove_mask.begin(),
102  [&](auto lep_remove_tau) -> bool {
103  return static_cast<bool>(acc_modified(*lep_remove_tau));
104  }
105  );
106  std::vector<bool> tau_mask(OriTaus->size(),false);
107  std::transform(tau_lep_remove_mask.cbegin(), tau_lep_remove_mask.cend(), tau_kine_mask.cbegin(), tau_mask.begin(),
108  [](auto tau_lep_remove_pass, auto tau_kine_pass) -> bool
109  {
110  return tau_lep_remove_pass == 1 && tau_kine_pass == 1;
111  }
112  );
113 
114  std::vector<const xAOD::TauJet*> LepRMTausAfterThinning;
115  std::transform(tau_mask.cbegin(), tau_mask.cend(), LepRMTaus->cbegin(), std::back_inserter(LepRMTausAfterThinning),
116  [](bool mask, auto tau) -> const xAOD::TauJet*
117  {
118  return mask ? tau : nullptr;
119  }
120  );
121  LepRMTausAfterThinning.erase(std::remove(LepRMTausAfterThinning.begin(), LepRMTausAfterThinning.end(), nullptr), LepRMTausAfterThinning.end());
122 
123  //Thin TauTrack_LepRM
124  std::vector<bool> tau_track_mask(TauTracks->size(), false);
125  std::vector<bool> id_track_mask(TrackParticles->size(), false);
126  std::for_each(LepRMTausAfterThinning.cbegin(), LepRMTausAfterThinning.cend(),
127  [&](auto tau)
128  {
129  auto tau_track_links = tau->tauTrackLinks();
130  std::for_each(tau_track_links.cbegin(), tau_track_links.cend(),
131  [&](auto link)
132  {
133  if (link.isValid())
134  {
135  tau_track_mask[link.index()] = 1;
136  if (auto id_track_link = (*link)->trackLinks().at(0); id_track_link.isValid())
137  {
138  id_track_mask[id_track_link.index()] = 1;
139  }
140  }
141  }
142  );
143  }
144  );
145 
146  LepRMTaus.keep(tau_mask);
147  TauTracks.keep(tau_track_mask);
148  TrackParticles.keep(id_track_mask);
149 
150  m_ntot_taus += OriTaus->size();
151  m_ntot_trks += TauTracks->size();
152  m_ntot_ID_trks += TrackParticles->size();
153  m_npass_taus += std::accumulate(tau_mask.begin(), tau_mask.end(),0);
154  m_npass_trks += std::accumulate(tau_track_mask.begin(), tau_track_mask.end(),0);
155  m_npass_ID_trks += std::accumulate(id_track_mask.begin(), id_track_mask.end(),0);
156  ATH_MSG_DEBUG(std::accumulate(tau_mask.begin(), tau_mask.end(),0) << " / " << OriTaus->size() << " taus were retained");
157 
158  return StatusCode::SUCCESS;
159 
160 }

◆ finalize()

StatusCode DerivationFramework::TauJets_LepRMParticleThinning::finalize ( )
overridevirtual

Definition at line 61 of file TauJets_LepRMParticleThinning.cxx.

62 {
63  ATH_MSG_VERBOSE("finalize() ...");
64  ATH_MSG_INFO("Processed "<< m_ntot_trks <<" tau tracks, "<< m_npass_trks<< " were retained ");
65  ATH_MSG_INFO("Processed "<< m_ntot_ID_trks <<" ID tracks, "<< m_npass_ID_trks<< " were retained ");
66  ATH_MSG_INFO("Processed "<< m_ntot_taus <<" taus, "<< m_npass_taus<< " were retained ");
67  ATH_CHECK( finalizeParser() );
68  return StatusCode::SUCCESS;
69 }

◆ initialize()

StatusCode DerivationFramework::TauJets_LepRMParticleThinning::initialize ( )
overridevirtual

Definition at line 25 of file TauJets_LepRMParticleThinning.cxx.

26 {
27  // Decide which collections need to be checked for ID TrackParticles
28  ATH_MSG_VERBOSE("initialize() ...");
29  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
30  ATH_MSG_INFO("Using " << m_inDetSGKey << " as the source collection for inner detector track particles");
31 
32  if (m_LepRMTauKey.key().empty())
33  {
34  ATH_MSG_FATAL("No tau collection provided for thinning.");
35  return StatusCode::FAILURE;
36  }
37  else
38  {
39  ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_LepRMTauKey.key() << " will be retained in this format with the rest being thinned away");
40  }
42 
43  //tautracks
44  if (m_tauTracksSGKey.key().empty()) {
45  ATH_MSG_FATAL("No tau tracks collection provided for thinning.");
46  return StatusCode::FAILURE;
47  } else {
48  ATH_MSG_INFO("Tau track thinning requested; tau tracks with the SG key " << m_tauTracksSGKey.key() << " will be thinned if not associated with objects in " << m_LepRMTauKey.key());
49  ATH_CHECK( m_tauTracksSGKey.initialize (m_streamName) );
50  }
51 
52  // Set up the text-parsing machinery for selectiong the tau directly according to user cuts
53  if (!m_selectionString.empty()) {
54  ATH_CHECK(initializeParser(m_selectionString) );
55  }
56 
57  ATH_CHECK(m_originalTauKey.initialize());
58  return StatusCode::SUCCESS;
59 }

Member Data Documentation

◆ m_inDetSGKey

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

Definition at line 49 of file TauJets_LepRMParticleThinning.h.

◆ m_LepRMTauKey

SG::ThinningHandleKey<xAOD::TauJetContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_LepRMTauKey { this, "LepRMTauKey", "TauJets_LepRM", "where Lep can be Muon or Elec" }
private

Definition at line 47 of file TauJets_LepRMParticleThinning.h.

◆ m_npass_ID_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_ID_trks {0}
mutableprivate

Definition at line 41 of file TauJets_LepRMParticleThinning.h.

◆ m_npass_taus

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_taus {0}
mutableprivate

Definition at line 39 of file TauJets_LepRMParticleThinning.h.

◆ m_npass_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_trks {0}
mutableprivate

Definition at line 40 of file TauJets_LepRMParticleThinning.h.

◆ m_ntot_ID_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_ID_trks {0}
mutableprivate

Definition at line 38 of file TauJets_LepRMParticleThinning.h.

◆ m_ntot_taus

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_taus {0}
mutableprivate

Definition at line 36 of file TauJets_LepRMParticleThinning.h.

◆ m_ntot_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_trks {0}
mutableprivate

Definition at line 37 of file TauJets_LepRMParticleThinning.h.

◆ m_originalTauKey

SG::ReadHandleKey<xAOD::TauJetContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_originalTauKey { this, "originalTauKey", "", ""}
private

Definition at line 45 of file TauJets_LepRMParticleThinning.h.

◆ m_selectionString

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

Definition at line 53 of file TauJets_LepRMParticleThinning.h.

◆ m_streamName

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

Definition at line 43 of file TauJets_LepRMParticleThinning.h.

◆ m_tauTracksSGKey

SG::ThinningHandleKey<xAOD::TauTrackContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_tauTracksSGKey { this, "TauTracksKey", "TauTracks_LepRM", "where Lep can be Muon or Elec" }
private

Definition at line 51 of file TauJets_LepRMParticleThinning.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::TauJets_LepRMParticleThinning::m_npass_trks
std::atomic< unsigned int > m_npass_trks
Definition: TauJets_LepRMParticleThinning.h:40
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
DerivationFramework::TauJets_LepRMParticleThinning::m_originalTauKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_originalTauKey
Definition: TauJets_LepRMParticleThinning.h:45
DerivationFramework::TauJets_LepRMParticleThinning::m_tauTracksSGKey
SG::ThinningHandleKey< xAOD::TauTrackContainer > m_tauTracksSGKey
Definition: TauJets_LepRMParticleThinning.h:51
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_ID_trks
std::atomic< unsigned int > m_ntot_ID_trks
Definition: TauJets_LepRMParticleThinning.h:38
DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_taus
std::atomic< unsigned int > m_ntot_taus
Definition: TauJets_LepRMParticleThinning.h:36
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::TauJets_LepRMParticleThinning::m_npass_ID_trks
std::atomic< unsigned int > m_npass_ID_trks
Definition: TauJets_LepRMParticleThinning.h:41
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_trks
std::atomic< unsigned int > m_ntot_trks
Definition: TauJets_LepRMParticleThinning.h:37
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TauJets_LepRMParticleThinning::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: TauJets_LepRMParticleThinning.h:53
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::TauJets_LepRMParticleThinning::m_LepRMTauKey
SG::ThinningHandleKey< xAOD::TauJetContainer > m_LepRMTauKey
Definition: TauJets_LepRMParticleThinning.h:47
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TauJets_LepRMParticleThinning::m_npass_taus
std::atomic< unsigned int > m_npass_taus
Definition: TauJets_LepRMParticleThinning.h:39
DerivationFramework::TauJets_LepRMParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: TauJets_LepRMParticleThinning.h:49
DerivationFramework::TauJets_LepRMParticleThinning::m_streamName
StringProperty m_streamName
Definition: TauJets_LepRMParticleThinning.h:43