18 std::vector<DetId>& vdets,
bool debug,
19 bool ignoreTransition) {
28 std::cout <<
"matrixECALIds::Add " << ieta <<
" rows and " << iphi
29 <<
" columns of cells for 1 cell" << std::endl;
33 std::vector<DetId> dets(1,det);
36 *barrelGeom, *endcapGeom, debug, ignoreTransition);
39 *barrelTopo, *endcapTopo,
40 *barrelGeom, *endcapGeom,
41 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 *barrelGeom, *endcapGeom, vdetExtra, debug);
51 if (vdetExtra.size() > 0)
52 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
57 std::cout <<
"matrixECALIds::Total number of cells found is " 58 << vdets.size() << std::endl;
67 bool debug,
bool ignoreTransition) {
69 std::vector<DetId> vdets;
79 bool debug,
bool ignoreTransition) {
89 int ietaphi = (
int)(dR/2.0)+1;
90 std::vector<DetId> vdets, vdetx;
93 for (
unsigned int i=0;
i<vdets.size(); ++
i) {
103 vdetx.push_back(vdets[
i]);
109 std::cout <<
"matrixECALIds::Final List of cells for dR " << dR
110 <<
" is with " << vdetx.size() <<
" from original list of " 111 << vdets.size() << std::endl;
121 std::vector<DetId>& vdets,
bool debug,
122 bool ignoreTransition) {
131 std::cout <<
"matrixECALIds::Add " << ietaE <<
"|" << ietaW
132 <<
" rows and " << iphiN <<
"|" << iphiS
133 <<
" columns of cells for 1 cell" << std::endl;
137 std::vector<DetId> dets(1,det);
138 std::vector<CaloDirection>
dirs(1,
NORTH);
139 std::vector<int> jetaE(1,ietaE), jetaW(1,ietaW);
140 std::vector<int> jphiN(1,iphiN), jphiS(1,iphiS);
142 *barrelTopo, *endcapTopo, *barrelGeom,
143 *endcapGeom, debug, ignoreTransition);
146 jphiS, dirs, *barrelTopo,
147 *endcapTopo, *barrelGeom,
150 for (
unsigned int i1=0; i1<vdetS.size(); i1++) {
151 if (
std::count(vdets.begin(),vdets.end(),vdetS[i1]) == 0)
152 vdets.push_back(vdetS[i1]);
155 unsigned int ndet = (ietaE+ietaW+1)*(iphiN+iphiS+1);
156 if (vdets.size() != ndet) {
157 std::vector<DetId> vdetExtra;
159 *barrelGeom, *endcapGeom, vdetExtra, debug);
160 if (vdetExtra.size() > 0)
161 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
166 std::cout <<
"matrixECALIds::Total number of cells found is " 167 << vdets.size() << std::endl;
174 int iphiN,
int iphiS,
177 bool debug,
bool ignoreTransition) {
179 std::vector<DetId> vdets;
181 vdets, debug, ignoreTransition);
187 std::vector<CaloDirection>&
dir,
192 bool debug,
bool ignoreTransition) {
196 std::cout <<
"newECALIdNS::Add " << iphi <<
" columns of cells for " 197 << (dets.size()-
last) <<
" cells (last " << last <<
")" 202 std::vector<DetId> vdets;
203 std::vector<CaloDirection>
dirs;
204 vdets.insert(vdets.end(), dets.begin(), dets.end());
205 dirs.insert(dirs.end(), dir.begin(), dir.end());
207 std::vector<DetId> vdetE, vdetW;
209 unsigned int ndet = vdets.size();
210 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
212 barrelGeom, endcapGeom, debug, ignoreTransition);
214 barrelGeom, endcapGeom, debug, ignoreTransition);
215 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
216 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
217 vdets.push_back(vdetW[i1]);
218 dirs.push_back(dir[0]);
221 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
222 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
223 vdets.push_back(vdetE[i1]);
224 dirs.push_back(dir[0]);
229 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of " 230 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
236 unsigned int last0 = vdets.size();
237 std::vector<DetId> vdetnew;
238 std::vector<CaloDirection> dirnew;
240 std::vector<DetId> vdetn(1);
241 std::vector<CaloDirection> dirn(1);
242 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
244 for (
unsigned int i1=last; i1<dets.size(); i1++) {
245 std::vector<DetId> cells;
247 barrelGeom, endcapGeom, cells, flag,
248 debug, ignoreTransition);
250 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
252 vdetnew.push_back(vdetn[0]);
256 else dirn[0] =
NORTH;
258 dirnew.push_back(dirn[0]);
260 endcapTopo, barrelGeom, endcapGeom,
261 debug, ignoreTransition);
263 endcapTopo, barrelGeom, endcapGeom,
264 debug, ignoreTransition);
265 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
266 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
267 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
268 vdets.push_back(vdetW[i2]);
269 dirs.push_back(dirn[0]);
272 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
273 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
274 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
275 vdets.push_back(vdetE[i2]);
276 dirs.push_back(dirn[0]);
284 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
285 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
286 vdets.push_back(vdetnew[i2]);
287 dirs.push_back(dirnew[i2]);
292 std::cout <<
"newECALIdNS::Addition results a set of " 293 << (vdets.size()-last0) <<
" new cells (last " << last0
294 <<
", iphi " << iphi <<
")" << std::endl;
304 endcapTopo, barrelGeom, endcapGeom,
305 debug, ignoreTransition);
309 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
310 <<
" cells" << std::endl;
319 std::vector<int>& ietaE,
320 std::vector<int>& ietaW,
321 std::vector<int>& iphiN,
322 std::vector<int>& iphiS,
323 std::vector<CaloDirection>&
dir,
328 bool debug,
bool ignoreTransition) {
332 std::cout <<
"newECALIdNS::Add columns of cells for " 333 << (dets.size()-
last) <<
" cells (last) " << last << std::endl;
334 for (
unsigned int i1=last; i1<dets.size(); i1++) {
336 std::cout <<
" along " << dir[i1] <<
" # " << iphiN[i1] <<
"|" 337 << iphiS[i1] << std::endl;
341 std::vector<DetId> vdets;
342 std::vector<CaloDirection>
dirs;
343 std::vector<int> jetaE, jetaW, jphiN, jphiS;
344 vdets.insert(vdets.end(), dets.begin(), dets.end());
345 dirs.insert(dirs.end(), dir.begin(), dir.end());
346 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
347 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
348 jphiN.insert(jphiN.end(), iphiN.begin(), iphiN.end());
349 jphiS.insert(jphiS.end(), iphiS.begin(), iphiS.end());
350 std::vector<DetId> vdetE, vdetW;
352 unsigned int ndet = vdets.size();
353 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
355 endcapTopo, barrelGeom, endcapGeom,
356 debug, ignoreTransition);
358 endcapTopo, barrelGeom, endcapGeom,
359 debug, ignoreTransition);
360 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
361 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
362 vdets.push_back(vdetW[i1]);
363 dirs.push_back(dir[0]);
366 jphiN.push_back(iphiN[0]);
367 jphiS.push_back(iphiS[0]);
370 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
371 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
372 vdets.push_back(vdetE[i1]);
373 dirs.push_back(dir[0]);
376 jphiN.push_back(iphiN[0]);
377 jphiS.push_back(iphiS[0]);
382 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of " 383 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
389 unsigned int last0 = vdets.size();
390 std::vector<DetId> vdetnew;
391 std::vector<CaloDirection> dirnew;
392 std::vector<int> kphiN, kphiS, ketaE, ketaW;
394 for (
unsigned int i1=last; i1<dets.size(); i1++) {
395 int iphi = iphiS[i1];
396 if (dir[i1] ==
NORTH) iphi = iphiN[i1];
398 std::vector<DetId> vdetn(1);
399 std::vector<CaloDirection> dirn(1);
400 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
402 std::vector<DetId> cells;
404 barrelGeom, endcapGeom, cells, flag,
405 debug, ignoreTransition);
407 if (iphi > kphi) kphi = iphi;
408 if (dir[i1] ==
NORTH) jphiN[i1] = iphi;
409 else jphiS[i1] = iphi;
411 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
412 int kfiN = iphiN[i1];
413 int kfiS = iphiS[i1];
415 vdetnew.push_back(vdetn[0]);
417 if (dir[i1] ==
NORTH) kfiN = iphi;
420 int ktmp = kfiS; kfiS = kfiN; kfiN = ktmp;
422 else dirn[0] =
NORTH;
424 dirnew.push_back(dirn[0]);
425 kphiN.push_back(kfiN); ketaE.push_back(ietaE[i1]);
426 kphiS.push_back(kfiS); ketaW.push_back(ietaW[i1]);
427 std::vector<int> ietE(1,ietaE[i1]), ietW(1,ietaW[i1]);
429 endcapTopo, barrelGeom, endcapGeom,
430 debug, ignoreTransition);
432 endcapTopo, barrelGeom, endcapGeom,
433 debug, ignoreTransition);
434 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
435 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
436 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
437 vdets.push_back(vdetW[i2]);
438 dirs.push_back(dirn[0]);
439 jetaE.push_back(0); jphiN.push_back(kfiN);
440 jetaW.push_back(0); jphiS.push_back(kfiS);
443 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
444 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
445 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
446 vdets.push_back(vdetE[i2]);
447 dirs.push_back(dirn[0]);
448 jetaE.push_back(0); jphiN.push_back(kfiN);
449 jetaW.push_back(0); jphiS.push_back(kfiS);
457 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
458 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
459 vdets.push_back(vdetnew[i2]);
460 dirs.push_back(dirnew[i2]);
461 jetaE.push_back(ketaE[i2]);
462 jetaW.push_back(ketaW[i2]);
463 jphiN.push_back(kphiN[i2]);
464 jphiS.push_back(kphiS[i2]);
469 std::cout <<
"newECALIdNS::Addition results a set of " 470 << (vdets.size()-last0) <<
" new cells (last " << last0
471 <<
", iphi " << kphi <<
")" << std::endl;
472 for (
unsigned int i1=last0; i1<vdets.size(); i1++) {
474 std::cout <<
" along " << dirs[i1] <<
" iphi " << jphiN[i1] <<
"|" 475 << jphiS[i1] <<
" ieta " << jetaE[i1] <<
"|" << jetaW[i1]
485 barrelTopo, endcapTopo, barrelGeom, endcapGeom,
486 debug, ignoreTransition);
490 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
491 <<
" cells" << std::endl;
500 int ieta, std::vector<CaloDirection>&
dir,
505 bool debug,
bool ignoreTransition) {
509 std::cout <<
"newECALIdEW::Add " << ieta <<
" rows of cells for " 510 << last <<
":" << dets.size() <<
":" << (dets.size()-
last)
511 <<
" cells" << std::endl;
515 std::vector<DetId> vdets; vdets.clear();
516 std::vector<CaloDirection>
dirs; dirs.clear();
517 vdets.insert(vdets.end(), dets.begin(), dets.end());
518 dirs.insert(dirs.end(), dir.begin(), dir.end());
521 for (
unsigned int i1=last; i1<dets.size(); i1++) {
523 std::vector<DetId> cells;
525 barrelGeom, endcapGeom, cells, flag,
526 debug, ignoreTransition);
528 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
534 vdets.push_back(cells[0]);
535 dirs.push_back(dirn);
544 std::cout <<
"newECALIdEW::Addition results a set of " 545 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
552 barrelGeom, endcapGeom, debug, ignoreTransition);
556 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
557 <<
" cells" << std::endl;
566 std::vector<int>& ietaE,
567 std::vector<int>& ietaW,
568 std::vector<CaloDirection>&
dir,
573 bool debug,
bool ignoreTransition) {
577 std::cout <<
"newECALIdEW::Add " << ietaE[0] <<
"|" << ietaW[0]
578 <<
" rows of cells for " << (dets.size()-
last)
579 <<
" cells (last " << last <<
")" << std::endl;
583 std::vector<DetId> vdets;
584 vdets.insert(vdets.end(), dets.begin(), dets.end());
585 std::vector<CaloDirection>
dirs;
586 dirs.insert(dirs.end(), dir.begin(), dir.end());
587 std::vector<int> jetaE, jetaW;
588 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
589 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
591 for (
unsigned int i1=last; i1<dets.size(); i1++) {
592 int ieta = ietaW[i1];
593 if (dir[i1] ==
EAST) ieta = ietaE[i1];
596 std::vector<DetId> cells;
598 barrelGeom, endcapGeom, cells, flag,
599 debug, ignoreTransition);
601 if (ieta > keta) keta = ieta;
602 if (dir[i1] ==
EAST) jetaE[i1] = ieta;
603 else jetaW[i1] = ieta;
605 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
606 vdets.push_back(cells[0]);
608 int ketaE = ietaE[i1];
609 int ketaW = ietaW[i1];
610 if (dirn ==
EAST) ketaE = ieta;
613 int ktmp = ketaW; ketaW = ketaE; ketaE = ktmp;
617 dirs.push_back(dirn);
618 jetaE.push_back(ketaE);
619 jetaW.push_back(ketaW);
627 std::cout <<
"newECALIdEW::Addition results a set of " 628 << (vdets.size()-dets.size()) <<
" new cells (last " 629 << dets.size() <<
", ieta " << keta <<
")" << std::endl;
636 endcapTopo, barrelGeom, endcapGeom,
637 debug, ignoreTransition);
641 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
642 <<
" cells" << std::endl;
655 std::vector<DetId>& cells,
int&
ok,
bool 659 ,
bool ignoreTransition) {
665 std::vector<DetId> neighbours = barrelTopo.
getNeighbours(detId,dir);
666 if (neighbours.size()>0 && !neighbours[0].null()) {
667 cells.push_back(neighbours[0]);
668 cell = neighbours[0];
671 const int ietaAbs ( detId.
ietaAbs() ) ;
677 cell = *(ol.begin() );
679 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
682 cells.push_back(*iptr);
687 std::vector<DetId> neighbours = endcapTopo.
getNeighbours(detId,dir);
688 if (neighbours.size()>0 && !neighbours[0].null()) {
689 cells.push_back(neighbours[0]);
690 cell = neighbours[0];
696 if (iphi != 0 && (!ignoreTransition)) {
701 cell = *(ol.begin() );
703 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
706 cells.push_back(*iptr);
712 std::cout <<
"simpleMove:: Move DetId 0x" << std::hex << det()
713 <<
std::dec <<
" along " << dir <<
" to get 0x" << std::hex
714 << cell() <<
std::dec <<
" with flag " << ok <<
" # " 716 for (
unsigned int i1=0; i1<cells.size(); ++i1)
724 int ietaW,
int iphiN,
int iphiS,
727 std::vector<DetId>& cells,
bool 736 if (
debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
737 <<
"|" << ietaE <<
" columns " << iphiS <<
"|" 738 << iphiN << std::endl;
740 int etaC =
id.ietaAbs();
741 int phiC =
id.iphi();
742 int zsid =
id.zside();
743 for (
int eta = -ietaW;
eta <= ietaE; ++
eta) {
744 for (
int phi = -iphiS; phi <= iphiN; ++phi) {
746 if (iphi < 0) iphi += 360;
747 else if (iphi > 360) iphi -= 360;
748 int ieta = zsid*(etaC+
eta);
753 cells.push_back((
DetId)
id);
762 if (
debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
763 <<
"|" << ietaE <<
" columns " << iphiS <<
"|" 764 << iphiN << std::endl;
768 int zsid =
id.zside();
769 for (
int kx = -ietaW; kx <= ietaE; ++kx) {
770 for (
int ky = -iphiS; ky <= iphiN; ++ky) {
777 cells.push_back((
DetId)
id);
787 std::cout <<
"extraIds:: finds " << cells.size() <<
" new cells"
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 debugEcalDets(unsigned int, const DetId &, bool)
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)
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)
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)
static bool validDetId(int i, int j)
check if a valid index combination
virtual bool present(const DetId &id) const
is this detid present in the geometry?
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 iPhiOuterRing() const
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
const OrderedListOfEBDetId * getClosestBarrelCells(EEDetId id) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
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)
MgrType::const_iterator const_iterator
CaloDirection
Codes the local directions in the cell lattice.
int ietaAbs() const
get the absolute value of the crystal ieta