3 #include <mdet/Pixel.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>
64 return o->
GetId() == fPixel.GetId() &&
79 template<
class PGroup,
class Container>
81 PixelPusher(PGroup&
g, Container&
c) : fGroup(g), fContainer(c) { }
87 fContainer.push_back(&p);
90 Container& fContainer;
116 PMT::PixelGroup::SizeType
120 PixelGroup::SizeType tot =
fPixels.GetNumberOfComponents();
124 PixelGroup::SizeType root =
static_cast<PixelGroup::SizeType
>(
std::sqrt(
double(tot)));
125 if (tot != root*root) {
126 std::ostringstream ss;
127 ss <<
"The total number of pixels is not a perfect square number in ";
136 PMT::PixelGroup::SizeType
140 PixelGroup::SizeType tot =
fPixels.GetNumberOfComponents();
166 if (
fPixels.GetNumberOfComponents()) {
185 for (++i; i != e; ++i)
190 if (
fPixels.GetNumberOfComponents() > 1) {
192 const PixelGroup::SizeType cols =
GetCols();
193 const PixelGroup::SizeType colsLessOne =
GetCols() - 1;
194 const PixelGroup::SizeType rowsLessOne =
GetRows() - 1;
196 std::vector<int> check;
198 check.reserve(
fPixels.GetNumberOfComponents());
201 const int id = i->GetId();
216 const unsigned int quot = idOffset / cols;
217 const unsigned int mod = idOffset % cols;
218 const bool firstCol = !
mod;
219 const bool firstRow = !quot;
220 const bool lastCol = (mod == colsLessOne);
221 const bool lastRow = (quot == rowsLessOne);
224 int count = firstCol + firstRow + lastCol + lastRow;
233 PixelPusher<PixelGroup, NeighborsContainer> pusher(
fPixels, i->fNeighbors);
248 pusher(
id - cols -1);
251 pusher(
id - cols + 1);
259 pusher(
id + cols - 1);
262 pusher(
id + cols + 1);
274 std::adjacent_find(check.begin(), check.end(), boost::lambda::_1 > boost::lambda::_2) == check.end();
276 std::sort(check.begin(), check.end());
278 std::adjacent_difference(check.begin(), check.end(), check.begin());
281 typedef std::vector<int>::const_iterator It;
282 std::pair<It, It>
mm = boost::minmax_element(check.begin() + 1, check.end());
283 if (*mm.first != 1 || *mm.second != 1) {
284 std::ostringstream ss;
285 ss <<
"There is no consecutiveness in the pixels of PMT ";
299 return boost::make_indirect_iterator(p.
fNeighbors.begin());
307 return boost::make_indirect_iterator(p.
fNeighbors.end());
320 template<
class Predicate>
321 NeighborsContainer::const_iterator
336 const double rnd = CLHEP::RandFlat::shoot(& eng.
GetEngine());
342 double rightSide = 0;
400 const unsigned int quot = idOffset /
GetCols();
401 const unsigned int mod = idOffset %
GetCols();
403 const bool firstRow = !quot;
404 const bool lastCol = (mod ==
GetCols() - 1);
405 const bool lastRow = (quot ==
GetCols() - 1);
409 NeighborsContainer::const_iterator i =
IsNeighbor(src, dst, e);
412 NeighborsContainer::difference_type o = i - src.
fNeighbors.begin();
444 }
else if (lastRow) {
451 }
else if (firstRow) {
492 std::ostringstream ss;
493 ss <<
"The neighbors list for the Pixel hasn't got the "
494 "expected size, it has "
503 std::ostringstream ss;
504 ss <<
"The neighbors coefficients list for the Pixel hasn't got the "
505 "same length that the cross-talk one, it has "
507 <<
" and the second has "
533 if (invalidateComponents)
std::vector< double > CrossTalkContainer
Typedef for mdet::Pixel crosstalk container.
NeighborConstIterator NeighborsBegin(const Pixel &p) const
Begin iterator over neighbors of the given pixel.
double GetCrossTalkNormalizationFactor(const mdet::Pixel &pix) const
Helper method to manage the conversion factor for cross-talk.
PixelGroup::ConstIterator PixelConstIterator
Convenience typedef for const iterator over the contained mdet::Pixel instances.
RandomEngineType & GetEngine()
NeighborConstIterator NeighborsEnd(const Pixel &p) const
End iterator over neighbors of the given pixel.
static const char *const kComponentsNames[13]
static const double kCentralPixelSelfTalk
Assumed value for central pixel self-talk.
Defines within it the common (templated) type for muon detector hierarchy components.
double GetCrossTalk(const Pixel &src, const Pixel &dst) const
Returns the cross-talk coefficient for dst seen as a neighbor of src.
void Update(std::vector< double > &init, const std::vector< double > &res)
void InitPixels()
Initilization and validations related to pixels.
static const char *const kComponentsIds[13]
const CrossTalkContainer & GetNeighborsCrossTalkCorner() const
Cross-talk coeffcient for neighbors of corner located pixel.
static const char *const kComponentName
#define FATAL(message)
Macro for logging fatal messages.
const VManager::IndexMap & GetIdsMap() const
The id identifying this component within its detector hierarhy.
PixelGroup::Iterator PixelIterator
Non-const private alias.
const Module & GetModule() const
The module to which this PMT belongs.
const Pixel & ComputePulseDestination(const Pixel &src) const
Computes a destination pixel according to crosstalk effect.
static const unsigned int kNumNeighborsCorner
Number of neighbors for a pixel on the corner of the PMT's cathode. The assumed layout for the neighb...
Wraps the random number engine used to generate distributions.
double GetCrossTalkProportion(const Pixel &src, const Pixel &dst) const
The cross-talk proportion coefficient for dst seen as a neighbor of \ src.
static const unsigned int kNumNeighborsSide
Number of neighbors for a pixel on the side of the PMT's cathode.
PixelGroup::SizeType GetRows() const
Retrieves the number of rows.
Multiple-pixel photo-multiplier tube.
PixelGroup::SizeType GetCols() const
Retrieves the number of columns.
PixelConstIterator PixelsBegin() const
Begin iterator over the contained pixels.
bool IsNeighbor(const Pixel &src, const Pixel &dst) const
Tells whether dst is one of the neighbors of src.
std::map< std::string, std::string > IndexMap
void Update(bool invalidateData, bool invalidateComponents)
Perform update in this component and forward to subcomponents.
int GetId() const
The id of this component.
int fFirstIdPMT
Minimum id among PMT's ids.
double mod(const double d, const double periode)
utl::Validated< double > fCrossTalkNormalizationFactor
Conversion factor to percentual values. Handled within mdet::PMT.
Type
The type of file that we are acutally opening.
const CrossTalkContainer & GetNeighborsCrossTalkSide() const
Cross-talk coeffcient for neighbors of a side (not corner) located pixel.
NeighborsContainer fNeighbors
Neighbors.
#define ERROR(message)
Macro for logging error messages.
PMT(int pId, const det::VManager::IndexMap &parentMap, const Module &parent)
Constructs the tube.
PixelConstIterator PixelsEnd() const
End iterator over the contained pixels.
static const unsigned int kNumNeighborsInside
Number of neighbors for a pixel inside (ie in the middle) the PMT's cathode.
const CrossTalkContainer & GetNeighborsCrossTalkInside() const
Cross-talk coeffcient for neighbors of a pixel located inside the pixel matrix.
boost::indirect_iterator< NeighborsContainer::const_iterator > NeighborConstIterator
Convenience typedef for iteration over neighbors.
static const char *const kComponentId
boost::indirect_iterator< NeighborsContainer::const_iterator > NeighborConstIterator
Convenience typedef for iteration over neighbors.