ATLAS Offline Software
Loading...
Searching...
No Matches
TRTOverlay Class Reference

#include <TRTOverlay.h>

Inheritance diagram for TRTOverlay:
Collaboration diagram for TRTOverlay:

Public Member Functions

 TRTOverlay (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override final
virtual StatusCode execute (const EventContext &ctx) const override final
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode overlayContainer (const EventContext &ctx, const TRT_RDO_Container *bkgContainer, const TRT_RDO_Container *signalContainer, TRT_RDO_Container *outputContainer, const InDetSimDataCollection *signalSDOCollection, DataPool< TRT_LoLumRawData > &dataItemsPool) const
void mergeCollections (TRT_RDO_Collection *bkgCollection, TRT_RDO_Collection *signalCollection, TRT_RDO_Collection *outputCollection, double occupancy, const InDetSimDataCollection *signalSDOCollection, const TRTCond::StrawStatusData *strawStatusHT, CLHEP::HepRandomEngine *rndmEngine) const
 Here we take 2 view containers with elements owned by the DataPool we modify some of them and push them to a 3rd view container.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const TRT_IDm_trtId {}
Gaudi::Property< bool > m_sortBkgInput
SG::ReadHandleKey< TRT_RDO_Containerm_bkgInputKey
SG::ReadHandleKey< TRT_RDO_Containerm_signalInputKey
SG::WriteHandleKey< TRT_RDO_Containerm_outputKey
SG::ReadHandleKey< InDetSimDataCollectionm_signalInputSDOKey
SG::ReadCondHandleKey< TRTCond::StrawStatusDatam_strawStatusHTKey
ServiceHandle< IAthRNGSvcm_rndmSvc
Gaudi::Property< double > m_HTOccupancyCorrectionB
Gaudi::Property< double > m_HTOccupancyCorrectionEC
Gaudi::Property< double > m_HTOccupancyCorrectionB_noE
Gaudi::Property< double > m_HTOccupancyCorrectionEC_noE
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar_noE
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar_noE
ToolHandle< InDet::ITRT_LocalOccupancym_TRT_LocalOccupancyTool
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Friends

class OverlayTesting::TRTOverlay_test

Detailed Description

Definition at line 32 of file TRTOverlay.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TRTOverlay()

TRTOverlay::TRTOverlay ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 64 of file TRTOverlay.cxx.

65 : AthReentrantAlgorithm(name, pSvcLocator)
66{
67}

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode TRTOverlay::execute ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 101 of file TRTOverlay.cxx.

102{
103 ATH_MSG_DEBUG("execute() begin");
104
105 // Reading the input RDOs
106 const TRT_RDO_Container *bkgContainerPtr = nullptr;
107 if (!m_bkgInputKey.empty()) {
108 SG::ReadHandle<TRT_RDO_Container> bkgContainer(m_bkgInputKey, ctx);
109 if (!bkgContainer.isValid()) {
110 ATH_MSG_ERROR("Could not get background TRT RDO container " << bkgContainer.name() << " from store " << bkgContainer.store());
111 return StatusCode::FAILURE;
112 }
113 bkgContainerPtr = bkgContainer.cptr();
114
115 ATH_MSG_DEBUG("Found background TRT RDO container " << bkgContainer.name() << " in store " << bkgContainer.store());
116 ATH_MSG_DEBUG("TRT Background = " << Overlay::debugPrint(bkgContainer.cptr()));
117 }
118
119 SG::ReadHandle<TRT_RDO_Container> signalContainer(m_signalInputKey, ctx);
120 if (!signalContainer.isValid()) {
121 ATH_MSG_ERROR("Could not get signal TRT RDO container " << signalContainer.name() << " from store " << signalContainer.store());
122 return StatusCode::FAILURE;
123 }
124 ATH_MSG_DEBUG("Found signal TRT RDO container " << signalContainer.name() << " in store " << signalContainer.store());
125 ATH_MSG_DEBUG("TRT Signal = " << Overlay::debugPrint(signalContainer.cptr()));
126
127 SG::ReadHandle<InDetSimDataCollection> signalSDOContainer(m_signalInputSDOKey, ctx);
128 if (!signalSDOContainer.isValid()) {
129 ATH_MSG_ERROR("Could not get signal TRT SDO map container " << signalSDOContainer.name() << " from store " << signalSDOContainer.store());
130 return StatusCode::FAILURE;
131 }
132 ATH_MSG_DEBUG("Found signal TRT SDO map container " << signalSDOContainer.name() << " in store " << signalSDOContainer.store());
133
134 // The DataPool, this is what will actually own the elements
135 // we create during this algorithm. The containers are
136 // views.
137 DataPool<TRT_LoLumRawData> dataItemsPool(ctx);
138 dataItemsPool.prepareToAdd(200000);
139
140 // Creating output RDO container
141 SG::WriteHandle<TRT_RDO_Container> outputContainer(m_outputKey, ctx);
142 ATH_CHECK(outputContainer.record(std::make_unique<TRT_RDO_Container>(signalContainer->size())));
143 if (!outputContainer.isValid()) {
144 ATH_MSG_ERROR("Could not record output TRT RDO container " << outputContainer.name() << " to store " << outputContainer.store());
145 return StatusCode::FAILURE;
146 }
147 ATH_MSG_DEBUG("Recorded output TRT RDO container " << outputContainer.name() << " in store " << outputContainer.store());
148
149 ATH_CHECK(overlayContainer(ctx, bkgContainerPtr, signalContainer.cptr(),
150 outputContainer.ptr(), signalSDOContainer.cptr(),
151 dataItemsPool));
153 "TRT Result = " << Overlay::debugPrint(outputContainer.ptr()));
154
155 ATH_MSG_DEBUG("execute() end");
156 return StatusCode::SUCCESS;
157}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
SG::WriteHandleKey< TRT_RDO_Container > m_outputKey
Definition TRTOverlay.h:68
StatusCode overlayContainer(const EventContext &ctx, const TRT_RDO_Container *bkgContainer, const TRT_RDO_Container *signalContainer, TRT_RDO_Container *outputContainer, const InDetSimDataCollection *signalSDOCollection, DataPool< TRT_LoLumRawData > &dataItemsPool) const
SG::ReadHandleKey< TRT_RDO_Container > m_bkgInputKey
Definition TRTOverlay.h:62
SG::ReadHandleKey< InDetSimDataCollection > m_signalInputSDOKey
Definition TRTOverlay.h:71
SG::ReadHandleKey< TRT_RDO_Container > m_signalInputKey
Definition TRTOverlay.h:65
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ initialize()

StatusCode TRTOverlay::initialize ( )
finaloverridevirtual

Definition at line 69 of file TRTOverlay.cxx.

70{
71 ATH_MSG_DEBUG("Initializing...");
72
73 // Check and initialize keys
74 ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
75 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
76 ATH_CHECK( m_signalInputKey.initialize() );
77 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
78 ATH_CHECK( m_outputKey.initialize() );
79 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
80 ATH_CHECK( m_signalInputSDOKey.initialize() );
81 ATH_MSG_VERBOSE("Initialized ReadHandleKey for SDO: " << m_signalInputSDOKey);
82 ATH_CHECK( m_strawStatusHTKey.initialize() );
83 ATH_MSG_VERBOSE("Initialized ReadCondHandleKey: " << m_strawStatusHTKey);
84
85 // Retrieve TRT ID helper
86 if (!detStore()->retrieve(m_trtId, "TRT_ID").isSuccess() || !m_trtId) {
87 ATH_MSG_FATAL("Cannot retrieve TRT ID helper");
88 return StatusCode::FAILURE;
89 }
90
91 // Initialize random number generator
92 CHECK(m_rndmSvc.retrieve());
93
94 // Retrieve TRT local occupancy tool
96
97 return StatusCode::SUCCESS;
98}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
ToolHandle< InDet::ITRT_LocalOccupancy > m_TRT_LocalOccupancyTool
Definition TRTOverlay.h:98
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition TRTOverlay.h:79
SG::ReadCondHandleKey< TRTCond::StrawStatusData > m_strawStatusHTKey
Definition TRTOverlay.h:74
const TRT_ID * m_trtId
Definition TRTOverlay.h:57
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ mergeCollections()

void TRTOverlay::mergeCollections ( TRT_RDO_Collection * bkgCollection,
TRT_RDO_Collection * signalCollection,
TRT_RDO_Collection * outputCollection,
double occupancy,
const InDetSimDataCollection * signalSDOCollection,
const TRTCond::StrawStatusData * strawStatusHT,
CLHEP::HepRandomEngine * rndmEngine ) const
private

Here we take 2 view containers with elements owned by the DataPool we modify some of them and push them to a 3rd view container.

Definition at line 288 of file TRTOverlay.cxx.

295{
296 if (bkgCollection->identify() != signalCollection->identify()) {
297 throw std::runtime_error("mergeCollections(): collection Id mismatch");
298 }
299
300 // Merge by copying ptrs from background and signal to output collection
301 TRT_RDO_Collection::size_type ibkg = 0, isig = 0;
302
303 outputCollection->reserve(
304 std::max(bkgCollection->size(), signalCollection->size()));
305 // Below we have swapElements.
306 // Remember the elements of the signalCollection and bkgCollection
307 // containers are owned by the DataPool.
308 // tmpBkg and tmp are whaterver elements we take out of the containers.
309 //
310 // So
311 // A) We can not delete them. dataPool will do that at the end of the event.
312 // B) We can push them back only to a View so outputCollection is a view
313 // collection
314 // C) We pass nullptr so no need to get another item from the pool
315
316 while ((ibkg < bkgCollection->size()) || (isig < signalCollection->size())) {
317 // The RDO that goes to the output at the end of this step.
318 TRT_RDORawData *tmp{};
319
320 if (isig == signalCollection->size()) {
321 // just copy the remaining background digits
322 bkgCollection->swapElement(ibkg++, nullptr, tmp);
323 } else if (ibkg == bkgCollection->size()) {
324 // just copy the remaining signal digits
325 signalCollection->swapElement(isig++, nullptr, tmp);
326 } else {
327 // Need to decide which one goes first.
328 // See comments in TRTDigitization.cxx about the assumption that id1<id2 <=> hash1<hash2
329 if (signalCollection->at(isig)->identify() < bkgCollection->at(ibkg)->identify()) {
330 signalCollection->swapElement(isig++, nullptr, tmp);
331 } else if (bkgCollection->at(ibkg)->identify() < signalCollection->at(isig)->identify()) {
332 bkgCollection->swapElement(ibkg++, nullptr, tmp);
333 } else {
334 // The hits are on the same channel.
335 TRT_RDORawData *tmpBkg{};
336
337 bkgCollection->swapElement(ibkg++, nullptr, tmpBkg);
338 signalCollection->swapElement(isig++, nullptr, tmp);
339
340 TRT_LoLumRawData *sigRdo = dynamic_cast<TRT_LoLumRawData *>(tmp);
341 const TRT_LoLumRawData *bkgRdo = dynamic_cast<const TRT_LoLumRawData *>(tmpBkg);
342
343 if (sigRdo && bkgRdo) {
344 // the actual merging
345 sigRdo->merge(*bkgRdo);
346
347 // If the hit is not already a high level hit
348 if (!(sigRdo->getWord() & 0x04020100)) {
349 // Determine if the hit is from an electron or not
350 bool isElectron = false;
351 Identifier rdoId = sigRdo->identify();
352 InDetSimDataCollection::const_iterator sdoIter = signalSDOCollection->find(rdoId);
353 if (sdoIter != signalSDOCollection->end()) {
354 const std::vector<InDetSimData::Deposit> &deposits = sdoIter->second.getdeposits();
355 for (const InDetSimData::Deposit &deposit : deposits) {
356 const HepMcParticleLink &particleLink = deposit.first;
357 if (particleLink.isValid()) {
358 if (std::abs(particleLink->pdg_id()) == 11) {
359 isElectron = true;
360 break;
361 }
362 }
363 }
364 }
365
366 // Determine what type of straw was hit
367 bool isXenonStraw = false;
368 if (strawStatusHT != nullptr) {
369 if (strawStatusHT->findStatus(m_trtId->straw_hash(rdoId)) == TRTCond::StrawStatus::Good) {
370 isXenonStraw = true;
371 }
372 }
373
374 // Get random number
375 int det = m_trtId->barrel_ec(rdoId);
376 float HTOccupancyCorrection = 0.;
377 if (isXenonStraw) {
378 if (isElectron) {
379 HTOccupancyCorrection = std::abs(det) > 1 ? m_HTOccupancyCorrectionEC : m_HTOccupancyCorrectionB;
380 } else {
381 HTOccupancyCorrection = std::abs(det) > 1 ? m_HTOccupancyCorrectionEC_noE : m_HTOccupancyCorrectionB_noE;
382 }
383 } else {
384 if (isElectron) {
385 HTOccupancyCorrection = std::abs(det) > 1 ? m_HTOccupancyCorrectionEC_Ar : m_HTOccupancyCorrectionB_Ar;
386 } else {
387 HTOccupancyCorrection = std::abs(det) > 1 ? m_HTOccupancyCorrectionEC_Ar_noE : m_HTOccupancyCorrectionB_Ar_noE;
388 }
389 }
390
391 unsigned int newWord = 0;
392 if (HTOccupancyCorrection != 0. && occupancy * HTOccupancyCorrection > CLHEP::RandFlat::shoot(rndmEngine, 0, 1)) {
393 newWord += 1 << (26-9);
394 }
395
396 TRT_LoLumRawData newRdo(rdoId, newWord);
397 sigRdo->merge(newRdo);
398 }
399 } else {
400 ATH_MSG_WARNING("TRT RDO is the wrong format");
401 }
402 }
403 }
404
405 outputCollection->push_back(tmp);
406 } // <= while
407}
#define ATH_MSG_WARNING(x)
bool isElectron(const T &p)
Definition AtlasPID.h:202
typename DataVectorBase< TRT_RDORawData >::Base::size_type size_type
Definition DataVector.h:814
const RawDataT * at(size_type n) const
void swapElement(size_type index, value_type newElem, reference oldElem)
size_type size() const noexcept
virtual Identifier identify() const override final
void merge(const InDetRawData &other)
virtual Identifier identify() const override final
unsigned int getWord() const
std::pair< HepMcParticleLink, float > Deposit
unsigned int findStatus(const IdentifierHash &hashID) const
Gaudi::Property< double > m_HTOccupancyCorrectionB_noE
Definition TRTOverlay.h:86
Gaudi::Property< double > m_HTOccupancyCorrectionEC_noE
Definition TRTOverlay.h:88
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar_noE
Definition TRTOverlay.h:94
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar
Definition TRTOverlay.h:90
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar
Definition TRTOverlay.h:92
Gaudi::Property< double > m_HTOccupancyCorrectionEC
Definition TRTOverlay.h:84
Gaudi::Property< double > m_HTOccupancyCorrectionB
Definition TRTOverlay.h:82
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar_noE
Definition TRTOverlay.h:96

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ overlayContainer()

StatusCode TRTOverlay::overlayContainer ( const EventContext & ctx,
const TRT_RDO_Container * bkgContainer,
const TRT_RDO_Container * signalContainer,
TRT_RDO_Container * outputContainer,
const InDetSimDataCollection * signalSDOCollection,
DataPool< TRT_LoLumRawData > & dataItemsPool ) const
private

Definition at line 160 of file TRTOverlay.cxx.

166{
167
168 // There are some use cases where background is empty
169 if (!bkgContainer) {
170 // Only loop through the signal collections and copy them over
171 for (const auto &[hashId, ptr] : signalContainer->GetAllHashPtrPair()) {
172 // Copy the signal collection
173 // pools own the individual elements
174 std::unique_ptr<TRT_RDO_Collection> signalCollection = copyCollection(hashId, ptr, dataItemsPool);
175
176 if (outputContainer->addCollection(signalCollection.get(), hashId).isFailure()) {
177 ATH_MSG_ERROR("Adding signal Collection with hashId " << hashId << " failed");
178 return StatusCode::FAILURE;
179 } else {
180 (void)signalCollection.release();
181 }
182 }
183
184 return StatusCode::SUCCESS;
185 }
186
187 // Setup the random engine
188 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
189 rngWrapper->setSeed( name(), ctx );
190 CLHEP::HepRandomEngine *rndmEngine = rngWrapper->getEngine(ctx);
191
192 // Load TRT conditions
193 SG::ReadCondHandle<TRTCond::StrawStatusData> strawStatusHTHandle{ m_strawStatusHTKey, ctx };
194 const TRTCond::StrawStatusData *strawStatusHT{*strawStatusHTHandle};
195
196 // Retrieve the occupancy map
197 std::map<int, double> occupancyMap = m_TRT_LocalOccupancyTool->getDetectorOccupancy(ctx, bkgContainer);
198
199 // The MC signal container should typically be smaller than bkgContainer,
200 // because the latter contains all the noise, minimum bias and pile up.
201 // Thus we firstly iterate over signal hashes and store them in a map.
202 std::vector < std::pair<IdentifierHash, bool> > overlapMap;
203 overlapMap.reserve(signalContainer->numberOfCollections());
204 for (const auto &[hashId, ptr] : signalContainer->GetAllHashPtrPair()) {
205 overlapMap.emplace_back(hashId, false);
206 }
207
208 // Now loop through the background hashes and copy unique ones over
209 for (const auto &[hashId, ptr] : bkgContainer->GetAllHashPtrPair()) {
210 auto search = std::lower_bound( overlapMap.begin(), overlapMap.end(), hashId,
211 [](const std::pair<IdentifierHash, bool> &lhs, IdentifierHash rhs) -> bool { return lhs.first < rhs; } );
212 if (search == overlapMap.end() || search->first != hashId) {
213 // Copy the background collection
214 std::unique_ptr<TRT_RDO_Collection> bkgCollection{};
215 if (m_sortBkgInput) {
216 // copy the bkg again Pool owns the individual elements
217 bkgCollection = copyCollectionAndSort(hashId, bkgContainer->indexFindPtr(hashId),dataItemsPool);
218 } else {
219 bkgCollection = copyCollection(hashId, bkgContainer->indexFindPtr(hashId),dataItemsPool);
220 }
221
222 if (outputContainer->addCollection(bkgCollection.get(), hashId).isFailure()) {
223 ATH_MSG_ERROR("Adding background Collection with hashId " << hashId << " failed");
224 return StatusCode::FAILURE;
225 } else {
226 (void)bkgCollection.release();
227 }
228 } else {
229 // Flip the overlap flag
230 search->second = true;
231 }
232 }
233
234 // Finally loop through the map and process the signal and overlay if
235 // necessary
236 for (const auto &[hashId, overlap] : overlapMap) {
237 // Copy the signal collection the pool owns the individual elements
238 std::unique_ptr<TRT_RDO_Collection> signalCollection =
239 copyCollection(hashId, signalContainer->indexFindPtr(hashId),dataItemsPool);
240
241 if (overlap) { // Do overlay
242 // Create the output collection, only works for Inner Detector
243 auto outputCollection = std::make_unique<TRT_RDO_Collection>(hashId);
244 outputCollection->setIdentifier(signalCollection->identify());
245 // This will receive merged elements from the other containers.
246 // There elements are owned actually by the DataPool
248
249 // Copy the background collection the pool owns the individual elements
250 std::unique_ptr<TRT_RDO_Collection> bkgCollection{};
251 if (m_sortBkgInput) {
252 bkgCollection = copyCollectionAndSort(hashId, bkgContainer->indexFindPtr(hashId),dataItemsPool);
253 } else {
254 bkgCollection = copyCollection(hashId, bkgContainer->indexFindPtr(hashId),dataItemsPool);
255 }
256
257 // Merge collections
258 int det = m_trtId->barrel_ec(signalCollection->identify());
259 mergeCollections(bkgCollection.get(),
260 signalCollection.get(),
261 outputCollection.get(),
262 occupancyMap[det],
263 signalSDOCollection,
264 strawStatusHT,
265 rndmEngine);
266
267 if (outputContainer->addCollection(outputCollection.get(), hashId).isFailure()) {
268 ATH_MSG_ERROR("Adding overlaid Collection with hashId " << hashId << " failed");
269 return StatusCode::FAILURE;
270 } else {
271 outputCollection.release();
272 }
273 } else { // Only write signal out
274 if (outputContainer->addCollection(signalCollection.get(), hashId).isFailure()) {
275 ATH_MSG_ERROR("Adding signal Collection with hashId " << hashId << " failed");
276 return StatusCode::FAILURE;
277 } else {
278 (void)signalCollection.release();
279 }
280 }
281 }
282
283 return StatusCode::SUCCESS;
284}
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
virtual size_t numberOfCollections() const override final
return number of collections
const std::vector< EventContainers::hashPair< T > > & GetAllHashPtrPair() const
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Gaudi::Property< bool > m_sortBkgInput
Definition TRTOverlay.h:59
void mergeCollections(TRT_RDO_Collection *bkgCollection, TRT_RDO_Collection *signalCollection, TRT_RDO_Collection *outputCollection, double occupancy, const InDetSimDataCollection *signalSDOCollection, const TRTCond::StrawStatusData *strawStatusHT, CLHEP::HepRandomEngine *rndmEngine) const
Here we take 2 view containers with elements owned by the DataPool we modify some of them and push th...
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition hcg.cxx:739
std::unique_ptr< HGTD_RDO_Collection > copyCollection(const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

◆ OverlayTesting::TRTOverlay_test

friend class OverlayTesting::TRTOverlay_test
friend

Definition at line 34 of file TRTOverlay.h.

Member Data Documentation

◆ m_bkgInputKey

SG::ReadHandleKey<TRT_RDO_Container> TRTOverlay::m_bkgInputKey
private
Initial value:
{
this, "BkgInputKey", "Bkg_TRT_RDOs",
" ReadHandleKey for Background Input TRT_RDO_Container"}

Definition at line 62 of file TRTOverlay.h.

62 {
63 this, "BkgInputKey", "Bkg_TRT_RDOs",
64 " ReadHandleKey for Background Input TRT_RDO_Container"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_HTOccupancyCorrectionB

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionB
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionBarrel", 0.110, ""}

Definition at line 82 of file TRTOverlay.h.

82 {
83 this, "TRT_HT_OccupancyCorrectionBarrel", 0.110, ""};

◆ m_HTOccupancyCorrectionB_Ar

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionB_Ar
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionBarrelAr", 0.100, ""}

Definition at line 90 of file TRTOverlay.h.

90 {
91 this, "TRT_HT_OccupancyCorrectionBarrelAr", 0.100, ""};

◆ m_HTOccupancyCorrectionB_Ar_noE

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionB_Ar_noE
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionBarrelArNoE", 0.088, ""}

Definition at line 94 of file TRTOverlay.h.

94 {
95 this, "TRT_HT_OccupancyCorrectionBarrelArNoE", 0.088, ""};

◆ m_HTOccupancyCorrectionB_noE

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionB_noE
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionBarrelNoE", 0.060, ""}

Definition at line 86 of file TRTOverlay.h.

86 {
87 this, "TRT_HT_OccupancyCorrectionBarrelNoE", 0.060, ""};

◆ m_HTOccupancyCorrectionEC

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionEC
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionEndcap", 0.090, ""}

Definition at line 84 of file TRTOverlay.h.

84 {
85 this, "TRT_HT_OccupancyCorrectionEndcap", 0.090, ""};

◆ m_HTOccupancyCorrectionEC_Ar

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionEC_Ar
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionEndcapAr", 0.101, ""}

Definition at line 92 of file TRTOverlay.h.

92 {
93 this, "TRT_HT_OccupancyCorrectionEndcapAr", 0.101, ""};

◆ m_HTOccupancyCorrectionEC_Ar_noE

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionEC_Ar_noE
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionEndcapArNoE", 0.102, ""}

Definition at line 96 of file TRTOverlay.h.

96 {
97 this, "TRT_HT_OccupancyCorrectionEndcapArNoE", 0.102, ""};

◆ m_HTOccupancyCorrectionEC_noE

Gaudi::Property<double> TRTOverlay::m_HTOccupancyCorrectionEC_noE
private
Initial value:
{
this, "TRT_HT_OccupancyCorrectionEndcapNoE", 0.050, ""}

Definition at line 88 of file TRTOverlay.h.

88 {
89 this, "TRT_HT_OccupancyCorrectionEndcapNoE", 0.050, ""};

◆ m_outputKey

SG::WriteHandleKey<TRT_RDO_Container> TRTOverlay::m_outputKey
private
Initial value:
{
this, "OutputKey", "TRT_RDOs",
"WriteHandleKey for Output TRT_RDO_Container"}

Definition at line 68 of file TRTOverlay.h.

68 {
69 this, "OutputKey", "TRT_RDOs",
70 "WriteHandleKey for Output TRT_RDO_Container"};

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> TRTOverlay::m_rndmSvc
private
Initial value:
{this, "RndmSvc", "AthRNGSvc",
"Random Number Service"}

Definition at line 79 of file TRTOverlay.h.

79 {this, "RndmSvc", "AthRNGSvc",
80 "Random Number Service"};

◆ m_signalInputKey

SG::ReadHandleKey<TRT_RDO_Container> TRTOverlay::m_signalInputKey
private
Initial value:
{
this, "SignalInputKey", "Sig_TRT_RDOs",
"ReadHandleKey for Signal Input TRT_RDO_Container"}

Definition at line 65 of file TRTOverlay.h.

65 {
66 this, "SignalInputKey", "Sig_TRT_RDOs",
67 "ReadHandleKey for Signal Input TRT_RDO_Container"};

◆ m_signalInputSDOKey

SG::ReadHandleKey<InDetSimDataCollection> TRTOverlay::m_signalInputSDOKey
private
Initial value:
{
this, "SignalInputSDOKey", "Sig_TRT_SDO_Map",
"ReadHandleKey for Signal Input InDetSimDataCollection for TRT"}

Definition at line 71 of file TRTOverlay.h.

71 {
72 this, "SignalInputSDOKey", "Sig_TRT_SDO_Map",
73 "ReadHandleKey for Signal Input InDetSimDataCollection for TRT"};

◆ m_sortBkgInput

Gaudi::Property<bool> TRTOverlay::m_sortBkgInput
private
Initial value:
{this, "SortBkgInput", false,
"Sort background input RDOs"}

Definition at line 59 of file TRTOverlay.h.

59 {this, "SortBkgInput", false,
60 "Sort background input RDOs"};

◆ m_strawStatusHTKey

SG::ReadCondHandleKey<TRTCond::StrawStatusData> TRTOverlay::m_strawStatusHTKey
private
Initial value:
{
this, "StrawStatusHT", "StrawStatusHTData", "StrawStatusHT key"}

Definition at line 74 of file TRTOverlay.h.

74 {
75 this, "StrawStatusHT", "StrawStatusHTData", "StrawStatusHT key"};

◆ m_TRT_LocalOccupancyTool

ToolHandle<InDet::ITRT_LocalOccupancy> TRTOverlay::m_TRT_LocalOccupancyTool
private
Initial value:
{
this, "TRT_LocalOccupancyTool", "TRT_LocalOccupancy", ""}

Definition at line 98 of file TRTOverlay.h.

98 {
99 this, "TRT_LocalOccupancyTool", "TRT_LocalOccupancy", ""};

◆ m_trtId

const TRT_ID* TRTOverlay::m_trtId {}
private

Definition at line 57 of file TRTOverlay.h.

57{};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: