7#include "CLHEP/Units/SystemOfUnits.h"
17#include "Identifier/Identifier.h"
104 return StatusCode::SUCCESS;
116 return StatusCode::SUCCESS;
120 const bool useConditionStore = not accessDuringInitialization;
122 if (useConditionStore) {
127 if (elements==
nullptr) {
133 elements =
m_manager->getDetectorElementCollection();
149 ATH_MSG_ALWAYS(
" center (x,y,z) = " << element->center().x() <<
"," << element->center().y() <<
"," << element->center().z());
150 ATH_MSG_ALWAYS(
" center (r,phi,z) = " << element->center().perp() <<
"," << element->center().phi() <<
"," <<element->center().z());
154 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());
155 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());
160 ATH_MSG_ALWAYS(
" Normal = " <<element->normal().perp() <<
"," << element->normal().phi() <<
","<< element->normal().z());
161 ATH_MSG_ALWAYS(
" sin(tilt), sin(stereo) = " << element->sinTilt() <<
" "
162 << element->sinStereo());
164 << element->width()/CLHEP::mm <<
" "
165 << element->minWidth()/CLHEP::mm <<
" "
166 << element->maxWidth()/CLHEP::mm <<
" "
167 << element->length()/CLHEP::mm);
172 const EventContext &ctx = Gaudi::Hive::currentContext();
173 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
185 ATH_MSG_ALWAYS(
" HashId, Id : " << hashId <<
"\t" << element->identify().getString());
200 if (useConditionStore) {
203 elementtest1 = elements->getDetectorElement(
m_pixelIdHelper->wafer_hash(element->identify()));
205 elementtest1 = elements->getDetectorElement(
m_sctIdHelper->wafer_hash(element->identify()));
207 elementtest2 = elements->getDetectorElement(hashId);
209 elementtest1 =
m_manager->getDetectorElement(element->identify());
210 elementtest2 =
m_manager->getDetectorElement(hashId);
213 if (idHashTest != hashId) {
ATH_MSG_ALWAYS(
" Id test 1 FAILED!"); idOK =
false;}
214 if (idTest != element->identify()) {
ATH_MSG_ALWAYS(
" Id test 2 FAILED!"); idOK =
false;}
215 if (elementtest1 != element) {
ATH_MSG_ALWAYS(
" Id test 3 FAILED!"); idOK =
false;}
216 if (elementtest2 != element) {
ATH_MSG_ALWAYS(
" Id test 4 FAILED!"); idOK =
false;}
222 const GeoTrf::Transform3D mytrf = element->transform();
223 const GeoTrf::Transform3D mytrfhit = element->transformHit();
226 ATH_MSG_ALWAYS(
"|"<<mytrf(2,0)<<
","<<mytrf(2,1)<<
","<<mytrf(2,2)<<
"|");
227 ATH_MSG_ALWAYS(
"|"<<mytrf(1,0)<<
","<<mytrf(1,1)<<
","<<mytrf(1,2)<<
"|");
228 ATH_MSG_ALWAYS(
"|"<<mytrf(0,0)<<
","<<mytrf(0,1)<<
","<<mytrf(0,2)<<
"|");
231 ATH_MSG_ALWAYS(
"|"<<mytrfhit(2,0)<<
","<<mytrfhit(2,1)<<
","<<mytrfhit(2,2)<<
"|");
232 ATH_MSG_ALWAYS(
"|"<<mytrfhit(1,0)<<
","<<mytrfhit(1,1)<<
","<<mytrfhit(1,2)<<
"|");
233 ATH_MSG_ALWAYS(
"|"<<mytrfhit(0,0)<<
","<<mytrfhit(0,1)<<
","<<mytrfhit(0,2)<<
"|");
238 if(element->depthDirection())
ATH_MSG_ALWAYS(
"Depth Direction True");
247 if(std::abs(element->depthAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD DEPTH DIRECTION!");
248 if(std::abs(element->etaAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD ETA DIRECTION!");
249 if(std::abs(element->phiAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD PHI DIRECTION!");
260 int barrelCountError = 0;
262 for (
int iBarrelIndex = 0; iBarrelIndex < siNumerology.
numBarrels(); iBarrelIndex++) {
263 int iBarrel = siNumerology.
barrelId(iBarrelIndex);
266 for (
int iLayer = 0; iLayer < siNumerology.
numLayers(); iLayer++) {
274 for (
int iSide = 0; iSide < nSides; iSide++) {
279 id =
m_sctIdHelper->wafer_id(iBarrel,iLayer,iPhi,iEta,iSide);
282 if (useConditionStore) {
290 element =
m_manager->getDetectorElement(
id);
308 int endcapCountError = 0;
310 for (
int iEndcapIndex = 0; iEndcapIndex < siNumerology.
numEndcaps(); iEndcapIndex++) {
311 int iEndcap = siNumerology.
endcapId(iEndcapIndex);
314 for (
int iDisk = 0; iDisk < siNumerology.
numDisks(); iDisk++) {
318 for (
int iEta = 0; iEta < siNumerology.
numRingsForDisk(iDisk); iEta++) {
322 for (
int iSide = 0; iSide < nSides; iSide++) {
364 const bool useConditionStore = (
m_managerName ==
"SCT" and (not accessDuringInitialization));
366 if (useConditionStore) {
370 if (elements==
nullptr) {
382 std::vector<SiCellId> cellIds;
383 std::vector<Amg::Vector2D> positions;
390 cellIds.emplace_back(32,8);
392 for (
int i(151);i != 176; ++i){
393 cellIds.emplace_back(i,8);
395 cellIds.emplace_back(-1,1);
396 cellIds.emplace_back(0,1);
397 cellIds.emplace_back(1,-1);
398 cellIds.emplace_back(1,0);
399 cellIds.emplace_back(327,1);
400 cellIds.emplace_back(328,1);
401 cellIds.emplace_back(1,143);
402 cellIds.emplace_back(1,144);
403 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
413 cellIds.emplace_back(32,8);
414 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
422 cellIds.emplace_back(182,75);
423 positions.emplace_back(0*CLHEP::mm, 0*CLHEP::mm);
424 positions.emplace_back(30.4*CLHEP::mm, 8.2*CLHEP::mm);
425 positions.emplace_back(12*CLHEP::mm, -8.15*CLHEP::mm);
426 positions.emplace_back(12*CLHEP::mm, -8.25*CLHEP::mm);
427 positions.emplace_back(12*CLHEP::mm, -8.35*CLHEP::mm);
438 std::vector<SiCellId> cellIds;
439 std::vector<Amg::Vector2D> positions;
447 id = idHelper->
wafer_id(0,1,15,-3,0);
450 cellIds.emplace_back(32);
451 cellIds.emplace_back(1);
452 cellIds.emplace_back(0);
454 cellIds.emplace_back(-1);
455 cellIds.emplace_back(-2);
456 cellIds.emplace_back(-3);
458 cellIds.emplace_back(767);
459 cellIds.emplace_back(768);
460 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
467 id = idHelper->
wafer_id(0,1,15,-3,1);
470 cellIds.emplace_back(32);
471 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
478 id = idHelper->
wafer_id(2,3,15,0,0);
481 cellIds.emplace_back(532);
482 cellIds.emplace_back(0);
484 cellIds.emplace_back(767);
485 cellIds.emplace_back(768);
486 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
487 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
488 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
494 id = idHelper->
wafer_id(2,3,15,0,1);
497 cellIds.emplace_back(532);
498 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
499 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
500 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
507 id = idHelper->
wafer_id(2,1,15,1,0);
510 cellIds.emplace_back(532);
511 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
518 id = idHelper->
wafer_id(2,7,15,1,0);
521 cellIds.emplace_back(532);
522 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
529 id = idHelper->
wafer_id(2,1,15,2,0);
532 cellIds.emplace_back(532);
533 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
545 if (elementsC==
nullptr) {
553 if (elementsC->
size()!=elementsM->
size()) {
554 ATH_MSG_FATAL(
"Sizes of SiDetectorElementCollections are different");
560 for (; elementM!=elementMe; ++elementC, ++elementM) {
561 auto diff = (*elementC)->center()-(*elementM)->center();
565 ATH_MSG_ALWAYS(
"center (store) " << (*elementC)->center().transpose());
566 ATH_MSG_ALWAYS(
"center (manager) " << (*elementM)->center().transpose());
575 const std::vector<SiCellId> & cellIdVec,
576 const std::vector<Amg::Vector2D> & positionsVec,
587 element =
m_manager->getDetectorElement(
id);
592 ATH_MSG_ALWAYS(
" width, minWidth, maxWidth, length, thickness (mm) = "
593 << element->
width()/CLHEP::mm <<
" "
594 << element->
minWidth()/CLHEP::mm <<
" "
595 << element->
maxWidth()/CLHEP::mm <<
" "
596 << element->
length()/CLHEP::mm <<
" "
601 ATH_MSG_ALWAYS(
" rMin, rMax, zMin, zMax (mm), phiMin, phiMax (deg) = "
602 << element->
rMin()/CLHEP::mm <<
" "
603 << element->
rMax()/CLHEP::mm <<
" "
604 << element->
zMin()/CLHEP::mm <<
" "
605 << element->
zMax()/CLHEP::mm <<
" "
606 << element->
phiMin()/CLHEP::degree <<
" "
607 << element->
phiMax()/CLHEP::degree
610 << element->
center() <<
" "
611 << element->
normal() <<
" "
616 <<
", phi (deg) = " << element->
center().phi()/CLHEP::deg);
618 const EventContext &ctx = Gaudi::Hive::currentContext();
619 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
624 ATH_MSG_ALWAYS(
" sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
626 << asin(element->
sinTilt())/CLHEP::degree <<
", "
628 << asin(element->
sinStereo())/CLHEP::degree);
636 for (
unsigned int iTestCell = 0; iTestCell < cellIdVec.size(); iTestCell++) {
637 SiCellId cellId = cellIdVec[iTestCell];
647 ATH_MSG_ALWAYS(
" extracted cell id [phiIndex.etaIndex] = " << cellId2);
651 ATH_MSG_ALWAYS(
" raw localPosition (using cell id) (xPhi,xEta) = "
652 << localPosRaw1.
xPhi() <<
", " << localPosRaw1.
xEta());
653 ATH_MSG_ALWAYS(
" raw localPosition (using full id) (xPhi,xEta) = "
654 << localPosRaw2.
xPhi() <<
", " << localPosRaw2.
xEta());
660 msg(MSG::ALWAYS) <<
" Connected cells";
663 msg(MSG::ALWAYS) <<
", " << iCell <<
": " << connectedCellId;
668 for (
unsigned int iTestPos = 0; iTestPos < positionsVec.size(); iTestPos++) {
670 ATH_MSG_ALWAYS(
" Requested local pos (xPhi,xEta) = " << localPosOrig.
xPhi() <<
", " << localPosOrig.
xEta());
673 ATH_MSG_ALWAYS(
" Global pos = " << globalPos <<
", r (mm) = " << globalPos.perp()/CLHEP::mm<<
", phi (deg) = " << globalPos.phi()/CLHEP::degree);
679 double tolerance = 100*CLHEP::micrometer;
682 <<
" (in,out,nearBoundary,mayIntersect) : "
683 << intersectState.
in() <<
","
684 << intersectState.
out() <<
","
693 ATH_MSG_ALWAYS(
" using global position sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
694 << element->
sinTilt(globalPos) <<
", "
695 << asin(element->
sinTilt(globalPos))/CLHEP::degree <<
", "
697 << asin(element->
sinStereo(globalPos))/CLHEP::degree);
722 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 with parameters:
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
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