ATLAS Offline Software
Loading...
Searching...
No Matches
TgcPrepDataRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "MuonFullIDHelper.h"
9
10namespace JiveXML {
11
12 //--------------------------------------------------------------------------
13
14 TgcPrepDataRetriever::TgcPrepDataRetriever(const std::string& type,const std::string& name, const IInterface* parent):
15 AthAlgTool(type, name, parent)
16 {
17
18 declareInterface<IDataRetriever>(this);
19 }
20
21 //--------------------------------------------------------------------------
22
24
25 ATH_MSG_DEBUG("Initializing retriever for " << dataTypeName());
26 ATH_CHECK(m_sgKey.initialize());
27 ATH_CHECK( m_idHelperSvc.retrieve() );
28
29 return StatusCode::SUCCESS;
30 }
31
32 //--------------------------------------------------------------------------
33
34 StatusCode TgcPrepDataRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
35
36 //be verbose
37 ATH_MSG_DEBUG("Retrieving " << dataTypeName());
38
40
41 int ndata = 0;
43 for (containerIt=tgcContainer->begin(); containerIt!=tgcContainer->end(); ++containerIt) {
44 ndata += (*containerIt)->size();
45 }
46 //Make the vectors to contain the information and reserve space accordingly
47 DataVect x; x.reserve(ndata);
48 DataVect y; y.reserve(ndata);
49 DataVect z; z.reserve(ndata);
50 DataVect lengthVec; lengthVec.reserve(ndata);
51 DataVect swidthVec; swidthVec.reserve(ndata);
52 DataVect lwidthVec; lwidthVec.reserve(ndata);
53 DataVect idVec; idVec.reserve(ndata);
54 DataVect identifierVec; identifierVec.reserve(ndata);
55 DataVect barcode; barcode.reserve(ndata);
56
57 for (containerIt=tgcContainer->begin(); containerIt!=tgcContainer->end(); ++containerIt) {
58 const Muon::TgcPrepDataCollection *tgcCollection = *containerIt;
59
61 for (collectionIt=tgcCollection->begin(); collectionIt!=tgcCollection->end(); ++collectionIt) {
62
63 const Muon::TgcPrepData *data = *collectionIt;
64 const MuonGM::TgcReadoutElement *element = data->detectorElement();
65 Identifier id = data->identify();
66
67 if (!element) {
68 if (msgLvl(MSG::WARNING)) ATH_MSG_WARNING("No MuonGM::TgcReadoutElement for hit " << id);
69 continue;
70 }
71
72 Amg::Vector3D globalPos;
73 double shortWidth, longWidth, length;
74 if (m_idHelperSvc->tgcIdHelper().isStrip(id)) {
75 int gasGap = m_idHelperSvc->tgcIdHelper().gasGap(id);
76 int strip = m_idHelperSvc->tgcIdHelper().channel(id);
77 shortWidth = element->stripShortWidth(gasGap, strip);
78 longWidth = element->stripLongWidth(gasGap, strip);
79 length = element->stripLength();
80 globalPos = element->stripPos(gasGap, strip);
81 } else {
82 int gasGap = m_idHelperSvc->tgcIdHelper().gasGap(id);
83 int gang = m_idHelperSvc->tgcIdHelper().channel(id);
84 shortWidth = element->gangShortWidth(gasGap, gang);
85 longWidth = element->gangLongWidth(gasGap, gang);
86 length = element->gangRadialLength(gasGap, gang);
87 globalPos = element->wireGangPos(gasGap, gang);
88 }
89
90 x.push_back(DataType(globalPos.x()/CLHEP::cm));
91 y.push_back(DataType(globalPos.y()/CLHEP::cm));
92 z.push_back(DataType(globalPos.z()/CLHEP::cm));
93 swidthVec.push_back(DataType(shortWidth/CLHEP::cm));
94 lwidthVec.push_back(DataType(longWidth/CLHEP::cm));
95 lengthVec.push_back(DataType(length/CLHEP::cm));
96 identifierVec.push_back(DataType(MuonFullIDHelper::getFullID(id, m_idHelperSvc->tgcIdHelper())));
97 idVec.push_back(DataType( id.get_compact() ));
98 barcode.push_back(DataType(0));
99
100 }
101 }
102
103 DataMap myDataMap;
104 myDataMap["x"] = x;
105 myDataMap["y"] = y;
106 myDataMap["z"] = z;
107 myDataMap["length"] = lengthVec;
108 myDataMap["swidth"] = swidthVec;
109 myDataMap["lwidth"] = lwidthVec;
110 myDataMap["identifier"] = identifierVec;
111 myDataMap["id"] = idVec;
112 myDataMap["barcode"] = barcode;
113
114 //Be verbose
115 ATH_MSG_DEBUG(dataTypeName() << ": "<< x.size());
116
118 //return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
121 std::string emptyStr="";
122 return FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &myDataMap);
123 }
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
double length(const pvec &v)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
StatusCode initialize()
Default AthAlgTool methods.
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_sgKey
The storegate key for the TGC collection.
virtual std::string dataTypeName() const
Return the name of the data type.
TgcPrepDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
double stripLength() const
Returns the length of each strip which is equal to the height of the chamber.
double gangShortWidth(int gasGap, int gang) const
Returns the length of the most bottom wire in the gang.
double gangLongWidth(int gasGap, int gang) const
Returns the length of the most top wire in the gang.
Amg::Vector3D stripPos(int gasGap, int strip) const
Returns the global position of a strip.
double gangRadialLength(int gasGap, int gang) const
Returns the length of the wire gang along the radial direction [pitch x N_{wire}^{gang}...
Amg::Vector3D wireGangPos(const Identifier &id) const
Returns the global position of a wireGang.
Class to represent TGC measurements.
Definition TgcPrepData.h:32
Eigen::Matrix< double, 3, 1 > Vector3D
std::string getFullID(Identifier id, const MdtIdHelper &mdtHelper)
Get the identifier string for an MDT ID with the sequence: Detector/StationName/StationEta/StationPhi...
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection