796 {
800 if (not element) {
803 }
804 const AtlasDetectorID* aid = element->
getIdHelper();
805 if (not aid){
808 }
809
813 }
814 const PixelID* pixelIDp=static_cast<const PixelID*>(aid);
815 const PixelID& pixelID = *pixelIDp;
816 const InDetDD::PixelModuleDesign* design
817 (dynamic_cast<const InDetDD::PixelModuleDesign*>(&element->design()));
818 if (not design){
819 ATH_MSG_ERROR(
"Dynamic cast failed at line "<<__LINE__<<
" of NnClusterizationFactory.cxx.");
821 }
822 SG::ReadCondHandle<PixelChargeCalibCondData> calibDataHandle(
m_chargeDataKey);
823 const PixelChargeCalibCondData *calibData = *calibDataHandle;
824 const std::vector<Identifier>& rdos = pCluster.
rdoList();
825 const size_t rdoSize = rdos.size();
827 const std::vector<float>& chList = pCluster.
chargeList();
828 const std::vector<int>& totList = pCluster.
totList();
829 std::vector<float> chListRecreated{};
830 chListRecreated.reserve(rdoSize);
832 std::vector<int>::const_iterator
tot = totList.begin();
833 std::vector<Identifier>::const_iterator rdosBegin = rdos.begin();
834 std::vector<Identifier>::const_iterator rdosEnd = rdos.end();
835 std::vector<int> totListRecreated{};
836 totListRecreated.reserve(rdoSize);
837 std::vector<int>::const_iterator totRecreated = totListRecreated.begin();
838
840 IdentifierHash moduleHash = element->identifyHash();
841
842 for ( ; rdosBegin!= rdosEnd and
tot != totList.end(); ++
tot, ++rdosBegin, ++totRecreated ){
843
845 Identifier pixid = *rdosBegin;
847
848 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
851 InDetDD::PixelDiodeTree::DiodeProxy si_param ( design->diodeProxyFromIdx(diode_idx));
852 std::uint32_t feValue = design->getFE(si_param);
853 auto diode_type = design->getDiodeType(si_param);
855 && design->numberOfConnectedCells( design->readoutIdOfCell(InDetDD::SiCellId(diode_idx[0],diode_idx[1])))>1) {
857 }
858
859 float charge = calibData->
getCharge(diode_type, moduleHash, feValue, tot0);
860 chListRecreated.push_back(
charge);
861 totListRecreated.push_back(tot0);
862 }
863
864 rdosBegin = rdos.begin();
865 rdosEnd = rdos.end();
866
867 tot = totList.begin();
868 totRecreated = totListRecreated.begin();
869
870 std::vector<float>::const_iterator
charge = chListRecreated.begin();
871 std::vector<float>::const_iterator chargeEnd = chListRecreated.end();
872 tot = totListRecreated.begin();
873 std::vector<int>::const_iterator totEnd = totListRecreated.end();
874 InDetDD::SiLocalPosition sumOfWeightedPositions(0,0,0);
875 double sumOfTot=0;
876 int rowMin = 999;
877 int rowMax = 0;
878 int colMin = 999;
879 int colMax = 0;
880 for (; (rdosBegin!= rdosEnd) and (
charge != chargeEnd) and (tot != totEnd); ++rdosBegin, ++
charge, ++
tot){
881 Identifier rId = *rdosBegin;
884 InDetDD::SiLocalPosition siLocalPosition (design->positionFromColumnRow(col,row));
886 sumOfWeightedPositions += (*charge)*siLocalPosition;
887 sumOfTot += (*charge);
888 } else {
889 sumOfWeightedPositions += ((
double)(*tot))*siLocalPosition;
890 sumOfTot += (
double)(*tot);
891 }
892 rowMin = std::min(row, rowMin);
893 rowMax = std::max(row, rowMax);
894 colMin = std::min(col, colMin);
895 colMax = std::max(col, colMax);
896
897 }
898 sumOfWeightedPositions /= sumOfTot;
899
900
901 InDetDD::SiCellId cellIdWeightedPosition=design->cellIdOfPosition(sumOfWeightedPositions);
902
903 if (!cellIdWeightedPosition.
isValid()){
905 }
906 int columnWeightedPosition=cellIdWeightedPosition.
etaIndex();
907 int rowWeightedPosition=cellIdWeightedPosition.
phiIndex();
908 ATH_MSG_VERBOSE(
" weighted pos row: " << rowWeightedPosition <<
" col: " << columnWeightedPosition );
909 int centralIndexX=(
m_sizeX-1)/2;
910 int centralIndexY=(
m_sizeY-1)/2;
911 if (std::abs(rowWeightedPosition-rowMin)>centralIndexX or
912 std::abs(rowWeightedPosition-rowMax)>centralIndexX){
913 ATH_MSG_VERBOSE(
" Cluster too large rowMin" << rowMin <<
" rowMax " << rowMax <<
" centralX " << centralIndexX);
915 }
916 if (std::abs(columnWeightedPosition-colMin)>centralIndexY or
917 std::abs(columnWeightedPosition-colMax)>centralIndexY){
918 ATH_MSG_VERBOSE(
" Cluster too large colMin" << colMin <<
" colMax " << colMax <<
" centralY " << centralIndexY);
920 }
924 }
925
926
927
929 input.vectorOfPitchesY.assign(
m_sizeY, design->etaPitch());
930 input.vectorOfPitchesX.assign(
m_sizeX, design->phiPitch());
931 } else {
933 }
934 rdosBegin = rdos.begin();
935 charge = chListRecreated.begin();
936 chargeEnd = chListRecreated.end();
937 tot = totListRecreated.begin();
938 ATH_MSG_VERBOSE(
" Putting together the n. " << rdos.size() <<
" rdos into a matrix." );
939 Identifier pixidentif=pCluster.
identify();
943 for (;(
charge != chargeEnd) and (rdosBegin!= rdosEnd); ++rdosBegin, ++
charge, ++
tot){
944 Identifier rId = *rdosBegin;
945 unsigned int absrow = pixelID.
phi_index(rId)-rowWeightedPosition+centralIndexX;
946 unsigned int abscol = pixelID.
eta_index(rId)-columnWeightedPosition+centralIndexY;
950 }
954 }
955 InDetDD::SiCellId cellId = element->cellIdFromIdentifier(*rdosBegin);
956 InDetDD::SiDiodesParameters diodeParameters = design->parameters(cellId);
957 double pitchY = diodeParameters.
width().
xEta();
958 double pitchX = diodeParameters.
width().
xPhi();
961 } else {
963
966 input.matrixOfToT[absrow][abscol]*=3;
967 }
968 }else{
969
970 if ( (
input.ClusterPixLayer==0) and (
input.ClusterPixBarrelEC==0)){
971 input.matrixOfToT[absrow][abscol]*=3;
972 }
973 }
974
975 }
977 input.vectorOfPitchesY[abscol]=pitchY;
978 input.vectorOfPitchesX[absrow]=pitchX;
979 } else if (std::abs(pitchY-0.4)>1e-5){
980
981 input.vectorOfPitchesY[abscol]=pitchY;
982 }
983 }
986 input.useTrackInfo=
false;
988 InDetDD::SiLocalPosition centroid(prdLocPos);
994 float trkphicomp = my_track.dot(my_phiax);
995 float trketacomp = my_track.dot(my_etaax);
996 float trknormcomp = my_track.dot(my_normal);
997 double bowphi = std::atan2(trkphicomp,trknormcomp);
998 double boweta = std::atan2(trketacomp,trknormcomp);
1000 if(bowphi > M_PI_2) bowphi -=
M_PI;
1001 if(bowphi < -M_PI_2) bowphi +=
M_PI;
1002 int readoutside = design->readoutSide();
1003 double angle = std::atan(std::tan(bowphi)-readoutside*tanl);
1006 if (boweta>M_PI_2) boweta-=
M_PI;
1007 if (boweta<-M_PI_2) boweta+=
M_PI;
1010 input.rowWeightedPosition=rowWeightedPosition;
1011 input.columnWeightedPosition=columnWeightedPosition;
1012 ATH_MSG_VERBOSE(
" RowWeightedPosition: " << rowWeightedPosition <<
" ColWeightedPosition: " << columnWeightedPosition );
1014 }
#define ATH_MSG_WARNING(x)
double charge(const T &p)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex(T local_x_idx, T local_y_idx)
Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.
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.
const SiLocalPosition & width() const
width of the diodes:
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline).
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
ToolHandle< ISiLorentzAngleTool > m_pixelLorentzAngleTool
Gaudi::Property< bool > m_useXPitches
Gaudi::Property< bool > m_doRunI
const std::vector< int > & totList() const
const std::vector< float > & chargeList() const
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...
float getCharge(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float ToT) const
int eta_index(const Identifier &id) const
int layer_disk(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
int eta_module(const Identifier &id) const
int phi_index(const Identifier &id) const
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Eigen::Matrix< double, 2, 1 > Vector2D
row
Appending html table to final .html summary file.