16 std::vector<DetId>& vdets,
bool debug) {
24 std::cout <<
"matrixECALIds::Add " << ieta <<
" rows and " << iphi
25 <<
" columns of cells for 1 cell" << std::endl;
29 std::vector<DetId> dets(1,det);
30 std::vector<CaloDirection> dirs(1,
NORTH);
32 *barrelGeom,*endcapGeom,debug);
35 *barrelTopo,*endcapTopo,
36 *barrelGeom,*endcapGeom,debug);
37 for (
unsigned int i1=0; i1<vdetS.size(); i1++) {
38 if (
std::count(vdets.begin(),vdets.end(),vdetS[i1]) == 0)
39 vdets.push_back(vdetS[i1]);
41 unsigned int ndet = (2*ieta+1)*(2*iphi+1);
42 if (vdets.size() != ndet) {
43 std::vector<DetId> vdetExtra;
45 *barrelGeom, *endcapGeom, vdetExtra, debug);
46 if (vdetExtra.size() > 0)
47 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
51 std::cout <<
"matrixECALIds::Total number of cells found is "
52 << vdets.size() << std::endl;
62 std::vector<DetId> vdets;
81 int ietaphi = (int)(dR/2.0)+1;
82 std::vector<DetId> vdets, vdetx;
84 for (
unsigned int i=0;
i<vdets.size(); ++
i) {
94 vdetx.push_back(vdets[
i]);
99 std::cout <<
"matrixECALIds::Final List of cells for dR " << dR
100 <<
" is with " << vdetx.size() <<
" from original list of "
101 << vdets.size() << std::endl;
109 std::vector<DetId>& vdets,
bool debug) {
117 std::cout <<
"matrixECALIds::Add " << ietaE <<
"|" << ietaW
118 <<
" rows and " << iphiN <<
"|" << iphiS
119 <<
" columns of cells for 1 cell" << std::endl;
123 std::vector<DetId> dets(1,det);
124 std::vector<CaloDirection> dirs(1,
NORTH);
125 std::vector<int> jetaE(1,ietaE), jetaW(1,ietaW);
126 std::vector<int> jphiN(1,iphiN), jphiS(1,iphiS);
128 *barrelTopo, *endcapTopo, *barrelGeom,
132 jphiS, dirs, *barrelTopo,
133 *endcapTopo, *barrelGeom,
135 for (
unsigned int i1=0; i1<vdetS.size(); i1++) {
136 if (
std::count(vdets.begin(),vdets.end(),vdetS[i1]) == 0)
137 vdets.push_back(vdetS[i1]);
140 unsigned int ndet = (ietaE+ietaW+1)*(iphiN+iphiS+1);
141 if (vdets.size() != ndet) {
142 std::vector<DetId> vdetExtra;
144 *barrelGeom, *endcapGeom, vdetExtra, debug);
145 if (vdetExtra.size() > 0)
146 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
150 std::cout <<
"matrixECALIds::Total number of cells found is "
151 << vdets.size() << std::endl;
157 int iphiN,
int iphiS,
162 std::vector<DetId> vdets;
170 std::vector<CaloDirection>&
dir,
178 std::cout <<
"newECALIdNS::Add " << iphi <<
" columns of cells for "
179 << (dets.size()-
last) <<
" cells (last " << last <<
")"
184 std::vector<DetId> vdets;
185 std::vector<CaloDirection> dirs;
186 vdets.insert(vdets.end(), dets.begin(), dets.end());
187 dirs.insert(dirs.end(), dir.begin(), dir.end());
189 std::vector<DetId> vdetE, vdetW;
191 unsigned int ndet = vdets.size();
192 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
194 barrelGeom, endcapGeom, debug);
196 barrelGeom, endcapGeom, debug);
197 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
198 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
199 vdets.push_back(vdetW[i1]);
200 dirs.push_back(dir[0]);
203 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
204 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
205 vdets.push_back(vdetE[i1]);
206 dirs.push_back(dir[0]);
210 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of "
211 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
216 unsigned int last0 = vdets.size();
217 std::vector<DetId> vdetnew;
218 std::vector<CaloDirection> dirnew;
220 std::vector<DetId> vdetn(1);
221 std::vector<CaloDirection> dirn(1);
222 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
224 for (
unsigned int i1=last; i1<dets.size(); i1++) {
225 std::vector<DetId> cells;
227 barrelGeom, endcapGeom, cells, flag, debug);
229 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
231 vdetnew.push_back(vdetn[0]);
235 else dirn[0] =
NORTH;
237 dirnew.push_back(dirn[0]);
239 endcapTopo, barrelGeom, endcapGeom,debug);
241 endcapTopo, barrelGeom, endcapGeom,debug);
242 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
243 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
244 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
245 vdets.push_back(vdetW[i2]);
246 dirs.push_back(dirn[0]);
249 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
250 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
251 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
252 vdets.push_back(vdetE[i2]);
253 dirs.push_back(dirn[0]);
261 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
262 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
263 vdets.push_back(vdetnew[i2]);
264 dirs.push_back(dirnew[i2]);
268 std::cout <<
"newECALIdNS::Addition results a set of "
269 << (vdets.size()-last0) <<
" new cells (last " << last0
270 <<
", iphi " << iphi <<
")" << std::endl;
278 return spr::newECALIdNS(vdets,last,ieta,iphi,dirs,barrelTopo,endcapTopo,barrelGeom,endcapGeom,debug);
281 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
282 <<
" cells" << std::endl;
290 std::vector<int>& ietaE,
291 std::vector<int>& ietaW,
292 std::vector<int>& iphiN,
293 std::vector<int>& iphiS,
294 std::vector<CaloDirection>&
dir,
302 std::cout <<
"newECALIdNS::Add columns of cells for "
303 << (dets.size()-
last) <<
" cells (last) " << last << std::endl;
304 for (
unsigned int i1=last; i1<dets.size(); i1++) {
306 std::cout <<
" along " << dir[i1] <<
" # " << iphiN[i1] <<
"|"
307 << iphiS[i1] << std::endl;
311 std::vector<DetId> vdets;
312 std::vector<CaloDirection> dirs;
313 std::vector<int> jetaE, jetaW, jphiN, jphiS;
314 vdets.insert(vdets.end(), dets.begin(), dets.end());
315 dirs.insert(dirs.end(), dir.begin(), dir.end());
316 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
317 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
318 jphiN.insert(jphiN.end(), iphiN.begin(), iphiN.end());
319 jphiS.insert(jphiS.end(), iphiS.begin(), iphiS.end());
320 std::vector<DetId> vdetE, vdetW;
322 unsigned int ndet = vdets.size();
323 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
325 endcapTopo, barrelGeom, endcapGeom, debug);
327 endcapTopo, barrelGeom, endcapGeom, debug);
328 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
329 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
330 vdets.push_back(vdetW[i1]);
331 dirs.push_back(dir[0]);
334 jphiN.push_back(iphiN[0]);
335 jphiS.push_back(iphiS[0]);
338 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
339 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
340 vdets.push_back(vdetE[i1]);
341 dirs.push_back(dir[0]);
344 jphiN.push_back(iphiN[0]);
345 jphiS.push_back(iphiS[0]);
349 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of "
350 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
355 unsigned int last0 = vdets.size();
356 std::vector<DetId> vdetnew;
357 std::vector<CaloDirection> dirnew;
358 std::vector<int> kphiN, kphiS, ketaE, ketaW;
360 for (
unsigned int i1=last; i1<dets.size(); i1++) {
361 int iphi = iphiS[i1];
362 if (dir[i1] ==
NORTH) iphi = iphiN[i1];
364 std::vector<DetId> vdetn(1);
365 std::vector<CaloDirection> dirn(1);
366 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
368 std::vector<DetId> cells;
370 barrelGeom, endcapGeom, cells, flag, debug);
372 if (iphi > kphi) kphi = iphi;
373 if (dir[i1] ==
NORTH) jphiN[i1] = iphi;
374 else jphiS[i1] = iphi;
376 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
377 int kfiN = iphiN[i1];
378 int kfiS = iphiS[i1];
380 vdetnew.push_back(vdetn[0]);
382 if (dir[i1] ==
NORTH) kfiN = iphi;
385 int ktmp = kfiS; kfiS = kfiN; kfiN = ktmp;
387 else dirn[0] =
NORTH;
389 dirnew.push_back(dirn[0]);
390 kphiN.push_back(kfiN); ketaE.push_back(ietaE[i1]);
391 kphiS.push_back(kfiS); ketaW.push_back(ietaW[i1]);
392 std::vector<int> ietE(1,ietaE[i1]), ietW(1,ietaW[i1]);
394 endcapTopo, barrelGeom, endcapGeom,debug);
396 endcapTopo, barrelGeom, endcapGeom,debug);
397 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
398 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
399 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
400 vdets.push_back(vdetW[i2]);
401 dirs.push_back(dirn[0]);
402 jetaE.push_back(0); jphiN.push_back(kfiN);
403 jetaW.push_back(0); jphiS.push_back(kfiS);
406 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
407 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
408 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
409 vdets.push_back(vdetE[i2]);
410 dirs.push_back(dirn[0]);
411 jetaE.push_back(0); jphiN.push_back(kfiN);
412 jetaW.push_back(0); jphiS.push_back(kfiS);
420 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
421 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
422 vdets.push_back(vdetnew[i2]);
423 dirs.push_back(dirnew[i2]);
424 jetaE.push_back(ketaE[i2]);
425 jetaW.push_back(ketaW[i2]);
426 jphiN.push_back(kphiN[i2]);
427 jphiS.push_back(kphiS[i2]);
431 std::cout <<
"newECALIdNS::Addition results a set of "
432 << (vdets.size()-last0) <<
" new cells (last " << last0
433 <<
", iphi " << kphi <<
")" << std::endl;
434 for (
unsigned int i1=last0; i1<vdets.size(); i1++) {
436 std::cout <<
" along " << dirs[i1] <<
" iphi " << jphiN[i1] <<
"|"
437 << jphiS[i1] <<
" ieta " << jetaE[i1] <<
"|" << jetaW[i1]
446 barrelTopo, endcapTopo, barrelGeom, endcapGeom,
450 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
451 <<
" cells" << std::endl;
459 int ieta, std::vector<CaloDirection>&
dir,
467 std::cout <<
"newECALIdEW::Add " << ieta <<
" rows of cells for "
468 << last <<
":" << dets.size() <<
":" << (dets.size()-
last)
469 <<
" cells" << std::endl;
473 std::vector<DetId> vdets; vdets.clear();
474 std::vector<CaloDirection> dirs; dirs.clear();
475 vdets.insert(vdets.end(), dets.begin(), dets.end());
476 dirs.insert(dirs.end(), dir.begin(), dir.end());
479 for (
unsigned int i1=last; i1<dets.size(); i1++) {
481 std::vector<DetId> cells;
483 barrelGeom, endcapGeom, cells, flag, debug);
485 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
491 vdets.push_back(cells[0]);
492 dirs.push_back(dirn);
500 std::cout <<
"newECALIdEW::Addition results a set of "
501 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
507 return spr::newECALIdEW(vdets,last,ieta,dirs,barrelTopo,endcapTopo,barrelGeom,endcapGeom,debug);
510 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
511 <<
" cells" << std::endl;
519 std::vector<int>& ietaE,
520 std::vector<int>& ietaW,
521 std::vector<CaloDirection>&
dir,
529 std::cout <<
"newECALIdEW::Add " << ietaE[0] <<
"|" << ietaW[0]
530 <<
" rows of cells for " << (dets.size()-
last)
531 <<
" cells (last " << last <<
")" << std::endl;
535 std::vector<DetId> vdets;
536 vdets.insert(vdets.end(), dets.begin(), dets.end());
537 std::vector<CaloDirection> dirs;
538 dirs.insert(dirs.end(), dir.begin(), dir.end());
539 std::vector<int> jetaE, jetaW;
540 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
541 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
543 for (
unsigned int i1=last; i1<dets.size(); i1++) {
544 int ieta = ietaW[i1];
545 if (dir[i1] ==
EAST) ieta = ietaE[i1];
548 std::vector<DetId> cells;
550 barrelGeom, endcapGeom, cells, flag, debug);
552 if (ieta > keta) keta = ieta;
553 if (dir[i1] ==
EAST) jetaE[i1] = ieta;
554 else jetaW[i1] = ieta;
556 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
557 vdets.push_back(cells[0]);
559 int ketaE = ietaE[i1];
560 int ketaW = ietaW[i1];
561 if (dirn ==
EAST) ketaE = ieta;
564 int ktmp = ketaW; ketaW = ketaE; ketaE = ktmp;
568 dirs.push_back(dirn);
569 jetaE.push_back(ketaE);
570 jetaW.push_back(ketaW);
577 std::cout <<
"newECALIdEW::Addition results a set of "
578 << (vdets.size()-dets.size()) <<
" new cells (last "
579 << dets.size() <<
", ieta " << keta <<
")" << std::endl;
586 endcapTopo, barrelGeom, endcapGeom, debug);
589 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
590 <<
" cells" << std::endl;
602 std::vector<DetId>& cells,
int&
ok,
bool debug) {
608 std::vector<DetId> neighbours = barrelTopo.
getNeighbours(detId,dir);
609 if (neighbours.size()>0 && !neighbours[0].null()) {
610 cells.push_back(neighbours[0]);
611 cell = neighbours[0];
614 const int ietaAbs ( detId.
ietaAbs() ) ;
620 cell = *(ol.begin() );
622 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
625 cells.push_back(*iptr);
630 std::vector<DetId> neighbours = endcapTopo.
getNeighbours(detId,dir);
631 if (neighbours.size()>0 && !neighbours[0].null()) {
632 cells.push_back(neighbours[0]);
633 cell = neighbours[0];
643 cell = *(ol.begin() );
645 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
648 cells.push_back(*iptr);
653 std::cout <<
"simpleMove:: Move DetId 0x" << std::hex << det()
654 << std::dec <<
" along " << dir <<
" to get 0x" << std::hex
655 << cell() << std::dec <<
" with flag " << ok <<
" # "
657 for (
unsigned int i1=0; i1<cells.size(); ++i1)
658 std::cout <<
" " << std::hex << cells[0]() << std::dec;
667 if (debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
668 <<
"|" << ietaE <<
" columns " << iphiS <<
"|"
669 << iphiN << std::endl;
670 int etaC =
id.ietaAbs();
671 int phiC =
id.iphi();
672 int zsid =
id.zside();
673 for (
int eta = -ietaW;
eta <= ietaE; ++
eta) {
674 for (
int phi = -iphiS;
phi <= iphiN; ++
phi) {
676 if (iphi < 0) iphi += 360;
677 else if (iphi > 360) iphi -= 360;
678 int ieta = zsid*(etaC+
eta);
683 cells.push_back((
DetId)
id);
691 if (debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
692 <<
"|" << ietaE <<
" columns " << iphiS <<
"|"
693 << iphiN << std::endl;
696 int zsid =
id.zside();
697 for (
int kx = -ietaW; kx <= ietaE; ++kx) {
698 for (
int ky = -iphiS; ky <= iphiN; ++ky) {
705 cells.push_back((
DetId)
id);
714 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
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
void debugEcalDets(unsigned int, const DetId &, bool)
double getDistInPlaneTrackDir(const GlobalPoint &caloPoint, const GlobalVector &caloVector, const GlobalPoint &rechitPoint)
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
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)
virtual bool present(const DetId &id) const
is this detid present in the geometry?
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) ...
void matrixECALIds(const DetId &det, int ieta, int iphi, const CaloGeometry *geo, const CaloTopology *caloTopology, std::vector< DetId > &vdets, bool debug=false)
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
MgrType::const_iterator const_iterator
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)
CaloDirection
Codes the local directions in the cell lattice.
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)
int ietaAbs() const
get the absolute value of the crystal ieta