14#include "GaudiKernel/ClassID.h"
93#include "CaloEvent/CaloClusterContainer.h"
107template<
class T,
class EDMLIST = TypeInfo_EDM>
struct known{
110 static const bool value = !std::is_same<HLT::TypeInformation::ERROR_THE_FOLLOWING_TYPE_IS_NOT_KNOWN_TO_THE_EDM<T>,
search_result>
::value;
114template<typename T, bool = known<T>::value>
struct getCLID;
116template<
typename T>
struct getCLID<T,false>{
static int ID(){
return -1;}};
128 return StatusCode::SUCCESS;
131 virtual StatusCode
help(
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>
190 virtual StatusCode
help(
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;
212 if(aod->size() != xaod->size()){
213 ATH_MSG_ERROR(
"conversion resulted in differently sized containers");
214 return StatusCode::FAILURE;
216 return StatusCode::SUCCESS;
222 std::string fmtkey_xAOD = IH::template
format<XAOD>(newLabel);
223 std::string fmtkey_xAODAux = IH::template
format<xAODAux>(newLabel+
"Aux.");
225 const AOD* aod = this->
m_sg->template tryConstRetrieve<AOD>(fmtkey_AOD);
228 return StatusCode::SUCCESS;
230 ATH_MSG_DEBUG(
"AOD container " << fmtkey_AOD <<
" extracted of size " << aod->size() );
234 if( aod->size() != tpb_aod->
size() ) {
235 ATH_MSG_WARNING(
"sizes of the container " << fmtkey_AOD <<
" and the corresponding (?) trigpassbits object are different: "
236 << aod->size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
237 return StatusCode::SUCCESS;
240 XAOD* xaod = this->
m_sg->template tryRetrieve<XAOD>(fmtkey_xAOD);
243 return StatusCode::SUCCESS;
245 ATH_MSG_DEBUG(
"xAOD container " << fmtkey_xAOD <<
" extracted of size " << xaod->size());
247 if(aod->size() != xaod->size()) {
248 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
249 return StatusCode::FAILURE;
255 for(
uint i=0; i<aod->size(); i++) {
257 ATH_MSG_DEBUG(
"looking at object " << i+1 <<
" of " << aod->size() );
260 ATH_MSG_DEBUG(
"xaod ispassing = " << xBits->isPassing( i ) );
262 xBits->markPassing( i );
263 ATH_MSG_DEBUG(
"xaod ispassing (after update) = " << xBits->isPassing( i ) );
268 tpb_xaod = xBits.release();
269 return StatusCode::SUCCESS;
282 virtual StatusCode
help(
const std::string&
label,
const std::string& newLabel){
286 return StatusCode::SUCCESS;
290 if(!xaodCombTrackParticles){
292 return StatusCode::SUCCESS;
296 if(!xaodCombTrackParticles){
298 return StatusCode::SUCCESS;
305 return StatusCode::SUCCESS;
308 CHECK(this->
m_tool->convertTrigMuonEFInfoContainer( *aod, *xaodMuon, xaodCombTrackParticles, xaodExtrapTrackParticles));
313 return StatusCode::SUCCESS;
321 return StatusCode::SUCCESS;
324 if( aod->
size() != tpb_aod->
size() ) {
325 ATH_MSG_WARNING(
"sizes of the muon container " <<
label <<
" and the corresponding (?) trigpassbits object are different: "
326 << aod->
size() <<
" vs " << tpb_aod->
size() <<
", will not convert TrigPassBits for this container" );
331 return StatusCode::SUCCESS;
335 if(aod->
size() != xaodMuon->
size()) {
336 ATH_MSG_ERROR(
"containers before and after the conversion are of different sizes");
337 return StatusCode::FAILURE;
348 ATH_MSG_DEBUG(
"muon xaod ispassing = " << xBits->isPassing( i ) );
350 xBits->markPassing( i );
351 ATH_MSG_DEBUG(
"muon xaod ispassing (after update) = " << xBits->isPassing( i ) );
356 tpb_xaod = xBits.release();
357 return StatusCode::SUCCESS;
365 m_tauJetTool(
"xAODMaker::TauJetCnvTool/TauJetCnvTool",this),
366 m_combMuonTool(
"xAODMaker::CombinedMuonFeatureContainerCnvTool/CombinedMuonFeatureContainerCnvTool",this),
367 m_isoMuonTool(
"xAODMaker::IsoMuonFeatureContainerCnvTool/IsoMuonFeatureContainerCnvTool",this),
368 m_trigMuonTool(
"TrigMuonEFInfoToMuonCnvTool/TrigMuonEFInfoToMuonCnvTool",this),
371 m_emClusterTool(
"xAODMaker::TrigEMClusterCnvTool/TrigEMClusterCnvTool",this),
372 m_bjetTool(
"xAODMaker::TrigBjetCnvTool/TrigBjetCnvTool",this),
373 m_efBphysTool(
"xAODMaker::TrigEFBphysContainerCnvTool/TrigEFBphysContainerCnvTool",this),
374 m_l2BphysTool(
"xAODMaker::TrigL2BphysContainerCnvTool/TrigL2BphysContainerCnvTool",this),
375 m_trigMetTool(
"xAODMaker::TrigMissingETCnvTool/TrigMissingETCnvTool",this),
376 m_trigSpacePtsTool(
"xAODMaker::TrigSpacePointCountsCnvTool/TrigSpacePointCountsCnvTool",this),
379 m_trigVtxCtsTool(
"xAODMaker::TrigVertexCountsCnvTool/TrigVertexCountsCnvTool",this),
380 m_electronTool(
"xAODMaker::ElectronCnvTool/ElectronCnvTool", this ),
381 m_photonTool(
"xAODMaker::PhotonCnvTool/PhotonCnvTool", this ),
385 declareInterface<ITrigBStoxAODTool>(
this );
416 std::map<CLID,BStoXAODHelper::IHelper*>::iterator it;
434 m_helpers.insert( std::pair<CLID,BStoXAODHelper::MuonHelper*>
559 std::multimap<CLID,BStoXAODHelper::IHelper*>::iterator it;
571 <<
") is not the same as the number of old containers names ("
573 return StatusCode::FAILURE;
581 m_clid_labels[i].second <<
" differs from the equivalent Run-2 label: "
586 return StatusCode::SUCCESS;
597 ATH_MSG_WARNING(
"couldn't find holder for " << clidlabel->first <<
" " << clidlabel->second);
603 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator hit;
606 std::string clabel = clidlabel->second;
611 <<
" for label " << clidlabel->second <<
", new label " << clidNewLabel->second);
612 CHECK(hit->second->help(clidlabel->second,clidNewLabel->second));
616 ATH_MSG_DEBUG(
"couldn't find converters for clid: " << clidlabel->first);
619 return StatusCode::SUCCESS;
627 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
629 ATH_MSG_DEBUG(
"rewiring Navigation for xAOD. working on " << allTEs.size() <<
" TEs");
630 for(
auto te : allTEs){
631 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
632 for(
auto& featacchelp : feats){
638 ATH_MSG_WARNING(
"could not find old holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
642 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
643 std::string old_label = oldholder->
label();
648 bool iselement = (oldholder->
typeClid()==it->second->AODElementClid());
649 bool iscontainer = (oldholder->
typeClid()==it->second->AODContainerClid());
651 ATH_MSG_VERBOSE(
"old is element feature " << iselement <<
" or container feature: " << iscontainer);
653 if(!(iselement || iscontainer)){
654 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. Old holder is:" << *oldholder);
657 CLID newTypeClid = CLID_NULL;
658 if(iselement) newTypeClid = it->second->xAODElementClid();
659 if(iscontainer) newTypeClid = it->second->xAODContainerClid();
661 std::lock_guard<std::recursive_mutex> lock(nav->
getMutex());
667 ATH_MSG_WARNING(
"could not find new holder for xAOD clid " << newTypeClid <<
" and label " << oldholder->
label());
673 ATH_MSG_VERBOSE(
"changing CLID: " << featacchelp.getCLID() <<
" to " << newTypeClid);
676 featacchelp.setCLIDandIndex(newTypeClid,newholder->
subTypeIndex());
677 ATH_MSG_VERBOSE(
"clid is now: " << featacchelp.getCLID() <<
" sti: " << featacchelp.getIndex().subTypeIndex());
684 return StatusCode::SUCCESS;
691 const std::vector<std::string>& newProperty,
692 std::vector<std::pair<CLID,std::string> >& decoded,
693 std::vector<std::pair<CLID,std::string> >& decodedNewNames) {
695 SmartIF<IClassIDSvc> clidSvc{service(
"ClassIDSvc")};
698 if( property.size() != newProperty.size() ) {
699 ATH_MSG_ERROR(
"vector sizes of new and old SG labels are different: "
700 << newProperty.size() <<
" vs " << property.size() );
701 return StatusCode::FAILURE;
704 std::vector<std::string>::const_iterator it;
705 std::vector<std::string>::const_iterator itNew = newProperty.begin();
706 for ( it = property.begin(); it != property.end(); ++it, ++itNew ) {
709 std::string label_new;
712 if ( it->find(
'#') != std::string::npos ) {
713 type = it->substr(0, it->find(
'#') );
714 label = it->substr(it->find(
'#')+1 );
720 if ( itNew->find(
'#') != std::string::npos ) {
721 label_new = itNew->substr(itNew->find(
'#')+1 );
726 if ( clidSvc->getIDOfTypeName(
type, clid).isFailure() ) {
728 <<
" check property");
729 return StatusCode::FAILURE;
732 ATH_MSG_DEBUG(
"Recognized CLID : " <<
type <<
" and label: " <<
label <<
", new label will be: " << label_new);
733 decoded.push_back(std::make_pair(clid,
label));
734 decodedNewNames.push_back(std::make_pair(clid, label_new));
736 return StatusCode::SUCCESS;
745 std::vector<HLT::TriggerElement*>& allTEs = nav->
getAllTEs();
747 ATH_MSG_DEBUG(
"setting xAOD TrigPassBits. Working on " << allTEs.size() <<
" TEs");
749 for(
auto te : allTEs){
750 std::vector<HLT::TriggerElement::FeatureAccessHelper>& feats = te->getFeatureAccessHelpers();
751 for(
auto& featacchelp : feats){
757 ATH_MSG_WARNING(
"could not find holder for CLID " << featacchelp.getCLID() <<
" and subTypeIndex: " << featacchelp.getIndex());
761 if(holder->
label() ==
"passbits") {
762 ATH_MSG_VERBOSE(
"skipping this feature, as this is the passbits object itself" );
766 std::multimap<CLID,BStoXAODHelper::IHelper*>::const_iterator it =
m_helpers.end();
767 std::string hlabel = holder->
label();
772 <<
", label " << holder->
label() <<
" corresponding to xAOD CLID " << it->second->xAODContainerClid() );
774 bool iselement = (holder->
typeClid()==it->second->AODElementClid());
775 bool iscontainer = (holder->
typeClid()==it->second->AODContainerClid());
777 ATH_MSG_VERBOSE(
"is element feature " << iselement <<
" or container feature: " << iscontainer);
779 if(!(iselement || iscontainer)){
780 ATH_MSG_WARNING(
"not clear what kind of feature we're dealing with. Skipping. The holder is:" << *holder);
785 const TrigPassBitsCollection* bits_collection =
evtStore()->template tryConstRetrieve<TrigPassBitsCollection>(
"HLT_TrigPassBitsCollection_passbits");
786 if(bits_collection !=
nullptr) {
787 ATH_MSG_DEBUG(
"aod bits collection extracted of size " << bits_collection->
size() );
799 if(xaod_bits_collection !=
nullptr)
800 ATH_MSG_DEBUG(
"xaod bits container extracted of size " << xaod_bits_collection->
size() );
807 if ( nav->
getFeature(te, bits,
"passbits" ) ){
819 if(bits_collection !=
nullptr && xaod_bits_collection !=
nullptr && bits !=
nullptr) {
821 for(
uint i=0; i<bits_collection->
size(); i++) {
822 if(bits == bits_collection->
at(i)) {
830 std::pair<CLID,std::string>
pair = std::make_pair( featacchelp.getCLID(), holder->
label() );
833 std::string new_label =
"";
835 new_label = (*it_new_label).second;
836 ATH_MSG_DEBUG(
"calling help_fillTrigPassBits for TE " << te <<
", feature CLID " << featacchelp.getCLID()
837 <<
", aod container " << holder->
label() <<
", new container name: " << new_label );
838 CHECK( it->second->help_fillTrigPassBits( holder->
label(), new_label, bits_collection->
at(bits_nr), xaod_tpb ) );
840 ATH_MSG_DEBUG(
"new label was not found, presumably this container was not converted. Will not look for TrigPassBits" );
843 if(xaod_tpb !=
nullptr) {
844 xaod_bits_collection->
at(bits_nr) = xaod_tpb;
845 ATH_MSG_VERBOSE(
"after the conversion, size of xAOD::TrigPassBits is " << xaod_bits_collection->
at(bits_nr)->size() );
849 ATH_MSG_WARNING(
"TrigPassBits object was not identified within container!" );
857 return StatusCode::SUCCESS;
862 auto myrange = helpers.equal_range(clid);
865 int distance = std::distance(myrange.first, myrange.second);
869 return StatusCode::SUCCESS;
870 }
else if (distance == 2) {
874 for(;it!=myrange.second;++it) {
875 CLID myHelperxAODCLID = (*it).second->xAODContainerClid();
879 return StatusCode::SUCCESS;
882 }
else if( distance == 0) {
885 return StatusCode::SUCCESS;
888 ATH_MSG_ERROR(
"found " << distance <<
" helpers to convert AOD type " << clid <<
" and label " <<
label
889 <<
", probably you should accomodate for this change in the code above" );
890 return StatusCode::FAILURE;
894 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< Identifier > ID
#define CHECK(...)
Evaluate an expression and check for errors.
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.
Container2Aux< XAOD >::type xAODAux
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)
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()
master_search< typenameEDMLIST::map, HLT::TypeInformation::get_cont, CONTAINER >::result::search_result::aux type
master_search< typenameEDMLIST::map, get_strictly_feat, T >::result::search_result search_result