ATLAS Offline Software
Loading...
Searching...
No Matches
SiDetectorElementStatus.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
5#include <stdexcept>
6#include <sstream>
7
8#ifdef DO_VALIDATE_STATUS_ARRAY
9#include "GaudiKernel/ThreadLocalContext.h"
10#include <iostream>
11namespace dbg {
12 void break_point( bool input1, bool input2, const char *label) {
13 const EventContext& ctx = Gaudi::Hive::currentContext();
14 std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
15 }
16 void break_point( double input1, double input2, const char *label) {
17 const EventContext& ctx = Gaudi::Hive::currentContext();
18 std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
19 }
20 void break_point( uint64_t input1, uint64_t input2, const char *label) {
21 const EventContext& ctx = Gaudi::Hive::currentContext();
22 std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
23 }
24}
25#endif
26
27namespace InDet {
29 if ( (!getElementStatus().empty() && !b.getElementStatus().empty() && getElementStatus().size() != b.getElementStatus().size())
30 || (!getElementChipStatus().empty() && !b.getElementChipStatus().empty() && getElementChipStatus().size() != b.getElementChipStatus().size())) {
31 std::stringstream msg;
32 msg << "Status array sizes do not match:"
33 << getElementStatus().size() << " != " << b.getElementStatus().size() << " || "
34 << getElementChipStatus().size() << " != " << b.getElementChipStatus().size();
35 throw std::runtime_error(msg.str());
36 }
37
38 if (!getElementStatus().empty() && !b.getElementStatus().empty()) {
39 for (std::size_t elm_i=0; elm_i < m_elementStatus.size(); ++elm_i) {
40 m_elementStatus[elm_i] = m_elementStatus[elm_i] && b.m_elementStatus[elm_i];
41 }
42 }
43 else if (!b.getElementStatus().empty()) {
44 m_elementStatus = b.m_elementStatus;
45 }
46
47 if (!getElementChipStatus().empty() && !b.getElementChipStatus().empty()) {
48 for (std::size_t elm_i=0; elm_i < m_elementChipStatus.size(); ++elm_i) {
49 m_elementChipStatus[elm_i] &= b.m_elementChipStatus[elm_i];
50 }
51 }
52 else if (!b.getElementChipStatus().empty()) {
53 m_elementChipStatus = b.m_elementChipStatus;
54 }
55 if (&getBadCells() != &b.getBadCells()) {
57 if (!getBadCells().empty() && !b.getBadCells().empty()) {
58 unsigned int element_i=0;
59 for (const std::vector<unsigned short> &bad_module_strips : b.getBadCells()) {
60 std::vector<unsigned short> &dest = (*m_badCells)[element_i];
61 if (dest.empty()) {
62 dest=bad_module_strips;
63 }
64 else {
65 for (unsigned int bad_strip : bad_module_strips) {
66 std::vector<unsigned short>::const_iterator iter = std::lower_bound(dest.begin(),dest.end(),bad_strip);
67 if (iter == dest.end() || *iter != bad_strip) {
68 dest.insert( iter, bad_strip);
69 }
70 }
71 }
72 ++element_i;
73 }
74 }
75 else if (!b.getBadCells().empty()){
76 *m_badCells = b.getBadCells();
77 }
78 }
79 return *this;
80 }
81
82 void SiDetectorElementStatus::notOwningBadCells() { throw std::logic_error("Bad cells not owned by this instance, cannot return non const bad cell pointer."); }
83} // namespace InDetDD
static const Attributes_t empty
const std::vector< bool > & getElementStatus() const
std::vector< std::vector< unsigned short > > * m_badCells
SiDetectorElementStatus & merge(const SiDetectorElementStatus &a)
bitwise AND of module and chip status bits.
const std::vector< ChipFlags_t > & getElementChipStatus() const
SiDetectorElementStatus(const InDetDD::SiDetectorElementCollection &detector_elements)
std::vector< ChipFlags_t > m_elementChipStatus
const std::vector< std::vector< unsigned short > > & getBadCells() const
std::string label(const std::string &format, int i)
Definition label.h:19
Primary Vertex Finder.
tuple input1
MsgStream & msg
Definition testRead.cxx:32