Skip to content
Snippets Groups Projects
Commit 60373b77 authored by Dave Casper's avatar Dave Casper
Browse files

Merge branch 'master-veto-neighbors' into 'master'

Implement neighbors for VetoID and add test of them

See merge request !23
parents ba4b1ba1 a3d7d0a2
No related branches found
No related tags found
1 merge request!23Implement neighbors for VetoID and add test of them
Pipeline #1071096 passed
......@@ -4,6 +4,7 @@
#include "GeoModelUtilities/GeoModelExperiment.h"
#include "ScintReadoutGeometry/VetoDetectorManager.h"
#include "ScintIdentifier/VetoID.h"
GeoModelTestAlg::GeoModelTestAlg(const std::string& name, ISvcLocator* pSvcLocator)
......@@ -61,6 +62,61 @@ StatusCode GeoModelTestAlg::execute()
return StatusCode::FAILURE;
}
// Test neighbors
const VetoID* helper = nullptr;
ATH_CHECK(detStore()->retrieve(helper, "VetoID"));
if (helper != nullptr)
{
const IdContext& context = helper->plate_context();
ATH_MSG_ALWAYS("Retrieved VetoID helper from DetStore.");
for (int iStation = 0; iStation < 2; iStation++)
{
for (int iPlate = 0; iPlate < 2; iPlate++)
{
Identifier thisId = helper->plate_id(iStation, iPlate, true);
IdentifierHash thisHash = helper->plate_hash(thisId);
IdentifierHash prevHash;
IdentifierHash nextHash;
Identifier prevId;
Identifier nextId;
int prevStation {-1};
int prevPlate {-1};
int nextStation {-1};
int nextPlate {-1};
int prevStat = helper->get_prev_in_z(thisHash, prevHash);
if (prevStat == 0)
{
prevStat = helper->get_id(prevHash, prevId, &context);
if (prevStat == 0)
{
prevStation = helper->station(prevId);
prevPlate = helper->plate(prevId);
}
}
int nextStat = helper->get_next_in_z(thisHash, nextHash);
if (nextStat == 0)
{
nextStat = helper->get_id(nextHash, nextId, &context);
if (nextStat == 0)
{
nextStation = helper->station(nextId);
nextPlate = helper->plate(nextId);
}
}
ATH_MSG_ALWAYS("Station/Plate " << iStation << "/" << iPlate <<
" (" << thisHash << ") " <<
" : prev = " << prevStation << "/" << prevPlate <<
" , next = " << nextStation << "/" << nextPlate );
}
}
}
else
{
ATH_MSG_ALWAYS("Failed to retrieve VetoID helper from DetStore.");
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
......
......@@ -150,8 +150,12 @@ public:
int pmt_max (const Identifier& id) const;
//@}
/// @name module eta/phi navigation
/// @name module navigation
//@{
/// Previous plate in z
int get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const;
/// Next plate in z
int get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const;
// /// Previous wafer hash in phi (return == 0 for neighbor found)
// int get_prev_in_phi (const IdentifierHash& id, IdentifierHash& prev) const;
// /// Next wafer hash in phi (return == 0 for neighbor found)
......@@ -260,6 +264,8 @@ private:
size_type m_pmt_hash_max;
// Range::field m_barrel_field;
id_vec m_plate_vec;
hash_vec m_prev_z_plate_vec;
hash_vec m_next_z_plate_vec;
// hash_vec m_prev_phi_wafer_vec;
// hash_vec m_next_phi_wafer_vec;
// hash_vec m_prev_eta_wafer_vec;
......
......@@ -303,6 +303,32 @@ VetoID::init_hashes(void)
return (0);
}
int
VetoID::get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const
{
unsigned short index = id;
if (index < m_prev_z_plate_vec.size())
{
if (m_prev_z_plate_vec[index] == NOT_VALID_HASH) return (1);
prev = m_prev_z_plate_vec[index];
return (0);
}
return (1);
}
int
VetoID::get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const
{
unsigned short index = id;
if (index < m_next_z_plate_vec.size())
{
if (m_next_z_plate_vec[index] == NOT_VALID_HASH) return (1);
next = m_next_z_plate_vec[index];
return (0);
}
return (1);
}
// int
// VetoID::get_prev_in_phi(const IdentifierHash& id, IdentifierHash& prev) const
// {
......@@ -371,17 +397,142 @@ VetoID::init_neighbors(void)
{
//
// create a vector(s) to retrieve the hashes for compact ids for
// wafer neighbors.
// plate neighbors.
//
MsgStream log(m_msgSvc, "VetoID");
if (m_msgSvc) {
log << MSG::DEBUG << "VetoID::init_neighbors not yet implemented" << endmsg;
}
else {
std::cout << " DEBUG VetoID::init_neighbors not yet implemented" << std::endl;
m_prev_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH);
m_next_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH);
for (unsigned int i = 0; i < m_full_plate_range.size(); i++)
{
const Range& range = m_full_plate_range[i];
const Range::field& station_field = range[m_STATION_INDEX];
const Range::field& plate_field = range[m_PLATE_INDEX];
Range::const_identifier_factory first = range.factory_begin();
Range::const_identifier_factory last = range.factory_end();
for (; first != last; ++first)
{
const ExpandedIdentifier& exp_id = (*first);
ExpandedIdentifier::element_type previous_plate;
ExpandedIdentifier::element_type next_plate;
ExpandedIdentifier::element_type previous_station;
ExpandedIdentifier::element_type next_station;
bool pplate = plate_field.get_previous(exp_id[m_PLATE_INDEX], previous_plate);
bool nplate = plate_field.get_next (exp_id[m_PLATE_INDEX], next_plate);
bool pstation = station_field.get_previous(exp_id[m_STATION_INDEX], previous_station);
bool nstation = station_field.get_next (exp_id[m_STATION_INDEX], next_station);
IdContext pcontext = plate_context();
IdentifierHash hash_id;
Identifier originalId = plate_id(exp_id[m_STATION_INDEX],
exp_id[m_PLATE_INDEX]);
if (get_hash(originalId, hash_id, &pcontext))
{
log << MSG::ERROR << " VetoID::init_neighbors - unable to get hash, exp/compact "
<< show_to_string(originalId, &pcontext)
<< " " << (std::string)m_full_plate_range << endmsg;
return (1);
}
// index for the subsequent arrays
unsigned short index = hash_id;
assert (hash_id < m_prev_z_plate_vec.size());
assert (hash_id < m_next_z_plate_vec.size());
if (pplate) {
// Get previous plate hash id
ExpandedIdentifier expId = exp_id;
expId[m_PLATE_INDEX] = previous_plate;
Identifier id = plate_id(expId[m_STATION_INDEX],
expId[m_PLATE_INDEX]);
if (get_hash(id, hash_id, &pcontext)) {
log << MSG::ERROR << " VetoID::init_neighbors - unable to get previous plate hash, exp/compact " << id.getString() << " "
<< endmsg;
return (1);
}
m_prev_z_plate_vec[index] = hash_id;
}
else if (pstation)
{
ExpandedIdentifier expId = exp_id;
expId[m_STATION_INDEX] = previous_station;
ExpandedIdentifier stationId;
stationId.add(expId[m_SCINT_INDEX]);
stationId.add(expId[m_VETO_INDEX]);
stationId.add(previous_station);
Range prefix;
MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate");
const Range::field& upstream_plate_field = range[m_PLATE_INDEX];
if (upstream_plate_field.has_maximum())
{
expId[m_PLATE_INDEX] = upstream_plate_field.get_maximum();
Identifier id = plate_id(expId[m_STATION_INDEX],
expId[m_PLATE_INDEX]);
if (get_hash(id, hash_id, &pcontext)) {
log << MSG::ERROR << " VetoID::init_neighbors - unable to get last plate hash from previous station, exp/compact " << id.getString() << " "
<< endmsg;
return (1);
}
m_prev_z_plate_vec[index] = hash_id;
}
else
{
log << MSG::ERROR << "VetoID::init_neighbors - unable to get plate_max for previous station, exp/compact " << originalId.getString() << " "
<< endmsg;
return (1);
}
}
if (nplate) {
// Get next plate hash id
ExpandedIdentifier expId = exp_id;
expId[m_PLATE_INDEX] = next_plate;
Identifier id = plate_id(expId[m_STATION_INDEX],
expId[m_PLATE_INDEX]);
if (get_hash(id, hash_id, &pcontext)) {
log << MSG::ERROR << " VetoID::init_neighbors - unable to get next plate hash, exp/compact " << id.getString() << " "
<< endmsg;
return (1);
}
m_next_z_plate_vec[index] = hash_id;
}
else if (nstation)
{
ExpandedIdentifier expId = exp_id;
expId[m_STATION_INDEX] = next_station;
ExpandedIdentifier stationId;
stationId.add(expId[m_SCINT_INDEX]);
stationId.add(expId[m_VETO_INDEX]);
stationId.add(next_station);
Range prefix;
MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate");
const Range::field& downstream_plate_field = range[m_PLATE_INDEX];
if (downstream_plate_field.has_minimum())
{
expId[m_PLATE_INDEX] = downstream_plate_field.get_minimum();
Identifier id = plate_id(expId[m_STATION_INDEX],
expId[m_PLATE_INDEX]);
if (get_hash(id, hash_id, &pcontext)) {
log << MSG::ERROR << " VetoID::init_neighbors - unable to get previous plate hash from next station, exp/compact " << id.getString() << " "
<< endmsg;
return (1);
}
m_next_z_plate_vec[index] = hash_id;
}
else
{
log << MSG::ERROR << "VetoID::init_neighbors - unable to get plate_min for next station, exp/compact " << originalId.getString() << " "
<< endmsg;
return (1);
}
}
}
}
// m_prev_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH);
// m_next_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment