Commit 0a63cb77 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (InDetCaloClusterROIBuilder-01-00-01)

parent 93d8d70b
################################################################################
# Package: InDetCaloClusterROIBuilder
################################################################################
# Declare the package name:
atlas_subdir( InDetCaloClusterROIBuilder )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PRIVATE
Calorimeter/CaloDetDescr
Calorimeter/CaloTrackingGeometry
Control/AthenaBaseComps
Event/xAOD/xAODCaloEvent
Event/xAOD/xAODEgamma
GaudiKernel
InnerDetector/InDetRecTools/InDetRecToolInterfaces
Tracking/TrkDetDescr/TrkSurfaces
Tracking/TrkEvent/TrkCaloClusterROI
Tracking/TrkEvent/TrkEventPrimitives )
# tag ROOTMathLibs was not recognized in automatic conversion in cmt2cmake
# Component(s) in the package:
atlas_add_component( InDetCaloClusterROIBuilder
src/*.cxx
src/components/*.cxx
LINK_LIBRARIES CaloDetDescrLib AthenaBaseComps xAODCaloEvent xAODEgamma GaudiKernel InDetRecToolInterfaces TrkSurfaces TrkCaloClusterROI TrkEventPrimitives )
# Install files from the package:
atlas_install_headers( InDetCaloClusterROIBuilder )
package InDetCaloClusterROIBuilder
author A. Morley <amorley@cern.ch>
use AtlasPolicy AtlasPolicy-*
private
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
use InDetRecToolInterfaces InDetRecToolInterfaces-* InnerDetector/InDetRecTools
use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent
use TrkSurfaces TrkSurfaces-* Tracking/TrkDetDescr
use TrkCaloClusterROI TrkCaloClusterROI-* Tracking/TrkEvent
use CaloDetDescr CaloDetDescr-* Calorimeter
use CaloTrackingGeometry CaloTrackingGeometry-* Calorimeter
use xAODEgamma xAODEgamma-* Event/xAOD
use xAODCaloEvent xAODCaloEvent-* Event/xAOD
apply_tag ROOTMathLibs
library InDetCaloClusterROIBuilder *.cxx components/*.cxx
apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloClusterROI_Builder.h"
#include "CaloTrackingGeometry/ICaloSurfaceBuilder.h"
#include "CaloDetDescr/CaloDepthTool.h"
#include "xAODCaloEvent/CaloCluster.h"
#include "xAODEgamma/EgammaxAODHelpers.h"
//#include "TrkEventPrimitives/GlobalPosition.h"
#include "TrkEventPrimitives/LocalParameters.h"
#include "TrkSurfaces/Surface.h"
#include "TrkCaloClusterROI/CaloClusterROI.h"
InDet::CaloClusterROI_Builder::CaloClusterROI_Builder(const std::string& t,
const std::string& n,
const IInterface* p )
: AthAlgTool(t,n,p),
m_calosurf("CaloSurfaceBuilder")
{
declareInterface<ICaloClusterROI_Builder>(this);
declareProperty( "CaloSurfaceBuilder", m_calosurf );
}
//--------------------------------------------------------------------------------------------
InDet::CaloClusterROI_Builder::~CaloClusterROI_Builder() {}
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
StatusCode InDet::CaloClusterROI_Builder::initialize() {
//--------------------------------------------------------------------------------------------
ATH_MSG_INFO("Initializing CaloClusterROI_Builder");
// Retrieve the updator CaloSurfaceBuilder
if ( m_calosurf.retrieve().isFailure() ){
ATH_MSG_FATAL ( "Unable to retrieve the instance " << m_calosurf.name() << "... Exiting!" );
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
//--------------------------------------------------------------------------------------------
StatusCode InDet::CaloClusterROI_Builder::finalize(){ return StatusCode::SUCCESS; }
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
Trk::CaloClusterROI* InDet::CaloClusterROI_Builder::buildClusterROI( const xAOD::CaloCluster* cluster ) const
//--------------------------------------------------------------------------------------------
{
ATH_MSG_DEBUG("Building Trk::CaloCluster_OnTrack");
if(!cluster) return 0;
const Trk::Surface* surface = getCaloSurface( cluster );
if(!surface) return 0;
const Trk::LocalParameters* lp = getClusterLocalParameters( cluster, surface );
if (!lp){
delete surface;
return 0;
}
double energy = cluster->e();
double widthPhi = 0.1;
double widthEta = 0.1;
Trk::CaloClusterROI* ccROI = new Trk::CaloClusterROI( lp, *surface, energy, widthPhi, widthEta );
delete surface;
if(ccROI) {
ATH_MSG_DEBUG("Successful build of Trk::CaloClusterROI");
}
return ccROI;
}
//--------------------------------------------------------------------------------------------
const Trk::Surface* InDet::CaloClusterROI_Builder::getCaloSurface( const xAOD::CaloCluster* cluster ) const
//--------------------------------------------------------------------------------------------
{
const Trk::Surface* destinationSurface = 0;
// Determine if we want to extrapolate to the barrel or endcap. If in the crack choose the
// detector with largest amount of energy in the second sampling layer
if ( xAOD::EgammaHelpers::isBarrel( cluster ) )
{
destinationSurface = m_calosurf->CreateUserSurface (CaloCell_ID::EMB2, 0. , cluster->eta() );
} else{
destinationSurface = m_calosurf->CreateUserSurface (CaloCell_ID::EME2, 0. , cluster->eta() );
}
return destinationSurface;
}
//--------------------------------------------------------------------------------------------
const Trk::LocalParameters* InDet::CaloClusterROI_Builder::getClusterLocalParameters( const xAOD::CaloCluster* cluster,
const Trk::Surface* surf) const
//--------------------------------------------------------------------------------------------
{
Amg::Vector3D surfRefPoint = surf->globalReferencePoint();
//std::cout << "REFPOINT " << "[r,phi,z] = [ " << surfRefPoint.perp() << ", " << surfRefPoint.phi() << ", " << surfRefPoint.z() << " ]" <<std::endl;
double eta = cluster->eta();
double theta = 2*atan(exp(-eta)); // -log(tan(theta/2));
double tantheta = tan(theta);
double phi = cluster->phi();
Trk::LocalParameters* newLocalParameters(0);
if ( xAOD::EgammaHelpers::isBarrel( cluster ) ){
//Two corindate in a cyclinder are
//Trk::locRPhi = 0 (ie phi)
//Trk::locZ = 1(ie z)
double r = surfRefPoint.perp() ;
double z = tantheta == 0 ? 0. : r/tantheta;
Trk::DefinedParameter locRPhi( r * phi , Trk::locRPhi ) ;
Trk::DefinedParameter locZ ( z , Trk::locZ ) ;
std::vector<Trk::DefinedParameter> defPar ;
defPar.push_back( locRPhi ) ;
defPar.push_back( locZ ) ;
newLocalParameters = new Trk::LocalParameters( defPar ) ;
} else{
//Local paramters of a disk are
//Trk::locR = 0
//Trk::locPhi = 1
double z = surfRefPoint.z();
double r = z*tantheta;
Trk::DefinedParameter locR ( r , Trk::locR ) ;
Trk::DefinedParameter locPhi( phi , Trk::locPhi ) ;
std::vector<Trk::DefinedParameter> defPar ;
defPar.push_back( locR ) ;
defPar.push_back( locPhi ) ;
newLocalParameters = new Trk::LocalParameters( defPar ) ;
}
return newLocalParameters;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOCLUSTERROI_BUILDER_H
#define CALOCLUSTERROI_BUILDER_H
#include "InDetRecToolInterfaces/ICaloClusterROI_Builder.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "xAODCaloEvent/CaloClusterFwd.h"
namespace Trk{
class CaloClusterROI;
class Surface;
class LocalParameters;
}
class ICaloSurfaceBuilder;
namespace InDet{
class CaloClusterROI_Builder : public AthAlgTool, virtual public ICaloClusterROI_Builder
{
public:
/** Constructor with AlgTool parameters */
CaloClusterROI_Builder(const std::string&, const std::string&, const IInterface*);
CaloClusterROI_Builder();
~CaloClusterROI_Builder();
// standard Athena methods
virtual StatusCode initialize();
virtual StatusCode finalize();
virtual Trk::CaloClusterROI* buildClusterROI( const xAOD::CaloCluster* cl ) const;
private:
const Trk::Surface* getCaloSurface( const xAOD::CaloCluster* cluster ) const;
const Trk::LocalParameters* getClusterLocalParameters( const xAOD::CaloCluster* cluster,
const Trk::Surface* surf) const;
bool findPosition(const xAOD::CaloCluster* cluster) const;
/** @brief Tool to build calorimeter layer surfaces */
ToolHandle<ICaloSurfaceBuilder> m_calosurf;
};
}
#endif //CALOCLUSTERROI_BUIDLER_H
#include "../CaloClusterROI_Builder.h"
#include "GaudiKernel/DeclareFactoryEntries.h"
using namespace InDet;
DECLARE_TOOL_FACTORY (CaloClusterROI_Builder)
DECLARE_FACTORY_ENTRIES(InDetCaloClusterROIBuilder) {
DECLARE_TOOL ( CaloClusterROI_Builder )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(InDetCaloClusterROIBuilder)
Supports Markdown
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