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>(),
555 std::multimap<CLID,BStoXAODHelper::IHelper*>::iterator it;
567 <<
") is not the same as the number of old containers names ("
569 return StatusCode::FAILURE;
577 m_clid_labels[i].second <<
" differs from the equivalent Run-2 label: "
582 return StatusCode::SUCCESS;
593 ATH_MSG_WARNING(
"couldn't find holder for " << clidlabel->first <<
" " << clidlabel->second);
599 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator hit;
602 std::string clabel = clidlabel->second;
607 <<
" for label " << clidlabel->second <<
", new label " << clidNewLabel->second);
608 CHECK(hit->second->help(ctx, clidlabel->second,clidNewLabel->second));
612 ATH_MSG_DEBUG(
"couldn't find converters for clid: " << clidlabel->first);
615 return StatusCode::SUCCESS;
623 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
625 ATH_MSG_DEBUG(
"rewiring Navigation for xAOD. working on " << allTEs.size() <<
" TEs");
626 for(
auto te : allTEs){
627 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
628 for(
auto& featacchelp : feats){
634 ATH_MSG_WARNING(
"could not find old holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
638 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
639 std::string old_label = oldholder->
label();
644 bool iselement = (oldholder->
typeClid()==it->second->AODElementClid());
645 bool iscontainer = (oldholder->
typeClid()==it->second->AODContainerClid());
647 ATH_MSG_VERBOSE(
"old is element feature " << iselement <<
" or container feature: " << iscontainer);
649 if(!(iselement || iscontainer)){
650 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. Old holder is:" << *oldholder);
653 CLID newTypeClid = CLID_NULL;
654 if(iselement) newTypeClid = it->second->xAODElementClid();
655 if(iscontainer) newTypeClid = it->second->xAODContainerClid();
657 std::lock_guard<std::recursive_mutex>
lock(nav->
getMutex());
663 ATH_MSG_WARNING(
"could not find new holder for xAOD clid " << newTypeClid <<
" and label " << oldholder->
label());
669 ATH_MSG_VERBOSE(
"changing CLID: " << featacchelp.getCLID() <<
" to " << newTypeClid);
672 featacchelp.setCLIDandIndex(newTypeClid,newholder->
subTypeIndex());
673 ATH_MSG_VERBOSE(
"clid is now: " << featacchelp.getCLID() <<
" sti: " << featacchelp.getIndex().subTypeIndex());
680 return StatusCode::SUCCESS;
687 const std::vector<std::string>& newProperty,
688 std::vector<std::pair<CLID,std::string> >& decoded,
689 std::vector<std::pair<CLID,std::string> >& decodedNewNames) {
691 SmartIF<IClassIDSvc> clidSvc{service(
"ClassIDSvc")};
694 if( property.size() != newProperty.size() ) {
695 ATH_MSG_ERROR(
"vector sizes of new and old SG labels are different: "
696 << newProperty.size() <<
" vs " << property.size() );
697 return StatusCode::FAILURE;
700 std::vector<std::string>::const_iterator it;
701 std::vector<std::string>::const_iterator itNew = newProperty.begin();
702 for ( it = property.begin(); it != property.end(); ++it, ++itNew ) {
705 std::string label_new;
708 if ( it->find(
'#') != std::string::npos ) {
709 type = it->substr(0, it->find(
'#') );
710 label = it->substr(it->find(
'#')+1 );
716 if ( itNew->find(
'#') != std::string::npos ) {
717 label_new = itNew->substr(itNew->find(
'#')+1 );
722 if ( clidSvc->getIDOfTypeName(
type, clid).isFailure() ) {
724 <<
" check property");
725 return StatusCode::FAILURE;
728 ATH_MSG_DEBUG(
"Recognized CLID : " <<
type <<
" and label: " <<
label <<
", new label will be: " << label_new);
729 decoded.push_back(std::make_pair(clid,
label));
730 decodedNewNames.push_back(std::make_pair(clid, label_new));
732 return StatusCode::SUCCESS;
741 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
743 ATH_MSG_DEBUG(
"setting xAOD TrigPassBits. Working on " << allTEs.size() <<
" TEs");
745 for(
auto te : allTEs){
746 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
747 for(
auto& featacchelp : feats){
753 ATH_MSG_WARNING(
"could not find holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
757 if(holder->
label() ==
"passbits") {
758 ATH_MSG_VERBOSE(
"skipping this feature, as this is the passbits object itself" );
762 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
763 std::string hlabel = holder->
label();
768 <<
", label " << holder->
label() <<
" corresponding to xAOD CLID " << it->second->xAODContainerClid() );
770 bool iselement = (holder->
typeClid()==it->second->AODElementClid());
771 bool iscontainer = (holder->
typeClid()==it->second->AODContainerClid());
773 ATH_MSG_VERBOSE(
"is element feature " << iselement <<
" or container feature: " << iscontainer);
775 if(!(iselement || iscontainer)){
776 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. The holder is:" << *holder);
781 const TrigPassBitsCollection* bits_collection =
evtStore()->template tryConstRetrieve<TrigPassBitsCollection>(
"HLT_TrigPassBitsCollection_passbits");
782 if(bits_collection !=
nullptr) {
783 ATH_MSG_DEBUG(
"aod bits collection extracted of size " << bits_collection->
size() );
795 if(xaod_bits_collection !=
nullptr)
796 ATH_MSG_DEBUG(
"xaod bits container extracted of size " << xaod_bits_collection->
size() );
803 if ( nav->
getFeature(te, bits,
"passbits" ) ){
815 if(bits_collection !=
nullptr && xaod_bits_collection !=
nullptr && bits !=
nullptr) {
817 for(
uint i=0; i<bits_collection->
size(); i++) {
818 if(bits == bits_collection->
at(i)) {
826 std::pair<CLID,std::string>
pair = std::make_pair( featacchelp.getCLID(), holder->
label() );
829 std::string new_label =
"";
831 new_label = (*it_new_label).second;
832 ATH_MSG_DEBUG(
"calling help_fillTrigPassBits for TE " << te <<
", feature CLID " << featacchelp.getCLID()
833 <<
", aod container " << holder->
label() <<
", new container name: " << new_label );
834 CHECK( it->second->help_fillTrigPassBits( holder->
label(), new_label, bits_collection->
at(bits_nr), xaod_tpb ) );
836 ATH_MSG_DEBUG(
"new label was not found, presumably this container was not converted. Will not look for TrigPassBits" );
839 if(xaod_tpb !=
nullptr) {
840 xaod_bits_collection->
at(bits_nr) = xaod_tpb;
841 ATH_MSG_VERBOSE(
"after the conversion, size of xAOD::TrigPassBits is " << xaod_bits_collection->
at(bits_nr)->size() );
845 ATH_MSG_WARNING(
"TrigPassBits object was not identified within container!" );
853 return StatusCode::SUCCESS;
858 auto myrange = helpers.equal_range(clid);
861 int distance = std::distance(myrange.first, myrange.second);
865 return StatusCode::SUCCESS;
866 }
else if (distance == 2) {
870 for(;it!=myrange.second;++it) {
871 CLID myHelperxAODCLID = (*it).second->xAODContainerClid();
875 return StatusCode::SUCCESS;
878 }
else if( distance == 0) {
881 return StatusCode::SUCCESS;
884 ATH_MSG_ERROR(
"found " << distance <<
" helpers to convert AOD type " << clid <<
" and label " <<
label
885 <<
", probably you should accomodate for this change in the code above" );
886 return StatusCode::FAILURE;
890 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()