10#include "Identifier/Identifier.h"
15#include "GeoModelKernel/GeoVAlignmentStore.h"
26 const std::string& name,
27 const std::string& pixelIDName)
35 if (pixelIDName ==
"PLR_ID") {
36 const PLR_ID* plr_idHelper;
37 StatusCode
sc = detStore->
retrieve(plr_idHelper, pixelIDName);
127 throw std::runtime_error(
"PixelDetectorManager: Error adding detector element.");
146 result =
m_idHelper->get_next_in_eta(idHash, idHashOther);
149 result =
m_idHelper->get_prev_in_eta(idHash, idHashOther);
152 result =
m_idHelper->get_next_in_phi(idHash, idHashOther);
155 result =
m_idHelper->get_prev_in_phi(idHash, idHashOther);
169 unsigned int barrelLayers = 0;
170 for (
int i =
numerology().numLayers() - 1; i >= 0; --i) {
179 unsigned int endcapLayers = 0;
180 for (
int i =
numerology().numDisks() - 1; i >= 0; --i) {
192 GeoVAlignmentStore* alignStore)
const
199 if (!idHash.
is_valid())
return false;
208 if (!element)
return false;
226 ATH_MSG_WARNING(
"Frames other than global or local are not supported.");
241 AlignableTransformMap::const_iterator iter;
254 GeoAlignableTransform *transform,
255 const GeoVPhysVol * child)
260 const GeoVFullPhysVol * childFPV =
dynamic_cast<const GeoVFullPhysVol *
>(child);
262 ATH_MSG_ERROR(
"Child of alignable transform is not a full physical volume");
271 GeoAlignableTransform *transform,
272 const GeoVFullPhysVol * child)
309 bool alignmentChange =
false;
311 std::string alignfolder;
315 ATH_MSG_INFO(
"Processing IBLDist alignment container with key (" << key <<
")"
316 <<
"and alignment folder pointing to " << alignfolder);
319 if (
numerology().numPhiModulesForLayer(0)<14) nstaves = 14;
322 std::vector<float> ibldist;
323 std::vector<float> iblbaseline;
324 ibldist.resize(nstaves);
325 iblbaseline.resize(nstaves);
328 if (StatusCode::SUCCESS==
m_detStore->retrieve(atrlistcol,key)) {
331 const coral::AttributeList& atrlist=citr->second;
332 ibldist[atrlist[
"stave"].data<
int>()] = atrlist[
"mag"].data<float>();
333 iblbaseline[atrlist[
"stave"].data<
int>()] = atrlist[
"base"].data<float>();
336 <<
" ,stave: " << atrlist[
"stave"].data<
int>()
337 <<
" ,mag: " << atrlist[
"mag"].data<
float>()
338 <<
" ,base: " << atrlist[
"base"].data<
float>());
343 << key <<
" - no IBL bowing alignment");
344 return alignmentChange;
359 if (StatusCode::SUCCESS!=
m_detStore->retrieve(container, alignfolder)) {
360 ATH_MSG_ERROR(
"Cannot find AlignableTransformContainer for key "
361 << key <<
" - no misalignment");
363 throw std::runtime_error(
"Unable to apply Inner Detector alignments");
366 if (container->empty()) {
368 << key <<
" is empty. Probably due to out of range IOV");
370 throw std::runtime_error(
"Unable to apply Inner Detector alignments.");
373 std::string IBLalignfolder = std::move(alignfolder);
374 IBLalignfolder.append(
"/PIXB1");
375 for (
const auto *pat : *container)
377 if (!( pat->tag()==IBLalignfolder &&
380 ATH_MSG_DEBUG(
"IBLDist; ignoring collections " << pat->tag());
385 trans_iter != transformCollection->
end();
389 <<
getIdHelper()->show_to_string(trans_iter->identify()));
394 <<
getIdHelper()->show_to_string(trans_iter->identify()));
395 ATH_MSG_WARNING(
"No IBLDist corrections can be applied for invalid HashID's - exiting");
401 double z = center[2];
402 const double y0y0 = 366.5*366.5;
408 ATH_MSG_DEBUG(
"Total IBL-module Tx shift (baseline+bowing): " << basex+bowx);
409 if ( (basex+bowx)==0 )
continue;
418 if (
msgLvl(MSG::VERBOSE)) {
421 ATH_MSG_LVL_NOCHK(MSG::VERBOSE,
"Original alignable Transformation from StoreGate:");
430 trans_iter->identify(),
436 ATH_MSG_DEBUG(
"Cannot set AlignableTransform for identifier."
437 <<
getIdHelper()->show_to_string(trans_iter->identify())
438 <<
" at level 0 for IBLDist bowing deformation");
440 alignmentChange = (alignmentChange || status);
445 return alignmentChange;
450 GeoVAlignmentStore* alignStore)
const {
451 bool alignmentChange =
false;
453 ATH_MSG_INFO(
"Processing IBLDist alignment container with key " << key);
456 return alignmentChange;
460 if (
numerology().numPhiModulesForLayer(0) < 14)
465 std::vector<float> ibldist;
466 std::vector<float> iblbaseline;
467 ibldist.resize(nstaves);
468 iblbaseline.resize(nstaves);
472 citr != obj->end(); ++citr) {
474 const coral::AttributeList &atrlist = citr->second;
475 ibldist[atrlist[
"stave"].data<
int>()] = atrlist[
"mag"].data<float>();
476 iblbaseline[atrlist[
"stave"].data<
int>()] = atrlist[
"base"].data<float>();
479 <<
", stave: " << atrlist[
"stave"].data<
int>()
480 <<
", mag: " << atrlist[
"mag"].data<
float>()
481 <<
", base: " << atrlist[
"base"].data<
float>());
497 if(!detElem->isInnermostPixelLayer()) {
510 "invalid HashID's - exiting ");
518 double z = center[2];
519 const double y0y0 = 366.5 * 366.5;
521 double bowx = ibldist[stave] * (
z *
z - y0y0) / y0y0;
522 double basex = iblbaseline[stave];
525 ATH_MSG_DEBUG(
"Total IBL-module Tx shift (baseline+bowing): " << basex + bowx);
527 if ((basex + bowx) == 0) {
532 Amg::RotationMatrix3D::Identity();
537 const GeoTrf::Transform3D* currentDelta = alignStore->getDelta(eat->
alignableTransform());
538 if (currentDelta ==
nullptr) {
539 ATH_MSG_ERROR(
"Have IBL Dist for element which does not have an alignment delta."
540 <<
" This indicates inconsistent alignment data");
544 HepGeom::Transform3D recoToHitTransform = detElem->recoToHitTransform();
547 ATH_MSG_VERBOSE(
"Previous delta for " << repr <<
":\n" << currentDelta->matrix());
548 ATH_MSG_VERBOSE(
"Bowing-only delta for " << repr <<
":\n" << shift.matrix());
565 alignmentChange |= status;
568 return alignmentChange;
575 bool alignmentChange =
false;
577 ATH_MSG_INFO(
"Processing new global alignment containers with key " << key
578 <<
" in the " << frame <<
" frame at level " << level);
584 ATH_MSG_INFO(
"Read alignment from detector store with key " << key);
585 if (StatusCode::SUCCESS!=
m_detStore->retrieve(atrlistcol,key)) {
587 << key <<
" - no new global alignment");
588 return alignmentChange;
593 return alignmentChange;
599 const coral::AttributeList& atrlist=citr->second;
601 if (atrlist[
"det"].data<int>()!=1)
continue;
604 atrlist[
"layer"].data<int>(),
605 atrlist[
"ring"].data<int>(),
606 atrlist[
"sector"].data<int>());
610 if (!(
getIdHelper()->wafer_hash(ident)).is_valid()){
612 ATH_MSG_WARNING(
"No global alignment corrections can be applied for invalid HashID's - exiting");
618 Amg::Translation3D newtranslation(atrlist[
"Tx"].data<float>(),atrlist[
"Ty"].data<float>(),atrlist[
"Tz"].data<float>());
619 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
625 <<
" ,det: " << atrlist[
"det"].data<
int>()
626 <<
" ,bec: " << atrlist[
"bec"].data<
int>()
627 <<
" ,layer: " << atrlist[
"layer"].data<
int>()
628 <<
" ,ring: " << atrlist[
"ring"].data<
int>()
629 <<
" ,sector: " << atrlist[
"sector"].data<
int>()
630 <<
" ,Tx: " << atrlist[
"Tx"].data<
float>()
631 <<
" ,Ty: " << atrlist[
"Ty"].data<
float>()
632 <<
" ,Tz: " << atrlist[
"Tz"].data<
float>()
633 <<
" ,Rx: " << atrlist[
"Rx"].data<
float>()
634 <<
" ,Ry: " << atrlist[
"Ry"].data<
float>()
635 <<
" ,Rz: " << atrlist[
"Rz"].data<
float>());
645 ATH_MSG_DEBUG(
"Cannot set AlignableTransform for identifier."
647 <<
" at level " << level <<
" for new global DB");
650 alignmentChange = (alignmentChange || status);
653 return alignmentChange;
661 ATH_MSG_LVL_NOCHK(level,
" - translation: " << tr.translation().x() <<
" " <<tr.translation().y() <<
" " <<tr.translation().z());
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_LVL_NOCHK(lvl, x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
GeoIntrusivePtr< T > GeoNodePtr
bool msgLvl(const MSG::Level lvl) const
Test the output level.
bool is_pixel(Identifier id) const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
DataModel_detail::iterator< DataVector > iterator
This is a "hash" representation of an Identifier.
constexpr bool is_valid() const
StoreGateSvc * m_detStore
std::atomic_bool m_suppressWarnings
std::vector< std::unique_ptr< ExtendedAlignableTransform > > m_alignableTransforms
virtual const PixelModuleDesign * getPixelDesign(int i) const
Access to module design, Casts to PixelModuleDesign.
void printTransform(MSG::Level level, const Amg::Transform3D &tr) const
void addTreeTop(const PVConstLink &vol)
Add a Tree top:
virtual void addDetectorElement(SiDetectorElement *element) override
Add elememts.
bool processSpecialAlignment(const std::string &, InDetDD::AlignFolderType) override
Process new IBLDist DB folder.
virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const override
std::vector< PVConstLink > m_volume
virtual const PixelID * getIdHelper() const override
PixelDetectorManager(StoreGateSvc *detStore)
Constructor.
virtual SiDetectorElementCollection::const_iterator getDetectorElementEnd() const override
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collection via Iterators
virtual unsigned int getNumTreeTops() const override
Access to raw geometry:
const PixelID * m_idHelper
SiDetectorElementCollection m_elementCollection
bool m_isLogical
This variable switches the how the local alignment corrections are applied If true they will be calcu...
unsigned int getEndcapLayers() const
Layers built.
virtual bool setAlignableTransformDelta(int level, const Identifier &id, const Amg::Transform3D &delta, FrameType frame, GeoVAlignmentStore *alignStore) const override
implements the main alignment update for delta transforms in different frames, it translates into the...
virtual void addAlignableTransform(int level, const Identifier &id, GeoAlignableTransform *xf, const GeoVFullPhysVol *child)
Add alignable transforms.
std::vector< AlignableTransformMap > m_higherAlignableTransforms
unsigned int getBarrelLayers() const
Layers built.
virtual void initNeighbours() override
Initialize the neighbours.
virtual bool processGlobalAlignment(const std::string &, int level, FrameType frame, const CondAttrListCollection *obj, GeoVAlignmentStore *alignStore) const override
Process new global DB folders for L1 and L2.
virtual PVConstLink getTreeTop(unsigned int i) const override
virtual bool identifierBelongs(const Identifier &id) const override
Check identifier is for this detector.
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Class used to describe the design of a module (diode segmentation and readout scheme).
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
void setPrevInEta(const SiDetectorElement *element)
void setPrevInPhi(const SiDetectorElement *element)
void setNextInEta(const SiDetectorElement *element)
void setNextInPhi(const SiDetectorElement *element)
const SiNumerology & numerology() const
Access Numerology.
SiDetectorManager(StoreGateSvc *detStore, const std::string &name)
const SiDetectorDesign * getDesign(int i) const
static bool setAlignableTransformGlobalDelta(ExtendedAlignableTransform *extXF, const Amg::Transform3D &delta, GeoVAlignmentStore *alignStore=nullptr)
Helper method to set delta transform from a global delta - Amg interface.
static bool setAlignableTransformLocalDelta(ExtendedAlignableTransform *extXF, const Amg::Transform3D &localToGlobalXF, const Amg::Transform3D &delta, GeoVAlignmentStore *alignStore=nullptr)
Helper method to set delta transform from a local delta - Amg interface.
bool useLayer(int layer) const
Check if layer exists.
bool useDisk(int disk) const
Check if disk exists.
int numPhiModulesForLayer(int layer) const
Number of sectors in phi for a layer.
const Amg::Transform3D defTransform() const
virtual const Amg::Transform3D & transform() const override final
Return local to global transform.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual void updateCache() const
Recalculate cached values.
This is a Identifier helper class for the PLR subdetector.
This is an Identifier helper class for the Pixel subdetector.
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
int phi_module(const Identifier &id) const
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Eigen::AngleAxisd AngleAxis3D
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
const int FIRST_HIGHER_LEVEL