7#include "CLHEP/Units/SystemOfUnits.h"
17#include "Identifier/Identifier.h"
91 return StatusCode::SUCCESS;
103 return StatusCode::SUCCESS;
107 const bool useConditionStore = not accessDuringInitialization;
109 if (useConditionStore) {
114 if (elements==
nullptr) {
120 elements =
m_manager->getDetectorElementCollection();
130 if (!element)
continue;
136 ATH_MSG_ALWAYS(
" center (x,y,z) = " << element->center().x() <<
"," << element->center().y() <<
"," << element->center().z());
137 ATH_MSG_ALWAYS(
" center (r,phi,z) = " << element->center().perp() <<
"," << element->center().phi() <<
"," <<element->center().z());
141 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());
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());
147 ATH_MSG_ALWAYS(
" Normal = " <<element->normal().perp() <<
"," << element->normal().phi() <<
","<< element->normal().z());
148 ATH_MSG_ALWAYS(
" sin(tilt), sin(stereo) = " << element->sinTilt() <<
" "
149 << element->sinStereo());
151 << element->width()/CLHEP::mm <<
" "
152 << element->minWidth()/CLHEP::mm <<
" "
153 << element->maxWidth()/CLHEP::mm <<
" "
154 << element->length()/CLHEP::mm);
159 const EventContext &ctx = Gaudi::Hive::currentContext();
160 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
168 ATH_MSG_ALWAYS(
" HashId, Id : " << hashId <<
"\t" << element->identify().getString());
181 if (useConditionStore) {
184 elementtest1 = elements->getDetectorElement(
m_pixelIdHelper->wafer_hash(element->identify()));
186 elementtest1 = elements->getDetectorElement(
m_sctIdHelper->wafer_hash(element->identify()));
188 elementtest2 = elements->getDetectorElement(hashId);
190 elementtest1 =
m_manager->getDetectorElement(element->identify());
191 elementtest2 =
m_manager->getDetectorElement(hashId);
194 if (idHashTest != hashId) {
ATH_MSG_ALWAYS(
" Id test 1 FAILED!"); idOK =
false;}
195 if (idTest != element->identify()) {
ATH_MSG_ALWAYS(
" Id test 2 FAILED!"); idOK =
false;}
196 if (elementtest1 != element) {
ATH_MSG_ALWAYS(
" Id test 3 FAILED!"); idOK =
false;}
197 if (elementtest2 != element) {
ATH_MSG_ALWAYS(
" Id test 4 FAILED!"); idOK =
false;}
200 const GeoTrf::Transform3D mytrf = element->transform();
201 const GeoTrf::Transform3D mytrfhit = element->transformHit();
203 ATH_MSG_ALWAYS(
"|"<<mytrf(2,0)<<
","<<mytrf(2,1)<<
","<<mytrf(2,2)<<
"|");
204 ATH_MSG_ALWAYS(
"|"<<mytrf(1,0)<<
","<<mytrf(1,1)<<
","<<mytrf(1,2)<<
"|");
205 ATH_MSG_ALWAYS(
"|"<<mytrf(0,0)<<
","<<mytrf(0,1)<<
","<<mytrf(0,2)<<
"|");
208 ATH_MSG_ALWAYS(
"|"<<mytrfhit(2,0)<<
","<<mytrfhit(2,1)<<
","<<mytrfhit(2,2)<<
"|");
209 ATH_MSG_ALWAYS(
"|"<<mytrfhit(1,0)<<
","<<mytrfhit(1,1)<<
","<<mytrfhit(1,2)<<
"|");
210 ATH_MSG_ALWAYS(
"|"<<mytrfhit(0,0)<<
","<<mytrfhit(0,1)<<
","<<mytrfhit(0,2)<<
"|");
215 if(element->depthDirection())
ATH_MSG_ALWAYS(
"Depth Direction True");
224 if(std::abs(element->depthAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD DEPTH DIRECTION!");
225 if(std::abs(element->etaAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD ETA DIRECTION!");
226 if(std::abs(element->phiAngle())<0.5)
ATH_MSG_ALWAYS(
"BAD PHI DIRECTION!");
237 int barrelCountError = 0;
239 for (
int iBarrelIndex = 0; iBarrelIndex < siNumerology.
numBarrels(); iBarrelIndex++) {
240 int iBarrel = siNumerology.
barrelId(iBarrelIndex);
243 for (
int iLayer = 0; iLayer < siNumerology.
numLayers(); iLayer++) {
251 for (
int iSide = 0; iSide < nSides; iSide++) {
256 id =
m_sctIdHelper->wafer_id(iBarrel,iLayer,iPhi,iEta,iSide);
259 if (useConditionStore) {
267 element =
m_manager->getDetectorElement(
id);
285 int endcapCountError = 0;
287 for (
int iEndcapIndex = 0; iEndcapIndex < siNumerology.
numEndcaps(); iEndcapIndex++) {
288 int iEndcap = siNumerology.
endcapId(iEndcapIndex);
291 for (
int iDisk = 0; iDisk < siNumerology.
numDisks(); iDisk++) {
295 for (
int iEta = 0; iEta < siNumerology.
numRingsForDisk(iDisk); iEta++) {
299 for (
int iSide = 0; iSide < nSides; iSide++) {
341 const bool useConditionStore = (
m_managerName ==
"SCT" and (not accessDuringInitialization));
343 if (useConditionStore) {
347 if (elements==
nullptr) {
358 std::vector<SiCellId> cellIds;
359 std::vector<Amg::Vector2D> positions;
366 cellIds.emplace_back(32,8);
368 for (
int i(151);i != 176; ++i){
369 cellIds.emplace_back(i,8);
371 cellIds.emplace_back(-1,1);
372 cellIds.emplace_back(0,1);
373 cellIds.emplace_back(1,-1);
374 cellIds.emplace_back(1,0);
375 cellIds.emplace_back(327,1);
376 cellIds.emplace_back(328,1);
377 cellIds.emplace_back(1,143);
378 cellIds.emplace_back(1,144);
379 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
389 cellIds.emplace_back(32,8);
390 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
398 cellIds.emplace_back(182,75);
399 positions.emplace_back(0*CLHEP::mm, 0*CLHEP::mm);
400 positions.emplace_back(30.4*CLHEP::mm, 8.2*CLHEP::mm);
401 positions.emplace_back(12*CLHEP::mm, -8.15*CLHEP::mm);
402 positions.emplace_back(12*CLHEP::mm, -8.25*CLHEP::mm);
403 positions.emplace_back(12*CLHEP::mm, -8.35*CLHEP::mm);
410 std::vector<SiCellId> cellIds;
411 std::vector<Amg::Vector2D> positions;
419 id = idHelper->
wafer_id(0,1,15,-3,0);
422 cellIds.emplace_back(32);
423 cellIds.emplace_back(1);
424 cellIds.emplace_back(0);
426 cellIds.emplace_back(-1);
427 cellIds.emplace_back(-2);
428 cellIds.emplace_back(-3);
430 cellIds.emplace_back(767);
431 cellIds.emplace_back(768);
432 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
439 id = idHelper->
wafer_id(0,1,15,-3,1);
442 cellIds.emplace_back(32);
443 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
450 id = idHelper->
wafer_id(2,3,15,0,0);
453 cellIds.emplace_back(532);
454 cellIds.emplace_back(0);
456 cellIds.emplace_back(767);
457 cellIds.emplace_back(768);
458 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
459 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
460 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
466 id = idHelper->
wafer_id(2,3,15,0,1);
469 cellIds.emplace_back(532);
470 positions.emplace_back(12.727*CLHEP::mm, 20.534*CLHEP::mm);
471 positions.emplace_back(12.727*CLHEP::mm, -20.534*CLHEP::mm);
472 positions.emplace_back(3*CLHEP::mm, -25*CLHEP::mm);
479 id = idHelper->
wafer_id(2,1,15,1,0);
482 cellIds.emplace_back(532);
483 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
490 id = idHelper->
wafer_id(2,7,15,1,0);
493 cellIds.emplace_back(532);
494 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
501 id = idHelper->
wafer_id(2,1,15,2,0);
504 cellIds.emplace_back(532);
505 positions.emplace_back(12.727*CLHEP::mm, 4.534*CLHEP::mm);
516 if (elementsC==
nullptr) {
524 if (elementsC->
size()!=elementsM->
size()) {
525 ATH_MSG_FATAL(
"Sizes of SiDetectorElementCollections are different");
531 for (; elementM!=elementMe; ++elementC, ++elementM) {
532 auto diff = (*elementC)->center()-(*elementM)->center();
536 ATH_MSG_ALWAYS(
"center (store) " << (*elementC)->center().transpose());
537 ATH_MSG_ALWAYS(
"center (manager) " << (*elementM)->center().transpose());
546 const std::vector<SiCellId> & cellIdVec,
547 const std::vector<Amg::Vector2D> & positionsVec,
558 element =
m_manager->getDetectorElement(
id);
563 ATH_MSG_ALWAYS(
" width, minWidth, maxWidth, length, thickness (mm) = "
564 << element->
width()/CLHEP::mm <<
" "
565 << element->
minWidth()/CLHEP::mm <<
" "
566 << element->
maxWidth()/CLHEP::mm <<
" "
567 << element->
length()/CLHEP::mm <<
" "
572 ATH_MSG_ALWAYS(
" rMin, rMax, zMin, zMax (mm), phiMin, phiMax (deg) = "
573 << element->
rMin()/CLHEP::mm <<
" "
574 << element->
rMax()/CLHEP::mm <<
" "
575 << element->
zMin()/CLHEP::mm <<
" "
576 << element->
zMax()/CLHEP::mm <<
" "
577 << element->
phiMin()/CLHEP::degree <<
" "
578 << element->
phiMax()/CLHEP::degree
581 << element->
center() <<
" "
582 << element->
normal() <<
" "
587 <<
", phi (deg) = " << element->
center().phi()/CLHEP::deg);
589 const EventContext &ctx = Gaudi::Hive::currentContext();
590 ATH_MSG_ALWAYS(
" Temperature (C), bias voltage, depletion voltage: "
595 ATH_MSG_ALWAYS(
" sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
597 << asin(element->
sinTilt())/CLHEP::degree <<
", "
599 << asin(element->
sinStereo())/CLHEP::degree);
607 for (
unsigned int iTestCell = 0; iTestCell < cellIdVec.size(); iTestCell++) {
608 SiCellId cellId = cellIdVec[iTestCell];
618 ATH_MSG_ALWAYS(
" extracted cell id [phiIndex.etaIndex] = " << cellId2);
622 ATH_MSG_ALWAYS(
" raw localPosition (using cell id) (xPhi,xEta) = "
623 << localPosRaw1.
xPhi() <<
", " << localPosRaw1.
xEta());
624 ATH_MSG_ALWAYS(
" raw localPosition (using full id) (xPhi,xEta) = "
625 << localPosRaw2.
xPhi() <<
", " << localPosRaw2.
xEta());
631 msg(MSG::ALWAYS) <<
" Connected cells";
634 msg(MSG::ALWAYS) <<
", " << iCell <<
": " << connectedCellId;
639 for (
unsigned int iTestPos = 0; iTestPos < positionsVec.size(); iTestPos++) {
641 ATH_MSG_ALWAYS(
" Requested local pos (xPhi,xEta) = " << localPosOrig.
xPhi() <<
", " << localPosOrig.
xEta());
644 ATH_MSG_ALWAYS(
" Global pos = " << globalPos <<
", r (mm) = " << globalPos.perp()/CLHEP::mm<<
", phi (deg) = " << globalPos.phi()/CLHEP::degree);
650 double tolerance = 100*CLHEP::micrometer;
653 <<
" (in,out,nearBoundary,mayIntersect) : "
654 << intersectState.
in() <<
","
655 << intersectState.
out() <<
","
664 ATH_MSG_ALWAYS(
" using global position sin(tilt), tilt (deg), sin(stereo), stereo (deg) = "
665 << element->
sinTilt(globalPos) <<
", "
666 << asin(element->
sinTilt(globalPos))/CLHEP::degree <<
", "
668 << asin(element->
sinStereo(globalPos))/CLHEP::degree);
693 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