22#ifndef XAOD_STANDALONE
39 return StatusCode::SUCCESS;
43 std::map<xAOD::Type::ObjectType,std::vector<const xAOD::IParticle*> > typeSeparated;
45 for (
const auto& obj : recoObjects){
46 if(typeSeparated.find(obj->type()) == typeSeparated.end()){
47 std::vector<const xAOD::IParticle*> typevec;
48 typeSeparated[obj->type()] = typevec;
50 typeSeparated[obj->type()].push_back(obj);
53 ATH_MSG_DEBUG(
"found: " << typeSeparated.size() <<
" unique objects types to match");
54 for(
auto& [objType, recoObjs_thistype] : typeSeparated){
55 ATH_MSG_DEBUG(
"type: " << objType <<
"(" << recoObjs_thistype.size() <<
" elements)");
58 bool overall_status =
true;
59 std::map<xAOD::Type::ObjectType,bool> status;
60 for(
auto& [objType, recoObjs_thistype] : typeSeparated){
62 ATH_MSG_DEBUG(
"type: " << objType <<
" status: " << single_status);
63 status[objType] = single_status;
64 overall_status = overall_status && single_status;
67 return overall_status;
73 auto recoType = recoObjects.at(0)->type();
77 std::string container_typename(
"");
80 if (recoType ==
xAOD::Type::Electron && chain.find(
"etcut") != std::string::npos && chain.find(
"trkcut") == std::string::npos){
81 ATH_MSG_DEBUG(
"Electron offline and matching electron etcut chain. Try to match to cluster instead!: " );
87 auto clid_container =
m_typeMap.get(recoType);
89 clid = clid_container.first;
90 container_typename = clid_container.second;
91 ATH_MSG_DEBUG(
"getting trigger features (clid: " << clid <<
" and type: " << container_typename <<
")");
94 ATH_MSG_WARNING(
"could not find corresponding trigger type, can't match");
98 auto iparticle_feats = comb.
getIParticle(clid,container_typename);
100 ATH_MSG_DEBUG(
"found: " << iparticle_feats.size() <<
" xAOD::IParticle");
102 for(
auto& feat : iparticle_feats){
103 ATH_MSG_DEBUG(
" ==> pt: " << feat.cptr()->pt() <<
" and eta: " << feat.cptr()->eta() <<
" address: " << feat.cptr());
106 if(recoObjects.size() > iparticle_feats.size()){
107 ATH_MSG_WARNING(
"more reco objects (" << recoObjects.size() <<
") than trigger object (" << iparticle_feats.size() <<
"). no hope of matching!");
111 ATH_MSG_DEBUG(
"now matching: " << recoObjects.size() <<
" reco objects to " << iparticle_feats.size() <<
" trigger objects");
113 std::vector<const xAOD::IParticle*> trigObjects;
114 for(
auto& feat : iparticle_feats){trigObjects.push_back(feat.cptr());}
116 std::vector<std::vector<double>> scoreMatrix;
117 scoreMatrix.reserve(recoObjects.size());
120 scoreMatrix.emplace_back();
121 std::vector<double> &scores = scoreMatrix.back();
122 scores.reserve(trigObjects.size());
126 scores.push_back(
static_cast<double>(
m_scoreTool->score(*trig, *reco)));
139 std::vector<const xAOD::IParticle*> recoObjects(1,&recoObject);
140 bool out =
match(recoObjects, chain, matchThreshold, rerun);
144 bool MatchingTool::match(
const std::vector<const xAOD::IParticle*>& recoObjects,
const std::string& chain,
double matchThreshold,
bool rerun)
const {
145 ATH_MSG_DEBUG(
"matching " << recoObjects.size() <<
" reco objects to chain: " << chain );
154 if(!decision)
return false;
156 auto featureContainer = chainGroup->features();
157 auto combinations = featureContainer.getCombinations();
159 ATH_MSG_DEBUG(
"chain has: " << combinations.size() <<
" combos");
163 for(
auto& comb : combinations){
164 bool combResult =
matchCombination(recoObjects,comb, chain, matchThreshold);
165 ATH_MSG_DEBUG(
"matching result for this combination: " << combResult);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool isPassed(unsigned int condition=TrigDefs::Physics) const
tells if chain group passed
is a connector between chains and object It store single combination of trigger elements.
std::vector< Trig::Feature< xAOD::IParticle > > getIParticle(HLT::class_id_type clid, const std::string &container_name, const std::string &label="", unsigned int condition=TrigDefs::Physics, const std::string &teName="") const
Experimental flattened get for IParticle types.
const std::vector< const HLT::TriggerElement * > & tes() const
trigger elements in the combination can be used directly with ancestor method
const Trig::TrigDecisionTool * tdt() const
bool matchDistanceMatrix(const std::vector< std::vector< double > > &matrix, const Trig::MatchingStrategy::Strategy strategy=Trig::MatchingStrategy::MinimalSum, double threshold=0.0) const
Class providing the definition of the 4-vector interface.
static const unsigned int allowResurrectedDecision
static const unsigned int Physics
The common trigger namespace for trigger analysis tools.
@ CaloCluster
The object is a calorimeter cluster.
@ Electron
The object is an electron.