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

#include <EventInfoPixelDecorator.h>

Inheritance diagram for DerivationFramework::EventInfoPixelDecorator:
Collaboration diagram for DerivationFramework::EventInfoPixelDecorator:

Public Member Functions

 EventInfoPixelDecorator (const std::string &type, const std::string &name, const IInterface *parent)
 
StatusCode initialize ()
 
StatusCode finalize ()
 
virtual StatusCode addBranches () const
 

Private Types

enum  EIntDecor {
  kperModuleMultiplicity, klayer, keta_module, kphi_module,
  kNIntDecor
}
 

Private Attributes

Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "" , "" }
 
std::atomic< unsigned int > m_ntot {}
 
std::atomic< unsigned int > m_npass {}
 
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey { this, "EventInfoKey", "EventInfo", ""}
 
Gaudi::Property< std::string > m_decorationPrefix { this, "DecorationPrefix", "", ""}
 
SG::ReadHandleKey< xAOD::TrackMeasurementValidationContainerm_pixelKey { this, "TrackMeasurementValidationKey", "PixelClusters", ""}
 
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
 

Detailed Description

Definition at line 26 of file EventInfoPixelDecorator.h.

Member Enumeration Documentation

◆ EIntDecor

Enumerator
kperModuleMultiplicity 
klayer 
keta_module 
kphi_module 
kNIntDecor 

Definition at line 48 of file EventInfoPixelDecorator.h.

Constructor & Destructor Documentation

◆ EventInfoPixelDecorator()

DerivationFramework::EventInfoPixelDecorator::EventInfoPixelDecorator ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 23 of file EventInfoPixelDecorator.cxx.

25  :
26  base_class(type,name,parent)
27  {
28  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::EventInfoPixelDecorator::addBranches ( ) const
virtual

Definition at line 79 of file EventInfoPixelDecorator.cxx.

80  {
81  ATH_MSG_DEBUG("Adding per-module information to EventInfo");
82  const EventContext& ctx = Gaudi::Hive::currentContext();
83 
85  CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
86 
87  // Get the cluster container
89  if (!clusters.isValid()) {
90  ATH_MSG_ERROR ("Couldn't retrieve TrackMeasurementValidationContainer with key" << m_pixelKey.key());
91  return StatusCode::FAILURE;
92  }
93 
94  // Check the event contains clusters
95  unsigned int nClusters = clusters->size();
96  if (nClusters==0) return StatusCode::SUCCESS;
97 
98  // Set up a mask with the same entries as the full collection
99  std::vector<bool> mask;
100  mask.assign(nClusters,false); // default: don't keep anything
101  m_ntot += nClusters;
102 
103  // Execute the text parser and update the mask
104  if (m_parser) {
105  std::vector<int> entries = m_parser->evaluateAsVector();
106  unsigned int nEntries = entries.size();
107  // check the sizes are compatible
108  if (nClusters != nEntries ) {
109  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used the same collection as the input collection??");
110  return StatusCode::FAILURE;
111  } else {
112  // set mask
113  for (unsigned int i=0; i<nClusters; ++i) if (entries[i]==1) mask[i]=true;
114  }
115  }
116  // Count the mask
117  unsigned int n_pass=0;
118  for (unsigned int i=0; i<nClusters; ++i) {
119  if (mask[i]) ++n_pass;
120  }
121  m_npass += n_pass;
122 
123  // fill the per-module information
124  std::array<std::vector<int>,kNIntDecor> vec;
125 
126  unsigned int i=0;
127  std::vector<int> keys;
128  for (const xAOD::TrackMeasurementValidation* clusIt : *clusters) {
129 
130  if( !mask[++i] ) continue;
131 
132  static const SG::AuxElement::Accessor<int> acc_layer("layer");
133  int clus_layer = acc_layer(*clusIt);
134  static const SG::AuxElement::Accessor<int> acc_eta_module("eta_module");
135  int clus_eta_module = acc_eta_module(*clusIt);
136  static const SG::AuxElement::Accessor<int> acc_phi_module("phi_module");
137  int clus_phi_module = acc_phi_module(*clusIt);
138 
139  int key = clus_layer * 10000 + clus_eta_module * 100 + clus_phi_module;
140  unsigned int index = 9999;
141  for( unsigned int j = 0; j < keys.size() ; j++ )
142  if( key == keys[j] ){
143  index = j;
144  break;
145  }
146  if( index == 9999 ){
147  keys.push_back( key );
148  vec[klayer].push_back( clus_layer );
149  vec[keta_module].push_back( clus_eta_module );
150  vec[kphi_module].push_back( clus_phi_module );
151  vec[kperModuleMultiplicity].push_back( 1 );
152  } else {
153  assert(index < vec[kperModuleMultiplicity].size());
155  }
156  }
157 
158  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int> > > int_decor_handles(createDecorators<xAOD::EventInfo,std::vector<int> >(m_intDecorKeys,ctx));
159  assert(int_decor_handles.size() == kNIntDecor);
160  for(unsigned int decorate_i=0; decorate_i<int_decor_handles.size(); ++decorate_i) {
161  int_decor_handles[decorate_i](*eventInfo) = std::move(vec[decorate_i]);
162  }
163 
164  return StatusCode::SUCCESS;
165  }

◆ finalize()

StatusCode DerivationFramework::EventInfoPixelDecorator::finalize ( )

Definition at line 71 of file EventInfoPixelDecorator.cxx.

72  {
73  ATH_MSG_VERBOSE("finalize() ...");
74  ATH_MSG_INFO("Processed "<< m_ntot <<" measurements, "<< m_npass<< " were used for the per-module summary");
75  ATH_CHECK( finalizeParser() );
76  return StatusCode::SUCCESS;
77  }

◆ initialize()

StatusCode DerivationFramework::EventInfoPixelDecorator::initialize ( )

Definition at line 30 of file EventInfoPixelDecorator.cxx.

31  {
32  ATH_MSG_VERBOSE("initialize() ...");
33 
34  if (m_selectionString.empty()) {
35  ATH_MSG_FATAL("No inner detector track selection string provided!");
36  return StatusCode::FAILURE;
37  } else {ATH_MSG_INFO("Selection string for the per-module pixel cluster decoration: " << m_selectionString);}
38 
39  if (m_decorationPrefix.empty()) {
40  ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoPixelDecorator!");
41  }
42 
43  if (m_eventInfoKey.key().empty()) {
44  ATH_MSG_ERROR("No collection provided for EventInfoPixelDecorator!");
45  return StatusCode::FAILURE;
46  }
48 
49  //check xAOD::TrackMeasurementValidation collection
50  ATH_CHECK(m_pixelKey.initialize());
51  ATH_MSG_INFO("Using " << m_pixelKey.key() << " as the source collection for EventInfoPixelDecorator.");
52 
53  // Set up the text-parsing machinery
54  if (!m_selectionString.empty()) {
55  ATH_CHECK( initializeParser(m_selectionString));
56  }
57 
58  {
59  std::vector<std::string> names;
60  names.resize(kNIntDecor);
61  names[kperModuleMultiplicity] ="perModuleMultiplicity";
62  names[klayer] ="layer";
63  names[keta_module] ="eta_module";
64  names[kphi_module] ="phi_module";
66  }
67 
68  return StatusCode::SUCCESS;
69  }

Member Data Documentation

◆ m_decorationPrefix

Gaudi::Property<std::string> DerivationFramework::EventInfoPixelDecorator::m_decorationPrefix { this, "DecorationPrefix", "", ""}
private

Definition at line 43 of file EventInfoPixelDecorator.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::EventInfoPixelDecorator::m_eventInfoKey { this, "EventInfoKey", "EventInfo", ""}
private

Definition at line 41 of file EventInfoPixelDecorator.h.

◆ m_intDecorKeys

std::vector<SG::WriteDecorHandleKey<xAOD::EventInfo> > DerivationFramework::EventInfoPixelDecorator::m_intDecorKeys
private

Definition at line 53 of file EventInfoPixelDecorator.h.

◆ m_npass

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

Definition at line 39 of file EventInfoPixelDecorator.h.

◆ m_ntot

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

Definition at line 38 of file EventInfoPixelDecorator.h.

◆ m_pixelKey

SG::ReadHandleKey<xAOD::TrackMeasurementValidationContainer> DerivationFramework::EventInfoPixelDecorator::m_pixelKey { this, "TrackMeasurementValidationKey", "PixelClusters", ""}
private

Definition at line 45 of file EventInfoPixelDecorator.h.

◆ m_selectionString

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

Definition at line 35 of file EventInfoPixelDecorator.h.


The documentation for this class was generated from the following files:
DerivationFramework::EventInfoPixelDecorator::kphi_module
@ kphi_module
Definition: EventInfoPixelDecorator.h:51
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::createDecoratorKeys
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
Definition: DecoratorUtils.h:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
index
Definition: index.py:1
DerivationFramework::EventInfoPixelDecorator::m_ntot
std::atomic< unsigned int > m_ntot
Definition: EventInfoPixelDecorator.h:38
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::EventInfoPixelDecorator::m_pixelKey
SG::ReadHandleKey< xAOD::TrackMeasurementValidationContainer > m_pixelKey
Definition: EventInfoPixelDecorator.h:46
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
DerivationFramework::EventInfoPixelDecorator::kNIntDecor
@ kNIntDecor
Definition: EventInfoPixelDecorator.h:52
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
xAOD::TrackMeasurementValidation_v1
Class describing a TrackMeasurementValidation.
Definition: TrackMeasurementValidation_v1.h:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.subdetectors.mmg.names
names
Definition: mmg.py:8
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DerivationFramework::EventInfoPixelDecorator::keta_module
@ keta_module
Definition: EventInfoPixelDecorator.h:50
DerivationFramework::EventInfoPixelDecorator::m_npass
std::atomic< unsigned int > m_npass
Definition: EventInfoPixelDecorator.h:39
DerivationFramework::EventInfoPixelDecorator::kperModuleMultiplicity
@ kperModuleMultiplicity
Definition: EventInfoPixelDecorator.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DerivationFramework::EventInfoPixelDecorator::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: EventInfoPixelDecorator.h:36
columnar::ContainerId::eventInfo
@ eventInfo
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DeMoScan.index
string index
Definition: DeMoScan.py:364
DerivationFramework::EventInfoPixelDecorator::klayer
@ klayer
Definition: EventInfoPixelDecorator.h:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::EventInfoPixelDecorator::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: EventInfoPixelDecorator.h:42
DerivationFramework::createDecorators
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Definition: DecoratorUtils.h:51
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
entries
double entries
Definition: listroot.cxx:49
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
DerivationFramework::EventInfoPixelDecorator::m_intDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
Definition: EventInfoPixelDecorator.h:53
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::EventInfoPixelDecorator::m_decorationPrefix
Gaudi::Property< std::string > m_decorationPrefix
Definition: EventInfoPixelDecorator.h:44
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37