ATLAS Offline Software
xAODShallowAuxContainerCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
11 
14 
15 }
16 
19  const std::string& key)
20 {
21 // std::cout << "Thinning shallow aux, size = " << trans->size() << std::endl;
22  if (trans->size() > 0) {
23 
24 
26  const xAOD::ShallowAuxContainer& orig = *trans; //need the 'const' version to ensure use the const methods!
27  size_t size = orig.size();
28  size_t nremaining = size;
29 
30  std::string key2 = key;
31  if (key2.size() >= 4 && key2.substr (key2.size()-4, 4) == "Aux.")
32  {
33  key2.erase (key2.size()-4, 4);
34  }
36  const SG::ThinningDecisionBase* dec = info ? info->m_decision : nullptr;
37  if (dec) {
38  nremaining = dec->thinnedSize();
39  }
40 
41  //if there is no thinning to do, then just return a regular copy
42  // Be sure to also check for variable vetoes.
43  if(!dec) {
45  if (info) {
46  ids = orig.getSelectedAuxIDs();
47  ids &= info->m_vetoed;
48  }
49  if (ids.empty()) {
50  return new xAOD::ShallowAuxContainer(orig);
51  }
52  }
53  xAOD::ShallowAuxContainer* newcont = new xAOD::ShallowAuxContainer; //dont use copy constructor (like copyThinned.h), want it to have it's own internal store
54  newcont->setParent(trans->parent());
55 
56  // newcont should be set for shallow IO regardless of the setting
57  // of the original container. Below we're going to copy all the
58  // variables that should be written. Any variables left in the
59  // parent that are not also in newcont are ones that were
60  // explicitly vetoed.
61  newcont->setShallowIO(true);
62 
63  // Access the auxiliary type registry:
65  // The auxiliary IDs that the original container has:
66  SG::auxid_set_t auxids = orig.getDynamicAuxIDs(); //all ids of a shallow container are dynamic, don't look at the parents unless not in shallow IO mode //orig.getAuxIDs();
67  SG::auxid_set_t sel_auxids = orig.getSelectedAuxIDs();
68 
69  newcont->getStore()->resize(nremaining); //had to access underlying store directly, can't call 'resize' on container
70 
71  SG::AuxVectorInterface dstIface (*newcont->getStore());
72  SG::AuxVectorInterface srcIface (orig);
73 
74  // Loop over all the variables of the original container:
75  for (SG::auxid_t auxid : auxids) {
76  // Skip null auxids (happens if we don't have the dictionary)
77  if(auxid == SG::null_auxid) continue;
78  // Skip non-selected dynamic variables.
79  if (info && info->vetoed (auxid)) continue;
80  if (sel_auxids.count(auxid) == 0) continue;
81  // Create the target variable:
82  (void)newcont->getStore()->getData (auxid, nremaining, nremaining); //use store's getData directly, not the container's getData ... saves on a copy!
83 
84  // Access the source variable:
85  const void* src = orig.getData (auxid);
86 
87  if (!src) continue;
88 
89  // Copy over all elements.
90  if (nremaining == size) {
91  // No thinning.
92  r.copyForOutput (auxid, dstIface, 0, srcIface, 0, size);
93  }
94  else {
95  // Thinning
96  for (std::size_t isrc = 0, idst = 0; isrc < size; ++isrc) {
97  if ( ! (dec && dec->thinned(isrc)) ) {
98  r.copyForOutput (auxid, dstIface, idst, srcIface, isrc, 1);
99  ++idst;
100  }
101  }
102  }
103  }
105 
106 /* HERE is the old code which is non optimal, but functional if modification to 'resize' method of shallowauxcontainer is made
107  newcont->setShallowIO(false); //necessary so that branch selections work
108  copyAuxStoreThinned (*trans, *newcont, dec); //FIXME: In this methods call to 'getData' it ends up doing an unnecessary copy of the parent store's values!
109 */ // std::cout << " Thinned size = " << newcont->size() << std::endl;
110  return newcont;
111  }
112  return new xAOD::ShallowAuxContainer(*trans);
113 }
114 
117  return poolReadObject<xAOD::ShallowAuxContainer>();
118 }
grepfile.info
info
Definition: grepfile.py:38
beamspotman.r
def r
Definition: beamspotman.py:676
CxxUtils::ConcurrentBitset::count
bit_t count() const
Count the number of 1 bits in the set.
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
AuxVectorInterface.h
Make an AuxVectorData object from either a raw vector or an aux store.
xAOD::ShallowAuxContainer::getDynamicAuxIDs
virtual const auxid_set_t & getDynamicAuxIDs() const override
Get the types(names) of variables created dynamically.
Definition: ShallowAuxContainer.cxx:563
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
xAODShallowAuxContainerCnv.h
SG::ThinningDecisionBase
Hold thinning decisions for one container.
Definition: ThinningDecisionBase.h:39
xAOD::ShallowAuxContainer::parent
const DataLink< SG::IConstAuxStore > & parent() const
Get the parent store.
Definition: ShallowAuxContainer.cxx:117
xAODShallowAuxContainerCnv::createTransientWithKey
virtual xAOD::ShallowAuxContainer * createTransientWithKey(const std::string &key) override
Function reading in the object from the input file.
Definition: xAODShallowAuxContainerCnv.cxx:116
xAOD::ShallowAuxContainer
Class creating a shallow copy of an existing auxiliary container.
Definition: ShallowAuxContainer.h:54
SG::ThinningDecisionBase::thinned
bool thinned(size_t ndx) const
Return true if element ndx should be thinned.
SG::ThinningDecisionBase::thinnedSize
size_t thinnedSize() const
Return the size of the container being thinned after thinning.
Definition: ThinningDecisionBase.cxx:42
xAOD::ShallowAuxContainer::setParent
void setParent(const DataLink< SG::IConstAuxStore > &link)
Set the parent store.
Definition: ShallowAuxContainer.cxx:123
xAOD::ShallowAuxContainer::size
virtual size_t size() const override
Get the size of the container.
Definition: ShallowAuxContainer.cxx:360
T_AthenaPoolCustomCnvWithKey
This templated class extends T_AthenaPoolCustCnv to provide management of the persistent objects crea...
Definition: T_AthenaPoolCustomCnv.h:35
module_driven_slicing.key2
key2
Definition: module_driven_slicing.py:159
xAODShallowAuxContainerCnv::createPersistentWithKey
virtual xAOD::ShallowAuxContainer * createPersistentWithKey(xAOD::ShallowAuxContainer *trans, const std::string &key) override
Function preparing the container to be written out.
Definition: xAODShallowAuxContainerCnv.cxx:18
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::ShallowAuxContainer::setShallowIO
void setShallowIO(bool value)
Set whether only the overriden parameters should be written out.
Definition: ShallowAuxContainer.cxx:137
SG::ThinningInfo
Hold thinning/slimming information for a given object.
Definition: ThinningInfo.h:40
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
getThinningCache.h
Helpers to retrieve the current thinning cache from the event context.
xAOD::ShallowAuxContainer::getStore
virtual SG::IAuxStore * getStore() override
Get the currently used internal store object.
Definition: ShallowAuxContainer.cxx:149
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
SG::AuxVectorInterface
Make an AuxVectorData object from either a raw array or an aux store.
Definition: AuxVectorInterface.h:33
SG::IAuxStore::getData
virtual void * getData(auxid_t auxid, size_t size, size_t capacity)=0
Return the data vector for one aux data item.
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
SG::IAuxStore::resize
virtual bool resize(size_t sz)=0
Change the size of all aux data vectors.
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
copyThinned.h
Helper to copy an object while applying thinning.
SG::getThinningInfo
const SG::ThinningInfo * getThinningInfo(const EventContext &ctx, const std::string &key)
Retrieve the current thinning information for key.
Definition: getThinningCache.cxx:54
xAODShallowAuxContainerCnv::xAODShallowAuxContainerCnv
xAODShallowAuxContainerCnv(ISvcLocator *svcLoc)
Converter constructor.
Definition: xAODShallowAuxContainerCnv.cxx:12
xAOD::ShallowAuxContainer::getData
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
Definition: ShallowAuxContainer.cxx:187
xAOD::ShallowAuxContainer::getSelectedAuxIDs
virtual auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected dynamic Aux variables (for writing)
Definition: ShallowAuxContainer.cxx:578
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37