ATLAS Offline Software
CscPrepDataRetriever.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 "CscPrepDataRetriever.h"
6 
7 #include "MuonFullIDHelper.h"
9 
10 namespace JiveXML {
11 
12  //--------------------------------------------------------------------------
13 
14  CscPrepDataRetriever::CscPrepDataRetriever(const std::string& type, const std::string& name, const IInterface* parent):
16  {
17 
18  declareInterface<IDataRetriever>(this);
19 
20  }
21 
22  //--------------------------------------------------------------------------
23 
25 
26  ATH_MSG_DEBUG("Initializing retriever for " << dataTypeName());
27 
28  ATH_CHECK(m_sgKey.initialize());
29  ATH_CHECK( m_idHelperSvc.retrieve() );
30  return StatusCode::SUCCESS;
31  }
32 
33  //--------------------------------------------------------------------------
34 
35  StatusCode CscPrepDataRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
36 
37  //be verbose
38  ATH_MSG_VERBOSE("Retrieving " << dataTypeName());
39 
41 
42 
43  int ndata = 0;
45  for (containerIt=cscContainer->begin(); containerIt!=cscContainer->end(); ++containerIt) {
46  ndata += (*containerIt)->size();
47  }
48 
49  //Make the vectors to contain the information and reserve space accordingly
50  DataVect x; x.reserve(ndata);
51  DataVect y; y.reserve(ndata);
52  DataVect z; z.reserve(ndata);
53  DataVect lengthVec; lengthVec.reserve(ndata);
54  DataVect chargeVec; chargeVec.reserve(ndata);
55  DataVect idVec; idVec.reserve(ndata);
56  DataVect identifierVec; identifierVec.reserve(ndata);
57  DataVect barcode; barcode.reserve(ndata);
58 
59  for (containerIt=cscContainer->begin(); containerIt!=cscContainer->end(); ++containerIt) {
60  const Muon::CscPrepDataCollection *cscCollection = *containerIt;
61 
63  for (collectionIt=cscCollection->begin(); collectionIt!=cscCollection->end(); ++collectionIt) {
64 
65  const Muon::CscPrepData *data = *collectionIt;
66  const MuonGM::CscReadoutElement *element = data->detectorElement();
67  Identifier id = data->identify();
68 
69  if (!element) {
70  ATH_MSG_WARNING("No MuonGM::CscReadoutElement for hit " << id);
71  continue;
72  }
73 
74  Amg::Vector3D globalPos = element->stripPos(id);
75  double length = element->stripLength(id);
76  int charge = data->charge();
77 
78  x.push_back(DataType(globalPos.x()/CLHEP::cm));
79  y.push_back(DataType(globalPos.y()/CLHEP::cm));
80  z.push_back(DataType(globalPos.z()/CLHEP::cm));
81  lengthVec.push_back(DataType(length/CLHEP::cm));
82  chargeVec.push_back(DataType(charge));
83  identifierVec.push_back(DataType(MuonFullIDHelper::getFullID(id, m_idHelperSvc->cscIdHelper())));
84  idVec.push_back(DataType( id.get_compact() ));
85  barcode.push_back(DataType(0));
86  }
87  }
88 
89  DataMap myDataMap;
90  myDataMap["x"] = x;
91  myDataMap["y"] = y;
92  myDataMap["z"] = z;
93  myDataMap["length"] = lengthVec;
94  myDataMap["charge"] = chargeVec;
95  myDataMap["identifier"] = identifierVec;
96  myDataMap["id"] = idVec;
97  myDataMap["barcode"] = barcode;
98 
99  //Be verbose
100  ATH_MSG_DEBUG(dataTypeName() << ": "<< x.size());
101 
102  //forward data to formating tool
103  //return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
106  std::string emptyStr="";
107  return FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &myDataMap);
108  }
109 
110  //--------------------------------------------------------------------------
111 }
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
JiveXML::CscPrepDataRetriever::CscPrepDataRetriever
CscPrepDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: CscPrepDataRetriever.cxx:14
CscPrepDataRetriever.h
JiveXML::CscPrepDataRetriever::initialize
virtual StatusCode initialize()
Default AthAlgTool methods.
Definition: CscPrepDataRetriever.cxx:24
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JiveXML::CscPrepDataRetriever::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: CscPrepDataRetriever.h:39
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
x
#define x
MuonGM::CscReadoutElement::stripLength
double stripLength(int chamberLayer, int measuresPhi, int stripNumber, double &epsilon) const
Definition: CscReadoutElement.cxx:292
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
Muon::CscPrepData
Class representing clusters from the CSC.
Definition: CscPrepData.h:39
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
CscReadoutElement.h
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
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
charge
double charge(const T &p)
Definition: AtlasPID.h:494
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
JiveXML::CscPrepDataRetriever::m_sgKey
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_sgKey
The storegate key for the CSC collection.
Definition: CscPrepDataRetriever.h:37
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JiveXML::CscPrepDataRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: CscPrepDataRetriever.h:30
MuonFullIDHelper.h
MuonGM::CscReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
takes into account internal alignment parameters, hence gives accurate answer
Definition: CscReadoutElement.cxx:227
AthAlgTool
Definition: AthAlgTool.h:26
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
JiveXML::CscPrepDataRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: CscPrepDataRetriever.cxx:35
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.