32 declareInterface<ITrackIsolationTool>(
this);
49 return StatusCode::FAILURE;
70 return StatusCode::SUCCESS;
81 for (
const auto*
const vtx : *vtxC ) {
93 if( !tp ) tp =
muon->trackParticle(xAOD::Muon::TrackParticleType::Primary);
97 ATH_MSG_WARNING(
" No TrackParticle found for muon with pT: " <<
muon->pt() * 1.e-3 <<
"[GeV], eta: "<<
muon->eta()<<
" phi: "<<
98 muon->phi()<<
" q: "<<
muon->charge()<<
" primaryAuthor: "<<
muon->author()<<
" allAuthors: "<<
muon->allAuthors());
115 const std::vector<Iso::IsolationType>& isoTypes,
118 const std::set<const TrackParticle*>* exclusionSet,
132 ATH_MSG_DEBUG(
"No vertex provided, is required. Use the ID-chosen pvx, z = " << vertex->z());
142 ATH_MSG_WARNING(
"A particle of type " << particle.type() <<
" with strange pT : " << tp->
pt()*1
e-3 <<
" GeV");
145 for(
auto isoType : isoTypes ){
152 input.coneSizesSquared.push_back(conesize*conesize);
155 for(
size_t i=1; i<input.coneSizesSquared.size(); i++){
156 if(input.coneSizesSquared[i]>input.coneSizesSquared[i-1])
ATH_MSG_ERROR(
"Isolation Cone should be in decreasing order. "<< i <<
"th variable is " <<
Iso::toCString(isoTypes[i]) <<
" is larger than the one before it: " <<
Iso::toCString(isoTypes[i-1]));
159 std::sort(input.coneSizesSquared.begin(),input.coneSizesSquared.end(),[](
float i,
float j) { return i>j; });
161 initresult(result, corrbitset, input.coneSizesSquared.size());
163 input.maxRadius = sqrt(input.coneSizesSquared[0]);
165 bool success =
false;
167 if( indetTrackParticles ) success =
simpleIsolation(input,result,indetTrackParticles);
175 msg(MSG::DEBUG) <<
"Calculated track isolation: ";
176 for(
unsigned int i = 0; i< result.ptcones.size();++i ){
177 msg(MSG::DEBUG) <<
" coneSizeSquared " << std::setw(3) << input.coneSizesSquared[i] <<
" value " << result.ptcones[i];
189 std::vector<const TrackParticle*> tps;
191 if( !
m_tracksInConeTool->particlesInCone(input.particle->eta(),input.particle->phi(),input.maxRadius,tps) )
return false;
193 if( !getparticlesInCone(input.particle->eta(),input.particle->phi(),input.maxRadius,tps) )
return false;
196 for(
const auto& tp : tps ) {
200 ATH_MSG_DEBUG(
"Encountered a track isolation input with invalid vertex while requiring TTVA. Rejecting, please check your inputs!");
205 ATH_MSG_DEBUG(
"Accept track " << tp <<
" pt = " << tp->pt() <<
" z+vz = " << tp->z0()+tp->vz() <<
" eta = " << tp->eta() <<
" phi = " << tp->phi());
207 add( input,*tp, result );
218 if( !indetTrackParticles ) {
221 ATH_MSG_ERROR(
"Could not open a TrackParticle container with key "
225 indetTrackParticles = tpH.
ptr();
229 if( !indetTrackParticles )
return false;
232 for(
const auto *
const tp : *indetTrackParticles ) {
239 add( input, *tp, result );
255 if(input.corrections.trackbitset.test(
static_cast<unsigned int>(
Iso::coreTrackPtr))){
256 if(input.particle == &tp2 ||
257 (input.exclusionSet && input.exclusionSet->count(&tp2)) ||
259 ATH_MSG_DEBUG(
"track pointer " << &tp2 <<
", track pt = " << tp2.
pt() <<
", input pt = " << input.particle->pt()) ;
266 float deta = input.particle->eta()-tp2.
eta();
267 if( fabs(deta) > input.maxRadius )
return;
271 if( fabs(dphi) > input.maxRadius )
return;
274 float dr2 = deta*deta + dphi*dphi;
284 ATH_MSG_DEBUG(
"No valid time for the track while doing track->time()" );
298 for(
unsigned int k=0;k<input.coneSizesSquared.size();++k ){
299 if( dr2 >= input.coneSizesSquared[k] )
return;
300 result.ptcones[k] += tp2.
pt();
301 if( dr2 <= input.ptvarconeRadiusSquared ){
302 result.ptvarcones_10GeVDivPt[k] += tp2.
pt();
309 unsigned int typesize) {
311 result.corrlist = corrlist;
312 result.coreCorrections.clear();
313 result.ptcones.resize(typesize,0.);
314 result.ptvarcones_10GeVDivPt.resize(typesize,0.);
316 std::vector<float>
vec;
317 vec.resize(typesize,0.);
325 bool TrackIsolationTool::getparticlesInCone(
float eta,
float phi,
float dr, std::vector< const TrackParticle*>& output )
const {
329 if(!trks.isValid()) {
330 ATH_MSG_ERROR(
"Could not find TrackParticle container with key "
338 for(
auto trk: *trks){
339 float dEta = fabs(
eta-trk->eta());
340 if(dEta>dr)
continue;
341 float dPhi = fabs(
phi-trk->phi());
342 while(dPhi>
M_PI){dPhi = 2.*
M_PI -dPhi;}
343 if(dPhi>dr)
continue;
344 ATH_MSG_DEBUG(
"ID trk pt=" << trk->pt()*0.001 <<
" eta=" << trk->eta() <<
", phi=" << trk->phi() <<
" dEta=" << dEta <<
", dPhi=" << dPhi <<
", dR2 = " << dEta*dEta+dPhi*dPhi);
345 if(dr2>(dEta*dEta+dPhi*dPhi))
output.push_back(trk);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
std::vector< size_t > vec
bool msgLvl(const MSG::Level lvl) const
bool empty() const noexcept
Returns true if the collection is empty.
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Class providing the definition of the 4-vector interface.
virtual double pt() const =0
The transverse momentum ( ) of the particle.
float timeResolution() const
Returns the time resolution.
float time() const
Returns the time.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
uint8_t hasValidTime() const
Returns whether or not the track has a valid time.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
@ TrackParticle
The object is a charged track particle.
@ Muon
The object is a muon.
@ Electron
The object is an electron.
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
IsolationFlavour isolationFlavour(IsolationType type)
convert Isolation Type into Isolation Flavour
IsolationFlavour
Enumeration for different ways of calculating isolation in xAOD files.
@ numIsolationTrackCorrections
unknown
@ coreTrackPtr
tracks pointer
@ coreTrackCone
tracks in cone
static const char * toCString(IsolationConeSize conesize)
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Electron_v1 Electron
Definition of the current "egamma version".