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; \
42 bool 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) {
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 |= 1<<overlapIndex;
110 if( (trkOverlap&overlapType) && trkvec.
sumpt() <= assoc->
trkVec(overlapIndex).
sumpt() ) {
111 ATH_MSG(
" trk overlap " << overlapIndex);
112 trkmask |= 1<<overlapIndex;
115 ATH_MSG(
" calmask = " << calmask <<
", trkmask = " << trkmask);
117 if(calmap[calmask].sumpt()==0 && calvec.
sumpt()>1
e-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()>1
e-9) {
123 trkmap[trkmask] = trkvec;
124 sortedTrkPairs.emplace_back(trkmask,trkvec);
125 ATH_MSG(
" Add unique trk mask " << trkmask <<
", sumpt " << trkvec.
sumpt());
131 std::sort(sortedCalPairs.begin(),sortedCalPairs.end(),
maskSumptSort);
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() <<
")");
153 std::sort(sortedTrkPairs.begin(),sortedTrkPairs.end(),
maskSumptSort);
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) {
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) {
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::"