Skip to content
Snippets Groups Projects
Commit 80e2aa81 authored by Will Leight's avatar Will Leight
Browse files

Migrate MuidCaloEnergyMeas and MuidTrackIsolation to use DataHandles.

Both tools now retrieve the collection they need using a ReadHandle.  No other changes are made to the code.


Former-commit-id: ef6e5784
parent 02de24cf
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "MuidInterfaces/IMuidCaloEnergyMeas.h"
#include "StoreGate/ReadHandleKey.h"
#include "CaloEvent/CaloCellContainer.h"
//<<<<<< CLASS DECLARATIONS >>>>>>
......@@ -95,7 +97,7 @@ private:
const TileID* m_tileID;
const LArEM_ID* m_emID;
const LArHEC_ID* m_hecID;
std::string m_cellContainerLocation; // Cell container's name
SG::ReadHandleKey<CaloCellContainer> m_cellContainerLocation{this,"CellContainerLocation","AllCalo","calo cell container location"};
double m_measurementConeTile;
double m_measurementConeLArHEC;
......
......@@ -14,7 +14,6 @@
//<<<<<< INCLUDES >>>>>>
#include "CLHEP/Geometry/Vector3D.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloEvent/CaloCell.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloIdentifier/TileID.h"
......@@ -44,7 +43,6 @@ MuidCaloEnergyMeas::MuidCaloEnergyMeas (const std::string& type,
m_tileID (0),
m_emID (0),
m_hecID (0),
m_cellContainerLocation (""),
m_sigmasAboveNoise (4.),
m_sigmasAboveNoiseCore (1.5),
m_useCaloNoiseTool (true),
......@@ -58,7 +56,6 @@ MuidCaloEnergyMeas::MuidCaloEnergyMeas (const std::string& type,
declareInterface<IMuidCaloEnergyMeas>(this);
declareProperty ("CaloNoiseTool", m_caloNoiseTool);
declareProperty ("CaloParamTool", m_caloParamTool);
declareProperty ("CellContainerLocation", m_cellContainerLocation);
declareProperty ("NoiseThresInSigmas", m_sigmasAboveNoise);
declareProperty ("NoiseThresInSigmasCore", m_sigmasAboveNoiseCore);
declareProperty ("UseCaloNoiseTool", m_useCaloNoiseTool);
......@@ -136,6 +133,8 @@ MuidCaloEnergyMeas::initialize()
ATH_MSG_INFO( "Retrieved tool " << m_caloParamTool );
}
ATH_CHECK(m_cellContainerLocation.initialize());
return StatusCode::SUCCESS;
}
......@@ -160,33 +159,28 @@ MuidCaloEnergyMeas::energyMeasurement (double etaEM,
double etaHad,
double phiHad) const
{
const CaloCellContainer* cellContainer = 0;
if (evtStore()->contains<CaloCellContainer>(m_cellContainerLocation))
{
if (StatusCode::FAILURE == evtStore()->retrieve(cellContainer,m_cellContainerLocation))
{
ATH_MSG_WARNING( "failed to retrieve CaloCellContainer: " << m_cellContainerLocation );
return 0;
}
}
else
{
ATH_MSG_WARNING( "failed to retrieve CaloCellContainer: " << m_cellContainerLocation );
return 0;
}
SG::ReadHandle<CaloCellContainer> cellContainer(m_cellContainerLocation);
if(!cellContainer.isPresent()){
ATH_MSG_DEBUG("No calo cell container "<<m_cellContainerLocation.key()<<", energy measurement is 0");
return 0;
}
if(!cellContainer.isValid()){
ATH_MSG_WARNING("Calo cell container "<<m_cellContainerLocation.key()<<" not valid!");
return 0;
}
// set measured tile energy, measured sampling fraction and isolation energy into CaloMeas
CaloMeas* caloMeas = new CaloMeas();
energyInCalo(*caloMeas,cellContainer,etaHad,phiHad,0);
isolationEnergy(*caloMeas,cellContainer,etaHad,phiHad,0);
energyInCalo(*caloMeas,cellContainer.cptr(),etaHad,phiHad,0);
isolationEnergy(*caloMeas,cellContainer.cptr(),etaHad,phiHad,0);
// similar for LArHEC
energyInCalo(*caloMeas,cellContainer,etaHad,phiHad,1);
isolationEnergy(*caloMeas,cellContainer,etaHad,phiHad,1);
energyInCalo(*caloMeas,cellContainer.cptr(),etaHad,phiHad,1);
isolationEnergy(*caloMeas,cellContainer.cptr(),etaHad,phiHad,1);
// and for the em calo
energyInCalo(*caloMeas,cellContainer,etaEM,phiEM,2);
isolationEnergy(*caloMeas,cellContainer,etaEM,phiEM,2);
energyInCalo(*caloMeas,cellContainer.cptr(),etaEM,phiEM,2);
isolationEnergy(*caloMeas,cellContainer.cptr(),etaEM,phiEM,2);
if (msgLvl(MSG::DEBUG))
{
......
......@@ -21,6 +21,7 @@
#include "GaudiKernel/ToolHandle.h"
#include "MuidInterfaces/IMuidTrackIsolation.h"
#include "TrkTrack/TrackCollection.h"
#include "StoreGate/ReadHandleKey.h"
//<<<<<< CLASS DECLARATIONS >>>>>>
......@@ -71,7 +72,7 @@ private:
const Trk::Surface* m_caloCylinder;
const Trk::Surface* m_caloForwardDisc;
double m_etaSafetyFactor;
std::string m_inDetTracksLocation;
SG::ReadHandleKey<TrackCollection> m_inDetTracksLocation{this,"InDetTracksLocation","Tracks","ID tracks"};
// FIXME: mutable
mutable ToolHandle<Trk::IIntersector> m_intersector;
mutable double m_maxP;
......
......@@ -35,7 +35,6 @@ MuidTrackIsolation::MuidTrackIsolation (const std::string&type,
const IInterface*parent)
: AthAlgTool (type, name, parent),
m_etaSafetyFactor (0.1),
m_inDetTracksLocation ("Tracks"),
m_intersector ("Trk::RungeKuttaIntersector/RungeKuttaIntersector"),
m_minPt (1.0*Gaudi::Units::GeV),
m_trackCone (0.2),
......@@ -44,7 +43,6 @@ MuidTrackIsolation::MuidTrackIsolation (const std::string&type,
declareInterface<IMuidTrackIsolation>(this);
declareProperty("MinPt", m_minPt);
declareProperty("RungeKuttaIntersector", m_intersector);
declareProperty("InDetTracksLocation", m_inDetTracksLocation);
declareProperty("TrackCone", m_trackCone);
declareProperty("TrackExtrapolation", m_trackExtrapolation);
}
......@@ -90,6 +88,8 @@ MuidTrackIsolation::initialize()
*transform *= Amg::Translation3D(backwardDiscPosition);
m_caloBackwardDisc = new Trk::DiscSurface(transform, 0., radius);
ATH_CHECK(m_inDetTracksLocation.initialize());
return StatusCode::SUCCESS;
}
......@@ -131,27 +131,27 @@ MuidTrackIsolation::trackIsolation(double eta, double phi) const
std::pair<int,double> isolation = std::make_pair(0,0.);
// retrieve track collection
const TrackCollection* inDetTracks = 0;
if (! evtStore()->contains<TrackCollection>(m_inDetTracksLocation))
SG::ReadHandle<TrackCollection> inDetTracks(m_inDetTracksLocation);
if (! inDetTracks.isPresent())
{
ATH_MSG_DEBUG( " no ID Track container at location " << m_inDetTracksLocation );
ATH_MSG_DEBUG( " no ID Track container at location " << m_inDetTracksLocation.key() );
return isolation;
}
if (StatusCode::SUCCESS != evtStore()->retrieve(inDetTracks,m_inDetTracksLocation))
if (!inDetTracks.isValid())
{
ATH_MSG_WARNING( " Could not retrieve ID Track container from " << m_inDetTracksLocation );
ATH_MSG_WARNING( " ID Track container " << m_inDetTracksLocation.key()<<" not valid!" );
return isolation;
}
// evaluate isolation according to configuration
if (m_trackExtrapolation)
{
isolation = trackExtrapolated(inDetTracks,eta,phi);
isolation = trackExtrapolated(inDetTracks.cptr(),eta,phi);
}
else
{
isolation = trackVertex(inDetTracks,eta,phi);
isolation = trackVertex(inDetTracks.cptr(),eta,phi);
}
// debug result
......
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