ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellVolumes Class Reference

#include <CaloCellVolumes.h>

Collaboration diagram for CaloCellVolumes:

Public Member Functions

 CaloCellVolumes (ISvcLocator *svcLocator, const CaloCell_ID *calocell_id)
 ~CaloCellVolumes ()
double CellVolume (Identifier cell_id)
const std::string & layout ()
double getFcalTubeSpacing (int sampling)
void print ()

Private Types

typedef std::map< int, double > TubeSpacingMap

Private Attributes

const CaloCell_IDm_calocell_id {nullptr}
CaloCellVolumeVector m_cellVolumes
std::string m_geometryLayout
TubeSpacingMap m_fcalTubeSpacings

Detailed Description

Definition at line 24 of file CaloCellVolumes.h.

Member Typedef Documentation

◆ TubeSpacingMap

typedef std::map<int, double> CaloCellVolumes::TubeSpacingMap
private

Definition at line 45 of file CaloCellVolumes.h.

Constructor & Destructor Documentation

◆ CaloCellVolumes()

CaloCellVolumes::CaloCellVolumes ( ISvcLocator * svcLocator,
const CaloCell_ID * calocell_id )

Definition at line 32 of file CaloCellVolumes.cxx.

34 : m_calocell_id(calocell_id)
35{
36 // Retrieve input parameters from the database
37 SmartIF<IGeoModelSvc> geoModel{svcLocator->service("GeoModelSvc")};
38 if(!geoModel)
39 throw std::runtime_error("CellVolumes error: cannot access GeoModelSvc");
40
41 SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service("GeoDbTagSvc")};
42 if(!geoDbTagSvc)
43 throw std::runtime_error("CellVolumes error: cannot access GeoDbTagSvc");
44
45 SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(geoDbTagSvc->getParamSvcName())};
46 if(!rdbAccess)
47 throw std::runtime_error("CellVolumes error: cannot access RDBAccessSvc");
48
49 std::string larKey, larNode;
50 if(geoDbTagSvc->getSqliteReader()==nullptr) {
51 DecodeVersionKey detectorKey = DecodeVersionKey(geoModel,"LAr");
52 larKey = detectorKey.tag();
53 larNode = detectorKey.node();
54 }
55
56 IRDBRecordset_ptr cellVolRec = rdbAccess->getRecordsetPtr("LArCellVolumes",larKey,larNode);
57 if(cellVolRec->size()==0) {
58 cellVolRec = rdbAccess->getRecordsetPtr("LArCellVolumes","LArCellVolumes-00");
59 if(cellVolRec->size()==0) {
60 throw std::runtime_error("CaloCellVolumes error: 0 size of LArCellVolumes recordset");
61 }
62 }
63
64 // get fcal tube spacings
65 IRDBRecordset_ptr fcalModRec = rdbAccess->getRecordsetPtr("FCalMod",larKey,larNode);
66 if(fcalModRec->size()==0) {
67 fcalModRec = rdbAccess->getRecordsetPtr("FCalMod","FCalMod-00");
68 if(fcalModRec->size()==0) {
69 throw std::runtime_error("CaloCellVolumes error: 0 size of FCalMod recordset");
70 }
71 }
72
73 for(const IRDBRecord_ptr& rec : *fcalModRec) {
74 m_fcalTubeSpacings[rec->getInt("FCALSAMPLING")] = rec->getDouble("TUBESPACING");
75 }
76
77 m_geometryLayout = "Atlas";
78 if(geoDbTagSvc->getSqliteReader()==nullptr) {
79 std::string LArTag = rdbAccess->getChildTag("LAr",larKey,larNode);
80 if(LArTag.find("H8")!=std::string::npos) {
81 m_geometryLayout = "H8";
82 }
83 else if(LArTag.find("H6")!=std::string::npos) {
84 m_geometryLayout = "H6";
85 }
86 else if(LArTag.find("G3")!=std::string::npos) {
87 m_geometryLayout = "G3";
88 }
89 }
90
91 // Initialize m_cellVolumes vector
92 for(const IRDBRecord_ptr& rec : *cellVolRec) {
93
94 int subcalo = rec->getInt("SUBCALO");
95 int posneg = rec->getInt("POSNEG");
96 int sampling = rec->getInt("SAMPLING");
97 int region = rec->getInt("REGION");
98 int eta = rec->getInt("ETA");
99 int phi = rec->getInt("PHI");
100
101 Identifier channelID;
102 if(m_geometryLayout != "H6" || subcalo == CaloCell_ID::LARFCAL) {
103 channelID = m_calocell_id->cell_id (subcalo, posneg, sampling, region, eta, phi);
104 }
105 else {
106 Identifier reg_id = m_calocell_id->region_id(subcalo, posneg, sampling, region);
107 int phimin = m_calocell_id->phi_min(reg_id);
108 channelID = m_calocell_id->cell_id (subcalo, posneg, sampling, region, eta, phimin);
109 }
110
111 CaloCellVolume cellVol;
112 cellVol.channelID = channelID;
113 cellVol.volume = rec->getDouble("VOLUME");
114 m_cellVolumes.push_back(cellVol);
115 }
116
117 if (m_cellVolumes.empty()) {
118 throw std::runtime_error("CaloCellVolumes error: 0 volumes have been built!");
119 }
120
121 std::sort (m_cellVolumes.begin(), m_cellVolumes.end(),
122 CaloCellVolume_Compare());
123}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
CaloCellVolumeVector m_cellVolumes
TubeSpacingMap m_fcalTubeSpacings
const CaloCell_ID * m_calocell_id
std::string m_geometryLayout
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
virtual unsigned int size() const =0
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Identifier channelID

◆ ~CaloCellVolumes()

CaloCellVolumes::~CaloCellVolumes ( )

Definition at line 125 of file CaloCellVolumes.cxx.

126{
127 m_cellVolumes.clear();
128}

Member Function Documentation

◆ CellVolume()

double CaloCellVolumes::CellVolume ( Identifier cell_id)

Definition at line 130 of file CaloCellVolumes.cxx.

131{
132 // compute Identifier of Cell with same eta, but phi=0 and pos side
133 // (except for fcal)
134 Identifier volId;
135
136 if (!m_calocell_id->is_fcal(cell_id)) {
137 int subCalo = m_calocell_id->sub_calo(cell_id);
138 int posneg = std::abs (m_calocell_id->pos_neg(cell_id));
139 int sampling = m_calocell_id->sampling(cell_id);
140 int region = m_calocell_id->region(cell_id);
141 int eta = m_calocell_id->eta(cell_id);
142
143 if(m_geometryLayout != "H6") {
144 volId = m_calocell_id->cell_id(subCalo, posneg, sampling, region, eta, 0);
145 }
146 else {
147 Identifier reg_id = m_calocell_id->region_id(subCalo, posneg, sampling, region);
148 int phimin = m_calocell_id->phi_min(reg_id);
149 volId = m_calocell_id->cell_id(subCalo, posneg, sampling, region, eta, phimin);
150 }
151 }
152 else {
153 volId = cell_id;
154 }
155
156 CaloCellVolumeVector::const_iterator it =
157 std::lower_bound (m_cellVolumes.begin(), m_cellVolumes.end(), volId,
158 CaloCellVolume_Compare());
159 if (it != m_cellVolumes.end() && it->channelID == volId) return it->volume;
160
161 return 0.;
162}

◆ getFcalTubeSpacing()

double CaloCellVolumes::getFcalTubeSpacing ( int sampling)

Definition at line 181 of file CaloCellVolumes.cxx.

182{
183 TubeSpacingMap::const_iterator it = m_fcalTubeSpacings.find(sampling);
184 if(it==m_fcalTubeSpacings.end())
185 throw std::runtime_error("CaloCellVolumes::getFcalTubeSpacing error: wrong sampling provided");
186
187 return (*it).second;
188}

◆ layout()

const std::string & CaloCellVolumes::layout ( )
inline

Definition at line 32 of file CaloCellVolumes.h.

32{ return m_geometryLayout; }

◆ print()

void CaloCellVolumes::print ( )

Definition at line 164 of file CaloCellVolumes.cxx.

165{
166 if (m_cellVolumes.empty()) {
167 std::cerr << "CaloCellVolumes::print(). No cell volumes..." << std::endl;
168 }
169 else {
170 std::cout << "CaloCellVolumes::print(). Number of volumes found: "
171 << m_cellVolumes.size() << std::endl;
172
173 for(const CaloCellVolume& vol : m_cellVolumes) {
174 m_calocell_id->print( (Identifier) vol.channelID );
175 std::cout << m_calocell_id->show_to_string( (Identifier) vol.channelID );
176 std::cout << " ==> vol= " << vol.volume << " mm3" << std::endl;
177 }
178 }
179}

Member Data Documentation

◆ m_calocell_id

const CaloCell_ID* CaloCellVolumes::m_calocell_id {nullptr}
private

Definition at line 40 of file CaloCellVolumes.h.

40{nullptr};

◆ m_cellVolumes

CaloCellVolumeVector CaloCellVolumes::m_cellVolumes
private

Definition at line 41 of file CaloCellVolumes.h.

◆ m_fcalTubeSpacings

TubeSpacingMap CaloCellVolumes::m_fcalTubeSpacings
private
Initial value:
{
{1, 7.5}
, {2, 8.179}
, {3, 9.}
}

Definition at line 46 of file CaloCellVolumes.h.

46 {
47 {1, 7.5}
48 , {2, 8.179}
49 , {3, 9.}
50 };

◆ m_geometryLayout

std::string CaloCellVolumes::m_geometryLayout
private

Definition at line 42 of file CaloCellVolumes.h.


The documentation for this class was generated from the following files: