16 std::vector<DetId>& vdets,
bool debug,
17 bool ignoreTransition) {
25 std::cout <<
"matrixECALIds::Add " << ieta <<
" rows and " << iphi
26 <<
" columns of cells for 1 cell" << std::endl;
30 std::vector<DetId> dets(1,det);
33 *barrelGeom, *endcapGeom, debug, ignoreTransition);
36 *barrelTopo, *endcapTopo,
37 *barrelGeom, *endcapGeom,
38 debug, ignoreTransition);
39 for (
unsigned int i1=0; i1<vdetS.size(); i1++) {
40 if (
std::count(vdets.begin(),vdets.end(),vdetS[i1]) == 0)
41 vdets.push_back(vdetS[i1]);
43 unsigned int ndet = (2*ieta+1)*(2*iphi+1);
44 if (vdets.size() != ndet) {
45 std::vector<DetId> vdetExtra;
47 *barrelGeom, *endcapGeom, vdetExtra, debug);
48 if (vdetExtra.size() > 0)
49 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
53 std::cout <<
"matrixECALIds::Total number of cells found is " 54 << vdets.size() << std::endl;
62 bool debug,
bool ignoreTransition) {
64 std::vector<DetId> vdets;
74 bool debug,
bool ignoreTransition) {
84 int ietaphi = (
int)(dR/2.0)+1;
85 std::vector<DetId> vdets, vdetx;
88 for (
unsigned int i=0;
i<vdets.size(); ++
i) {
98 vdetx.push_back(vdets[
i]);
103 std::cout <<
"matrixECALIds::Final List of cells for dR " << dR
104 <<
" is with " << vdetx.size() <<
" from original list of " 105 << vdets.size() << std::endl;
114 std::vector<DetId>& vdets,
bool debug,
115 bool ignoreTransition) {
123 std::cout <<
"matrixECALIds::Add " << ietaE <<
"|" << ietaW
124 <<
" rows and " << iphiN <<
"|" << iphiS
125 <<
" columns of cells for 1 cell" << std::endl;
129 std::vector<DetId> dets(1,det);
130 std::vector<CaloDirection>
dirs(1,
NORTH);
131 std::vector<int> jetaE(1,ietaE), jetaW(1,ietaW);
132 std::vector<int> jphiN(1,iphiN), jphiS(1,iphiS);
134 *barrelTopo, *endcapTopo, *barrelGeom,
135 *endcapGeom, debug, ignoreTransition);
138 jphiS, dirs, *barrelTopo,
139 *endcapTopo, *barrelGeom,
142 for (
unsigned int i1=0; i1<vdetS.size(); i1++) {
143 if (
std::count(vdets.begin(),vdets.end(),vdetS[i1]) == 0)
144 vdets.push_back(vdetS[i1]);
147 unsigned int ndet = (ietaE+ietaW+1)*(iphiN+iphiS+1);
148 if (vdets.size() != ndet) {
149 std::vector<DetId> vdetExtra;
151 *barrelGeom, *endcapGeom, vdetExtra, debug);
152 if (vdetExtra.size() > 0)
153 vdets.insert(vdets.end(), vdetExtra.begin(), vdetExtra.end());
157 std::cout <<
"matrixECALIds::Total number of cells found is " 158 << vdets.size() << std::endl;
164 int iphiN,
int iphiS,
167 bool debug,
bool ignoreTransition) {
169 std::vector<DetId> vdets;
171 vdets, debug, ignoreTransition);
177 std::vector<CaloDirection>&
dir,
182 bool debug,
bool ignoreTransition) {
185 std::cout <<
"newECALIdNS::Add " << iphi <<
" columns of cells for " 186 << (dets.size()-
last) <<
" cells (last " << last <<
")" 191 std::vector<DetId> vdets;
192 std::vector<CaloDirection>
dirs;
193 vdets.insert(vdets.end(), dets.begin(), dets.end());
194 dirs.insert(dirs.end(), dir.begin(), dir.end());
196 std::vector<DetId> vdetE, vdetW;
198 unsigned int ndet = vdets.size();
199 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
201 barrelGeom, endcapGeom, debug, ignoreTransition);
203 barrelGeom, endcapGeom, debug, ignoreTransition);
204 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
205 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
206 vdets.push_back(vdetW[i1]);
207 dirs.push_back(dir[0]);
210 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
211 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
212 vdets.push_back(vdetE[i1]);
213 dirs.push_back(dir[0]);
217 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of " 218 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
223 unsigned int last0 = vdets.size();
224 std::vector<DetId> vdetnew;
225 std::vector<CaloDirection> dirnew;
227 std::vector<DetId> vdetn(1);
228 std::vector<CaloDirection> dirn(1);
229 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
231 for (
unsigned int i1=last; i1<dets.size(); i1++) {
232 std::vector<DetId> cells;
234 barrelGeom, endcapGeom, cells, flag,
235 debug, ignoreTransition);
237 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
239 vdetnew.push_back(vdetn[0]);
243 else dirn[0] =
NORTH;
245 dirnew.push_back(dirn[0]);
247 endcapTopo, barrelGeom, endcapGeom,
248 debug, ignoreTransition);
250 endcapTopo, barrelGeom, endcapGeom,
251 debug, ignoreTransition);
252 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
253 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
254 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
255 vdets.push_back(vdetW[i2]);
256 dirs.push_back(dirn[0]);
259 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
260 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
261 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
262 vdets.push_back(vdetE[i2]);
263 dirs.push_back(dirn[0]);
271 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
272 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
273 vdets.push_back(vdetnew[i2]);
274 dirs.push_back(dirnew[i2]);
278 std::cout <<
"newECALIdNS::Addition results a set of " 279 << (vdets.size()-last0) <<
" new cells (last " << last0
280 <<
", iphi " << iphi <<
")" << std::endl;
289 endcapTopo, barrelGeom, endcapGeom,
290 debug, ignoreTransition);
293 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
294 <<
" cells" << std::endl;
302 std::vector<int>& ietaE,
303 std::vector<int>& ietaW,
304 std::vector<int>& iphiN,
305 std::vector<int>& iphiS,
306 std::vector<CaloDirection>&
dir,
311 bool debug,
bool ignoreTransition) {
314 std::cout <<
"newECALIdNS::Add columns of cells for " 315 << (dets.size()-
last) <<
" cells (last) " << last << std::endl;
316 for (
unsigned int i1=last; i1<dets.size(); i1++) {
318 std::cout <<
" along " << dir[i1] <<
" # " << iphiN[i1] <<
"|" 319 << iphiS[i1] << std::endl;
323 std::vector<DetId> vdets;
324 std::vector<CaloDirection>
dirs;
325 std::vector<int> jetaE, jetaW, jphiN, jphiS;
326 vdets.insert(vdets.end(), dets.begin(), dets.end());
327 dirs.insert(dirs.end(), dir.begin(), dir.end());
328 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
329 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
330 jphiN.insert(jphiN.end(), iphiN.begin(), iphiN.end());
331 jphiS.insert(jphiS.end(), iphiS.begin(), iphiS.end());
332 std::vector<DetId> vdetE, vdetW;
334 unsigned int ndet = vdets.size();
335 std::vector<CaloDirection> dirE(ndet,
EAST), dirW(ndet,
WEST);
337 endcapTopo, barrelGeom, endcapGeom,
338 debug, ignoreTransition);
340 endcapTopo, barrelGeom, endcapGeom,
341 debug, ignoreTransition);
342 for (
unsigned int i1=0; i1<vdetW.size(); i1++) {
343 if (
std::count(vdets.begin(),vdets.end(),vdetW[i1]) == 0) {
344 vdets.push_back(vdetW[i1]);
345 dirs.push_back(dir[0]);
348 jphiN.push_back(iphiN[0]);
349 jphiS.push_back(iphiS[0]);
352 for (
unsigned int i1=0; i1<vdetE.size(); i1++) {
353 if (
std::count(vdets.begin(),vdets.end(),vdetE[i1]) == 0) {
354 vdets.push_back(vdetE[i1]);
355 dirs.push_back(dir[0]);
358 jphiN.push_back(iphiN[0]);
359 jphiS.push_back(iphiS[0]);
363 std::cout <<
"newECALIdNS::With Added cells along E/W results a set of " 364 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
369 unsigned int last0 = vdets.size();
370 std::vector<DetId> vdetnew;
371 std::vector<CaloDirection> dirnew;
372 std::vector<int> kphiN, kphiS, ketaE, ketaW;
374 for (
unsigned int i1=last; i1<dets.size(); i1++) {
375 int iphi = iphiS[i1];
376 if (dir[i1] ==
NORTH) iphi = iphiN[i1];
378 std::vector<DetId> vdetn(1);
379 std::vector<CaloDirection> dirn(1);
380 std::vector<CaloDirection> dirnE(1,
EAST), dirnW(1,
WEST);
382 std::vector<DetId> cells;
384 barrelGeom, endcapGeom, cells, flag,
385 debug, ignoreTransition);
387 if (iphi > kphi) kphi = iphi;
388 if (dir[i1] ==
NORTH) jphiN[i1] = iphi;
389 else jphiS[i1] = iphi;
391 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
392 int kfiN = iphiN[i1];
393 int kfiS = iphiS[i1];
395 vdetnew.push_back(vdetn[0]);
397 if (dir[i1] ==
NORTH) kfiN = iphi;
400 int ktmp = kfiS; kfiS = kfiN; kfiN = ktmp;
402 else dirn[0] =
NORTH;
404 dirnew.push_back(dirn[0]);
405 kphiN.push_back(kfiN); ketaE.push_back(ietaE[i1]);
406 kphiS.push_back(kfiS); ketaW.push_back(ietaW[i1]);
407 std::vector<int> ietE(1,ietaE[i1]), ietW(1,ietaW[i1]);
409 endcapTopo, barrelGeom, endcapGeom,
410 debug, ignoreTransition);
412 endcapTopo, barrelGeom, endcapGeom,
413 debug, ignoreTransition);
414 for (
unsigned int i2=0; i2<vdetW.size(); i2++) {
415 if (
std::count(vdets.begin(),vdets.end(),vdetW[i2]) == 0 &&
416 std::count(vdetnew.begin(),vdetnew.end(),vdetW[i2]) == 0) {
417 vdets.push_back(vdetW[i2]);
418 dirs.push_back(dirn[0]);
419 jetaE.push_back(0); jphiN.push_back(kfiN);
420 jetaW.push_back(0); jphiS.push_back(kfiS);
423 for (
unsigned int i2=0; i2<vdetE.size(); i2++) {
424 if (
std::count(vdets.begin(),vdets.end(),vdetE[i2]) == 0 &&
425 std::count(vdetnew.begin(),vdetnew.end(),vdetE[i2]) == 0) {
426 vdets.push_back(vdetE[i2]);
427 dirs.push_back(dirn[0]);
428 jetaE.push_back(0); jphiN.push_back(kfiN);
429 jetaW.push_back(0); jphiS.push_back(kfiS);
437 for (
unsigned int i2=0; i2<vdetnew.size(); i2++) {
438 if (
std::count(vdets.begin(),vdets.end(),vdetnew[i2]) == 0) {
439 vdets.push_back(vdetnew[i2]);
440 dirs.push_back(dirnew[i2]);
441 jetaE.push_back(ketaE[i2]);
442 jetaW.push_back(ketaW[i2]);
443 jphiN.push_back(kphiN[i2]);
444 jphiS.push_back(kphiS[i2]);
448 std::cout <<
"newECALIdNS::Addition results a set of " 449 << (vdets.size()-last0) <<
" new cells (last " << last0
450 <<
", iphi " << kphi <<
")" << std::endl;
451 for (
unsigned int i1=last0; i1<vdets.size(); i1++) {
453 std::cout <<
" along " << dirs[i1] <<
" iphi " << jphiN[i1] <<
"|" 454 << jphiS[i1] <<
" ieta " << jetaE[i1] <<
"|" << jetaW[i1]
463 barrelTopo, endcapTopo, barrelGeom, endcapGeom,
464 debug, ignoreTransition);
467 std::cout <<
"newECALIdNS::Final list consists of " << vdets.size()
468 <<
" cells" << std::endl;
476 int ieta, std::vector<CaloDirection>&
dir,
481 bool debug,
bool ignoreTransition) {
484 std::cout <<
"newECALIdEW::Add " << ieta <<
" rows of cells for " 485 << last <<
":" << dets.size() <<
":" << (dets.size()-
last)
486 <<
" cells" << std::endl;
490 std::vector<DetId> vdets; vdets.clear();
491 std::vector<CaloDirection>
dirs; dirs.clear();
492 vdets.insert(vdets.end(), dets.begin(), dets.end());
493 dirs.insert(dirs.end(), dir.begin(), dir.end());
496 for (
unsigned int i1=last; i1<dets.size(); i1++) {
498 std::vector<DetId> cells;
500 barrelGeom, endcapGeom, cells, flag,
501 debug, ignoreTransition);
503 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
509 vdets.push_back(cells[0]);
510 dirs.push_back(dirn);
518 std::cout <<
"newECALIdEW::Addition results a set of " 519 << (vdets.size()-dets.size()) <<
" new cells" << std::endl;
526 barrelGeom, endcapGeom, debug, ignoreTransition);
529 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
530 <<
" cells" << std::endl;
538 std::vector<int>& ietaE,
539 std::vector<int>& ietaW,
540 std::vector<CaloDirection>&
dir,
545 bool debug,
bool ignoreTransition) {
548 std::cout <<
"newECALIdEW::Add " << ietaE[0] <<
"|" << ietaW[0]
549 <<
" rows of cells for " << (dets.size()-
last)
550 <<
" cells (last " << last <<
")" << std::endl;
554 std::vector<DetId> vdets;
555 vdets.insert(vdets.end(), dets.begin(), dets.end());
556 std::vector<CaloDirection>
dirs;
557 dirs.insert(dirs.end(), dir.begin(), dir.end());
558 std::vector<int> jetaE, jetaW;
559 jetaE.insert(jetaE.end(), ietaE.begin(), ietaE.end());
560 jetaW.insert(jetaW.end(), ietaW.begin(), ietaW.end());
562 for (
unsigned int i1=last; i1<dets.size(); i1++) {
563 int ieta = ietaW[i1];
564 if (dir[i1] ==
EAST) ieta = ietaE[i1];
567 std::vector<DetId> cells;
569 barrelGeom, endcapGeom, cells, flag,
570 debug, ignoreTransition);
572 if (ieta > keta) keta = ieta;
573 if (dir[i1] ==
EAST) jetaE[i1] = ieta;
574 else jetaW[i1] = ieta;
576 if (
std::count(vdets.begin(),vdets.end(),cells[0]) == 0) {
577 vdets.push_back(cells[0]);
579 int ketaE = ietaE[i1];
580 int ketaW = ietaW[i1];
581 if (dirn ==
EAST) ketaE = ieta;
584 int ktmp = ketaW; ketaW = ketaE; ketaE = ktmp;
588 dirs.push_back(dirn);
589 jetaE.push_back(ketaE);
590 jetaW.push_back(ketaW);
597 std::cout <<
"newECALIdEW::Addition results a set of " 598 << (vdets.size()-dets.size()) <<
" new cells (last " 599 << dets.size() <<
", ieta " << keta <<
")" << std::endl;
606 endcapTopo, barrelGeom, endcapGeom,
607 debug, ignoreTransition);
610 std::cout <<
"newECALIdEW::Final list (EW) consists of " <<vdets.size()
611 <<
" cells" << std::endl;
623 std::vector<DetId>& cells,
int&
ok,
624 bool debug,
bool ignoreTransition) {
630 std::vector<DetId> neighbours = barrelTopo.
getNeighbours(detId,dir);
631 if (neighbours.size()>0 && !neighbours[0].null()) {
632 cells.push_back(neighbours[0]);
633 cell = neighbours[0];
636 const int ietaAbs ( detId.
ietaAbs() ) ;
642 cell = *(ol.begin() );
644 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
647 cells.push_back(*iptr);
652 std::vector<DetId> neighbours = endcapTopo.
getNeighbours(detId,dir);
653 if (neighbours.size()>0 && !neighbours[0].null()) {
654 cells.push_back(neighbours[0]);
655 cell = neighbours[0];
661 if (iphi != 0 && (!ignoreTransition)) {
666 cell = *(ol.begin() );
668 if (neighbours.size()>0 && !neighbours[0].null()) ok = 1;
671 cells.push_back(*iptr);
676 std::cout <<
"simpleMove:: Move DetId 0x" << std::hex << det()
677 <<
std::dec <<
" along " << dir <<
" to get 0x" << std::hex
678 << cell() <<
std::dec <<
" with flag " << ok <<
" # " 680 for (
unsigned int i1=0; i1<cells.size(); ++i1)
687 int ietaW,
int iphiN,
int iphiS,
694 if (debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
695 <<
"|" << ietaE <<
" columns " << iphiS <<
"|" 696 << iphiN << std::endl;
697 int etaC =
id.ietaAbs();
698 int phiC =
id.iphi();
699 int zsid =
id.zside();
700 for (
int eta = -ietaW;
eta <= ietaE; ++
eta) {
701 for (
int phi = -iphiS; phi <= iphiN; ++phi) {
703 if (iphi < 0) iphi += 360;
704 else if (iphi > 360) iphi -= 360;
705 int ieta = zsid*(etaC+
eta);
710 cells.push_back((
DetId)
id);
718 if (debug)
std::cout <<
"extraIds::Cell " <<
id <<
" rows " << ietaW
719 <<
"|" << ietaE <<
" columns " << iphiS <<
"|" 720 << iphiN << std::endl;
723 int zsid =
id.zside();
724 for (
int kx = -ietaW; kx <= ietaE; ++kx) {
725 for (
int ky = -iphiS; ky <= iphiN; ++ky) {
732 cells.push_back((
DetId)
id);
741 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