11#include "GaudiKernel/MsgStream.h"
25#define MSGLVL MSG::VERBOSE
28#define ATH_MSG( MSG ) \
30 if( log.level() <= MSGLVL ) { \
31 log << MSGLVL << MSG << endmsg; \
42bool maskSumptSort(
const std::pair<bitmask_t,constvec_t>& p1,
const std::pair<bitmask_t,constvec_t>& p2) {
44 return p1.first>p2.first;
46 return p1.second.sumpt()<p2.second.sumpt();
52 MsgStream& log )
const {
55 ATH_MSG(
"Converting xAOD::MissingETAuxAssociationMap_v1 to current version..." );
68 for(
size_t i = 0; i < oldObj->
size(); ++i ) {
71 oldInt.setStore( oldObj );
74 for(
size_t i = 0; i < newObj->
size(); ++i ) {
77 newInt.setStore( newObj );
79 unsigned char calOverlap(11), trkOverlap(25);
80 std::map<bitmask_t,constvec_t> calmap, trkmap;
81 std::vector<std::pair<bitmask_t,constvec_t> > sortedCalPairs, sortedTrkPairs;
82 sortedCalPairs.reserve(10);
83 sortedTrkPairs.reserve(10);
84 for(
size_t iAssoc=0; iAssoc < oldInt.
size(); ++iAssoc ) {
86 ATH_MSG(
"On assoc " << iAssoc <<
", size = " << assoc->
size() );
92 sortedCalPairs.clear();
93 sortedTrkPairs.clear();
95 for(
size_t iObj=0; iObj<assoc->
size(); ++iObj) {
102 for(
size_t iOverlap=0; iOverlap<assoc->
overlapIndices(iObj).size(); ++iOverlap) {
104 size_t overlapType = assoc->
overlapTypes(iObj)[iOverlap];
105 ATH_MSG(
" Overlap " << iOverlap <<
" (" << overlapIndex <<
", " << overlapType <<
")" );
106 if( (calOverlap&overlapType) && calvec.
sumpt() <= assoc->
calVec(overlapIndex).
sumpt() ) {
107 ATH_MSG(
" cal overlap " << overlapIndex);
108 calmask |=
static_cast<bitmask_t>(1)<<overlapIndex;
110 if( (trkOverlap&overlapType) && trkvec.
sumpt() <= assoc->
trkVec(overlapIndex).
sumpt() ) {
111 ATH_MSG(
" trk overlap " << overlapIndex);
112 trkmask |=
static_cast<bitmask_t>(1)<<overlapIndex;
115 ATH_MSG(
" calmask = " << calmask <<
", trkmask = " << trkmask);
117 if(calmap[calmask].sumpt()==0 && calvec.
sumpt()>1e-9) {
118 calmap[calmask] = calvec;
119 sortedCalPairs.emplace_back(calmask,calvec);
120 ATH_MSG(
" Add unique cal mask " << calmask <<
", sumpt " << calvec.
sumpt());
122 if(trkmap[trkmask].sumpt()==0 && trkvec.
sumpt()>1e-9) {
123 trkmap[trkmask] = trkvec;
124 sortedTrkPairs.emplace_back(trkmask,trkvec);
125 ATH_MSG(
" Add unique trk mask " << trkmask <<
", sumpt " << trkvec.
sumpt());
133 for(
auto& calpair : sortedCalPairs) {
135 double sumpt = calpair.second.sumpt();
136 ATH_MSG(
" Do subtractions on calmask " << calmask <<
" with sumpt " << sumpt);
138 for(
size_t jPair(iPair+1); jPair<sortedCalPairs.size(); ++jPair) {
139 const auto& calpair2=sortedCalPairs[jPair];
140 ATH_MSG(
" Check calmask " << calpair2.first <<
" with sumpt " << calpair2.second.sumpt());
141 if(calmask > calpair2.first && (calmask & calpair2.first)==calpair2.first) {
143 calmap[calpair2.first] -= calpair.second;
144 ATH_MSG(
" Cal mask " << calmask <<
", sumpt " << sumpt
145 <<
", subtract from " << calpair2.first
146 <<
" (" << calpair2.second.sumpt() <<
" --> " << calmap[calpair2.first].sumpt() <<
")");
155 for(
auto& trkpair : sortedTrkPairs) {
157 double sumpt = trkpair.second.sumpt();
158 ATH_MSG(
" Do subtractions on trkmask " << trkmask <<
" with sumpt " << sumpt);
160 for(
size_t jPair(iPair+1); jPair<sortedTrkPairs.size(); ++jPair) {
161 const auto& trkpair2=sortedTrkPairs[jPair];
162 ATH_MSG(
" Check trkmask " << trkpair2.first <<
" with sumpt " << trkpair2.second.sumpt());
163 if(trkmask > trkpair2.first && (trkmask&trkpair2.first)==trkpair2.first) {
165 trkmap[trkpair2.first] -= trkpair.second;
166 ATH_MSG(
" Trk mask " << trkmask <<
", sumpt " << sumpt
167 <<
", subtract from " << trkpair2.first
168 <<
" (" << trkpair2.second.sumpt() <<
" --> " << trkmap[trkpair2.first].sumpt() <<
")");
179 for (
const auto& calpair : calmap) {
182 if(cv.
sumpt()>1e-9) {
183 ATH_MSG(
" CalKey " << bm <<
", constvec sumpt = " << cv.
sumpt());
185 ATH_MSG(
" retrieve key " << newassoc->
calkey(iKey) <<
", sumpt " <<
190 ATH_MSG(
"Final calsize = " << newassoc->
sizeCal() <<
", " << newassoc->
cale().size());
194 for (
const auto& trkpair : trkmap) {
197 if(cv.
sumpt()>1e-9) {
198 ATH_MSG(
" TrkKey " << bm <<
", constvec sumpt = " << cv.
sumpt());
200 ATH_MSG(
" retrieve key " << newassoc->
trkkey(iKey) <<
", sumpt " <<
205 ATH_MSG(
"Final trksize = " << newassoc->
sizeTrk() <<
", " << newassoc->
trke().size());
210 ATH_MSG(
"Converting xAOD::MissingETAuxAssociationMap_v1 to current version "
222 MsgStream& log )
const {
225 <<
"Somebody called xAODMissingETAuxAssociationMapCnv_v1::transToPers"
227 throw std::runtime_error(
"Somebody called xAODMissingETAuxAssociationMapCnv_v1::"
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual void transToPers(const xAOD::MissingETAuxAssociationMap *, xAOD::MissingETAuxAssociationMap_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
virtual void persToTrans(const xAOD::MissingETAuxAssociationMap_v1 *oldObj, xAOD::MissingETAuxAssociationMap *newObj, MsgStream &log) const override
Function converting from the old type to the current one.
xAODMissingETAuxAssociationMapCnv_v1()
Default constructor.
virtual bool resize(size_t size) override
Resize the arrays to a given size.
virtual size_t size() const override
Get the size of the container.
float ce() const
Returns .
float sumpt() const
Returns sum of component pt.
float cpz() const
Returns .
float cpx() const
Returns .
float cpy() const
Returns .
MET association descriptor contains object links and corresponding parameters.
const std::vector< float > & cale() const
Get the vector of .
const std::vector< MissingETBase::Types::bitmask_t > & calkey() const
Get the vector of cal keys.
bool clearTrkVecs()
Reset the track constituent vectors and keys.
size_t size() const
Update all internally used ElementLink instances.
ConstVec trkVec(const IParticle *pPart) const
Get track constituent vector for a given object.
const std::vector< std::vector< unsigned char > > & overlapTypes() const
Get the list of object overlapTypes.
const std::vector< MissingETBase::Types::bitmask_t > & trkkey() const
Get the vector of trk keys.
bool addTrkVec(MissingETBase::Types::bitmask_t key, float trkpx, float trkpy, float trkpz, float ce, float sumpt)
Add a key/vector pair for calo contributions.
const std::vector< float > & trke() const
Get the vector of .
bool clearCalVecs()
Reset the calo constituent vectors and keys.
bool addCalVec(MissingETBase::Types::bitmask_t key, float calpx, float calpy, float calpz, float cale, float sumpt)
Add a key/vector pair for calo contributions.
const std::vector< std::vector< size_t > > & overlapIndices() const
Get the list of object overlapIndices.
ConstVec calVec(const IParticle *pPart) const
Get calo constituent vector for a given object.
Auxiliary data store for xAOD::MissingETAssociationMap_v1.
Helper to copy an aux store while applying thinning.
Namespace for generally used type definitions.
xAOD::MissingETAssociation_v1::ConstVec constvec_t
Type for constituent vector.
uint64_t bitmask_t
Type for status word bit mask.
General namespace for MET EDM software.
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore ©, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
MissingETAuxAssociationMap_v2 MissingETAuxAssociationMap
Version control by type definition.
MissingETAssociation_v1 MissingETAssociation
Version control by type definition.
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.
static bool isEqual(double x, double y)
Test of equality.
bool maskSumptSort(const std::pair< bitmask_t, constvec_t > &p1, const std::pair< bitmask_t, constvec_t > &p2)