21 std::vector<DetId>& vdets,
23 bool ignoreTransition) {
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;
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;
78 bool ignoreTransition) {
87 int ietaphi = (
int)(
dR / 2.0) + 1;
88 std::vector<DetId> vdets, vdetx;
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;
201 std::vector<CaloDirection>&
dir,
207 bool ignoreTransition) {
210 <<
" cells (last " <<
last <<
")";
213 std::vector<DetId> vdets;
214 std::vector<CaloDirection>
dirs;
215 vdets.insert(vdets.end(), dets.begin(), dets.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]);
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]);
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);
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());
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]);
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]);
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++) {
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);
410 int kfiN = iphiN[
i1];
411 int kfiS = iphiS[
i1];
413 vdetnew.push_back(vdetn[0]);
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) {
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());
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);
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;
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++) {
602 std::vector<DetId>
cells;
604 dets[
i1],
dir[
i1], barrelTopo, endcapTopo, barrelGeom, endcapGeom,
cells,
flag,
debug, ignoreTransition);
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) {
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);
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;
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);
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) {
Log< level::Info, true > LogVerbatim
double getDistInPlaneTrackDir(const GlobalPoint &caloPoint, const GlobalVector &caloVector, const GlobalPoint &rechitPoint, bool debug=false)
int ietaAbs() const
get the absolute value of the crystal ieta
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)
const OrderedListOfEEDetId * getClosestEndcapCells(EBDetId id) const
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)
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
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) ...
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
static const int MAX_IETA
bool present(const DetId &id) const override
is this detid present in the geometry?
MgrType::const_iterator const_iterator
const OrderedListOfEBDetId * getClosestBarrelCells(EEDetId id) const
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)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
int iPhiOuterRing() const