1 #include <mdet/SiPMArray.h>
4 #include <mdet/MHierarchyInfo.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/RandomEngine.h>
9 #include <fwk/RandomEngineRegistry.h>
11 #include <CLHEP/Random/RandFlat.h>
18 #include <boost/algorithm/minmax_element.hpp>
19 #include <boost/lambda/lambda.hpp>
42 bool operator()(
const mdet::SiPM*
const o)
const {
58 return o->
GetId() == fSiPM.GetId() &&
76 SiPMArray::SiPMGroup::SizeType
80 SiPMGroup::SizeType tot =
fSiPMs.GetNumberOfComponents();
84 SiPMGroup::SizeType root =
static_cast<SiPMGroup::SizeType
>(
std::sqrt(
double(tot)));
85 if (tot != root*root) {
86 std::ostringstream ss;
87 ss <<
"The total number of SiPMs is not a perfect square number in ";
95 SiPMArray::SiPMGroup::SizeType
99 SiPMGroup::SizeType tot =
fSiPMs.GetNumberOfComponents();
116 fSiPMs.Update(GetIdsMap());
123 if (
fSiPMs.GetNumberOfComponents()) {
142 for (++i; i != e; ++i)
147 if (
fSiPMs.GetNumberOfComponents() > 1) {
150 std::vector<int> check;
152 check.reserve(
fSiPMs.GetNumberOfComponents());
155 const int id = i->GetId();
167 bool sorted = std::adjacent_find(check.begin(), check.end(),
168 boost::lambda::_1 > boost::lambda::_2) == check.end();
170 std::sort(check.begin(), check.end());
172 std::adjacent_difference(check.begin(), check.end(), check.begin());
175 typedef std::vector<int>::const_iterator It;
176 std::pair< It, It >
mm = boost::minmax_element(check.begin() + 1, check.end());
177 if (*mm.first != 1 || *mm.second != 1) {
178 std::ostringstream ss;
179 ss <<
"There is no consecutiveness in the SiPMs of SiPMArray ";
198 if (invalidateComponents)
SiPMConstIterator SiPMsBegin() const
Begin iterator over the contained sipms.
void InitSiPMs()
Initilization and validations related to sipms.
SiPMGroup::SizeType GetRows() const
Retrieves the number of rows.
static const char *const kComponentsNames[13]
det::DetectorComponent< C, MManagerProvider > Type
Type specializing det::DetectorComponent for Muon hierarchy.
void Update(std::vector< double > &init, const std::vector< double > &res)
SiPMConstIterator SiPMsEnd() const
End iterator over the contained sipms.
static const char *const kComponentsIds[13]
#define FATAL(message)
Macro for logging fatal messages.
static const char *const kComponentName
const VManager::IndexMap & GetIdsMap() const
The id identifying this component within its detector hierarhy.
const Module & GetModule() const
SiPMGroup::SizeType GetCols() const
Retrieves the number of columns.
SiPMGroup::ConstIterator SiPMConstIterator
SiPMGroup::Iterator SiPMIterator
Non-const private alias.
SiPMArray(int pId, const det::VManager::IndexMap &parentMap, const Module &parent)
std::map< std::string, std::string > IndexMap
static const char *const kComponentId
void Update(bool invalidateData, bool invalidateComponents)
Perform update in this component and forward to subcomponents.
int fFirstIdSiPMArray
Minimum id among SiPM Array ids.
int GetId() const
The id of this component.
#define ERROR(message)
Macro for logging error messages.