ATLAS Offline Software
Loading...
Searching...
No Matches
Overlay Namespace Reference

Helpers for overlaying Identifiable Containers. More...

Classes

struct  PixelRDOSorter

Functions

template<>
void mergeChannelData (HGTD_RDO &, const HGTD_RDO &, const IDC_OverlayBase *algorithm)
template<>
std::unique_ptr< HGTD_RDO_CollectioncopyCollection (const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)
template<>
void mergeChannelData (PixelRDORawData &, const PixelRDORawData &, const IDC_OverlayBase *algorithm)
template<>
std::unique_ptr< PixelRDO_CollectioncopyCollection (const IdentifierHash &hashId, const PixelRDO_Collection *collection, DataPool< Pixel1RawData > &dataItems)
template<>
void sortCollection (PixelRDO_Collection *collection)
template<>
std::unique_ptr< SCT_RDO_CollectioncopyCollection (const IdentifierHash &hashId, const SCT_RDO_Collection *collection, DataPool< SCT3_RawData > &dataItems)
template<>
void mergeCollections (SCT_RDO_Collection *bkgCollection, SCT_RDO_Collection *signalCollection, SCT_RDO_Collection *outputCollection, const IDC_OverlayBase *algorithm, DataPool< SCT3_RawData > &dataItems)
template<>
void mergeChannelData (MdtDigit &signalDigit, const MdtDigit &bkgDigit, const IDC_MuonOverlayBase *algorithm)
 template specialization function to add 2 MDT Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.
template<>
void mergeChannelData (MmDigit &signalDigit, const MmDigit &bkgDigit, const IDC_MuonOverlayBase *algorithm)
 template specialization function to add 2 MM Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.
template<class Datum>
void mergeMultiHits (const std::vector< Datum * > &bkgHits, const std::vector< Datum * > &signalHits, std::vector< Datum * > &outputHits)
 Merging of hits on the same channel.
template<class Collection>
void mergeMultiHitCollections (Collection *bkgCollection, Collection *signalCollection, Collection *outputCollection)
template<>
void mergeChannelData (sTgcDigit &signalDigit, const sTgcDigit &bkgDigit, const IDC_MuonOverlayBase *algorithm)
 template specialization function to add 2 sTGC Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.
template<class Collection>
std::unique_ptr< Collection > copyCollection (const IdentifierHash &hashId, const Collection *collection)
template<typename Collection, typename Type>
std::unique_ptr< Collection > copyCollection (const IdentifierHash &hashId, const Collection *collection, DataPool< Type > &dataItems)
template<typename Collection, typename Alg>
void mergeCollections (Collection *bkgCollection, Collection *signalCollection, Collection *outputCollection, const Alg *algorithm)
template<typename Type, typename Collection, typename Alg>
void mergeCollections (Collection *bkgCollection, Collection *signalCollection, Collection *outputCollection, const Alg *algorithm, DataPool< Type > &dataItems)
template<typename Type, typename Collection, typename Alg>
void mergeSortedCollections (Collection *bkgCollection, Collection *signalCollection, Collection *outputCollection, const Alg *algorithm, DataPool< Type > &dataItems)
template<class Datum, class Alg>
void mergeChannelData (Datum &baseDatum, const Datum &additionalDatum, const Alg *algorithm)
template<typename Collection>
void sortCollection (Collection *collection)
template<class IDC_Container>
std::string debugPrint (const IDC_Container *container, unsigned numprint=25)
 Diagnostic output of Identifiable Containers.

Variables

struct Overlay::PixelRDOSorter PixelRDOSorterObject

Detailed Description

Helpers for overlaying Identifiable Containers.

Author
Tadej Novak

Function Documentation

◆ copyCollection() [1/5]

template<class Collection>
std::unique_ptr< Collection > Overlay::copyCollection ( const IdentifierHash & hashId,
const Collection * collection )

◆ copyCollection() [2/5]

template<typename Collection, typename Type>
std::unique_ptr< Collection > Overlay::copyCollection ( const IdentifierHash & hashId,
const Collection * collection,
DataPool< Type > & dataItems )

◆ copyCollection() [3/5]

template<>
std::unique_ptr< HGTD_RDO_Collection > Overlay::copyCollection ( const IdentifierHash & hashId,
const HGTD_RDO_Collection * collection )

Definition at line 24 of file HGTD_Overlay.cxx.

26 {
27 auto outputCollection = std::make_unique<HGTD_RDO_Collection>(hashId);
28 outputCollection->setIdentifier(collection->identify());
29
30 for (const HGTD_RDO *existingDatum : *collection) {
31 // Owned by the collection
32 auto *datumCopy = new HGTD_RDO(existingDatum->identify(), existingDatum->getTOA(), existingDatum->getTOT(),
33 existingDatum->getBCID(), existingDatum->getL1ID(), existingDatum->getL1A());
34 outputCollection->push_back(datumCopy);
35 }
36
37 return outputCollection;
38 }
const Identifier & identify() const

◆ copyCollection() [4/5]

template<>
std::unique_ptr< PixelRDO_Collection > Overlay::copyCollection ( const IdentifierHash & hashId,
const PixelRDO_Collection * collection,
DataPool< Pixel1RawData > & dataItems )

Definition at line 36 of file PixelOverlay.cxx.

38 {
39 auto outputCollection = std::make_unique<PixelRDO_Collection>(hashId);
40 outputCollection->setIdentifier(collection->identify());
41 outputCollection->clear(SG::VIEW_ELEMENTS);
42 outputCollection->reserve(collection->size());
43 for (const PixelRDORawData *existingDatum : *collection) {
44 Pixel1RawData *datumCopy = dataItems.nextElementPtr();
45 (*datumCopy) =
46 Pixel1RawData(existingDatum->identify(), existingDatum->getWord());
47 outputCollection->push_back(datumCopy);
48 }
49 return outputCollection;
50}
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
size_type size() const noexcept
virtual Identifier identify() const override final
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ copyCollection() [5/5]

template<>
std::unique_ptr< SCT_RDO_Collection > Overlay::copyCollection ( const IdentifierHash & hashId,
const SCT_RDO_Collection * collection,
DataPool< SCT3_RawData > & dataItems )

Definition at line 19 of file SCTOverlay.cxx.

22 {
23 auto outputCollection = std::make_unique<SCT_RDO_Collection>(hashId);
24 outputCollection->setIdentifier(collection->identify());
25
26 // Elements created here are owned by the DataPool
27 outputCollection->clear(SG::VIEW_ELEMENTS);
28 outputCollection->reserve(collection->size());
29
30 for (const SCT_RDORawData *existingDatum : *collection) {
31 auto *oldDatum = dynamic_cast<const SCT3_RawData *>(existingDatum);
32 if (not oldDatum) {
33 throw std::runtime_error("Dynamic cast to SCT3_RawData failed in SCTOverlay.cxx, Overlay::copyCollection");
34 }
35 SCT3_RawData* datumCopy = dataItems.nextElementPtr();
36 (*datumCopy) = SCT3_RawData(oldDatum->identify(), oldDatum->getWord(),
37 &oldDatum->getErrorCondensedHit());
38 outputCollection->push_back(datumCopy);
39 }
40
41 return outputCollection;
42 }

◆ debugPrint()

template<class IDC_Container>
std::string Overlay::debugPrint ( const IDC_Container * container,
unsigned numprint = 25 )

Diagnostic output of Identifiable Containers.

◆ mergeChannelData() [1/6]

template<class Datum, class Alg>
void Overlay::mergeChannelData ( Datum & baseDatum,
const Datum & additionalDatum,
const Alg * algorithm )

◆ mergeChannelData() [2/6]

template<>
void Overlay::mergeChannelData ( HGTD_RDO & ,
const HGTD_RDO & ,
const IDC_OverlayBase * algorithm )

Definition at line 14 of file HGTD_Overlay.cxx.

17 {
18 algorithm->msg(MSG::DEBUG) << "Overlay::mergeChannelData<HGTD_RDORawData>(): "
19 << "Merging of data on the same channel is not explicitly implemented for HGTD_RDORawData" << endmsg;
20 }
#define endmsg
std::string algorithm
Definition hcg.cxx:85

◆ mergeChannelData() [3/6]

template<>
void Overlay::mergeChannelData ( MdtDigit & signalDigit,
const MdtDigit & bkgDigit,
const IDC_MuonOverlayBase * algorithm )

template specialization function to add 2 MDT Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.

So we just put this implementation at the beginning of this file.

signal masks the background - no correction to the ADC FIXME: Probably should return the masked hit as well

Physics hit masks the background hit - no correct to the AOD FIXME: Probably should return the masked hit as well

the 2 hits overlap withing the ADC integration window the ADC will add partially the TDC is from the first hit that crosses the threshold FIXME: how to add partially for correct - for now just add the ADD total

Definition at line 26 of file MdtOverlay.cxx.

29 {
30 // We want to use the integration window provided by MdtOverlay, thus the constraint
31 const MdtOverlay *parent = dynamic_cast<const MdtOverlay *>(algorithm);
32 if (!parent) {
33 throw std::runtime_error("mergeChannelData<MdtDigit>() called by a wrong parent algorithm? Must be MdtOverlay.");
34 }
35
36 int sig_tdc = signalDigit.tdc();
37 int bkg_tdc = bkgDigit.tdc();
38
41 if (std::abs(sig_tdc - bkg_tdc) > parent->adcIntegrationWindow() && sig_tdc < bkg_tdc ) {
42 // do nothing - keep baseDigit.
43 }
46 else if (std::abs(sig_tdc - bkg_tdc) > parent->adcIntegrationWindow() && sig_tdc > bkg_tdc ) {
47 // Use the background digit as the final answer
48 signalDigit = bkgDigit;
49 }
54 else if (std::abs(sig_tdc - bkg_tdc) < parent->adcIntegrationWindow() ) {
55 int tdc = std::min( signalDigit.tdc(), bkgDigit.tdc() );
56 int adc = signalDigit.adc() + bkgDigit.adc();
57 signalDigit = MdtDigit(signalDigit.identify(), tdc, adc, false);
58 }
59 }
int16_t adc() const
Definition MdtDigit.h:28
int16_t tdc() const
Definition MdtDigit.h:26
Identifier identify() const
Definition MuonDigit.h:30

◆ mergeChannelData() [4/6]

template<>
void Overlay::mergeChannelData ( MmDigit & signalDigit,
const MmDigit & bkgDigit,
const IDC_MuonOverlayBase * algorithm )

template specialization function to add 2 MM Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.

So we just put this implementation at the beginning of this file.

signal masks the background

Background hit masks the signal hit

the 2 hits overlap withing the time integration window For now, just add total charge

Definition at line 27 of file MM_Overlay.cxx.

30 {
31 // We want to use the integration window provided by MmOverlay, thus the constraint
32 const MM_Overlay *parent = dynamic_cast<const MM_Overlay *>(algorithm);
33 if (!parent) {
34 throw std::runtime_error("mergeChannelData<MmDigit>() called by a wrong parent algorithm? Must be MM_Overlay.");
35 }
36 float sig_time = signalDigit.stripResponseTime();
37 float bkg_time = bkgDigit.stripResponseTime();
38
39
40 // As of now, we need to decide how to overlay MM digits
41 // NEEDS TO BE ADDRESSED
42 // For this preliminary version of July 2019, use only the data from the 1st digit in vector.
44 if ( std::abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time < bkg_time ) {
45 // do nothing - keep baseDigit.
46 }
48 else if ( std::abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time > bkg_time ) {
49 // Use the background digit as the final answer
50 signalDigit = bkgDigit;
51 }
54 else if ( std::abs(sig_time - bkg_time) < parent->timeIntegrationWindow() ) {
55 // Use the earliest time
56 // And use all the other values of the signal digit.
57 float time = std::min( sig_time, bkg_time );
58 float charge = signalDigit.stripResponseCharge() + bkgDigit.stripResponseCharge();
59 signalDigit = MmDigit(signalDigit.identify(), time, charge);
60 }
61 }
double charge(const T &p)
Definition AtlasPID.h:997
float stripResponseCharge() const
Return the charge.
Definition MmDigit.h:45
float stripResponseTime() const
strip response info
Definition MmDigit.h:43
time(flags, cells_name, *args, **kw)

◆ mergeChannelData() [5/6]

template<>
void Overlay::mergeChannelData ( PixelRDORawData & ,
const PixelRDORawData & ,
const IDC_OverlayBase * algorithm )

Definition at line 25 of file PixelOverlay.cxx.

27 {
28 algorithm->msg(MSG::DEBUG) << "Overlay::mergeChannelData<PixelRDORawData>(): "
29 << "Merging of data on the same channel is not "
30 "explicitly implemented for PixelRDORawData"
31 << endmsg;
32}

◆ mergeChannelData() [6/6]

template<>
void Overlay::mergeChannelData ( sTgcDigit & signalDigit,
const sTgcDigit & bkgDigit,
const IDC_MuonOverlayBase * algorithm )

template specialization function to add 2 sTGC Digits - basically the operator+= A declaration of the specialization must happen before the template is used from the overlayContainer() method.

So we just put this implementation at the beginning of this file.

signal masks the background

Background hit masks the signal hit

the 2 hits overlap withing the time integration window For now, just add total charge

Definition at line 27 of file STGC_Overlay.cxx.

30 {
31 // We want to use the integration window provided by sTgcOverlay, thus the constraint
32 const STGC_Overlay *parent = dynamic_cast<const STGC_Overlay *>(algorithm);
33 if (!parent) {
34 throw std::runtime_error("mergeChannelData<sTgcDigit>() called by a wrong parent algorithm? Must be STGC_Overlay.");
35 }
36
37 float sig_time = signalDigit.time();
38 float bkg_time = bkgDigit.time();
39
41 if ( abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time < bkg_time ) {
42 // do nothing - keep baseDigit.
43 }
45 else if ( abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time > bkg_time ) {
46 // Use the background digit as the final answer
47 signalDigit = bkgDigit;
48 }
51 else if ( abs(sig_time - bkg_time) < parent->timeIntegrationWindow() ) {
52 // Use the earliest time
53 float time = std::min( signalDigit.time(), bkgDigit.time() );
54 float charge = signalDigit.charge() + bkgDigit.charge();
55 //signalDigit = sTgcDigit(signalDigit.identify(), time, charge);
56 signalDigit = sTgcDigit(signalDigit.identify(), signalDigit.bcTag(), time, charge, signalDigit.isDead(), signalDigit.isPileup());
57 }
58 }
float time() const
Definition sTgcDigit.cxx:61
uint16_t bcTag() const
Definition sTgcDigit.cxx:34
float charge() const
Definition sTgcDigit.cxx:46
bool isDead() const
Definition sTgcDigit.cxx:38
bool isPileup() const
Definition sTgcDigit.cxx:42

◆ mergeCollections() [1/3]

template<typename Collection, typename Alg>
void Overlay::mergeCollections ( Collection * bkgCollection,
Collection * signalCollection,
Collection * outputCollection,
const Alg * algorithm )

◆ mergeCollections() [2/3]

template<typename Type, typename Collection, typename Alg>
void Overlay::mergeCollections ( Collection * bkgCollection,
Collection * signalCollection,
Collection * outputCollection,
const Alg * algorithm,
DataPool< Type > & dataItems )

◆ mergeCollections() [3/3]

template<>
void Overlay::mergeCollections ( SCT_RDO_Collection * bkgCollection,
SCT_RDO_Collection * signalCollection,
SCT_RDO_Collection * outputCollection,
const IDC_OverlayBase * algorithm,
DataPool< SCT3_RawData > & dataItems )

Definition at line 48 of file SCTOverlay.cxx.

53 {
54 // We want to use the SCT_ID helper provided by SCTOverlay, thus the constraint
55 const SCTOverlay *parent = dynamic_cast<const SCTOverlay *>(algorithm);
56 if (!parent) {
57 throw std::runtime_error("mergeCollections<SCT_RDORawData>() called by a wrong parent algorithm? Must be SCTOverlay.");
58 }
59
60 if (bkgCollection->identify() != signalCollection->identify()) {
61 throw std::runtime_error("mergeCollections<SCT_RDO_Collection>(): collection Id mismatch");
62 }
63
64 outputCollection->reserve(
65 std::max(bkgCollection->size(), signalCollection->size()));
66 const Identifier idColl =
67 parent->get_sct_id()->wafer_id(signalCollection->identifyHash());
68
69 // Strip hit timing information for Next, Current, Previous and Any BCs
70 // Prepare one more strip to create the last one. The additional strip has no hits.
71 std::bitset<SCTOverlay::NumberOfStrips+1> stripInfo[SCTOverlay::NumberOfBitSets];
72 // Process background and signal in the wafer
76 if (source == SCTOverlay::BkgSource) { // background
77 rdo = bkgCollection->begin();
78 rdoEnd = bkgCollection->end();
79 } else { // signal
80 rdo = signalCollection->begin();
81 rdoEnd = signalCollection->end();
82 }
83 // Loop over all RDOs in the wafer
84 for (; rdo!=rdoEnd; ++rdo) {
85 // Here we'll just go with SCT3.
86 const SCT3_RawData* rdo3 = dynamic_cast<const SCT3_RawData*>(*rdo);
87 if (!rdo3) {
88 std::ostringstream os;
89 const auto& elt = **rdo;
90 os << "mergeCollection<SCT_RDO_Collection>(): wrong datum format. Only SCT3_RawData are produced by SCT_RodDecoder and supported by overlay."
91 << "For the supplied datum typeid(datum).name() = " << typeid(elt).name();
92 throw std::runtime_error(os.str());
93 }
94 int strip = parent->get_sct_id()->strip(rdo3->identify());
95 int stripEnd = strip + rdo3->getGroupSize();
96 int timeBin = rdo3->getTimeBin();
97 for (; strip < stripEnd && strip < SCTOverlay::NumberOfStrips; strip++) {
98 // Fill timing information for each strips, loop over 3 BCs
99 for (unsigned int bc = SCTOverlay::NextBC; bc < SCTOverlay::NumberOfBCs; bc++) {
100 if (timeBin & (1 << bc)) stripInfo[bc].set(strip);
101 }
102 }
103 }
104 }
105 // Get OR for AnyBC, loop over 3 BCs
106 for (unsigned int bc = SCTOverlay::NextBC; bc < SCTOverlay::NumberOfBCs; bc++) {
107 stripInfo[SCTOverlay::AnyBC] |= stripInfo[bc];
108 }
109 // Check if we need to use Expanded mode by checking if there is at least one hit in Next BC or Previous BC
110 bool anyNextBCHits = stripInfo[SCTOverlay::NextBC].any();
111 bool anyPreivousBCHits = stripInfo[SCTOverlay::PreviousBC].any();
112 bool isExpandedMode = (anyNextBCHits or anyPreivousBCHits);
113 // No error information is recorded because this information is not filled in data and no errors are assumed in MC.
114 const int ERRORS = 0;
115 const std::vector<int> errvec{};
116 if (isExpandedMode) {
117 // Expanded mode (record strip one by one)
118 const int groupSize = 1;
119 int tbin = 0;
120 for (unsigned int strip = 0; strip < SCTOverlay::NumberOfStrips; strip++) {
121 if (stripInfo[SCTOverlay::AnyBC][strip]) {
122 tbin = 0;
123 for (unsigned int bc = SCTOverlay::NextBC; bc < SCTOverlay::NumberOfBCs; bc++) {
124 if (stripInfo[bc][strip]) {
125 tbin |= (1 << bc);
126 }
127 }
128 unsigned int SCT_Word = (groupSize | (strip << 11) | (tbin <<22) | (ERRORS << 25));
129 Identifier rdoId = parent->get_sct_id()->strip_id(idColl, strip) ;
130 // use the pool
131 SCT3_RawData* datum = dataItems.nextElementPtr();
132 (*datum) = SCT3_RawData(rdoId, SCT_Word, &errvec);
133 outputCollection->push_back(datum);
134 }
135 }
136 } else {
137 // We can record consecutive hits into one RDO if all hits have timeBin of 010.
138 unsigned int groupSize = 0;
139 const int tbin = (1 << SCTOverlay::CurrentBC);
140 for (unsigned int strip=0; strip<SCTOverlay::NumberOfStrips+1; strip++) { // Loop over one more strip to create the last one if any
141 if (stripInfo[SCTOverlay::AnyBC][strip]) {
142 groupSize++;
143 } else {
144 if (groupSize>0) {
145 unsigned int firstStrip = strip - groupSize;
146 unsigned int SCT_Word = (groupSize | (firstStrip << 11) | (tbin <<22) | (ERRORS << 25));
147 Identifier rdoId = parent->get_sct_id()->strip_id(idColl, firstStrip) ;
148 SCT3_RawData* datum = dataItems.nextElementPtr();
149 (*datum) = SCT3_RawData(rdoId, SCT_Word, &errvec);
150 outputCollection->push_back(datum);
151 groupSize = 0;
152 }
153 }
154 }
155 }
156 } // mergeCollections()
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
virtual IdentifierHash identifyHash() const override final
virtual Identifier identify() const override final
int getTimeBin() const
virtual int getGroupSize() const override final
@ NumberOfBitSets
Definition SCTOverlay.h:28
@ NumberOfSources
Definition SCTOverlay.h:29

◆ mergeMultiHitCollections()

template<class Collection>
void Overlay::mergeMultiHitCollections ( Collection * bkgCollection,
Collection * signalCollection,
Collection * outputCollection )

◆ mergeMultiHits()

template<class Datum>
void Overlay::mergeMultiHits ( const std::vector< Datum * > & bkgHits,
const std::vector< Datum * > & signalHits,
std::vector< Datum * > & outputHits )

Merging of hits on the same channel.

Modifies the first argument by adding data from the second.. Implementations can assume that the arguments have the same Id. (That is, correspond to the same readout channel.)

A generic implementation of this template is provided in this package, but subdetectors can provide specializations suitable for their RDO type.

As a Collection is usually based on the DataVector elements are not const.

◆ mergeSortedCollections()

template<typename Type, typename Collection, typename Alg>
void Overlay::mergeSortedCollections ( Collection * bkgCollection,
Collection * signalCollection,
Collection * outputCollection,
const Alg * algorithm,
DataPool< Type > & dataItems )

◆ sortCollection() [1/2]

template<typename Collection>
void Overlay::sortCollection ( Collection * collection)

◆ sortCollection() [2/2]

template<>
void Overlay::sortCollection ( PixelRDO_Collection * collection)

Definition at line 54 of file PixelOverlay.cxx.

54 {
55 if (!std::is_sorted(collection->begin(), collection->end(), PixelRDOSorterObject)) {
56 std::stable_sort(collection->begin(), collection->end(), PixelRDOSorterObject);
57 }
58}
struct Overlay::PixelRDOSorter PixelRDOSorterObject
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

Variable Documentation

◆ PixelRDOSorterObject

struct Overlay::PixelRDOSorter Overlay::PixelRDOSorterObject