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;
87 return StatusCode::SUCCESS;
100 if ( !PixelClusterContainer.isValid() )
102 ATH_MSG_ERROR(
"Failed to retrieve PixelClusterContainer with key" << PixelClusterContainer.key() );
103 return StatusCode::FAILURE;
110 if (prdmtCollHandle.
isValid()) {
111 prdmtColl = &*prdmtCollHandle;
115 if (truthParticleLinksHandle.
isValid()) {
116 truth_particle_links = truthParticleLinksHandle.
cptr();
124 if (sdoCollectionHandle.
isValid()) {
125 sdoCollection = &*sdoCollectionHandle;
127 ATH_MSG_WARNING(
"SDO information requested, but SDO collection not available!");
132 bool foundSplitProbContainer =
false;
135 if (!splitProbContainer.
isValid()) {
138 foundSplitProbContainer =
true;
141 std::vector<std::vector<const SiHit*>> siHits(
m_PixelHelper->wafer_hash_max());
144 if (siHitCollectionHandle.
isValid()) {
145 for (
const SiHit& siHit: *siHitCollectionHandle) {
147 if (!siHit.isPixel())
continue;
150 siHit.getLayerDisk(),
151 siHit.getPhiModule(),
152 siHit.getEtaModule()));
155 siHits[wafer_hash].push_back(&siHit);
158 ATH_MSG_WARNING(
"SiHit information requested, but SiHit collection not available!");
165 if (!calibData_handle.
isValid()) {
168 calibData=calibData_handle.
cptr();
173 ATH_CHECK(xaod.
record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
174 std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
179 unsigned int have_truth_link=0u;
180 unsigned int missing_truth_particle=0u;
181 unsigned int missing_parent_particle=0u;
183 unsigned int counter(0);
189 std::unordered_map< unsigned int , std::vector<unsigned int> > cluster_map;
190 for(
const auto clusterCollection : * PixelClusterContainer ){
193 (*offsets)[clusterCollection->identifyHash()] = counter;
196 if( clusterCollection->empty() )
continue;
209 unsigned int cluster_idx = xaod->size();
210 xaod->push_back(xprd);
226 if(localCov.size() == 1){
228 }
else if(localCov.size() == 4){
235 std::vector< uint64_t > rdoIdentifierList;
236 rdoIdentifierList.reserve(prd->rdoList().size());
237 int rowmin=9999;
int rowmax=-9999;
238 int colmin=9999;
int colmax=-9999;
239 for(
const auto &hitIdentifier : prd->rdoList() ){
240 rdoIdentifierList.push_back( hitIdentifier.get_compact() );
244 if(rowmin > row) rowmin = row;
245 if(rowmax < row) rowmax = row;
246 if(colmin > col) colmin = col;
247 if(colmax < col) colmax = col;
256 AUXDATA(xprd,
int,layer) = the_layer ;
257 AUXDATA(xprd,
int,phi_module) = the_phi ;
258 AUXDATA(xprd,
int,eta_module) = the_eta ;
262 cluster_map[ makeKey(the_phi, the_eta, the_layer)].push_back(cluster_idx);
267 AUXDATA(xprd,
int,nRDO) = (int)prd->rdoList().size();
270 AUXDATA(xprd,
int,ToT) = prd->totalToT();
271 AUXDATA(xprd,
int,LVL1A) = prd->LVL1A();
273 AUXDATA(xprd,
char,isFake) = (char)prd->isFake();
274 AUXDATA(xprd,
char,gangedPixel) = (char)prd->gangedPixel();
277 AUXDATA(xprd,
char,isSplit) =
static_cast<char>(splitProb.
isSplit());
288 AUXDATA(xprd,
int,DCSState) = dcsState->getModuleStatus(moduleHash);
290 float deplVoltage = 0.0;
291 AUXDATA(xprd,
float,BiasVoltage) = dcsHV->getBiasVoltage(moduleHash);
292 AUXDATA(xprd,
float,Temperature) = dcsTemp->getTemperature(moduleHash);
293 AUXDATA(xprd,
float,DepletionVoltage) = deplVoltage;
304 uint64_t detElementId(0);
311 AUXDATA(xprd,uint64_t,detectorElementID) = detElementId;
323 AUXDATA(xprd,
float,centroid_xphi) = centroid.
xPhi();
324 AUXDATA(xprd,
float,centroid_xeta) = centroid.
xEta();
326 AUXDATA(xprd,
float,omegax) = prd->omegax();
327 AUXDATA(xprd,
float,omegay) = prd->omegay();
332 auto range{prdmtColl->equal_range(clusterId)};
333 if (truth_particle_links) {
334 std::vector<unsigned int> tp_indices;
335 for (
auto i{range.first}; i!=range.second; ++i) {
337 if (a_truth_particle_link) {
339 if (truth_particle) {
341 tp_indices.push_back(
static_cast<int>(truth_particle->index()));
344 ++missing_parent_particle;
348 tp_indices.push_back(std::numeric_limits<unsigned int>::max());
349 ++missing_truth_particle;
353 AUXDATA(xprd,std::vector<unsigned int>, truth_index) = std::move(tp_indices);
355 std::vector<int> uniqueIDs;
356 for (
auto i = range.first; i != range.second; ++i) {
359 AUXDATA(xprd,std::vector<int>, truth_barcode) = std::move(uniqueIDs);
362 std::vector< std::vector< int > > sdo_tracks;
384 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr ) {
385 AUXDATA(*clusItr,
char,broken) =
false;
391 static const SG::AuxElement::Accessor<int> acc_layer (
"layer");
392 static const SG::AuxElement::Accessor<int> acc_phi_module (
"phi_module");
393 static const SG::AuxElement::Accessor<int> acc_eta_module (
"eta_module");
394 static const SG::AuxElement::Accessor<std::vector<int> > acc_sihit_barcode (
"sihit_barcode");
395 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr)
397 auto pixelCluster = *clusItr;
398 int layer = acc_layer(*pixelCluster);
399 std::vector<int> uniqueIDs = acc_sihit_barcode(*pixelCluster);
401 const std::vector< unsigned int> &cluster_idx_list = cluster_map.at( makeKey(acc_phi_module(*pixelCluster), acc_eta_module(*pixelCluster), acc_layer(*pixelCluster) ));
402 for (
unsigned int cluster_idx : cluster_idx_list) {
403 auto pixelCluster2 = xaod->at(cluster_idx);
404 if ( acc_layer(*pixelCluster2) != layer )
406 if ( acc_eta_module(*pixelCluster) != acc_eta_module(*pixelCluster2) )
408 if ( acc_phi_module(*pixelCluster) != acc_phi_module(*pixelCluster2) )
411 std::vector<int> uniqueIDs2 = acc_sihit_barcode(*pixelCluster2);
413 for (
auto uid : uniqueIDs ) {
414 if (std::find(uniqueIDs2.begin(), uniqueIDs2.end(), uid ) == uniqueIDs2.end())
continue;
415 static const SG::AuxElement::Accessor<char> acc_broken (
"broken");
416 acc_broken(*pixelCluster) =
true;
417 acc_broken(*pixelCluster2) =
true;
423 ATH_MSG_DEBUG(
" recorded PixelPrepData objects: size " << xaod->size() );
427 return StatusCode::SUCCESS;
435 std::vector<int> sdo_word;
436 std::vector< std::vector< int > > sdo_depositsUniqueID;
437 std::vector< std::vector< float > > sdo_depositsEnergy;
439 for(
const auto &hitIdentifier : prd->
rdoList() ){
440 auto pos = sdoCollection.find(hitIdentifier);
441 if( pos == sdoCollection.end() )
continue;
442 sdo_word.push_back( pos->second.word() ) ;
444 std::vector<float> sdoDepEnergy(pos->second.getdeposits().size());
445 unsigned int nDepos{0};
446 for (
auto& deposit: pos->second.getdeposits()) {
449 sdoDepEnergy[nDepos] = deposit.second;
452 sdo_depositsUniqueID.push_back( std::move(sdoDepUID) );
453 sdo_depositsEnergy.push_back( std::move(sdoDepEnergy) );
455 AUXDATA(xprd,std::vector<int>,sdo_words) = std::move(sdo_word);
456 AUXDATA(xprd,std::vector< std::vector<int> >,sdo_depositsBarcode) = sdo_depositsUniqueID;
457 AUXDATA(xprd,std::vector< std::vector<float> >,sdo_depositsEnergy) = std::move(sdo_depositsEnergy);
459 return sdo_depositsUniqueID;
466 const std::vector<SiHit> & matchingHits )
const
469 int numHits = matchingHits.size();
471 std::vector<float> sihit_energyDeposit(numHits,0);
472 std::vector<float> sihit_meanTime(numHits,0);
474 std::vector<int> sihit_pdgid(numHits,0);
476 std::vector<float> sihit_startPosX(numHits,0);
477 std::vector<float> sihit_startPosY(numHits,0);
478 std::vector<float> sihit_startPosZ(numHits,0);
480 std::vector<float> sihit_endPosX(numHits,0);
481 std::vector<float> sihit_endPosY(numHits,0);
482 std::vector<float> sihit_endPosZ(numHits,0);
487 for (
const auto& sihit : matchingHits ) {
488 sihit_energyDeposit[hitNumber] = sihit.energyLoss() ;
489 sihit_meanTime[hitNumber] = sihit.meanTime() ;
493 sihit_pdgid[hitNumber] = HMPL->pdg_id();
497 const HepGeom::Point3D<double>& startPos=sihit.localStartPosition();
500 sihit_startPosX[hitNumber] = pos[0];
501 sihit_startPosY[hitNumber] = pos[1];
502 sihit_startPosZ[hitNumber] = startPos.x();
505 const HepGeom::Point3D<double>& endPos=sihit.localEndPosition();
507 sihit_endPosX[hitNumber] = pos[0];
508 sihit_endPosY[hitNumber] = pos[1];
509 sihit_endPosZ[hitNumber] = endPos.x();
514 AUXDATA(xprd,std::vector<float>,sihit_energyDeposit) = std::move(sihit_energyDeposit);
515 AUXDATA(xprd,std::vector<float>,sihit_meanTime) = std::move(sihit_meanTime);
516 AUXDATA(xprd,std::vector<int>,sihit_barcode) = std::move(sihit_uniqueID);
517 AUXDATA(xprd,std::vector<int>,sihit_pdgid) = std::move(sihit_pdgid);
519 AUXDATA(xprd,std::vector<float>,sihit_startPosX) = std::move(sihit_startPosX);
520 AUXDATA(xprd,std::vector<float>,sihit_startPosY) = std::move(sihit_startPosY);
521 AUXDATA(xprd,std::vector<float>,sihit_startPosZ) = std::move(sihit_startPosZ);
523 AUXDATA(xprd,std::vector<float>,sihit_endPosX) = std::move(sihit_endPosX);
524 AUXDATA(xprd,std::vector<float>,sihit_endPosY) = std::move(sihit_endPosY);
525 AUXDATA(xprd,std::vector<float>,sihit_endPosZ) = std::move(sihit_endPosZ);
536 const std::vector<const SiHit*>* sihits,
537 std::vector< std::vector< int > > & trkUIDs )
const
539 ATH_MSG_VERBOSE(
"Got " << sihits->size() <<
" SiHits to look through" );
540 std::vector<SiHit> matchingHits;
547 std::vector<const SiHit* > multiMatchingHits;
549 for (
const SiHit* siHit : *sihits) {
555 HepGeom::Point3D<double> averagePosition = siHit->localStartPosition() + siHit->localEndPosition();
556 averagePosition *= 0.5;
560 for(
const auto &hitIdentifier : prd->
rdoList() ){
566 multiMatchingHits.push_back(siHit);
574 for (
const auto& uniqueIDSDOColl : trkUIDs ) {
575 if (std::find(uniqueIDSDOColl.begin(),uniqueIDSDOColl.end(),uid) == uniqueIDSDOColl.end() )
continue;
576 multiMatchingHits.push_back(siHit);
582 std::vector<const SiHit* >::iterator siHitIter = multiMatchingHits.begin();
583 std::vector<const SiHit* >::iterator siHitIter2 = multiMatchingHits.begin();
584 ATH_MSG_DEBUG(
"Found " << multiMatchingHits.size() <<
" SiHit " );
585 for ( ; siHitIter != multiMatchingHits.end(); ++siHitIter) {
586 const SiHit* lowestXPos = *siHitIter;
587 const SiHit* highestXPos = *siHitIter;
591 std::vector<const SiHit* > ajoiningHits;
592 ajoiningHits.push_back( *siHitIter );
594 siHitIter2 = siHitIter+1;
595 while ( siHitIter2 != multiMatchingHits.end() ) {
604 if (std::abs((highestXPos->
localEndPosition().x()-(*siHitIter2)->localStartPosition().x()))<0.00005 &&
605 std::abs((highestXPos->
localEndPosition().y()-(*siHitIter2)->localStartPosition().y()))<0.00005 &&
606 std::abs((highestXPos->
localEndPosition().z()-(*siHitIter2)->localStartPosition().z()))<0.00005 )
608 highestXPos = *siHitIter2;
609 ajoiningHits.push_back( *siHitIter2 );
612 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
613 }
else if (std::abs((lowestXPos->
localStartPosition().x()-(*siHitIter2)->localEndPosition().x()))<0.00005 &&
614 std::abs((lowestXPos->
localStartPosition().y()-(*siHitIter2)->localEndPosition().y()))<0.00005 &&
615 std::abs((lowestXPos->
localStartPosition().z()-(*siHitIter2)->localEndPosition().z()))<0.00005)
617 lowestXPos = *siHitIter2;
618 ajoiningHits.push_back( *siHitIter2 );
621 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
627 if( ajoiningHits.size() == 0){
630 }
else if(ajoiningHits.size() == 1){
632 matchingHits.push_back( *ajoiningHits[0] );
636 ATH_MSG_DEBUG(
"Merging " << ajoiningHits.size() <<
" SiHits together." );
641 for(
const auto& siHit : ajoiningHits){
642 energyDep += siHit->energyLoss();
643 time += siHit->meanTime();
645 time /= (float)ajoiningHits.size();
651 (*siHitIter)->particleLink(),
653 (*siHitIter)->getBarrelEndcap(),
654 (*siHitIter)->getLayerDisk(),
655 (*siHitIter)->getEtaModule(),
656 (*siHitIter)->getPhiModule(),
657 (*siHitIter)->getSide() );
658 ATH_MSG_DEBUG(
"Finished Merging " << ajoiningHits.size() <<
" SiHits together." );
675 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
677 const std::vector<float> &chList = pixelCluster->chargeList();
678 const std::vector<int> &totList = pixelCluster->totList();
682 std::vector<int> etaIndexList;
683 std::vector<int> phiIndexList;
684 std::vector<float> CTerm;
685 std::vector<float> ATerm;
686 std::vector<float> ETerm;
691 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
692 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
694 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
696 phiIndexList.reserve( rdos.size());
697 etaIndexList.reserve( rdos.size());
698 CTerm.reserve( rdos.size());
699 ATerm.reserve( rdos.size());
700 ETerm.reserve( rdos.size());
701 for (; rdosBegin!= rdosEnd; ++rdosBegin)
714 CTerm.emplace_back(parameters.C);
715 ATerm.emplace_back(parameters.A);
716 ETerm.emplace_back(parameters.E);
721 AUXDATA(xprd, std::vector<int>,rdo_phi_pixel_index) = std::move(phiIndexList);
722 AUXDATA(xprd, std::vector<int>,rdo_eta_pixel_index) = std::move(etaIndexList);
723 AUXDATA(xprd, std::vector<float>,rdo_charge) = chList;
724 AUXDATA(xprd, std::vector<int>,rdo_tot) = totList;
726 AUXDATA(xprd, std::vector<float>,rdo_Cterm) = std::move(CTerm);
727 AUXDATA(xprd, std::vector<float>,rdo_Aterm) = std::move(ATerm);
728 AUXDATA(xprd, std::vector<float>,rdo_Eterm) = std::move(ETerm);
735 const unsigned int sizeX,
const unsigned int sizeY )
const
748 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNInformation'");
751 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
753 const std::vector<float>& chList = pixelCluster->chargeList();
754 const std::vector<int>& totList = pixelCluster->totList();
762 int phiPixelIndexMin, phiPixelIndexMax, etaPixelIndexMin, etaPixelIndexMax;
765 if (!cellIdWeightedPosition.
isValid())
770 int etaPixelIndexWeightedPosition=cellIdWeightedPosition.
etaIndex();
771 int phiPixelIndexWeightedPosition=cellIdWeightedPosition.
phiIndex();
774 ATH_MSG_DEBUG(
" weighted pos phiPixelIndex: " << phiPixelIndexWeightedPosition <<
" etaPixelIndex: " << etaPixelIndexWeightedPosition );
792 double localEtaPixelIndexWeightedPosition = w.xEta();
793 double localPhiPixelIndexWeightedPosition = w.xPhi();
795 int centralIndexX=(sizeX-1)/2;
796 int centralIndexY=(sizeY-1)/2;
802 if (abs(phiPixelIndexWeightedPosition-phiPixelIndexMin)>centralIndexX ||
803 abs(phiPixelIndexWeightedPosition-phiPixelIndexMax)>centralIndexX)
805 ATH_MSG_DEBUG(
" Cluster too large phiPixelIndexMin " << phiPixelIndexMin <<
" phiPixelIndexMax " << phiPixelIndexMax <<
" centralX " << centralIndexX);
809 if (abs(etaPixelIndexWeightedPosition-etaPixelIndexMin)>centralIndexY ||
810 abs(etaPixelIndexWeightedPosition-etaPixelIndexMax)>centralIndexY)
812 ATH_MSG_DEBUG(
" Cluster too large etaPixelIndexMin" << etaPixelIndexMin <<
" etaPixelIndexMax " << etaPixelIndexMax <<
" centralY " << centralIndexY);
816 std::vector< std::vector<float> > matrixOfToT (sizeX, std::vector<float>(sizeY,0) );
817 std::vector< std::vector<float> > matrixOfCharge(sizeX, std::vector<float>(sizeY,0));
821 std::vector<float> vectorOfPitchesY(sizeY, design->
etaPitch());
822 std::vector<float> vectorOfPitchesX(sizeX, design->
phiPitch());
826 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
827 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
828 auto charge = chList.begin();
829 auto tot = totList.begin();
831 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
833 for (; rdosBegin!= rdosEnd; ++rdosBegin)
837 int absphiPixelIndex =
m_PixelHelper->phi_index(rId)-phiPixelIndexWeightedPosition + centralIndexX;
838 int absetaPixelIndex =
m_PixelHelper->eta_index(rId)-etaPixelIndexWeightedPosition + centralIndexY;
839 if (
charge != chList.end()){
840 ATH_MSG_VERBOSE(
" Phi Index: " <<
m_PixelHelper->phi_index(rId) <<
" absphiPixelIndex: " << absphiPixelIndex <<
" eta Idx: " <<
m_PixelHelper->eta_index(rId) <<
" absetaPixelIndex: " << absetaPixelIndex <<
" charge " << *
charge );
842 if (absphiPixelIndex <0 || absphiPixelIndex >= (
int)sizeX)
844 ATH_MSG_DEBUG(
" problem with index: " << absphiPixelIndex <<
" min: " << 0 <<
" max: " << sizeX);
848 if (absetaPixelIndex <0 || absetaPixelIndex >= (
int)sizeY)
850 ATH_MSG_DEBUG(
" problem with index: " << absetaPixelIndex <<
" min: " << 0 <<
" max: " << sizeY);
856 float pitchY = diodeParameters.
width().
xEta();
857 float pitchX = diodeParameters.
width().
xPhi();
859 if ( (not totList.empty()) && tot != totList.end()) {
860 matrixOfToT[absphiPixelIndex][absetaPixelIndex] =*tot;
862 }
else matrixOfToT[absphiPixelIndex][absetaPixelIndex] = -1;
864 if ( (not chList.empty()) &&
charge != chList.end()){
865 matrixOfCharge[absphiPixelIndex][absetaPixelIndex]=*
charge;
867 }
else matrixOfCharge[absphiPixelIndex][absetaPixelIndex] = -1;
872 vectorOfPitchesY[absetaPixelIndex]=pitchY;
873 vectorOfPitchesX[absphiPixelIndex]=pitchX;
881 const Amg::Vector2D& prdLocPos = pixelCluster->localPosition();
886 trackDir.normalize();
893 float trkphicomp = trackDir.dot(module_phiax);
894 float trketacomp = trackDir.dot(module_etaax);
895 float trknormcomp = trackDir.dot(module_normal);
896 double bowphi = atan2(trkphicomp,trknormcomp);
897 double boweta = atan2(trketacomp,trknormcomp);
899 if(bowphi >
pi/2) bowphi -=
pi;
900 if(bowphi < -
pi/2) bowphi +=
pi;
902 double angle = atan(tan(bowphi)-readoutside*tanl);
907 if (boweta>
pi/2.) boweta-=
pi;
908 if (boweta<-
pi/2.) boweta+=
pi;
912 ATH_MSG_VERBOSE(
" PhiPixelIndexWeightedPosition: " << phiPixelIndexWeightedPosition <<
" EtaPixelIndexWeightedPosition: " << etaPixelIndexWeightedPosition );
915 std::vector<float> vectorOfCharge(sizeX*sizeY,0);
916 std::vector<float> vectorOfToT(sizeX*sizeY,0);
918 for (
unsigned int u=0;u<sizeX;u++)
920 for (
unsigned int s=0;s<sizeY;s++)
922 vectorOfToT[counter] = matrixOfToT[u][s];
923 vectorOfCharge[counter] = matrixOfCharge[u][s];
932 AUXDATA(xprd,
int, NN_sizeX) = sizeX;
933 AUXDATA(xprd,
int, NN_sizeY) = sizeY;
936 AUXDATA(xprd,
float, NN_thetaBS) = boweta;
938 AUXDATA(xprd, std::vector<float>, NN_matrixOfToT) = std::move(vectorOfToT);
939 AUXDATA(xprd, std::vector<float>, NN_matrixOfCharge) = std::move(vectorOfCharge);
940 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesY) = std::move(vectorOfPitchesY);
941 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesX) = std::move(vectorOfPitchesX);
944 AUXDATA(xprd,
int, NN_etaPixelIndexWeightedPosition) = etaPixelIndexWeightedPosition;
945 AUXDATA(xprd,
int, NN_phiPixelIndexWeightedPosition) = phiPixelIndexWeightedPosition;
947 AUXDATA(xprd,
float, NN_localEtaPixelIndexWeightedPosition) = localEtaPixelIndexWeightedPosition;
948 AUXDATA(xprd,
float, NN_localPhiPixelIndexWeightedPosition) = localPhiPixelIndexWeightedPosition;
955 const std::vector<SiHit> & matchingHits )
const
959 unsigned int numberOfSiHits = matchingHits.size();
961 std::vector<float> positionsX(numberOfSiHits,0);
962 std::vector<float> positionsY(numberOfSiHits,0);
964 std::vector<float> positions_indexX(numberOfSiHits,0);
965 std::vector<float> positions_indexY(numberOfSiHits,0);
967 std::vector<float>
theta(numberOfSiHits,0);
968 std::vector<float>
phi(numberOfSiHits,0);
971 std::vector<int> pdgid(numberOfSiHits,0);
972 std::vector<float> chargeDep(numberOfSiHits,0);
973 std::vector<float> truep(numberOfSiHits,0);
975 std::vector<float> pathlengthX(numberOfSiHits,0);
976 std::vector<float> pathlengthY(numberOfSiHits,0);
977 std::vector<float> pathlengthZ(numberOfSiHits,0);
980 std::vector<int> motherPdgid(numberOfSiHits,0);
993 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNTruthInfo'");
998 unsigned hitNumber(0);
999 for(
const auto& siHit : matchingHits ){
1001 HepGeom::Point3D<double> averagePosition = (siHit.localStartPosition() + siHit.localEndPosition()) * 0.5;
1003 ATH_MSG_VERBOSE(
"Truth Part X: " << averagePosition.y() <<
" shift " << shift <<
" Y: " << averagePosition.z() );
1006 float YposC = averagePosition.y()-shift;
1008 if (std::abs(YposC)>design->
width()/2 &&
1009 std::abs(averagePosition.y())<design->
width()/2)
1011 if (YposC>design->
width()/2)
1013 YposC=design->
width()/2-1e-6;
1014 }
else if (YposC<-design->
width()/2)
1016 YposC=-design->
width()/2+1e-6;
1020 positionsX[hitNumber] = YposC;
1021 positionsY[hitNumber] = averagePosition.z();
1023 HepGeom::Point3D<double> deltaPosition = siHit.localEndPosition() - siHit.localStartPosition();
1025 pathlengthX[hitNumber] = deltaPosition.y();
1026 pathlengthY[hitNumber] = deltaPosition.z();
1027 pathlengthZ[hitNumber] = deltaPosition.x();
1038 int truthEtaIndex = cellIdOfTruthPosition.
etaIndex();
1039 int truthPhiIndex = cellIdOfTruthPosition.
phiIndex();
1042 double pitchY = diodeParameters.
width().
xEta();
1043 double pitchX = diodeParameters.
width().
xPhi();
1060 double pixelCenterY = siLocalPositionCenter.
xEta();
1061 double pixelCenterX = siLocalPositionCenter.
xPhi();
1067 double truthIndexY = truthEtaIndex + (siLocalTruthPosition[
Trk::distEta] - pixelCenterY)/pitchY;
1068 double truthIndexX = truthPhiIndex + (siLocalTruthPosition[
Trk::distPhi] - pixelCenterX)/pitchX;
1071 positions_indexX[hitNumber] = truthIndexX - cellIdWeightedPosition.
phiIndex();
1072 positions_indexY[hitNumber] = truthIndexY - cellIdWeightedPosition.
etaIndex();
1074 HepGeom::Point3D<double> diffPositions = (siHit.localEndPosition() - siHit.localStartPosition());
1075 double bowphi = std::atan2( diffPositions.y(), diffPositions.x() );
1079 theta[hitNumber] = std::atan2(diffPositions.z() ,diffPositions.x());
1084 phi[hitNumber] = std::atan(std::tan(bowphi)-readoutside*tanlorentz);
1088 const auto particle = HMPL.
cptr();
1089 pdgid[hitNumber] = particle->pdg_id();
1091 truep[hitNumber] = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
1092 const auto vertex = particle->production_vertex();
1094 if ( vertex && !vertex->particles_in().empty()){
1095 const auto& mother_of_particle=vertex->particles_in().front();
1097 motherPdgid[hitNumber] = mother_of_particle->pdg_id();
1100 chargeDep[hitNumber] = siHit.energyLoss() ;
1106 AUXDATA(xprd, std::vector<float>, NN_positionsX) = std::move(positionsX);
1107 AUXDATA(xprd, std::vector<float>, NN_positionsY) = std::move(positionsY);
1109 AUXDATA(xprd, std::vector<float>, NN_positions_indexX) = std::move(positions_indexX);
1110 AUXDATA(xprd, std::vector<float>, NN_positions_indexY) = std::move(positions_indexY);
1112 AUXDATA(xprd, std::vector<float>, NN_theta) = std::move(
theta);
1113 AUXDATA(xprd, std::vector<float>, NN_phi) = std::move(
phi);
1115 AUXDATA(xprd, std::vector<int>, NN_barcode) = std::move(uniqueID);
1116 AUXDATA(xprd, std::vector<int>, NN_pdgid) = std::move(pdgid);
1117 AUXDATA(xprd, std::vector<float>, NN_energyDep) = std::move(chargeDep);
1118 AUXDATA(xprd, std::vector<float>, NN_trueP) = std::move(truep);
1120 AUXDATA(xprd, std::vector<int>, NN_motherBarcode) = std::move(motherUniqueID);
1121 AUXDATA(xprd, std::vector<int>, NN_motherPdgid) = std::move(motherPdgid);
1125 AUXDATA(xprd, std::vector<float>, NN_pathlengthX) = std::move(pathlengthX);
1126 AUXDATA(xprd, std::vector<float>, NN_pathlengthY) = std::move(pathlengthY);
1127 AUXDATA(xprd, std::vector<float>, NN_pathlengthZ) = std::move(pathlengthZ);
1136 int *rphiPixelIndexMin,
1137 int *rphiPixelIndexMax,
1138 int *retaPixelIndexMin,
1139 int *retaPixelIndexMax )
const
1150 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'getCellIdWeightedPosition'");
1153 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
1156 const std::vector<float>& chList = pixelCluster->chargeList();
1159 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
1160 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
1162 auto charge = chList.begin();
1165 double sumOfCharge=0;
1167 int phiPixelIndexMin = 99999;
1168 int phiPixelIndexMax = -99999;
1169 int etaPixelIndexMin = 99999;
1170 int etaPixelIndexMax = -99999;
1172 for (; rdosBegin!= rdosEnd; ++rdosBegin, ++
charge)
1179 ATH_MSG_VERBOSE(
" Adding pixel phiPixelIndex: " << phiPixelIndex <<
" etaPixelIndex: " << etaPixelIndex <<
" charge: " << *
charge );
1197 sumOfWeightedPositions += (*charge)*siLocalPosition;
1198 sumOfCharge += (*charge);
1200 if (phiPixelIndex < phiPixelIndexMin)
1201 phiPixelIndexMin = phiPixelIndex;
1203 if (phiPixelIndex > phiPixelIndexMax)
1204 phiPixelIndexMax = phiPixelIndex;
1206 if (etaPixelIndex < etaPixelIndexMin)
1207 etaPixelIndexMin = etaPixelIndex;
1209 if (etaPixelIndex > etaPixelIndexMax)
1210 etaPixelIndexMax = etaPixelIndex;
1213 sumOfWeightedPositions /= sumOfCharge;
1215 ATH_MSG_VERBOSE (
"Wighted position: Row = " << sumOfWeightedPositions.
xRow() <<
", Col = " << sumOfWeightedPositions.
xColumn() );
1217 if(rphiPixelIndexMin) *rphiPixelIndexMin = phiPixelIndexMin;
1218 if(rphiPixelIndexMax) *rphiPixelIndexMax = phiPixelIndexMax;
1219 if(retaPixelIndexMin) *retaPixelIndexMin = etaPixelIndexMin;
1220 if(retaPixelIndexMax) *retaPixelIndexMax = etaPixelIndexMax;
1228 return cellIdWeightedPosition;
1245 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)
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
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
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