ATLAS Offline Software
Loading...
Searching...
No Matches
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
13using namespace std;
14
15TrigZFinderAlg::TrigZFinderAlg(const std::string& name, ISvcLocator* pSvcLocator) :
16 AthReentrantAlgorithm(name, pSvcLocator)
17{
18}
19
23
25{
26 ATH_CHECK(m_zFinderTools.retrieve());
27 ATH_CHECK(m_pixelSpKey.initialize());
28 ATH_CHECK(m_pixelHelperKey.initialize());
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
40StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
An algorithm that can be simultaneously executed in multiple threads.
size_type size() const noexcept
Returns the number of elements in the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual ~TrigZFinderAlg() override
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &context) const override
ToolHandle< GenericMonitoringTool > m_monTool
SG::ReadHandleKey< PixelID > m_pixelHelperKey
ToolHandleArray< TrigZFinder > m_zFinderTools
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_vertexKey
SG::ReadHandleKey< SpacePointContainer > m_pixelSpKey
virtual StatusCode finalize() override
TrigZFinderAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
STL namespace.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.