ATLAS Offline Software
TrigZFinderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <vector>
6 #include "TrigZFinderAlg.h"
7 #include "TrigZFinder.h"
10 // To add identifier
12 
13 using namespace std;
14 
15 TrigZFinderAlg::TrigZFinderAlg(const std::string& name, ISvcLocator* pSvcLocator) :
16  AthReentrantAlgorithm(name, pSvcLocator)
17 {
18 }
19 
21 {
22 }
23 
25 {
26  ATH_CHECK(m_zFinderTools.retrieve());
29  ATH_CHECK(m_vertexKey.initialize());
30  if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
31 
32  return StatusCode::SUCCESS;
33 }
34 
36 {
37  return StatusCode::SUCCESS;
38 }
39 
40 StatusCode TrigZFinderAlg::execute(const EventContext& context) const
41 {
42  vector<TrigSiSpacePointBase> spVec;
44 
45  //For Pixel info decoding
46  SG::ReadHandle<PixelID> pixelHelper(m_pixelHelperKey, context);
47 
49  // This loop is to count sp
50  // The z's are found from reconstructing these sp's.
51  for (const auto pixSPointColl : *pixelSP)
52  {
53  if (pixSPointColl == nullptr)
54  continue;
55 
56  const Identifier pixid = (pixSPointColl)->identify();
57  int layerId = pixelHelper->layer_disk(pixid);
58  // Set the resolution for r & z in barrel/end cap.
59  if(pixelHelper->is_barrel(pixid)){
60  const double dr = 0.01;
61  const double dz = 0.13;
62 
63  for (const auto pSP : *pixSPointColl)
64  {
65  // Store SP into vector
66  spVec.push_back(TrigSiSpacePointBase(layerId, pSP->globalPosition().perp(), pSP->globalPosition().phi(), pSP->globalPosition().z(),
67  dr, dz, pSP));
68  }
69  }
70  }
71  ATH_MSG_DEBUG("Size of spVec: " << spVec.size());
72 
74  TrigRoiDescriptor fullscan_roi( true );
75 
76 
77 
78  // Recording Data
79  auto zVertexContainer = std::make_unique<xAOD::TrigCompositeContainer>();
80  auto zVertexContainerAux = std::make_unique<xAOD::TrigCompositeAuxContainer>();
81  zVertexContainer->setStore(zVertexContainerAux.get());
82 
83  int toolIndex=0;
84  for ( auto& tool: m_zFinderTools ) {
85  TrigVertexCollection* vertices = tool->findZ(spVec, TrigRoiDescriptor(true));
86 
87  ATH_MSG_DEBUG("Successfully retrieved size of number of vertices: " << vertices->size());
88 
89  for ( auto vertex: *vertices ) {
90  ATH_MSG_DEBUG("z of vertex: "<< vertex->z() );
91  ATH_MSG_DEBUG("weight vertex: "<< vertex->cov()[5] );
92 
93  xAOD::TrigComposite *outputVertex = new xAOD::TrigComposite();
94  zVertexContainer->push_back(outputVertex);
95  outputVertex->setDetail<int>("zfinder_tool", toolIndex );
96  outputVertex->setDetail<float>("zfinder_vtx_z", vertex->z() );
97  outputVertex->setDetail<float>("zfinder_vtx_weight", vertex->cov()[5] );
98  // Adding monitoring histograms
99  auto ZVertex = Monitored::Scalar("ZVertex",vertex->z());
100  auto ZVertexWeight = Monitored::Scalar("ZVertexWeight",vertex->cov()[5]);
101 
102  auto mon = Monitored::Group(m_monTool, ZVertex, ZVertexWeight);
103  }
104  toolIndex++;
105  delete vertices;
106  }
107  if ( zVertexContainer->empty() ) {
108  xAOD::TrigComposite *emptyVertex = new xAOD::TrigComposite();
109  zVertexContainer->push_back(emptyVertex);
110  emptyVertex->setDetail<int>("zfinder_tool", -1 );
111  emptyVertex->setDetail<float>("zfinder_vtx_z", -1000.0 );
112  emptyVertex->setDetail<float>("zfinder_vtx_weight", -1.0 );
113  }
114 
116  ATH_CHECK(vertexHandle.record(std::move(zVertexContainer), std::move(zVertexContainerAux)));
117  return StatusCode::SUCCESS;
118 }
TrigZFinderAlg::m_pixelSpKey
SG::ReadHandleKey< SpacePointContainer > m_pixelSpKey
Definition: TrigZFinderAlg.h:45
xAOD::TrigComposite_v1::setDetail
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigZFinderAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigZFinderAlg.cxx:40
TrigZFinderAlg::~TrigZFinderAlg
virtual ~TrigZFinderAlg() override
Definition: TrigZFinderAlg.cxx:20
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:16
PixelCluster.h
SG::ReadHandle< SpacePointContainer >
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
TrigZFinderAlg::initialize
virtual StatusCode initialize() override
Definition: TrigZFinderAlg.cxx:24
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TrigZFinderAlg::m_pixelHelperKey
SG::ReadHandleKey< PixelID > m_pixelHelperKey
Definition: TrigZFinderAlg.h:46
PixelID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for g...
Definition: PixelID.h:605
TrigZFinderAlg.h
TrigSiSpacePointBase.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigZFinderAlg::m_vertexKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_vertexKey
Definition: TrigZFinderAlg.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
TrigZFinderAlg::finalize
virtual StatusCode finalize() override
Definition: TrigZFinderAlg.cxx:35
TrigZFinder.h
TrigZFinderAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigZFinderAlg.h:48
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TrigVertexCollection
Definition: TrigVertexCollection.h:13
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TrigZFinderAlg::m_zFinderTools
ToolHandleArray< TrigZFinder > m_zFinderTools
Definition: TrigZFinderAlg.h:44
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
TrigRoiDescriptor.h
TrigSiSpacePointBase
Definition: TrigSiSpacePointBase.h:23
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigZFinderAlg::TrigZFinderAlg
TrigZFinderAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigZFinderAlg.cxx:15