File indexing completed on 2023-03-17 11:00:39
0001
0002 #include "FastSimulation/CaloGeometryTools/interface/CrystalWindowMap.h"
0003 #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
0004
0005 #include <algorithm>
0006
0007 CrystalWindowMap::CrystalWindowMap(const CaloGeometryHelper* calo, const std::vector<Crystal>& cw)
0008 : myCalorimeter_(calo), originalVector_(cw) {
0009 size_ = cw.size();
0010 if (size_ == 0)
0011 return;
0012
0013
0014 myNeighbours_.resize(size_);
0015
0016 for (unsigned ic = 0; ic < size_; ++ic) {
0017 const CaloGeometryHelper::NeiVect& neighbours = myCalorimeter_->getNeighbours(cw[ic].getDetId());
0018 myNeighbours_[ic].reserve(8);
0019 for (unsigned in = 0; in < 8; ++in) {
0020
0021
0022 Crystal::crystalEqual myCrystal(neighbours[in]);
0023 std::vector<Crystal>::const_iterator itcheck;
0024 itcheck = find_if(cw.begin(), cw.end(), myCrystal);
0025
0026 if (itcheck == cw.end()) {
0027
0028
0029
0030
0031
0032
0033
0034
0035 } else {
0036 myNeighbours_[ic].push_back(itcheck - cw.begin());
0037
0038 }
0039 }
0040 }
0041 }
0042
0043 bool CrystalWindowMap::getCrystalWindow(unsigned iq, std::vector<unsigned>& cw) const {
0044 if (iq < size_)
0045 {
0046 cw = myNeighbours_[iq];
0047 return true;
0048 } else
0049 return false;
0050 }
0051
0052 bool CrystalWindowMap::getCrystalWindow(unsigned iq, const std::vector<unsigned>* cw) const {
0053 if (iq < size_)
0054 {
0055 cw = &myNeighbours_[iq];
0056 return true;
0057 } else
0058 return false;
0059
0060 }
0061
0062 const std::vector<unsigned>& CrystalWindowMap::getCrystalWindow(unsigned iq, bool& status) const {
0063 return myNeighbours_[iq];
0064 }