15#include "Identifier/Identifier.h"
25#include "CLHEP/Random/RandGaussZiggurat.h"
26#include "CLHEP/Random/RandFlat.h"
27#include "CLHEP/Random/RandLandau.h"
70 const IInterface* parent):
97 return StatusCode::FAILURE;
100 if (detStore()->retrieve(
m_pixel_ID,
"PixelID").isFailure()) {
102 return StatusCode::FAILURE;
108 return StatusCode::FAILURE;
134 return StatusCode::FAILURE;
141 return StatusCode::FAILURE;
148 return StatusCode::SUCCESS;
159 return StatusCode::SUCCESS;
173 TimedHitCollList hitCollList;
176 bSubEvents, eSubEvents).isSuccess()) &&
177 hitCollList.empty()) {
179 return StatusCode::FAILURE;
185 TimedHitCollList::iterator iColl(hitCollList.begin());
186 TimedHitCollList::iterator endColl(hitCollList.end());
188 for( ; iColl != endColl; ++iColl) {
194 <<
" index: " << timeIndex.
index()
195 <<
" type: " << timeIndex.
type());
196 m_thpcsi->insert(timeIndex, siHitColl);
200 return StatusCode::SUCCESS;
209 ATH_MSG_FATAL(
"[ --- ] Could not create PixelClusterContainer");
210 return StatusCode::FAILURE;
213 InDet::SiClusterContainer* symSiContainer=
nullptr;
219 ATH_MSG_FATAL(
"[ hitproc ] Error while registering PixelCluster container");
220 return StatusCode::FAILURE;
225 ATH_MSG_FATAL(
"[ --- ] PixelClusterContainer could not be symlinked to SiClusterContainter in StoreGate !" );
226 return StatusCode::FAILURE;
228 ATH_MSG_DEBUG(
"[ hitproc ] PixelClusterContainer symlinked to SiClusterContainer in StoreGate" );
238 return StatusCode::FAILURE;
243 return StatusCode::FAILURE;
255 TimedHitCollList hitCollList;
256 unsigned int numberOfSimHits(0);
257 if ( !(
m_mergeSvc->retrieveSubEvtsData(
m_inputObjectName.value(), hitCollList, numberOfSimHits).isSuccess()) && hitCollList.empty() ) {
259 return StatusCode::FAILURE;
268 TimedHitCollList::iterator iColl(hitCollList.begin());
269 TimedHitCollList::iterator endColl(hitCollList.end() );
273 while ( iColl != endColl ) {
279 thpcsi.
insert(iColl->first, p_collection);
280 ATH_MSG_DEBUG (
"SiHitCollection found with " << p_collection->
size() <<
" hits" );
285 if(this->
digitize(ctx, thpcsi).isFailure()) {
287 return StatusCode::FAILURE;
292 return StatusCode::FAILURE;
300 ATH_MSG_ERROR(
"[ ---- ] Could not set Pixel ROT container ");
305 ATH_MSG_FATAL (
"PixelClusterAmbiguitiesMap could not be recorded in StoreGate !" );
306 return StatusCode::FAILURE;
308 ATH_MSG_DEBUG (
"PixelClusterAmbiguitiesMap recorded in StoreGate" );
314 return StatusCode::SUCCESS;
326 ATH_MSG_FATAL(
"[ --- ] Could not create PixelClusterContainer");
327 return StatusCode::FAILURE;
330 InDet::SiClusterContainer* symSiContainer=
nullptr;
336 ATH_MSG_FATAL(
"[ hitproc ] Error while registering PixelCluster container");
337 return StatusCode::FAILURE;
342 ATH_MSG_FATAL(
"[ --- ] PixelClusterContainer could not be symlinked to SiClusterContainter in StoreGate !" );
343 return StatusCode::FAILURE;
345 ATH_MSG_DEBUG(
"[ hitproc ] PixelClusterContainer symlinked to SiClusterContainer in StoreGate" );
354 return StatusCode::FAILURE;
359 return StatusCode::FAILURE;
368 return StatusCode::FAILURE;
379 return StatusCode::FAILURE;
386 ATH_MSG_ERROR(
"[ ---- ] Could not set Pixel ROT container ");
391 ATH_MSG_FATAL (
"PixelClusterAmbiguitiesMap could not be recorded in StoreGate !" );
392 return StatusCode::FAILURE;
394 ATH_MSG_DEBUG (
"PixelClusterAmbiguitiesMap recorded in StoreGate" );
399 return StatusCode::SUCCESS;
409 rngWrapper->
setSeed( rngName, ctx );
410 CLHEP::HepRandomEngine *rndmEngine = rngWrapper->
getEngine(ctx);
414 if (not pixelDetEleHandle.
isValid() or elements==
nullptr) {
416 return StatusCode::FAILURE;
427 std::vector<int> truthIdList;
428 std::vector<Identifier> detEl;
443 const int barrelEC = hit->getBarrelEndcap();
444 const int layerDisk = hit->getLayerDisk();
445 const int phiModule = hit->getPhiModule();
446 const int etaModule = hit->getEtaModule();
451 if (!hitSiDetElement) {
ATH_MSG_ERROR(
" could not get detector element ");
continue;}
453 if (!(hitSiDetElement->
isPixel())) {
continue;}
457 std::vector<HepMcParticleLink> hit_vector;
459 const int truthID = (currentLink.
barcode() !=0 && currentLink.
id() == 0) ? 3 : currentLink.
id();
467 for (
int j : truthIdList) {
468 for (
auto & k : detEl) {
469 if ((truthID > 0) && (truthID == j) && (hitId == k)) {isRep =
true;
break;}
476 truthIdList.push_back(truthID);
477 detEl.push_back(hitId);
479 HepGeom::Point3D<double> localStartPosition = hit->localStartPosition();
480 HepGeom::Point3D<double> localEndPosition = hit->localEndPosition();
485 int isEndcap = (barrelEC==0) ? 0:1;
493 Diffuse(localStartPosition, localEndPosition, shiftX, shiftY);
495 const Amg::Vector3D localDirection(localEndPosition.x()-localStartPosition.x(), localEndPosition.y()-localStartPosition.y(), localEndPosition.z()-localStartPosition.z());
497 Amg::Vector3D entryPoint(localStartPosition.x(),localStartPosition.y(),localStartPosition.z());
498 Amg::Vector3D exitPoint(localEndPosition.x(),localEndPosition.y(),localEndPosition.z());
502 ATH_MSG_FATAL(
"Failed to cast the hitSiDetElement::design pointer to a PixelModuleDesign*; aborting due to null pointer");
503 return StatusCode::FAILURE;
505 const Amg::Vector2D localEntry(localStartPosition.x(),localStartPosition.y());
506 const Amg::Vector2D localExit(localEndPosition.x(),localEndPosition.y());
514 double halfthickness = hitSiDetElement->
thickness()*0.5;
516 bool EntryValid(entryCellId.
isValid());
517 bool ExitValid(exitCellId.
isValid());
532 pixMinimalPathCut=th0;
534 if (!EntryValid || !ExitValid)
538 if ( !EntryValid && !ExitValid)
continue;
546 ATH_MSG_WARNING(
"ATTENTION THE INTERSECTION COORDINATE IS OUT OF THE MODULE");
550 const Amg::Vector2D Intersection_2d(Intersection.x(),Intersection.y());
556 if(!Intersection_2dCellId.
isValid())
continue;
559 exitPoint = Intersection;
561 entryPoint = Intersection;
569 if(!digitizationModule){
571 return StatusCode::FAILURE;
575 std::vector<Trk::DigitizationStep> digitizationSteps =
m_digitizationStepper->cellSteps(*digitizationModule,entryPoint,exitPoint);
580 std::unique_ptr<InDet::PixelCluster> pixelCluster =
nullptr;
583 std::vector<Identifier> rdoList;
584 std::vector<int> totList;
586 const bool isGanged =
false;
589 double accumulatedPathLength=0.;
592 int phiIndexMax = -999999;
593 int phiIndexMin = 1000000;
594 int etaIndexMax = -999999;
595 int etaIndexMin = 1000000;
598 for (
auto& dStep : digitizationSteps){
600 double pathlength = dStep.stepLength;
607 pathlength *= (1.+sPar);
611 if (pathlength < pixMinimalPathCut)
continue;
625 clusterPosition += pathlength * chargeCenterPosition;
627 int currentEtaIndex = diode.
etaIndex();
628 int currentPhiIndex = diode.
phiIndex();
629 if(currentEtaIndex > etaIndexMax) etaIndexMax = currentEtaIndex;
630 if(currentEtaIndex < etaIndexMin) etaIndexMin = currentEtaIndex;
631 if(currentPhiIndex > phiIndexMax) phiIndexMax = currentPhiIndex;
632 if(currentPhiIndex < phiIndexMin) phiIndexMin = currentPhiIndex;
636 accumulatedPathLength += pathlength;
638 rdoList.push_back(rdoId);
643 delete digitizationModule;
646 int siDeltaPhiCut = phiIndexMax-phiIndexMin+1;
647 int siDeltaEtaCut = etaIndexMax-etaIndexMin+1;
649 int totalToT=std::accumulate(totList.begin(), totList.end(), 0);;
652 if (rdoList.empty() || accumulatedPathLength < pixMinimalPathCut || totalToT == 0) {
653 if (totalToT == 0 && !rdoList.empty() )
ATH_MSG_WARNING(
"The total ToT of the cluster is 0, this should never happen");
658 clusterPosition *= 1./accumulatedPathLength;
667 for(Pixel_detElement_RIO_map::iterator currentClusIter = PixelDetElClusterMap.begin(); currentClusIter != PixelDetElClusterMap.end();) {
669 Pixel_detElement_RIO_map::iterator clusIter = currentClusIter++;
671 const std::vector<Identifier> ¤tRdoList = currentCluster->
rdoList();
673 for (
auto rdoIter : rdoList) {
675 if (areNb) {
break; }
678 const std::vector<int> ¤tTotList = currentCluster->
totList();
679 rdoList.insert(rdoList.end(), currentRdoList.begin(), currentRdoList.end() );
680 totList.insert(totList.end(), currentTotList.begin(), currentTotList.end() );
682 float c1 = (float)currentRdoList.size();
683 float c2 = (float)rdoList.size();
684 clusterPosition = (clusterPosition*c2 + currentClusterPosition*c1)/((c1 + c2));
687 PixelDetElClusterMap.erase(clusIter);
690 std::pair<PRD_MultiTruthCollection::iterator,PRD_MultiTruthCollection::iterator> saved_hit =
m_pixPrdTruth->equal_range(currentCluster->
identify());
691 for (PRD_MultiTruthCollection::iterator this_hit = saved_hit.first; this_hit != saved_hit.second; ++this_hit)
693 hit_vector.push_back(this_hit->second);
697 delete currentCluster;
703 bool not_valid =
false;
704 for (
auto & entry : rdoList) {
705 if (!(entry.is_valid())) { not_valid =
true;
break;}
708 if (not_valid)
continue;
712 for (
auto rdoIter : rdoList) {
715 int chargePhiIndex = chargeCellId.
phiIndex();
716 int chargeEtaIndex = chargeCellId.
etaIndex();
718 phiIndexMin = chargePhiIndex < phiIndexMin ? chargePhiIndex : phiIndexMin;
719 phiIndexMax = chargePhiIndex > phiIndexMax ? chargePhiIndex : phiIndexMax;
720 etaIndexMin = chargeEtaIndex < etaIndexMin ? chargeEtaIndex : etaIndexMin;
721 etaIndexMax = chargeEtaIndex > etaIndexMax ? chargeEtaIndex : etaIndexMax;
723 siDeltaPhiCut = (phiIndexMax-phiIndexMin)+1;
724 siDeltaEtaCut = (etaIndexMax-etaIndexMin)+1;
739 const auto* pixModDesign =
741 &hitSiDetElement->
design());
743 return StatusCode::FAILURE;
749 pixModDesign->widthFromRowRange(phiIndexMin, phiIndexMax);
757 clusterId, clusterPosition, std::vector<Identifier>(rdoList),
758 lvl1a, std::vector<int>(totList), siWidth,
760 false, 0.0, 0.0, calibData, *offlineCalibData, ctx));
762 pixelCluster->setGangedPixel(isGanged);
766 "[ cluster - pix ] No pixels errors provided, but configured to "
769 " -> No pixels cluster will be created.");
773 if (!(pixelCluster->identify().is_valid())) {
774 pixelCluster.reset();
778 if (!(
m_pixel_ID->is_pixel(pixelCluster->identify()))) {
779 pixelCluster.reset();
784 PixelDetElClusterMap.insert(Pixel_detElement_RIO_map::value_type(
785 waferHash, pixelCluster.release()));
791 std::make_pair(insertedCluster->
identify(), currentLink));
794 <<
" and link = " << currentLink);
798 "Particle link NOT valid!! Truth map NOT filled with cluster"
799 << insertedCluster <<
" and link = " << currentLink);
812 (void)
m_pixelClusterMap->insert(PixelDetElClusterMap.begin(), PixelDetElClusterMap.end());
818 return StatusCode::SUCCESS;
825 if (not pixelDetEleHandle.
isValid() or elements==
nullptr) {
827 return StatusCode::FAILURE;
833 InDet::PixelClusterCollection* clusterCollection =
nullptr;
838 std::pair <Pixel_detElement_RIO_map::iterator, Pixel_detElement_RIO_map::iterator> range;
841 Pixel_detElement_RIO_map::iterator firstDetElem;
842 firstDetElem = range.first;
844 waferHash = firstDetElem->first;
848 clusterCollection =
new InDet::PixelClusterCollection(waferHash);
849 clusterCollection->setIdentifier(detElement->
identify());
852 for ( Pixel_detElement_RIO_map::iterator iter = range.first; iter != range.second; ++iter){
855 pixelCluster->setHashAndIndex(clusterCollection->identifyHash(),clusterCollection->size());
856 clusterCollection->push_back(pixelCluster);
861 if (clusterCollection) {
862 if (!clusterCollection->empty()) {
867 ATH_MSG_WARNING(
"Could not add collection to Identifyable container !" );
870 else {
delete clusterCollection;}
878 return StatusCode::SUCCESS;
882(
const std::vector<Identifier>& group,
892 std::vector<Identifier>::const_iterator groupBegin = group.begin();
893 std::vector<Identifier>::const_iterator groupEnd = group.end();
900 while (groupBegin!=groupEnd)
905 if(row1 > rowmax) rowmax = row1;
906 int deltarow = abs(row2-row1);
907 int deltacol = abs(col2-col1);
910 if(deltacol+deltarow < 2)
match =
true;
912 if(deltacol == 1 && deltarow == 1)
match =
true;
931 const double halfThickness = hitSiDetElement->
thickness() * 0.5;
932 const double halfWidth = design->
width() * 0.5;
933 const double halfLength = design->
length() * 0.5;
935 int binsX = design->
rows();
943 ATH_MSG_VERBOSE(
"Retrieving infos: halfThickness = " << halfThickness <<
" --- halfWidth = " << halfWidth <<
" --- halfLength = " << halfLength );
944 ATH_MSG_VERBOSE(
"Retrieving infos: binsX = " << binsX <<
" --- binsY = " << binsY <<
" --- numberOfChip = " << numberOfChip);
948 const bool useLorentzAngle{
true};
964 auto rectangleBounds = std::make_shared<const Trk::RectangleBounds>(halfWidth,halfLength);
967 std::shared_ptr<const Trk::Segmentation> rectangleSegmentation(
new Trk::RectangularSegmentation(std::move(rectangleBounds),(
size_t)binsX,LongPitch,(
size_t)binsY, numberOfChip));
974 ATH_MSG_VERBOSE(
"Building Rectangle Segmentation with dimensions (halfX, halfY) = (" << halfWidth <<
", " << halfLength <<
")");
977 return digitizationModule;
986 std::vector<double> parameters;
987 parameters.push_back((PlaneBorder.x() -
Point.x())/Direction.x());
988 parameters.push_back((-PlaneBorder.x() -
Point.x())/Direction.x());
989 parameters.push_back((PlaneBorder.y() -
Point.y())/Direction.y());
990 parameters.push_back((-PlaneBorder.y() -
Point.y())/Direction.y());
992 for(
double parameter: parameters)
994 double z =
Point.
z() + Direction.z() * parameter;
995 if( std::abs(
z) > halfthickness )
999 double x =
Point.x() + Direction.x() * parameter;
1000 double y =
Point.y() + Direction.y() * parameter;
1002 if(std::abs(
x) > PlaneBorder.x() || std::abs(
y) > PlaneBorder.y())
1011 return Intersection;
1016 double localEntryX = localEntry.x();
1017 double localEntryY = localEntry.y();
1018 double localExitX = localExit.x();
1019 double localExitY = localExit.y();
1021 double signX = localExitX>localEntryX ? 1:-1 ;
1022 double signY = localExitY>localEntryY ? 1:-1 ;
1024 localEntryX += shiftX*signX*(-1);
1025 localExitX += shiftX*signX;
1026 localEntryY += shiftY*signY*(-1);
1027 localExitY += shiftY*signY;
1029 localEntry.setX(localEntryX);
1030 localEntry.setY(localEntryY);
1031 localExit.setX(localExitX);
1032 localExit.setY(localExitY);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Structs for holding charge calibration parameterisation and data.
defines an "iterator" over instances of a given type in StoreGateSvc
This is an Identifier helper class for the Pixel subdetector.
AtlasHitsVector< SiHit > SiHitCollection
A wrapper class for event-slot-local random engines.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
a link optimized in size for a GenParticle in a McEventCollection
int id() const
Return the id of the target particle.
bool isValid() const
Validity check.
static HepMcParticleLink getRedirectedLink(const HepMcParticleLink &particleLink, uint32_t eventIndex, const EventContext &ctx)
Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.
int barcode() const
Return the barcode of the target particle.
This is a "hash" representation of an Identifier.
int readoutSide() const
ReadoutSide.
Class used to describe the design of a module (diode segmentation and readout scheme)
virtual SiDiodesParameters parameters(const SiCellId &cellId) const
readout or diode id -> position, size
int columns() const
Number of cell columns per module:
virtual double length() const
Method to calculate length of a module.
int rows() const
Number of cell rows per module:
double widthFromColumnRange(const int colMin, const int colMax) const
Method to calculate eta width from a column range.
int numberOfCircuits() const
Total number of circuits:
virtual double width() const
Method to calculate average width of a module.
Identifier for the strip or pixel cell.
int phiIndex() const
Get phi index. Equivalent to strip().
bool isValid() const
Test if its in a valid state.
int etaIndex() const
Get eta index.
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):
const SiLocalPosition & width() const
width of the diodes:
double xEta() const
position along eta direction:
HepGeom::Point3D< double > hitLocalToLocal3D(const HepGeom::Point3D< double > &hitPosition) const
Same as previuos method but 3D.
SiCellId cellIdOfPosition(const Amg::Vector2D &localPos) const
As in previous method but returns SiCellId.
double hitPhiDirection() const
See previous method.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual Identifier identify() const override final
identifier of this detector element (inline)
double hitDepthDirection() const
Directions of hit depth,phi,eta axes relative to reconstruction local position axes (LocalPosition).
Identifier identifierOfPosition(const Amg::Vector2D &localPos) const
Full identifier of the cell for a given position: assumes a raw local position (no Lorentz shift)
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
const std::vector< int > & totList() const
A PRD is mapped onto all contributing particles.
PixelChargeCalib::Thresholds getThresholds(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE) const
This is an Identifier helper class for the Pixel subdetector.
int eta_index(const Identifier &id) const
int phi_index(const Identifier &id) const
bool nextDetectorElement(const_iterator &b, const_iterator &e)
sets an iterator range with the hits of current detector element returns a bool when done
TimedVector::const_iterator const_iterator
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
a smart pointer to a hit that also provides access to the extended timing info of the host event.
unsigned short eventId() const
the index of the component event in PileUpEventInfo.
Class that holds the surfaces for a planar digitization detector module.
const Segmentation & segmentation() const
return the segmenation
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
virtual const Amg::Vector2D cellPosition(const DigitizationCell &dCell) const =0
calculate the cell Position from the Id
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
std::pair< size_t, size_t > DigitizationCell
std::list< value_t > type
type of the collection of timed data object
a struct encapsulating the identifier of a pile-up event
index_type index() const
the index of the component event in PileUpEventInfo
PileUpType type() const
the pileup type - minbias, cavern, beam halo, signal?
time_type time() const
bunch xing time in ns