Commit 66b78eaa authored by Igor Gavrilenko's avatar Igor Gavrilenko Committed by Graeme Stewart
Browse files

add output information (TRT_TrackSegmentsFinder-01-00-01)

parent cb48b784
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRT_TrackSegmentsFinder_H
#define TRT_TrackSegmentsFinder_H
#include <string>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "InDetRecToolInterfaces/ITRT_TrackSegmentsMaker.h"
#include "InDetRecToolInterfaces/ITRT_DetElementsRoadMaker.h"
namespace InDet {
// Class-algorithm for track finding in TRT
//
class TRT_TrackSegmentsFinder : public AthAlgorithm
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
///////////////////////////////////////////////////////////////////
// Standard Algotithm methods
///////////////////////////////////////////////////////////////////
TRT_TrackSegmentsFinder(const std::string &name, ISvcLocator *pSvcLocator);
virtual ~TRT_TrackSegmentsFinder() {};
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
///////////////////////////////////////////////////////////////////
// Print internal tool parameters and status
///////////////////////////////////////////////////////////////////
MsgStream& dump (MsgStream& out) const;
std::ostream& dump (std::ostream& out) const;
protected:
///////////////////////////////////////////////////////////////////
// Protected data
///////////////////////////////////////////////////////////////////
bool m_useCaloSeeds ;
int m_outputlevel ; // Print level for debug
int m_nprint ; // Kind of print
int m_nsegments ; // Number segments
int m_nsegmentsTotal ; // Number segments
int m_minNumberDCs ; // Min. number of DriftCircles
std::string m_segmentslocation ; // Name of segments location
std::string m_inputClusterContainerName; // Calo clusters collection name
ToolHandle<ITRT_TrackSegmentsMaker> m_segmentsMakerTool; // TRT segments maker
ToolHandle<ITRT_DetElementsRoadMaker> m_roadtool ; // TRT road maker tool
///////////////////////////////////////////////////////////////////
// Protected methods
///////////////////////////////////////////////////////////////////
MsgStream& dumptools(MsgStream& out) const;
MsgStream& dumpevent(MsgStream& out) const;
};
MsgStream& operator << (MsgStream& ,const TRT_TrackSegmentsFinder&);
std::ostream& operator << (std::ostream&,const TRT_TrackSegmentsFinder&);
}
#endif // TRT_TrackSegmentsFinder_H
package TRT_TrackSegmentsFinder
author Igor Gavrilenko <Igor.Gavrilenko@cern.ch>
private
use TrkSegment TrkSegment-* Tracking/TrkEvent
use TrkCaloClusterROI TrkCaloClusterROI-* Tracking/TrkEvent
use InDetReadoutGeometry InDetReadoutGeometry-* InnerDetector/InDetDetDescr
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
use InDetRecToolInterfaces InDetRecToolInterfaces-* InnerDetector/InDetRecTools
library TRT_TrackSegmentsFinder *.cxx components/*.cxx
apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@mainpage TRT_TrackSegmentsFinder
@author Markus.Elsing@cern.ch, Igor.Gavrilenko@cern.ch
@section TRT_TrackSegmentsFinderIntro Introduction
This algorithm is devoted for tracks finding in TRT without extra infomation (Stande alone TRT reconstruction).
Output of this algorithm is Trk::SegmentCollection.
This algorithm uses standard ITRT_TrackSegmentsMaker tool.
@section TRT_TrackSegmentsFinderReq Requirements file
@include requirements
*/
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "TRT_TrackSegmentsFinder/TRT_TrackSegmentsFinder.h"
#include "TrkSegment/SegmentCollection.h"
#include "TrkCaloClusterROI/CaloClusterROI.h"
#include "TrkCaloClusterROI/CaloClusterROI_Collection.h"
#include "InDetReadoutGeometry/TRT_BaseElement.h"
///////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////
InDet::TRT_TrackSegmentsFinder::TRT_TrackSegmentsFinder
(const std::string& name,ISvcLocator* pSvcLocator) :
AthAlgorithm(name, pSvcLocator) ,
m_segmentsMakerTool("InDet::TRT_TrackSegmentsMaker_ATLxk"),
m_roadtool ("InDet::TRT_DetElementsRoadMaker_xk")
{
// TRT_TrackSegmentsFinder steering parameters
//
m_segmentslocation = "TRTSegments" ;
m_useCaloSeeds = false ;
m_inputClusterContainerName = "InDetCaloClusterROIs" ;
m_minNumberDCs = 9 ;
declareProperty("SegmentsMakerTool",m_segmentsMakerTool);
declareProperty("SegmentsLocation" ,m_segmentslocation );
declareProperty("useCaloSeeds" ,m_useCaloSeeds );
declareProperty("RoadTool" ,m_roadtool );
declareProperty("InputClusterContainerName",m_inputClusterContainerName);
declareProperty("MinNumberDriftCircles" ,m_minNumberDCs);
}
///////////////////////////////////////////////////////////////////
// Initialisation
///////////////////////////////////////////////////////////////////
StatusCode InDet::TRT_TrackSegmentsFinder::initialize()
{
StatusCode sc;
// get tTools servise
//
IToolSvc* toolSvc;
if ((sc=service("ToolSvc", toolSvc)).isFailure()) {
msg(MSG::FATAL)<<"Toll service not found !"<<endreq; return sc;
}
// Get tool for drift circles seeds maker
//
if(m_segmentsMakerTool.retrieve().isFailure()) {
msg(MSG::FATAL) << "Failed to retrieve tool " << m_segmentsMakerTool<< endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << "Retrieved tool " << m_segmentsMakerTool << endreq;
}
if( m_useCaloSeeds) {
// Get detector elements road maker tool
//
if(m_roadtool.retrieve().isFailure()) {
msg(MSG::FATAL)<<"Failed to retrieve tool "<< m_roadtool <<endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << "Retrieved tool " << m_roadtool << endreq;
}
}
// Get output print level
//
m_outputlevel = msg().level()-MSG::DEBUG;
if(m_outputlevel<=0) {
m_nprint=0; msg(MSG::DEBUG)<<(*this)<<endreq;
}
m_nsegmentsTotal = 0;
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Execute
///////////////////////////////////////////////////////////////////
StatusCode InDet::TRT_TrackSegmentsFinder::execute()
{
Trk::SegmentCollection* foundSegments = new Trk::SegmentCollection;
Trk::Segment* segment = 0;
m_nsegments = 0;
if(!m_useCaloSeeds) {
m_segmentsMakerTool->newEvent();
m_segmentsMakerTool->find ();
// Loop through all segments and reconsrtucted segments collection preparation
//
while((segment = m_segmentsMakerTool->next())) {
++m_nsegments; foundSegments->push_back(segment);
}
}
else {
Amg::Vector3D PSV(0.,0.,0.); Trk::PerigeeSurface PS(PSV);
const Trk::TrackParameters* par = 0;
const CaloClusterROI_Collection* calo = 0;
std::vector<IdentifierHash> vTR;
StatusCode sc = evtStore()->retrieve(calo,m_inputClusterContainerName);
if(sc == StatusCode::SUCCESS && calo) {
CaloClusterROI_Collection::const_iterator c = calo->begin(), ce = calo->end();
for(; c!=ce; ++c) {
double x = (*c)->globalPosition().x();
double y = (*c)->globalPosition().y();
double z = (*c)->globalPosition().z();
par = PS.createTrackParameters(0.,0.,atan2(y,x), atan2(1.,z/sqrt(x*x+y*y)),0.,0);
// TRT detector elements road builder
//
std::list<const InDetDD::TRT_BaseElement*> DE;
m_roadtool->detElementsRoad(*par,Trk::alongMomentum,DE); delete par;
if(int(DE.size()) < m_minNumberDCs) continue;
vTR.clear();
std::list<const InDetDD::TRT_BaseElement*>::iterator d,de=DE.end();
for(d=DE.begin(); d!=de; ++d) {vTR.push_back((*d)->identifyHash());}
m_segmentsMakerTool->newRegion(vTR);
m_segmentsMakerTool->find();
// Loop through all segments and reconsrtucted segments collection preparation
//
while((segment = m_segmentsMakerTool->next())) {
++m_nsegments; foundSegments->push_back(segment);
}
}
}
}
m_segmentsMakerTool->endEvent();
m_nsegmentsTotal+=m_nsegments;
// Save reconstructed tracks
//
StatusCode s = evtStore()->record(foundSegments,m_segmentslocation,false);
if (s.isFailure() ) {
msg(MSG::ERROR)<<"Could not save TRT segments" <<endreq;
}
// Print common event information
//
if(m_outputlevel<=0) {
m_nprint=1; msg(MSG::DEBUG)<<(*this)<<endreq;
}
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Finalize
///////////////////////////////////////////////////////////////////
StatusCode InDet::TRT_TrackSegmentsFinder::finalize()
{
m_nprint=2; msg(MSG::INFO)<<(*this)<<endreq;
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Overload of << operator MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& InDet::operator <<
(MsgStream& sl,const InDet::TRT_TrackSegmentsFinder& se)
{
return se.dump(sl);
}
///////////////////////////////////////////////////////////////////
// Overload of << operator std::ostream
///////////////////////////////////////////////////////////////////
std::ostream& InDet::operator <<
(std::ostream& sl,const InDet::TRT_TrackSegmentsFinder& se)
{
return se.dump(sl);
}
///////////////////////////////////////////////////////////////////
// Dumps relevant information into the MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& InDet::TRT_TrackSegmentsFinder::dump( MsgStream& out ) const
{
out<<std::endl;
if(m_nprint) return dumpevent(out); return dumptools(out);
}
///////////////////////////////////////////////////////////////////
// Dumps conditions information into the MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& InDet::TRT_TrackSegmentsFinder::dumptools( MsgStream& out ) const
{
int n = 65-m_segmentsMakerTool.type().size();
std::string s1; for(int i=0; i<n; ++i) s1.append(" "); s1.append("|");
n = 65-m_segmentslocation.size();
std::string s2; for(int i=0; i<n; ++i) s2.append(" "); s2.append("|");
out<<"|----------------------------------------------------------------"
<<"----------------------------------------------------|"
<<std::endl;
out<<"| Tool for TRT track segments finding | "<<m_segmentsMakerTool.type()<<s1
<<std::endl;
out<<"| Location of output segments | "<<m_segmentslocation<<s2
<<std::endl;
out<<"|----------------------------------------------------------------"
<<"----------------------------------------------------|"
<<std::endl;
return out;
}
///////////////////////////////////////////////////////////////////
// Dumps event information into the ostream
///////////////////////////////////////////////////////////////////
MsgStream& InDet::TRT_TrackSegmentsFinder::dumpevent( MsgStream& out ) const
{
int n = m_nsegments; if(m_nprint > 1) n = m_nsegmentsTotal;
out<<"|-------------------------------------------------------------------";
out<<"-----------------------------|"
<<std::endl;
if(m_useCaloSeeds) {
out<<"| TRT track segments found with calo seeds |"
<<std::setw(7)<<n
<<" |"
<<std::endl;
}
else {
out<<"| TRT track segments found without calo seeds |"
<<std::setw(7)<<n
<<" |"
<<std::endl;
}
out<<"|-------------------------------------------------------------------";
out<<"-----------------------------|"
<<std::endl;
return out;
}
///////////////////////////////////////////////////////////////////
// Dumps relevant information into the ostream
///////////////////////////////////////////////////////////////////
std::ostream& InDet::TRT_TrackSegmentsFinder::dump( std::ostream& out ) const
{
return out;
}
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "TRT_TrackSegmentsFinder/TRT_TrackSegmentsFinder.h"
using namespace InDet;
DECLARE_ALGORITHM_FACTORY( TRT_TrackSegmentsFinder )
DECLARE_FACTORY_ENTRIES( TRT_TrackSegmentsFinder )
{
DECLARE_ALGORITHM( TRT_TrackSegmentsFinder )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES( TRT_TrackSegmentsFinder)
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