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);
48 StatusCode
sc = detStore->retrieve(
m_idHelper, pixelIDName);
132 throw std::runtime_error(
"PixelDetectorManager: Error adding detector element.");
174 unsigned int barrelLayers = 0;
175 for (
int i =
numerology().numLayers() - 1; i >= 0; --i) {
184 unsigned int endcapLayers = 0;
185 for (
int i =
numerology().numDisks() - 1; i >= 0; --i) {
197 GeoVAlignmentStore* alignStore)
const
204 if (!idHash.
is_valid())
return false;
213 if (!element)
return false;
231 ATH_MSG_WARNING(
"Frames other than global or local are not supported.");
246 AlignableTransformMap::const_iterator iter;
259 GeoAlignableTransform *transform,
260 const GeoVPhysVol * child)
265 const GeoVFullPhysVol * childFPV =
dynamic_cast<const GeoVFullPhysVol *
>(child);
267 ATH_MSG_ERROR(
"Child of alignable transform is not a full physical volume");
276 GeoAlignableTransform *transform,
277 const GeoVFullPhysVol * child)
314 bool alignmentChange =
false;
316 std::string alignfolder;
320 ATH_MSG_INFO(
"Processing IBLDist alignment container with key (" << key <<
")"
321 <<
"and alignment folder pointing to " << alignfolder);
324 if (
numerology().numPhiModulesForLayer(0)<14) nstaves = 14;
327 std::vector<float> ibldist;
328 std::vector<float> iblbaseline;
329 ibldist.resize(nstaves);
330 iblbaseline.resize(nstaves);
333 if (StatusCode::SUCCESS==
m_detStore->retrieve(atrlistcol,key)) {
336 const coral::AttributeList& atrlist=citr->second;
337 ibldist[atrlist[
"stave"].data<
int>()] = atrlist[
"mag"].
data<float>();
338 iblbaseline[atrlist[
"stave"].data<
int>()] = atrlist[
"base"].
data<float>();
341 <<
" ,stave: " << atrlist[
"stave"].data<
int>()
342 <<
" ,mag: " << atrlist[
"mag"].data<
float>()
343 <<
" ,base: " << atrlist[
"base"].data<
float>());
348 << key <<
" - no IBL bowing alignment");
349 return alignmentChange;
365 ATH_MSG_ERROR(
"Cannot find AlignableTransformContainer for key "
366 << key <<
" - no misalignment");
368 throw std::runtime_error(
"Unable to apply Inner Detector alignments");
373 << key <<
" is empty. Probably due to out of range IOV");
375 throw std::runtime_error(
"Unable to apply Inner Detector alignments.");
378 std::string IBLalignfolder = alignfolder;
379 IBLalignfolder.append(
"/PIXB1");
382 if (!( pat->tag()==IBLalignfolder &&
385 ATH_MSG_DEBUG(
"IBLDist; ignoring collections " << pat->tag());
390 trans_iter != transformCollection->
end();
394 <<
getIdHelper()->show_to_string(trans_iter->identify()));
399 <<
getIdHelper()->show_to_string(trans_iter->identify()));
400 ATH_MSG_WARNING(
"No IBLDist corrections can be applied for invalid HashID's - exiting");
406 double z = center[2];
407 const double y0y0 = 366.5*366.5;
413 ATH_MSG_DEBUG(
"Total IBL-module Tx shift (baseline+bowing): " << basex+bowx);
414 if ( (basex+bowx)==0 )
continue;
423 if (
msgLvl(MSG::VERBOSE)) {
426 ATH_MSG_LVL_NOCHK(MSG::VERBOSE,
"Original alignable Transformation from StoreGate:");
435 trans_iter->identify(),
441 ATH_MSG_DEBUG(
"Cannot set AlignableTransform for identifier."
442 <<
getIdHelper()->show_to_string(trans_iter->identify())
443 <<
" at level 0 for IBLDist bowing deformation");
445 alignmentChange = (alignmentChange || status);
450 return alignmentChange;
455 GeoVAlignmentStore* alignStore)
const {
456 bool alignmentChange =
false;
458 ATH_MSG_INFO(
"Processing IBLDist alignment container with key " << key);
461 return alignmentChange;
465 if (
numerology().numPhiModulesForLayer(0) < 14)
470 std::vector<float> ibldist;
471 std::vector<float> iblbaseline;
472 ibldist.resize(nstaves);
473 iblbaseline.resize(nstaves);
477 citr != obj->end(); ++citr) {
479 const coral::AttributeList &atrlist = citr->second;
480 ibldist[atrlist[
"stave"].data<
int>()] = atrlist[
"mag"].
data<float>();
481 iblbaseline[atrlist[
"stave"].data<
int>()] = atrlist[
"base"].
data<float>();
484 <<
", stave: " << atrlist[
"stave"].data<
int>()
485 <<
", mag: " << atrlist[
"mag"].data<
float>()
486 <<
", base: " << atrlist[
"base"].data<
float>());
502 if(!detElem->isInnermostPixelLayer()) {
515 "invalid HashID's - exiting ");
523 double z = center[2];
524 const double y0y0 = 366.5 * 366.5;
526 double bowx = ibldist[stave] * (
z *
z - y0y0) / y0y0;
527 double basex = iblbaseline[stave];
530 ATH_MSG_DEBUG(
"Total IBL-module Tx shift (baseline+bowing): " << basex + bowx);
532 if ((basex + bowx) == 0) {
537 Amg::RotationMatrix3D::Identity();
542 const GeoTrf::Transform3D* currentDelta = alignStore->getDelta(eat->
alignableTransform());
543 if (currentDelta ==
nullptr) {
544 ATH_MSG_ERROR(
"Have IBL Dist for element which does not have an alignment delta."
545 <<
" This indicates inconsistent alignment data");
549 HepGeom::Transform3D recoToHitTransform = detElem->recoToHitTransform();
552 ATH_MSG_VERBOSE(
"Previous delta for " << repr <<
":\n" << currentDelta->matrix());
553 ATH_MSG_VERBOSE(
"Bowing-only delta for " << repr <<
":\n" << shift.matrix());
570 alignmentChange |= status;
573 return alignmentChange;
580 bool alignmentChange =
false;
582 ATH_MSG_INFO(
"Processing new global alignment containers with key " << key
583 <<
" in the " << frame <<
" frame at level " << level);
589 ATH_MSG_INFO(
"Read alignment from detector store with key " << key);
590 if (StatusCode::SUCCESS!=
m_detStore->retrieve(atrlistcol,key)) {
592 << key <<
" - no new global alignment");
593 return alignmentChange;
598 return alignmentChange;
604 const coral::AttributeList& atrlist=citr->second;
606 if (atrlist[
"det"].
data<int>()!=1)
continue;
615 if (!(
getIdHelper()->wafer_hash(ident)).is_valid()){
617 ATH_MSG_WARNING(
"No global alignment corrections can be applied for invalid HashID's - exiting");
624 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
630 <<
" ,det: " << atrlist[
"det"].data<
int>()
631 <<
" ,bec: " << atrlist[
"bec"].data<
int>()
632 <<
" ,layer: " << atrlist[
"layer"].data<
int>()
633 <<
" ,ring: " << atrlist[
"ring"].data<
int>()
634 <<
" ,sector: " << atrlist[
"sector"].data<
int>()
635 <<
" ,Tx: " << atrlist[
"Tx"].data<
float>()
636 <<
" ,Ty: " << atrlist[
"Ty"].data<
float>()
637 <<
" ,Tz: " << atrlist[
"Tz"].data<
float>()
638 <<
" ,Rx: " << atrlist[
"Rx"].data<
float>()
639 <<
" ,Ry: " << atrlist[
"Ry"].data<
float>()
640 <<
" ,Rz: " << atrlist[
"Rz"].data<
float>());
650 ATH_MSG_DEBUG(
"Cannot set AlignableTransform for identifier."
652 <<
" at level " << level <<
" for new global DB");
655 alignmentChange = (alignmentChange || status);
658 return alignmentChange;
666 ATH_MSG_LVL_NOCHK(level,
" - translation: " << tr.translation().x() <<
" " <<tr.translation().y() <<
" " <<tr.translation().z());
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_LVL_NOCHK(lvl, x)
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
GeoIntrusivePtr< T > GeoNodePtr
char data[hepevt_bytes_allocation_ATLAS]
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.
bool is_valid() const
Check if id is in a valid state.
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.
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