14#include "GaudiKernel/ClassID.h"
93#include "CaloEvent/CaloClusterContainer.h"
105 template<
typename element,
typename list,
int index>
106 struct get_strictly_feat {
107 static constexpr bool result = HLT::TypeInformation::at<list,index>::type::list_of_features::template has<element>::result;
112 constexpr int getCLID() {
115 constexpr bool known = !std::is_same_v<search_result, HLT::TypeInformation::ERROR_THE_FOLLOWING_TYPE_IS_NOT_KNOWN_TO_THE_EDM<T>>;
131 return StatusCode::SUCCESS;
134 virtual StatusCode
help(
const std::string&
label,
const std::string& newLabel) = 0;
147 if(
m_msg->level() <= l){
148 *
m_msg << l;
return true;
176 return StatusCode::SUCCESS;
181 template<
typename AOD,
typename XAOD,
typename CnvTool>
193 virtual StatusCode
help(
const std::string&
label,
const std::string& newLabel){
196 std::string fmtkey_xAOD = IH::template
format<XAOD>(newLabel);
197 std::string fmtkey_xAODAux = IH::template
format<xAODAux>(newLabel+
"Aux.");
199 const AOD* aod = this->
m_sg->template tryConstRetrieve<AOD>(fmtkey_AOD);
201 ATH_MSG_WARNING(
"AOD key: " << fmtkey_AOD <<
" not found for xAOD conversion");
202 return StatusCode::SUCCESS;
205 ATH_MSG_DEBUG(
"attempting to convert " << fmtkey_AOD <<
" of size " << aod->size() <<
" to " << fmtkey_xAOD);
207 XAOD* xaod = this->
m_sg->template tryRetrieve<XAOD>(fmtkey_xAOD);
209 ATH_MSG_WARNING(
"xAOD key: " << fmtkey_xAOD <<
" not found for xAOD conversion");
210 return StatusCode::SUCCESS;
215 if(aod->size() != xaod->size()){
216 ATH_MSG_ERROR(
"conversion resulted in differently sized containers");
217 return StatusCode::FAILURE;
219 return StatusCode::SUCCESS;
225 std::string fmtkey_xAOD = IH::template
format<XAOD>(newLabel);
226 std::string fmtkey_xAODAux = IH::template
format<xAODAux>(newLabel+
"Aux.");
228 const AOD* aod = this->
m_sg->template tryConstRetrieve<AOD>(fmtkey_AOD);
231 return StatusCode::SUCCESS;
233 ATH_MSG_DEBUG(
"AOD container " << fmtkey_AOD <<
" extracted of size " << aod->size() );
237 if( aod->size() != tpb_aod->
size() ) {
238 ATH_MSG_WARNING(
"sizes of the container " << fmtkey_AOD <<
" and the corresponding (?) trigpassbits object are different: "
239 << aod->size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
240 return StatusCode::SUCCESS;
243 XAOD* xaod = this->
m_sg->template tryRetrieve<XAOD>(fmtkey_xAOD);
246 return StatusCode::SUCCESS;
248 ATH_MSG_DEBUG(
"xAOD container " << fmtkey_xAOD <<
" extracted of size " << xaod->size());
250 if(aod->size() != xaod->size()) {
251 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
252 return StatusCode::FAILURE;
258 for(
uint i=0; i<aod->size(); i++) {
260 ATH_MSG_DEBUG(
"looking at object " << i+1 <<
" of " << aod->size() );
263 ATH_MSG_DEBUG(
"xaod ispassing = " << xBits->isPassing( i ) );
265 xBits->markPassing( i );
266 ATH_MSG_DEBUG(
"xaod ispassing (after update) = " << xBits->isPassing( i ) );
271 tpb_xaod = xBits.release();
272 return StatusCode::SUCCESS;
285 virtual StatusCode
help(
const std::string&
label,
const std::string& newLabel){
289 return StatusCode::SUCCESS;
293 if(!xaodCombTrackParticles){
295 return StatusCode::SUCCESS;
299 if(!xaodCombTrackParticles){
301 return StatusCode::SUCCESS;
308 return StatusCode::SUCCESS;
311 CHECK(this->
m_tool->convertTrigMuonEFInfoContainer( *aod, *xaodMuon, xaodCombTrackParticles, xaodExtrapTrackParticles));
316 return StatusCode::SUCCESS;
324 return StatusCode::SUCCESS;
327 if( aod->
size() != tpb_aod->
size() ) {
328 ATH_MSG_WARNING(
"sizes of the muon container " <<
label <<
" and the corresponding (?) trigpassbits object are different: "
329 << aod->
size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
334 return StatusCode::SUCCESS;
338 if(aod->
size() != xaodMuon->
size()) {
339 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
340 return StatusCode::FAILURE;
351 ATH_MSG_DEBUG(
"muon xaod ispassing = " << xBits->isPassing( i ) );
353 xBits->markPassing( i );
354 ATH_MSG_DEBUG(
"muon xaod ispassing (after update) = " << xBits->isPassing( i ) );
359 tpb_xaod = xBits.release();
360 return StatusCode::SUCCESS;
368 m_tauJetTool(
"xAODMaker::TauJetCnvTool/TauJetCnvTool",this),
369 m_combMuonTool(
"xAODMaker::CombinedMuonFeatureContainerCnvTool/CombinedMuonFeatureContainerCnvTool",this),
370 m_isoMuonTool(
"xAODMaker::IsoMuonFeatureContainerCnvTool/IsoMuonFeatureContainerCnvTool",this),
371 m_trigMuonTool(
"TrigMuonEFInfoToMuonCnvTool/TrigMuonEFInfoToMuonCnvTool",this),
374 m_emClusterTool(
"xAODMaker::TrigEMClusterCnvTool/TrigEMClusterCnvTool",this),
375 m_bjetTool(
"xAODMaker::TrigBjetCnvTool/TrigBjetCnvTool",this),
376 m_efBphysTool(
"xAODMaker::TrigEFBphysContainerCnvTool/TrigEFBphysContainerCnvTool",this),
377 m_l2BphysTool(
"xAODMaker::TrigL2BphysContainerCnvTool/TrigL2BphysContainerCnvTool",this),
378 m_trigMetTool(
"xAODMaker::TrigMissingETCnvTool/TrigMissingETCnvTool",this),
379 m_trigSpacePtsTool(
"xAODMaker::TrigSpacePointCountsCnvTool/TrigSpacePointCountsCnvTool",this),
382 m_trigVtxCtsTool(
"xAODMaker::TrigVertexCountsCnvTool/TrigVertexCountsCnvTool",this),
383 m_electronTool(
"xAODMaker::ElectronCnvTool/ElectronCnvTool", this ),
384 m_photonTool(
"xAODMaker::PhotonCnvTool/PhotonCnvTool", this ),
388 declareInterface<ITrigBStoxAODTool>(
this );
419 std::map<CLID,BStoXAODHelper::IHelper*>::iterator it;
437 m_helpers.insert( std::pair<CLID,BStoXAODHelper::MuonHelper*>
503 (getCLID<TrigTrackCountsCollection>(),
562 std::multimap<CLID,BStoXAODHelper::IHelper*>::iterator it;
574 <<
") is not the same as the number of old containers names ("
576 return StatusCode::FAILURE;
584 m_clid_labels[i].second <<
" differs from the equivalent Run-2 label: "
589 return StatusCode::SUCCESS;
600 ATH_MSG_WARNING(
"couldn't find holder for " << clidlabel->first <<
" " << clidlabel->second);
606 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator hit;
609 std::string clabel = clidlabel->second;
614 <<
" for label " << clidlabel->second <<
", new label " << clidNewLabel->second);
615 CHECK(hit->second->help(clidlabel->second,clidNewLabel->second));
619 ATH_MSG_DEBUG(
"couldn't find converters for clid: " << clidlabel->first);
622 return StatusCode::SUCCESS;
630 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
632 ATH_MSG_DEBUG(
"rewiring Navigation for xAOD. working on " << allTEs.size() <<
" TEs");
633 for(
auto te : allTEs){
634 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
635 for(
auto& featacchelp : feats){
641 ATH_MSG_WARNING(
"could not find old holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
645 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
646 std::string old_label = oldholder->
label();
651 bool iselement = (oldholder->
typeClid()==it->second->AODElementClid());
652 bool iscontainer = (oldholder->
typeClid()==it->second->AODContainerClid());
654 ATH_MSG_VERBOSE(
"old is element feature " << iselement <<
" or container feature: " << iscontainer);
656 if(!(iselement || iscontainer)){
657 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. Old holder is:" << *oldholder);
660 CLID newTypeClid = CLID_NULL;
661 if(iselement) newTypeClid = it->second->xAODElementClid();
662 if(iscontainer) newTypeClid = it->second->xAODContainerClid();
664 std::lock_guard<std::recursive_mutex> lock(nav->
getMutex());
670 ATH_MSG_WARNING(
"could not find new holder for xAOD clid " << newTypeClid <<
" and label " << oldholder->
label());
676 ATH_MSG_VERBOSE(
"changing CLID: " << featacchelp.getCLID() <<
" to " << newTypeClid);
679 featacchelp.setCLIDandIndex(newTypeClid,newholder->
subTypeIndex());
680 ATH_MSG_VERBOSE(
"clid is now: " << featacchelp.getCLID() <<
" sti: " << featacchelp.getIndex().subTypeIndex());
687 return StatusCode::SUCCESS;
694 const std::vector<std::string>& newProperty,
695 std::vector<std::pair<CLID,std::string> >& decoded,
696 std::vector<std::pair<CLID,std::string> >& decodedNewNames) {
698 SmartIF<IClassIDSvc> clidSvc{service(
"ClassIDSvc")};
701 if( property.size() != newProperty.size() ) {
702 ATH_MSG_ERROR(
"vector sizes of new and old SG labels are different: "
703 << newProperty.size() <<
" vs " << property.size() );
704 return StatusCode::FAILURE;
707 std::vector<std::string>::const_iterator it;
708 std::vector<std::string>::const_iterator itNew = newProperty.begin();
709 for ( it = property.begin(); it != property.end(); ++it, ++itNew ) {
712 std::string label_new;
715 if ( it->find(
'#') != std::string::npos ) {
716 type = it->substr(0, it->find(
'#') );
717 label = it->substr(it->find(
'#')+1 );
723 if ( itNew->find(
'#') != std::string::npos ) {
724 label_new = itNew->substr(itNew->find(
'#')+1 );
729 if ( clidSvc->getIDOfTypeName(
type, clid).isFailure() ) {
731 <<
" check property");
732 return StatusCode::FAILURE;
735 ATH_MSG_DEBUG(
"Recognized CLID : " <<
type <<
" and label: " <<
label <<
", new label will be: " << label_new);
736 decoded.push_back(std::make_pair(clid,
label));
737 decodedNewNames.push_back(std::make_pair(clid, label_new));
739 return StatusCode::SUCCESS;
748 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
750 ATH_MSG_DEBUG(
"setting xAOD TrigPassBits. Working on " << allTEs.size() <<
" TEs");
752 for(
auto te : allTEs){
753 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
754 for(
auto& featacchelp : feats){
760 ATH_MSG_WARNING(
"could not find holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
764 if(holder->
label() ==
"passbits") {
765 ATH_MSG_VERBOSE(
"skipping this feature, as this is the passbits object itself" );
769 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
770 std::string hlabel = holder->
label();
775 <<
", label " << holder->
label() <<
" corresponding to xAOD CLID " << it->second->xAODContainerClid() );
777 bool iselement = (holder->
typeClid()==it->second->AODElementClid());
778 bool iscontainer = (holder->
typeClid()==it->second->AODContainerClid());
780 ATH_MSG_VERBOSE(
"is element feature " << iselement <<
" or container feature: " << iscontainer);
782 if(!(iselement || iscontainer)){
783 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. The holder is:" << *holder);
788 const TrigPassBitsCollection* bits_collection =
evtStore()->template tryConstRetrieve<TrigPassBitsCollection>(
"HLT_TrigPassBitsCollection_passbits");
789 if(bits_collection !=
nullptr) {
790 ATH_MSG_DEBUG(
"aod bits collection extracted of size " << bits_collection->
size() );
802 if(xaod_bits_collection !=
nullptr)
803 ATH_MSG_DEBUG(
"xaod bits container extracted of size " << xaod_bits_collection->
size() );
810 if ( nav->
getFeature(te, bits,
"passbits" ) ){
822 if(bits_collection !=
nullptr && xaod_bits_collection !=
nullptr && bits !=
nullptr) {
824 for(
uint i=0; i<bits_collection->
size(); i++) {
825 if(bits == bits_collection->
at(i)) {
833 std::pair<CLID,std::string>
pair = std::make_pair( featacchelp.getCLID(), holder->
label() );
836 std::string new_label =
"";
838 new_label = (*it_new_label).second;
839 ATH_MSG_DEBUG(
"calling help_fillTrigPassBits for TE " << te <<
", feature CLID " << featacchelp.getCLID()
840 <<
", aod container " << holder->
label() <<
", new container name: " << new_label );
841 CHECK( it->second->help_fillTrigPassBits( holder->
label(), new_label, bits_collection->
at(bits_nr), xaod_tpb ) );
843 ATH_MSG_DEBUG(
"new label was not found, presumably this container was not converted. Will not look for TrigPassBits" );
846 if(xaod_tpb !=
nullptr) {
847 xaod_bits_collection->
at(bits_nr) = xaod_tpb;
848 ATH_MSG_VERBOSE(
"after the conversion, size of xAOD::TrigPassBits is " << xaod_bits_collection->
at(bits_nr)->size() );
852 ATH_MSG_WARNING(
"TrigPassBits object was not identified within container!" );
860 return StatusCode::SUCCESS;
865 auto myrange = helpers.equal_range(clid);
868 int distance = std::distance(myrange.first, myrange.second);
872 return StatusCode::SUCCESS;
873 }
else if (distance == 2) {
877 for(;it!=myrange.second;++it) {
878 CLID myHelperxAODCLID = (*it).second->xAODContainerClid();
882 return StatusCode::SUCCESS;
885 }
else if( distance == 0) {
888 return StatusCode::SUCCESS;
891 ATH_MSG_ERROR(
"found " << distance <<
" helpers to convert AOD type " << clid <<
" and label " <<
label
892 <<
", probably you should accomodate for this change in the code above" );
893 return StatusCode::FAILURE;
897 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.
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 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
virtual StatusCode help(const std::string &label, const std::string &newLabel)=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.
virtual StatusCode help_fillTrigPassBits(const std::string &label, const std::string &newLabel, const TrigPassBits *tpb_aod, xAOD::TrigPassBits *&tpb_xaod)
virtual StatusCode help(const std::string &label, const std::string &newLabel)
Container2Aux_t< XAOD > xAODAux
DefaultHelper(const ToolHandle< CnvTool > &tool)
virtual StatusCode help(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()