96 int iNumRanges, iRepeatOverX, iRepeatOverY, xEta, yPhi,
k;
97 int iPage, iPosition, iXeta, iYphi;
98 double dEtaMin=-999, dEtaMax=-999, dPhiMin= -999, dPhiMax = -999;
114 for(
k=0;
k<iNumRanges;++
k){
122 iRepeatOverX = std::abs(iRepeatOverX);
125 iRepeatOverY = std::abs(iRepeatOverY);
131 for(yPhi=0;yPhi<iRepeatOverY;++yPhi){
133 for(xEta=0;xEta<iRepeatOverX;++xEta){
134 iPosition = iPage + (iYphi*
m_iColumns +iXeta);
145 for(
k=0;
k<iNumRanges;++
k){
146 std::cout <<
"REGSELECTOR HASH TABLE " <<
151 std::cout << std::hex;
154 std::cout << std::dec;
155 std::cout << std::endl;
158 for(
k=0;
k<iNumRanges;++
k){
165 iRepeatOverX = std::abs(iRepeatOverX);
167 iRepeatOverY = std::abs(iRepeatOverY);
171 for(yPhi=0;yPhi<iRepeatOverY;++yPhi){
173 for(xEta=0;xEta<iRepeatOverX;++xEta){
174 iPosition = iPage + (iYphi*
m_iColumns +iXeta);
175 std::cout <<
"REGSELECTOR MAPS " <<
176 iXeta <<
" " << iYphi <<
" " << iPosition <<
" " <<
178 std::cout << std::hex;
180 std::cout <<
"0x" <<
m_robIDMap[iPosition][
i] <<
" ";
181 std::cout << std::dec;
182 std::cout << std::endl;
193 double phiminIn,
double phimaxIn,
194 std::vector<uint32_t>&
outList)
const {
199 double phiminIn,
double phimaxIn,
200 std::vector<uint32_t>&
outList)
const {
205 int xEta,yPhi, iPosition;
206 int max_iPosition(0);
211 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
212 iPosition = iPage + (yPhi*
m_iColumns + xEta);
213 if(iPosition>max_iPosition) max_iPosition=iPosition;
219 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
220 iPosition = iPage + (yPhi*
m_iColumns + xEta);
229 int xEta,yPhi, iPosition;
232 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
233 iPosition = iPage + (yPhi*
m_iColumns + xEta);
241 int k, iPage, iNumRanges;
245 for(
k=0;
k<=iNumRanges;++
k){
253 const std::vector<uint32_t>& robId,
const double& emin,
254 const double& emax,
const double& pmin,
255 const double& pmax,
const int& samp){
272 dFloor = std::floor(pdValue);
273 dAux = std::fabs(pdValue-dFloor);
275 iReturn = (
int) (dFloor + 1);
277 iReturn = (
int) dFloor;
283 const double& etaminIn,
const double& etamaxIn,
284 const double& phiminIn,
const double& phimaxIn,
285 std::vector<IdentifierHash>* outListIH)
const {
286 int iYBeg, iYEnd, iXBeg, iXEnd,
k, iPage;
288 std::vector<IdentifierHash>& auxsetIH=(*outListIH);
298 bool pi_boundary =
false;
299 if ( phiminIn>phimaxIn ) pi_boundary =
true;
312 if(iXBeg < 0) iXBeg = 0;
314 if(iXEnd < 0) iXEnd = 0;
360 const double& etaminIn,
const double& etamaxIn,
const double& phiminIn,
361 const double& phimaxIn,
362 std::vector<uint32_t>*
outList)
const {
363 int iYBeg{}, iYEnd{}, iXBeg{}, iXEnd{},
k{}, iPage{};
365 std::vector<uint32_t>& auxset=(*outList);
378 bool pi_boundary =
false;
379 if ( phiminIn>phimaxIn ) pi_boundary =
true;
391 if(iXBeg < 0) iXBeg = 0;
393 if(iXEnd < 0) iXEnd = 0;
440 double etaminIn,
double etamaxIn,
441 double phiminIn,
double phimaxIn,
442 double etamin,
double etamax,
443 std::set<IdentifierHash>* outset)
const {
444 double phimin, phimax;
449 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
450 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
456 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
457 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
464 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
465 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
474 double etaminIn,
double etamaxIn,
475 double phiminIn,
double phimaxIn,
476 double etamin,
double etamax,
477 std::set<uint32_t>* outset)
const {
478 double phimin, phimax;
483 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
484 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
490 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
491 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
498 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
499 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
508 double phiminIn,
double phimaxIn,std::vector<IdentifierHash>&
outList)
const {
511 (
double)phiminIn, (
double)phimaxIn,&
outList);
516 double phiminIn,
double phimaxIn, std::vector<IdentifierHash>&
outList)
const {
519 (
double)phiminIn, (
double)phimaxIn,&
outList);
537 double emin, emax, pmin, pmax;
538 double stepPhi, stepEta;
539 char robIdStr[12], robIdStr2[12];
541 std::vector<uint32_t> robId;
545 std::string unresolvedFileName(
filename);
547 if (fullFileName ==
"") {
548 std::cerr <<
"LArTTRegionSelectorIdentifierHash: FATAL: Could not find input file in DATAPATH" << unresolvedFileName<< std::endl;
549 return StatusCode::FAILURE;
552 std::ifstream
fin(fullFileName.c_str());
555 sc = StatusCode::FAILURE;
558 if (strncmp(
buffer,
" TT-ID",6)==0){
563 int test = sscanf(pch,
" %u %d %d %lf %lf %lf %lf %11s %11s",
564 &hashId, &
layer, &samp, &emin, &emax, &pmin, &pmax, robIdStr, robIdStr2);
565 robId.push_back(strtol(robIdStr,
nullptr,16));
567 robId.push_back(strtol(robIdStr2,
nullptr,16));
569 stepPhi = std::fabs(pmax-pmin);
570 stepEta = std::fabs(emin-emax);
580 }
while((
fin.getline(
buffer, 128,
'\n')));
592 std::vector<uint32_t> robId_cpy;
597 double etamin(-999.0), etamax(-999.0), phimin(-999.0), phimax(-999.0);
598 int samp(999),
layer(999);
600 int tablesize = detLut->
maxHash();
610 for(
int j=0; j<tablesize; ++j){
613 detLut->
phiMin(j)==phimin && detLut->
phiMax(j) == phimax &&
615 robId_cpy.push_back(detLut->
robId(j));
630 robId_cpy.push_back(detLut->
robId(j));
636 double stepPhi = std::fabs(phimax-phimin);
637 double stepEta = std::fabs(
etamin-etamax);
654 it != dataList.end(); ++
it){
655 std::cout <<
"position: " << (*it).layerDiskPosition() <<
" number: " << (*it).layerDiskNumber() << std::endl;
658 std::cout <<
"hashId: ";
659 std::vector<IdentifierHash> aux = (*it).hashId();
661 std::cout << (*i) <<
" ";
662 std::cout << std::endl;
668 double &phiminIn,
double &phimaxIn)
const {
671 while (phiminIn > 2*
M_PI ) phiminIn -= 2*
M_PI;
672 while (phiminIn < 0 ) phiminIn += 2*
M_PI;
673 while (phimaxIn > 2*
M_PI ) phimaxIn -= 2*
M_PI;
674 while (phimaxIn < 0 ) phimaxIn += 2*
M_PI;
676 while (phiminIn >
M_PI ) phiminIn -= 2*
M_PI;
677 while (phiminIn < -
M_PI ) phiminIn += 2*
M_PI;
678 while (phimaxIn >
M_PI ) phimaxIn -= 2*
M_PI;
679 while (phimaxIn < -
M_PI ) phimaxIn += 2*
M_PI;
697 double phiminIn,
double phimaxIn,
698 std::vector<uint32_t>& outputIdlist)
const {
700 std::set<uint32_t> myset;
701 std::vector<uint32_t> outset;
702 std::vector<std::vector<uint32_t> >
identifier;
703 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
708 if(etaminIn > etamaxIn){
714 phimintmp = phiminIn;
715 phimaxtmp = phimaxIn;
717 for(
i= 0;
i < vecsize; ++
i){
724 if(phiminIn > phimaxIn ){
728 phimaxIn = phimaxtmp;
734 phiminIn = phimintmp; phimaxIn = phimaxtmp;
738 for(
it = myset.begin();
it!= myset.end(); ++
it){
739 outset.push_back(*
it);
742 if( (outset == outputIdlist) || (outputIdlist.size() >= outset.size()) ){
743 std::cout <<
"equal vectors " << std::endl;
746 std::cout <<
"nonequal vectors " << std::endl;
747 std::cout <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
748 std::cout <<
"desired output ";
749 for(
unsigned int i=0;
i < outset.size(); ++
i)
750 std::cout << std::dec << outset[
i] <<
" ";
751 std::cout << std::endl;
752 std::cout <<
"obtained output ";
753 for(
unsigned int i=0;
i < outputIdlist.size(); ++
i)
754 std::cout << std::dec << outputIdlist[
i] <<
" ";
755 std::cout << std::endl;
761 double etaminIn,
double etamaxIn,
762 double phiminIn,
double phimaxIn,
763 std::vector<uint32_t>& outputIdlist)
const {
766 std::set<uint32_t> myset;
767 std::vector<std::vector<uint32_t> >
identifier;
768 std::vector<uint32_t> outset;
769 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
774 if(etaminIn > etamaxIn){
780 phimintmp = phiminIn;
781 phimaxtmp = phimaxIn;
783 for(
i= 0;
i < vecsize; ++
i){
791 if(phiminIn > phimaxIn ){
795 phimaxIn = phimaxtmp;
802 phiminIn = phimintmp; phimaxIn = phimaxtmp;
806 for(
it = myset.begin();
it!= myset.end(); ++
it){
807 outset.push_back(*
it);
810 if(outset == outputIdlist){
811 std::cout <<
"equal vectors " << std::endl;
814 std::cout <<
"sampling " << sampling <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
815 std::cout <<
"desired output ";
816 for(
unsigned int i=0;
i < outset.size(); ++
i)
817 std::cout << std::dec << outset[
i] <<
" ";
818 std::cout << std::endl;
819 std::cout <<
"obtained output ";
820 for(
unsigned int i=0;
i < outputIdlist.size(); ++
i)
821 std::cout << std::dec << outputIdlist[
i] <<
" ";
822 std::cout << std::endl;
828 double phiminIn,
double phimaxIn,
829 std::vector<IdentifierHash>* outputIdlist)
const {
831 std::set<IdentifierHash> myset;
832 std::vector<IdentifierHash> outset;
833 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
836 if(etaminIn > etamaxIn){
842 phimintmp = phiminIn;
843 phimaxtmp = phimaxIn;
845 for(
i= 0;
i < vecsize; ++
i){
852 if(phiminIn > phimaxIn ){
856 phimaxIn = phimaxtmp;
862 phiminIn = phimintmp; phimaxIn = phimaxtmp;
866 for(
it = myset.begin();
it!= myset.end(); ++
it){
867 outset.push_back(*
it);
870 if(outset == (*outputIdlist) ){
871 std::cout <<
"equal vectors " << std::endl;
874 std::cout <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
875 std::cout <<
"desired output ";
876 for(
unsigned int i=0;
i < outset.size(); ++
i)
877 std::cout << std::dec << outset[
i] <<
" ";
878 std::cout << std::endl;
879 std::cout <<
"obtained output ";
880 for(
unsigned int i=0;
i < (*outputIdlist).size(); ++
i)
881 std::cout << std::dec << (*outputIdlist)[
i] <<
" ";
882 std::cout << std::endl;
887 double phiminIn,
double phimaxIn,
888 std::vector<IdentifierHash>* outputIdlist)
const {
890 std::set<IdentifierHash> myset;
891 std::vector<IdentifierHash> outset;
892 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
895 if(etaminIn > etamaxIn){
901 phimintmp = phiminIn;
902 phimaxtmp = phimaxIn;
904 for(
i= 0;
i < vecsize; ++
i){
912 if(phiminIn > phimaxIn ){
916 phimaxIn = phimaxtmp;
923 phiminIn = phimintmp; phimaxIn = phimaxtmp;
927 for(
it = myset.begin();
it!= myset.end(); ++
it){
928 outset.push_back(*
it);
931 if(outset == (*outputIdlist) ){
932 std::cout <<
"equal vectors " << std::endl;
935 std::cout <<
"sampling " << sampling <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
936 std::cout <<
"desired output ";
937 for(
unsigned int i=0;
i < outset.size(); ++
i)
938 std::cout << std::dec << outset[
i] <<
" ";
939 std::cout << std::endl;
940 std::cout <<
"obtained output ";
941 for(
unsigned int i=0;
i < (*outputIdlist).size(); ++
i)
942 std::cout << std::dec << (*outputIdlist)[
i] <<
" ";
943 std::cout << std::endl;
949 const int iXBeg,
const int iXEnd,
950 const int iYBeg,
const int iYEnd,
951 const int iPage)
const {
952 int xEta, yPhi, iPosition;
954 for(xEta= iXBeg; xEta < iXEnd; ++xEta){
955 for(yPhi=iYBeg; yPhi < iYEnd; ++yPhi){
956 iPosition = iPage + (yPhi*
m_iColumns + xEta);
963 if(auxsetIH.size()!=0){
964 sort(auxsetIH.begin(),auxsetIH.end());
965 auxsetIH.erase(unique(auxsetIH.begin(),auxsetIH.end()),auxsetIH.end());
971 const int iXBeg,
const int iXEnd,
972 const int iYBeg,
const int iYEnd,
973 const int iPage )
const {
974 int xEta, yPhi, iPosition;
975 unsigned int i,size_rod;
977 for(xEta= iXBeg; xEta < iXEnd; ++xEta){
978 for(yPhi=iYBeg; yPhi < iYEnd; ++yPhi){
979 iPosition = iPage + (yPhi*
m_iColumns + xEta);
981 for(
i=0;
i < size_rod; ++
i)
987 if(auxset.size()!=0){
988 sort(auxset.begin(),auxset.end());
989 auxset.erase(unique(auxset.begin(),auxset.end()),auxset.end());
998 double *phiMin,
double *phiMax)
const {
1007 for(
size_t i=0;
i<
vec.size();++
i){