18#include "Identifier/Identifier.h"
33#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);
122 return StatusCode::SUCCESS;
135 if ( !PixelClusterContainer.isValid() )
137 ATH_MSG_ERROR(
"Failed to retrieve PixelClusterContainer with key" << PixelClusterContainer.key() );
138 return StatusCode::FAILURE;
145 if (prdmtCollHandle.
isValid()) {
146 prdmtColl = &*prdmtCollHandle;
150 if (truthParticleLinksHandle.
isValid()) {
151 truth_particle_links = truthParticleLinksHandle.
cptr();
159 if (sdoCollectionHandle.
isValid()) {
160 sdoCollection = &*sdoCollectionHandle;
162 ATH_MSG_WARNING(
"SDO information requested, but SDO collection not available!");
167 bool foundSplitProbContainer =
false;
170 if (!splitProbContainer.
isValid()) {
173 foundSplitProbContainer =
true;
176 std::vector<std::vector<const SiHit*>> siHits(
m_PixelHelper->wafer_hash_max());
179 if (siHitCollectionHandle.
isValid()) {
180 for (
const SiHit& siHit: *siHitCollectionHandle) {
182 if (!siHit.isPixel())
continue;
185 siHit.getLayerDisk(),
186 siHit.getPhiModule(),
187 siHit.getEtaModule()));
190 siHits[wafer_hash].push_back(&siHit);
193 ATH_MSG_WARNING(
"SiHit information requested, but SiHit collection not available!");
200 if (!calibData_handle.
isValid()) {
203 calibData=calibData_handle.
cptr();
208 ATH_CHECK(xaod.
record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
209 std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
214 unsigned int have_truth_link=0u;
215 unsigned int missing_truth_particle=0u;
216 unsigned int missing_parent_particle=0u;
218 unsigned int counter(0);
224 std::unordered_map< unsigned int , std::vector<unsigned int> > cluster_map;
225 for(
const auto clusterCollection : * PixelClusterContainer ){
228 (*offsets)[clusterCollection->identifyHash()] = counter;
231 if( clusterCollection->empty() )
continue;
244 unsigned int cluster_idx = xaod->size();
245 xaod->push_back(xprd);
261 if(localCov.size() == 1){
263 }
else if(localCov.size() == 4){
270 std::vector< uint64_t > rdoIdentifierList;
271 rdoIdentifierList.reserve(prd->rdoList().size());
272 int rowmin=9999;
int rowmax=-9999;
273 int colmin=9999;
int colmax=-9999;
274 for(
const auto &hitIdentifier : prd->rdoList() ){
275 rdoIdentifierList.push_back( hitIdentifier.get_compact() );
279 if(rowmin > row) rowmin = row;
280 if(rowmax < row) rowmax = row;
281 if(colmin > col) colmin = col;
282 if(colmax < col) colmax = col;
291 AUXDATA(xprd,
int,layer) = the_layer ;
292 AUXDATA(xprd,
int,phi_module) = the_phi ;
293 AUXDATA(xprd,
int,eta_module) = the_eta ;
297 cluster_map[ makeKey(the_phi, the_eta, the_layer)].push_back(cluster_idx);
302 AUXDATA(xprd,
int,nRDO) = (int)prd->rdoList().size();
305 AUXDATA(xprd,
int,ToT) = prd->totalToT();
306 AUXDATA(xprd,
int,LVL1A) = prd->LVL1A();
308 AUXDATA(xprd,
char,isFake) = (char)prd->isFake();
309 AUXDATA(xprd,
char,gangedPixel) = (char)prd->gangedPixel();
312 AUXDATA(xprd,
char,isSplit) =
static_cast<char>(splitProb.
isSplit());
323 AUXDATA(xprd,
int,DCSState) = dcsState->getModuleStatus(moduleHash);
325 float deplVoltage = 0.0;
326 AUXDATA(xprd,
float,BiasVoltage) = dcsHV->getBiasVoltage(moduleHash);
327 AUXDATA(xprd,
float,Temperature) = dcsTemp->getTemperature(moduleHash);
328 AUXDATA(xprd,
float,DepletionVoltage) = deplVoltage;
339 uint64_t detElementId(0);
346 AUXDATA(xprd,uint64_t,detectorElementID) = detElementId;
358 AUXDATA(xprd,
float,centroid_xphi) = centroid.
xPhi();
359 AUXDATA(xprd,
float,centroid_xeta) = centroid.
xEta();
361 AUXDATA(xprd,
float,omegax) = prd->omegax();
362 AUXDATA(xprd,
float,omegay) = prd->omegay();
367 auto range{prdmtColl->equal_range(clusterId)};
368 if (truth_particle_links) {
369 std::vector<unsigned int> tp_indices;
370 for (
auto i{range.first}; i!=range.second; ++i) {
372 if (a_truth_particle_link) {
374 if (truth_particle) {
376 tp_indices.push_back(
static_cast<int>(truth_particle->index()));
379 ++missing_parent_particle;
383 tp_indices.push_back(std::numeric_limits<unsigned int>::max());
384 ++missing_truth_particle;
388 AUXDATA(xprd,std::vector<unsigned int>, truth_index) = tp_indices;
390 std::vector<int> uniqueIDs;
391 for (
auto i = range.first; i != range.second; ++i) {
395 AUXDATA(xprd,std::vector<int>, truth_barcode) = uniqueIDs;
398 std::vector< std::vector< int > > sdo_tracks;
420 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr ) {
421 AUXDATA(*clusItr,
char,broken) =
false;
427 static const SG::AuxElement::Accessor<int> acc_layer (
"layer");
428 static const SG::AuxElement::Accessor<int> acc_phi_module (
"phi_module");
429 static const SG::AuxElement::Accessor<int> acc_eta_module (
"eta_module");
430 static const SG::AuxElement::Accessor<std::vector<int> > acc_sihit_barcode (
"sihit_barcode");
431 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr)
433 auto pixelCluster = *clusItr;
434 int layer = acc_layer(*pixelCluster);
435 std::vector<int> uniqueIDs = acc_sihit_barcode(*pixelCluster);
437 const std::vector< unsigned int> &cluster_idx_list = cluster_map.at( makeKey(acc_phi_module(*pixelCluster), acc_eta_module(*pixelCluster), acc_layer(*pixelCluster) ));
438 for (
unsigned int cluster_idx : cluster_idx_list) {
439 auto pixelCluster2 = xaod->at(cluster_idx);
440 if ( acc_layer(*pixelCluster2) != layer )
442 if ( acc_eta_module(*pixelCluster) != acc_eta_module(*pixelCluster2) )
444 if ( acc_phi_module(*pixelCluster) != acc_phi_module(*pixelCluster2) )
447 std::vector<int> uniqueIDs2 = acc_sihit_barcode(*pixelCluster2);
449 for (
auto uid : uniqueIDs ) {
450 if (std::find(uniqueIDs2.begin(), uniqueIDs2.end(), uid ) == uniqueIDs2.end())
continue;
451 static const SG::AuxElement::Accessor<char> acc_broken (
"broken");
452 acc_broken(*pixelCluster) =
true;
453 acc_broken(*pixelCluster2) =
true;
459 ATH_MSG_DEBUG(
" recorded PixelPrepData objects: size " << xaod->size() );
463 return StatusCode::SUCCESS;
471 std::vector<int> sdo_word;
472 std::vector< std::vector< int > > sdo_depositsUniqueID;
473 std::vector< std::vector< float > > sdo_depositsEnergy;
475 for(
const auto &hitIdentifier : prd->
rdoList() ){
476 auto pos = sdoCollection.find(hitIdentifier);
477 if( pos == sdoCollection.end() )
continue;
478 sdo_word.push_back( pos->second.word() ) ;
480 std::vector<float> sdoDepEnergy(pos->second.getdeposits().size());
481 unsigned int nDepos{0};
482 for (
auto& deposit: pos->second.getdeposits()) {
485 sdoDepEnergy[nDepos] = deposit.second;
488 sdo_depositsUniqueID.push_back( sdoDepUID );
489 sdo_depositsEnergy.push_back( sdoDepEnergy );
491 AUXDATA(xprd,std::vector<int>,sdo_words) = sdo_word;
492 AUXDATA(xprd,std::vector< std::vector<int> >,sdo_depositsBarcode) = sdo_depositsUniqueID;
493 AUXDATA(xprd,std::vector< std::vector<float> >,sdo_depositsEnergy) = sdo_depositsEnergy;
495 return sdo_depositsUniqueID;
502 const std::vector<SiHit> & matchingHits )
const
505 int numHits = matchingHits.size();
507 std::vector<float> sihit_energyDeposit(numHits,0);
508 std::vector<float> sihit_meanTime(numHits,0);
510 std::vector<int> sihit_pdgid(numHits,0);
512 std::vector<float> sihit_startPosX(numHits,0);
513 std::vector<float> sihit_startPosY(numHits,0);
514 std::vector<float> sihit_startPosZ(numHits,0);
516 std::vector<float> sihit_endPosX(numHits,0);
517 std::vector<float> sihit_endPosY(numHits,0);
518 std::vector<float> sihit_endPosZ(numHits,0);
523 for (
const auto& sihit : matchingHits ) {
524 sihit_energyDeposit[hitNumber] = sihit.energyLoss() ;
525 sihit_meanTime[hitNumber] = sihit.meanTime() ;
529 sihit_pdgid[hitNumber] = HMPL->pdg_id();
533 const HepGeom::Point3D<double>& startPos=sihit.localStartPosition();
536 sihit_startPosX[hitNumber] = pos[0];
537 sihit_startPosY[hitNumber] = pos[1];
538 sihit_startPosZ[hitNumber] = startPos.x();
541 const HepGeom::Point3D<double>& endPos=sihit.localEndPosition();
543 sihit_endPosX[hitNumber] = pos[0];
544 sihit_endPosY[hitNumber] = pos[1];
545 sihit_endPosZ[hitNumber] = endPos.x();
550 AUXDATA(xprd,std::vector<float>,sihit_energyDeposit) = sihit_energyDeposit;
551 AUXDATA(xprd,std::vector<float>,sihit_meanTime) = sihit_meanTime;
552 AUXDATA(xprd,std::vector<int>,sihit_barcode) = sihit_uniqueID;
553 AUXDATA(xprd,std::vector<int>,sihit_pdgid) = sihit_pdgid;
555 AUXDATA(xprd,std::vector<float>,sihit_startPosX) = sihit_startPosX;
556 AUXDATA(xprd,std::vector<float>,sihit_startPosY) = sihit_startPosY;
557 AUXDATA(xprd,std::vector<float>,sihit_startPosZ) = sihit_startPosZ;
559 AUXDATA(xprd,std::vector<float>,sihit_endPosX) = sihit_endPosX;
560 AUXDATA(xprd,std::vector<float>,sihit_endPosY) = sihit_endPosY;
561 AUXDATA(xprd,std::vector<float>,sihit_endPosZ) = sihit_endPosZ;
572 const std::vector<const SiHit*>* sihits,
573 std::vector< std::vector< int > > & trkUIDs )
const
575 ATH_MSG_VERBOSE(
"Got " << sihits->size() <<
" SiHits to look through" );
576 std::vector<SiHit> matchingHits;
583 std::vector<const SiHit* > multiMatchingHits;
585 for (
const SiHit* siHit : *sihits) {
591 HepGeom::Point3D<double> averagePosition = siHit->localStartPosition() + siHit->localEndPosition();
592 averagePosition *= 0.5;
596 for(
const auto &hitIdentifier : prd->
rdoList() ){
602 multiMatchingHits.push_back(siHit);
610 for (
const auto& uniqueIDSDOColl : trkUIDs ) {
611 if (std::find(uniqueIDSDOColl.begin(),uniqueIDSDOColl.end(),uid) == uniqueIDSDOColl.end() )
continue;
612 multiMatchingHits.push_back(siHit);
618 std::vector<const SiHit* >::iterator siHitIter = multiMatchingHits.begin();
619 std::vector<const SiHit* >::iterator siHitIter2 = multiMatchingHits.begin();
620 ATH_MSG_DEBUG(
"Found " << multiMatchingHits.size() <<
" SiHit " );
621 for ( ; siHitIter != multiMatchingHits.end(); ++siHitIter) {
622 const SiHit* lowestXPos = *siHitIter;
623 const SiHit* highestXPos = *siHitIter;
627 std::vector<const SiHit* > ajoiningHits;
628 ajoiningHits.push_back( *siHitIter );
630 siHitIter2 = siHitIter+1;
631 while ( siHitIter2 != multiMatchingHits.end() ) {
640 if (std::abs((highestXPos->
localEndPosition().x()-(*siHitIter2)->localStartPosition().x()))<0.00005 &&
641 std::abs((highestXPos->
localEndPosition().y()-(*siHitIter2)->localStartPosition().y()))<0.00005 &&
642 std::abs((highestXPos->
localEndPosition().z()-(*siHitIter2)->localStartPosition().z()))<0.00005 )
644 highestXPos = *siHitIter2;
645 ajoiningHits.push_back( *siHitIter2 );
648 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
649 }
else if (std::abs((lowestXPos->
localStartPosition().x()-(*siHitIter2)->localEndPosition().x()))<0.00005 &&
650 std::abs((lowestXPos->
localStartPosition().y()-(*siHitIter2)->localEndPosition().y()))<0.00005 &&
651 std::abs((lowestXPos->
localStartPosition().z()-(*siHitIter2)->localEndPosition().z()))<0.00005)
653 lowestXPos = *siHitIter2;
654 ajoiningHits.push_back( *siHitIter2 );
657 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
663 if( ajoiningHits.size() == 0){
666 }
else if(ajoiningHits.size() == 1){
668 matchingHits.push_back( *ajoiningHits[0] );
672 ATH_MSG_DEBUG(
"Merging " << ajoiningHits.size() <<
" SiHits together." );
677 for(
const auto& siHit : ajoiningHits){
678 energyDep += siHit->energyLoss();
679 time += siHit->meanTime();
681 time /= (float)ajoiningHits.size();
687 (*siHitIter)->particleLink(),
689 (*siHitIter)->getBarrelEndcap(),
690 (*siHitIter)->getLayerDisk(),
691 (*siHitIter)->getEtaModule(),
692 (*siHitIter)->getPhiModule(),
693 (*siHitIter)->getSide() );
694 ATH_MSG_DEBUG(
"Finished Merging " << ajoiningHits.size() <<
" SiHits together." );
711 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
713 const std::vector<float> &chList = pixelCluster->chargeList();
714 const std::vector<int> &totList = pixelCluster->totList();
718 std::vector<int> etaIndexList;
719 std::vector<int> phiIndexList;
720 std::vector<float> CTerm;
721 std::vector<float> ATerm;
722 std::vector<float> ETerm;
727 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
728 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
730 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
732 phiIndexList.reserve( rdos.size());
733 etaIndexList.reserve( rdos.size());
734 CTerm.reserve( rdos.size());
735 ATerm.reserve( rdos.size());
736 ETerm.reserve( rdos.size());
737 for (; rdosBegin!= rdosEnd; ++rdosBegin)
750 CTerm.emplace_back(parameters.C);
751 ATerm.emplace_back(parameters.A);
752 ETerm.emplace_back(parameters.E);
757 AUXDATA(xprd, std::vector<int>,rdo_phi_pixel_index) = phiIndexList;
758 AUXDATA(xprd, std::vector<int>,rdo_eta_pixel_index) = etaIndexList;
759 AUXDATA(xprd, std::vector<float>,rdo_charge) = chList;
760 AUXDATA(xprd, std::vector<int>,rdo_tot) = totList;
762 AUXDATA(xprd, std::vector<float>,rdo_Cterm) = CTerm;
763 AUXDATA(xprd, std::vector<float>,rdo_Aterm) = ATerm;
764 AUXDATA(xprd, std::vector<float>,rdo_Eterm) = ETerm;
771 const unsigned int sizeX,
const unsigned int sizeY )
const
784 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNInformation'");
787 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
789 const std::vector<float>& chList = pixelCluster->chargeList();
790 const std::vector<int>& totList = pixelCluster->totList();
798 int phiPixelIndexMin, phiPixelIndexMax, etaPixelIndexMin, etaPixelIndexMax;
801 if (!cellIdWeightedPosition.
isValid())
806 int etaPixelIndexWeightedPosition=cellIdWeightedPosition.
etaIndex();
807 int phiPixelIndexWeightedPosition=cellIdWeightedPosition.
phiIndex();
810 ATH_MSG_DEBUG(
" weighted pos phiPixelIndex: " << phiPixelIndexWeightedPosition <<
" etaPixelIndex: " << etaPixelIndexWeightedPosition );
828 double localEtaPixelIndexWeightedPosition = w.xEta();
829 double localPhiPixelIndexWeightedPosition = w.xPhi();
831 int centralIndexX=(sizeX-1)/2;
832 int centralIndexY=(sizeY-1)/2;
838 if (abs(phiPixelIndexWeightedPosition-phiPixelIndexMin)>centralIndexX ||
839 abs(phiPixelIndexWeightedPosition-phiPixelIndexMax)>centralIndexX)
841 ATH_MSG_DEBUG(
" Cluster too large phiPixelIndexMin " << phiPixelIndexMin <<
" phiPixelIndexMax " << phiPixelIndexMax <<
" centralX " << centralIndexX);
845 if (abs(etaPixelIndexWeightedPosition-etaPixelIndexMin)>centralIndexY ||
846 abs(etaPixelIndexWeightedPosition-etaPixelIndexMax)>centralIndexY)
848 ATH_MSG_DEBUG(
" Cluster too large etaPixelIndexMin" << etaPixelIndexMin <<
" etaPixelIndexMax " << etaPixelIndexMax <<
" centralY " << centralIndexY);
852 std::vector< std::vector<float> > matrixOfToT (sizeX, std::vector<float>(sizeY,0) );
853 std::vector< std::vector<float> > matrixOfCharge(sizeX, std::vector<float>(sizeY,0));
854 std::vector<float> vectorOfPitchesY(sizeY,0.4);
858 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
859 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
860 auto charge = chList.begin();
861 auto tot = totList.begin();
863 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
865 for (; rdosBegin!= rdosEnd; ++rdosBegin)
869 int absphiPixelIndex =
m_PixelHelper->phi_index(rId)-phiPixelIndexWeightedPosition + centralIndexX;
870 int absetaPixelIndex =
m_PixelHelper->eta_index(rId)-etaPixelIndexWeightedPosition + centralIndexY;
871 if (
charge != chList.end()){
872 ATH_MSG_VERBOSE(
" Phi Index: " <<
m_PixelHelper->phi_index(rId) <<
" absphiPixelIndex: " << absphiPixelIndex <<
" eta Idx: " <<
m_PixelHelper->eta_index(rId) <<
" absetaPixelIndex: " << absetaPixelIndex <<
" charge " << *
charge );
874 if (absphiPixelIndex <0 || absphiPixelIndex >= (
int)sizeX)
876 ATH_MSG_DEBUG(
" problem with index: " << absphiPixelIndex <<
" min: " << 0 <<
" max: " << sizeX);
880 if (absetaPixelIndex <0 || absetaPixelIndex >= (
int)sizeY)
882 ATH_MSG_DEBUG(
" problem with index: " << absetaPixelIndex <<
" min: " << 0 <<
" max: " << sizeY);
888 float pitchY = diodeParameters.
width().
xEta();
890 if ( (not totList.empty()) && tot != totList.end()) {
891 matrixOfToT[absphiPixelIndex][absetaPixelIndex] =*tot;
893 }
else matrixOfToT[absphiPixelIndex][absetaPixelIndex] = -1;
895 if ( (not chList.empty()) &&
charge != chList.end()){
896 matrixOfCharge[absphiPixelIndex][absetaPixelIndex]=*
charge;
898 }
else matrixOfCharge[absphiPixelIndex][absetaPixelIndex] = -1;
902 vectorOfPitchesY[absetaPixelIndex]=pitchY;
911 const Amg::Vector2D& prdLocPos = pixelCluster->localPosition();
916 trackDir.normalize();
923 float trkphicomp = trackDir.dot(module_phiax);
924 float trketacomp = trackDir.dot(module_etaax);
925 float trknormcomp = trackDir.dot(module_normal);
926 double bowphi = atan2(trkphicomp,trknormcomp);
927 double boweta = atan2(trketacomp,trknormcomp);
929 if(bowphi > TMath::Pi()/2) bowphi -= TMath::Pi();
930 if(bowphi < -TMath::Pi()/2) bowphi += TMath::Pi();
932 double angle = atan(tan(bowphi)-readoutside*tanl);
937 if (boweta>TMath::Pi()/2.) boweta-=TMath::Pi();
938 if (boweta<-TMath::Pi()/2.) boweta+=TMath::Pi();
942 ATH_MSG_VERBOSE(
" PhiPixelIndexWeightedPosition: " << phiPixelIndexWeightedPosition <<
" EtaPixelIndexWeightedPosition: " << etaPixelIndexWeightedPosition );
945 std::vector<float> vectorOfCharge(sizeX*sizeY,0);
946 std::vector<float> vectorOfToT(sizeX*sizeY,0);
948 for (
unsigned int u=0;u<sizeX;u++)
950 for (
unsigned int s=0;s<sizeY;s++)
952 vectorOfToT[counter] = matrixOfToT[u][s];
953 vectorOfCharge[counter] = matrixOfCharge[u][s];
962 AUXDATA(xprd,
int, NN_sizeX) = sizeX;
963 AUXDATA(xprd,
int, NN_sizeY) = sizeY;
966 AUXDATA(xprd,
float, NN_thetaBS) = boweta;
968 AUXDATA(xprd, std::vector<float>, NN_matrixOfToT) = vectorOfToT;
969 AUXDATA(xprd, std::vector<float>, NN_matrixOfCharge) = vectorOfCharge;
970 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesY) = vectorOfPitchesY;
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) = positionsX;
1136 AUXDATA(xprd, std::vector<float>, NN_positionsY) = positionsY;
1138 AUXDATA(xprd, std::vector<float>, NN_positions_indexX) = positions_indexX;
1139 AUXDATA(xprd, std::vector<float>, NN_positions_indexY) = positions_indexY;
1142 AUXDATA(xprd, std::vector<float>, NN_phi) =
phi;
1144 AUXDATA(xprd, std::vector<int>, NN_barcode) = uniqueID;
1145 AUXDATA(xprd, std::vector<int>, NN_pdgid) = pdgid;
1146 AUXDATA(xprd, std::vector<float>, NN_energyDep) = chargeDep;
1147 AUXDATA(xprd, std::vector<float>, NN_trueP) = truep;
1149 AUXDATA(xprd, std::vector<int>, NN_motherBarcode) = motherUniqueID;
1150 AUXDATA(xprd, std::vector<int>, NN_motherPdgid) = motherPdgid;
1153 AUXDATA(xprd, std::vector<float>, NN_pathlengthX) = pathlengthX;
1154 AUXDATA(xprd, std::vector<float>, NN_pathlengthY) = pathlengthY;
1155 AUXDATA(xprd, std::vector<float>, NN_pathlengthZ) = pathlengthZ;
1164 int *rphiPixelIndexMin,
1165 int *rphiPixelIndexMax,
1166 int *retaPixelIndexMin,
1167 int *retaPixelIndexMax )
const
1178 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'getCellIdWeightedPosition'");
1181 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
1184 const std::vector<float>& chList = pixelCluster->chargeList();
1187 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
1188 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
1190 auto charge = chList.begin();
1193 double sumOfCharge=0;
1195 int phiPixelIndexMin = 99999;
1196 int phiPixelIndexMax = -99999;
1197 int etaPixelIndexMin = 99999;
1198 int etaPixelIndexMax = -99999;
1200 for (; rdosBegin!= rdosEnd; ++rdosBegin, ++
charge)
1207 ATH_MSG_VERBOSE(
" Adding pixel phiPixelIndex: " << phiPixelIndex <<
" etaPixelIndex: " << etaPixelIndex <<
" charge: " << *
charge );
1225 sumOfWeightedPositions += (*charge)*siLocalPosition;
1226 sumOfCharge += (*charge);
1228 if (phiPixelIndex < phiPixelIndexMin)
1229 phiPixelIndexMin = phiPixelIndex;
1231 if (phiPixelIndex > phiPixelIndexMax)
1232 phiPixelIndexMax = phiPixelIndex;
1234 if (etaPixelIndex < etaPixelIndexMin)
1235 etaPixelIndexMin = etaPixelIndex;
1237 if (etaPixelIndex > etaPixelIndexMax)
1238 etaPixelIndexMax = etaPixelIndex;
1241 sumOfWeightedPositions /= sumOfCharge;
1243 ATH_MSG_VERBOSE (
"Wighted position: Row = " << sumOfWeightedPositions.
xRow() <<
", Col = " << sumOfWeightedPositions.
xColumn() );
1245 if(rphiPixelIndexMin) *rphiPixelIndexMin = phiPixelIndexMin;
1246 if(rphiPixelIndexMax) *rphiPixelIndexMax = phiPixelIndexMax;
1247 if(retaPixelIndexMin) *retaPixelIndexMin = etaPixelIndexMin;
1248 if(retaPixelIndexMax) *retaPixelIndexMax = etaPixelIndexMax;
1256 return cellIdWeightedPosition;
1273 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 with parameters:
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.
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