Commit 81b17a2a authored by Roland Jansky's avatar Roland Jansky Committed by Graeme Stewart
Browse files

branch with small fix to make InDetRecExample?-01-25-01-branch work...

branch with small fix to make InDetRecExample?-01-25-01-branch work (InDetPrepRawDataFormation-01-08-28-00)
parent 8c709059
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file PixelClusterization.h
* (c) ATLAS Detector software
* @author D.Calvet, N.Nesvadba, T.Lari
* (modified s.roe, Dec 2008)
**/
#ifndef INDETRIOMAKER_PIXELCLUSTERIZATION_H
#define INDETRIOMAKER_PIXELCLUSTERIZATION_H
//STL
#include <string>
//Gaudi
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/IIncidentListener.h"
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
//InDet
//can't fwd declare this, needed for typedef to Pixel_RDO_Container
#include "InDetPrepRawData/PixelClusterContainer.h"
#include "InDetRawData/InDetRawDataCollection.h"
//
// Fwd declarations
class ISvcLocator;
class StatusCode;
class Incident;
class PixelRDORawData;
class PixelID;
namespace InDetDD{
class SiDetectorManager;
}
namespace InDet {
class IPixelClusteringTool;
class PixelGangedAmbiguitiesFinder;
}
namespace InDet {
/**
* Top Algorithm to clusterize the pixel RDOs
* (InDetRawDataCollection<PixelRDORawData> -> RecInputCollection)
* The clustering algorithm is actually a private Tool in the
* SiClusterizationTool package
**/
class PixelClusterization : public AthAlgorithm,
public IIncidentListener {
public:
typedef InDetRawDataCollection<PixelRDORawData> COLLECTION;
typedef InDetDD::SiDetectorManager SiDetectorManager;
/// Constructor with parameters:
PixelClusterization(const std::string &name,ISvcLocator *pSvcLocator);
//@name Usual algorithm methods
//@{
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
//@}
/// Incident listener method re-declared
virtual void handle( const Incident& incident );
private:
/** @name Disallow default instantiation, copy, assignment */
//@{
PixelClusterization();
PixelClusterization(const PixelClusterization&);
PixelClusterization &operator=(const PixelClusterization&);
//@}
ToolHandle< IPixelClusteringTool > m_clusteringTool;
/// class to find out which clusters shares ganged pixels
ToolHandle< PixelGangedAmbiguitiesFinder > m_gangedAmbiguitiesFinder;
std::string m_dataObjectName; //!< RDO container name in StoreGate
std::string m_elementsObjectName; //!< element collection name in StoreGate
std::string m_managerName; //!< detector manager name in StoreGate
std::string m_clustersName;
int m_page; //!< page number for hash function
const PixelID* m_idHelper;
PixelClusterContainer* m_clusterContainer;
const SiDetectorManager* m_manager;
};
}//end of ns
#endif // INDETRIOMAKER_PIXELCLUSTERIZATION_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/** @file SCT_Clusterization
* Header file for the SCT_Clusterization class (an Algorithm).
* @author Paul Bell, Tommaso Lari, Shaun Roe, Carl Gwilliam
* @date 08 July 2008
*/
#ifndef INDETPREPRAWDATAFORMATION_SCT_CLUSTERIZATION_H
#define INDETPREPRAWDATAFORMATION_SCT_CLUSTERIZATION_H
//STL
#include <string>
#include <map>
#include <set>
//Gaudi
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/IIncidentListener.h"
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
//InDet includes
//Stored by value, cannot be fwd declared
#include "Identifier/IdentifierHash.h"
//template parameter, so should not be possible to just fwd declare
#include "Identifier/Identifier.h"
//Next contains a typedef so cannot be fwd declared
#include "InDetPrepRawData/SCT_ClusterContainer.h"
//tool/service handle template parameters
class SCT_ID;
class SCT_ChannelStatusAlg;
class SiDetectorManager;
class ISvcLocator;
class StatusCode;
class Incident;
class ISCT_FlaggedConditionSvc;
class IInDetConditionsSvc;
namespace InDetDD{
class SiDetectorManager;
}
namespace InDet {
class ISCT_ClusteringTool;
/**
* @class SCT_Clusterization
* @brief Form clusters from SCT Raw Data Objects
* The class loops over an RDO grouping strips and creating collections of clusters, subsequently recorded in StoreGate
* Uses SCT_ConditionsServices to determine which strips to include.
*/
class SCT_Clusterization : public AthAlgorithm,
public IIncidentListener {
public:
/// Constructor with parameters:
SCT_Clusterization(const std::string &name,ISvcLocator *pSvcLocator);
/** @name Usual algorithm methods */
//@{
///Retrieve the tools used and initialize variables
virtual StatusCode initialize();
///Form clusters and record them in StoreGate (detector store)
virtual StatusCode execute();
///Clean up and release the collection containers
virtual StatusCode finalize();
//@}
/// Incident listener method re-declared
virtual void handle( const Incident& incident );
private:
/** @name Disallow default instantiation, copy, assignment */
//@{
SCT_Clusterization();
SCT_Clusterization(const SCT_Clusterization&);
SCT_Clusterization &operator=(const SCT_Clusterization&);
//@}
ToolHandle< ISCT_ClusteringTool > m_clusteringTool; //!< Clustering algorithm
std::string m_dataObjectName; //!< RDO container name in StoreGate
std::string m_managerName; //!< Detector manager name in StoreGate
std::string m_clustersName;
int m_page; //!< Page number for hash function
const SCT_ID* m_idHelper;
typedef std::map<Identifier, int> IdMap_t;
IdMap_t m_status;
IdentifierHash m_maxKey;
SCT_ClusterContainer* m_clusterContainer;
bool m_selectPixels;
bool m_selectSCTs;
const InDetDD::SiDetectorManager* m_manager;
unsigned int m_maxRDOs;
ServiceHandle<IInDetConditionsSvc> m_pSummarySvc;
ServiceHandle<ISCT_FlaggedConditionSvc> m_flaggedConditionSvc;
bool m_checkBadModules;
std::set<IdentifierHash> m_flaggedModules;
unsigned int m_maxTotalOccupancyPercent;
};
}
#endif // INDETRIOMAKER_SCT_CLUSTERIZATION_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file TRT_RIOMaker.h
* Header file for class TRT_RIO_Maker
* (c) ATLAS Detector software
* @author I.Gavrilenko
**/
#ifndef TRT_RIO_Maker_H
#define TRT_RIO_Maker_H
//STL
#include <string>
//Gaudi
#include "GaudiKernel/ToolHandle.h"
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
//InDet
// no forward declare (typedef?)
#include "InDetPrepRawData/TRT_DriftCircleContainer.h"
//fwd declarations
class StatusCode;
class ISvcLocator;
namespace InDet{
class ITRT_DriftCircleTool;
}
namespace InDet{
/** TRT_DriftCircleContainer production algorithm
* Top Algorithm for InDetRawDataContainer<TRT_RDORawData> conversion
* to TRT_DriftCircleContainer
**/
class TRT_RIO_Maker : public AthAlgorithm {
public:
///constructor
TRT_RIO_Maker(const std::string &name, ISvcLocator *pSvcLocator);
///no-op destructor
virtual ~TRT_RIO_Maker() ;
/** @name Usual algorithm methods */
//@{
StatusCode initialize () ;
StatusCode execute () ;
StatusCode finalize () ;
//@}
private:
std::string m_trt_rdo_location ;
std::string m_trt_rio_location ;
std::string m_trt_mgr_location ;
ToolHandle< ITRT_DriftCircleTool > m_driftcircle_tool ;
InDet::TRT_DriftCircleContainer* p_riocontainer ;
int m_mode_rio_production;
bool m_trtBadChannels;
};
}//end of namespace
#endif // TRT_RIO_Maker_H
Package: InnerDetector/InDetRecAlgs/PrepRawDataFormation
responsible: Tommaso Lari (Tommaso.Lari@cern.ch)
content: Silicon Clustering algorithms. Uses the algorithm tools
of SiClusterizationTool to cluster pixel and strips.
Inputs: Silicon RDO, Geometry
Outputs: cluster collection
Dependencies: Control/StoreGate
DetectorDescription/AtlasDetDescr
DetectorDescription/Identifier
External/GaudiInterface
InnerDetector/InDetConditions/SCT_ConditionsAlgs
InnerDetector/InDetRawEvent/InDetRawData
InnerDetector/InDetDetDescr/InDetCabling
InnerDetector/InDetDetDescr/InDetIdentifier
InnerDetector/InDetDetDescr/InDetReadoutGeometry
InnerDetector/InDetRecEvent/InDetPrepRawData
InnerDetector/InDetRecTools/SiClusterizationTool
InnerDetector/InDetRecTools/TRT_DriftCircleTool
Tracking/TrkDetDescr/TrkSurfaces
JobOptions: none
# Silicon Trackers Clusterization Framework package
# Classes defining the framework for the Pixel and SCT clustering algorithms
package InDetPrepRawDataFormation
author Tommaso Lari <Tommaso.Lari@cern.ch>
use AtlasPolicy AtlasPolicy-*
use AthenaBaseComps AthenaBaseComps-* Control
use GaudiInterface GaudiInterface-* External
use InDetPrepRawData InDetPrepRawData-* InnerDetector/InDetRecEvent
use InDetRawData InDetRawData-* InnerDetector/InDetRawEvent
use Identifier Identifier-* DetectorDescription
private
use StoreGate StoreGate-* Control
use AtlasDetDescr AtlasDetDescr-* DetectorDescription
use SiClusterizationTool SiClusterizationTool-* InnerDetector/InDetRecTools
use InDetIdentifier InDetIdentifier-* InnerDetector/InDetDetDescr
use InDetReadoutGeometry InDetReadoutGeometry-* InnerDetector/InDetDetDescr
use TRT_DriftCircleTool TRT_DriftCircleTool-* InnerDetector/InDetRecTools
use SCT_ConditionsServices SCT_ConditionsServices-* InnerDetector/InDetConditions
use InDetConditionsSummaryService InDetConditionsSummaryService-* InnerDetector/InDetConditions
public
library InDetPrepRawDataFormation *.cxx components/*.cxx
apply_pattern component_library
#apply_pattern dual_use_library files="*.cxx"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@mainpage InDetPrepRawDataFormation Package
@author Tommaso.Lari@cern.ch
@section InDetPrepRawDataFormationIntro Introduction
This package manages the creation of InDetPrepRawData objects
for the Inner Detector.
@section InDetPrepRawDataFormationOverview Overview
There are three classes, all of them Algorithms:
PixelClusterization
-------------------
For each module, retrieves the RDO collection, and calls an
algorithm tool of SiClusterizationTool (default is MergedPixelTool,
can be changed by job option) which clusters togheter neighbouring
pixels and creates a cluster collection (actually, an
InDetPrepRawDataCollection)
- SCT_Clusterization
For each module, retrieves the RDO collection, and calls an algorithm tool of SiClusterizationTool which clusters together adjacent
strips and creates a cluster collection (actually, an InDetPrepRawDataCollection).
Previous versions referenced SCT_ChannelStatusAlg, vestigial code from combined test beam 2004. This was removed July 2007, pending
introduction of the use of SCT_ConditionsAlgTools.
TRT_RIO_Maker
-------------
@ref used_InDetPrepRawDataFormation
@ref requirements_InDetPrepRawDataFormation
*/
/**
@page used_InDetPrepRawDataFormation Used Packages
@htmlinclude used_packages.html
*/
/**
@page requirements_InDetPrepRawDataFormation requirements
@include requirements
*/
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file PixelClusterization.h
* Implementation for PixelClusterization.
* (modified s.roe, 18.12.2008)
**/
// Silicon trackers includes
#include "InDetRawData/PixelRDO_Container.h"
#include "InDetPrepRawDataFormation/PixelClusterization.h"
#include "InDetPrepRawData/SiClusterContainer.h"
#include "InDetRawData/PixelRDORawData.h"
#include "InDetReadoutGeometry/PixelDetectorManager.h"
#include "Identifier/Identifier.h"
#include "AtlasDetDescr/AtlasDetectorID.h"
#include "InDetIdentifier/PixelID.h"
#include "InDetReadoutGeometry/SiDetectorManager.h"
#include "InDetPrepRawData/PixelClusterCollection.h"
// TES includes
#include "StoreGate/StoreClearedIncident.h"
#include "SiClusterizationTool/IPixelClusteringTool.h"
#include "SiClusterizationTool/PixelGangedAmbiguitiesFinder.h"
// Gaudi includes
#include "GaudiKernel/PropertyMgr.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include "StoreGate/DataHandle.h"
namespace InDet{
using namespace InDet;
// Constructor with parameters:
PixelClusterization::PixelClusterization(const std::string &name, ISvcLocator *pSvcLocator) :
AthAlgorithm(name,pSvcLocator),
m_clusteringTool("InDet::MergedPixelsTool"),
m_gangedAmbiguitiesFinder("InDet::PixelGangedAmbiguitiesFinder"),
m_dataObjectName("PixelRDOs"), // RDO container
m_managerName("Pixel"),
m_clustersName("PixelClusters"),
m_page(0),
m_idHelper(0){
// Get parameter values from jobOptions file
declareProperty("DataObjectName",m_dataObjectName);
declareProperty("DetectorManagerName",m_managerName);
declareProperty("clusteringTool", m_clusteringTool);
declareProperty("gangedAmbiguitiesFinder", m_gangedAmbiguitiesFinder);
declareProperty("ClustersName",m_clustersName);
declareProperty("PageNumber",m_page);
// error strategy <-- this is now in the MergedPixelTool
//
// 0 : broad errors (cluster width/sqrt(12) )
// as in old clustering code (release 6 and 7)
// 1 : narrow errors (pixel pitch/sqrt(12.) )
// DEFAULT - should be more accurate,
// and still conservative
// 2 : parameterization as a function of eta & cluster size
// same as in atrecon (fortran code)
// declareProperty("ErrorStrategy",m_errorStrategy); <-- this is now in the MergedPixelTool
// position strategy
//
// 0 : arithmetic mean of pixel position
// 1 : simple charge interpolation
// declareProperty("PositionStrategy",m_positionStrategy); <-- this is now in the MergedPixelTool
}
//-----------------------------------------------------------------------------
// Initialize method:
StatusCode PixelClusterization::initialize(){
msg(MSG::INFO) << "PixelClusterization::initialize()" << endreq;
// get the InDet::MergedPixelsTool
if ( m_clusteringTool.retrieve().isFailure() ) {
msg(MSG:: FATAL) << m_clusteringTool.propertyName() << ": Failed to retrieve tool " << m_clusteringTool.type() << endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << m_clusteringTool.propertyName() << ": Retrieved tool " << m_clusteringTool.type() << endreq;
}
// get the InDet::PixelGangedAmbiguitiesFinder
if ( m_gangedAmbiguitiesFinder.retrieve().isFailure() ) {
msg(MSG:: FATAL) << m_gangedAmbiguitiesFinder.propertyName() << ": Failed to retrieve tool " << m_gangedAmbiguitiesFinder.type() << endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << m_gangedAmbiguitiesFinder.propertyName() << ": Retrieved tool " << m_gangedAmbiguitiesFinder.type() << endreq;
}
StatusCode sc =detStore()->retrieve(m_manager, m_managerName);
if (sc.isFailure()){
msg(MSG:: FATAL) << "Cannot retrieve the Pixel detector manager "
<< m_managerName << endreq;
return StatusCode::FAILURE;
}
msg(MSG:: DEBUG) << "Pixel detector manager retrieved" << endreq;
// Get the Pixel helper
if (detStore()->retrieve(m_idHelper,"PixelID").isFailure())
return (msg(MSG:: FATAL) << "Cannot retrieve ID helper!" << endreq), StatusCode::FAILURE;
// declare the container:
m_clusterContainer = new PixelClusterContainer(m_idHelper->wafer_hash_max());
m_clusterContainer->addRef();
// Register incident handler
ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
if ( !incSvc.retrieve().isSuccess() ) {
msg(MSG:: WARNING) << "Unable to retrieve the IncidentSvc" << endreq;
} else {
incSvc->addListener(this,"StoreCleared");
}
msg(MSG:: DEBUG) << "Initialize done !" << endreq;
return StatusCode::SUCCESS;
}
void PixelClusterization::handle(const Incident& incident){
if (incident.type() == "StoreCleared") {
if (const StoreClearedIncident* inc = dynamic_cast<const StoreClearedIncident*> (&incident)){
if (inc->store() == &*evtStore()) m_clusterContainer->cleanup();
}
}
}
//----------------------------------------------------------------------------
// Execute method:
StatusCode PixelClusterization::execute() {
msg(MSG:: DEBUG) << "PixelClusterization::execute()" << endreq;
m_clusterContainer->cleanup();
// register the IdentifiableContainer into StoreGate
StatusCode sc = evtStore()->record(m_clusterContainer,m_clustersName);
if (sc.isFailure()){
msg(MSG:: FATAL) << "Container " << m_clustersName<< "could not be recorded in StoreGate !"<< endreq;
return StatusCode::FAILURE;
}else{
if (msgLvl(MSG::DEBUG)) msg() << "Container '" << m_clustersName<< "' recorded in StoreGate" << endreq;
}
// symlink the collection
SiClusterContainer* symSiContainer(0);
sc = evtStore()->symLink(m_clusterContainer,symSiContainer);
if (sc.isFailure()) {
msg(MSG:: FATAL) << "Pixel clusters could not be symlinked in StoreGate !"<< endreq;
return StatusCode::FAILURE;
} else {
if (msgLvl(MSG::DEBUG)) msg() << "Pixel clusters '" << m_clustersName << "' symlinked in StoreGate"<< endreq;
}
if (msgLvl(MSG::DEBUG)) msg() << "Creating the ganged ambiguities map" << endreq;
PixelGangedClusterAmbiguities* AmbiguitiesMap =new PixelGangedClusterAmbiguities();
const DataHandle<PixelRDO_Container> p_rdocontainer;
sc=evtStore()->retrieve(p_rdocontainer,m_dataObjectName);
if (sc.isFailure() ){
msg(MSG:: FATAL) << "Could not find the data object "<< m_dataObjectName << " !" << endreq;
// return StatusCode::FAILURE;
} else {
if (msgLvl(MSG::DEBUG)) msg() << "Data object " << m_dataObjectName << " found" << endreq;
p_rdocontainer->clID(); // anything to dereference the DataHandle
// will trigger the converter
PixelRDO_Container::const_iterator rdoCollections = p_rdocontainer->begin();
PixelRDO_Container::const_iterator rdoCollectionsEnd = p_rdocontainer->end();
AtlasDetectorID detType;
for(; rdoCollections!=rdoCollectionsEnd; ++rdoCollections){
const COLLECTION* RDO_Collection(*rdoCollections);
if (!RDO_Collection) continue;
//all debug messages taken out by shaun, 18.12.2008.... too many messages to be useful, and it makes it too slow (maybe use a ifndef NDEBUG ?)
//if (msgLvl(MSG::DEBUG)) msg() << "RDO collection size="<< RDO_Collection->size()<< ", ID=" << RDO_Collection->identify() << endreq;
//if (msgLvl(MSG::DEBUG)) msg() << "Ambiguities map: " << AmbiguitiesMap->size() << " elements" << endreq;
if (RDO_Collection->size() != 0){
// Use one of the specific clustering AlgTools to make clusters
//if (msgLvl(MSG::DEBUG)) msg() << "Calling clusterize()"<< endreq;
PixelClusterCollection* clusterCollection = m_clusteringTool->clusterize(*RDO_Collection,*m_manager,*m_idHelper);
//if (msgLvl(MSG::DEBUG)) msg() << "Exiting from clusterize()"<< endreq;
if (clusterCollection){
if (clusterCollection->size() != 0) {
//if (msgLvl(MSG::DEBUG)) msg() << "Filling ambiguities map" << endreq;
m_gangedAmbiguitiesFinder->execute(clusterCollection,*m_manager,*AmbiguitiesMap);
//if (msgLvl(MSG::DEBUG)) msg() << "Ambiguities map: " << AmbiguitiesMap->size() << " elements" << endreq;
// -me- new IDC does no longer register in Storegate if hash is used !
sc= m_clusterContainer->addCollection( clusterCollection, clusterCollection->identifyHash() );
if (sc.isSuccess()){
//if (msgLvl(MSG::DEBUG)) msg() << "Clusters successfully added to Container !"<< endreq;
}else{
msg(MSG:: ERROR) << "Failed to add Clusters to container"<< endreq;
return StatusCode::FAILURE;
}
} else {
//if (msgLvl(MSG::DEBUG)) msg() << "Clustering algorithm found no clusters"<< endreq;
// -me- clean up memory
delete (clusterCollection);
}
}
}
}
sc = evtStore()->setConst(m_clusterContainer);
if(sc.isFailure()){
msg(MSG:: WARNING) << "Set Const failed!" << endreq;
return sc;
}