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

#include <UFOTrackParticleThinning.h>

Inheritance diagram for DerivationFramework::UFOTrackParticleThinning:
Collaboration diagram for DerivationFramework::UFOTrackParticleThinning:

Public Member Functions

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

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
 
Gaudi::Property< bool > m_thinTracks {this,"ThinTrackingContainer",true,"Toggle thinning of container with name InDetTrackParticlesKey"}
 
Gaudi::Property< std::string > m_PFOSGKey { this, "PFOCollectionSGKey", "Global", "" }
 
SG::ThinningHandleKey< xAOD::FlowElementContainerm_PFOChargedSGKey { this, "PFOChargedCollectionSGKey", "GlobalChargedParticleFlowObjects", "" }
 
SG::ThinningHandleKey< xAOD::FlowElementContainerm_PFONeutralSGKey { this, "PFONeutralCollectionSGKey", "GlobalNeutralParticleFlowObjects", "" }
 
Gaudi::Property< std::vector< std::string > > m_addPFOSGKey { this, "AdditionalPFOKey", {}, ""}
 
SG::ThinningHandleKey< xAOD::FlowElementContainerm_tmpAddPFOChargedSGKey { this, "TempAddPFOChargedKey","",""}
 
SG::ThinningHandleKey< xAOD::FlowElementContainerm_tmpAddPFONeutralSGKey { this, "TempAddPFONeutralKey","",""}
 
std::vector< SG::ThinningHandleKey< xAOD::FlowElementContainer > > m_addPFOChargedSGKey
 
std::vector< SG::ThinningHandleKey< xAOD::FlowElementContainer > > m_addPFONeutralSGKey
 
SG::ThinningHandleKey< xAOD::FlowElementContainerm_ufoSGKey { this, "UFOKey", "UFOCSSK", "" }
 
SG::ReadHandleKey< xAOD::JetContainerm_jetSGKey { this, "JetKey", "", ""}
 
StringProperty m_selectionString { this, "SelectionString", "", "" }
 

Detailed Description

Definition at line 30 of file UFOTrackParticleThinning.h.

Constructor & Destructor Documentation

◆ UFOTrackParticleThinning()

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

Definition at line 14 of file UFOTrackParticleThinning.cxx.

16  :
17 base_class(t,n,p)
18 {
19 }

◆ ~UFOTrackParticleThinning()

DerivationFramework::UFOTrackParticleThinning::~UFOTrackParticleThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 67 of file UFOTrackParticleThinning.cxx.

68 {
69 
70  const EventContext& ctx = Gaudi::Hive::currentContext();
71 
72  // Retrieve main TrackParticle collection
74 
75  // Retrieve PFO collection if required
78 
79  // Retrieve main jet collection
81  unsigned int nJets(importedJets->size());
82  std::vector<const xAOD::Jet*> jetToCheck; jetToCheck.clear();
83 
84  // Check the event contains tracks
85  unsigned int nTracks = importedTrackParticles->size();
86  // Check the event contains calo clusters
87  const size_t nPFONeutral = importedPFONeutral->size();
88  const size_t nPFOCharged = importedPFOCharged->size() ;
89  unsigned int nPFOs = nPFOCharged + nPFONeutral;
90  if (nPFOs==0 && nTracks==0) return StatusCode::SUCCESS;
91 
92  // Set up a mask with the same entries as the full TrackParticle collection
93  std::vector<bool> maskTracks;
94  maskTracks.assign(nTracks,false); // default: don't keep any tracks
95 
96  // Set up a mask with the same entries as the full PFO collection(s)
97  std::vector< bool > pfomaskNeutral( nPFONeutral, false );
98  std::vector< bool > pfomaskCharged( nPFOCharged, false );
99 
100  // Retrieve containers
101  // ... UFOs
103  unsigned int nUFOs(importedUFOs->size());
104 
105  // Set up a mask with the same entries as the full CaloCluster collection
106  std::vector<bool> maskUFOs;
107  maskUFOs.assign(nUFOs,false); // default: don't keep any tracks
108 
109  // Execute the text parser if requested
110  if (m_selectionString!="") {
111  std::vector<int> entries = m_parser->evaluateAsVector();
112  unsigned int nEntries = entries.size();
113  // check the sizes are compatible
114  if (nJets != nEntries ) {
115  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used jets??");
116  return StatusCode::FAILURE;
117  } else {
118  // identify which jets to keep for the thinning check
119  for (unsigned int i=0; i<nJets; ++i) if (entries[i]==1) jetToCheck.push_back((*importedJets)[i]);
120  }
121  }
122 
123  if (m_selectionString=="") { // check all jets as user didn't provide a selection string
124  for(const auto *jet : *importedJets){
125  for( size_t j = 0; j < jet->numConstituents(); ++j ) {
126  auto ufo = jet->constituentLinks().at(j);
127  int index = ufo.index();
128  maskUFOs[index] = true;
129  const xAOD::FlowElement* ufoO = dynamic_cast<const xAOD::FlowElement*>(*ufo);
130  if(!ufoO) continue;
131 
132  // Retrieve the track if UFO is charged or combined object
134  int index_trk = ufoO->chargedObject(0)->index();
135  if(index_trk>=0) {
136  maskTracks[index_trk] = true;
137  }
138  }
139 
140  // Loop over charged and neutral PFOs
141  for (size_t n = 0; n < ufoO->otherObjects().size(); ++n) {
142  int index_pfo = ufoO->otherObject(n)->index();
143  if(index_pfo<0) continue;
144 
145  const xAOD::FlowElement* fe = dynamic_cast<const xAOD::FlowElement*>(ufoO->otherObject(n));
146 
147  if(fe->signalType()==xAOD::FlowElement::SignalType::ChargedPFlow){
148  pfomaskCharged.at( index_pfo ) = true;
149  }
150  else if(fe->signalType()==xAOD::FlowElement::SignalType::NeutralPFlow){
151  pfomaskNeutral.at( index_pfo ) = true;
152  }
153  }
154  }
155  }
156 
157  } else {
158 
159  for (auto & jetIt : jetToCheck) {
160  for( size_t j = 0; j < jetIt->numConstituents(); ++j ) {
161  auto ufo = jetIt->constituentLinks().at(j);
162  int index = ufo.index();
163  maskUFOs[index] = true;
164 
165  const xAOD::FlowElement* ufoO = dynamic_cast<const xAOD::FlowElement*>(*ufo);
166  if(!ufoO) continue;
167 
169  int index_trk = ufoO->chargedObject(0)->index();
170  if(index_trk>=0) {
171  maskTracks[index_trk] = true;
172  }
173  }
174 
175  for (size_t n = 0; n < ufoO->otherObjects().size(); ++n) {
176  int index_pfo = ufoO->otherObject(n)->index();
177  if(index_pfo<0) continue;
178 
179  const xAOD::FlowElement* fe = dynamic_cast<const xAOD::FlowElement*>(ufoO->otherObject(n));
180 
181  if(fe->signalType()==xAOD::FlowElement::SignalType::ChargedPFlow){
182  pfomaskCharged.at( index_pfo ) = true;
183  }
184  else if(fe->signalType()==xAOD::FlowElement::SignalType::NeutralPFlow){
185  pfomaskNeutral.at( index_pfo ) = true;
186  }
187  }
188  }
189  }
190  }
191 
192  // Execute the thinning service based on the mask. Finish.
193  if(m_thinTracks){
194  importedTrackParticles.keep (maskTracks);
195  }
196  importedPFONeutral.keep (pfomaskNeutral);
197  importedPFOCharged.keep (pfomaskCharged);
198  importedUFOs.keep (maskUFOs);
199 
200  for(unsigned int i = 0; i < m_addPFOChargedSGKey.size(); i++){
203 
204  tempPFOCharged.keep(pfomaskCharged);
205  tempPFONeutral.keep(pfomaskNeutral);
206  }
207 
208  return StatusCode::SUCCESS;
209 }

◆ finalize()

StatusCode DerivationFramework::UFOTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 61 of file UFOTrackParticleThinning.cxx.

62 {
63  return StatusCode::SUCCESS;
64 }

◆ initialize()

StatusCode DerivationFramework::UFOTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 25 of file UFOTrackParticleThinning.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.key() << " as the source collection for inner detector track particles");
31 
32  m_PFOChargedSGKey = m_PFOSGKey+"ChargedParticleFlowObjects";
33  m_PFONeutralSGKey = m_PFOSGKey+"NeutralParticleFlowObjects";
36  ATH_MSG_INFO("Using " << m_PFONeutralSGKey.key() << "and " << m_PFOChargedSGKey.key() << " as the source collection for the PFlow collection");
37 
38  for(unsigned int i = 0; i < m_addPFOSGKey.size(); i++){
39  m_tmpAddPFOChargedSGKey = m_addPFOSGKey[i]+"ChargedParticleFlowObjects";
42  m_tmpAddPFONeutralSGKey = m_addPFOSGKey[i]+"NeutralParticleFlowObjects";
45  }
46 
47  ATH_CHECK( m_ufoSGKey.initialize(m_streamName));
48  ATH_MSG_INFO("Using " << m_ufoSGKey.key()<< " as the source collection for UFOs");
49 
50  ATH_CHECK( m_jetSGKey.initialize());
51  ATH_MSG_INFO("Using " << m_jetSGKey.key() << " as the source collection for UFOs");
52 
53  if (!m_selectionString.empty()){
54  // order must match enum order EJetTrPThinningParser
55  ATH_CHECK( initializeParser( m_selectionString ));
56  }
57 
58  return StatusCode::SUCCESS;
59 }

Member Data Documentation

◆ m_addPFOChargedSGKey

std::vector<SG::ThinningHandleKey<xAOD::FlowElementContainer> > DerivationFramework::UFOTrackParticleThinning::m_addPFOChargedSGKey
private

Definition at line 48 of file UFOTrackParticleThinning.h.

◆ m_addPFONeutralSGKey

std::vector<SG::ThinningHandleKey<xAOD::FlowElementContainer> > DerivationFramework::UFOTrackParticleThinning::m_addPFONeutralSGKey
private

Definition at line 49 of file UFOTrackParticleThinning.h.

◆ m_addPFOSGKey

Gaudi::Property<std::vector<std::string> > DerivationFramework::UFOTrackParticleThinning::m_addPFOSGKey { this, "AdditionalPFOKey", {}, ""}
private

Definition at line 45 of file UFOTrackParticleThinning.h.

◆ m_inDetSGKey

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

Definition at line 40 of file UFOTrackParticleThinning.h.

◆ m_jetSGKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::UFOTrackParticleThinning::m_jetSGKey { this, "JetKey", "", ""}
private

Definition at line 51 of file UFOTrackParticleThinning.h.

◆ m_PFOChargedSGKey

SG::ThinningHandleKey<xAOD::FlowElementContainer> DerivationFramework::UFOTrackParticleThinning::m_PFOChargedSGKey { this, "PFOChargedCollectionSGKey", "GlobalChargedParticleFlowObjects", "" }
private

Definition at line 43 of file UFOTrackParticleThinning.h.

◆ m_PFONeutralSGKey

SG::ThinningHandleKey<xAOD::FlowElementContainer> DerivationFramework::UFOTrackParticleThinning::m_PFONeutralSGKey { this, "PFONeutralCollectionSGKey", "GlobalNeutralParticleFlowObjects", "" }
private

Definition at line 44 of file UFOTrackParticleThinning.h.

◆ m_PFOSGKey

Gaudi::Property<std::string> DerivationFramework::UFOTrackParticleThinning::m_PFOSGKey { this, "PFOCollectionSGKey", "Global", "" }
private

Definition at line 42 of file UFOTrackParticleThinning.h.

◆ m_selectionString

StringProperty DerivationFramework::UFOTrackParticleThinning::m_selectionString { this, "SelectionString", "", "" }
private

Definition at line 52 of file UFOTrackParticleThinning.h.

◆ m_streamName

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

Definition at line 39 of file UFOTrackParticleThinning.h.

◆ m_thinTracks

Gaudi::Property<bool> DerivationFramework::UFOTrackParticleThinning::m_thinTracks {this,"ThinTrackingContainer",true,"Toggle thinning of container with name InDetTrackParticlesKey"}
private

Definition at line 41 of file UFOTrackParticleThinning.h.

◆ m_tmpAddPFOChargedSGKey

SG::ThinningHandleKey<xAOD::FlowElementContainer> DerivationFramework::UFOTrackParticleThinning::m_tmpAddPFOChargedSGKey { this, "TempAddPFOChargedKey","",""}
private

Definition at line 46 of file UFOTrackParticleThinning.h.

◆ m_tmpAddPFONeutralSGKey

SG::ThinningHandleKey<xAOD::FlowElementContainer> DerivationFramework::UFOTrackParticleThinning::m_tmpAddPFONeutralSGKey { this, "TempAddPFONeutralKey","",""}
private

Definition at line 47 of file UFOTrackParticleThinning.h.

◆ m_ufoSGKey

SG::ThinningHandleKey<xAOD::FlowElementContainer> DerivationFramework::UFOTrackParticleThinning::m_ufoSGKey { this, "UFOKey", "UFOCSSK", "" }
private

Definition at line 50 of file UFOTrackParticleThinning.h.


The documentation for this class was generated from the following files:
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::UFOTrackParticleThinning::m_addPFOSGKey
Gaudi::Property< std::vector< std::string > > m_addPFOSGKey
Definition: UFOTrackParticleThinning.h:45
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
DerivationFramework::UFOTrackParticleThinning::m_PFONeutralSGKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_PFONeutralSGKey
Definition: UFOTrackParticleThinning.h:44
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::UFOTrackParticleThinning::m_thinTracks
Gaudi::Property< bool > m_thinTracks
Definition: UFOTrackParticleThinning.h:41
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
PUClassification.Charged
Charged
Definition: PUClassification.py:16
DerivationFramework::UFOTrackParticleThinning::m_tmpAddPFONeutralSGKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_tmpAddPFONeutralSGKey
Definition: UFOTrackParticleThinning.h:47
DerivationFramework::UFOTrackParticleThinning::m_PFOSGKey
Gaudi::Property< std::string > m_PFOSGKey
Definition: UFOTrackParticleThinning.h:42
DerivationFramework::UFOTrackParticleThinning::m_addPFOChargedSGKey
std::vector< SG::ThinningHandleKey< xAOD::FlowElementContainer > > m_addPFOChargedSGKey
Definition: UFOTrackParticleThinning.h:48
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::FlowElement_v1::signalType
signal_t signalType() const
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DerivationFramework::UFOTrackParticleThinning::m_PFOChargedSGKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_PFOChargedSGKey
Definition: UFOTrackParticleThinning.h:43
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
DerivationFramework::UFOTrackParticleThinning::m_tmpAddPFOChargedSGKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_tmpAddPFOChargedSGKey
Definition: UFOTrackParticleThinning.h:46
xAOD::FlowElement_v1::chargedObject
const xAOD::IParticle * chargedObject(std::size_t i) const
Definition: FlowElement_v1.cxx:127
DerivationFramework::UFOTrackParticleThinning::m_jetSGKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetSGKey
Definition: UFOTrackParticleThinning.h:51
DerivationFramework::UFOTrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: UFOTrackParticleThinning.h:40
DerivationFramework::UFOTrackParticleThinning::m_selectionString
StringProperty m_selectionString
Definition: UFOTrackParticleThinning.h:52
DerivationFramework::UFOTrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: UFOTrackParticleThinning.h:39
DerivationFramework::UFOTrackParticleThinning::m_addPFONeutralSGKey
std::vector< SG::ThinningHandleKey< xAOD::FlowElementContainer > > m_addPFONeutralSGKey
Definition: UFOTrackParticleThinning.h:49
DeMoScan.index
string index
Definition: DeMoScan.py:362
xAOD::FlowElement_v1::otherObject
const xAOD::IParticle * otherObject(std::size_t i) const
Definition: FlowElement_v1.cxx:196
entries
double entries
Definition: listroot.cxx:49
DerivationFramework::UFOTrackParticleThinning::m_ufoSGKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_ufoSGKey
Definition: UFOTrackParticleThinning.h:50
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
xAOD::FlowElement_v1::otherObjects
std::vector< const xAOD::IParticle * > otherObjects() const
Definition: FlowElement_v1.cxx:163
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25