ATLAS Offline Software
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"
10 #include "InDetIdentifier/SCT_ID.h"
12 #include "StoreGate/ReadHandle.h"
13 
14 #include "JiveXML/DataType.h"
15 
16 namespace JiveXML {
17 
24  SCTRDORetriever::SCTRDORetriever(const std::string& type,const std::string& name,const IInterface* 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
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
174 
175  ATH_CHECK( m_lorentzAngleTool.retrieve() );
176 
177  return m_geo.retrieve();
178  }
179 
180 } //namespace
DataType.h
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
JiveXML::SCTRDORetriever::m_SCTRDOContainerName
SG::ReadHandleKey< SCT_RDO_Container > m_SCTRDOContainerName
The StoreGate key for the SCTRDO container.
Definition: SCTRDORetriever.h:63
JiveXML::SCTRDORetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: SCTRDORetriever.cxx:40
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SCT3_RawData::SecondHitError
bool SecondHitError() const
Definition: SCT3_RawData.h:122
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
JiveXML::SCTRDORetriever::SCTRDORetriever
SCTRDORetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: SCTRDORetriever.cxx:24
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
SCTRDORetriever.h
ReadCondHandle.h
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition: ReadCondHandle.h:162
SCT3_RawData.h
JiveXML::SCTRDORetriever::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Condition object key of SiDetectorElementCollection for SCT.
Definition: SCTRDORetriever.h:66
SCT3_RawData
Definition: SCT3_RawData.h:24
JiveXML::SCTRDORetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: SCTRDORetriever.h:48
LArHistMerge_trf.dataMap
dataMap
Definition: LArHistMerge_trf.py:218
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT3_RawData::FirstHitError
bool FirstHitError() const
Definition: SCT3_RawData.h:114
SCT3_RawData::getTimeBin
int getTimeBin() const
Definition: SCT3_RawData.h:92
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
SCT_RDORawData.h
TRTByteStreamErrors::BCIDError
@ BCIDError
Definition: ITRT_ByteStream_ConditionsSvc.h:19
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trk::distPhi
@ distPhi
Definition: ParamDefs.h:50
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
InDetDD::SiDetectorElement::endsOfStrip
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...
Definition: SiDetectorElement.cxx:339
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SCT_RDO_Collection.h
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
JiveXML::SCTRDORetriever::m_geo
const ToolHandle< IInDetGeoModelTool > m_geo
A tool handle to the geo model tool.
Definition: SCTRDORetriever.h:57
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
SiDetectorElement.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
InDetDD::SolidStateDetectorElementBase::rawLocalPositionOfCell
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
Definition: SolidStateDetectorElementBase.cxx:230
TRT::Hit::phiModule
@ phiModule
Definition: HitInfo.h:80
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JiveXML::SCTRDORetriever::initialize
virtual StatusCode initialize()
Only retrieve geo tool in initialize.
Definition: SCTRDORetriever.cxx:169
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JiveXML::SCTRDORetriever::m_lorentzAngleTool
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
A tool handle to the SiLorentzAngleTool.
Definition: SCTRDORetriever.h:60
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
Identifier
Definition: IdentifierFieldParser.cxx:14