14#include "GaudiKernel/ClassID.h"
93#include "CaloEvent/CaloClusterContainer.h"
105 template <
typename T,
typename Element>
106 struct MatchFeaturesStrict {
107 static constexpr bool value = Element::list_of_features::template has<T>;
112 constexpr int getCLID() {
113 constexpr bool known = TypeInfo_EDM::map::template has<T, MatchFeaturesStrict>;
128 return StatusCode::SUCCESS;
131 virtual StatusCode
help(
const EventContext& ctx,
const std::string&
label,
const std::string& newLabel) = 0;
144 if(
m_msg->level() <= l){
145 *
m_msg << l;
return true;
173 return StatusCode::SUCCESS;
178 template<
typename AOD,
typename XAOD,
typename CnvTool,
bool withCtx = false>
190 virtual StatusCode
help(
const EventContext& ctx,
const std::string&
label,
const std::string& newLabel){
193 std::string fmtkey_xAOD = IH::template
format<XAOD>(newLabel);
194 std::string fmtkey_xAODAux = IH::template
format<xAODAux>(newLabel+
"Aux.");
196 const AOD* aod = this->
m_sg->template tryConstRetrieve<AOD>(fmtkey_AOD);
198 ATH_MSG_WARNING(
"AOD key: " << fmtkey_AOD <<
" not found for xAOD conversion");
199 return StatusCode::SUCCESS;
202 ATH_MSG_DEBUG(
"attempting to convert " << fmtkey_AOD <<
" of size " << aod->size() <<
" to " << fmtkey_xAOD);
204 XAOD* xaod = this->
m_sg->template tryRetrieve<XAOD>(fmtkey_xAOD);
206 ATH_MSG_WARNING(
"xAOD key: " << fmtkey_xAOD <<
" not found for xAOD conversion");
207 return StatusCode::SUCCESS;
209 if constexpr (withCtx)
CHECK( this->
m_tool->convert(ctx, aod,xaod));
213 if(aod->size() != xaod->size()){
214 ATH_MSG_ERROR(
"conversion resulted in differently sized containers");
215 return StatusCode::FAILURE;
217 return StatusCode::SUCCESS;
223 std::string fmtkey_xAOD = IH::template
format<XAOD>(newLabel);
224 std::string fmtkey_xAODAux = IH::template
format<xAODAux>(newLabel+
"Aux.");
226 const AOD* aod = this->
m_sg->template tryConstRetrieve<AOD>(fmtkey_AOD);
229 return StatusCode::SUCCESS;
231 ATH_MSG_DEBUG(
"AOD container " << fmtkey_AOD <<
" extracted of size " << aod->size() );
235 if( aod->size() != tpb_aod->
size() ) {
236 ATH_MSG_WARNING(
"sizes of the container " << fmtkey_AOD <<
" and the corresponding (?) trigpassbits object are different: "
237 << aod->size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
238 return StatusCode::SUCCESS;
241 XAOD* xaod = this->
m_sg->template tryRetrieve<XAOD>(fmtkey_xAOD);
244 return StatusCode::SUCCESS;
246 ATH_MSG_DEBUG(
"xAOD container " << fmtkey_xAOD <<
" extracted of size " << xaod->size());
248 if(aod->size() != xaod->size()) {
249 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
250 return StatusCode::FAILURE;
256 for(
uint i=0; i<aod->size(); i++) {
258 ATH_MSG_DEBUG(
"looking at object " << i+1 <<
" of " << aod->size() );
261 ATH_MSG_DEBUG(
"xaod ispassing = " << xBits->isPassing( i ) );
263 xBits->markPassing( i );
264 ATH_MSG_DEBUG(
"xaod ispassing (after update) = " << xBits->isPassing( i ) );
269 tpb_xaod = xBits.release();
270 return StatusCode::SUCCESS;
283 virtual StatusCode
help(
const EventContext& ,
const std::string&
label,
const std::string& newLabel){
287 return StatusCode::SUCCESS;
291 if(!xaodCombTrackParticles){
293 return StatusCode::SUCCESS;
297 if(!xaodCombTrackParticles){
299 return StatusCode::SUCCESS;
306 return StatusCode::SUCCESS;
309 CHECK(this->
m_tool->convertTrigMuonEFInfoContainer( *aod, *xaodMuon, xaodCombTrackParticles, xaodExtrapTrackParticles));
314 return StatusCode::SUCCESS;
322 return StatusCode::SUCCESS;
325 if( aod->
size() != tpb_aod->
size() ) {
326 ATH_MSG_WARNING(
"sizes of the muon container " <<
label <<
" and the corresponding (?) trigpassbits object are different: "
327 << aod->
size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
332 return StatusCode::SUCCESS;
336 if(aod->
size() != xaodMuon->
size()) {
337 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
338 return StatusCode::FAILURE;
349 ATH_MSG_DEBUG(
"muon xaod ispassing = " << xBits->isPassing( i ) );
351 xBits->markPassing( i );
352 ATH_MSG_DEBUG(
"muon xaod ispassing (after update) = " << xBits->isPassing( i ) );
357 tpb_xaod = xBits.release();
358 return StatusCode::SUCCESS;
366 m_tauJetTool(
"xAODMaker::TauJetCnvTool/TauJetCnvTool",this),
367 m_combMuonTool(
"xAODMaker::CombinedMuonFeatureContainerCnvTool/CombinedMuonFeatureContainerCnvTool",this),
368 m_isoMuonTool(
"xAODMaker::IsoMuonFeatureContainerCnvTool/IsoMuonFeatureContainerCnvTool",this),
369 m_trigMuonTool(
"TrigMuonEFInfoToMuonCnvTool/TrigMuonEFInfoToMuonCnvTool",this),
372 m_emClusterTool(
"xAODMaker::TrigEMClusterCnvTool/TrigEMClusterCnvTool",this),
373 m_bjetTool(
"xAODMaker::TrigBjetCnvTool/TrigBjetCnvTool",this),
374 m_efBphysTool(
"xAODMaker::TrigEFBphysContainerCnvTool/TrigEFBphysContainerCnvTool",this),
375 m_l2BphysTool(
"xAODMaker::TrigL2BphysContainerCnvTool/TrigL2BphysContainerCnvTool",this),
376 m_trigMetTool(
"xAODMaker::TrigMissingETCnvTool/TrigMissingETCnvTool",this),
377 m_trigSpacePtsTool(
"xAODMaker::TrigSpacePointCountsCnvTool/TrigSpacePointCountsCnvTool",this),
380 m_trigVtxCtsTool(
"xAODMaker::TrigVertexCountsCnvTool/TrigVertexCountsCnvTool",this),
381 m_electronTool(
"xAODMaker::ElectronCnvTool/ElectronCnvTool", this ),
382 m_photonTool(
"xAODMaker::PhotonCnvTool/PhotonCnvTool", this ),
386 declareInterface<ITrigBStoxAODTool>(
this );
417 std::map<CLID,BStoXAODHelper::IHelper*>::iterator it;
435 m_helpers.insert( std::pair<CLID,BStoXAODHelper::MuonHelper*>
501 (getCLID<TrigTrackCountsCollection>(),
560 std::multimap<CLID,BStoXAODHelper::IHelper*>::iterator it;
572 <<
") is not the same as the number of old containers names ("
574 return StatusCode::FAILURE;
582 m_clid_labels[i].second <<
" differs from the equivalent Run-2 label: "
587 return StatusCode::SUCCESS;
598 ATH_MSG_WARNING(
"couldn't find holder for " << clidlabel->first <<
" " << clidlabel->second);
604 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator hit;
607 std::string clabel = clidlabel->second;
612 <<
" for label " << clidlabel->second <<
", new label " << clidNewLabel->second);
613 CHECK(hit->second->help(ctx, clidlabel->second,clidNewLabel->second));
617 ATH_MSG_DEBUG(
"couldn't find converters for clid: " << clidlabel->first);
620 return StatusCode::SUCCESS;
628 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
630 ATH_MSG_DEBUG(
"rewiring Navigation for xAOD. working on " << allTEs.size() <<
" TEs");
631 for(
auto te : allTEs){
632 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
633 for(
auto& featacchelp : feats){
639 ATH_MSG_WARNING(
"could not find old holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
643 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
644 std::string old_label = oldholder->
label();
649 bool iselement = (oldholder->
typeClid()==it->second->AODElementClid());
650 bool iscontainer = (oldholder->
typeClid()==it->second->AODContainerClid());
652 ATH_MSG_VERBOSE(
"old is element feature " << iselement <<
" or container feature: " << iscontainer);
654 if(!(iselement || iscontainer)){
655 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. Old holder is:" << *oldholder);
658 CLID newTypeClid = CLID_NULL;
659 if(iselement) newTypeClid = it->second->xAODElementClid();
660 if(iscontainer) newTypeClid = it->second->xAODContainerClid();
662 std::lock_guard<std::recursive_mutex>
lock(nav->
getMutex());
668 ATH_MSG_WARNING(
"could not find new holder for xAOD clid " << newTypeClid <<
" and label " << oldholder->
label());
674 ATH_MSG_VERBOSE(
"changing CLID: " << featacchelp.getCLID() <<
" to " << newTypeClid);
677 featacchelp.setCLIDandIndex(newTypeClid,newholder->
subTypeIndex());
678 ATH_MSG_VERBOSE(
"clid is now: " << featacchelp.getCLID() <<
" sti: " << featacchelp.getIndex().subTypeIndex());
685 return StatusCode::SUCCESS;
692 const std::vector<std::string>& newProperty,
693 std::vector<std::pair<CLID,std::string> >& decoded,
694 std::vector<std::pair<CLID,std::string> >& decodedNewNames) {
696 SmartIF<IClassIDSvc> clidSvc{service(
"ClassIDSvc")};
699 if( property.size() != newProperty.size() ) {
700 ATH_MSG_ERROR(
"vector sizes of new and old SG labels are different: "
701 << newProperty.size() <<
" vs " << property.size() );
702 return StatusCode::FAILURE;
705 std::vector<std::string>::const_iterator it;
706 std::vector<std::string>::const_iterator itNew = newProperty.begin();
707 for ( it = property.begin(); it != property.end(); ++it, ++itNew ) {
710 std::string label_new;
713 if ( it->find(
'#') != std::string::npos ) {
714 type = it->substr(0, it->find(
'#') );
715 label = it->substr(it->find(
'#')+1 );
721 if ( itNew->find(
'#') != std::string::npos ) {
722 label_new = itNew->substr(itNew->find(
'#')+1 );
727 if ( clidSvc->getIDOfTypeName(
type, clid).isFailure() ) {
729 <<
" check property");
730 return StatusCode::FAILURE;
733 ATH_MSG_DEBUG(
"Recognized CLID : " <<
type <<
" and label: " <<
label <<
", new label will be: " << label_new);
734 decoded.push_back(std::make_pair(clid,
label));
735 decodedNewNames.push_back(std::make_pair(clid, label_new));
737 return StatusCode::SUCCESS;
746 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
748 ATH_MSG_DEBUG(
"setting xAOD TrigPassBits. Working on " << allTEs.size() <<
" TEs");
750 for(
auto te : allTEs){
751 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
752 for(
auto& featacchelp : feats){
758 ATH_MSG_WARNING(
"could not find holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
762 if(holder->
label() ==
"passbits") {
763 ATH_MSG_VERBOSE(
"skipping this feature, as this is the passbits object itself" );
767 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
768 std::string hlabel = holder->
label();
773 <<
", label " << holder->
label() <<
" corresponding to xAOD CLID " << it->second->xAODContainerClid() );
775 bool iselement = (holder->
typeClid()==it->second->AODElementClid());
776 bool iscontainer = (holder->
typeClid()==it->second->AODContainerClid());
778 ATH_MSG_VERBOSE(
"is element feature " << iselement <<
" or container feature: " << iscontainer);
780 if(!(iselement || iscontainer)){
781 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. The holder is:" << *holder);
786 const TrigPassBitsCollection* bits_collection =
evtStore()->template tryConstRetrieve<TrigPassBitsCollection>(
"HLT_TrigPassBitsCollection_passbits");
787 if(bits_collection !=
nullptr) {
788 ATH_MSG_DEBUG(
"aod bits collection extracted of size " << bits_collection->
size() );
800 if(xaod_bits_collection !=
nullptr)
801 ATH_MSG_DEBUG(
"xaod bits container extracted of size " << xaod_bits_collection->
size() );
808 if ( nav->
getFeature(te, bits,
"passbits" ) ){
820 if(bits_collection !=
nullptr && xaod_bits_collection !=
nullptr && bits !=
nullptr) {
822 for(
uint i=0; i<bits_collection->
size(); i++) {
823 if(bits == bits_collection->
at(i)) {
831 std::pair<CLID,std::string>
pair = std::make_pair( featacchelp.getCLID(), holder->
label() );
834 std::string new_label =
"";
836 new_label = (*it_new_label).second;
837 ATH_MSG_DEBUG(
"calling help_fillTrigPassBits for TE " << te <<
", feature CLID " << featacchelp.getCLID()
838 <<
", aod container " << holder->
label() <<
", new container name: " << new_label );
839 CHECK( it->second->help_fillTrigPassBits( holder->
label(), new_label, bits_collection->
at(bits_nr), xaod_tpb ) );
841 ATH_MSG_DEBUG(
"new label was not found, presumably this container was not converted. Will not look for TrigPassBits" );
844 if(xaod_tpb !=
nullptr) {
845 xaod_bits_collection->
at(bits_nr) = xaod_tpb;
846 ATH_MSG_VERBOSE(
"after the conversion, size of xAOD::TrigPassBits is " << xaod_bits_collection->
at(bits_nr)->size() );
850 ATH_MSG_WARNING(
"TrigPassBits object was not identified within container!" );
858 return StatusCode::SUCCESS;
863 auto myrange = helpers.equal_range(clid);
866 int distance = std::distance(myrange.first, myrange.second);
870 return StatusCode::SUCCESS;
871 }
else if (distance == 2) {
875 for(;it!=myrange.second;++it) {
876 CLID myHelperxAODCLID = (*it).second->xAODContainerClid();
880 return StatusCode::SUCCESS;
883 }
else if( distance == 0) {
886 return StatusCode::SUCCESS;
889 ATH_MSG_ERROR(
"found " << distance <<
" helpers to convert AOD type " << clid <<
" and label " <<
label
890 <<
", probably you should accomodate for this change in the code above" );
891 return StatusCode::FAILURE;
895 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Container2Aux< FEATURE, EDMLIST >::type Container2Aux_t
uint32_t CLID
The Class ID type.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const std::string m_AODprefix
bool msgLvl(const MSG::Level l)
virtual CLID xAODElementClid()=0
virtual CLID AODContainerClid()=0
virtual StatusCode help(const EventContext &ctx, const std::string &label, const std::string &newLabel)=0
virtual CLID xAODContainerClid()=0
virtual CLID AODElementClid()=0
std::string format(const std::string &label)
virtual StatusCode help_fillTrigPassBits(const std::string &label, const std::string &newLabel, const TrigPassBits *tpb_aod, xAOD::TrigPassBits *&tpb_xaod)=0
MsgStream & msg(MSG::Level l)
virtual StatusCode initialize(MsgStream &m, StoreGateSvc &s)
Storable container for CaloCluster.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual CLID containerClid() const =0
const std::string & label() const
returns the label of objects stores by this holder
virtual CLID typeClid() const =0
returns the CLID of objects stores by this holder
uint16_t subTypeIndex() const
returns the index (short number used when linking object to the TE) of objects stores by this holder
HLTNavDetails::Holder< T > * getHolder(uint16_t subTypeIndex) const
as above but does not create holder on demand (return 0 if not found)
bool getFeature(const TriggerElement *te, const T *&features, const std::string &label="", std::string &sourcelabel=::HLT::TrigNavStructure::m_unspecifiedLabel) const
The Navigation class, organizes TriggerElements into the tree structure.
HolderType * getHolder(class_id_type clid, const std::variant< sub_index_type, std::string > &stiOrLabel) const
std::vector< TriggerElement * > & getAllTEs()
access needed by slimming tools.
std::recursive_mutex & getMutex()
TrigHolderStructure & getHolderStorage()
The Athena Transient Store API.
Container from TrigCaloCluster type objects.
Container of TrigEFBjet objects to be stored in POOL.
Container from TrigEMCluster type objects.
unsigned int size() const
gets size of the bits array
This is a data object, containing a collection of egamma Objects.
std::string label(const std::string &format, int i)
Tool used by TrigBSExtraction to convert to xAOD.
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
bool isPassing(const TrigPassBits *bits, const T *obj, const CONTAINER *container)
Check the bit for the object in the associated bits object.
TrigVertexCountsContainer_v1 TrigVertexCountsContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
BTaggingContainer_v1 BTaggingContainer
Definition of the current "BTagging container version".
TrigPassBitsContainer_v1 TrigPassBitsContainer
Define the latest version of the trig pass bits container class.
TrigMissingETContainer_v1 TrigMissingETContainer
DataVector of TrigMissingET - the current version.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrigCaloClusterContainer_v1 TrigCaloClusterContainer
Define the latest version of the trigger calorimeter cluster container.
TrigT2MbtsBitsContainer_v1 TrigT2MbtsBitsContainer
TrigSpacePointCountsContainer_v1 TrigSpacePointCountsContainer
TrigEMClusterContainer_v1 TrigEMClusterContainer
Define the latest version of the trigger EM cluster container.
TrigTrackCountsContainer_v1 TrigTrackCountsContainer
L2CombinedMuonContainer_v1 L2CombinedMuonContainer
Define the latest version of the muon CB container.
TrigPassBits_v1 TrigPassBits
Define the latest version of the trigger pass bits class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
TrigBphysContainer_v1 TrigBphysContainer
std::unique_ptr< TrigPassBits_v1 > makeTrigPassBits(const CONT *container, uint32_t containerKey=xAOD::TrigPassBits_v1::DEFAULT_KEY)
Helper function creating a new object to describe a target container.
Container2Aux_t< XAOD > xAODAux
DefaultHelper(const ToolHandle< CnvTool > &tool)
virtual StatusCode help(const EventContext &ctx, const std::string &label, const std::string &newLabel)
virtual StatusCode help_fillTrigPassBits(const std::string &label, const std::string &newLabel, const TrigPassBits *tpb_aod, xAOD::TrigPassBits *&tpb_xaod)
virtual StatusCode help(const EventContext &, const std::string &label, const std::string &newLabel)
MuonHelper(const ToolHandle< ITrigMuonEFInfoToMuonCnvTool > &tool)
virtual StatusCode help_fillTrigPassBits(const std::string &label, const std::string &newLabel, const TrigPassBits *tpb_aod, xAOD::TrigPassBits *&tpb_xaod)
static const std::string & typeName()
static constexpr CLID ID()