21 std::vector<DetId>& vdets,
23 bool ignoreTransition) {
32 edm::LogVerbatim(
"IsoTrack") <<
"matrixECALIds::Add " << ieta <<
" rows and " << iphi
35 std::vector<DetId> dets(1, det);
36 std::vector<CaloDirection>
dirs(1,
NORTH);
38 dets, 0, ieta, iphi, dirs, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
41 dets, 0, ieta, iphi, dirs, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
42 for (
unsigned int i1 = 0; i1 < vdetS.size(); i1++) {
43 if (
std::count(vdets.begin(), vdets.end(), vdetS[i1]) == 0)
44 vdets.push_back(vdetS[i1]);
46 unsigned int ndet = (2 * ieta + 1) * (2 * iphi + 1);
47 if (vdets.size() != ndet) {
48 std::vector<DetId> vdetExtra;
49 spr::extraIds(det, vdets, ieta, ieta, iphi, iphi, barrelGeom, endcapGeom, vdetExtra, debug);
50 if (!vdetExtra.empty())
51 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
55 edm::LogVerbatim(
"IsoTrack") <<
"matrixECALIds::Total number of cells found is " << vdets.size();
66 bool ignoreTransition) {
67 std::vector<DetId> vdets;
68 spr::matrixECALIds(det, ieta, iphi, geo, caloTopology, vdets, debug, ignoreTransition);
78 bool ignoreTransition) {
87 int ietaphi = (int)(dR / 2.0) + 1;
88 std::vector<DetId> vdets, vdetx;
89 spr::matrixECALIds(det, ietaphi, ietaphi, geo, caloTopology, vdets, debug, ignoreTransition);
90 for (
unsigned int i = 0;
i < vdets.size(); ++
i) {
100 vdetx.push_back(vdets[
i]);
105 edm::LogVerbatim(
"IsoTrack") <<
"matrixECALIds::Final List of cells for dR " << dR <<
" is with " << vdetx.size()
106 <<
" from original list of " << vdets.size();
119 std::vector<DetId>& vdets,
121 bool ignoreTransition) {
130 edm::LogVerbatim(
"IsoTrack") <<
"matrixECALIds::Add " << ietaE <<
"|" << ietaW <<
" rows and " << iphiN <<
"|"
133 std::vector<DetId> dets(1, det);
134 std::vector<CaloDirection>
dirs(1,
NORTH);
135 std::vector<int> jetaE(1, ietaE), jetaW(1, ietaW);
136 std::vector<int> jphiN(1, iphiN), jphiS(1, iphiS);
164 for (
unsigned int i1 = 0; i1 < vdetS.size(); i1++) {
165 if (
std::count(vdets.begin(), vdets.end(), vdetS[i1]) == 0)
166 vdets.push_back(vdetS[i1]);
169 unsigned int ndet = (ietaE + ietaW + 1) * (iphiN + iphiS + 1);
170 if (vdets.size() != ndet) {
171 std::vector<DetId> vdetExtra;
172 spr::extraIds(det, vdets, ietaE, ietaW, iphiN, iphiS, barrelGeom, endcapGeom, vdetExtra, debug);
173 if (!vdetExtra.empty())
174 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
178 edm::LogVerbatim(
"IsoTrack") <<
"matrixECALIds::Total number of cells found is " << vdets.size();
191 bool ignoreTransition) {
192 std::vector<DetId> vdets;
193 spr::matrixECALIds(det, ietaE, ietaW, iphiN, iphiS, geo, caloTopology, vdets, debug, ignoreTransition);
201 std::vector<CaloDirection>&
dir,
207 bool ignoreTransition) {
209 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Add " << iphi <<
" columns of cells for " << (dets.size() -
last)
210 <<
" cells (last " << last <<
")";
213 std::vector<DetId> vdets;
214 std::vector<CaloDirection>
dirs;
215 vdets.insert(vdets.end(), dets.begin(), dets.end());
216 dirs.insert(dirs.end(), dir.begin(), dir.end());
218 std::vector<DetId> vdetE, vdetW;
220 unsigned int ndet = vdets.size();
221 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
223 dets, last, ieta, dirE, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
225 dets, last, ieta, dirW, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
226 for (
unsigned int i1 = 0; i1 < vdetW.size(); i1++) {
227 if (
std::count(vdets.begin(), vdets.end(), vdetW[i1]) == 0) {
228 vdets.push_back(vdetW[i1]);
229 dirs.push_back(dir[0]);
232 for (
unsigned int i1 = 0; i1 < vdetE.size(); i1++) {
233 if (
std::count(vdets.begin(), vdets.end(), vdetE[i1]) == 0) {
234 vdets.push_back(vdetE[i1]);
235 dirs.push_back(dir[0]);
239 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::With Added cells along E/W results a set of "
240 << (vdets.size() - dets.size()) <<
" new cells";
245 unsigned int last0 = vdets.size();
246 std::vector<DetId> vdetnew;
247 std::vector<CaloDirection> dirnew;
249 std::vector<DetId> vdetn(1);
250 std::vector<CaloDirection> dirn(1);
251 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
253 for (
unsigned int i1 = last; i1 < dets.size(); i1++) {
254 std::vector<DetId>
cells;
256 dets[i1], dir[i1], barrelTopo, endcapTopo, barrelGeom, endcapGeom, cells, flag, debug, ignoreTransition);
258 if (
std::count(vdets.begin(), vdets.end(), cells[0]) == 0) {
260 vdetnew.push_back(vdetn[0]);
263 if (dirn[0] ==
NORTH)
268 dirnew.push_back(dirn[0]);
270 vdetn, 0, ieta, dirnE, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
272 vdetn, 0, ieta, dirnW, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
273 for (
unsigned int i2 = 0; i2 < vdetW.size(); i2++) {
274 if (
std::count(vdets.begin(), vdets.end(), vdetW[i2]) == 0 &&
275 std::count(vdetnew.begin(), vdetnew.end(), vdetW[i2]) == 0) {
276 vdets.push_back(vdetW[i2]);
277 dirs.push_back(dirn[0]);
280 for (
unsigned int i2 = 0; i2 < vdetE.size(); i2++) {
281 if (
std::count(vdets.begin(), vdets.end(), vdetE[i2]) == 0 &&
282 std::count(vdetnew.begin(), vdetnew.end(), vdetE[i2]) == 0) {
283 vdets.push_back(vdetE[i2]);
284 dirs.push_back(dirn[0]);
292 for (
unsigned int i2 = 0; i2 < vdetnew.size(); i2++) {
293 if (
std::count(vdets.begin(), vdets.end(), vdetnew[i2]) == 0) {
294 vdets.push_back(vdetnew[i2]);
295 dirs.push_back(dirnew[i2]);
299 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Addition results a set of " << (vdets.size() - last0)
300 <<
" new cells (last " << last0 <<
", iphi " << iphi <<
")";
309 vdets, last, ieta, iphi, dirs, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
312 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Final list consists of " << vdets.size() <<
" cells";
321 std::vector<int>& ietaE,
322 std::vector<int>& ietaW,
323 std::vector<int>& iphiN,
324 std::vector<int>& iphiS,
325 std::vector<CaloDirection>&
dir,
331 bool ignoreTransition) {
333 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Add columns of cells for " << (dets.size() -
last)
334 <<
" cells (last) " << last;
335 for (
unsigned int i1 = last; i1 < dets.size(); i1++) {
337 << iphiN[i1] <<
"|" << iphiS[i1];
340 std::vector<DetId> vdets;
341 std::vector<CaloDirection>
dirs;
342 std::vector<int> jetaE, jetaW, jphiN, jphiS;
343 vdets.insert(vdets.end(), dets.begin(), dets.end());
344 dirs.insert(dirs.end(), dir.begin(), dir.end());
345 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
346 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
347 jphiN.insert(jphiN.end(), iphiN.begin(), iphiN.end());
348 jphiS.insert(jphiS.end(), iphiS.begin(), iphiS.end());
349 std::vector<DetId> vdetE, vdetW;
351 unsigned int ndet = vdets.size();
352 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
354 dets, last, ietaE, ietaW, dirE, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
356 dets, last, ietaE, ietaW, dirW, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
357 for (
unsigned int i1 = 0; i1 < vdetW.size(); i1++) {
358 if (
std::count(vdets.begin(), vdets.end(), vdetW[i1]) == 0) {
359 vdets.push_back(vdetW[i1]);
360 dirs.push_back(dir[0]);
363 jphiN.push_back(iphiN[0]);
364 jphiS.push_back(iphiS[0]);
367 for (
unsigned int i1 = 0; i1 < vdetE.size(); i1++) {
368 if (
std::count(vdets.begin(), vdets.end(), vdetE[i1]) == 0) {
369 vdets.push_back(vdetE[i1]);
370 dirs.push_back(dir[0]);
373 jphiN.push_back(iphiN[0]);
374 jphiS.push_back(iphiS[0]);
378 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::With Added cells along E/W results a set of "
379 << (vdets.size() - dets.size()) <<
" new cells";
384 unsigned int last0 = vdets.size();
385 std::vector<DetId> vdetnew;
386 std::vector<CaloDirection> dirnew;
387 std::vector<int> kphiN, kphiS, ketaE, ketaW;
389 for (
unsigned int i1 = last; i1 < dets.size(); i1++) {
390 int iphi = iphiS[i1];
391 if (dir[i1] ==
NORTH)
394 std::vector<DetId> vdetn(1);
395 std::vector<CaloDirection> dirn(1);
396 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
398 std::vector<DetId>
cells;
400 dets[i1], dir[i1], barrelTopo, endcapTopo, barrelGeom, endcapGeom, cells, flag, debug, ignoreTransition);
404 if (dir[i1] ==
NORTH)
409 if (
std::count(vdets.begin(), vdets.end(), cells[0]) == 0) {
410 int kfiN = iphiN[i1];
411 int kfiS = iphiS[i1];
413 vdetnew.push_back(vdetn[0]);
415 if (dir[i1] ==
NORTH)
423 if (dirn[0] ==
NORTH)
428 dirnew.push_back(dirn[0]);
429 kphiN.push_back(kfiN);
430 ketaE.push_back(ietaE[i1]);
431 kphiS.push_back(kfiS);
432 ketaW.push_back(ietaW[i1]);
433 std::vector<int> ietE(1, ietaE[i1]), ietW(1, ietaW[i1]);
435 vdetn, 0, ietE, ietW, dirnE, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
437 vdetn, 0, ietE, ietW, dirnW, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
438 for (
unsigned int i2 = 0; i2 < vdetW.size(); i2++) {
439 if (
std::count(vdets.begin(), vdets.end(), vdetW[i2]) == 0 &&
440 std::count(vdetnew.begin(), vdetnew.end(), vdetW[i2]) == 0) {
441 vdets.push_back(vdetW[i2]);
442 dirs.push_back(dirn[0]);
444 jphiN.push_back(kfiN);
446 jphiS.push_back(kfiS);
449 for (
unsigned int i2 = 0; i2 < vdetE.size(); i2++) {
450 if (
std::count(vdets.begin(), vdets.end(), vdetE[i2]) == 0 &&
451 std::count(vdetnew.begin(), vdetnew.end(), vdetE[i2]) == 0) {
452 vdets.push_back(vdetE[i2]);
453 dirs.push_back(dirn[0]);
455 jphiN.push_back(kfiN);
457 jphiS.push_back(kfiS);
465 for (
unsigned int i2 = 0; i2 < vdetnew.size(); i2++) {
466 if (
std::count(vdets.begin(), vdets.end(), vdetnew[i2]) == 0) {
467 vdets.push_back(vdetnew[i2]);
468 dirs.push_back(dirnew[i2]);
469 jetaE.push_back(ketaE[i2]);
470 jetaW.push_back(ketaW[i2]);
471 jphiN.push_back(kphiN[i2]);
472 jphiS.push_back(kphiS[i2]);
476 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Addition results a set of " << (vdets.size() - last0)
477 <<
" new cells (last " << last0 <<
", iphi " << kphi <<
")";
478 for (
unsigned int i1 = last0; i1 < vdets.size(); i1++) {
480 << jphiN[i1] <<
"|" << jphiS[i1] <<
" ieta " << jetaE[i1] <<
"|" << jetaW[i1];
502 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdNS::Final list consists of " << vdets.size() <<
" cells";
512 std::vector<CaloDirection>&
dir,
518 bool ignoreTransition) {
520 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Add " << ieta <<
" rows of cells for " << last <<
":" << dets.size()
521 <<
":" << (dets.size() -
last) <<
" cells" << std::endl;
524 std::vector<DetId> vdets;
526 std::vector<CaloDirection>
dirs;
528 vdets.insert(vdets.end(), dets.begin(), dets.end());
529 dirs.insert(dirs.end(), dir.begin(), dir.end());
532 for (
unsigned int i1 = last; i1 < dets.size(); i1++) {
534 std::vector<DetId>
cells;
536 dets[i1], dir[i1], barrelTopo, endcapTopo, barrelGeom, endcapGeom, cells, flag, debug, ignoreTransition);
538 if (
std::count(vdets.begin(), vdets.end(), cells[0]) == 0) {
546 vdets.push_back(cells[0]);
547 dirs.push_back(dirn);
555 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Addition results a set of " << (vdets.size() - dets.size())
562 vdets, last, ieta, dirs, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
565 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Final list (EW) consists of " << vdets.size() <<
" cells";
574 std::vector<int>& ietaE,
575 std::vector<int>& ietaW,
576 std::vector<CaloDirection>&
dir,
582 bool ignoreTransition) {
584 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Add " << ietaE[0] <<
"|" << ietaW[0] <<
" rows of cells for "
585 << (dets.size() -
last) <<
" cells (last " << last <<
")";
588 std::vector<DetId> vdets;
589 vdets.insert(vdets.end(), dets.begin(), dets.end());
590 std::vector<CaloDirection>
dirs;
591 dirs.insert(dirs.end(), dir.begin(), dir.end());
592 std::vector<int> jetaE, jetaW;
593 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
594 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
596 for (
unsigned int i1 = last; i1 < dets.size(); i1++) {
597 int ieta = ietaW[i1];
602 std::vector<DetId>
cells;
604 dets[i1], dir[i1], barrelTopo, endcapTopo, barrelGeom, endcapGeom, cells, flag, debug, ignoreTransition);
613 if (
std::count(vdets.begin(), vdets.end(), cells[0]) == 0) {
614 vdets.push_back(cells[0]);
616 int ketaE = ietaE[i1];
617 int ketaW = ietaW[i1];
631 dirs.push_back(dirn);
632 jetaE.push_back(ketaE);
633 jetaW.push_back(ketaW);
640 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Addition results a set of " << (vdets.size() - dets.size())
641 <<
" new cells (last " << dets.size() <<
", ieta " << keta <<
")";
647 vdets, last, jetaE, jetaW, dirs, barrelTopo, endcapTopo, barrelGeom, endcapGeom, debug, ignoreTransition);
650 edm::LogVerbatim(
"IsoTrack") <<
"newECALIdEW::Final list (EW) consists of " << vdets.size() <<
" cells";
663 std::vector<DetId>&
cells,
666 bool ignoreTransition) {
671 std::vector<DetId> neighbours = barrelTopo->
getNeighbours(detId, dir);
672 if (!neighbours.empty() && !neighbours[0].null()) {
673 cells.push_back(neighbours[0]);
674 cell = neighbours[0];
677 const int ietaAbs(detId.
ietaAbs());
682 cell = *(ol.begin());
684 if (!neighbours.empty() && !neighbours[0].null())
689 cells.push_back(*iptr);
694 std::vector<DetId> neighbours = endcapTopo->
getNeighbours(detId, dir);
695 if (!neighbours.empty() && !neighbours[0].null()) {
696 cells.push_back(neighbours[0]);
697 cell = neighbours[0];
703 if (iphi != 0 && (!ignoreTransition)) {
707 cell = *(ol.begin());
709 if (!neighbours.empty() && !neighbours[0].null())
714 cells.push_back(*iptr);
719 std::ostringstream st1;
720 for (
unsigned int i1 = 0; i1 < cells.size(); ++i1)
721 st1 <<
" " << std::hex << cells[0]() <<
std::dec;
723 <<
" to get 0x" << std::hex << cell() <<
std::dec <<
" with flag " << ok <<
" # "
724 << cells.size() << st1.str();
729 std::vector<DetId>& dets,
736 std::vector<DetId>&
cells,
741 edm::LogVerbatim(
"IsoTrack") <<
"extraIds::Cell " <<
id <<
" rows " << ietaW <<
"|" << ietaE <<
" columns "
742 << iphiS <<
"|" << iphiN;
743 int etaC =
id.ietaAbs();
744 int phiC =
id.iphi();
745 int zsid =
id.zside();
746 for (
int eta = -ietaW;
eta <= ietaE; ++
eta) {
747 for (
int phi = -iphiS; phi <= iphiN; ++phi) {
748 int iphi = phiC + phi;
753 int ieta = zsid * (etaC +
eta);
758 cells.push_back((
DetId)
id);
767 edm::LogVerbatim(
"IsoTrack") <<
"extraIds::Cell " <<
id <<
" rows " << ietaW <<
"|" << ietaE <<
" columns "
768 << iphiS <<
"|" << iphiN;
771 int zsid =
id.zside();
772 for (
int kx = -ietaW; kx <= ietaE; ++kx) {
773 for (
int ky = -iphiS; ky <= iphiN; ++ky) {
780 cells.push_back((
DetId)
id);
789 edm::LogVerbatim(
"IsoTrack") <<
"extraIds:: finds " << cells.size() <<
" new cells";
Log< level::Info, true > LogVerbatim
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
const OrderedListOfEEDetId * getClosestEndcapCells(EBDetId id) const
double getDistInPlaneTrackDir(const GlobalPoint &caloPoint, const GlobalVector &caloVector, const GlobalPoint &rechitPoint, bool debug=false)
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
void matrixECALIds(const DetId &det, int ieta, int iphi, const CaloGeometry *geo, const CaloTopology *caloTopology, std::vector< DetId > &vdets, bool debug=false, bool igNoreTransition=true)
static bool validDetId(int i, int j)
check if a valid index combination
void debugEcalDets(unsigned int, std::vector< DetId > &)
std::vector< DetId > newECALIdEW(std::vector< DetId > &dets, unsigned int last, int ieta, std::vector< CaloDirection > &dir, const CaloSubdetectorTopology *barrelTopo, const CaloSubdetectorTopology *endcapTopo, const EcalBarrelGeometry *barrelGeom, const EcalEndcapGeometry *endcapGeom, bool debug=false, bool igNoreTransition=true)
std::ostringstream debugEcalDet(unsigned int, const DetId &)
std::vector< DetId > newECALIdNS(std::vector< DetId > &dets, unsigned int last, int ieta, int iphi, std::vector< CaloDirection > &dir, const CaloSubdetectorTopology *barrelTopo, const CaloSubdetectorTopology *endcapTopo, const EcalBarrelGeometry *barrelGeom, const EcalEndcapGeometry *endcapGeom, bool debug=false, bool igNoreTransition=true)
void extraIds(const DetId &det, std::vector< DetId > &dets, int ietaE, int ietaW, int iphiN, int iphiS, const EcalBarrelGeometry *barrelGeom, const EcalEndcapGeometry *endcapGeom, std::vector< DetId > &cells, bool debug=false)
bool present(const DetId &id) const override
is this detid present in the geometry?
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
int iPhiOuterRing() const
const OrderedListOfEBDetId * getClosestBarrelCells(EEDetId id) const
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
static const int MAX_IETA
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
bool present(const DetId &id) const override
is this detid present in the geometry?
MgrType::const_iterator const_iterator
CaloDirection
Codes the local directions in the cell lattice.
void simpleMove(DetId &det, const CaloDirection &dir, const CaloSubdetectorTopology *barrelTopo, const CaloSubdetectorTopology *endcapTopo, const EcalBarrelGeometry *barrelGeom, const EcalEndcapGeometry *endcapGeom, std::vector< DetId > &cells, int &flag, bool debug=false, bool igNoreTransition=true)
int ietaAbs() const
get the absolute value of the crystal ieta