ATLAS Offline Software
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 
5 #include "MdtPrepDataRetriever.h"
6 
7 #include "MuonFullIDHelper.h"
9 
10 namespace JiveXML {
11 
12  //--------------------------------------------------------------------------
13 
14  MdtPrepDataRetriever::MdtPrepDataRetriever(const std::string& type, const std::string& name, const IInterface* 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 }
MdtReadoutElement.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
MuonGM::MdtReadoutElement::tubeLength
double tubeLength(const int tubeLayer, const int tube) const
JiveXML::MdtPrepDataRetriever::m_sgKey
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_sgKey
The storegate key for the MDT collection.
Definition: MdtPrepDataRetriever.h:39
JiveXML::MdtPrepDataRetriever::initialize
StatusCode initialize()
Default AthAlgTool methods.
Definition: MdtPrepDataRetriever.cxx:26
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
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
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JiveXML::MdtPrepDataRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: MdtPrepDataRetriever.h:31
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
x
#define x
JiveXML::MdtPrepDataRetriever::MdtPrepDataRetriever
MdtPrepDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: MdtPrepDataRetriever.cxx:14
JiveXML::MdtPrepDataRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: MdtPrepDataRetriever.cxx:37
Muon::MdtStatusMasked
@ MdtStatusMasked
A hit during a previous bunch crossing occured which rendered the tube dead for this bunch crossing.
Definition: MdtDriftCircleStatus.h:31
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:50
JiveXML::MdtPrepDataRetriever::m_adcCut
int m_adcCut
Definition: MdtPrepDataRetriever.h:43
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:59
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
JiveXML::MdtPrepDataRetriever::m_obeyMasked
bool m_obeyMasked
Definition: MdtPrepDataRetriever.h:44
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
Muon::MuonPrepDataCollection
Template to hold collections of MuonPrepRawData objects.
Definition: MuonPrepDataCollection.h:46
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Muon::MdtPrepData
Class to represent measurements from the Monitored Drift Tubes.
Definition: MdtPrepData.h:37
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
JiveXML::MuonFullIDHelper::getFullID
std::string getFullID(Identifier id, const MdtIdHelper &mdtHelper)
Get the identifier string for an MDT ID with the sequence: Detector/StationName/StationEta/StationPhi...
Definition: MuonFullIDHelper.cxx:26
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
MuonGM::MdtReadoutElement::tubePos
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JiveXML::MdtPrepDataRetriever::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtPrepDataRetriever.h:41
MuonFullIDHelper.h
tubeLength
double tubeLength
Definition: MDT_ResponseTest.cxx:32
MdtPrepDataRetriever.h
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.