|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "CLHEP/Random/RandomEngine.h"
7 #include "CLHEP/Random/RandFlat.h"
45 (*datumCopy) =
TRT_LoLumRawData(existingDatum->identify(), existingDatum->getWord());
52 std::unique_ptr<TRT_RDO_Collection> copyCollectionAndSort(
88 return StatusCode::FAILURE;
97 return StatusCode::SUCCESS;
110 ATH_MSG_ERROR(
"Could not get background TRT RDO container " << bkgContainer.
name() <<
" from store " << bkgContainer.
store());
111 return StatusCode::FAILURE;
113 bkgContainerPtr = bkgContainer.
cptr();
115 ATH_MSG_DEBUG(
"Found background TRT RDO container " << bkgContainer.
name() <<
" in store " << bkgContainer.
store());
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;
124 ATH_MSG_DEBUG(
"Found signal TRT RDO container " << signalContainer.
name() <<
" in store " << signalContainer.
store());
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;
132 ATH_MSG_DEBUG(
"Found signal TRT SDO map container " << signalSDOContainer.
name() <<
" in store " << signalSDOContainer.
store());
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;
147 ATH_MSG_DEBUG(
"Recorded output TRT RDO container " << outputContainer.
name() <<
" in store " << outputContainer.
store());
150 outputContainer.
ptr(), signalSDOContainer.
cptr(),
156 return StatusCode::SUCCESS;
174 std::unique_ptr<TRT_RDO_Collection> signalCollection =
copyCollection(hashId,
ptr, dataItemsPool);
176 if (outputContainer->
addCollection(signalCollection.get(), hashId).isFailure()) {
177 ATH_MSG_ERROR(
"Adding signal Collection with hashId " << hashId <<
" failed");
178 return StatusCode::FAILURE;
180 (void)signalCollection.release();
184 return StatusCode::SUCCESS;
190 CLHEP::HepRandomEngine *rndmEngine = rngWrapper->
getEngine(ctx);
202 std::vector < std::pair<IdentifierHash, bool> > overlapMap;
205 overlapMap.emplace_back(hashId,
false);
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) {
214 std::unique_ptr<TRT_RDO_Collection> bkgCollection{};
217 bkgCollection = copyCollectionAndSort(hashId, bkgContainer->
indexFindPtr(hashId),dataItemsPool);
222 if (outputContainer->
addCollection(bkgCollection.get(), hashId).isFailure()) {
223 ATH_MSG_ERROR(
"Adding background Collection with hashId " << hashId <<
" failed");
224 return StatusCode::FAILURE;
226 (void)bkgCollection.release();
236 for (
const auto &[hashId, overlap] : overlapMap) {
238 std::unique_ptr<TRT_RDO_Collection> signalCollection =
250 std::unique_ptr<TRT_RDO_Collection> bkgCollection{};
252 bkgCollection = copyCollectionAndSort(hashId, bkgContainer->
indexFindPtr(hashId),dataItemsPool);
260 signalCollection.get(),
268 ATH_MSG_ERROR(
"Adding overlaid Collection with hashId " << hashId <<
" failed");
269 return StatusCode::FAILURE;
274 if (outputContainer->
addCollection(signalCollection.get(), hashId).isFailure()) {
275 ATH_MSG_ERROR(
"Adding signal Collection with hashId " << hashId <<
" failed");
276 return StatusCode::FAILURE;
278 (void)signalCollection.release();
283 return StatusCode::SUCCESS;
294 CLHEP::HepRandomEngine *rndmEngine)
const
297 throw std::runtime_error(
"mergeCollections(): collection Id mismatch");
316 while ((ibkg < bkgCollection->
size()) || (isig < signalCollection->
size())) {
320 if (isig == signalCollection->
size()) {
323 }
else if (ibkg == bkgCollection->
size()) {
329 if (signalCollection->
at(isig)->identify() < bkgCollection->
at(ibkg)->identify()) {
331 }
else if (bkgCollection->
at(ibkg)->identify() < signalCollection->
at(isig)->identify()) {
337 bkgCollection->
swapElement(ibkg++,
nullptr, tmpBkg);
343 if (sigRdo && bkgRdo) {
345 sigRdo->
merge(*bkgRdo);
348 if (!(sigRdo->
getWord() & 0x04020100)) {
352 InDetSimDataCollection::const_iterator sdoIter = signalSDOCollection->find(rdoId);
353 if (sdoIter != signalSDOCollection->end()) {
354 const std::vector<InDetSimData::Deposit> &deposits = sdoIter->second.getdeposits();
358 if (std::abs(particleLink->pdg_id()) == 11) {
367 bool isXenonStraw =
false;
368 if (strawStatusHT !=
nullptr) {
376 float HTOccupancyCorrection = 0.;
391 unsigned int newWord = 0;
392 if (HTOccupancyCorrection != 0. && occupancy * HTOccupancyCorrection > CLHEP::RandFlat::shoot(rndmEngine, 0, 1)) {
393 newWord += 1 << (26-9);
397 sigRdo->
merge(newRdo);
def retrieve(aClass, aKey=None)
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar
virtual StatusCode initialize() override final
IdentifierHash straw_hash(Identifier straw_id) const
straw hash from id - optimized
const_pointer_type cptr()
Dereference the pointer.
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,...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar
const std::string & name() const
Return the StoreGate ID for the referenced object.
virtual StatusCode execute(const EventContext &ctx) const override final
virtual Identifier identify() const override final
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
size_t size() const
Duplicate of fullSize for backwards compatability.
SG::WriteHandleKey< TRT_RDO_Container > m_outputKey
SG::ReadCondHandleKey< TRTCond::StrawStatusData > m_strawStatusHTKey
#define ATH_MSG_VERBOSE(x)
SG::ReadHandleKey< TRT_RDO_Container > m_signalInputKey
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< InDetSimDataCollection > m_signalInputSDOKey
Handle class for recording to StoreGate.
a link optimized in size for a GenParticle in a McEventCollection
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
virtual size_t numberOfCollections() const override final
return number of collections
void prepareToAdd(unsigned int size)
Prepare to add cached elements.
std::unique_ptr< HGTD_RDO_Collection > copyCollection(const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
std::string store() const
Return the name of the store holding the object we are proxying.
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...
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
bool isValid() const
Validity check.
ToolHandle< InDet::ITRT_LocalOccupancy > m_TRT_LocalOccupancyTool
Gaudi::Property< double > m_HTOccupancyCorrectionB_noE
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Gaudi::Property< double > m_HTOccupancyCorrectionEC_noE
virtual bool isValid() override final
Can the handle be successfully dereferenced?
A wrapper class for event-slot-local random engines.
StatusCode initialize(bool used=true)
Gaudi::Property< bool > m_sortBkgInput
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
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,...
Gaudi::Property< double > m_HTOccupancyCorrectionB
unsigned int getWord() const
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
unsigned int findStatus(const IdentifierHash &hashID) const
#define ATH_MSG_WARNING(x)
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
const std::vector< EventContainers::hashPair< T > > & GetAllHashPtrPair() const
Gaudi::Property< double > m_HTOccupancyCorrectionEC
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
virtual Identifier identify() const override final
const T * at(size_type n) const
Access an element, as an rvalue.
Handle class for reading from StoreGate.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
BASE::size_type size_type
std::pair< HepMcParticleLink, float > Deposit
ServiceHandle< IAthRNGSvc > m_rndmSvc
void merge(const InDetRawData &other)
SG::ReadHandleKey< TRT_RDO_Container > m_bkgInputKey
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.
size_type size() const noexcept
Returns the number of elements in the collection.
TRTOverlay(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< double > m_HTOccupancyCorrectionB_Ar_noE
Gaudi::Property< double > m_HTOccupancyCorrectionEC_Ar_noE