Skip to content
Snippets Groups Projects
Commit 33c4829f authored by Emmanuel Le Guirriec's avatar Emmanuel Le Guirriec
Browse files

Cleaning, temporary methods deleted

parent 3bfa29ea
No related merge requests found
Showing
with 12 additions and 601 deletions
......@@ -56,7 +56,6 @@ namespace Analysis
virtual StatusCode initialize() override;
virtual StatusCode BTagSecVtx_exec(xAOD::Jet& myJet, xAOD::BTagging*, xAOD::VertexContainer*, xAOD::BTagVertexContainer*, const xAOD::Vertex* vtx=0) const override; //Kept for TrigBtagFex.cxx
virtual StatusCode BTagSecVtx_exec(jetcollection_t* theJets, btagcollection_t*) const override;
virtual StatusCode BTagSecVtx_exec(const xAOD::JetContainer * jetContainer, xAOD::BTaggingContainer * btaggingContainer) const override;
virtual StatusCode finalize() override;
......
......@@ -29,7 +29,6 @@ namespace Analysis
virtual StatusCode initialize() override;
virtual StatusCode finalize() override;
virtual StatusCode BTagTrackAssociation_exec(jetcollection_t* theJets, const xAOD::TrackParticleContainer* tracks = 0) const override; //Kept for TrigBtagFex.cxx
virtual StatusCode BTagTrackAssociation_exec(jetcollection_t* theJets, btagcollection_t*) const override;
virtual StatusCode BTagTrackAssociation_exec(const xAOD::JetContainer * jetContainer, xAOD::BTaggingContainer* btaggingContainer) const override;
private:
......
......@@ -30,13 +30,8 @@ namespace Analysis
/** AlgTool interface methods */
static const InterfaceID& interfaceID() { return IID_IBTagSecVertexing; };
typedef std::vector<xAOD::Jet* > jetcollection_t;
typedef std::vector<xAOD::BTagging* > btagcollection_t;
virtual StatusCode initialize() = 0;
virtual StatusCode BTagSecVtx_exec(xAOD::Jet& myJet, xAOD::BTagging*, xAOD::VertexContainer*, xAOD::BTagVertexContainer*, const xAOD::Vertex* vtx=0) const = 0;
virtual StatusCode BTagSecVtx_exec(jetcollection_t* theJets, btagcollection_t*) const = 0;
virtual StatusCode BTagSecVtx_exec(const xAOD::JetContainer * jetContainer, xAOD::BTaggingContainer * btaggingContainer) const = 0;
virtual StatusCode finalize() = 0;
......
......@@ -27,7 +27,6 @@ namespace Analysis
virtual ~IBTagTrackAssociation(){};
typedef std::vector<xAOD::Jet* > jetcollection_t;
typedef std::vector<xAOD::BTagging* > btagcollection_t;
/** AlgTool interface methods */
static const InterfaceID& interfaceID() { return IID_IBTagTrackAssociation; };
......@@ -35,7 +34,6 @@ namespace Analysis
virtual StatusCode initialize() = 0;
virtual StatusCode finalize() = 0;
virtual StatusCode BTagTrackAssociation_exec(jetcollection_t* theJets, const xAOD::TrackParticleContainer* tracks = 0) const = 0;
virtual StatusCode BTagTrackAssociation_exec(jetcollection_t* theJets, btagcollection_t*) const = 0;
virtual StatusCode BTagTrackAssociation_exec(const xAOD::JetContainer * jetContainer, xAOD::BTaggingContainer* btaggingContainer) const = 0;
};
......
......@@ -39,7 +39,6 @@ class JetBTaggerTool:
StatusCode execute();
JetBTaggerTool(const std::string & n);
//JetBTaggerTool(const std::string&, const IInterface*, const std::string&);
virtual ~JetBTaggerTool();
virtual int modify(xAOD::JetContainer& jets) const;
......@@ -50,10 +49,6 @@ class JetBTaggerTool:
Gaudi::Property<SG::WriteDecorHandleKey<xAOD::JetContainer> >m_jetBTaggingLinkName{this,"JetContainerName","",""};
SG::WriteHandleKey<xAOD::BTaggingContainer> m_BTaggingCollectionName { this, "BTaggingCollectionName", "", ""} ;
//std::string m_BTagName;
//std::string m_BTagSVName;
//std::string m_BTagJFVtxName;
// FIXME: mutable
mutable ToolHandle< IBTagTool > m_bTagTool;
ToolHandle< IBTagTrackAssociation > m_BTagTrackAssocTool;
......@@ -63,12 +58,6 @@ class JetBTaggerTool:
bool m_PtRescale;
ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc;
// Utility functions to be used in case of container overwriting.
// Note that they do not need to be defined here, as they can only be called from code in JetBTaggerTool.cxx.
template< class CONTAINER, class AUXSTORE >
StatusCode overwrite(const std::string& key, bool doCopy = true) const;
template< class CONTAINER, class AUXSTORE >
StatusCode overwriteImp(const std::string& key, bool doCopy = true) const;
};
}
......
......@@ -10,9 +10,6 @@
#include "VxVertex/RecVertex.h"
#include "VxVertex/PrimaryVertexSelector.h" // new since rel 17.2
// migration to new ParticleJet class
//#include "JetEvent/Jet.h"
//general interface for secondary vertex finders
#include "InDetRecToolInterfaces/ISecVertexInJetFinder.h"
#include "VxSecVertex/VxSecVertexInfo.h"
......@@ -40,7 +37,6 @@
#include "JetTagTools/MSVVariablesFactory.h"
#include "xAODBTagging/BTagging.h"
//#include "xAODBTagging/SecVtxHelper.h"
#include "xAODBTagging/BTagVertex.h"
#include "xAODBTagging/BTagVertexContainer.h"
......@@ -346,7 +342,6 @@ namespace Analysis {
newBTag->setSV1_TrackParticleLinks(TrkList);
}
else if ("SV0" == basename){
//newBTag->setTaggerInfo(npprm, xAOD::BTagInfo::SV0_NGTinJet);
newBTag->setTaggerInfo(mass, xAOD::BTagInfo::SV0_masssvx);
newBTag->setTaggerInfo(energyfrc, xAOD::BTagInfo::SV0_efracsvx);
newBTag->setTaggerInfo(n2trk, xAOD::BTagInfo::SV0_N2Tpair);
......@@ -354,7 +349,6 @@ namespace Analysis {
newBTag->setSV0_TrackParticleLinks(TrkList);
}
else{
// newBTag->setVariable<int>(basename, "NGTinJet", npprm);
newBTag->setVariable<float>(basename, "masssvx", mass);
newBTag->setVariable<float>(basename, "efracsvx", energyfrc);
newBTag->setVariable<int>(basename, "N2Tpair", n2trk);
......@@ -381,7 +375,6 @@ namespace Analysis {
}
newBTag->setVariable<std::vector<ElementLink<xAOD::TrackParticleContainer> > >(basename, "badTracksIP", badtrackEL);
newBTag->setDynTPELName(basename, "badTracksIP");
// newBTag->auxdata<std::vector<ElementLink<xAOD::TrackParticleContainer> > >(basename+"_badTracksIP") = badtrackEL;
} else {
ATH_MSG_WARNING("#BTAG# pointer to track particle container not available -> can't create EL to bad tracks IP");
}
......@@ -417,7 +410,6 @@ namespace Analysis {
Trk::VxJetCandidate* vxjetcand = dynamic_cast< Trk::VxJetCandidate*>(JFvertices[0]);
if (!vxjetcand) {
ATH_MSG_WARNING("#BTAG# bad VxCandidate is not a VxJetCandidate");
ATH_MSG_INFO("#BTAG# bad VxCandidate is not a VxJetCandidate");
return StatusCode::SUCCESS;
}
......@@ -452,7 +444,6 @@ namespace Analysis {
float comptoPV(0.);
double chi2(0.);
int ndf(0);
//ATH_MSG_INFO("#BTAGJetFitter# size of Vtxonjetaxes: " << Vtxonjetaxes.size());
nVtx = Vtxonjetaxes.size();
std::vector< ElementLink< xAOD::BTagVertexContainer > > JFVerticesLinks;
std::vector<xAOD::BTagVertex*> JFVertices;
......@@ -683,13 +674,13 @@ namespace Analysis {
const xAOD::Vertex& PrimaryVtx = *primaryVertex;
/* Record the BTagging JF Vertex output container */
ATH_MSG_INFO("#BTAG# Record the BTagging JF Vertex output container");
ATH_MSG_DEBUG("#BTAG# Record the BTagging JF Vertex output container");
SG::WriteHandle<xAOD::BTagVertexContainer> h_BTagJFVtxCollectionName (m_BTagJFVtxCollectionName);
ATH_CHECK( h_BTagJFVtxCollectionName.record(std::make_unique<xAOD::BTagVertexContainer>(),
std::make_unique<xAOD::BTagVertexAuxContainer>()) );
/* Record the BTagging Secondary Vertex output container */
ATH_MSG_INFO("#BTAG# Record the BTagging Secondary Vertex output container");
ATH_MSG_DEBUG("#BTAG# Record the BTagging Secondary Vertex output container");
SG::WriteHandle<xAOD::VertexContainer> h_BTagSVCollectionName (m_BTagSVCollectionName);
ATH_CHECK( h_BTagSVCollectionName.record(std::make_unique<xAOD::VertexContainer>(),
std::make_unique<xAOD::VertexAuxContainer>()) );
......@@ -707,14 +698,12 @@ namespace Analysis {
for ( ; itSecVtxFinders != itSecVtxFindersEnd; ++itSecVtxFinders ) {
if (*itSecVtxFinders==0) {
ATH_MSG_WARNING("#BTAG# could not run the SecVertexFinder:" << *itSecVtxFinders);
ATH_MSG_INFO("#BTAG# could not run the SecVertexFinder:" << *itSecVtxFinders);
++nameiter;
continue;
}
std::string trackname = m_secVertexFinderTrackNameList[nameiter];
std::string basename = m_secVertexFinderBaseNameList[nameiter];
ATH_MSG_INFO("#BTAG# basename:" << basename);
++nameiter;
std::vector<ElementLink< xAOD::TrackParticleContainer > > tracksInJet;
......@@ -751,9 +740,9 @@ namespace Analysis {
(*btagIter)->setDynTPELName(basename, "tracksAtPVlinks");
}
//return StatusCode::SUCCESS;
//MANU break to mimick what was done before. To be fixed. AFT-297
break;
}
ATH_MSG_INFO("#BTAG# tracks associated to the jet " << trackname << " size " << tracksInJet.size());
for ( ; itEL != itELend; ++itEL ) {
const xAOD::TrackParticle* const *inputTrackParticle ;
......@@ -773,7 +762,6 @@ namespace Analysis {
if (const Trk::VxSecVKalVertexInfo* myVertexInfoVKal = dynamic_cast<const Trk::VxSecVKalVertexInfo*>(myVertexInfo)) {
ATH_MSG_DEBUG("#BTAG# Found VKalVertexInfo information");
ATH_MSG_INFO("#BTAG# Found VKalVertexInfo information");
StatusCode sc = fillVkalVariables(jetToTag, *btagIter, &(*h_BTagSVCollectionName), myVertexInfoVKal, theTrackParticleContainer, PrimaryVtx, basename);
if(sc.isFailure()){
ATH_MSG_ERROR("#BTAG# error filling variables from VxSecVKalVertexInfo for tool " << *itSecVtxFinders);
......@@ -782,8 +770,6 @@ namespace Analysis {
}
} else if (const Trk::VxJetFitterVertexInfo* myVertexInfoJetFitter = dynamic_cast<const Trk::VxJetFitterVertexInfo*>(myVertexInfo)) {
ATH_MSG_DEBUG("#BTAG# Found VxJetFitterVertexInfo information");
ATH_MSG_INFO("#BTAG# Found VxJetFitterVertexInfo information");
//sc = fillJFVariables(myJet, newBTag, bTagJFVertexContainer, myVertexInfoJetFitter, theTrackParticleContainer, basename);
StatusCode sc = fillJFVariables(jetToTag, *btagIter, &(*h_BTagJFVtxCollectionName), myVertexInfoJetFitter, theTrackParticleContainer, basename);
if(sc.isFailure()){
ATH_MSG_ERROR("#BTAG# error filling variables from VxJetFitterVertexInfo for tool " << *itSecVtxFinders);
......@@ -802,137 +788,4 @@ namespace Analysis {
}
StatusCode BTagSecVertexing::BTagSecVtx_exec(jetcollection_t* theJets, btagcollection_t* newBTags) const {
const xAOD::Vertex* primaryVertex(0);
//retrieve primary verte
SG::ReadHandle<xAOD::VertexContainer> h_VertexCollectionName (m_VertexCollectionName);
if (!h_VertexCollectionName.isValid()) {
ATH_MSG_ERROR( " cannot retrieve primary vertex container with key " << m_VertexCollectionName.key() );
return StatusCode::FAILURE;
}
unsigned int nVertexes = h_VertexCollectionName->size();
if (nVertexes == 0) {
ATH_MSG_DEBUG("#BTAG# Vertex container is empty");
ATH_MSG_INFO("#BTAG# Vertex container is empty");
return StatusCode::SUCCESS;
}
for (xAOD::VertexContainer::const_iterator fz = h_VertexCollectionName->begin(); fz != h_VertexCollectionName->end(); ++fz) {
if ((*fz)->vertexType() == xAOD::VxType::PriVtx) {
primaryVertex = *fz;
break;
}
}
if (! primaryVertex) {
ATH_MSG_DEBUG("#BTAG# No vertex labeled as VxType::PriVtx!");
ATH_MSG_INFO("#BTAG# No vertex labeled as VxType::PriVtx!");
xAOD::VertexContainer::const_iterator fz = h_VertexCollectionName->begin();
primaryVertex = *fz;
if (primaryVertex->nTrackParticles() == 0) {
ATH_MSG_DEBUG("#BTAG# PV==BeamSpot: probably poor tagging");
}
}
const xAOD::Vertex& PrimaryVtx = *primaryVertex;
ToolHandleArray< InDet::ISecVertexInJetFinder >::const_iterator itSecVtxFinders = m_secVertexFinderToolsHandleArray.begin();
ToolHandleArray< InDet::ISecVertexInJetFinder >::const_iterator itSecVtxFindersEnd = m_secVertexFinderToolsHandleArray.end();
int nameiter = 0;
const xAOD::TrackParticleContainer* theTrackParticleContainer = 0;
/* Record the BTagging JF Vertex output container */
ATH_MSG_INFO("#BTAG# Record the BTagging JF Vertex output container");
SG::WriteHandle<xAOD::BTagVertexContainer> h_BTagJFVtxCollectionName (m_BTagJFVtxCollectionName);
ATH_CHECK( h_BTagJFVtxCollectionName.record(std::make_unique<xAOD::BTagVertexContainer>(),
std::make_unique<xAOD::BTagVertexAuxContainer>()) );
/* Record the BTagging Secondary Vertex output container */
ATH_MSG_INFO("#BTAG# Record the BTagging Secondary Vertex output container");
SG::WriteHandle<xAOD::VertexContainer> h_BTagSVCollectionName (m_BTagSVCollectionName);
ATH_CHECK( h_BTagSVCollectionName.record(std::make_unique<xAOD::VertexContainer>(),
std::make_unique<xAOD::VertexAuxContainer>()) );
btagcollection_t::iterator btagIter=newBTags->begin();
for (jetcollection_t::iterator jetIter = theJets->begin(); jetIter != theJets->end(); ++jetIter, ++btagIter) {
xAOD::Jet& jetToTag = ( **jetIter );
for ( ; itSecVtxFinders != itSecVtxFindersEnd; ++itSecVtxFinders ) {
if (*itSecVtxFinders==0) {
ATH_MSG_WARNING("#BTAG# could not run the SecVertexFinder:" << *itSecVtxFinders);
ATH_MSG_INFO("#BTAG# could not run the SecVertexFinder:" << *itSecVtxFinders);
++nameiter;
continue;
}
std::string trackname = m_secVertexFinderTrackNameList[nameiter];
std::string basename = m_secVertexFinderBaseNameList[nameiter];
ATH_MSG_INFO("#BTAG# basename:" << basename);
++nameiter;
std::vector<ElementLink< xAOD::TrackParticleContainer > > tracksInJet;
tracksInJet = (*btagIter)->auxdata< std::vector<ElementLink< xAOD::TrackParticleContainer > > >(trackname);
std::vector<const xAOD::IParticle*> inputIParticles;
std::vector<ElementLink< xAOD::TrackParticleContainer > >::iterator itEL = tracksInJet.begin();
std::vector<ElementLink< xAOD::TrackParticleContainer > >::iterator itELend = tracksInJet.end();
if(tracksInJet.size()==0){
ATH_MSG_DEBUG("#BTAG# no tracks associated to the jet");
ATH_MSG_INFO("#BTAG# no tracks associated to the jet " << trackname);
return StatusCode::SUCCESS;
}
ATH_MSG_INFO("#BTAG# tracks associated to the jet " << trackname << " size " << tracksInJet.size());
for ( ; itEL != itELend; ++itEL ) {
const xAOD::TrackParticle* const *inputTrackParticle ;
inputTrackParticle = (*itEL).cptr(); //ElementConstPointer cptr
/// warning -> will not work if at some point we decide to associate to several track collections at the same time (in the same assoc object)
theTrackParticleContainer = (*itEL).getStorableObjectPointer();
inputIParticles.push_back(*inputTrackParticle);
}
ATH_MSG_DEBUG("#BTAG# Running " << *itSecVtxFinders);
const Trk::VxSecVertexInfo* myVertexInfo = (*itSecVtxFinders)->findSecVertex(PrimaryVtx, (*jetIter)->p4(), inputIParticles);
ATH_MSG_DEBUG("#BTAG# Storing result ");
if (const Trk::VxSecVKalVertexInfo* myVertexInfoVKal = dynamic_cast<const Trk::VxSecVKalVertexInfo*>(myVertexInfo)) {
ATH_MSG_DEBUG("#BTAG# Found VKalVertexInfo information");
ATH_MSG_INFO("#BTAG# Found VKalVertexInfo information");
StatusCode sc = fillVkalVariables(jetToTag, *btagIter, &(*h_BTagSVCollectionName), myVertexInfoVKal, theTrackParticleContainer, PrimaryVtx, basename);
if(sc.isFailure()){
ATH_MSG_ERROR("#BTAG# error filling variables from VxSecVKalVertexInfo for tool " << *itSecVtxFinders);
delete myVertexInfo;
return sc;
}
} else if (const Trk::VxJetFitterVertexInfo* myVertexInfoJetFitter = dynamic_cast<const Trk::VxJetFitterVertexInfo*>(myVertexInfo)) {
ATH_MSG_DEBUG("#BTAG# Found VxJetFitterVertexInfo information");
ATH_MSG_INFO("#BTAG# Found VxJetFitterVertexInfo information");
//sc = fillJFVariables(myJet, newBTag, bTagJFVertexContainer, myVertexInfoJetFitter, theTrackParticleContainer, basename);
StatusCode sc = fillJFVariables(jetToTag, *btagIter, &(*h_BTagJFVtxCollectionName), myVertexInfoJetFitter, theTrackParticleContainer, basename);
if(sc.isFailure()){
ATH_MSG_ERROR("#BTAG# error filling variables from VxJetFitterVertexInfo for tool " << *itSecVtxFinders);
delete myVertexInfo;
return sc;
}
} else {
ATH_MSG_WARNING("#BTAG# VxSecVertexInfo pointer cannot be interpreted for tool " << *itSecVtxFinders);
}
delete myVertexInfo;
} /// for loop on vertex tools
}// for loop on jets
return StatusCode::SUCCESS;
}
} // namespace
......@@ -293,7 +293,7 @@ namespace Analysis {
// ----- associate tracks
SG::ReadHandle<xAOD::TrackParticleContainer> h_TrackContainerName (m_TrackContainerName);
ATH_MSG_INFO( " retrieve track particle container with key " << m_TrackContainerName.key() );
ATH_MSG_DEBUG( " retrieve track particle container with key " << m_TrackContainerName.key() );
if (!h_TrackContainerName.isValid()) {
ATH_MSG_ERROR( " cannot retrieve track particle container with key " << m_TrackContainerName.key() );
return StatusCode::FAILURE;
......@@ -305,7 +305,6 @@ namespace Analysis {
for (; tAssocIter!=tAssocEnd; ++tAssocIter) {
ATH_MSG_VERBOSE("#BTAG# Number of TrackParticles in event: " << (*h_TrackContainerName).size());
ATH_MSG_INFO("#BTAG# Number of TrackParticles in event: " << (*h_TrackContainerName).size());
// compute the associations
std::vector<std::vector<const xAOD::TrackParticle*>*> assocs =
......@@ -349,12 +348,12 @@ namespace Analysis {
}
// Retrieve the muon container
SG::ReadHandle<xAOD::MuonContainer> h_MuonContainerName (m_MuonContainerName);
ATH_MSG_INFO( " retrieve muon container with key " << m_MuonContainerName.key() );
ATH_MSG_DEBUG( " retrieve muon container with key " << m_MuonContainerName.key() );
if (!h_MuonContainerName.isValid()) {
ATH_MSG_ERROR( " cannot retrieve muon container with key " << m_MuonContainerName.key() );
return StatusCode::FAILURE;
}
ATH_MSG_INFO("#BTAG# Number of Muons in event: " << (*h_MuonContainerName).size());
ATH_MSG_DEBUG("#BTAG# Number of Muons in event: " << (*h_MuonContainerName).size());
std::vector<std::vector<const xAOD::Muon*>*> assocs =
(*muAssocIter)->associateParticlesToJets<std::vector<const xAOD::Muon*>, xAOD::MuonContainer>( jetContainer, &(*h_MuonContainerName), *muAssocNameIter );
......@@ -384,125 +383,4 @@ namespace Analysis {
return StatusCode::SUCCESS;
}
StatusCode BTagTrackAssociation::BTagTrackAssociation_exec(jetcollection_t* theJets, btagcollection_t* newBTags) const {
/* ----------------------------------------------------------------------------------- */
/* Particle to Jet Associations */
/* ----------------------------------------------------------------------------------- */
// new style associations
btagcollection_t::iterator btagIter;
if ( m_TracksToTagList.size() ) {
for (const std::string& trackColName : m_TracksToTagList) {
btagIter = newBTags->begin();
for (const xAOD::Jet* jet : *theJets) {
std::vector< ElementLink< xAOD::TrackParticleContainer > > tmp;
if (!jet->getAttribute(trackColName, tmp)) {
ATH_MSG_FATAL("Unable to read track collection " + trackColName + " from jets for b-tagging.");
return StatusCode::FAILURE;
}
(*btagIter)->auxdata<std::vector<ElementLink<xAOD::TrackParticleContainer> > >(trackColName) = tmp;
++btagIter;
}
}
return StatusCode::SUCCESS;
}
// ----- associate tracks
SG::ReadHandle<xAOD::TrackParticleContainer> h_TrackContainerName (m_TrackContainerName);
ATH_MSG_INFO( " retrieve track particle container with key " << m_TrackContainerName.key() );
if (!h_TrackContainerName.isValid()) {
ATH_MSG_ERROR( " cannot retrieve track particle container with key " << m_TrackContainerName.key() );
return StatusCode::FAILURE;
}
ToolHandleArray< Analysis::ParticleToJetAssociator >::const_iterator tAssocIter = m_TrackToJetAssociatorList.begin();
ToolHandleArray< Analysis::ParticleToJetAssociator >::const_iterator tAssocEnd = m_TrackToJetAssociatorList.end();
std::vector< std::string >::const_iterator tAssocNameIter = m_TrackToJetAssocNameList.begin();
for (; tAssocIter!=tAssocEnd; ++tAssocIter) {
ATH_MSG_VERBOSE("#BTAG# Number of TrackParticles in event: " << (*h_TrackContainerName).size());
ATH_MSG_INFO("#BTAG# Number of TrackParticles in event: " << (*h_TrackContainerName).size());
// compute the associations
std::vector<std::vector<const xAOD::TrackParticle*>*> assocs =
(*tAssocIter)->associateParticlesToJets<std::vector<const xAOD::TrackParticle*>, xAOD::TrackParticleContainer>( theJets, &(*h_TrackContainerName), *tAssocNameIter );
// then store them in the BTagging objects.
unsigned int i = 0;
for ( btagIter = newBTags->begin(); btagIter != newBTags->end(); ++btagIter) {
std::vector< ElementLink< xAOD::TrackParticleContainer > > associationLinks;
for (std::vector<const xAOD::TrackParticle*>::const_iterator trkIter = assocs[i]->begin(); trkIter != assocs[i]->end(); ++trkIter) {
ElementLink<xAOD::TrackParticleContainer> EL;
EL.toContainedElement(*h_TrackContainerName, *trkIter);
associationLinks.push_back(EL);
}
(*btagIter)->auxdata<std::vector<ElementLink<xAOD::TrackParticleContainer> > >(*tAssocNameIter) = associationLinks;
++i;
}
ATH_MSG_VERBOSE("#BTAG# stored track-to jet associations under name " << *tAssocNameIter);
//delete pointer created in associateParticlesToJets
for (i=0; i < assocs.size(); i++) {
delete assocs[i];
}
++tAssocNameIter;
}
// // ----- associate muons
ToolHandleArray< Analysis::ParticleToJetAssociator >::const_iterator muAssocIter = m_MuonToJetAssociatorList.begin();
ToolHandleArray< Analysis::ParticleToJetAssociator >::const_iterator muAssocEnd = m_MuonToJetAssociatorList.end();
std::vector< std::string >::const_iterator muNameIter = m_MuonContainerNameList.begin();
std::vector< std::string >::const_iterator muAssocNameIter = m_MuonToJetAssocNameList.begin();
if (m_MuonToJetAssociatorList.size() == 0) {
ATH_MSG_INFO("#BTAG# MuonToJetAssociatorList is empty - revisit config ");
}
for (; muAssocIter!=muAssocEnd; ++muAssocIter) {
//For test only
if (m_MuonContainerName.key().compare(*muNameIter) != 0) {
ATH_MSG_INFO("#BTAG# Extra muon container - no association - revisit config " << *muNameIter);
continue;
}
// Retrieve the muon container
SG::ReadHandle<xAOD::MuonContainer> h_MuonContainerName (m_MuonContainerName);
ATH_MSG_INFO( " retrieve muon container with key " << m_MuonContainerName.key() );
if (!h_MuonContainerName.isValid()) {
ATH_MSG_ERROR( " cannot retrieve muon container with key " << m_MuonContainerName.key() );
return StatusCode::FAILURE;
}
ATH_MSG_INFO("#BTAG# Number of Muons in event: " << (*h_MuonContainerName).size());
std::vector<std::vector<const xAOD::Muon*>*> assocs =
(*muAssocIter)->associateParticlesToJets<std::vector<const xAOD::Muon*>, xAOD::MuonContainer>( theJets, &(*h_MuonContainerName), *muAssocNameIter );
// then store them in the BTagging objects.
unsigned int i = 0;
for ( btagIter = newBTags->begin(); btagIter != newBTags->end(); ++btagIter) {
std::vector< ElementLink< xAOD::MuonContainer > > associationLinks;
for (std::vector<const xAOD::Muon*>::const_iterator muonIter = assocs[i]->begin(); muonIter != assocs[i]->end(); ++muonIter) {
ElementLink<xAOD::MuonContainer> EL;
EL.toContainedElement(*h_MuonContainerName, *muonIter);
associationLinks.push_back(EL);
}
(*btagIter)->auxdata<std::vector<ElementLink<xAOD::MuonContainer> > >(*muAssocNameIter) = associationLinks;
++i;
}
ATH_MSG_VERBOSE("#BTAG# stored muon-to-jet associations under name " << *muAssocNameIter);
//delete pointer created in associateParticlesToJets
for (i=0; i < assocs.size(); i++) {
delete assocs[i];
}
++muNameIter;
++muAssocNameIter;
}
return StatusCode::SUCCESS;
}
} // namespace
......@@ -127,7 +127,7 @@ StatusCode JetBTaggerTool::execute() {
//Create a xAOD::BTaggingContainer in any case (must be done)
std::string bTaggingContName = m_BTaggingCollectionName.key();
ATH_MSG_INFO("#BTAG# Container name: "<< bTaggingContName);
ATH_MSG_DEBUG("#BTAG# Container name: "<< bTaggingContName);
/* Record the BTagging output container */
SG::WriteHandle<xAOD::BTaggingContainer> h_BTaggingCollectionName (m_BTaggingCollectionName);
......@@ -153,7 +153,6 @@ StatusCode JetBTaggerTool::execute() {
StatusCode jetIsAssociated;
if (!m_BTagTrackAssocTool.empty()) {
ATH_MSG_VERBOSE("#BTAG# Track association tool is not empty");
ATH_MSG_INFO("#BTAG# Track association tool is not empty");
//jetIsAssociated = m_BTagTrackAssocTool->BTagTrackAssociation_exec(&jets, h_BTaggingCollectionName.ptr());
jetIsAssociated = m_BTagTrackAssocTool->BTagTrackAssociation_exec(h_JetCollectionName.ptr(), h_BTaggingCollectionName.ptr());
if ( jetIsAssociated.isFailure() ) {
......@@ -221,207 +220,23 @@ int JetBTaggerTool::modify(xAOD::JetContainer& jetsOriginal) const{
ATH_CHECK( h_BTaggingCollectionName.record(std::make_unique<xAOD::BTaggingContainer>(),
std::make_unique<xAOD::BTaggingAuxContainer>()) );
//xAOD::BTaggingContainer * bTaggingContainer(0);
// Keep track (on an event by event basis; not sure whether this is really necessary) of whether Flavour
// Tagging information exists already or not, as in that case it needs to be overwritten rather than created.
bool retag = false;
/*if (evtStore()->contains<xAOD::BTaggingContainer > ( bTaggingContName )) { //prepare re-tagging
//BTaggingContainer in SG - overwrite it (copying BTagging objects if in "augmentation" mode)
ATH_MSG_VERBOSE("#BTAG# BTagging container " << bTaggingContName << " in store, re-tagging scenario");
retag = true;
StatusCode sc = overwrite<xAOD::BTaggingContainer,xAOD::BTaggingAuxContainer>(bTaggingContName, m_augment);
if (sc.isFailure()) return sc;
CHECK( evtStore()->retrieve(bTaggingContainer, bTaggingContName) );
if (m_augment && jets.size() != bTaggingContainer->size() && m_magFieldSvc->solenoidOn()) {
ATH_MSG_ERROR("#BTAG# existing BTaggingContainer has size" << bTaggingContainer->size() << ", expected " << jets.size());
}
for (const xAOD::Jet* j : jets) {
const_cast<ElementLink< xAOD::BTaggingContainer >&>(j->btaggingLink()).toTransient();
}
}
else {
if (m_augment)
ATH_MSG_WARNING("#BTAG# augmentation requested for non-existent BTaggingContainer");
//No BTaggingContainer not in SG and not re-tagging - record it in SG
ATH_MSG_VERBOSE("#BTAG# BTagging container " << bTaggingContName << " not in store, Jet reco scenario");
bTaggingContainer = new xAOD::BTaggingContainer();
xAOD::BTaggingAuxContainer* bTaggingAuxContainer = new xAOD::BTaggingAuxContainer();
CHECK( evtStore()->record(bTaggingAuxContainer, bTaggingContName+"Aux.") );
bTaggingContainer->setStore(bTaggingAuxContainer);
CHECK( evtStore()->record(bTaggingContainer, bTaggingContName) );
ATH_MSG_VERBOSE("#BTAG# BTagging container " << bTaggingContName << " recorded in store");
}*/
// The SV need to be remade in case of re-tagging, or simply used if b-tagging information is merely to be extended.
// If the SV container does not exist it is created.
// It is conceivable that they do not exist but also don't need to be created anymore (e.g. if
// the container was slimmed away but is also not needed anymore), but we will ignore this case.
//std::string bTagSecVertexContName = bTaggingContName + m_BTagSVCollectionName.key();
/*xAOD::VertexContainer *bTagSecVertexContainer(0);
xAOD::ShallowAuxContainer* bTagSVShallowAuxContainer(0);
bool reuse_SVContainer = false;
if (evtStore()->contains<xAOD::VertexContainer > ( bTagSecVertexContName )) {
if (retag && !m_augment) {
StatusCode sc = overwrite<xAOD::VertexContainer,xAOD::VertexAuxContainer>(bTagSecVertexContName, false);
if (sc.isFailure()) return sc;
CHECK( evtStore()->retrieve(bTagSecVertexContainer, bTagSecVertexContName) );
ATH_MSG_VERBOSE("#BTAG# SV container " << bTagSecVertexContName << " overwritten in store");
} else {
const xAOD::VertexContainer *bTagSecVertexContainerAOD;
StatusCode sc = evtStore()->retrieve(bTagSecVertexContainerAOD,bTagSecVertexContName);
if (sc.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed to retrieve bTagSecVertexContainer " << bTagSecVertexContName );
} else {
auto rec = xAOD::shallowCopyContainer (*bTagSecVertexContainerAOD);
bTagSecVertexContainer = rec.first;
bTagSVShallowAuxContainer = rec.second;
reuse_SVContainer = true;
}
}
} else {
bTagSecVertexContainer = new xAOD::VertexContainer();
xAOD::VertexAuxContainer * bTagSecVertexAuxContainer = new xAOD::VertexAuxContainer();
CHECK( evtStore()->record(bTagSecVertexAuxContainer, bTagSecVertexContName+"Aux.") );
bTagSecVertexContainer->setStore(bTagSecVertexAuxContainer);
CHECK( evtStore()->record(bTagSecVertexContainer, bTagSecVertexContName) );
ATH_MSG_VERBOSE("#BTAG# SV Vertex container " << bTagSecVertexContName << " recorded in store");
}*/
// JFVertex container: the logic here is the same as for the "ordinary" SV container.
//std::string bTagJFVertexContName = bTaggingContName + m_BTagJFVtxCollectionName.key();
/*xAOD::BTagVertexContainer *bTagJFVertexContainer(0);
xAOD::ShallowAuxContainer* bTagJFVShallowAuxContainer(0);
bool reuse_JFVContainer = false;
if (evtStore()->contains<xAOD::BTagVertexContainer > ( bTagJFVertexContName )) {
if (retag && !m_augment) {
StatusCode sc = overwrite<xAOD::BTagVertexContainer,xAOD::BTagVertexAuxContainer>(bTagJFVertexContName, false);
if (sc.isFailure()) return sc;
CHECK( evtStore()->retrieve(bTagJFVertexContainer, bTagJFVertexContName) );
ATH_MSG_VERBOSE("#BTAG# JetFitter Vertex container " << bTagJFVertexContName << " overwritten in store");
} else {
const xAOD::BTagVertexContainer *bTagJFVertexContainerAOD;
StatusCode sc = evtStore()->retrieve(bTagJFVertexContainerAOD,bTagJFVertexContName);
if (sc.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed to retrieve bTagJFVertexContainer " <<bTagJFVertexContName );
} else {
auto rec = xAOD::shallowCopyContainer (*bTagJFVertexContainerAOD);
bTagJFVertexContainer = rec.first;
bTagJFVShallowAuxContainer = rec.second;
reuse_JFVContainer = true;
}
}
} else {
bTagJFVertexContainer = new xAOD::BTagVertexContainer();
xAOD::BTagVertexAuxContainer *bTagJFVertexAuxContainer = new xAOD::BTagVertexAuxContainer();
CHECK( evtStore()->record(bTagJFVertexAuxContainer, bTagJFVertexContName+"Aux.") );
bTagJFVertexContainer->setStore(bTagJFVertexAuxContainer);
CHECK( evtStore()->record(bTagJFVertexContainer, bTagJFVertexContName) );
ATH_MSG_VERBOSE("#BTAG# JetFitter Vertex container " << bTagJFVertexContName << " recorded in store");
}*/
// Since the secondary vertex reconstruction deals with the "ordinary" SV and JetFitter SV simultaneously,
// they should always be handled together. Since the logic above allows for differences between the two,
// these are at least flagged explicitly here.
/* if ((reuse_SVContainer && ! reuse_JFVContainer) || (! reuse_SVContainer && reuse_JFVContainer)) {
ATH_MSG_WARNING("#BTAG# Inconsistent results obtained for SV and JetFitter vertex containers will lead to inconsistent ElementLinks to SV/JFV in output");
}
*/
//ATH_MSG_INFO("MANU before creating BTagging object");
//std::vector<xAOD::Jet*> jetsList;
xAOD::JetContainer::const_iterator itB = jets.begin();
xAOD::JetContainer::const_iterator itE = jets.end();
if (m_magFieldSvc->solenoidOn()) {
// In case of augmentation, fill the btagsList vector here (so as not to complicate the downstream logic)
/*if (m_augment) {
for (auto bt : *bTaggingContainer) btagsList.push_back(bt);
}*/
//unsigned int ibtag = 0;
for (xAOD::JetContainer::const_iterator it = itB ; it != itE; ++it) {
//xAOD::Jet& jetToTag = ( **it );
//jetsList.push_back(&jetToTag);
// In case of augmentation, the BTagging object has been copied and added to btagsList already.
/*xAOD::BTagging* newBTag = 0;
if (m_augment) {
newBTag = btagsList[ibtag++];
} else {*/
xAOD::BTagging * newBTagMT = new xAOD::BTagging();
h_BTaggingCollectionName->push_back(newBTagMT);
//std::unique_ptr<xAOD::BTagging> newBTagMT = std::make_unique<xAOD::BTagging>();
//h_BTaggingCollectionName->push_back(std::move(newBTagMT));
//newBTag = new xAOD::BTagging();
//bTaggingContainer = new xAOD::BTaggingContainer();
//bTaggingContainer->push_back(newBTag);
//xAOD::BTagging * mylastBTag = h_BTaggingCollectionName->back();
//ATH_MSG_INFO("MANU before test SetV0");
//double sv0_significance3D = gRandom->Gaus(0.,1);
//mylastBTag->setSV0_significance3D(sv0_significance3D);
//newBTagMT->setSV0_significance3D(sv0_significance3D);
//ATH_MSG_INFO("MANU before test DL1");
//mylastBTag->setVariable<double>("DL1","pu",1.1);
//ATH_MSG_INFO("MANU before test int");
//mylastBTag->auxdata<int >("TestINT") =1;
//ATH_MSG_INFO("MANU after test int");
//newBTag = new xAOD::BTagging();
//Push the BTagging object in the container and in the temporary vector
//bTaggingContainer->push_back(newBTag);
//btagsList.push_back(mylastBTag);
//}
/*if (!retag) {
//Create an element link to be passed to the tagged Jet.
//Nothing done in case of re-tagging, assuming the same order is used
ElementLink< xAOD::BTaggingContainer> linkBTagger;
linkBTagger.toContainedElement(*bTaggingContainer, newBTag);
jetToTag.setBTaggingLink(linkBTagger);
}*/
} //end loop JetContainer
}
else { //Solenoid OFF
for (xAOD::JetContainer::const_iterator it = itB ; it != itE; ++it) {
const xAOD::Jet& jetToTag = ( **it );
if (!retag) {
ElementLink< xAOD::BTaggingContainer> linkBTagger;
h_jetBTaggingLinkName(jetToTag) = linkBTagger;
//jetToTag.setBTaggingLink(linkBTagger);
}
ElementLink< xAOD::BTaggingContainer> linkBTagger;
h_jetBTaggingLinkName(jetToTag) = linkBTagger;
} //end loop JetContainer
return StatusCode::SUCCESS;
} //end test Solenoid status
// From here on, no modification should be made to the JetContainer anymore.
// We use this to create a shallow copy of the JetContainer, for the case of track-jet collections.
// This allows us to rescale the jet pt values used in the Flavour Tagging algorithms without affecting the input jets.
/* xAOD::ShallowAuxContainer* jetShallowAuxContainer(0);
xAOD::JetContainer* jetShallowContainer(0);
if (m_magFieldSvc->solenoidOn()) {
if (m_PtRescale) {
auto rec = xAOD::shallowCopyContainer (jets);
jetShallowContainer = rec.first;
jetShallowAuxContainer = rec.second;
StatusCode sc = m_PtRescalingTool->BTagJetPtScaling_exec(*jetShallowContainer);
if (sc.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed to carry out jet pt rescaling");
}
// also change the iterators to point to the shallow-copied JetContainer
itB = jetShallowContainer->begin();
itE = jetShallowContainer->end();
// and modify the jetsList variable accordingly
unsigned int ijet = 0;
for (auto it = itB; it != itE; ++it) {
xAOD::Jet& jetToTag = **it;
jetsList[ijet++] = &jetToTag;
}
}
}
*/
// if (!m_augment) {
// We don't want to redo the track-jet association in case of augmentation; however, since
// in the release-20 production the muon-jet association wasn't switched on and it is needed at
// least for the JetVertexChargeTool, we do rerun it here. The working assumption is that in the
......@@ -429,7 +244,6 @@ int JetBTaggerTool::modify(xAOD::JetContainer& jetsOriginal) const{
StatusCode jetIsAssociated;
if (!m_BTagTrackAssocTool.empty()) {
ATH_MSG_VERBOSE("#BTAG# Track association tool is not empty");
ATH_MSG_INFO("#BTAG# Track association tool is not empty");
jetIsAssociated = m_BTagTrackAssocTool->BTagTrackAssociation_exec(&jets, h_BTaggingCollectionName.ptr());
if ( jetIsAssociated.isFailure() ) {
ATH_MSG_ERROR("#BTAG# Failed to associate tracks to jet ");
......@@ -439,10 +253,8 @@ int JetBTaggerTool::modify(xAOD::JetContainer& jetsOriginal) const{
else {
ATH_MSG_WARNING("#BTAG# Empty track association tool ");
}
// }
// Secondary vertex reconstruction: unless it is clear that previous results are to be re-used, run this always.
//if (! (reuse_SVContainer || m_augment)) {
StatusCode SV = m_bTagSecVtxTool->BTagSecVtx_exec(&jets, h_BTaggingCollectionName.ptr());
if (SV.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed to reconstruct sec vtx");
......@@ -451,7 +263,7 @@ int JetBTaggerTool::modify(xAOD::JetContainer& jetsOriginal) const{
//Tag the jets
SV = m_bTagTool->tagJet( &jets, h_BTaggingCollectionName.ptr());
if (SV.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed in taggers call");
ATH_MSG_WARNING("#BTAG# Failed to tag the jets");
}
//Create the element link from the jet to the btagging
......@@ -461,119 +273,9 @@ int JetBTaggerTool::modify(xAOD::JetContainer& jetsOriginal) const{
ElementLink< xAOD::BTaggingContainer> linkBTagger;
linkBTagger.toContainedElement(*h_BTaggingCollectionName.ptr(), itBTag);
h_jetBTaggingLinkName(*jetToTag) = linkBTagger;
//jetToTag.setBTaggingLink(linkBTagger);
}
/* std::vector<xAOD::BTagging *>::iterator itBTag = btagsList.begin();
std::vector<xAOD::Jet *>::iterator itJetB = jetsList.begin();
std::vector<xAOD::Jet *>::iterator itJetE = jetsList.end();
for (std::vector<xAOD::Jet *>::iterator it = itJetB ; it != itJetE; ++it,++itBTag) {
xAOD::Jet& jetToTag = ( **it );
StatusCode sc = m_bTagTool->tagJet( jetToTag, *itBTag );
if (sc.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed in taggers call");
}
ElementLink< xAOD::BTaggingContainer> linkBTagger;
linkBTagger.toContainedElement(h_BTaggingCollectionName.ptr(), itBTag);
if (sc.isFailure()) {
ATH_MSG_WARNING("#BTAG# Failed in taggers call");
}
ElementLink< xAOD::BTaggingContainer> linkBTagger;
linkBTagger.toContainedElement(h_BTaggingCollectionName.ptr(), itBTag);
jetToTag.setBTaggingLink(linkBTagger);
jetToTag.setBTaggingLink(linkBTagger);
}
*/
/* if (reuse_SVContainer) { //is a shallow copy
delete bTagSecVertexContainer;
delete bTagSVShallowAuxContainer;
}
if (reuse_JFVContainer) { //is a shallow copy
delete bTagJFVertexContainer;
delete bTagJFVShallowAuxContainer;
}
*/
/*if (m_PtRescale) { // is a shallow copy
delete jetShallowAuxContainer;
delete jetShallowContainer;
}*/
/// testme
/*for(xAOD::JetContainer::iterator it = itB ; it != itE; ++it) {
xAOD::Jet& jetToTag = ( **it );
const xAOD::BTagging* testbtag = jetToTag.getBTagging();
std::cout << "georges say sv0 = " << testbtag->SV0_significance3D() << std::endl;
}*/
return 1;
return StatusCode::SUCCESS;
}
// Since we are having to do some manipulations for multiple containers, use a few functions to take care of this.
// We keep the functions private so that no other compilation unit can try to
// Code "borrowed" from IsolationAugmentationToolMuons.cxx_nocompile and modified.
// This functionality is needed when overwriting containers within the Derivation context.
template< class CONTAINER, class AUXSTORE >
StatusCode
JetBTaggerTool::overwrite(const std::string& key, bool doCopy) const {
// Let the user know what's happening:
ATH_MSG_VERBOSE( "Running deepCopy on container: " << key );
// Decide which implementation to call:
if (evtStore()->template contains< AUXSTORE >(key+"Aux.")) {
if (overwriteImp< CONTAINER, AUXSTORE >(key, doCopy).isFailure()) {
ATH_MSG_FATAL( "Couldn't call overwriteImp with concrete auxiliary store" );
return StatusCode::FAILURE;
}
} else if (evtStore()->template contains< xAOD::AuxContainerBase >(key+"Aux.")) {
if (overwriteImp<CONTAINER, xAOD::AuxContainerBase>(key, doCopy).isFailure()) {
ATH_MSG_FATAL( "Couldn't call overwriteImp with generic auxiliary store" );
return StatusCode::FAILURE;
}
} else {
ATH_MSG_FATAL( "Couldn't discover auxiliary store type for container \"" << key << "\"" );
return StatusCode::FAILURE;
}
// Return gracefully:
return StatusCode::SUCCESS;
}
template< class CONTAINER, class AUXSTORE >
StatusCode
JetBTaggerTool::overwriteImp(const std::string& key, bool doCopy) const {
// Retrieve the const container:
const CONTAINER* c = 0;
ATH_CHECK( evtStore()->retrieve(c, key) );
// Create the new container:
CONTAINER* copy = new CONTAINER();
AUXSTORE* copyAux = new AUXSTORE();
copy->setStore(copyAux);
if (doCopy) {
// Create the new objects, doing a deep copy if requested
for (auto oldObj : *c ) {
auto newObj = new typename CONTAINER::base_value_type();
copy->push_back(newObj);
*newObj = *oldObj;
}
}
// Do the overwrite:
ATH_CHECK( evtStore()->overwrite( copy, key, true, false ) );
ATH_CHECK( evtStore()->overwrite( copyAux, key + "Aux.", true, false ) );
// Return gracefully:
return StatusCode::SUCCESS;
}
} //// namespace analysis
......@@ -66,8 +66,6 @@ StatusCode StandAloneJetBTaggerAlg::execute() {
return StatusCode::FAILURE;
}
// Should work only with AntiKtEMTopoJets collection, only this collection is b-tagged during reconstruction
//xAOD::JetContainer* jets = h_JetCollectionName
//auto rec = xAOD::shallowCopyContainer (*jetsAOD);
auto rec = xAOD::shallowCopyContainer (*h_JetCollectionName);
int ret = m_JetBTaggerTool->modify(*rec.first);
delete rec.first;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment