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;
72 DisableTool{!(m_writeRDOinformation || m_writeModuleStatus)} ));
88 return StatusCode::SUCCESS;
101 if ( !PixelClusterContainer.isValid() )
103 ATH_MSG_ERROR(
"Failed to retrieve PixelClusterContainer with key" << PixelClusterContainer.key() );
104 return StatusCode::FAILURE;
111 if (prdmtCollHandle.
isValid()) {
112 prdmtColl = &*prdmtCollHandle;
116 if (truthParticleLinksHandle.
isValid()) {
117 truth_particle_links = truthParticleLinksHandle.
cptr();
125 if (sdoCollectionHandle.
isValid()) {
126 sdoCollection = &*sdoCollectionHandle;
128 ATH_MSG_WARNING(
"SDO information requested, but SDO collection not available!");
133 bool foundSplitProbContainer =
false;
136 if (!splitProbContainer.
isValid()) {
139 foundSplitProbContainer =
true;
142 std::vector<std::vector<const SiHit*>> siHits(
m_PixelHelper->wafer_hash_max());
145 if (siHitCollectionHandle.
isValid()) {
146 for (
const SiHit& siHit: *siHitCollectionHandle) {
148 if (!siHit.isPixel())
continue;
151 siHit.getLayerDisk(),
152 siHit.getPhiModule(),
153 siHit.getEtaModule()));
156 siHits[wafer_hash].push_back(&siHit);
159 ATH_MSG_WARNING(
"SiHit information requested, but SiHit collection not available!");
166 if (!calibData_handle.
isValid()) {
169 calibData=calibData_handle.
cptr();
174 ATH_CHECK(xaod.
record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
175 std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
180 unsigned int have_truth_link=0u;
181 unsigned int missing_truth_particle=0u;
182 unsigned int missing_parent_particle=0u;
184 unsigned int counter(0);
190 std::unordered_map< unsigned int , std::vector<unsigned int> > cluster_map;
191 for(
const auto clusterCollection : * PixelClusterContainer ){
194 (*offsets)[clusterCollection->identifyHash()] = counter;
197 if( clusterCollection->empty() )
continue;
210 unsigned int cluster_idx = xaod->size();
211 xaod->push_back(xprd);
227 if(localCov.size() == 1){
229 }
else if(localCov.size() == 4){
236 std::vector< uint64_t > rdoIdentifierList;
237 rdoIdentifierList.reserve(prd->rdoList().size());
238 int rowmin=9999;
int rowmax=-9999;
239 int colmin=9999;
int colmax=-9999;
240 for(
const auto &hitIdentifier : prd->rdoList() ){
241 rdoIdentifierList.push_back( hitIdentifier.get_compact() );
245 if(rowmin > row) rowmin = row;
246 if(rowmax < row) rowmax = row;
247 if(colmin > col) colmin = col;
248 if(colmax < col) colmax = col;
257 AUXDATA(xprd,
int,layer) = the_layer ;
258 AUXDATA(xprd,
int,phi_module) = the_phi ;
259 AUXDATA(xprd,
int,eta_module) = the_eta ;
265 cluster_map[ makeKey(the_phi, the_eta, the_layer)].push_back(cluster_idx);
271 AUXDATA(xprd,
int,nRDO) = (int)prd->rdoList().size();
274 AUXDATA(xprd,
int,ToT) = prd->totalToT();
275 AUXDATA(xprd,
int,LVL1A) = prd->LVL1A();
277 AUXDATA(xprd,
char,isFake) = (char)prd->isFake();
278 AUXDATA(xprd,
char,gangedPixel) = (char)prd->gangedPixel();
281 AUXDATA(xprd,
char,isSplit) =
static_cast<char>(splitProb.
isSplit());
292 AUXDATA(xprd,
int,DCSState) = dcsState->getModuleStatus(moduleHash);
299 float deplVoltage = 0.0;
300 AUXDATA(xprd,
float,BiasVoltage) = dcsHV->getBiasVoltage(moduleHash);
301 AUXDATA(xprd,
float,Temperature) = dcsTemp->getTemperature(moduleHash);
302 AUXDATA(xprd,
float,DepletionVoltage) = deplVoltage;
313 uint64_t detElementId(0);
320 AUXDATA(xprd,uint64_t,detectorElementID) = detElementId;
332 AUXDATA(xprd,
float,centroid_xphi) = centroid.
xPhi();
333 AUXDATA(xprd,
float,centroid_xeta) = centroid.
xEta();
335 AUXDATA(xprd,
float,omegax) = prd->omegax();
336 AUXDATA(xprd,
float,omegay) = prd->omegay();
341 auto range{prdmtColl->equal_range(clusterId)};
342 if (truth_particle_links) {
343 std::vector<unsigned int> tp_indices;
344 for (
auto i{range.first}; i!=range.second; ++i) {
346 if (a_truth_particle_link) {
348 if (truth_particle) {
350 tp_indices.push_back(
static_cast<int>(truth_particle->index()));
353 ++missing_parent_particle;
357 tp_indices.push_back(std::numeric_limits<unsigned int>::max());
358 ++missing_truth_particle;
362 AUXDATA(xprd,std::vector<unsigned int>, truth_index) = std::move(tp_indices);
364 std::vector<int> uniqueIDs;
365 for (
auto i = range.first; i != range.second; ++i) {
368 AUXDATA(xprd,std::vector<int>, truth_barcode) = std::move(uniqueIDs);
371 std::vector< std::vector< int > > sdo_tracks;
393 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr ) {
394 AUXDATA(*clusItr,
char,broken) =
false;
403 static const SG::AuxElement::Accessor<int> acc_layer (
"layer");
404 static const SG::AuxElement::Accessor<int> acc_phi_module (
"phi_module");
405 static const SG::AuxElement::Accessor<int> acc_eta_module (
"eta_module");
406 static const SG::AuxElement::Accessor<std::vector<int> > acc_sihit_barcode (
"sihit_barcode");
407 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr)
409 auto pixelCluster = *clusItr;
410 int layer = acc_layer(*pixelCluster);
411 std::vector<int> uniqueIDs = acc_sihit_barcode(*pixelCluster);
413 const std::vector< unsigned int> &cluster_idx_list = cluster_map.at( makeKey(acc_phi_module(*pixelCluster), acc_eta_module(*pixelCluster), acc_layer(*pixelCluster) ));
414 for (
unsigned int cluster_idx : cluster_idx_list) {
415 auto pixelCluster2 = xaod->at(cluster_idx);
416 if ( acc_layer(*pixelCluster2) != layer )
418 if ( acc_eta_module(*pixelCluster) != acc_eta_module(*pixelCluster2) )
420 if ( acc_phi_module(*pixelCluster) != acc_phi_module(*pixelCluster2) )
423 std::vector<int> uniqueIDs2 = acc_sihit_barcode(*pixelCluster2);
425 for (
auto uid : uniqueIDs ) {
426 if (std::find(uniqueIDs2.begin(), uniqueIDs2.end(), uid ) == uniqueIDs2.end())
continue;
427 static const SG::AuxElement::Accessor<char> acc_broken (
"broken");
428 acc_broken(*pixelCluster) =
true;
429 acc_broken(*pixelCluster2) =
true;
436 ATH_MSG_DEBUG(
" recorded PixelPrepData objects: size " << xaod->size() );
440 return StatusCode::SUCCESS;
448 std::vector<int> sdo_word;
449 std::vector< std::vector< int > > sdo_depositsUniqueID;
450 std::vector< std::vector< float > > sdo_depositsEnergy;
452 for(
const auto &hitIdentifier : prd->
rdoList() ){
453 auto pos = sdoCollection.find(hitIdentifier);
454 if( pos == sdoCollection.end() )
continue;
455 sdo_word.push_back( pos->second.word() ) ;
457 std::vector<float> sdoDepEnergy(pos->second.getdeposits().size());
458 unsigned int nDepos{0};
459 for (
auto& deposit: pos->second.getdeposits()) {
462 sdoDepEnergy[nDepos] = deposit.second;
465 sdo_depositsUniqueID.push_back( std::move(sdoDepUID) );
466 sdo_depositsEnergy.push_back( std::move(sdoDepEnergy) );
468 AUXDATA(xprd,std::vector<int>,sdo_words) = std::move(sdo_word);
469 AUXDATA(xprd,std::vector< std::vector<int> >,sdo_depositsBarcode) = sdo_depositsUniqueID;
470 AUXDATA(xprd,std::vector< std::vector<float> >,sdo_depositsEnergy) = std::move(sdo_depositsEnergy);
472 return sdo_depositsUniqueID;
479 const std::vector<SiHit> & matchingHits )
const
482 int numHits = matchingHits.size();
484 std::vector<float> sihit_energyDeposit(numHits,0);
485 std::vector<float> sihit_meanTime(numHits,0);
487 std::vector<int> sihit_pdgid(numHits,0);
489 std::vector<float> sihit_startPosX(numHits,0);
490 std::vector<float> sihit_startPosY(numHits,0);
491 std::vector<float> sihit_startPosZ(numHits,0);
493 std::vector<float> sihit_endPosX(numHits,0);
494 std::vector<float> sihit_endPosY(numHits,0);
495 std::vector<float> sihit_endPosZ(numHits,0);
500 for (
const auto& sihit : matchingHits ) {
501 sihit_energyDeposit[hitNumber] = sihit.energyLoss() ;
502 sihit_meanTime[hitNumber] = sihit.meanTime() ;
506 sihit_pdgid[hitNumber] = HMPL->pdg_id();
510 const HepGeom::Point3D<double>& startPos=sihit.localStartPosition();
513 sihit_startPosX[hitNumber] = pos[0];
514 sihit_startPosY[hitNumber] = pos[1];
515 sihit_startPosZ[hitNumber] = startPos.x();
518 const HepGeom::Point3D<double>& endPos=sihit.localEndPosition();
520 sihit_endPosX[hitNumber] = pos[0];
521 sihit_endPosY[hitNumber] = pos[1];
522 sihit_endPosZ[hitNumber] = endPos.x();
527 AUXDATA(xprd,std::vector<float>,sihit_energyDeposit) = std::move(sihit_energyDeposit);
528 AUXDATA(xprd,std::vector<float>,sihit_meanTime) = std::move(sihit_meanTime);
529 AUXDATA(xprd,std::vector<int>,sihit_barcode) = std::move(sihit_uniqueID);
530 AUXDATA(xprd,std::vector<int>,sihit_pdgid) = std::move(sihit_pdgid);
532 AUXDATA(xprd,std::vector<float>,sihit_startPosX) = std::move(sihit_startPosX);
533 AUXDATA(xprd,std::vector<float>,sihit_startPosY) = std::move(sihit_startPosY);
534 AUXDATA(xprd,std::vector<float>,sihit_startPosZ) = std::move(sihit_startPosZ);
536 AUXDATA(xprd,std::vector<float>,sihit_endPosX) = std::move(sihit_endPosX);
537 AUXDATA(xprd,std::vector<float>,sihit_endPosY) = std::move(sihit_endPosY);
538 AUXDATA(xprd,std::vector<float>,sihit_endPosZ) = std::move(sihit_endPosZ);
549 const std::vector<const SiHit*>* sihits,
550 std::vector< std::vector< int > > & trkUIDs )
const
552 ATH_MSG_VERBOSE(
"Got " << sihits->size() <<
" SiHits to look through" );
553 std::vector<SiHit> matchingHits;
560 std::vector<const SiHit* > multiMatchingHits;
562 for (
const SiHit* siHit : *sihits) {
566 bool matched =
false;
569 HepGeom::Point3D<double> averagePosition = siHit->localStartPosition() + siHit->localEndPosition();
570 averagePosition *= 0.5;
574 for(
const auto &hitIdentifier : prd->
rdoList() ){
580 multiMatchingHits.push_back(siHit);
589 for (
const auto& uniqueIDSDOColl : trkUIDs ) {
590 if (std::find(uniqueIDSDOColl.begin(),uniqueIDSDOColl.end(),uid) == uniqueIDSDOColl.end() )
continue;
591 multiMatchingHits.push_back(siHit);
597 std::vector<const SiHit* >::iterator siHitIter = multiMatchingHits.begin();
598 std::vector<const SiHit* >::iterator siHitIter2 = multiMatchingHits.begin();
599 ATH_MSG_DEBUG(
"Found " << multiMatchingHits.size() <<
" SiHit " );
600 for ( ; siHitIter != multiMatchingHits.end(); ++siHitIter) {
601 const SiHit* lowestXPos = *siHitIter;
602 const SiHit* highestXPos = *siHitIter;
606 std::vector<const SiHit* > ajoiningHits;
607 ajoiningHits.push_back( *siHitIter );
609 siHitIter2 = siHitIter+1;
610 while ( siHitIter2 != multiMatchingHits.end() ) {
619 if (std::abs((highestXPos->
localEndPosition().x()-(*siHitIter2)->localStartPosition().x()))<0.00005 &&
620 std::abs((highestXPos->
localEndPosition().y()-(*siHitIter2)->localStartPosition().y()))<0.00005 &&
621 std::abs((highestXPos->
localEndPosition().z()-(*siHitIter2)->localStartPosition().z()))<0.00005 )
623 highestXPos = *siHitIter2;
624 ajoiningHits.push_back( *siHitIter2 );
627 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
628 }
else if (std::abs((lowestXPos->
localStartPosition().x()-(*siHitIter2)->localEndPosition().x()))<0.00005 &&
629 std::abs((lowestXPos->
localStartPosition().y()-(*siHitIter2)->localEndPosition().y()))<0.00005 &&
630 std::abs((lowestXPos->
localStartPosition().z()-(*siHitIter2)->localEndPosition().z()))<0.00005)
632 lowestXPos = *siHitIter2;
633 ajoiningHits.push_back( *siHitIter2 );
636 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
642 if( ajoiningHits.size() == 0){
645 }
else if(ajoiningHits.size() == 1){
647 matchingHits.push_back( *ajoiningHits[0] );
651 ATH_MSG_DEBUG(
"Merging " << ajoiningHits.size() <<
" SiHits together." );
656 for(
const auto& siHit : ajoiningHits){
657 energyDep += siHit->energyLoss();
658 time += siHit->meanTime();
660 time /= (float)ajoiningHits.size();
666 (*siHitIter)->particleLink(),
668 (*siHitIter)->getBarrelEndcap(),
669 (*siHitIter)->getLayerDisk(),
670 (*siHitIter)->getEtaModule(),
671 (*siHitIter)->getPhiModule(),
672 (*siHitIter)->getSide() );
673 ATH_MSG_DEBUG(
"Finished Merging " << ajoiningHits.size() <<
" SiHits together." );
690 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
692 const std::vector<float> &chList = pixelCluster->chargeList();
693 const std::vector<int> &totList = pixelCluster->totList();
697 std::vector<int> etaIndexList;
698 std::vector<int> phiIndexList;
699 std::vector<float> CTerm;
700 std::vector<float> ATerm;
701 std::vector<float> ETerm;
706 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
707 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
709 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
711 phiIndexList.reserve( rdos.size());
712 etaIndexList.reserve( rdos.size());
713 CTerm.reserve( rdos.size());
714 ATerm.reserve( rdos.size());
715 ETerm.reserve( rdos.size());
716 for (; rdosBegin!= rdosEnd; ++rdosBegin)
729 CTerm.emplace_back(parameters.C);
730 ATerm.emplace_back(parameters.A);
731 ETerm.emplace_back(parameters.E);
736 AUXDATA(xprd, std::vector<int>,rdo_phi_pixel_index) = std::move(phiIndexList);
737 AUXDATA(xprd, std::vector<int>,rdo_eta_pixel_index) = std::move(etaIndexList);
738 AUXDATA(xprd, std::vector<float>,rdo_charge) = chList;
739 AUXDATA(xprd, std::vector<int>,rdo_tot) = totList;
741 AUXDATA(xprd, std::vector<float>,rdo_Cterm) = std::move(CTerm);
742 AUXDATA(xprd, std::vector<float>,rdo_Aterm) = std::move(ATerm);
743 AUXDATA(xprd, std::vector<float>,rdo_Eterm) = std::move(ETerm);
750 const unsigned int sizeX,
const unsigned int sizeY )
const
763 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNInformation'");
766 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
768 const std::vector<float>& chList = pixelCluster->chargeList();
769 const std::vector<int>& totList = pixelCluster->totList();
777 int phiPixelIndexMin, phiPixelIndexMax, etaPixelIndexMin, etaPixelIndexMax;
780 if (!cellIdWeightedPosition.
isValid())
785 int etaPixelIndexWeightedPosition=cellIdWeightedPosition.
etaIndex();
786 int phiPixelIndexWeightedPosition=cellIdWeightedPosition.
phiIndex();
789 ATH_MSG_DEBUG(
" weighted pos phiPixelIndex: " << phiPixelIndexWeightedPosition <<
" etaPixelIndex: " << etaPixelIndexWeightedPosition );
807 double localEtaPixelIndexWeightedPosition = w.xEta();
808 double localPhiPixelIndexWeightedPosition = w.xPhi();
810 int centralIndexX=(sizeX-1)/2;
811 int centralIndexY=(sizeY-1)/2;
817 if (abs(phiPixelIndexWeightedPosition-phiPixelIndexMin)>centralIndexX ||
818 abs(phiPixelIndexWeightedPosition-phiPixelIndexMax)>centralIndexX)
820 ATH_MSG_DEBUG(
" Cluster too large phiPixelIndexMin " << phiPixelIndexMin <<
" phiPixelIndexMax " << phiPixelIndexMax <<
" centralX " << centralIndexX);
824 if (abs(etaPixelIndexWeightedPosition-etaPixelIndexMin)>centralIndexY ||
825 abs(etaPixelIndexWeightedPosition-etaPixelIndexMax)>centralIndexY)
827 ATH_MSG_DEBUG(
" Cluster too large etaPixelIndexMin" << etaPixelIndexMin <<
" etaPixelIndexMax " << etaPixelIndexMax <<
" centralY " << centralIndexY);
831 std::vector< std::vector<float> > matrixOfToT (sizeX, std::vector<float>(sizeY,0) );
832 std::vector< std::vector<float> > matrixOfCharge(sizeX, std::vector<float>(sizeY,0));
836 std::vector<float> vectorOfPitchesY(sizeY, 0.f);
837 std::vector<float> vectorOfPitchesX(sizeX, 0.f);
838 for (
unsigned int iy = 0; iy < sizeY; ++iy) {
839 const int etaIdx = etaPixelIndexWeightedPosition + (
static_cast<int>(iy) - centralIndexY);
843 for (
unsigned int ix = 0; ix < sizeX; ++ix) {
844 const int phiIdx = phiPixelIndexWeightedPosition + (
static_cast<int>(ix) - centralIndexX);
851 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
852 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
853 auto charge = chList.begin();
854 auto tot = totList.begin();
856 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
858 for (; rdosBegin!= rdosEnd; ++rdosBegin)
862 int absphiPixelIndex =
m_PixelHelper->phi_index(rId)-phiPixelIndexWeightedPosition + centralIndexX;
863 int absetaPixelIndex =
m_PixelHelper->eta_index(rId)-etaPixelIndexWeightedPosition + centralIndexY;
868 float thisCharge = -1.f;
870 if ((not chList.empty()) &&
charge != chList.end()) { thisCharge = *
charge; ++
charge; }
871 if ((not totList.empty()) && tot != totList.end()) { thisToT = *tot; ++tot; }
874 <<
" absphiPixelIndex: " << absphiPixelIndex
876 <<
" absetaPixelIndex: " << absetaPixelIndex
877 <<
" charge " << thisCharge );
879 if (absphiPixelIndex <0 || absphiPixelIndex >= (
int)sizeX)
881 ATH_MSG_DEBUG(
" problem with index: " << absphiPixelIndex <<
" min: " << 0 <<
" max: " << sizeX);
885 if (absetaPixelIndex <0 || absetaPixelIndex >= (
int)sizeY)
887 ATH_MSG_DEBUG(
" problem with index: " << absetaPixelIndex <<
" min: " << 0 <<
" max: " << sizeY);
891 matrixOfToT[absphiPixelIndex][absetaPixelIndex] = thisToT;
892 matrixOfCharge[absphiPixelIndex][absetaPixelIndex] = thisCharge;
900 const Amg::Vector2D& prdLocPos = pixelCluster->localPosition();
905 trackDir.normalize();
912 float trkphicomp = trackDir.dot(module_phiax);
913 float trketacomp = trackDir.dot(module_etaax);
914 float trknormcomp = trackDir.dot(module_normal);
915 double bowphi = atan2(trkphicomp,trknormcomp);
916 double boweta = atan2(trketacomp,trknormcomp);
918 if(bowphi >
pi/2) bowphi -=
pi;
919 if(bowphi < -
pi/2) bowphi +=
pi;
921 double angle = atan(tan(bowphi)-readoutside*tanl);
926 if (boweta>
pi/2.) boweta-=
pi;
927 if (boweta<-
pi/2.) boweta+=
pi;
931 ATH_MSG_VERBOSE(
" PhiPixelIndexWeightedPosition: " << phiPixelIndexWeightedPosition <<
" EtaPixelIndexWeightedPosition: " << etaPixelIndexWeightedPosition );
934 std::vector<float> vectorOfCharge(sizeX*sizeY,0);
935 std::vector<float> vectorOfToT(sizeX*sizeY,0);
937 for (
unsigned int u=0;u<sizeX;u++)
939 for (
unsigned int s=0;s<sizeY;s++)
941 vectorOfToT[counter] = matrixOfToT[u][s];
942 vectorOfCharge[counter] = matrixOfCharge[u][s];
951 AUXDATA(xprd,
int, NN_sizeX) = sizeX;
952 AUXDATA(xprd,
int, NN_sizeY) = sizeY;
955 AUXDATA(xprd,
float, NN_thetaBS) = boweta;
957 AUXDATA(xprd, std::vector<float>, NN_matrixOfToT) = std::move(vectorOfToT);
958 AUXDATA(xprd, std::vector<float>, NN_matrixOfCharge) = std::move(vectorOfCharge);
959 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesY) = std::move(vectorOfPitchesY);
960 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesX) = std::move(vectorOfPitchesX);
963 AUXDATA(xprd,
int, NN_etaPixelIndexWeightedPosition) = etaPixelIndexWeightedPosition;
964 AUXDATA(xprd,
int, NN_phiPixelIndexWeightedPosition) = phiPixelIndexWeightedPosition;
966 AUXDATA(xprd,
float, NN_localEtaPixelIndexWeightedPosition) = localEtaPixelIndexWeightedPosition;
967 AUXDATA(xprd,
float, NN_localPhiPixelIndexWeightedPosition) = localPhiPixelIndexWeightedPosition;
974 const std::vector<SiHit> & matchingHits )
const
978 unsigned int numberOfSiHits = matchingHits.size();
980 std::vector<float> positionsX(numberOfSiHits,0);
981 std::vector<float> positionsY(numberOfSiHits,0);
983 std::vector<float> positions_indexX(numberOfSiHits,0);
984 std::vector<float> positions_indexY(numberOfSiHits,0);
986 std::vector<float>
theta(numberOfSiHits,0);
987 std::vector<float>
phi(numberOfSiHits,0);
990 std::vector<int> pdgid(numberOfSiHits,0);
991 std::vector<float> chargeDep(numberOfSiHits,0);
992 std::vector<float> truep(numberOfSiHits,0);
994 std::vector<float> pathlengthX(numberOfSiHits,0);
995 std::vector<float> pathlengthY(numberOfSiHits,0);
996 std::vector<float> pathlengthZ(numberOfSiHits,0);
999 std::vector<int> motherPdgid(numberOfSiHits,0);
1012 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNTruthInfo'");
1017 unsigned hitNumber(0);
1018 for(
const auto& siHit : matchingHits ){
1020 HepGeom::Point3D<double> averagePosition = (siHit.localStartPosition() + siHit.localEndPosition()) * 0.5;
1022 ATH_MSG_VERBOSE(
"Truth Part X: " << averagePosition.y() <<
" shift " << shift <<
" Y: " << averagePosition.z() );
1025 float YposC = averagePosition.y()-shift;
1027 if (std::abs(YposC)>design->
width()/2 &&
1028 std::abs(averagePosition.y())<design->
width()/2)
1030 if (YposC>design->
width()/2)
1032 YposC=design->
width()/2-1e-6;
1033 }
else if (YposC<-design->
width()/2)
1035 YposC=-design->
width()/2+1e-6;
1039 positionsX[hitNumber] = YposC;
1040 positionsY[hitNumber] = averagePosition.z();
1042 HepGeom::Point3D<double> deltaPosition = siHit.localEndPosition() - siHit.localStartPosition();
1044 pathlengthX[hitNumber] = deltaPosition.y();
1045 pathlengthY[hitNumber] = deltaPosition.z();
1046 pathlengthZ[hitNumber] = deltaPosition.x();
1057 int truthEtaIndex = cellIdOfTruthPosition.
etaIndex();
1058 int truthPhiIndex = cellIdOfTruthPosition.
phiIndex();
1061 double pitchY = diodeParameters.
width().
xEta();
1062 double pitchX = diodeParameters.
width().
xPhi();
1079 double pixelCenterY = siLocalPositionCenter.
xEta();
1080 double pixelCenterX = siLocalPositionCenter.
xPhi();
1086 double truthIndexY = truthEtaIndex + (siLocalTruthPosition[
Trk::distEta] - pixelCenterY)/pitchY;
1087 double truthIndexX = truthPhiIndex + (siLocalTruthPosition[
Trk::distPhi] - pixelCenterX)/pitchX;
1090 positions_indexX[hitNumber] = truthIndexX - cellIdWeightedPosition.
phiIndex();
1091 positions_indexY[hitNumber] = truthIndexY - cellIdWeightedPosition.
etaIndex();
1093 HepGeom::Point3D<double> diffPositions = (siHit.localEndPosition() - siHit.localStartPosition());
1094 double bowphi = std::atan2( diffPositions.y(), diffPositions.x() );
1098 theta[hitNumber] = std::atan2(diffPositions.z() ,diffPositions.x());
1103 phi[hitNumber] = std::atan(std::tan(bowphi)-readoutside*tanlorentz);
1107 const auto particle = HMPL.
cptr();
1108 pdgid[hitNumber] = particle->pdg_id();
1110 truep[hitNumber] = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
1111 const auto vertex = particle->production_vertex();
1113 if ( vertex && !vertex->particles_in().empty()){
1114 const auto& mother_of_particle=vertex->particles_in().front();
1116 motherPdgid[hitNumber] = mother_of_particle->pdg_id();
1119 chargeDep[hitNumber] = siHit.energyLoss() ;
1125 AUXDATA(xprd, std::vector<float>, NN_positionsX) = std::move(positionsX);
1126 AUXDATA(xprd, std::vector<float>, NN_positionsY) = std::move(positionsY);
1128 AUXDATA(xprd, std::vector<float>, NN_positions_indexX) = std::move(positions_indexX);
1129 AUXDATA(xprd, std::vector<float>, NN_positions_indexY) = std::move(positions_indexY);
1131 AUXDATA(xprd, std::vector<float>, NN_theta) = std::move(
theta);
1132 AUXDATA(xprd, std::vector<float>, NN_phi) = std::move(
phi);
1134 AUXDATA(xprd, std::vector<int>, NN_barcode) = std::move(uniqueID);
1135 AUXDATA(xprd, std::vector<int>, NN_pdgid) = std::move(pdgid);
1136 AUXDATA(xprd, std::vector<float>, NN_energyDep) = std::move(chargeDep);
1137 AUXDATA(xprd, std::vector<float>, NN_trueP) = std::move(truep);
1139 AUXDATA(xprd, std::vector<int>, NN_motherBarcode) = std::move(motherUniqueID);
1140 AUXDATA(xprd, std::vector<int>, NN_motherPdgid) = std::move(motherPdgid);
1144 AUXDATA(xprd, std::vector<float>, NN_pathlengthX) = std::move(pathlengthX);
1145 AUXDATA(xprd, std::vector<float>, NN_pathlengthY) = std::move(pathlengthY);
1146 AUXDATA(xprd, std::vector<float>, NN_pathlengthZ) = std::move(pathlengthZ);
1155 int *rphiPixelIndexMin,
1156 int *rphiPixelIndexMax,
1157 int *retaPixelIndexMin,
1158 int *retaPixelIndexMax )
const
1169 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'getCellIdWeightedPosition'");
1172 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
1175 const std::vector<float>& chList = pixelCluster->chargeList();
1178 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
1179 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
1181 auto charge = chList.begin();
1184 double sumOfCharge=0;
1186 int phiPixelIndexMin = 99999;
1187 int phiPixelIndexMax = -99999;
1188 int etaPixelIndexMin = 99999;
1189 int etaPixelIndexMax = -99999;
1191 for (; rdosBegin!= rdosEnd; ++rdosBegin, ++
charge)
1198 ATH_MSG_VERBOSE(
" Adding pixel phiPixelIndex: " << phiPixelIndex <<
" etaPixelIndex: " << etaPixelIndex <<
" charge: " << *
charge );
1216 sumOfWeightedPositions += (*charge)*siLocalPosition;
1217 sumOfCharge += (*charge);
1219 if (phiPixelIndex < phiPixelIndexMin)
1220 phiPixelIndexMin = phiPixelIndex;
1222 if (phiPixelIndex > phiPixelIndexMax)
1223 phiPixelIndexMax = phiPixelIndex;
1225 if (etaPixelIndex < etaPixelIndexMin)
1226 etaPixelIndexMin = etaPixelIndex;
1228 if (etaPixelIndex > etaPixelIndexMax)
1229 etaPixelIndexMax = etaPixelIndex;
1232 sumOfWeightedPositions /= sumOfCharge;
1234 ATH_MSG_VERBOSE (
"Wighted position: Row = " << sumOfWeightedPositions.
xRow() <<
", Col = " << sumOfWeightedPositions.
xColumn() );
1236 if(rphiPixelIndexMin) *rphiPixelIndexMin = phiPixelIndexMin;
1237 if(rphiPixelIndexMax) *rphiPixelIndexMax = phiPixelIndexMax;
1238 if(retaPixelIndexMin) *retaPixelIndexMin = etaPixelIndexMin;
1239 if(retaPixelIndexMax) *retaPixelIndexMax = etaPixelIndexMax;
1247 return cellIdWeightedPosition;
1264 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_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(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)
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.
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 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
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
Gaudi::Property< bool > m_writeExtendedPRDinformation
void addRdoInformation(xAOD::TrackMeasurementValidation *xprd, const InDet::PixelCluster *pixelCluster, const PixelChargeCalibCondData *calibData) const
std::atomic< unsigned int > m_missingTruthParticle
const PixelID * m_PixelHelper
Gaudi::Property< bool > m_writeNNinformation
Gaudi::Property< bool > m_writeRDOinformation
SG::ReadCondHandleKey< PixelDCSHVData > m_readKeyHV
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.
std::vector< SiHit > findAllHitsCompatibleWithCluster(const InDet::PixelCluster *prd, const std::vector< const SiHit * > *sihits, std::vector< std::vector< int > > &trkBCs) const
Gaudi::Property< bool > m_useSiHitsGeometryMatching
ToolHandle< IInDetConditionsTool > m_pixelSummary
Gaudi::Property< bool > m_useTruthInfo
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
Gaudi::Property< bool > m_writeSDOs
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
Gaudi::Property< bool > m_writeModuleStatus
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()
Gaudi::Property< bool > m_writeSiHits
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