Commit e75a1257 authored by Nicholas Styles's avatar Nicholas Styles Committed by Graeme Stewart
Browse files

fix for compiliation in mig5 (InDetConversionFinder-01-00-00)

parent b9cb1b62
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
ConversionFinder.h - Description
-------------------
begin : 10-11-2005
authors : Tatjana Lenz
email : tatjana.lenz@cern.ch
changes :
***************************************************************************/
#ifndef INDETCONVERSIONFINDER_CONVERSIONFINDER_H
#define INDETCONVERSIONFINDER_CONVERSIONFINDER_H
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "VxVertex/VxContainer.h"
namespace InDet{
class IVertexFinder;
class ConversionFinder : public AthAlgorithm {
public:
ConversionFinder(const std::string &name, ISvcLocator *pSvcLocator);
~ConversionFinder();
StatusCode initialize();
StatusCode finalize();
StatusCode execute();
void resetStatistics(); //<! Initialize the statistics vectors
void analyzeResults(VxContainer*); //<! Analyze the conversion candidates
protected:
std::string m_tracksName; //!< Name of track container in StoreGate
std::string m_InDetConversionOutputName; //!< Name of output container to store results
ToolHandle< IVertexFinder > m_VertexFinderTool; //<! Vertex finder tool
/** Statistics */
long m_events_processed; //!< Number of events processed
long m_Gamma_stored; //!< Number of conversion vertices stored
long m_Double_Conversions; //!< Number of two-track conversions
long m_Single_Conversions; //!< Number of single-track conversions
long m_SiSi_Conversions; //!< Number of Si-Si track conversions
long m_SiTrt_Conversions; //!< Number of Si-TRT track conversions
long m_TrtTrt_Conversions; //!< Number of TRT-TRT track conversions
long m_Si_Conversions; //!< Number of Si single-track conversions
long m_Trt_Conversions; //!< Number of TRT single-track conversions
};
}
#endif // INDETCONVERSIONFINDER_CONVERSIONFINDER_H
package InDetConversionFinder
author Tatjana Lenz <Tatjana.Lenz@cern.ch>
private
# for the new track class
use TrkTrack TrkTrack-* Tracking/TrkEvent
use InDetRecToolInterfaces InDetRecToolInterfaces-* InnerDetector/InDetRecTools
use TrkParticleBase TrkParticleBase-* Tracking/TrkEvent
use TrkTrackSummary TrkTrackSummary-* Tracking/TrkEvent
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
# dependencies on other vertexing packages
use VxVertex VxVertex-* Tracking/TrkEvent
library InDetConversionFinder *.cxx components/*.cxx
apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
\mainpage InDetConversionFinder
\section introduction Introduction:
InDetConversionFinder is a package which contains algorithm to reconstruct conversions. The only job now is to call a vertex finder tool - InDetConversionFinderTool. (see InnerDetector/InDetRecTools/InDetConversionFinderTools)
All units are in mm and MeV.
\section howitworks How it works:
The algorithm InDetConversion.cxx is a prototype usecase of the InDetConversionFinderTools package. This tool reconstructs conversions in the InnerDetector. The performance of the conversion reconstruction depends stronlgy on the BackTracking performace and the choosen cuts.
\section packagecontent Package Contents:
InDetConversionFinder contains the following files/classes:
-ConversionFinder.cxx
\section jobOptions The jobOptions file:
Remark: the algorithm is configured via automatic generated python scripts (genConf) <br>
All values shown are <b>default</b> values, i.e. if nothing is specified in the jobOptions
the algorithm will use this default value.
<ul>
<li>Specifiy the name of the track input container:<br>
<b>'TracksName' : 'Tracks' </b><br>
<li>Specify the name of the output container:<br>
<b>'InDetConversionOutputName' : 'InDetConversion' </b></li>
<li>Specify the name of IVertexFinder:<br>
<b>''VertexFinderTool' : PublicToolHandle('InDet::InDetConversionFinderTools') </b></li>
</ul>
\section used_packagesInDetConversionFinder used packages
@htmlinclude used_packages.html
\section requirements Requirements
@include requirements
\namespace Vtx
A namespace for all vertexing packages and related stuff.
*/
\ No newline at end of file
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
ConversionFinder.cxx - Description
-------------------
begin : 10-11-2005
authors : Tatjana Lenz
email : tatjana.lenz@cern.ch
changes :
***************************************************************************/
#include "InDetConversionFinder/ConversionFinder.h"
#include "TrkTrack/TrackCollection.h"
#include "InDetRecToolInterfaces/IVertexFinder.h"
#include "VxVertex/VxTrackAtVertex.h"
#include "TrkTrackSummary/TrackSummary.h"
#include "GaudiKernel/MsgStream.h"
#include "TrkParticleBase/LinkToTrackParticleBase.h"
#include "TrkParticleBase/TrackParticleBase.h"
namespace InDet
{
ConversionFinder::ConversionFinder(const std::string& name, ISvcLocator* pSvcLocator)
: AthAlgorithm(name, pSvcLocator),
m_tracksName("Tracks"),
m_InDetConversionOutputName("InDetConversion"),
m_VertexFinderTool("InDet::InDetConversionFinderTools")
{
/* Retrieve StoreGate container and tool names from job options */
declareProperty("TracksName",m_tracksName);
declareProperty("InDetConversionOutputName", m_InDetConversionOutputName);
declareProperty("VertexFinderTool",m_VertexFinderTool);
}
ConversionFinder::~ConversionFinder(){}
StatusCode ConversionFinder::initialize()
{
/* Get the VertexFinderTool */
if ( m_VertexFinderTool.retrieve().isFailure() ) {
msg(MSG::FATAL) << "Failed to retrieve tool " << m_VertexFinderTool << endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << "Retrieved tool " << m_VertexFinderTool << endreq;
}
resetStatistics();
msg(MSG::INFO) << "Initialization successful" << endreq;
return StatusCode::SUCCESS;
}
StatusCode ConversionFinder::finalize()
{
if ( msg().level() == MSG::INFO ){
msg(MSG::INFO) <<"Summary: "<<endreq;
std::cout<< "------------------------------------------------------------"<<std::endl;
std::cout<< "Processed: " << m_events_processed<< " events " <<std::endl;
std::cout<< "Stored : " << m_Gamma_stored<<" Conversions " <<std::endl;
std::cout<< "------------------------------------------------------------"<<std::endl;
std::cout<< "| Double Conversions Si-Si Si-TRT TRT-TRT |"
<<std::endl;
std::cout<<"| "<<
std::setw(10)<<m_Double_Conversions<<
std::setw(18)<<m_SiSi_Conversions<<
std::setw(11)<<m_SiTrt_Conversions<<
std::setw(13)<<m_TrtTrt_Conversions<<" |"<<
std::endl;
std::cout<< "------------------------------------------------------------" <<std::endl;
std::cout<< "| Single Conversions Si TRT |"
<<std::endl;
std::cout<<"| "<<
std::setw(10)<<m_Single_Conversions<<
std::setw(25)<<m_Si_Conversions<<
std::setw(19)<<m_Trt_Conversions<<" |"<<
std::endl;
std::cout<< "------------------------------------------------------------" <<std::endl;
}
return StatusCode::SUCCESS;
}
void ConversionFinder::resetStatistics() {
m_events_processed = 0;
m_Gamma_stored = 0;
m_Double_Conversions = 0;
m_Single_Conversions = 0;
m_SiSi_Conversions = 0;
m_SiTrt_Conversions = 0;
m_TrtTrt_Conversions = 0;
m_Si_Conversions = 0;
m_Trt_Conversions = 0;
}
StatusCode ConversionFinder::execute()
{
m_events_processed++;
VxContainer* InDetConversionContainer ( 0 );
//---- First try if m_tracksName is a TrackCollection -----------------//
if ( evtStore()->contains<TrackCollection> ( m_tracksName ) )
{
const DataVector<Trk::Track> * trk_coll(0);
if( evtStore()->retrieve( trk_coll, m_tracksName ).isFailure() ){
msg(MSG::DEBUG) << "Could not find Trk::TrackCollection " << m_tracksName << " in StoreGate." << endreq;
return StatusCode::SUCCESS;
}
// Find conversions
InDetConversionContainer = m_VertexFinderTool->findVertex ( trk_coll );
}
//---- Second try if m_tracksName is a TrackParticleBaseCollection ----//
else if ( evtStore()->contains<Trk::TrackParticleBaseCollection> ( m_tracksName ) )
{
const Trk::TrackParticleBaseCollection *trackParticleBaseCollection(0);
if ( evtStore()->retrieve ( trackParticleBaseCollection, m_tracksName ).isFailure() )
{
msg(MSG::DEBUG) << "Could not find Trk::TrackParticleBaseCollection " << m_tracksName << " in StoreGate." << endreq;
return StatusCode::SUCCESS;
}
InDetConversionContainer = m_VertexFinderTool->findVertex ( trackParticleBaseCollection );
}
else
{
msg(MSG::DEBUG) << "Neither a TrackCollection nor a TrackParticleBaseCollection with key " << m_tracksName << " exists in StoreGate." << endreq;
return StatusCode::SUCCESS;
}
//Analyze the results, update counters
if (InDetConversionContainer) {
m_Gamma_stored += InDetConversionContainer->size();
analyzeResults(InDetConversionContainer);
}
// Write to StoreGate
msg(MSG::DEBUG) << " Recording conversion collection with key: " << m_InDetConversionOutputName << endreq;
if( evtStore()->record(InDetConversionContainer, m_InDetConversionOutputName, false).isFailure() ){
msg(MSG::ERROR) << "Could not register conversion." << endreq;
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
void ConversionFinder::analyzeResults(VxContainer* convContainer) {
VxContainer::const_iterator fz,fze = convContainer->end();
for ( fz = convContainer->begin(); fz!=fze; ++fz){
if ((*fz)->vxTrackAtVertex()) {
int numTracksPerVertex = (*fz)->vxTrackAtVertex()->size();
if (numTracksPerVertex == 2) m_Double_Conversions++;
else m_Single_Conversions++;
bool isTrt1 = false; bool isSi1 = false; bool isTrt2 = false; bool isSi2 = false;
std::vector<Trk::VxTrackAtVertex*> * trkAtVtx = (*fz)->vxTrackAtVertex();
for (unsigned int i = 0; i < trkAtVtx->size() ; ++i) {
const Trk::ITrackLink * trLink =(*(trkAtVtx))[i]->trackOrParticleLink();
const Trk::TrackParticleBase* tempTrk(0);
if(0!= trLink){
const Trk::LinkToTrackParticleBase * linkToTrackPB = dynamic_cast<const Trk::LinkToTrackParticleBase *>(trLink);
if(0!= linkToTrackPB){
if(linkToTrackPB->isValid()) tempTrk = linkToTrackPB->cachedElement();
if(!tempTrk) continue;
const Trk::TrackSummary* summary = tempTrk->trackSummary();
if(!summary) continue;
int ncl = summary->get(Trk::numberOfPixelHits) + summary->get(Trk::numberOfSCTHits);
int ntrt = summary->get(Trk::numberOfTRTHits);
if(i==0) {
if(ncl>0) isSi1 = true; if(ncl==0 && ntrt>0) isTrt1 = true;
}
if(i==1) {
if(ncl>0) isSi2 = true; if(ncl==0 && ntrt>0) isTrt2 = true;
}
}//end of dynamic_cast check
}//end of ITrackLink existance check
}
//Decide on the type of track combination in vertex
if(numTracksPerVertex==2){
if (isSi1 && isSi2) m_SiSi_Conversions++;
else if(isTrt1 && isTrt2) m_TrtTrt_Conversions++;
else m_SiTrt_Conversions++;
}
if(numTracksPerVertex==1){
if(isSi1) m_Si_Conversions++;
if(isTrt1) m_Trt_Conversions++;
}
}
}
}
}
#include "InDetConversionFinder/ConversionFinder.h"
#include "GaudiKernel/DeclareFactoryEntries.h"
using namespace InDet;
DECLARE_ALGORITHM_FACTORY( ConversionFinder )
DECLARE_FACTORY_ENTRIES(InDetConversionFinder)
{
DECLARE_ALGORITHM( ConversionFinder )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES( InDetConversionFinder )
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