18#include "Identifier/Identifier.h"
32#include "CLHEP/Geometry/Point3D.h"
37#define AUXDATA(OBJ, TYP, NAME) \
38 static const SG::AuxElement::Accessor<TYP> acc_##NAME (#NAME); acc_##NAME(*(OBJ))
41 unsigned int makeKey(
short phi,
char eta,
char layer) {
42 return phi | (
eta << 16) | (layer << 24);
44 using std::numbers::pi;
116 return StatusCode::SUCCESS;
129 if ( !PixelClusterContainer.isValid() )
131 ATH_MSG_ERROR(
"Failed to retrieve PixelClusterContainer with key" << PixelClusterContainer.key() );
132 return StatusCode::FAILURE;
139 if (prdmtCollHandle.
isValid()) {
140 prdmtColl = &*prdmtCollHandle;
144 if (truthParticleLinksHandle.
isValid()) {
145 truth_particle_links = truthParticleLinksHandle.
cptr();
153 if (sdoCollectionHandle.
isValid()) {
154 sdoCollection = &*sdoCollectionHandle;
156 ATH_MSG_WARNING(
"SDO information requested, but SDO collection not available!");
161 bool foundSplitProbContainer =
false;
164 if (!splitProbContainer.
isValid()) {
167 foundSplitProbContainer =
true;
170 std::vector<std::vector<const SiHit*>> siHits(
m_PixelHelper->wafer_hash_max());
173 if (siHitCollectionHandle.
isValid()) {
174 for (
const SiHit& siHit: *siHitCollectionHandle) {
176 if (!siHit.isPixel())
continue;
179 siHit.getLayerDisk(),
180 siHit.getPhiModule(),
181 siHit.getEtaModule()));
184 siHits[wafer_hash].push_back(&siHit);
187 ATH_MSG_WARNING(
"SiHit information requested, but SiHit collection not available!");
194 if (!calibData_handle.
isValid()) {
197 calibData=calibData_handle.
cptr();
202 ATH_CHECK(xaod.
record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
203 std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
208 unsigned int have_truth_link=0u;
209 unsigned int missing_truth_particle=0u;
210 unsigned int missing_parent_particle=0u;
212 unsigned int counter(0);
218 std::unordered_map< unsigned int , std::vector<unsigned int> > cluster_map;
219 for(
const auto clusterCollection : * PixelClusterContainer ){
222 (*offsets)[clusterCollection->identifyHash()] = counter;
225 if( clusterCollection->empty() )
continue;
238 unsigned int cluster_idx = xaod->size();
239 xaod->push_back(xprd);
255 if(localCov.size() == 1){
257 }
else if(localCov.size() == 4){
264 std::vector< uint64_t > rdoIdentifierList;
265 rdoIdentifierList.reserve(prd->rdoList().size());
266 int rowmin=9999;
int rowmax=-9999;
267 int colmin=9999;
int colmax=-9999;
268 for(
const auto &hitIdentifier : prd->rdoList() ){
269 rdoIdentifierList.push_back( hitIdentifier.get_compact() );
273 if(rowmin > row) rowmin = row;
274 if(rowmax < row) rowmax = row;
275 if(colmin > col) colmin = col;
276 if(colmax < col) colmax = col;
285 AUXDATA(xprd,
int,layer) = the_layer ;
286 AUXDATA(xprd,
int,phi_module) = the_phi ;
287 AUXDATA(xprd,
int,eta_module) = the_eta ;
291 cluster_map[ makeKey(the_phi, the_eta, the_layer)].push_back(cluster_idx);
296 AUXDATA(xprd,
int,nRDO) = (int)prd->rdoList().size();
299 AUXDATA(xprd,
int,ToT) = prd->totalToT();
300 AUXDATA(xprd,
int,LVL1A) = prd->LVL1A();
302 AUXDATA(xprd,
char,isFake) = (char)prd->isFake();
303 AUXDATA(xprd,
char,gangedPixel) = (char)prd->gangedPixel();
306 AUXDATA(xprd,
char,isSplit) =
static_cast<char>(splitProb.
isSplit());
317 AUXDATA(xprd,
int,DCSState) = dcsState->getModuleStatus(moduleHash);
319 float deplVoltage = 0.0;
320 AUXDATA(xprd,
float,BiasVoltage) = dcsHV->getBiasVoltage(moduleHash);
321 AUXDATA(xprd,
float,Temperature) = dcsTemp->getTemperature(moduleHash);
322 AUXDATA(xprd,
float,DepletionVoltage) = deplVoltage;
333 uint64_t detElementId(0);
340 AUXDATA(xprd,uint64_t,detectorElementID) = detElementId;
352 AUXDATA(xprd,
float,centroid_xphi) = centroid.
xPhi();
353 AUXDATA(xprd,
float,centroid_xeta) = centroid.
xEta();
355 AUXDATA(xprd,
float,omegax) = prd->omegax();
356 AUXDATA(xprd,
float,omegay) = prd->omegay();
361 auto range{prdmtColl->equal_range(clusterId)};
362 if (truth_particle_links) {
363 std::vector<unsigned int> tp_indices;
364 for (
auto i{range.first}; i!=range.second; ++i) {
366 if (a_truth_particle_link) {
368 if (truth_particle) {
370 tp_indices.push_back(
static_cast<int>(truth_particle->index()));
373 ++missing_parent_particle;
377 tp_indices.push_back(std::numeric_limits<unsigned int>::max());
378 ++missing_truth_particle;
382 AUXDATA(xprd,std::vector<unsigned int>, truth_index) = std::move(tp_indices);
384 std::vector<int> uniqueIDs;
385 for (
auto i = range.first; i != range.second; ++i) {
388 AUXDATA(xprd,std::vector<int>, truth_barcode) = std::move(uniqueIDs);
391 std::vector< std::vector< int > > sdo_tracks;
413 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr ) {
414 AUXDATA(*clusItr,
char,broken) =
false;
420 static const SG::AuxElement::Accessor<int> acc_layer (
"layer");
421 static const SG::AuxElement::Accessor<int> acc_phi_module (
"phi_module");
422 static const SG::AuxElement::Accessor<int> acc_eta_module (
"eta_module");
423 static const SG::AuxElement::Accessor<std::vector<int> > acc_sihit_barcode (
"sihit_barcode");
424 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr)
426 auto pixelCluster = *clusItr;
427 int layer = acc_layer(*pixelCluster);
428 std::vector<int> uniqueIDs = acc_sihit_barcode(*pixelCluster);
430 const std::vector< unsigned int> &cluster_idx_list = cluster_map.at( makeKey(acc_phi_module(*pixelCluster), acc_eta_module(*pixelCluster), acc_layer(*pixelCluster) ));
431 for (
unsigned int cluster_idx : cluster_idx_list) {
432 auto pixelCluster2 = xaod->at(cluster_idx);
433 if ( acc_layer(*pixelCluster2) != layer )
435 if ( acc_eta_module(*pixelCluster) != acc_eta_module(*pixelCluster2) )
437 if ( acc_phi_module(*pixelCluster) != acc_phi_module(*pixelCluster2) )
440 std::vector<int> uniqueIDs2 = acc_sihit_barcode(*pixelCluster2);
442 for (
auto uid : uniqueIDs ) {
443 if (std::find(uniqueIDs2.begin(), uniqueIDs2.end(), uid ) == uniqueIDs2.end())
continue;
444 static const SG::AuxElement::Accessor<char> acc_broken (
"broken");
445 acc_broken(*pixelCluster) =
true;
446 acc_broken(*pixelCluster2) =
true;
452 ATH_MSG_DEBUG(
" recorded PixelPrepData objects: size " << xaod->size() );
456 return StatusCode::SUCCESS;
464 std::vector<int> sdo_word;
465 std::vector< std::vector< int > > sdo_depositsUniqueID;
466 std::vector< std::vector< float > > sdo_depositsEnergy;
468 for(
const auto &hitIdentifier : prd->
rdoList() ){
469 auto pos = sdoCollection.find(hitIdentifier);
470 if( pos == sdoCollection.end() )
continue;
471 sdo_word.push_back( pos->second.word() ) ;
473 std::vector<float> sdoDepEnergy(pos->second.getdeposits().size());
474 unsigned int nDepos{0};
475 for (
auto& deposit: pos->second.getdeposits()) {
478 sdoDepEnergy[nDepos] = deposit.second;
481 sdo_depositsUniqueID.push_back( std::move(sdoDepUID) );
482 sdo_depositsEnergy.push_back( std::move(sdoDepEnergy) );
484 AUXDATA(xprd,std::vector<int>,sdo_words) = std::move(sdo_word);
485 AUXDATA(xprd,std::vector< std::vector<int> >,sdo_depositsBarcode) = sdo_depositsUniqueID;
486 AUXDATA(xprd,std::vector< std::vector<float> >,sdo_depositsEnergy) = std::move(sdo_depositsEnergy);
488 return sdo_depositsUniqueID;
495 const std::vector<SiHit> & matchingHits )
const
498 int numHits = matchingHits.size();
500 std::vector<float> sihit_energyDeposit(numHits,0);
501 std::vector<float> sihit_meanTime(numHits,0);
503 std::vector<int> sihit_pdgid(numHits,0);
505 std::vector<float> sihit_startPosX(numHits,0);
506 std::vector<float> sihit_startPosY(numHits,0);
507 std::vector<float> sihit_startPosZ(numHits,0);
509 std::vector<float> sihit_endPosX(numHits,0);
510 std::vector<float> sihit_endPosY(numHits,0);
511 std::vector<float> sihit_endPosZ(numHits,0);
516 for (
const auto& sihit : matchingHits ) {
517 sihit_energyDeposit[hitNumber] = sihit.energyLoss() ;
518 sihit_meanTime[hitNumber] = sihit.meanTime() ;
522 sihit_pdgid[hitNumber] = HMPL->pdg_id();
526 const HepGeom::Point3D<double>& startPos=sihit.localStartPosition();
529 sihit_startPosX[hitNumber] = pos[0];
530 sihit_startPosY[hitNumber] = pos[1];
531 sihit_startPosZ[hitNumber] = startPos.x();
534 const HepGeom::Point3D<double>& endPos=sihit.localEndPosition();
536 sihit_endPosX[hitNumber] = pos[0];
537 sihit_endPosY[hitNumber] = pos[1];
538 sihit_endPosZ[hitNumber] = endPos.x();
543 AUXDATA(xprd,std::vector<float>,sihit_energyDeposit) = std::move(sihit_energyDeposit);
544 AUXDATA(xprd,std::vector<float>,sihit_meanTime) = std::move(sihit_meanTime);
545 AUXDATA(xprd,std::vector<int>,sihit_barcode) = std::move(sihit_uniqueID);
546 AUXDATA(xprd,std::vector<int>,sihit_pdgid) = std::move(sihit_pdgid);
548 AUXDATA(xprd,std::vector<float>,sihit_startPosX) = std::move(sihit_startPosX);
549 AUXDATA(xprd,std::vector<float>,sihit_startPosY) = std::move(sihit_startPosY);
550 AUXDATA(xprd,std::vector<float>,sihit_startPosZ) = std::move(sihit_startPosZ);
552 AUXDATA(xprd,std::vector<float>,sihit_endPosX) = std::move(sihit_endPosX);
553 AUXDATA(xprd,std::vector<float>,sihit_endPosY) = std::move(sihit_endPosY);
554 AUXDATA(xprd,std::vector<float>,sihit_endPosZ) = std::move(sihit_endPosZ);
565 const std::vector<const SiHit*>* sihits,
566 std::vector< std::vector< int > > & trkUIDs )
const
568 ATH_MSG_VERBOSE(
"Got " << sihits->size() <<
" SiHits to look through" );
569 std::vector<SiHit> matchingHits;
576 std::vector<const SiHit* > multiMatchingHits;
578 for (
const SiHit* siHit : *sihits) {
584 HepGeom::Point3D<double> averagePosition = siHit->localStartPosition() + siHit->localEndPosition();
585 averagePosition *= 0.5;
589 for(
const auto &hitIdentifier : prd->
rdoList() ){
595 multiMatchingHits.push_back(siHit);
603 for (
const auto& uniqueIDSDOColl : trkUIDs ) {
604 if (std::find(uniqueIDSDOColl.begin(),uniqueIDSDOColl.end(),uid) == uniqueIDSDOColl.end() )
continue;
605 multiMatchingHits.push_back(siHit);
611 std::vector<const SiHit* >::iterator siHitIter = multiMatchingHits.begin();
612 std::vector<const SiHit* >::iterator siHitIter2 = multiMatchingHits.begin();
613 ATH_MSG_DEBUG(
"Found " << multiMatchingHits.size() <<
" SiHit " );
614 for ( ; siHitIter != multiMatchingHits.end(); ++siHitIter) {
615 const SiHit* lowestXPos = *siHitIter;
616 const SiHit* highestXPos = *siHitIter;
620 std::vector<const SiHit* > ajoiningHits;
621 ajoiningHits.push_back( *siHitIter );
623 siHitIter2 = siHitIter+1;
624 while ( siHitIter2 != multiMatchingHits.end() ) {
633 if (std::abs((highestXPos->
localEndPosition().x()-(*siHitIter2)->localStartPosition().x()))<0.00005 &&
634 std::abs((highestXPos->
localEndPosition().y()-(*siHitIter2)->localStartPosition().y()))<0.00005 &&
635 std::abs((highestXPos->
localEndPosition().z()-(*siHitIter2)->localStartPosition().z()))<0.00005 )
637 highestXPos = *siHitIter2;
638 ajoiningHits.push_back( *siHitIter2 );
641 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
642 }
else if (std::abs((lowestXPos->
localStartPosition().x()-(*siHitIter2)->localEndPosition().x()))<0.00005 &&
643 std::abs((lowestXPos->
localStartPosition().y()-(*siHitIter2)->localEndPosition().y()))<0.00005 &&
644 std::abs((lowestXPos->
localStartPosition().z()-(*siHitIter2)->localEndPosition().z()))<0.00005)
646 lowestXPos = *siHitIter2;
647 ajoiningHits.push_back( *siHitIter2 );
650 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
656 if( ajoiningHits.size() == 0){
659 }
else if(ajoiningHits.size() == 1){
661 matchingHits.push_back( *ajoiningHits[0] );
665 ATH_MSG_DEBUG(
"Merging " << ajoiningHits.size() <<
" SiHits together." );
670 for(
const auto& siHit : ajoiningHits){
671 energyDep += siHit->energyLoss();
672 time += siHit->meanTime();
674 time /= (float)ajoiningHits.size();
680 (*siHitIter)->particleLink(),
682 (*siHitIter)->getBarrelEndcap(),
683 (*siHitIter)->getLayerDisk(),
684 (*siHitIter)->getEtaModule(),
685 (*siHitIter)->getPhiModule(),
686 (*siHitIter)->getSide() );
687 ATH_MSG_DEBUG(
"Finished Merging " << ajoiningHits.size() <<
" SiHits together." );
704 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
706 const std::vector<float> &chList = pixelCluster->chargeList();
707 const std::vector<int> &totList = pixelCluster->totList();
711 std::vector<int> etaIndexList;
712 std::vector<int> phiIndexList;
713 std::vector<float> CTerm;
714 std::vector<float> ATerm;
715 std::vector<float> ETerm;
720 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
721 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
723 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
725 phiIndexList.reserve( rdos.size());
726 etaIndexList.reserve( rdos.size());
727 CTerm.reserve( rdos.size());
728 ATerm.reserve( rdos.size());
729 ETerm.reserve( rdos.size());
730 for (; rdosBegin!= rdosEnd; ++rdosBegin)
743 CTerm.emplace_back(parameters.C);
744 ATerm.emplace_back(parameters.A);
745 ETerm.emplace_back(parameters.E);
750 AUXDATA(xprd, std::vector<int>,rdo_phi_pixel_index) = std::move(phiIndexList);
751 AUXDATA(xprd, std::vector<int>,rdo_eta_pixel_index) = std::move(etaIndexList);
752 AUXDATA(xprd, std::vector<float>,rdo_charge) = chList;
753 AUXDATA(xprd, std::vector<int>,rdo_tot) = totList;
755 AUXDATA(xprd, std::vector<float>,rdo_Cterm) = std::move(CTerm);
756 AUXDATA(xprd, std::vector<float>,rdo_Aterm) = std::move(ATerm);
757 AUXDATA(xprd, std::vector<float>,rdo_Eterm) = std::move(ETerm);
764 const unsigned int sizeX,
const unsigned int sizeY )
const
777 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNInformation'");
780 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
782 const std::vector<float>& chList = pixelCluster->chargeList();
783 const std::vector<int>& totList = pixelCluster->totList();
791 int phiPixelIndexMin, phiPixelIndexMax, etaPixelIndexMin, etaPixelIndexMax;
794 if (!cellIdWeightedPosition.
isValid())
799 int etaPixelIndexWeightedPosition=cellIdWeightedPosition.
etaIndex();
800 int phiPixelIndexWeightedPosition=cellIdWeightedPosition.
phiIndex();
803 ATH_MSG_DEBUG(
" weighted pos phiPixelIndex: " << phiPixelIndexWeightedPosition <<
" etaPixelIndex: " << etaPixelIndexWeightedPosition );
821 double localEtaPixelIndexWeightedPosition = w.xEta();
822 double localPhiPixelIndexWeightedPosition = w.xPhi();
824 int centralIndexX=(sizeX-1)/2;
825 int centralIndexY=(sizeY-1)/2;
831 if (abs(phiPixelIndexWeightedPosition-phiPixelIndexMin)>centralIndexX ||
832 abs(phiPixelIndexWeightedPosition-phiPixelIndexMax)>centralIndexX)
834 ATH_MSG_DEBUG(
" Cluster too large phiPixelIndexMin " << phiPixelIndexMin <<
" phiPixelIndexMax " << phiPixelIndexMax <<
" centralX " << centralIndexX);
838 if (abs(etaPixelIndexWeightedPosition-etaPixelIndexMin)>centralIndexY ||
839 abs(etaPixelIndexWeightedPosition-etaPixelIndexMax)>centralIndexY)
841 ATH_MSG_DEBUG(
" Cluster too large etaPixelIndexMin" << etaPixelIndexMin <<
" etaPixelIndexMax " << etaPixelIndexMax <<
" centralY " << centralIndexY);
845 std::vector< std::vector<float> > matrixOfToT (sizeX, std::vector<float>(sizeY,0) );
846 std::vector< std::vector<float> > matrixOfCharge(sizeX, std::vector<float>(sizeY,0));
850 std::vector<float> vectorOfPitchesY(sizeY, design->
etaPitch());
851 std::vector<float> vectorOfPitchesX(sizeX, design->
phiPitch());
855 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
856 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
857 auto charge = chList.begin();
858 auto tot = totList.begin();
860 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
862 for (; rdosBegin!= rdosEnd; ++rdosBegin)
866 int absphiPixelIndex =
m_PixelHelper->phi_index(rId)-phiPixelIndexWeightedPosition + centralIndexX;
867 int absetaPixelIndex =
m_PixelHelper->eta_index(rId)-etaPixelIndexWeightedPosition + centralIndexY;
868 if (
charge != chList.end()){
869 ATH_MSG_VERBOSE(
" Phi Index: " <<
m_PixelHelper->phi_index(rId) <<
" absphiPixelIndex: " << absphiPixelIndex <<
" eta Idx: " <<
m_PixelHelper->eta_index(rId) <<
" absetaPixelIndex: " << absetaPixelIndex <<
" charge " << *
charge );
871 if (absphiPixelIndex <0 || absphiPixelIndex >= (
int)sizeX)
873 ATH_MSG_DEBUG(
" problem with index: " << absphiPixelIndex <<
" min: " << 0 <<
" max: " << sizeX);
877 if (absetaPixelIndex <0 || absetaPixelIndex >= (
int)sizeY)
879 ATH_MSG_DEBUG(
" problem with index: " << absetaPixelIndex <<
" min: " << 0 <<
" max: " << sizeY);
885 float pitchY = diodeParameters.
width().
xEta();
886 float pitchX = diodeParameters.
width().
xPhi();
888 if ( (not totList.empty()) && tot != totList.end()) {
889 matrixOfToT[absphiPixelIndex][absetaPixelIndex] =*tot;
891 }
else matrixOfToT[absphiPixelIndex][absetaPixelIndex] = -1;
893 if ( (not chList.empty()) &&
charge != chList.end()){
894 matrixOfCharge[absphiPixelIndex][absetaPixelIndex]=*
charge;
896 }
else matrixOfCharge[absphiPixelIndex][absetaPixelIndex] = -1;
901 vectorOfPitchesY[absetaPixelIndex]=pitchY;
902 vectorOfPitchesX[absphiPixelIndex]=pitchX;
910 const Amg::Vector2D& prdLocPos = pixelCluster->localPosition();
915 trackDir.normalize();
922 float trkphicomp = trackDir.dot(module_phiax);
923 float trketacomp = trackDir.dot(module_etaax);
924 float trknormcomp = trackDir.dot(module_normal);
925 double bowphi = atan2(trkphicomp,trknormcomp);
926 double boweta = atan2(trketacomp,trknormcomp);
928 if(bowphi >
pi/2) bowphi -=
pi;
929 if(bowphi < -
pi/2) bowphi +=
pi;
931 double angle = atan(tan(bowphi)-readoutside*tanl);
936 if (boweta>
pi/2.) boweta-=
pi;
937 if (boweta<-
pi/2.) boweta+=
pi;
941 ATH_MSG_VERBOSE(
" PhiPixelIndexWeightedPosition: " << phiPixelIndexWeightedPosition <<
" EtaPixelIndexWeightedPosition: " << etaPixelIndexWeightedPosition );
944 std::vector<float> vectorOfCharge(sizeX*sizeY,0);
945 std::vector<float> vectorOfToT(sizeX*sizeY,0);
947 for (
unsigned int u=0;u<sizeX;u++)
949 for (
unsigned int s=0;s<sizeY;s++)
951 vectorOfToT[counter] = matrixOfToT[u][s];
952 vectorOfCharge[counter] = matrixOfCharge[u][s];
961 AUXDATA(xprd,
int, NN_sizeX) = sizeX;
962 AUXDATA(xprd,
int, NN_sizeY) = sizeY;
965 AUXDATA(xprd,
float, NN_thetaBS) = boweta;
967 AUXDATA(xprd, std::vector<float>, NN_matrixOfToT) = std::move(vectorOfToT);
968 AUXDATA(xprd, std::vector<float>, NN_matrixOfCharge) = std::move(vectorOfCharge);
969 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesY) = std::move(vectorOfPitchesY);
970 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesX) = std::move(vectorOfPitchesX);
973 AUXDATA(xprd,
int, NN_etaPixelIndexWeightedPosition) = etaPixelIndexWeightedPosition;
974 AUXDATA(xprd,
int, NN_phiPixelIndexWeightedPosition) = phiPixelIndexWeightedPosition;
976 AUXDATA(xprd,
float, NN_localEtaPixelIndexWeightedPosition) = localEtaPixelIndexWeightedPosition;
977 AUXDATA(xprd,
float, NN_localPhiPixelIndexWeightedPosition) = localPhiPixelIndexWeightedPosition;
984 const std::vector<SiHit> & matchingHits )
const
988 unsigned int numberOfSiHits = matchingHits.size();
990 std::vector<float> positionsX(numberOfSiHits,0);
991 std::vector<float> positionsY(numberOfSiHits,0);
993 std::vector<float> positions_indexX(numberOfSiHits,0);
994 std::vector<float> positions_indexY(numberOfSiHits,0);
996 std::vector<float>
theta(numberOfSiHits,0);
997 std::vector<float>
phi(numberOfSiHits,0);
1000 std::vector<int> pdgid(numberOfSiHits,0);
1001 std::vector<float> chargeDep(numberOfSiHits,0);
1002 std::vector<float> truep(numberOfSiHits,0);
1004 std::vector<float> pathlengthX(numberOfSiHits,0);
1005 std::vector<float> pathlengthY(numberOfSiHits,0);
1006 std::vector<float> pathlengthZ(numberOfSiHits,0);
1009 std::vector<int> motherPdgid(numberOfSiHits,0);
1022 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNTruthInfo'");
1027 unsigned hitNumber(0);
1028 for(
const auto& siHit : matchingHits ){
1030 HepGeom::Point3D<double> averagePosition = (siHit.localStartPosition() + siHit.localEndPosition()) * 0.5;
1032 ATH_MSG_VERBOSE(
"Truth Part X: " << averagePosition.y() <<
" shift " << shift <<
" Y: " << averagePosition.z() );
1035 float YposC = averagePosition.y()-shift;
1037 if (std::abs(YposC)>design->
width()/2 &&
1038 std::abs(averagePosition.y())<design->
width()/2)
1040 if (YposC>design->
width()/2)
1042 YposC=design->
width()/2-1e-6;
1043 }
else if (YposC<-design->
width()/2)
1045 YposC=-design->
width()/2+1e-6;
1049 positionsX[hitNumber] = YposC;
1050 positionsY[hitNumber] = averagePosition.z();
1052 HepGeom::Point3D<double> deltaPosition = siHit.localEndPosition() - siHit.localStartPosition();
1054 pathlengthX[hitNumber] = deltaPosition.y();
1055 pathlengthY[hitNumber] = deltaPosition.z();
1056 pathlengthZ[hitNumber] = deltaPosition.x();
1067 int truthEtaIndex = cellIdOfTruthPosition.
etaIndex();
1068 int truthPhiIndex = cellIdOfTruthPosition.
phiIndex();
1071 double pitchY = diodeParameters.
width().
xEta();
1072 double pitchX = diodeParameters.
width().
xPhi();
1089 double pixelCenterY = siLocalPositionCenter.
xEta();
1090 double pixelCenterX = siLocalPositionCenter.
xPhi();
1096 double truthIndexY = truthEtaIndex + (siLocalTruthPosition[
Trk::distEta] - pixelCenterY)/pitchY;
1097 double truthIndexX = truthPhiIndex + (siLocalTruthPosition[
Trk::distPhi] - pixelCenterX)/pitchX;
1100 positions_indexX[hitNumber] = truthIndexX - cellIdWeightedPosition.
phiIndex();
1101 positions_indexY[hitNumber] = truthIndexY - cellIdWeightedPosition.
etaIndex();
1103 HepGeom::Point3D<double> diffPositions = (siHit.localEndPosition() - siHit.localStartPosition());
1104 double bowphi = std::atan2( diffPositions.y(), diffPositions.x() );
1108 theta[hitNumber] = std::atan2(diffPositions.z() ,diffPositions.x());
1113 phi[hitNumber] = std::atan(std::tan(bowphi)-readoutside*tanlorentz);
1117 const auto particle = HMPL.
cptr();
1118 pdgid[hitNumber] = particle->pdg_id();
1120 truep[hitNumber] = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
1121 const auto vertex = particle->production_vertex();
1123 if ( vertex && !vertex->particles_in().empty()){
1124 const auto& mother_of_particle=vertex->particles_in().front();
1126 motherPdgid[hitNumber] = mother_of_particle->pdg_id();
1129 chargeDep[hitNumber] = siHit.energyLoss() ;
1135 AUXDATA(xprd, std::vector<float>, NN_positionsX) = std::move(positionsX);
1136 AUXDATA(xprd, std::vector<float>, NN_positionsY) = std::move(positionsY);
1138 AUXDATA(xprd, std::vector<float>, NN_positions_indexX) = std::move(positions_indexX);
1139 AUXDATA(xprd, std::vector<float>, NN_positions_indexY) = std::move(positions_indexY);
1141 AUXDATA(xprd, std::vector<float>, NN_theta) = std::move(
theta);
1142 AUXDATA(xprd, std::vector<float>, NN_phi) = std::move(
phi);
1144 AUXDATA(xprd, std::vector<int>, NN_barcode) = std::move(uniqueID);
1145 AUXDATA(xprd, std::vector<int>, NN_pdgid) = std::move(pdgid);
1146 AUXDATA(xprd, std::vector<float>, NN_energyDep) = std::move(chargeDep);
1147 AUXDATA(xprd, std::vector<float>, NN_trueP) = std::move(truep);
1149 AUXDATA(xprd, std::vector<int>, NN_motherBarcode) = std::move(motherUniqueID);
1150 AUXDATA(xprd, std::vector<int>, NN_motherPdgid) = std::move(motherPdgid);
1154 AUXDATA(xprd, std::vector<float>, NN_pathlengthX) = std::move(pathlengthX);
1155 AUXDATA(xprd, std::vector<float>, NN_pathlengthY) = std::move(pathlengthY);
1156 AUXDATA(xprd, std::vector<float>, NN_pathlengthZ) = std::move(pathlengthZ);
1165 int *rphiPixelIndexMin,
1166 int *rphiPixelIndexMax,
1167 int *retaPixelIndexMin,
1168 int *retaPixelIndexMax )
const
1179 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'getCellIdWeightedPosition'");
1182 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
1185 const std::vector<float>& chList = pixelCluster->chargeList();
1188 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
1189 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
1191 auto charge = chList.begin();
1194 double sumOfCharge=0;
1196 int phiPixelIndexMin = 99999;
1197 int phiPixelIndexMax = -99999;
1198 int etaPixelIndexMin = 99999;
1199 int etaPixelIndexMax = -99999;
1201 for (; rdosBegin!= rdosEnd; ++rdosBegin, ++
charge)
1208 ATH_MSG_VERBOSE(
" Adding pixel phiPixelIndex: " << phiPixelIndex <<
" etaPixelIndex: " << etaPixelIndex <<
" charge: " << *
charge );
1226 sumOfWeightedPositions += (*charge)*siLocalPosition;
1227 sumOfCharge += (*charge);
1229 if (phiPixelIndex < phiPixelIndexMin)
1230 phiPixelIndexMin = phiPixelIndex;
1232 if (phiPixelIndex > phiPixelIndexMax)
1233 phiPixelIndexMax = phiPixelIndex;
1235 if (etaPixelIndex < etaPixelIndexMin)
1236 etaPixelIndexMin = etaPixelIndex;
1238 if (etaPixelIndex > etaPixelIndexMax)
1239 etaPixelIndexMax = etaPixelIndex;
1242 sumOfWeightedPositions /= sumOfCharge;
1244 ATH_MSG_VERBOSE (
"Wighted position: Row = " << sumOfWeightedPositions.
xRow() <<
", Col = " << sumOfWeightedPositions.
xColumn() );
1246 if(rphiPixelIndexMin) *rphiPixelIndexMin = phiPixelIndexMin;
1247 if(rphiPixelIndexMax) *rphiPixelIndexMax = phiPixelIndexMax;
1248 if(retaPixelIndexMin) *retaPixelIndexMin = etaPixelIndexMin;
1249 if(retaPixelIndexMax) *retaPixelIndexMax = etaPixelIndexMax;
1257 return cellIdWeightedPosition;
1274 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Structs for holding charge calibration parameterisation and data.
This is an Identifier helper class for the Pixel subdetector.
#define AUXDATA(OBJ, TYP, NAME)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
ElementLink implementation for ROOT usage.
a link optimized in size for a GenParticle in a McEventCollection
bool isValid() const
Validity check.
HepMC::ConstGenParticlePtr cptr() const
Dereference.
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
value_type get_compact() const
Get the compact id.
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
SiLocalPosition positionFromColumnRow(const int column, const int row) const
Given row and column index of a diode, return position of diode center ALTERNATIVE/PREFERED way is to...
virtual SiCellId cellIdOfPosition(const SiLocalPosition &localPos) const
position -> id
virtual double width() const
Method to calculate average width of a module.
virtual double etaPitch() const
Pitch in eta direction.
virtual double phiPitch() const
Pitch in phi direction.
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 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):
Class to handle the position of the centre and the width of a diode or a cluster of diodes Version 1....
const SiLocalPosition & width() const
width of the diodes:
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 xColumn() const
positions for Pixel:
double xEta() const
position along eta direction:
SiCellId cellIdOfPosition(const Amg::Vector2D &localPos) const
As in previous method but returns SiCellId.
const Amg::Vector3D & etaAxis() const
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)
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
virtual Identifier identify() const override final
identifier of this detector element (inline)
const Amg::Vector3D & phiAxis() const
Amg::Vector2D hitLocalToLocal(double xEta, double xPhi) const
Simulation/Hit local frame to reconstruction local frame.
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
const Amg::Vector2D & colRow() const
A PRD is mapped onto all contributing particles.
PixelChargeCalib::LegacyFitParameters getLegacyFitParameters(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE) const
bool m_useSiHitsGeometryMatching
void addNNInformation(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *pixelCluster, const unsigned int SizeX, const unsigned int SizeY) const
SG::WriteHandleKey< std::vector< unsigned int > > m_write_offsets
void addRdoInformation(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *pixelCluster, const PixelChargeCalibCondData *calibData) const
bool m_writeRDOinformation
std::atomic< unsigned int > m_missingTruthParticle
const PixelID * m_PixelHelper
SG::ReadCondHandleKey< PixelDCSHVData > m_readKeyHV
bool m_writeNNinformation
SG::ReadHandleKey< SiHitCollection > m_sihitContainer_key
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
void addSiHitInformation(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *prd, const std::vector< SiHit > &matchingHits) const
SG::ReadHandleKey< Trk::ClusterSplitProbabilityContainer > m_clusterSplitProbContainer
virtual StatusCode execute(const EventContext &ctx)
Execute method.
PixelPrepDataToxAOD(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< SiHit > findAllHitsCompatibleWithCluster(const InDet::PixelCluster *prd, const std::vector< const SiHit * > *sihits, std::vector< std::vector< int > > &trkBCs) const
ToolHandle< IInDetConditionsTool > m_pixelSummary
SG::ReadHandleKey< xAODTruthParticleLinkVector > m_truthParticleLinks
SG::ReadCondHandleKey< PixelDCSTempData > m_readKeyTemp
InDetDD::SiCellId getCellIdWeightedPosition(const InDet::PixelCluster *pixelCluster, int *rrowMin=0, int *rrowMax=0, int *rcolMin=0, int *rcolMax=0) const
SG::ReadHandleKey< InDetSimDataCollection > m_SDOcontainer_key
SG::ReadCondHandleKey< PixelDCSStatusData > m_condDCSStatusKey
std::atomic< unsigned int > m_missingParentParticle
void addNNTruthInfo(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *prd, const std::vector< SiHit > &matchingHits) const
bool m_writeExtendedPRDinformation
virtual StatusCode finalize()
SG::ReadHandleKey< InDet::PixelClusterContainer > m_clustercontainer_key
SG::ReadHandleKey< PRD_MultiTruthCollection > m_multiTruth_key
SG::ReadCondHandleKey< PixelDCSStateData > m_condDCSStateKey
SG::WriteHandleKey< xAOD::TrackMeasurementValidationContainer > m_write_xaod_key
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
bool m_firstEventWarnings
std::vector< std::vector< int > > addSDOInformation(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *prd, const InDetSimDataCollection &sdoCollection) const
virtual StatusCode initialize()
std::atomic< unsigned int > m_haveTruthLink
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
HepGeom::Point3D< double > localStartPosition() const
HepGeom::Point3D< double > localEndPosition() const
static const ProbabilityInfo & getNoSplitProbability()
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
ElementLink< xAOD::TruthParticleContainer > find(const HepMcParticleLink &hepMCLink) const
void setRdoIdentifierList(const std::vector< uint64_t > &rdoIdentifierList)
Sets the list of RDO identifiers.
void setLocalPositionError(float localXError, float localYError, float localXYCorrelation)
Sets the local position error.
void setLocalPosition(float localX, float localY)
Sets the local position.
void setIdentifier(uint64_t identifier)
Sets the identifier.
void setGlobalPosition(float globalX, float globalY, float globalZ)
Sets the global position.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr int INVALID_PARTICLE_ID
HepMC3::FourVector FourVector
constexpr int UNDEFINED_ID
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
@ distEta
readout for silicon
TrackMeasurementValidation_v1 TrackMeasurementValidation
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
float splitProbability1() const
float splitProbability2() const