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;
132 const EventContext& ctx = Gaudi::Hive::currentContext();
136 if ( !PixelClusterContainer.isValid() )
138 ATH_MSG_ERROR(
"Failed to retrieve PixelClusterContainer with key" << PixelClusterContainer.key() );
139 return StatusCode::FAILURE;
146 if (prdmtCollHandle.
isValid()) {
147 prdmtColl = &*prdmtCollHandle;
151 if (truthParticleLinksHandle.
isValid()) {
152 truth_particle_links = truthParticleLinksHandle.
cptr();
160 if (sdoCollectionHandle.
isValid()) {
161 sdoCollection = &*sdoCollectionHandle;
163 ATH_MSG_WARNING(
"SDO information requested, but SDO collection not available!");
168 bool foundSplitProbContainer =
false;
171 if (!splitProbContainer.
isValid()) {
174 foundSplitProbContainer =
true;
177 std::vector<std::vector<const SiHit*>> siHits(
m_PixelHelper->wafer_hash_max());
180 if (siHitCollectionHandle.
isValid()) {
181 for (
const SiHit& siHit: *siHitCollectionHandle) {
183 if (!siHit.isPixel())
continue;
186 siHit.getLayerDisk(),
187 siHit.getPhiModule(),
188 siHit.getEtaModule()));
191 siHits[wafer_hash].push_back(&siHit);
194 ATH_MSG_WARNING(
"SiHit information requested, but SiHit collection not available!");
201 if (!calibData_handle.
isValid()) {
204 calibData=calibData_handle.
cptr();
209 ATH_CHECK(xaod.
record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
210 std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
215 unsigned int have_truth_link=0u;
216 unsigned int missing_truth_particle=0u;
217 unsigned int missing_parent_particle=0u;
219 unsigned int counter(0);
225 std::unordered_map< unsigned int , std::vector<unsigned int> > cluster_map;
226 for(
const auto clusterCollection : * PixelClusterContainer ){
229 (*offsets)[clusterCollection->identifyHash()] = counter;
232 if( clusterCollection->empty() )
continue;
245 unsigned int cluster_idx = xaod->size();
246 xaod->push_back(xprd);
262 if(localCov.size() == 1){
264 }
else if(localCov.size() == 4){
271 std::vector< uint64_t > rdoIdentifierList;
272 rdoIdentifierList.reserve(prd->rdoList().size());
273 int rowmin=9999;
int rowmax=-9999;
274 int colmin=9999;
int colmax=-9999;
275 for(
const auto &hitIdentifier : prd->rdoList() ){
276 rdoIdentifierList.push_back( hitIdentifier.get_compact() );
280 if(rowmin > row) rowmin = row;
281 if(rowmax < row) rowmax = row;
282 if(colmin > col) colmin = col;
283 if(colmax < col) colmax = col;
292 AUXDATA(xprd,
int,layer) = the_layer ;
293 AUXDATA(xprd,
int,phi_module) = the_phi ;
294 AUXDATA(xprd,
int,eta_module) = the_eta ;
298 cluster_map[ makeKey(the_phi, the_eta, the_layer)].push_back(cluster_idx);
303 AUXDATA(xprd,
int,nRDO) = (int)prd->rdoList().size();
306 AUXDATA(xprd,
int,ToT) = prd->totalToT();
307 AUXDATA(xprd,
int,LVL1A) = prd->LVL1A();
309 AUXDATA(xprd,
char,isFake) = (char)prd->isFake();
310 AUXDATA(xprd,
char,gangedPixel) = (char)prd->gangedPixel();
313 AUXDATA(xprd,
char,isSplit) =
static_cast<char>(splitProb.
isSplit());
324 AUXDATA(xprd,
int,DCSState) = dcsState->getModuleStatus(moduleHash);
326 float deplVoltage = 0.0;
327 AUXDATA(xprd,
float,BiasVoltage) = dcsHV->getBiasVoltage(moduleHash);
328 AUXDATA(xprd,
float,Temperature) = dcsTemp->getTemperature(moduleHash);
329 AUXDATA(xprd,
float,DepletionVoltage) = deplVoltage;
340 uint64_t detElementId(0);
347 AUXDATA(xprd,uint64_t,detectorElementID) = detElementId;
359 AUXDATA(xprd,
float,centroid_xphi) = centroid.
xPhi();
360 AUXDATA(xprd,
float,centroid_xeta) = centroid.
xEta();
362 AUXDATA(xprd,
float,omegax) = prd->omegax();
363 AUXDATA(xprd,
float,omegay) = prd->omegay();
368 auto range{prdmtColl->equal_range(clusterId)};
369 if (truth_particle_links) {
370 std::vector<unsigned int> tp_indices;
371 for (
auto i{range.first}; i!=range.second; ++i) {
373 if (a_truth_particle_link) {
375 if (truth_particle) {
377 tp_indices.push_back(
static_cast<int>(truth_particle->
index()));
380 ++missing_parent_particle;
384 tp_indices.push_back(std::numeric_limits<unsigned int>::max());
385 ++missing_truth_particle;
389 AUXDATA(xprd,std::vector<unsigned int>, truth_index) = tp_indices;
391 std::vector<int> uniqueIDs;
392 for (
auto i = range.first; i != range.second; ++i) {
396 AUXDATA(xprd,std::vector<int>, truth_barcode) = uniqueIDs;
399 std::vector< std::vector< int > > sdo_tracks;
421 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr ) {
422 AUXDATA(*clusItr,
char,broken) =
false;
432 for (
auto clusItr = xaod->begin(); clusItr != xaod->end(); ++clusItr)
434 auto pixelCluster = *clusItr;
435 int layer = acc_layer(*pixelCluster);
436 std::vector<int> uniqueIDs = acc_sihit_barcode(*pixelCluster);
438 const std::vector< unsigned int> &cluster_idx_list = cluster_map.at( makeKey(acc_phi_module(*pixelCluster), acc_eta_module(*pixelCluster), acc_layer(*pixelCluster) ));
439 for (
unsigned int cluster_idx : cluster_idx_list) {
440 auto pixelCluster2 = xaod->at(cluster_idx);
441 if ( acc_layer(*pixelCluster2) != layer )
443 if ( acc_eta_module(*pixelCluster) != acc_eta_module(*pixelCluster2) )
445 if ( acc_phi_module(*pixelCluster) != acc_phi_module(*pixelCluster2) )
448 std::vector<int> uniqueIDs2 = acc_sihit_barcode(*pixelCluster2);
450 for (
auto uid : uniqueIDs ) {
451 if (std::find(uniqueIDs2.begin(), uniqueIDs2.end(), uid ) == uniqueIDs2.end())
continue;
453 acc_broken(*pixelCluster) =
true;
454 acc_broken(*pixelCluster2) =
true;
460 ATH_MSG_DEBUG(
" recorded PixelPrepData objects: size " << xaod->size() );
464 return StatusCode::SUCCESS;
472 std::vector<int> sdo_word;
473 std::vector< std::vector< int > > sdo_depositsUniqueID;
474 std::vector< std::vector< float > > sdo_depositsEnergy;
476 for(
const auto &hitIdentifier : prd->
rdoList() ){
477 auto pos = sdoCollection.find(hitIdentifier);
478 if( pos == sdoCollection.end() )
continue;
479 sdo_word.push_back( pos->second.word() ) ;
481 std::vector<float> sdoDepEnergy(pos->second.getdeposits().size());
482 unsigned int nDepos{0};
483 for (
auto& deposit: pos->second.getdeposits()) {
486 sdoDepEnergy[nDepos] = deposit.second;
489 sdo_depositsUniqueID.push_back( sdoDepUID );
490 sdo_depositsEnergy.push_back( sdoDepEnergy );
492 AUXDATA(xprd,std::vector<int>,sdo_words) = sdo_word;
493 AUXDATA(xprd,std::vector< std::vector<int> >,sdo_depositsBarcode) = sdo_depositsUniqueID;
494 AUXDATA(xprd,std::vector< std::vector<float> >,sdo_depositsEnergy) = sdo_depositsEnergy;
496 return sdo_depositsUniqueID;
503 const std::vector<SiHit> & matchingHits )
const
506 int numHits = matchingHits.size();
508 std::vector<float> sihit_energyDeposit(numHits,0);
509 std::vector<float> sihit_meanTime(numHits,0);
511 std::vector<int> sihit_pdgid(numHits,0);
513 std::vector<float> sihit_startPosX(numHits,0);
514 std::vector<float> sihit_startPosY(numHits,0);
515 std::vector<float> sihit_startPosZ(numHits,0);
517 std::vector<float> sihit_endPosX(numHits,0);
518 std::vector<float> sihit_endPosY(numHits,0);
519 std::vector<float> sihit_endPosZ(numHits,0);
524 for (
const auto& sihit : matchingHits ) {
525 sihit_energyDeposit[hitNumber] = sihit.energyLoss() ;
526 sihit_meanTime[hitNumber] = sihit.meanTime() ;
530 sihit_pdgid[hitNumber] = HMPL->pdg_id();
534 const HepGeom::Point3D<double>& startPos=sihit.localStartPosition();
537 sihit_startPosX[hitNumber] = pos[0];
538 sihit_startPosY[hitNumber] = pos[1];
539 sihit_startPosZ[hitNumber] = startPos.x();
542 const HepGeom::Point3D<double>& endPos=sihit.localEndPosition();
544 sihit_endPosX[hitNumber] = pos[0];
545 sihit_endPosY[hitNumber] = pos[1];
546 sihit_endPosZ[hitNumber] = endPos.x();
551 AUXDATA(xprd,std::vector<float>,sihit_energyDeposit) = sihit_energyDeposit;
552 AUXDATA(xprd,std::vector<float>,sihit_meanTime) = sihit_meanTime;
553 AUXDATA(xprd,std::vector<int>,sihit_barcode) = sihit_uniqueID;
554 AUXDATA(xprd,std::vector<int>,sihit_pdgid) = sihit_pdgid;
556 AUXDATA(xprd,std::vector<float>,sihit_startPosX) = sihit_startPosX;
557 AUXDATA(xprd,std::vector<float>,sihit_startPosY) = sihit_startPosY;
558 AUXDATA(xprd,std::vector<float>,sihit_startPosZ) = sihit_startPosZ;
560 AUXDATA(xprd,std::vector<float>,sihit_endPosX) = sihit_endPosX;
561 AUXDATA(xprd,std::vector<float>,sihit_endPosY) = sihit_endPosY;
562 AUXDATA(xprd,std::vector<float>,sihit_endPosZ) = sihit_endPosZ;
573 const std::vector<const SiHit*>* sihits,
574 std::vector< std::vector< int > > & trkUIDs )
const
576 ATH_MSG_VERBOSE(
"Got " << sihits->size() <<
" SiHits to look through" );
577 std::vector<SiHit> matchingHits;
584 std::vector<const SiHit* > multiMatchingHits;
586 for (
const SiHit* siHit : *sihits) {
592 HepGeom::Point3D<double> averagePosition = siHit->localStartPosition() + siHit->localEndPosition();
593 averagePosition *= 0.5;
597 for(
const auto &hitIdentifier : prd->
rdoList() ){
603 multiMatchingHits.push_back(siHit);
611 for (
const auto& uniqueIDSDOColl : trkUIDs ) {
612 if (std::find(uniqueIDSDOColl.begin(),uniqueIDSDOColl.end(),uid) == uniqueIDSDOColl.end() )
continue;
613 multiMatchingHits.push_back(siHit);
619 std::vector<const SiHit* >::iterator siHitIter = multiMatchingHits.begin();
620 std::vector<const SiHit* >::iterator siHitIter2 = multiMatchingHits.begin();
621 ATH_MSG_DEBUG(
"Found " << multiMatchingHits.size() <<
" SiHit " );
622 for ( ; siHitIter != multiMatchingHits.end(); ++siHitIter) {
623 const SiHit* lowestXPos = *siHitIter;
624 const SiHit* highestXPos = *siHitIter;
628 std::vector<const SiHit* > ajoiningHits;
629 ajoiningHits.push_back( *siHitIter );
631 siHitIter2 = siHitIter+1;
632 while ( siHitIter2 != multiMatchingHits.end() ) {
641 if (std::abs((highestXPos->
localEndPosition().x()-(*siHitIter2)->localStartPosition().x()))<0.00005 &&
642 std::abs((highestXPos->
localEndPosition().y()-(*siHitIter2)->localStartPosition().y()))<0.00005 &&
643 std::abs((highestXPos->
localEndPosition().z()-(*siHitIter2)->localStartPosition().z()))<0.00005 )
645 highestXPos = *siHitIter2;
646 ajoiningHits.push_back( *siHitIter2 );
649 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
650 }
else if (std::abs((lowestXPos->
localStartPosition().x()-(*siHitIter2)->localEndPosition().x()))<0.00005 &&
651 std::abs((lowestXPos->
localStartPosition().y()-(*siHitIter2)->localEndPosition().y()))<0.00005 &&
652 std::abs((lowestXPos->
localStartPosition().z()-(*siHitIter2)->localEndPosition().z()))<0.00005)
654 lowestXPos = *siHitIter2;
655 ajoiningHits.push_back( *siHitIter2 );
658 siHitIter2 = multiMatchingHits.erase( siHitIter2 );
664 if( ajoiningHits.size() == 0){
667 }
else if(ajoiningHits.size() == 1){
669 matchingHits.push_back( *ajoiningHits[0] );
673 ATH_MSG_DEBUG(
"Merging " << ajoiningHits.size() <<
" SiHits together." );
678 for(
const auto& siHit : ajoiningHits){
679 energyDep += siHit->energyLoss();
680 time += siHit->meanTime();
682 time /= (float)ajoiningHits.size();
688 (*siHitIter)->particleLink(),
690 (*siHitIter)->getBarrelEndcap(),
691 (*siHitIter)->getLayerDisk(),
692 (*siHitIter)->getEtaModule(),
693 (*siHitIter)->getPhiModule(),
694 (*siHitIter)->getSide() );
695 ATH_MSG_DEBUG(
"Finished Merging " << ajoiningHits.size() <<
" SiHits together." );
712 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
714 const std::vector<float> &chList = pixelCluster->chargeList();
715 const std::vector<int> &totList = pixelCluster->totList();
719 std::vector<int> etaIndexList;
720 std::vector<int> phiIndexList;
721 std::vector<float> CTerm;
722 std::vector<float> ATerm;
723 std::vector<float> ETerm;
728 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
729 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
731 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
733 phiIndexList.reserve( rdos.size());
734 etaIndexList.reserve( rdos.size());
735 CTerm.reserve( rdos.size());
736 ATerm.reserve( rdos.size());
737 ETerm.reserve( rdos.size());
738 for (; rdosBegin!= rdosEnd; ++rdosBegin)
751 CTerm.emplace_back(parameters.C);
752 ATerm.emplace_back(parameters.A);
753 ETerm.emplace_back(parameters.E);
758 AUXDATA(xprd, std::vector<int>,rdo_phi_pixel_index) = phiIndexList;
759 AUXDATA(xprd, std::vector<int>,rdo_eta_pixel_index) = etaIndexList;
760 AUXDATA(xprd, std::vector<float>,rdo_charge) = chList;
761 AUXDATA(xprd, std::vector<int>,rdo_tot) = totList;
763 AUXDATA(xprd, std::vector<float>,rdo_Cterm) = CTerm;
764 AUXDATA(xprd, std::vector<float>,rdo_Aterm) = ATerm;
765 AUXDATA(xprd, std::vector<float>,rdo_Eterm) = ETerm;
772 const unsigned int sizeX,
const unsigned int sizeY )
const
785 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNInformation'");
788 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
790 const std::vector<float>& chList = pixelCluster->chargeList();
791 const std::vector<int>& totList = pixelCluster->totList();
799 int phiPixelIndexMin, phiPixelIndexMax, etaPixelIndexMin, etaPixelIndexMax;
802 if (!cellIdWeightedPosition.
isValid())
807 int etaPixelIndexWeightedPosition=cellIdWeightedPosition.
etaIndex();
808 int phiPixelIndexWeightedPosition=cellIdWeightedPosition.
phiIndex();
811 ATH_MSG_DEBUG(
" weighted pos phiPixelIndex: " << phiPixelIndexWeightedPosition <<
" etaPixelIndex: " << etaPixelIndexWeightedPosition );
829 double localEtaPixelIndexWeightedPosition = w.xEta();
830 double localPhiPixelIndexWeightedPosition = w.xPhi();
832 int centralIndexX=(sizeX-1)/2;
833 int centralIndexY=(sizeY-1)/2;
839 if (abs(phiPixelIndexWeightedPosition-phiPixelIndexMin)>centralIndexX ||
840 abs(phiPixelIndexWeightedPosition-phiPixelIndexMax)>centralIndexX)
842 ATH_MSG_DEBUG(
" Cluster too large phiPixelIndexMin " << phiPixelIndexMin <<
" phiPixelIndexMax " << phiPixelIndexMax <<
" centralX " << centralIndexX);
846 if (abs(etaPixelIndexWeightedPosition-etaPixelIndexMin)>centralIndexY ||
847 abs(etaPixelIndexWeightedPosition-etaPixelIndexMax)>centralIndexY)
849 ATH_MSG_DEBUG(
" Cluster too large etaPixelIndexMin" << etaPixelIndexMin <<
" etaPixelIndexMax " << etaPixelIndexMax <<
" centralY " << centralIndexY);
853 std::vector< std::vector<float> > matrixOfToT (sizeX, std::vector<float>(sizeY,0) );
854 std::vector< std::vector<float> > matrixOfCharge(sizeX, std::vector<float>(sizeY,0));
855 std::vector<float> vectorOfPitchesY(sizeY,0.4);
859 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
860 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
861 auto charge = chList.begin();
862 auto tot = totList.begin();
864 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix.");
866 for (; rdosBegin!= rdosEnd; ++rdosBegin)
870 int absphiPixelIndex =
m_PixelHelper->phi_index(rId)-phiPixelIndexWeightedPosition + centralIndexX;
871 int absetaPixelIndex =
m_PixelHelper->eta_index(rId)-etaPixelIndexWeightedPosition + centralIndexY;
872 if (
charge != chList.end()){
873 ATH_MSG_VERBOSE(
" Phi Index: " <<
m_PixelHelper->phi_index(rId) <<
" absphiPixelIndex: " << absphiPixelIndex <<
" eta Idx: " <<
m_PixelHelper->eta_index(rId) <<
" absetaPixelIndex: " << absetaPixelIndex <<
" charge " << *
charge );
875 if (absphiPixelIndex <0 || absphiPixelIndex >= (
int)sizeX)
877 ATH_MSG_DEBUG(
" problem with index: " << absphiPixelIndex <<
" min: " << 0 <<
" max: " << sizeX);
881 if (absetaPixelIndex <0 || absetaPixelIndex >= (
int)sizeY)
883 ATH_MSG_DEBUG(
" problem with index: " << absetaPixelIndex <<
" min: " << 0 <<
" max: " << sizeY);
889 float pitchY = diodeParameters.
width().
xEta();
891 if ( (not totList.empty()) && tot != totList.end()) {
892 matrixOfToT[absphiPixelIndex][absetaPixelIndex] =*tot;
894 }
else matrixOfToT[absphiPixelIndex][absetaPixelIndex] = -1;
896 if ( (not chList.empty()) &&
charge != chList.end()){
897 matrixOfCharge[absphiPixelIndex][absetaPixelIndex]=*
charge;
899 }
else matrixOfCharge[absphiPixelIndex][absetaPixelIndex] = -1;
903 vectorOfPitchesY[absetaPixelIndex]=pitchY;
912 const Amg::Vector2D& prdLocPos = pixelCluster->localPosition();
917 trackDir.normalize();
924 float trkphicomp = trackDir.dot(module_phiax);
925 float trketacomp = trackDir.dot(module_etaax);
926 float trknormcomp = trackDir.dot(module_normal);
927 double bowphi = atan2(trkphicomp,trknormcomp);
928 double boweta = atan2(trketacomp,trknormcomp);
930 if(bowphi > TMath::Pi()/2) bowphi -= TMath::Pi();
931 if(bowphi < -TMath::Pi()/2) bowphi += TMath::Pi();
933 double angle = atan(tan(bowphi)-readoutside*tanl);
938 if (boweta>TMath::Pi()/2.) boweta-=TMath::Pi();
939 if (boweta<-TMath::Pi()/2.) boweta+=TMath::Pi();
943 ATH_MSG_VERBOSE(
" PhiPixelIndexWeightedPosition: " << phiPixelIndexWeightedPosition <<
" EtaPixelIndexWeightedPosition: " << etaPixelIndexWeightedPosition );
946 std::vector<float> vectorOfCharge(sizeX*sizeY,0);
947 std::vector<float> vectorOfToT(sizeX*sizeY,0);
949 for (
unsigned int u=0;u<sizeX;u++)
951 for (
unsigned int s=0;s<sizeY;s++)
953 vectorOfToT[counter] = matrixOfToT[u][s];
954 vectorOfCharge[counter] = matrixOfCharge[u][s];
963 AUXDATA(xprd,
int, NN_sizeX) = sizeX;
964 AUXDATA(xprd,
int, NN_sizeY) = sizeY;
967 AUXDATA(xprd,
float, NN_thetaBS) = boweta;
969 AUXDATA(xprd, std::vector<float>, NN_matrixOfToT) = vectorOfToT;
970 AUXDATA(xprd, std::vector<float>, NN_matrixOfCharge) = vectorOfCharge;
971 AUXDATA(xprd, std::vector<float>, NN_vectorOfPitchesY) = vectorOfPitchesY;
974 AUXDATA(xprd,
int, NN_etaPixelIndexWeightedPosition) = etaPixelIndexWeightedPosition;
975 AUXDATA(xprd,
int, NN_phiPixelIndexWeightedPosition) = phiPixelIndexWeightedPosition;
977 AUXDATA(xprd,
float, NN_localEtaPixelIndexWeightedPosition) = localEtaPixelIndexWeightedPosition;
978 AUXDATA(xprd,
float, NN_localPhiPixelIndexWeightedPosition) = localPhiPixelIndexWeightedPosition;
985 const std::vector<SiHit> & matchingHits )
const
989 unsigned int numberOfSiHits = matchingHits.size();
991 std::vector<float> positionsX(numberOfSiHits,0);
992 std::vector<float> positionsY(numberOfSiHits,0);
994 std::vector<float> positions_indexX(numberOfSiHits,0);
995 std::vector<float> positions_indexY(numberOfSiHits,0);
997 std::vector<float>
theta(numberOfSiHits,0);
998 std::vector<float>
phi(numberOfSiHits,0);
1001 std::vector<int> pdgid(numberOfSiHits,0);
1002 std::vector<float> chargeDep(numberOfSiHits,0);
1003 std::vector<float> truep(numberOfSiHits,0);
1005 std::vector<float> pathlengthX(numberOfSiHits,0);
1006 std::vector<float> pathlengthY(numberOfSiHits,0);
1007 std::vector<float> pathlengthZ(numberOfSiHits,0);
1010 std::vector<int> motherPdgid(numberOfSiHits,0);
1023 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'addNNTruthInfo'");
1028 unsigned hitNumber(0);
1029 for(
const auto& siHit : matchingHits ){
1031 HepGeom::Point3D<double> averagePosition = (siHit.localStartPosition() + siHit.localEndPosition()) * 0.5;
1033 ATH_MSG_VERBOSE(
"Truth Part X: " << averagePosition.y() <<
" shift " << shift <<
" Y: " << averagePosition.z() );
1036 float YposC = averagePosition.y()-shift;
1038 if (std::abs(YposC)>design->
width()/2 &&
1039 std::abs(averagePosition.y())<design->
width()/2)
1041 if (YposC>design->
width()/2)
1043 YposC=design->
width()/2-1e-6;
1044 }
else if (YposC<-design->
width()/2)
1046 YposC=-design->
width()/2+1e-6;
1050 positionsX[hitNumber] = YposC;
1051 positionsY[hitNumber] = averagePosition.z();
1053 HepGeom::Point3D<double> deltaPosition = siHit.localEndPosition() - siHit.localStartPosition();
1055 pathlengthX[hitNumber] = deltaPosition.y();
1056 pathlengthY[hitNumber] = deltaPosition.z();
1057 pathlengthZ[hitNumber] = deltaPosition.x();
1068 int truthEtaIndex = cellIdOfTruthPosition.
etaIndex();
1069 int truthPhiIndex = cellIdOfTruthPosition.
phiIndex();
1072 double pitchY = diodeParameters.
width().
xEta();
1073 double pitchX = diodeParameters.
width().
xPhi();
1090 double pixelCenterY = siLocalPositionCenter.
xEta();
1091 double pixelCenterX = siLocalPositionCenter.
xPhi();
1097 double truthIndexY = truthEtaIndex + (siLocalTruthPosition[
Trk::distEta] - pixelCenterY)/pitchY;
1098 double truthIndexX = truthPhiIndex + (siLocalTruthPosition[
Trk::distPhi] - pixelCenterX)/pitchX;
1101 positions_indexX[hitNumber] = truthIndexX - cellIdWeightedPosition.
phiIndex();
1102 positions_indexY[hitNumber] = truthIndexY - cellIdWeightedPosition.
etaIndex();
1104 HepGeom::Point3D<double> diffPositions = (siHit.localEndPosition() - siHit.localStartPosition());
1105 double bowphi = std::atan2( diffPositions.y(), diffPositions.x() );
1109 theta[hitNumber] = std::atan2(diffPositions.z() ,diffPositions.x());
1114 phi[hitNumber] = std::atan(std::tan(bowphi)-readoutside*tanlorentz);
1118 const auto particle = HMPL.
cptr();
1119 pdgid[hitNumber] = particle->pdg_id();
1120 HepMC::FourVector mom=particle->momentum();
1121 truep[hitNumber] = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
1122 const auto vertex = particle->production_vertex();
1125 if ( vertex && !vertex->particles_in().empty()){
1126 const auto& mother_of_particle=vertex->particles_in().front();
1128 motherPdgid[hitNumber] = mother_of_particle->pdg_id();
1132 if( vertex->particles_in_const_begin() != vertex->particles_in_const_end() ){
1133 motherUniqueID[hitNumber] =
HepMC::uniqueID(*vertex->particles_in_const_begin());
1134 motherPdgid[hitNumber] = (*vertex->particles_in_const_begin())->pdg_id();
1139 chargeDep[hitNumber] = siHit.energyLoss() ;
1145 AUXDATA(xprd, std::vector<float>, NN_positionsX) = positionsX;
1146 AUXDATA(xprd, std::vector<float>, NN_positionsY) = positionsY;
1148 AUXDATA(xprd, std::vector<float>, NN_positions_indexX) = positions_indexX;
1149 AUXDATA(xprd, std::vector<float>, NN_positions_indexY) = positions_indexY;
1152 AUXDATA(xprd, std::vector<float>, NN_phi) =
phi;
1154 AUXDATA(xprd, std::vector<int>, NN_barcode) = uniqueID;
1155 AUXDATA(xprd, std::vector<int>, NN_pdgid) = pdgid;
1156 AUXDATA(xprd, std::vector<float>, NN_energyDep) = chargeDep;
1157 AUXDATA(xprd, std::vector<float>, NN_trueP) = truep;
1159 AUXDATA(xprd, std::vector<int>, NN_motherBarcode) = motherUniqueID;
1160 AUXDATA(xprd, std::vector<int>, NN_motherPdgid) = motherPdgid;
1163 AUXDATA(xprd, std::vector<float>, NN_pathlengthX) = pathlengthX;
1164 AUXDATA(xprd, std::vector<float>, NN_pathlengthY) = pathlengthY;
1165 AUXDATA(xprd, std::vector<float>, NN_pathlengthZ) = pathlengthZ;
1174 int *rphiPixelIndexMin,
1175 int *rphiPixelIndexMax,
1176 int *retaPixelIndexMin,
1177 int *retaPixelIndexMax )
const
1188 ATH_MSG_WARNING(
"PixelModuleDesign was not retrieved in function 'getCellIdWeightedPosition'");
1191 const std::vector<Identifier>& rdos = pixelCluster->rdoList();
1194 const std::vector<float>& chList = pixelCluster->chargeList();
1197 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
1198 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
1200 auto charge = chList.begin();
1203 double sumOfCharge=0;
1205 int phiPixelIndexMin = 99999;
1206 int phiPixelIndexMax = -99999;
1207 int etaPixelIndexMin = 99999;
1208 int etaPixelIndexMax = -99999;
1210 for (; rdosBegin!= rdosEnd; ++rdosBegin, ++
charge)
1217 ATH_MSG_VERBOSE(
" Adding pixel phiPixelIndex: " << phiPixelIndex <<
" etaPixelIndex: " << etaPixelIndex <<
" charge: " << *
charge );
1235 sumOfWeightedPositions += (*charge)*siLocalPosition;
1236 sumOfCharge += (*charge);
1238 if (phiPixelIndex < phiPixelIndexMin)
1239 phiPixelIndexMin = phiPixelIndex;
1241 if (phiPixelIndex > phiPixelIndexMax)
1242 phiPixelIndexMax = phiPixelIndex;
1244 if (etaPixelIndex < etaPixelIndexMin)
1245 etaPixelIndexMin = etaPixelIndex;
1247 if (etaPixelIndex > etaPixelIndexMax)
1248 etaPixelIndexMax = etaPixelIndex;
1251 sumOfWeightedPositions /= sumOfCharge;
1253 ATH_MSG_VERBOSE (
"Wighted position: Row = " << sumOfWeightedPositions.
xRow() <<
", Col = " << sumOfWeightedPositions.
xColumn() );
1255 if(rphiPixelIndexMin) *rphiPixelIndexMin = phiPixelIndexMin;
1256 if(rphiPixelIndexMax) *rphiPixelIndexMax = phiPixelIndexMax;
1257 if(retaPixelIndexMin) *retaPixelIndexMin = etaPixelIndexMin;
1258 if(retaPixelIndexMax) *retaPixelIndexMax = etaPixelIndexMax;
1266 return cellIdWeightedPosition;
1283 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
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()
virtual StatusCode execute()
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
SG::Accessor< T, ALLOC > Accessor
size_t index() const
Return the index of this element within its container.
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
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