ATLAS Offline Software
Loading...
Searching...
No Matches
MdtPrepDataRetriever.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 MdtPrepDataRetriever::MdtPrepDataRetriever(const std::string& type, const std::string& name, const IInterface* parent):
15 AthAlgTool(type, name, parent)
16 {
17
18 declareInterface<IDataRetriever>(this);
19
20 declareProperty("AdcCut", m_adcCut = 90, " Some ADC threshold cut");
21 declareProperty("ObeyMasked", m_obeyMasked = true, " Use info about masked channels");
22 }
23
24 //--------------------------------------------------------------------------
25
27
28 ATH_MSG_DEBUG("Initializing retriever for " << dataTypeName());
29 ATH_CHECK(m_sgKey.initialize());
30 ATH_CHECK( m_idHelperSvc.retrieve() );
31
32 return StatusCode::SUCCESS;
33 }
34
35 //--------------------------------------------------------------------------
36
37 StatusCode MdtPrepDataRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
38
39 //be verbose
40 ATH_MSG_VERBOSE("Retrieving " << dataTypeName());
41
43
44
45 int ndata = 0;
47 for (containerIt=mdtContainer->begin(); containerIt!=mdtContainer->end(); ++containerIt) {
48 ndata += (*containerIt)->size();
49 }
50
51 //Make the vectors to contain the information and reserve space accordingly
52 DataVect x; x.reserve(ndata);
53 DataVect y; y.reserve(ndata);
54 DataVect z; z.reserve(ndata);
55 DataVect lengthVec; lengthVec.reserve(ndata);
56 DataVect driftRVec; driftRVec.reserve(ndata);
57 DataVect idVec; idVec.reserve(ndata);
58 DataVect identifierVec; identifierVec.reserve(ndata);
59 DataVect barcode; barcode.reserve(ndata);
60
61 bool notMasked = true;
62
63 for (containerIt=mdtContainer->begin(); containerIt!=mdtContainer->end(); ++containerIt) {
64 const Muon::MdtPrepDataCollection *mdtCollection = *containerIt;
65
67 for (collectionIt=mdtCollection->begin(); collectionIt!=mdtCollection->end(); ++collectionIt) {
68
69 const Muon::MdtPrepData *data = *collectionIt;
70 const MuonGM::MdtReadoutElement *element = data->detectorElement();
71 Identifier id = data->identify();
72
73 if (!element) {
74 ATH_MSG_WARNING("No MuonGM::MdtReadoutElement for hit " << id);
75 continue;
76 }
77
80 Amg::Vector2D localPos = data->localPosition();
81 Amg::Vector3D globalPos = element->tubePos(id);
82 double tubeLength = element->tubeLength(id);
83 const int adcCount = data->adc();
84
85 // status from: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MdtDriftCircleStatus.h
86
87 if ( (data->status() == Muon::MdtStatusMasked) && ( m_obeyMasked )){
88 notMasked = false;
89 }else{
90 notMasked = true;
91 }
92 if ( ( adcCount >= m_adcCut ) && notMasked ){
93 x.push_back(DataType(globalPos.x()/CLHEP::cm));
94 y.push_back(DataType(globalPos.y()/CLHEP::cm));
95 z.push_back(DataType(globalPos.z()/CLHEP::cm));
96 driftRVec.push_back(DataType(localPos[Trk::driftRadius]/CLHEP::cm));
97 lengthVec.push_back(DataType(tubeLength/CLHEP::cm));
98 identifierVec.push_back(DataType(MuonFullIDHelper::getFullID(id, m_idHelperSvc->mdtIdHelper())));
99 idVec.push_back(DataType( id.get_compact() ));
100 barcode.push_back(DataType(0));
101 }
102
103 ATH_MSG_DEBUG(" MdtPrepData x, y, z, driftR, lenght " << globalPos.x() << " "
104 << globalPos.y() << " " << globalPos.z() << " " << localPos[Trk::driftRadius]
105 << " " << tubeLength << " adc: " << adcCount);
106 if ( notMasked ){ ATH_MSG_DEBUG(" *notMasked* "); }
107 }
108 }
109
110 DataMap myDataMap;
111 myDataMap["x"] = x;
112 myDataMap["y"] = y;
113 myDataMap["z"] = z;
114 myDataMap["length"] = lengthVec;
115 myDataMap["driftR"] = driftRVec;
116 myDataMap["identifier"] = identifierVec;
117 myDataMap["id"] = idVec;
118 myDataMap["barcode"] = barcode;
119
120 //Be verbose
121 ATH_MSG_DEBUG(dataTypeName() << ": "<< x.size());
122
123 //forward data to formating tool
124 //return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
127 std::string emptyStr="";
128 return FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &myDataMap);
129 }
130
131 //--------------------------------------------------------------------------
132}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
double tubeLength
#define y
#define x
#define z
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)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
MdtPrepDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
virtual std::string dataTypeName() const
Return the name of the data type.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_sgKey
The storegate key for the MDT collection.
StatusCode initialize()
Default AthAlgTool methods.
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
double tubeLength(const int tubeLayer, const int tube) const
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
Eigen::Matrix< double, 2, 1 > Vector2D
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
@ MdtStatusMasked
A hit during a previous bunch crossing occured which rendered the tube dead for this bunch crossing.
MuonPrepDataCollection< MdtPrepData > MdtPrepDataCollection
@ driftRadius
trt, straws
Definition ParamDefs.h:53