119 int iNumRanges, iRepeatOverX, iRepeatOverY, xEta, yPhi,
k;
120 int iPage, iPosition, iXeta, iYphi;
121 double dEtaMin=-999, dEtaMax=-999, dPhiMin= -999, dPhiMax = -999;
137 for(
k=0;
k<iNumRanges;++
k){
145 iRepeatOverX = std::abs(iRepeatOverX);
148 iRepeatOverY = std::abs(iRepeatOverY);
154 for(yPhi=0;yPhi<iRepeatOverY;++yPhi){
156 for(xEta=0;xEta<iRepeatOverX;++xEta){
157 iPosition = iPage + (iYphi*
m_iColumns +iXeta);
168 for(
k=0;
k<iNumRanges;++
k){
169 std::cout <<
"REGSELECTOR HASH TABLE " <<
174 std::cout << std::hex;
177 std::cout << std::dec;
178 std::cout << std::endl;
181 for(
k=0;
k<iNumRanges;++
k){
188 iRepeatOverX = std::abs(iRepeatOverX);
190 iRepeatOverY = std::abs(iRepeatOverY);
194 for(yPhi=0;yPhi<iRepeatOverY;++yPhi){
196 for(xEta=0;xEta<iRepeatOverX;++xEta){
197 iPosition = iPage + (iYphi*
m_iColumns +iXeta);
198 std::cout <<
"REGSELECTOR MAPS " <<
199 iXeta <<
" " << iYphi <<
" " << iPosition <<
" " <<
201 std::cout << std::hex;
203 std::cout <<
"0x" <<
m_robIDMap[iPosition][
i] <<
" ";
204 std::cout << std::dec;
205 std::cout << std::endl;
216 double phiminIn,
double phimaxIn,
217 std::vector<uint32_t>&
outList)
const {
222 double phiminIn,
double phimaxIn,
223 std::vector<uint32_t>&
outList)
const {
228 int xEta,yPhi, iPosition;
229 int max_iPosition(0);
234 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
235 iPosition = iPage + (yPhi*
m_iColumns + xEta);
236 if(iPosition>max_iPosition) max_iPosition=iPosition;
242 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
243 iPosition = iPage + (yPhi*
m_iColumns + xEta);
252 int xEta,yPhi, iPosition;
255 for(yPhi= 0; yPhi <
m_iLines; ++yPhi){
256 iPosition = iPage + (yPhi*
m_iColumns + xEta);
264 int k, iPage, iNumRanges;
268 for(
k=0;
k<=iNumRanges;++
k){
276 const std::vector<uint32_t>& robId,
const double& emin,
277 const double& emax,
const double& pmin,
278 const double& pmax,
const int& samp){
295 dFloor = std::floor(pdValue);
296 dAux = std::fabs(pdValue-dFloor);
298 iReturn = (
int) (dFloor + 1);
300 iReturn = (
int) dFloor;
306 const double& etaminIn,
const double& etamaxIn,
307 const double& phiminIn,
const double& phimaxIn,
308 std::vector<IdentifierHash>* outListIH)
const {
309 int iYBeg, iYEnd, iXBeg, iXEnd,
k, iPage;
311 std::vector<IdentifierHash>& auxsetIH=(*outListIH);
321 bool pi_boundary =
false;
322 if ( phiminIn>phimaxIn ) pi_boundary =
true;
335 if(iXBeg < 0) iXBeg = 0;
337 if(iXEnd < 0) iXEnd = 0;
383 const double& etaminIn,
const double& etamaxIn,
const double& phiminIn,
384 const double& phimaxIn,
385 std::vector<uint32_t>*
outList)
const {
386 int iYBeg{}, iYEnd{}, iXBeg{}, iXEnd{},
k{}, iPage{};
388 std::vector<uint32_t>& auxset=(*outList);
401 bool pi_boundary =
false;
402 if ( phiminIn>phimaxIn ) pi_boundary =
true;
414 if(iXBeg < 0) iXBeg = 0;
416 if(iXEnd < 0) iXEnd = 0;
463 double etaminIn,
double etamaxIn,
464 double phiminIn,
double phimaxIn,
465 double etamin,
double etamax,
466 std::set<IdentifierHash>* outset)
const {
467 double phimin, phimax;
472 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
473 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
479 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
480 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
487 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
488 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
497 double etaminIn,
double etamaxIn,
498 double phiminIn,
double phimaxIn,
499 double etamin,
double etamax,
500 std::set<uint32_t>* outset)
const {
501 double phimin, phimax;
506 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
507 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
513 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
514 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
521 if( (etaminIn <= etamax) && (etamaxIn >=
etamin) ){
522 if( (phiminIn <= phimax) && (phimaxIn >= phimin) ){
531 double phiminIn,
double phimaxIn,std::vector<IdentifierHash>&
outList)
const {
534 (
double)phiminIn, (
double)phimaxIn,&
outList);
539 double phiminIn,
double phimaxIn, std::vector<IdentifierHash>&
outList)
const {
542 (
double)phiminIn, (
double)phimaxIn,&
outList);
560 double emin, emax, pmin, pmax;
561 double stepPhi, stepEta;
562 char robIdStr[12], robIdStr2[12];
564 std::vector<uint32_t> robId;
568 std::string unresolvedFileName(
filename);
570 if (fullFileName ==
"") {
571 std::cerr <<
"LArTTRegionSelectorIdentifierHash: FATAL: Could not find input file in DATAPATH" << unresolvedFileName<< std::endl;
572 return StatusCode::FAILURE;
575 std::ifstream
fin(fullFileName.c_str());
578 sc = StatusCode::FAILURE;
581 if (strncmp(
buffer,
" TT-ID",6)==0){
586 int test = sscanf(pch,
" %u %d %d %lf %lf %lf %lf %11s %11s",
587 &hashId, &
layer, &samp, &emin, &emax, &pmin, &pmax, robIdStr, robIdStr2);
588 robId.push_back(strtol(robIdStr,
nullptr,16));
590 robId.push_back(strtol(robIdStr2,
nullptr,16));
592 stepPhi = std::fabs(pmax-pmin);
593 stepEta = std::fabs(emin-emax);
603 }
while((
fin.getline(
buffer, 128,
'\n')));
615 std::vector<uint32_t> robId_cpy;
620 double etamin(-999.0), etamax(-999.0), phimin(-999.0), phimax(-999.0);
621 int samp(999),
layer(999);
623 int tablesize = detLut->
maxHash();
633 for(
int j=0; j<tablesize; ++j){
636 detLut->
phiMin(j)==phimin && detLut->
phiMax(j) == phimax &&
638 robId_cpy.push_back(detLut->
robId(j));
653 robId_cpy.push_back(detLut->
robId(j));
659 double stepPhi = std::fabs(phimax-phimin);
660 double stepEta = std::fabs(
etamin-etamax);
677 it != dataList.end(); ++
it){
678 std::cout <<
"position: " << (*it).layerDiskPosition() <<
" number: " << (*it).layerDiskNumber() << std::endl;
681 std::cout <<
"hashId: ";
682 std::vector<IdentifierHash> aux = (*it).hashId();
684 std::cout << (*i) <<
" ";
685 std::cout << std::endl;
691 double &phiminIn,
double &phimaxIn)
const {
694 while (phiminIn > 2*
M_PI ) phiminIn -= 2*
M_PI;
695 while (phiminIn < 0 ) phiminIn += 2*
M_PI;
696 while (phimaxIn > 2*
M_PI ) phimaxIn -= 2*
M_PI;
697 while (phimaxIn < 0 ) phimaxIn += 2*
M_PI;
699 while (phiminIn >
M_PI ) phiminIn -= 2*
M_PI;
700 while (phiminIn < -
M_PI ) phiminIn += 2*
M_PI;
701 while (phimaxIn >
M_PI ) phimaxIn -= 2*
M_PI;
702 while (phimaxIn < -
M_PI ) phimaxIn += 2*
M_PI;
720 double phiminIn,
double phimaxIn,
721 std::vector<uint32_t>& outputIdlist)
const {
723 std::set<uint32_t> myset;
724 std::vector<uint32_t> outset;
725 std::vector<std::vector<uint32_t> >
identifier;
726 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
731 if(etaminIn > etamaxIn){
737 phimintmp = phiminIn;
738 phimaxtmp = phimaxIn;
740 for(
i= 0;
i < vecsize; ++
i){
747 if(phiminIn > phimaxIn ){
751 phimaxIn = phimaxtmp;
757 phiminIn = phimintmp; phimaxIn = phimaxtmp;
761 for(
it = myset.begin();
it!= myset.end(); ++
it){
762 outset.push_back(*
it);
765 if( (outset == outputIdlist) || (outputIdlist.size() >= outset.size()) ){
766 std::cout <<
"equal vectors " << std::endl;
769 std::cout <<
"nonequal vectors " << std::endl;
770 std::cout <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
771 std::cout <<
"desired output ";
772 for(
unsigned int i=0;
i < outset.size(); ++
i)
773 std::cout << std::dec << outset[
i] <<
" ";
774 std::cout << std::endl;
775 std::cout <<
"obtained output ";
776 for(
unsigned int i=0;
i < outputIdlist.size(); ++
i)
777 std::cout << std::dec << outputIdlist[
i] <<
" ";
778 std::cout << std::endl;
784 double etaminIn,
double etamaxIn,
785 double phiminIn,
double phimaxIn,
786 std::vector<uint32_t>& outputIdlist)
const {
789 std::set<uint32_t> myset;
790 std::vector<std::vector<uint32_t> >
identifier;
791 std::vector<uint32_t> outset;
792 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
797 if(etaminIn > etamaxIn){
803 phimintmp = phiminIn;
804 phimaxtmp = phimaxIn;
806 for(
i= 0;
i < vecsize; ++
i){
814 if(phiminIn > phimaxIn ){
818 phimaxIn = phimaxtmp;
825 phiminIn = phimintmp; phimaxIn = phimaxtmp;
829 for(
it = myset.begin();
it!= myset.end(); ++
it){
830 outset.push_back(*
it);
833 if(outset == outputIdlist){
834 std::cout <<
"equal vectors " << std::endl;
837 std::cout <<
"sampling " << sampling <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
838 std::cout <<
"desired output ";
839 for(
unsigned int i=0;
i < outset.size(); ++
i)
840 std::cout << std::dec << outset[
i] <<
" ";
841 std::cout << std::endl;
842 std::cout <<
"obtained output ";
843 for(
unsigned int i=0;
i < outputIdlist.size(); ++
i)
844 std::cout << std::dec << outputIdlist[
i] <<
" ";
845 std::cout << std::endl;
851 double phiminIn,
double phimaxIn,
852 std::vector<IdentifierHash>* outputIdlist)
const {
854 std::set<IdentifierHash> myset;
855 std::vector<IdentifierHash> outset;
856 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
859 if(etaminIn > etamaxIn){
865 phimintmp = phiminIn;
866 phimaxtmp = phimaxIn;
868 for(
i= 0;
i < vecsize; ++
i){
875 if(phiminIn > phimaxIn ){
879 phimaxIn = phimaxtmp;
885 phiminIn = phimintmp; phimaxIn = phimaxtmp;
889 for(
it = myset.begin();
it!= myset.end(); ++
it){
890 outset.push_back(*
it);
893 if(outset == (*outputIdlist) ){
894 std::cout <<
"equal vectors " << std::endl;
897 std::cout <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
898 std::cout <<
"desired output ";
899 for(
unsigned int i=0;
i < outset.size(); ++
i)
900 std::cout << std::dec << outset[
i] <<
" ";
901 std::cout << std::endl;
902 std::cout <<
"obtained output ";
903 for(
unsigned int i=0;
i < (*outputIdlist).size(); ++
i)
904 std::cout << std::dec << (*outputIdlist)[
i] <<
" ";
905 std::cout << std::endl;
910 double phiminIn,
double phimaxIn,
911 std::vector<IdentifierHash>* outputIdlist)
const {
913 std::set<IdentifierHash> myset;
914 std::vector<IdentifierHash> outset;
915 double etamin, etamax, etatmp, phimintmp, phimaxtmp;
918 if(etaminIn > etamaxIn){
924 phimintmp = phiminIn;
925 phimaxtmp = phimaxIn;
927 for(
i= 0;
i < vecsize; ++
i){
935 if(phiminIn > phimaxIn ){
939 phimaxIn = phimaxtmp;
946 phiminIn = phimintmp; phimaxIn = phimaxtmp;
950 for(
it = myset.begin();
it!= myset.end(); ++
it){
951 outset.push_back(*
it);
954 if(outset == (*outputIdlist) ){
955 std::cout <<
"equal vectors " << std::endl;
958 std::cout <<
"sampling " << sampling <<
"eta(" << etaminIn <<
"," << etamaxIn <<
") phi(" << phiminIn <<
"," << phimaxIn <<
")" << std::endl;
959 std::cout <<
"desired output ";
960 for(
unsigned int i=0;
i < outset.size(); ++
i)
961 std::cout << std::dec << outset[
i] <<
" ";
962 std::cout << std::endl;
963 std::cout <<
"obtained output ";
964 for(
unsigned int i=0;
i < (*outputIdlist).size(); ++
i)
965 std::cout << std::dec << (*outputIdlist)[
i] <<
" ";
966 std::cout << std::endl;
972 const int iXBeg,
const int iXEnd,
973 const int iYBeg,
const int iYEnd,
974 const int iPage)
const {
975 int xEta, yPhi, iPosition;
977 for(xEta= iXBeg; xEta < iXEnd; ++xEta){
978 for(yPhi=iYBeg; yPhi < iYEnd; ++yPhi){
979 iPosition = iPage + (yPhi*
m_iColumns + xEta);
986 if(auxsetIH.size()!=0){
987 sort(auxsetIH.begin(),auxsetIH.end());
988 auxsetIH.erase(unique(auxsetIH.begin(),auxsetIH.end()),auxsetIH.end());
994 const int iXBeg,
const int iXEnd,
995 const int iYBeg,
const int iYEnd,
996 const int iPage )
const {
997 int xEta, yPhi, iPosition;
998 unsigned int i,size_rod;
1000 for(xEta= iXBeg; xEta < iXEnd; ++xEta){
1001 for(yPhi=iYBeg; yPhi < iYEnd; ++yPhi){
1002 iPosition = iPage + (yPhi*
m_iColumns + xEta);
1004 for(
i=0;
i < size_rod; ++
i)
1010 if(auxset.size()!=0){
1011 sort(auxset.begin(),auxset.end());
1012 auxset.erase(unique(auxset.begin(),auxset.end()),auxset.end());
1021 double *phiMin,
double *phiMax)
const {
1030 for(
size_t i=0;
i<
vec.size();++
i){