Commit 1a4311a2 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (TrigTrackJetFinderTool-00-00-15)

parent d212f321
################################################################################
# Package: TrigTrackJetFinderTool
################################################################################
# Declare the package name:
atlas_subdir( TrigTrackJetFinderTool )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
GaudiKernel
Reconstruction/Particle
Tracking/TrkEvent/TrkTrack
Trigger/TrigEvent/TrigInDetEvent )
# External dependencies:
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
# Component(s) in the package:
atlas_add_component( TrigTrackJetFinderTool
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel Particle TrkTrack TrigInDetEvent )
# Install files from the package:
atlas_install_headers( TrigTrackJetFinderTool )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// **************************************************
//
// NAME: ITrigTrackJetFinderTool.h
// PACKAGE: Trigger/TrigTools/TrigTrackJetFinderTool
//
// AUTHOR: Andrea Coccaro
// MAIL: Andrea.Coccaro@ge.infn.it
//
// **************************************************
#ifndef ITRIGTRACKJETFINDERTOOL_H
#define ITRIGTRACKJETFINDERTOOL_H
#include "GaudiKernel/IAlgTool.h"
class TrigInDetTrack;
namespace Rec { class TrackParticle; }
namespace Trk { class Track;}
static const InterfaceID IID_ITrigTrackJetFinderTool("ITrigTrackJetFinderTool", 1, 0);
class ITrigTrackJetFinderTool : virtual public IAlgTool {
public:
static const InterfaceID& interfaceID() {return IID_ITrigTrackJetFinderTool;}
virtual void setDefTrackSel(bool) = 0;
virtual void setExtTrackSel(bool) = 0;
virtual void inputPrimaryVertexZ(const float&) = 0;
virtual void addTrack(const TrigInDetTrack*&, unsigned int) = 0;
virtual void addTrack(const Rec::TrackParticle*&, unsigned int) = 0;
virtual void addTrack(const Trk::Track*&, unsigned int) = 0;
virtual void findJet(std::vector<int>&, float&, float&) = 0;
virtual void clear() = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// *********************************************************
//
// NAME: TrigTrackJetFinderTool.h
// PACKAGE: Trigger/TrigTools/TrigTrackJetFinderTool
//
// AUTHOR: Andrea Coccaro (Andrea.Coccaro@ge.infn.it)
// Andrew Lowe (Andrew.Lowe@cern.ch)
// Ariel Schwartzman (sch@slac.stanford.edu)
//
// *********************************************************
#ifndef TRIGTRACKJETFINDERTOOL_H
#define TRIGTRACKJETFINDERTOOL_H
#include <vector>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include "AthenaBaseComps/AthAlgTool.h"
#include "TrigTrackJetFinderTool/ITrigTrackJetFinderTool.h"
#include "TrigInDetEvent/TrigInDetTrack.h"
#include "Particle/TrackParticle.h"
#include "TrkTrack/Track.h"
class TrackAttributes {
public:
TrackAttributes(const TrigInDetTrack*& track, unsigned int id) {
const float pi = 3.14159265358979323846;
m_id = id;
m_pt = track->param()->pT();
m_phi = track->param()->phi0();
m_eta = track->param()->eta();
m_z0 = track->param()->z0();
m_d0 = track->param()->a0();
if(m_phi < -pi) m_phi += 2 * pi;
if(m_phi > pi) m_phi -= 2 * pi;
m_px = fabs(m_pt)*cos(m_phi);
m_py = fabs(m_pt)*sin(m_phi);
m_pz = fabs(m_pt)*sinh(m_eta);
};
TrackAttributes(const Rec::TrackParticle*& track, unsigned int id) {
const float pi = 3.14159265358979323846;
m_id = id;
m_pt = track->pt();
m_phi = track->phi();
m_eta = track->eta();
m_z0 = track->measuredPerigee()->parameters()[Trk::z0];
m_d0 = track->measuredPerigee()->parameters()[Trk::d0];
if(m_phi < -pi) m_phi += 2 * pi;
if(m_phi > pi) m_phi -= 2 * pi;
m_px = fabs(m_pt)*cos(m_phi);
m_py = fabs(m_pt)*sin(m_phi);
m_pz = fabs(m_pt)*sinh(m_eta);
};
TrackAttributes(const Trk::Track*& track, unsigned int id) {
const float pi = 3.14159265358979323846;
m_id = id;
m_pt = track->perigeeParameters()->pT();
m_phi = track->perigeeParameters()->parameters()[Trk::phi];
m_eta = track->perigeeParameters()->eta();
m_z0 = track->perigeeParameters()->parameters()[Trk::z0];
m_d0 = track->perigeeParameters()->parameters()[Trk::d0];
if(m_phi < -pi) m_phi += 2 * pi;
if(m_phi > pi) m_phi -= 2 * pi;
m_px = fabs(m_pt)*cos(m_phi);
m_py = fabs(m_pt)*sin(m_phi);
m_pz = fabs(m_pt)*sinh(m_eta);
};
~TrackAttributes() {};
int Id() const { return m_id; }
float Px() const { return m_px; }
float Py() const { return m_py; }
float Pz() const { return m_pz; }
float Pt() const { return m_pt; }
float Eta() const { return m_eta; }
float Phi() const { return m_phi; }
float Z() const { return m_z0; }
bool operator== (const TrackAttributes &other) const {
if(this->Phi() != other.Phi()) return false;
return true;
}
private:
unsigned int m_id;
float m_px;
float m_py;
float m_pz;
float m_pt;
float m_eta;
float m_phi;
float m_z0;
float m_d0;
};
//** ----------------------------------------------------------------------------------------------------------------- **//
class TrigTrackJetFinderTool: public AthAlgTool, virtual public ITrigTrackJetFinderTool {
public:
TrigTrackJetFinderTool(const std::string&, const std::string&, const IInterface*);
virtual ~TrigTrackJetFinderTool();
virtual StatusCode initialize();
virtual StatusCode finalize();
void setDefTrackSel(bool doTrackSel) { defTrackSel=doTrackSel; }
void setExtTrackSel(bool doTrackSel) { extTrackSel=doTrackSel; }
void inputPrimaryVertexZ(const float& zPV);
void addTrack(const TrigInDetTrack*&, unsigned int);
void addTrack(const Rec::TrackParticle*&, unsigned int);
void addTrack(const Trk::Track*&, unsigned int);
void findJet(std::vector<int>& tracks, float& eta, float& phi);
void clear();
private:
int outputLevel;
bool defTrackSel;
bool extTrackSel;
float m_trkSelChi2;
int m_trkSelBLayer;
int m_trkSelPixHits;
int m_trkSelSiHits;
float m_trkSelPt;
float phiCorr(float);
float deltaR(float& eta0, float& phi0, float& eta1, float& phi1);
float m_dr, m_dz, m_ptMin, m_ptJet, m_ptSeed, m_mult;
float m_zpv;
/** @brief Value of pi set in CTOR to the exact value in TMath.h to avoid including everything in the TMath namespace and multiple calls to TMath::Pi(). */
const float m_pi;
std::vector<TrackAttributes> m_attributesOfTracks;
};
#endif
package TrigTrackJetFinderTool
author Andrea Coccaro <Andrea.Coccaro@ge.infn.it>
# ============================================================================================
public
use AtlasPolicy AtlasPolicy-*
use AthenaBaseComps AthenaBaseComps-* Control
use GaudiInterface GaudiInterface-* External
use Particle Particle-* Reconstruction
use TrigInDetEvent TrigInDetEvent-* Trigger/TrigEvent
use TrkTrack TrkTrack-* Tracking/TrkEvent
# ============================================================================================
private
use AtlasROOT AtlasROOT-* External
# ============================================================================================
public
library TrigTrackJetFinderTool *.cxx components/*.cxx
apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// *********************************************************
//
// NAME.cxx
// PACKAGE: Trigger/TrigTools/TrigTrackJetFinderTool
//
// AUTHOR: Andrea Coccaro (Andrea.Coccaro@ge.infn.it)
// Andrew Lowe (Andrew.Lowe@cern.ch)
// Ariel Schwartzman (sch@slac.stanford.edu)
//
// *********************************************************
#include "TrigTrackJetFinderTool/TrigTrackJetFinderTool.h"
#include "TMath.h"
using namespace std;
using std::vector;
//** ----------------------------------------------------------------------------------------------------------------- **//
bool TrackAttributesSortPredicate(const TrackAttributes& lhs, const TrackAttributes& rhs) {
return fabs(lhs.Pt()) > fabs(rhs.Pt());
}
//** ----------------------------------------------------------------------------------------------------------------- **//
TrigTrackJetFinderTool::TrigTrackJetFinderTool(const std::string& t, const std::string& n, const IInterface* p) :
AthAlgTool(t,n,p),
m_pi(3.14159265358979323846)
{
declareInterface<ITrigTrackJetFinderTool>(this);
declareProperty("DeltaR", m_dr = 0.4);
declareProperty("DeltaZ", m_dz = 10.0);
declareProperty("PtMin", m_ptMin = 0.5);
declareProperty("PtJet", m_ptJet = 0.0);
declareProperty("PtSeed", m_ptSeed = 2.0);
declareProperty("Mult", m_mult = 1);
declareProperty("DefTrkSel", defTrackSel = true);
declareProperty("ExtTrkSel", extTrackSel = false);
}
//** ----------------------------------------------------------------------------------------------------------------- **//
TrigTrackJetFinderTool::~TrigTrackJetFinderTool() {}
//** ----------------------------------------------------------------------------------------------------------------- **//
StatusCode TrigTrackJetFinderTool::initialize() {
StatusCode sc = AlgTool::initialize();
msg(MSG::INFO) << "Initializing TrigTrackJetFinderTool" << endreq;
if (msgLvl(MSG::DEBUG)) {
msg(MSG::DEBUG) << "declareProperty review:" << endreq;
msg(MSG::DEBUG) << " cone size (R,Z) = " << m_dr << ", " << m_dz << endreq;
msg(MSG::DEBUG) << " minimum seed pT = " << m_ptSeed << endreq;
msg(MSG::DEBUG) << " minimum jet pT = " << m_ptJet << endreq;
msg(MSG::DEBUG) << " minimum track pT = " << m_ptMin << endreq;
msg(MSG::DEBUG) << " minimum multiplicity = " << m_mult << endreq;
}
return sc;
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::clear() {
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << "Clearing internal track classe" << endreq;
m_attributesOfTracks.clear();
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::addTrack(const TrigInDetTrack*& track, unsigned int i) {
bool selTrack=true;
if (defTrackSel) {
if (fabs(track->param()->pT()) < m_ptMin && (fabs(track->param()->z0() - m_zpv) >= m_dz)) {
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " not selected (pT && deltaZ cut)" << endreq;
selTrack=false;
}
}
if (extTrackSel) {
m_trkSelPt = 1000;
m_trkSelSiHits = 4;
m_trkSelBLayer = 1;
m_trkSelChi2 = 0.001;
if (fabs(track->param()->pT()) < m_trkSelPt) {
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " not selected (pT cut)" << endreq; selTrack=false;
}
if (track->siSpacePoints()) {
if ((*track->siSpacePoints())[0]->layer()) {
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " not selected (missing b-layer hit)" << endreq; selTrack=false;
}
if ((int)track->siSpacePoints()->size() < m_trkSelSiHits) {
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " not selected (too few silicon hits)" << endreq; selTrack=false;
}
if (TMath::Prob(track->chi2(),(int)track->siSpacePoints()->size()*3-5) <= m_trkSelChi2) {
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " not selected (chi2 cut)" << endreq; selTrack=false;
}
}
}
if (!selTrack) return;
if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track " << i+1 << " selected" << endreq;
TrackAttributes p(track, i);
m_attributesOfTracks.push_back(p);
std::sort(m_attributesOfTracks.begin(), m_attributesOfTracks.end(), TrackAttributesSortPredicate);
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::addTrack(const Rec::TrackParticle*& track, unsigned int i) {
TrackAttributes p(track, i);
float z0 = track->measuredPerigee()->parameters()[Trk::z0];
float pT = track->pt();
if (fabs(pT) >= m_ptMin && (fabs(z0 - m_zpv) < m_dz)) {
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Adding selected track " << i+1 << " for finding the track-jet direction" << endreq;
m_attributesOfTracks.push_back(p);
} else {
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Selected track " << i+1 << " not added for finding the track-jet direction since pT "
<< pT << " is not >= " << m_ptMin << " and/or Delta(z) is not < " << m_dz << endreq;
}
std::sort(m_attributesOfTracks.begin(), m_attributesOfTracks.end(), TrackAttributesSortPredicate);
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::addTrack(const Trk::Track*& track, unsigned int i) {
TrackAttributes p(track, i);
float z0 = track->perigeeParameters()->parameters()[Trk::z0];
float pT = track->perigeeParameters()->pT();
if (fabs(pT) >= m_ptMin && (fabs(z0 - m_zpv) < m_dz)) {
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Adding selected track " << i+1 << " for finding the track-jet direction" << endreq;
m_attributesOfTracks.push_back(p);
} else {
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Selected track " << i+1 << " not added for finding the track-jet direction since pT "
<< pT << " is not >= " << m_ptMin << " and/or Delta(z) is not < " << m_dz << endreq;
}
std::sort(m_attributesOfTracks.begin(), m_attributesOfTracks.end(), TrackAttributesSortPredicate);
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::inputPrimaryVertexZ(const float& zPV) {
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << "Z primary vertex " << zPV << endreq;
m_zpv = zPV;
}
//** ----------------------------------------------------------------------------------------------------------------- **//
void TrigTrackJetFinderTool::findJet(std::vector<int>& tracks, float& jetEta, float& jetPhi) {
tracks.clear();
float jetPx = 0, jetPy = 0, jetPz = 0;
float jetP = 0;
jetEta = 0, jetPhi = 0;
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Number of input tracks = " << m_attributesOfTracks.size() << endreq;
if(m_attributesOfTracks.size() < m_mult) {
jetEta = -99; jetPhi = -99;
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Seed multiplicity is below threshold " << m_mult << ". Not computing track-jet direction." << endreq;
return;
}
TrackAttributes seed = m_attributesOfTracks[0];
if(fabs(seed.Pt())<m_ptSeed) {
jetEta = -99; jetPhi = -99;
if (msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) << "Highest-pT seed is below threshold " << m_ptSeed << ". Not computing track-jet direction." << endreq;
return;
}
tracks.push_back(seed.Id());
jetPx += seed.Px();
jetPy += seed.Py();
jetPz += seed.Pz();
jetP = sqrt(jetPx*jetPx+jetPy*jetPy+jetPz*jetPz);
jetEta = 0.5*log( (jetP+jetPz)/(jetP-jetPz) );
jetPhi = phiCorr(atan2(jetPy,jetPx));
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << " jetP = " << jetP << " jetEta = " << jetEta << " jetPhi = " << jetPhi << endreq;
for(unsigned int j=1; j < m_attributesOfTracks.size(); j++) {
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << "Considering seed " << m_attributesOfTracks[j].Id()+1 << endreq;
float pEta = m_attributesOfTracks[j].Eta();
float pPhi = m_attributesOfTracks[j].Phi();
float dr = deltaR(jetEta,jetPhi, pEta,pPhi);
if(dr<m_dr) {
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << " deltaR matching between seed and jet direction satisfied (" << dr << ">" << m_dr << ")" << endreq;
jetPx += m_attributesOfTracks[j].Px();