ATLAS Offline Software
Loading...
Searching...
No Matches
SCTRDORetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "SCTRDORetriever.h"
13
14#include "JiveXML/DataType.h"
15
16namespace JiveXML {
17
24 SCTRDORetriever::SCTRDORetriever(const std::string& type,const std::string& name,const IInterface* parent):
25 AthAlgTool(type,name,parent)
26 {
27 //Declare the interface
28 declareInterface<IDataRetriever>(this);
29
30 //And properties
31 declareProperty("SCTRDOContainer" , m_SCTRDOContainerName = std::string("SCT_RDOs"));
32 }
33
40 StatusCode SCTRDORetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
41
42 //be verbose
43 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
44
45 //Get an iterator over all containers
47 if (not SCTRDOContainer.isValid()){
48 ATH_MSG_DEBUG( "Unable to retrieve SCT_RDO_Container with name " << m_SCTRDOContainerName.key() );
49 return StatusCode::RECOVERABLE;
50 }
51
52 // Get SCT_DetectorElementCollection
54 const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve());
55 if (elements==nullptr) {
56 ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " could not be retrieved");
57 return StatusCode::FAILURE;
58 }
59
60 // Now find out how much space we need in total
61 unsigned long NSCTRDO = 0;
62 //Loop over SCTRDO containers
63 for (const auto SCTRDORawCollection : *SCTRDOContainer)
64 //and get number of SCTRDO in this collection
65 NSCTRDO+=SCTRDORawCollection->size();
66
67 //Define the data vectors we want to fill and create space
68 DataVect ident; ident.reserve(NSCTRDO);
69 DataVect x0; x0.reserve(NSCTRDO);
70 DataVect y0; y0.reserve(NSCTRDO);
71 DataVect z0; z0.reserve(NSCTRDO);
72 DataVect x1; x1.reserve(NSCTRDO);
73 DataVect y1; y1.reserve(NSCTRDO);
74 DataVect z1; z1.reserve(NSCTRDO);
75 DataVect phiModule; phiModule.reserve(NSCTRDO);
76 DataVect etaModule; etaModule.reserve(NSCTRDO);
77 DataVect timeBin; timeBin.reserve(NSCTRDO);
78 DataVect firstHitError; firstHitError.reserve(NSCTRDO);
79 DataVect secondHitError; secondHitError.reserve(NSCTRDO);
80 DataVect syncError; syncError.reserve(NSCTRDO);
81 DataVect preambleError; preambleError.reserve(NSCTRDO);
82 DataVect lvl1Error; lvl1Error.reserve(NSCTRDO);
83 DataVect BCIDError; BCIDError.reserve(NSCTRDO);
84 DataVect formatterError; formatterError.reserve(NSCTRDO);
85
86 //Now loop again over SCTRDO collections to retrieve the data
87 for (const auto SCTRDORawCollection : *SCTRDOContainer) {
88
89 //Get the identifier
90 const IdentifierHash waferHash = SCTRDORawCollection->identifyHash();
91
92 //Loop over raw hit collection
93 for (const auto rdoData : *SCTRDORawCollection) {
94
95 //Get the identifier
96 Identifier id = rdoData->identify();
97
98 //Get the hit detector element
99 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(waferHash);
100 //Make sure we got the detector element
101 if (element == nullptr){
102 ATH_MSG_WARNING( "Unable to obtain detector element for SCT_RDO hit with id " << id );
103 continue ;
104 }
105
106 //Get the local position and store it
107 Amg::Vector2D localPos = element->rawLocalPositionOfCell(id);
108 localPos[Trk::distPhi] += m_lorentzAngleTool->getLorentzShift(waferHash, Gaudi::Hive::currentContext());
109 const std::pair<Amg::Vector3D, Amg::Vector3D> endsOfStrip = element->endsOfStrip(localPos);
110 ident.push_back(DataType( id.get_compact() ));
111 x0.push_back(DataType( endsOfStrip.first.x()*CLHEP::mm/CLHEP::cm));
112 y0.push_back(DataType( endsOfStrip.first.y()*CLHEP::mm/CLHEP::cm));
113 z0.push_back(DataType( endsOfStrip.first.z()*CLHEP::mm/CLHEP::cm));
114 x1.push_back(DataType( endsOfStrip.second.x()*CLHEP::mm/CLHEP::cm));
115 y1.push_back(DataType( endsOfStrip.second.y()*CLHEP::mm/CLHEP::cm));
116 z1.push_back(DataType( endsOfStrip.second.z()*CLHEP::mm/CLHEP::cm));
117 phiModule.push_back(DataType( m_geo->SCTIDHelper()->phi_module(id) ));
118 etaModule.push_back(DataType( m_geo->SCTIDHelper()->eta_module(id) ));
119
120 //Check if we have rdoData3
121 const SCT3_RawData *rdoData3 = dynamic_cast<const SCT3_RawData *>(rdoData);
122 if (rdoData3) {
123 timeBin.push_back(DataType( rdoData3->getTimeBin() ));
124 firstHitError.push_back(DataType( rdoData3->FirstHitError() ));
125 secondHitError.push_back(DataType( rdoData3->SecondHitError() ));
126 } else {
127 timeBin.push_back(DataType( -1 ));
128 firstHitError.push_back(DataType( -1 ));
129 secondHitError.push_back(DataType( -1 ));
130 }
131
132 //Old testbeam information is no more used
133 syncError.push_back(DataType(-1));
134 preambleError.push_back(DataType(-1));
135 lvl1Error.push_back(DataType(-1));
136 BCIDError.push_back(DataType(-1));
137 formatterError.push_back(DataType(-1));
138
139 } // loop over SCTRDO collection
140 } // loop over containers
141
142 //Finally add the data to our map
143 DataMap dataMap;
144 dataMap["id"] = ident;
145 dataMap["x0"] = x0;
146 dataMap["y0"] = y0;
147 dataMap["z0"] = z0;
148 dataMap["x1"] = x1;
149 dataMap["y1"] = y1;
150 dataMap["z1"] = z1;
151 dataMap["phiModule"] = phiModule;
152 dataMap["etaModule"] = etaModule;
153 dataMap["timeBin"] = timeBin;
154 dataMap["firstHitError"] = firstHitError ;
155 dataMap["secondHitError"] = secondHitError ;
156 dataMap["syncError"] = syncError;
157 dataMap["preambleError"] = preambleError;
158 dataMap["lvl1Error"] = lvl1Error;
159 dataMap["BCIDError"] = BCIDError;
160 dataMap["formatterError"] = formatterError;
161
162 //Be verbose
163 ATH_MSG_DEBUG( dataTypeName() << ": " << ident.size() );
164
165 //forward data to formating tool and return
166 return FormatTool->AddToEvent(dataTypeName(), "", &dataMap);
167 }
168
170 // Read Handle Key
171 ATH_CHECK( m_SCTRDOContainerName.initialize() );
172 // Read Cond Handle Key
173 ATH_CHECK( m_SCTDetEleCollKey.initialize() );
174
175 ATH_CHECK( m_lorentzAngleTool.retrieve() );
176
177 return m_geo.retrieve();
178 }
179
180} //namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
This is a "hash" representation of an Identifier.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
std::pair< Amg::Vector3D, Amg::Vector3D > endsOfStrip(const Amg::Vector2D &position) const
Special method for SCT to retrieve the two ends of a "strip" Returned coordinates are in global frame...
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
virtual std::string dataTypeName() const
Return the name of the data type.
virtual StatusCode initialize()
Only retrieve geo tool in initialize.
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
A tool handle to the SiLorentzAngleTool.
SCTRDORetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Condition object key of SiDetectorElementCollection for SCT.
SG::ReadHandleKey< SCT_RDO_Container > m_SCTRDOContainerName
The StoreGate key for the SCTRDO container.
const ToolHandle< IInDetGeoModelTool > m_geo
A tool handle to the geo model tool.
int getTimeBin() const
bool SecondHitError() const
bool FirstHitError() const
const_pointer_type retrieve()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Eigen::Matrix< double, 2, 1 > Vector2D
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
@ distPhi
Definition ParamDefs.h:50