Commit 9d510eaf authored by Vladimir Lyubushkin's avatar Vladimir Lyubushkin Committed by Frank Winklmeier
Browse files

TrigBphysHypo: clean-up and optimization of TrigMultiTrkHypo algorithm (ATR-20836)

* refine the merging procedure of the incoming tracks/muons
* add Monitored::Timer
* xAOD::TrigBphys is still used as a decision feature object
parent d5dee2e6
......@@ -21,9 +21,9 @@ class TrigMultiTrkHypoConfig(object):
try:
value = trigLevelDict[trigLevel]
log.debug('TrigMultiTrkHypo.trigLevelString = %s ', value)
log.debug('TrigMultiTrkHypo.trigLevel = %s ', value)
except KeyError:
log.error('TrigMultiTrkHypo.trigLevelString should be L2 or EF, but %s provided.', trigLevel)
log.error('TrigMultiTrkHypo.trigLevel should be L2 or EF, but %s provided.', trigLevel)
from TrkVKalVrtFitter.TrkVKalVrtFitterConf import Trk__TrkVKalVrtFitter
VertexFitter = Trk__TrkVKalVrtFitter(
......@@ -42,24 +42,16 @@ class TrigMultiTrkHypoConfig(object):
tool = TrigMultiTrkHypo(
name = trigSequenceName+'HypoAlg'+trigLevel,
trigLevelString = trigLevel,
trackCollectionKey = trackCollection,
trigLevel = trigLevel,
nTracks = 2,
massRanges = [ (100., 20000.) ],
TrackCollectionKey = trackCollection,
MuonCollectionKey = muonCollection,
nTrk = 2,
nTrackMassMin = [100.],
nTrackMassMax = [20000.],
TrigBphysCollectionKey = ('TrigBphys' if trigLevel == 'L2' else 'TrigBphysEF') + trigSequenceName,
VertexFitter = VertexFitter,
VertexPointEstimator = VertexPointEstimator,
MonTool = TrigMultiTrkHypoMonitoring('TrigMultiTrkHypoMonitoring_'+trigSequenceName+trigLevel))
if trigLevel == 'L2':
tool.particleType = 0
tool.bphysCollectionKey = "TrigBphys"+trigSequenceName
elif trigLevel == 'EF':
tool.particleType = 1
tool.bphysCollectionKey = "TrigBphysEF"+trigSequenceName
return tool
def ConfigurationHypoTool(self, chainDict):
......
......@@ -6,15 +6,17 @@ class TrigMultiTrkHypoMonitoring(GenericMonitoringTool):
def __init__ (self, name):
super(TrigMultiTrkHypoMonitoring, self).__init__(name)
self.Histograms = [
defineHistogram('pairMass', type='TH1F', path='EXPERT', title="mass of track pairs; m_{#mu#mu} [GeV]", xbins=200, xmin=0, xmax=100),
defineHistogram('nTrk', type='TH1F',path='EXPERT', title="number of tracks input; N tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('accepted_highptNTrk', type='TH1F', path='EXPERT', title="Number of tracks selected; N selected tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('nPair', type='TH1F',path='EXPERT', title="number of pairs input; N tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('accepted_nPair', type='TH1F', path='EXPERT', title="Number of pairs selected; N selected tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('totCharge', type='TH1F', path='EXPERT', title="Total Charge of tracks", xbins=21, xmin=-10, xmax=10),
defineHistogram('nTrkMass', type='TH1F', path='EXPERT', title="mass of N tracks; mass of N selected tracks [GeV]", xbins=100, xmin=0, xmax=20),
defineHistogram('nTrkFitMass', type='TH1F', path='EXPERT', title="fit mass of N tracks; fit mass of N selected tracks", xbins=100, xmin=0, xmax=20),
defineHistogram('nTrkChi2', type='TH1F', path='EXPERT', title="chi2 fit of N tracks; fit chi2 of N selected tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('nTrk', type='TH1F', path='EXPERT', title="number of tracks in input views", xbins=100, xmin=0, xmax=100),
defineHistogram('nAcceptedTrk', type='TH1F', path='EXPERT', title="number of selected input tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('nCombination', type='TH1F',path='EXPERT', title="number of track combinations before mass preselection", xbins=100, xmin=0, xmax=100),
defineHistogram('nCombinationBeforeFit', type='TH1F', path='EXPERT', title="number of inputs to the vertex fitter", xbins=100, xmin=0, xmax=100),
defineHistogram('nBPhysObject', type='TH1F', path='EXPERT', title="number of fitted BPhysObjects", xbins=100, xmin=0, xmax=100),
defineHistogram('trkMassBeforeFit', type='TH1F', path='EXPERT', title="mass of track combinations BEFORE fit [GeV]", xbins=200, xmin=0, xmax=100),
defineHistogram('bphysChi2', type='TH1F', path='EXPERT', title="chi2 fit of N tracks; fit chi2 of N selected tracks", xbins=100, xmin=0, xmax=100),
defineHistogram('bphysFitMass', type='TH1F', path='EXPERT', title="fit mass of N tracks; fit mass of N selected tracks [GeV]", xbins=100, xmin=0, xmax=20),
defineHistogram('bphysMass', type='TH1F', path='EXPERT', title="mass of N tracks; mass of N selected tracks [GeV]", xbins=100, xmin=0, xmax=20),
defineHistogram('bphysCharge', type='TH1F', path='EXPERT', title="total charge of N tracks", xbins=20, xmin=-10, xmax=10),
defineHistogram('TIME_all', type='TH1F', path='EXPERT', title='execution time; [microseconds]', xbins=100, xmin=0, xmax=100),
]
class TrigMultiTrkHypoToolMonitoring(GenericMonitoringTool):
......
......@@ -8,111 +8,80 @@
**
** Description: multi-track hypothesis algorithm
**
** Author: H. Russell
** Author: Heather Russell
**
**************************************************************************/
#ifndef TRIG_TrigMultiTrkHypo_H
#define TRIG_TrigMultiTrkHypo_H
// standard stuff
#include <string>
// general athena stuff
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/IToolSvc.h"
#include "GaudiKernel/StatusCode.h"
#include <vector>
#include <utility>
#include "GaudiKernel/Property.h"
#include "xAODTracking/TrackParticleContainer.h"
#include "xAODMuon/MuonContainer.h"
#include "xAODTrigBphys/TrigBphysContainer.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "AthViews/View.h"
#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
#include "DecisionHandling/TrigCompositeUtils.h"
#include "TrigMultiTrkHypoTool.h"
#include "TrigBphysHelperUtilsTool.h"
#include "DecisionHandling/HypoBase.h"
#include "Constants.h"
#include "AthenaMonitoringKernel/Monitored.h"
#include "AthenaMonitoringKernel/GenericMonitoringTool.h"
#include "TrkVKalVrtFitter/TrkVKalVrtFitter.h"
#include "InDetConversionFinderTools/VertexPointEstimator.h"
#include "AthenaMonitoringKernel/Monitored.h"
#include "AthenaMonitoringKernel/GenericMonitoringTool.h"
class TrigMultiTrkHypo: public ::HypoBase {
enum { MaxNumberTools = 20 };
public:
TrigMultiTrkHypo(const std::string & name, ISvcLocator* pSvcLocator);
~TrigMultiTrkHypo();
virtual StatusCode initialize() override;
virtual StatusCode execute( const EventContext& context ) const override;
virtual StatusCode finalize() override;
protected:
//The vertexing tool is not reentrant so this algorithm cannot be used reentrantly
bool isReEntrant() const override { return false; }
private:
TrigMultiTrkHypo();
ToolHandleArray< TrigMultiTrkHypoTool > m_hypoTools {this, "HypoTools", {}, "Tools to perform selection"};
#include "TrigMultiTrkHypoTool.h"
bool passNTracks(int nObjMin,
const std::vector<float> & ptObjMin,
const std::vector<ElementLink<xAOD::TrackParticleContainer> > & inputTrkVec,
std::vector<ElementLink<xAOD::TrackParticleContainer> > & outputTrkVec,
float mindR) const;
SG::ReadHandleKey<xAOD::TrackParticleContainer> m_trackParticleContainerKey{ this,
"trackCollectionKey", // property name
"Tracks", // default value of StoreGate key
"input TrackParticle container name"};
class TrigMultiTrkHypo: public ::HypoBase {
public:
TrigMultiTrkHypo(const std::string& name, ISvcLocator* pSvcLocator);
TrigMultiTrkHypo() = delete;
SG::ReadHandleKey<xAOD::MuonContainer> m_muonContainerKey{ this,
"MuonCollectionKey", // property name
"CBCombinedMuon", // default value of StoreGate key
"input EF Muon container name"};
virtual StatusCode initialize() override;
virtual StatusCode execute(const EventContext& context) const override;
virtual StatusCode finalize() override;
SG::WriteHandleKey<xAOD::TrigBphysContainer> m_bphysObjContKey{ this,
"bphysCollectionKey", // property name
"TrigBphysContainer", // default value of StoreGate key
"Output TrigBphysContainer name"};
protected:
// the vertexing tool is not reentrant so this algorithm cannot be used reentrantly
bool isReEntrant() const override { return false; }
static bool sortTracks(ElementLink<xAOD::TrackParticleContainer> &l1, ElementLink<xAOD::TrackParticleContainer> &l2)
{
return (*l1)->pt() > (*l2)->pt();
}
private:
xAOD::TrigBphys* fit(const std::vector<ElementLink<xAOD::TrackParticleContainer>>& tracklist) const;
bool isIdenticalTracks(const xAOD::TrackParticle* lhs, const xAOD::TrackParticle* rhs) const;
bool isInMassRange(double mass) const;
ToolHandle<InDet::VertexPointEstimator> m_vertexPointEstimator{this, "VertexPointEstimator", "", "find starting point for the vertex fitter"};
ToolHandle<Trk::TrkVKalVrtFitter> m_vertexFitter{this, "VertexFitter", "", "VKalVrtFitter tool to fit tracks into the common vertex"};
std::unique_ptr<Trk::IVKalState> m_vertexFitterState;
Gaudi::Property<int> m_nTrk { this, "nTrk",2,"Number of tracks in the vertex"};
Gaudi::Property<int> m_nTrkQ { this, "nTrkCharge",-1,"sum of track charges"}; // if negative - no cut
Gaudi::Property<std::vector<double>> m_trkMasses {this, "trackMasses", {105.6583745,105.6583745}, "track masses for vertex reco (one per track!)"};
Gaudi::Property<std::vector<float>> m_ptTrkMin { this, "trkPtThresholds", {3650, 3650} ,"minimum track pTs (one per track, sorted descending!)"};
SG::ReadHandleKey<xAOD::TrackParticleContainer>
m_trackParticleContainerKey {this, "TrackCollectionKey", "Tracks", "input TrackParticle container name"};
Gaudi::Property<std::vector<float>> m_nTrkMassMin { this, "nTrackMassMin", {0},"list of mins for nTrk mass windows"}; // both min+max need to be defined
Gaudi::Property<std::vector<float>> m_nTrkMassMax { this, "nTrackMassMax", {100000},"list of maxes for nTrk mass windows"};
SG::ReadHandleKey<xAOD::MuonContainer>
m_muonContainerKey {this, "MuonCollectionKey", "CBCombinedMuon", "input EF Muon container name"};
Gaudi::Property<float> m_mindR { this, "overlapdR",0.01 ,"Minimum dR between tracks (overlap removal)"};
SG::WriteHandleKey<xAOD::TrigBphysContainer>
m_trigBphysContainerKey {this, "TrigBphysCollectionKey", "TrigBphysContainer", "output TrigBphysContainer name"};
Gaudi::Property<int> m_particleType { this, "particleType", 0, "Types of particles to use. 0 = tracks, 1 = EF Muons, 2 = tbd..."};
Gaudi::Property<unsigned int> m_nTrk {this, "nTracks", 2, "number of tracks in the vertex"};
Gaudi::Property<std::vector<double>> m_trkMass {this, "trackMasses", {105.6583745, 105.6583745}, "track masses for vertex reco (one per track)"};
Gaudi::Property<std::vector<float>> m_trkPt {this, "trkPtThresholds", {3650., 3650.} ,"minimum track pTs (one per track, sorted descending)"};
Gaudi::Property<std::vector<std::pair<double, double>>> m_massRange {this, "massRanges", { {0., 100000.} }, "mass ranges"};
Gaudi::Property<float> m_deltaR {this, "deltaR", 0.01, "minimum deltaR between same-sign tracks (overlap removal)"};
Gaudi::Property<std::string> m_trigLevelString { this, "trigLevelString", "", "Trigger Level to set for created TrigBphys objects."};
Gaudi::Property<std::string> m_trigLevelString {this, "trigLevel", "", "trigger Level to set for created TrigBphys objects"};
xAOD::TrigBphys::levelType m_trigLevel;
ToolHandle< GenericMonitoringTool > m_monTool { this, "MonTool", "", "Monitoring tool" };
ToolHandle<InDet::VertexPointEstimator> m_vertexPointEstimator {this, "VertexPointEstimator", "", "tool to find starting point for the vertex fitter"};
ToolHandle<Trk::TrkVKalVrtFitter> m_vertexFitter {this, "VertexFitter", "", "VKalVrtFitter tool to fit tracks into the common vertex"};
std::unique_ptr<Trk::IVKalState> m_vertexFitterState;
xAOD::TrigBphys::levelType m_trigLevel;
ToolHandleArray<TrigMultiTrkHypoTool> m_hypoTools {this, "HypoTools", {}, "tools to perform selection"};
ToolHandle<GenericMonitoringTool> m_monTool {this, "MonTool", "", "monitoring tool"};
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment