1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
//FAMOS headers
#include "FastSimulation/CaloGeometryTools/interface/CrystalWindowMap.h"
#include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h"
#include <algorithm>
CrystalWindowMap::CrystalWindowMap(const CaloGeometryHelper* calo, const std::vector<Crystal>& cw)
: myCalorimeter_(calo), originalVector_(cw) {
size_ = cw.size();
if (size_ == 0)
return;
// Loop over the crystals in the grid and stores the index number of the 8 neighbours
myNeighbours_.resize(size_);
for (unsigned ic = 0; ic < size_; ++ic) {
const CaloGeometryHelper::NeiVect& neighbours = myCalorimeter_->getNeighbours(cw[ic].getDetId());
myNeighbours_[ic].reserve(8);
for (unsigned in = 0; in < 8; ++in) {
// Check that the crystal is in the grid
Crystal::crystalEqual myCrystal(neighbours[in]);
std::vector<Crystal>::const_iterator itcheck;
itcheck = find_if(cw.begin(), cw.end(), myCrystal);
// The neighbour might not be in the grid
if (itcheck == cw.end()) {
// std::cout << " Ouh la " << std::endl;
// for(unsigned ic=0;ic<size_;++ic)
// {
// std::cout << cw[ic].getDetId().rawId()<< " " ;
// }
// std::cout << std::endl ;
// std::cout << " We are looking for " << neighbours[in].rawId() << std::endl;
// edm::LogWarning("CrystalWindowMap") << " Inconsistency in the CellWindow " << std::endl;
} else {
myNeighbours_[ic].push_back(itcheck - cw.begin());
// std::cout << " index " << itcheck-cw.begin() << std::endl;
}
}
}
}
bool CrystalWindowMap::getCrystalWindow(unsigned iq, std::vector<unsigned>& cw) const {
if (iq < size_) // iq >= 0, since iq is unsigned
{
cw = myNeighbours_[iq];
return true;
} else
return false;
}
bool CrystalWindowMap::getCrystalWindow(unsigned iq, const std::vector<unsigned>* cw) const {
if (iq < size_) // iq >= 0, since iq is unsigned
{
[[clang::suppress]] cw = &(myNeighbours_[iq]);
return true;
} else
return false;
// std::map<CrystalID,CrystalWindow>::const_iterator itcheck=myMap.find(cell);
}
const std::vector<unsigned>& CrystalWindowMap::getCrystalWindow(unsigned iq, bool& status) const {
return myNeighbours_[iq];
}
|