7#include "CLHEP/Units/SystemOfUnits.h"
17#include "Identifier/Identifier.h"
92 return StatusCode::SUCCESS;
104 return StatusCode::SUCCESS;
108 const bool useConditionStore = not accessDuringInitialization;
110 if (useConditionStore) {
115 if (elements==
nullptr) {
121 elements =
m_manager->getDetectorElementCollection();
131 if (!element)
continue;
137 ATH_MSG_ALWAYS(
" center (x,y,z) = " << element->center().x() <<
"," << element->center().y() <<
"," << element->center().z());
138 ATH_MSG_ALWAYS(
" center (r,phi,z) = " << element->center().perp() <<
"," << element->center().phi() <<
"," <<element->center().z());
142 ATH_MSG_ALWAYS(
" global (r,phi,z) hit position of (1,1,0) = " <<element->globalPositionHit(
Amg::Vector3D(1,1,0)).perp() <<
"," << element->globalPositionHit(
Amg::Vector3D(1,1,0)).phi() <<
","<< element->globalPositionHit(
Amg::Vector3D(1,1,0)).z());
143 ATH_MSG_ALWAYS(
" global (r,phi,z) hit position of (-1,-1,0) = " <<element->globalPositionHit(
Amg::Vector3D(-1,-1,0)).perp() <<
"," << element->globalPositionHit(
Amg::Vector3D(-1,-1,0)).phi() <<
","<< element->globalPositionHit(
Amg::Vector3D(-1,-1,0)).z());
148 ATH_MSG_ALWAYS(
" Normal = " <<element->normal().perp() <<
"," << element->normal().phi() <<
","<< element->normal().z());
149 ATH_MSG_ALWAYS(
" sin(tilt), sin(stereo) = " << element->sinTilt() <<
" "
150 << element->sinStereo());
152 << element->width()/CLHEP::mm <<
" "
153 << element->minWidth()/CLHEP::mm <<
" "
154 << element->maxWidth()/CLHEP::mm <<
" "
155 << element->length()/CLHEP::mm);
160 const EventContext &ctx = Gaudi::Hive::currentContext();
161 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
169 ATH_MSG_ALWAYS(
" HashId, Id : " << hashId <<
"\t" << element->identify().getString());
182 if (useConditionStore) {
185 elementtest1 = elements->getDetectorElement(
m_pixelIdHelper->wafer_hash(element->identify()));
187 elementtest1 = elements->getDetectorElement(
m_sctIdHelper->wafer_hash(element->identify()));
189 elementtest2 = elements->getDetectorElement(hashId);
191 elementtest1 =
m_manager->getDetectorElement(element->identify());
192 elementtest2 =
m_manager->getDetectorElement(hashId);
195 if (idHashTest != hashId) {
ATH_MSG_ALWAYS(
" Id test 1 FAILED!"); idOK =
false;}
196 if (idTest != element->identify()) {
ATH_MSG_ALWAYS(
" Id test 2 FAILED!"); idOK =
false;}
197 if (elementtest1 != element) {
ATH_MSG_ALWAYS(
" Id test 3 FAILED!"); idOK =
false;}
198 if (elementtest2 != element) {
ATH_MSG_ALWAYS(
" Id test 4 FAILED!"); idOK =
false;}
201 const GeoTrf::Transform3D mytrf = element->transform();
202 const GeoTrf::Transform3D mytrfhit = element->transformHit();
204 ATH_MSG_ALWAYS(
"|"<<mytrf(2,0)<<
","<<mytrf(2,1)<<
","<<mytrf(2,2)<<
"|");
205 ATH_MSG_ALWAYS(
"|"<<mytrf(1,0)<<
","<<mytrf(1,1)<<
","<<mytrf(1,2)<<
"|");
206 ATH_MSG_ALWAYS(
"|"<<mytrf(0,0)<<
","<<mytrf(0,1)<<
","<<mytrf(0,2)<<
"|");
209 ATH_MSG_ALWAYS(
"|"<<mytrfhit(2,0)<<
","<<mytrfhit(2,1)<<
","<<mytrfhit(2,2)<<
"|");
210 ATH_MSG_ALWAYS(
"|"<<mytrfhit(1,0)<<
","<<mytrfhit(1,1)<<
","<<mytrfhit(1,2)<<
"|");
211 ATH_MSG_ALWAYS(
"|"<<mytrfhit(0,0)<<
","<<mytrfhit(0,1)<<
","<<mytrfhit(0,2)<<
"|");
216 if(element->depthDirection())
ATH_MSG_ALWAYS(
"Depth Direction True");
225 if(std::abs(element->depthAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD DEPTH DIRECTION!");
226 if(std::abs(element->etaAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD ETA DIRECTION!");
227 if(std::abs(element->phiAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD PHI DIRECTION!");
238 int barrelCountError = 0;
240 for (
int iBarrelIndex = 0; iBarrelIndex < siNumerology.
numBarrels(); iBarrelIndex++) {
241 int iBarrel = siNumerology.
barrelId(iBarrelIndex);
244 for (
int iLayer = 0; iLayer < siNumerology.
numLayers(); iLayer++) {
252 for (
int iSide = 0; iSide < nSides; iSide++) {
257 id =
m_sctIdHelper->wafer_id(iBarrel,iLayer,iPhi,iEta,iSide);
260 if (useConditionStore) {
268 element =
m_manager->getDetectorElement(
id);
286 int endcapCountError = 0;
288 for (
int iEndcapIndex = 0; iEndcapIndex < siNumerology.
numEndcaps(); iEndcapIndex++) {
289 int iEndcap = siNumerology.
endcapId(iEndcapIndex);
292 for (
int iDisk = 0; iDisk < siNumerology.
numDisks(); iDisk++) {
296 for (
int iEta = 0; iEta < siNumerology.
numRingsForDisk(iDisk); iEta++) {
300 for (
int iSide = 0; iSide < nSides; iSide++) {
342 const bool useConditionStore = (
m_managerName ==
"SCT" and (not accessDuringInitialization));
344 if (useConditionStore) {
348 if (elements==
nullptr) {
359 std::vector<SiCellId> cellIds;
360 std::vector<Amg::Vector2D> positions;
367 cellIds.emplace_back(32,8);
369 for (
int i(151);i != 176; ++i){
370 cellIds.emplace_back(i,8);
372 cellIds.emplace_back(-1,1);
373 cellIds.emplace_back(0,1);
374 cellIds.emplace_back(1,-1);
375 cellIds.emplace_back(1,0);
376 cellIds.emplace_back(327,1);
377 cellIds.emplace_back(328,1);
378 cellIds.emplace_back(1,143);
379 cellIds.emplace_back(1,144);
380 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
390 cellIds.emplace_back(32,8);
391 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
399 cellIds.emplace_back(182,75);
400 positions.emplace_back(0*CLHEP::mm, 0*CLHEP::mm);
401 positions.emplace_back(30.4*CLHEP::mm, 8.2*CLHEP::mm);
402 positions.emplace_back(12*CLHEP::mm, -8.15*CLHEP::mm);
403 positions.emplace_back(12*CLHEP::mm, -8.25*CLHEP::mm);
404 positions.emplace_back(12*CLHEP::mm, -8.35*CLHEP::mm);
411 std::vector<SiCellId> cellIds;
412 std::vector<Amg::Vector2D> positions;
420 id = idHelper->
wafer_id(0,1,15,-3,0);
423 cellIds.emplace_back(32);
424 cellIds.emplace_back(1);
425 cellIds.emplace_back(0);
427 cellIds.emplace_back(-1);
428 cellIds.emplace_back(-2);
429 cellIds.emplace_back(-3);
431 cellIds.emplace_back(767);
432 cellIds.emplace_back(768);
433 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
440 id = idHelper->
wafer_id(0,1,15,-3,1);
443 cellIds.emplace_back(32);
444 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
451 id = idHelper->
wafer_id(2,3,15,0,0);
454 cellIds.emplace_back(532);
455 cellIds.emplace_back(0);
457 cellIds.emplace_back(767);
458 cellIds.emplace_back(768);
459 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
460 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
461 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
467 id = idHelper->
wafer_id(2,3,15,0,1);
470 cellIds.emplace_back(532);
471 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
472 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
473 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
480 id = idHelper->
wafer_id(2,1,15,1,0);
483 cellIds.emplace_back(532);
484 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
491 id = idHelper->
wafer_id(2,7,15,1,0);
494 cellIds.emplace_back(532);
495 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
502 id = idHelper->
wafer_id(2,1,15,2,0);
505 cellIds.emplace_back(532);
506 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
517 if (elementsC==
nullptr) {
525 if (elementsC->
size()!=elementsM->
size()) {
526 ATH_MSG_FATAL(
"Sizes of SiDetectorElementCollections are different");
532 for (; elementM!=elementMe; ++elementC, ++elementM) {
533 auto diff = (*elementC)->center()-(*elementM)->center();
537 ATH_MSG_ALWAYS(
"center (store) " << (*elementC)->center().transpose());
538 ATH_MSG_ALWAYS(
"center (manager) " << (*elementM)->center().transpose());
547 const std::vector<SiCellId> & cellIdVec,
548 const std::vector<Amg::Vector2D> & positionsVec,
559 element =
m_manager->getDetectorElement(
id);
564 ATH_MSG_ALWAYS(
" width, minWidth, maxWidth, length, thickness (mm) = "
565 << element->
width()/CLHEP::mm <<
" "
566 << element->
minWidth()/CLHEP::mm <<
" "
567 << element->
maxWidth()/CLHEP::mm <<
" "
568 << element->
length()/CLHEP::mm <<
" "
573 ATH_MSG_ALWAYS(
" rMin, rMax, zMin, zMax (mm), phiMin, phiMax (deg) = "
574 << element->
rMin()/CLHEP::mm <<
" "
575 << element->
rMax()/CLHEP::mm <<
" "
576 << element->
zMin()/CLHEP::mm <<
" "
577 << element->
zMax()/CLHEP::mm <<
" "
578 << element->
phiMin()/CLHEP::degree <<
" "
579 << element->
phiMax()/CLHEP::degree
582 << element->
center() <<
" "
583 << element->
normal() <<
" "
588 <<
", phi (deg) = " << element->
center().phi()/CLHEP::deg);
590 const EventContext &ctx = Gaudi::Hive::currentContext();
591 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
596 ATH_MSG_ALWAYS(
" sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
598 << asin(element->
sinTilt())/CLHEP::degree <<
", "
600 << asin(element->
sinStereo())/CLHEP::degree);
608 for (
unsigned int iTestCell = 0; iTestCell < cellIdVec.size(); iTestCell++) {
609 SiCellId cellId = cellIdVec[iTestCell];
619 ATH_MSG_ALWAYS(
" extracted cell id [phiIndex.etaIndex] = " << cellId2);
623 ATH_MSG_ALWAYS(
" raw localPosition (using cell id) (xPhi,xEta) = "
624 << localPosRaw1.
xPhi() <<
", " << localPosRaw1.
xEta());
625 ATH_MSG_ALWAYS(
" raw localPosition (using full id) (xPhi,xEta) = "
626 << localPosRaw2.
xPhi() <<
", " << localPosRaw2.
xEta());
632 msg(MSG::ALWAYS) <<
" Connected cells";
635 msg(MSG::ALWAYS) <<
", " << iCell <<
": " << connectedCellId;
640 for (
unsigned int iTestPos = 0; iTestPos < positionsVec.size(); iTestPos++) {
642 ATH_MSG_ALWAYS(
" Requested local pos (xPhi,xEta) = " << localPosOrig.
xPhi() <<
", " << localPosOrig.
xEta());
645 ATH_MSG_ALWAYS(
" Global pos = " << globalPos <<
", r (mm) = " << globalPos.perp()/CLHEP::mm<<
", phi (deg) = " << globalPos.phi()/CLHEP::degree);
651 double tolerance = 100*CLHEP::micrometer;
654 <<
" (in,out,nearBoundary,mayIntersect) : "
655 << intersectState.
in() <<
","
656 << intersectState.
out() <<
","
665 ATH_MSG_ALWAYS(
" using global position sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
666 << element->
sinTilt(globalPos) <<
", "
667 << asin(element->
sinTilt(globalPos))/CLHEP::degree <<
", "
669 << asin(element->
sinStereo(globalPos))/CLHEP::degree);
694 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ALWAYS(x)
This is an Identifier helper class for the Pixel subdetector.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
This is an Identifier helper class for the SCT subdetector.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
void show(Identifier id, const IdContext *context=0, char sep='.') const
Short print out of any identifier (optionally provide separation character - default is '.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
virtual SiCellId cellIdInRange(const SiCellId &cellId) const =0
Check if cell is in range.
Identifier for the strip or pixel cell.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
double phiPitch() const
Pitch (inline methods).
bool nearBondGap(const Amg::Vector2D &localPosition, double etaTol) const
Test if near bond gap within tolerances.
const SiDetectorElement * prevInPhi() const
double sinStereo() const
Compute sin(stereo angle) at a given position: at center.
const SiDetectorElement * nextInPhi() const
const SiDetectorElement * otherSide() const
Useful for SCT only.
const SiDetectorElement * prevInEta() const
double sinTilt() const
Compute sin(tilt angle) at a given position: at center.
virtual Identifier identifierFromCellId(const SiCellId &cellId) const override final
Identifier <-> SiCellId (ie strip number or pixel eta_index,phi_index) Identifier from SiCellId (ie s...
const SiDetectorElement * nextInEta() const
class to run intersection tests
bool mayIntersect() const
bool nearBoundary() const
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
Class to extract numerology for Pixel and SCT.
int numRingsForDisk(int disk) const
Number of rings (ie eta_module) in a disk.
bool useLayer(int layer) const
Check if layer exists.
bool useDisk(int disk) const
Check if disk exists.
int maxNumEndcapRings() const
Maximum number of rings in a disk.
int barrelId(int index) const
Barrel/endcap identifier for each barrel.
int numEtaModulesForLayer(int layer) const
Number of sectors in eta for a layer.
int maxNumPhiCells() const
Maximum number of cells in phi direction.
int numEndcaps() const
Number of endcaps.
int maxNumEtaCells() const
Maximum number of cells in eta direction.
int endEtaModuleForLayer(int layer) const
Last eta_module number + 1.
int maxNumStrips() const
Maximum number of strips.
int numLayers() const
Number of layers.
int numPhiModulesForLayer(int layer) const
Number of sectors in phi for a layer.
int numBarrels() const
Number of barrels.
int maxNumBarrelEta() const
Maximum number of modules in a barrel stave.
int beginEtaModuleForLayer(int layer) const
First eta_module number for a layer.
int numPhiModulesForDiskRing(int disk, int ring) const
Number of sectors in phi for a ring in a disk.
int endcapId(int index) const
Barrel/endcap identifier for each endcap.
bool skipEtaZeroForLayer(int layer) const
Check if eta_module=0 exists.
int numDisks() const
Number of disks.
double length() const
Length in eta direction (z - barrel, r - endcap).
SiCellId connectedCell(const SiCellId cellId, int number) const
Get the cell ids sharing the readout for this cell.
SiCellId cellIdOfPosition(const Amg::Vector2D &localPos) const
As in previous method but returns SiCellId.
const Amg::Vector3D & etaAxis() const
Amg::Vector2D localPosition(const HepGeom::Point3D< double > &globalPosition) const
transform a global position into a 2D local position (reconstruction frame) (inline)
double width() const
Methods from design (inline).
virtual const Amg::Vector3D & normal() const override final
Get reconstruction local normal axes in global frame.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
int numberOfConnectedCells(const SiCellId cellId) const
Test if readout cell has more than one diode associated with it.
double maxWidth() const
Max width.
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
virtual const Amg::Vector3D & center() const override final
Center in global coordinates.
SiIntersect inDetector(const Amg::Vector2D &localPosition, double phiTol, double etaTol) const
Test that it is in the active region.
virtual Identifier identify() const override final
identifier of this detector element (inline)
const Amg::Vector3D & phiAxis() const
double minWidth() const
Min width.
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline).
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
double etaPitch() const
Pitch (inline methods).
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.
bool m_printProbePositions
const SCT_ID * m_sctIdHelper
StatusCode execute(const EventContext &ctx)
Execute method.
ReadSiDetectorElements(const std::string &name, ISvcLocator *pSvcLocator)
const InDetDD::SiDetectorManager * m_manager
ToolHandle< ISiLorentzAngleTool > m_siLorentzAngleTool
ToolHandle< ISiliconConditionsTool > m_siConditionsTool
std::string m_managerName
void printRandomAccess(const bool accessDuringInitialization)
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_detEleCollKey
const PixelID * m_pixelIdHelper
bool m_useConditionsTools
const AtlasDetectorID * m_idHelper
void testElement(const Identifier &id, const std::vector< InDetDD::SiCellId > &cellIdVec, const std::vector< Amg::Vector2D > &positionsVec, const InDetDD::SiDetectorElementCollection *elements=nullptr) const
std::string printElementId(const InDetDD::SiDetectorElement *element) const
void printAllElements(const bool accessDuringInitialization)
void printDifference() const
This is an Identifier helper class for the SCT subdetector.
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
const_pointer_type retrieve()
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D