ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include "MuonFullIDHelper.h"
9
10namespace JiveXML {
11
12 //--------------------------------------------------------------------------
13
14 CscPrepDataRetriever::CscPrepDataRetriever(const std::string& type, const std::string& name, const IInterface* parent):
15 AthAlgTool(type,name,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}
#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)
double charge(const T &p)
Definition AtlasPID.h:997
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
double length(const pvec &v)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
CscPrepDataRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize()
Default AthAlgTool methods.
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_sgKey
The storegate key for the CSC collection.
virtual std::string dataTypeName() const
Return the name of the data type.
double stripLength(int chamberLayer, int measuresPhi, int stripNumber, double &epsilon) const
Amg::Vector3D stripPos(const Identifier &id) const
takes into account internal alignment parameters, hence gives accurate answer
Class representing clusters from the CSC.
Definition CscPrepData.h:39
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
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection