ATLAS Offline Software
PixelConditionsSummaryTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
11 #ifndef PIXELCONDITIONSSERVICES_PIXELCONDITIONSSUMMARYTOOL_H
12 #define PIXELCONDITIONSSERVICES_PIXELCONDITIONSSUMMARYTOOL_H
13 
14 
15 
19 
20 #include "GaudiKernel/ServiceHandle.h"
21 #include "Gaudi/Property.h"
22 
24 
26 #include "Identifier/Identifier.h"
29 
34 
39 
40 #include <string>
41 #include <mutex>
42 #include <tuple>
43 #include <memory>
44 #include <cstdint>//uint64_t
45 #include <vector>
46 #include <bitset>
47 #include <limits>
48 
50  public:
51  static InterfaceID& interfaceID();
52 
53  PixelConditionsSummaryTool(const std::string& type, const std::string& name, const IInterface* parent);
55  virtual StatusCode initialize() override;
56 
57  virtual bool isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override final;
58  virtual bool isActive(const IdentifierHash& moduleHash, const EventContext& ctx) const override final;
59  virtual bool isActive(const IdentifierHash& moduleHash, const Identifier& elementId, const EventContext& ctx) const override final;
60  virtual double activeFraction(const IdentifierHash& moduleHash, const Identifier & idStart, const Identifier & idEnd, const EventContext& ctx) const override final;
61 
62  virtual bool isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const override final;
63  virtual bool isGood(const IdentifierHash& moduleHash, const EventContext& ctx) const override final;
64  virtual bool isGood(const IdentifierHash& moduleHash, const Identifier& elementId, const EventContext& ctx, const IDCCacheEntry* cacheEntry=nullptr) const override final;
65  virtual double goodFraction(const IdentifierHash & moduleHash, const Identifier & idStart, const Identifier & idEnd, const EventContext& ctx) const override final;
66 
67  virtual std::unique_ptr<InDet::SiDetectorElementStatus>
68  getDetectorElementStatus(const EventContext& ctx,
69  SG::WriteCondHandle<InDet::SiDetectorElementStatus>* whandle) const override;
70 
71  virtual bool hasBSError(const IdentifierHash& moduleHash, const EventContext& ctx, const IDCCacheEntry* cacheEntry=nullptr) const override final;
72  virtual bool hasBSError(const IdentifierHash& moduleHash, Identifier pixid, const EventContext& ctx, const IDCCacheEntry* cacheEntry=nullptr) const override final;
73  virtual uint64_t getBSErrorWord(const IdentifierHash& moduleHash, const EventContext& ctx, const IDCCacheEntry* cacheEntry=nullptr) const override final;
74  virtual uint64_t getBSErrorWord(const IdentifierHash& moduleHash, const int index, const EventContext& ctx, const IDCCacheEntry* cacheEntry=nullptr) const override final;
75 
76  // public version of getCacheEntry
77  virtual IDCCacheEntry* getCacheEntryOut(const EventContext& ctx) const override final;
78 
79  bool checkChipStatus(IdentifierHash moduleHash, Identifier pixid, const EventContext& ctx) const;
80 
81  private:
83 
84  std::vector<std::string> m_isActiveStatus;
85  std::vector<std::string> m_isActiveStates;
86  std::vector<int> m_activeState;
87  std::vector<int> m_activeStatus;
88  unsigned int m_activeStateMask{};
89  unsigned int m_activeStatusMask{};
90 
91  Gaudi::Property<bool> m_useByteStreamFEI4
92  {this, "UseByteStreamFEI4", false, "Switch of the ByteStream error for FEI4"};
93 
94  Gaudi::Property<bool> m_useByteStreamFEI3
95  {this, "UseByteStreamFEI3", false, "Switch of the ByteStream error for FEI3"};
96 
97  Gaudi::Property<bool> m_useByteStreamRD53
98  {this, "UseByteStreamRD53", false, "Switch of the ByteStream error for RD53"};
99 
101  {this, "PixelDCSStateCondData", "PixelDCSStateCondData", "Pixel FSM state key"};
102 
104  {this, "PixelDCSStatusCondData", "PixelDCSStatusCondData", "Pixel FSM status key"};
105 
107  {this, "PixelTDAQCondData", "", "Pixel TDAQ conditions key"}; //Default empty - legacy option
108 
110  {this, "PixelDeadMapCondData", "PixelDeadMapCondData", "Pixel deadmap conditions key"};
111 
113  {this, "PixelReadoutManager", "PixelReadoutManager", "Pixel readout manager" };
114 
116  {this, "PixelByteStreamErrs", "PixelByteStreamErrs", "PixelByteStreamErrs container key"};
117 
119  {this, "PixelDetEleCollKey", "PixelDetectorElementCollection", "Key of SiDetectorElementCollection for Pixel"};
120 
122  {this, "PixelDetElStatusEventDataBaseKey", "", "Optional event data key of an input SiDetectorElementStatus on which the newly created object will be based."};
124  {this, "PixelDetElStatusCondDataBaseKey", "" , "Optional conditions data key of an input SiDetectorElementStatus on which the newly created object will be based."};
125 
126  Gaudi::Property< bool> m_activeOnly
127  {this, "ActiveOnly", false, "Module and chip status will only reflect whether the modules or chips are active not necessarily whether the signals are good."};
128 
130 
132 
133  /*struct IDCCacheEntry {
134  EventContext::ContextEvt_t eventId = EventContext::INVALID_CONTEXT_EVT; // invalid event ID for the start
135  const IDCInDetBSErrContainer_Cache* IDCCache = nullptr;
136 
137  void reset( EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache* cache) {
138  eventId = evtId;
139  IDCCache = cache;
140  }
141 
142  bool needsUpdate( const EventContext& ctx) const {
143  return eventId != ctx.evt() or eventId == EventContext::INVALID_CONTEXT_EVT;
144  }
145 
146  };*/
147  mutable SG::SlotSpecificObj<IDCCacheEntry> m_eventCache ATLAS_THREAD_SAFE; // Guarded by m_cacheMutex
148 
152  [[nodiscard]] const IDCInDetBSErrContainer* getContainer(const EventContext& ctx) const;
153 
159  [[nodiscard]] IDCCacheEntry* getCacheEntry(const EventContext& ctx) const;
160 
164  std::unique_ptr<InDet::SiDetectorElementStatus>
165  createDetectorElementStatus(const EventContext& ctx,
167 
168 };
169 
171  static InterfaceID IID_PixelConditionsSummaryTool("PixelConditionsSummaryTool", 1, 0);
172  return IID_PixelConditionsSummaryTool;
173 }
174 
175 inline bool PixelConditionsSummaryTool::checkChipStatus(IdentifierHash moduleHash, Identifier pixid, const EventContext& ctx) const {
176  std::bitset<16> chipStatus(SG::ReadCondHandle<PixelDeadMapCondData>(m_condDeadMapKey, ctx)->getChipStatus(moduleHash));
177  if (chipStatus.any()) {
178  Identifier moduleID = m_pixelID->wafer_id(pixid);
179  std::bitset<16> circ;
180  circ.set(m_pixelReadout->getFE(pixid,moduleID));
181  if ((chipStatus&circ).any()) { return false; }
182  }
183  return true;
184 }
185 
186 #endif
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
IInDetConditionsTool.h
max
#define max(a, b)
Definition: cfImp.cxx:41
PixelDeadMapCondData.h
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PixelConditionsSummaryTool::checkChipStatus
bool checkChipStatus(IdentifierHash moduleHash, Identifier pixid, const EventContext &ctx) const
Definition: PixelConditionsSummaryTool.h:175
SiDetectorElementStatus.h
PixelConditionsSummaryTool::m_activeStatusMask
unsigned int m_activeStatusMask
mask in which each status is represented by a bit and for status values which are cnsidered active th...
Definition: PixelConditionsSummaryTool.h:89
index
Definition: index.py:1
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
IDetectorElementStatusTool
Definition: IDetectorElementStatusTool.h:17
PixelConditionsSummaryTool::hasBSError
virtual bool hasBSError(const IdentifierHash &moduleHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override final
Definition: PixelConditionsSummaryTool.cxx:156
PixelTDAQData.h
Store pixel TDAQ information to PixelTDAQData.
IDCInDetBSErrContainer
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
Definition: IDCInDetBSErrContainer.h:19
PixelConditionsSummaryTool::getCacheEntry
IDCCacheEntry * getCacheEntry(const EventContext &ctx) const
Return cache for the current event If, for current slot, the cache is outdated it is retrieved from t...
Definition: PixelConditionsSummaryTool.cxx:98
PixelConditionsSummaryTool::m_isActiveStates
std::vector< std::string > m_isActiveStates
Definition: PixelConditionsSummaryTool.h:85
PixelDCSStateData.h
Store pixel DCS module state in PixelDCSStateData.
PixelConditionsSummaryTool::~PixelConditionsSummaryTool
virtual ~PixelConditionsSummaryTool()
PixelConditionsSummaryTool::getCacheEntryOut
virtual IDCCacheEntry * getCacheEntryOut(const EventContext &ctx) const override final
Definition: PixelConditionsSummaryTool.cxx:113
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
PixelConditionsSummaryTool::isGood
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override final
Definition: PixelConditionsSummaryTool.cxx:246
PixelConditionsSummaryTool::getBSErrorWord
virtual uint64_t getBSErrorWord(const IdentifierHash &moduleHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override final
Definition: PixelConditionsSummaryTool.cxx:119
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandleKey< IDCInDetBSErrContainer >
PixelConditionsSummaryTool::m_condDCSStateKey
SG::ReadCondHandleKey< PixelDCSStateData > m_condDCSStateKey
Definition: PixelConditionsSummaryTool.h:101
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
PixelConditionsSummaryTool::m_condDCSStatusKey
SG::ReadCondHandleKey< PixelDCSStatusData > m_condDCSStatusKey
Definition: PixelConditionsSummaryTool.h:104
PixelConditionsSummaryTool::isActive
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override final
Definition: PixelConditionsSummaryTool.cxx:196
SG::SlotSpecificObj< std::mutex >
PixelConditionsSummaryTool::m_pixelDetElStatusEventKey
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatusEventKey
Definition: PixelConditionsSummaryTool.h:122
PixelConditionsSummaryTool::m_BSErrContReadKey
SG::ReadHandleKey< IDCInDetBSErrContainer > m_BSErrContReadKey
Definition: PixelConditionsSummaryTool.h:116
PixelConditionsSummaryTool::m_activeStateMask
unsigned int m_activeStateMask
mask in which each state is represented by a bit and for states which are cnsidered active the corres...
Definition: PixelConditionsSummaryTool.h:88
PixelConditionsSummaryTool::m_useByteStreamFEI4
Gaudi::Property< bool > m_useByteStreamFEI4
Definition: PixelConditionsSummaryTool.h:92
PixelConditionsSummaryTool
Definition: PixelConditionsSummaryTool.h:49
PixelConditionsSummaryTool::initialize
virtual StatusCode initialize() override
Definition: PixelConditionsSummaryTool.cxx:25
PixelConditionsSummaryTool::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< IDCCacheEntry > m_eventCache ATLAS_THREAD_SAFE
Definition: PixelConditionsSummaryTool.h:147
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PixelConditionsSummaryTool::PixelConditionsSummaryTool
PixelConditionsSummaryTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PixelConditionsSummaryTool.cxx:12
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
PixelConditionsSummaryTool::m_pixelID
const PixelID * m_pixelID
Definition: PixelConditionsSummaryTool.h:82
IPixelReadoutManager.h
PixelConditionsSummaryTool::m_activeState
std::vector< int > m_activeState
Definition: PixelConditionsSummaryTool.h:86
ReadCondHandleKey.h
PixelDCSStatusData.h
Store pixel DCS module status in PixelDCSStatusData.
PixelConditionsSummaryTool::m_pixelReadout
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
Definition: PixelConditionsSummaryTool.h:113
PixelConditionsSummaryTool::m_condTDAQKey
SG::ReadCondHandleKey< PixelTDAQData > m_condTDAQKey
Definition: PixelConditionsSummaryTool.h:107
PixelConditionsSummaryTool::activeFraction
virtual double activeFraction(const IdentifierHash &moduleHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override final
Definition: PixelConditionsSummaryTool.cxx:242
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IdentifierHash.h
PixelConditionsSummaryTool::m_pixelDetElStatusCondKey
SG::ReadCondHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatusCondKey
Definition: PixelConditionsSummaryTool.h:124
IDetectorElementStatusTool.h
SiDetectorElementCollection.h
SG::ReadCondHandleKey< PixelDCSStateData >
PixelConditionsSummaryTool::goodFraction
virtual double goodFraction(const IdentifierHash &moduleHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override final
Definition: PixelConditionsSummaryTool.cxx:533
IInDetConditionsTool
Definition: IInDetConditionsTool.h:27
h
PixelConditionsSummaryTool::getContainer
const IDCInDetBSErrContainer * getContainer(const EventContext &ctx) const
Obtains container form the SG, if it is missing it will complain (hard-coded 3 times per job) and ret...
Definition: PixelConditionsSummaryTool.cxx:87
IDCInDetBSErrContainer.h
PixelConditionsSummaryTool::getDetectorElementStatus
virtual std::unique_ptr< InDet::SiDetectorElementStatus > getDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
get the module and chip status of Si detector elements
Definition: PixelConditionsSummaryTool.cxx:335
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PixelConditionsSummaryTool::m_condDeadMapKey
SG::ReadCondHandleKey< PixelDeadMapCondData > m_condDeadMapKey
Definition: PixelConditionsSummaryTool.h:110
PixelConditionsSummaryTool::createDetectorElementStatus
std::unique_ptr< InDet::SiDetectorElementStatus > createDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const
Create a new detector element status element container.
Definition: PixelConditionsSummaryTool.cxx:306
PixelConditionsSummaryTool::m_useByteStreamFEI3
Gaudi::Property< bool > m_useByteStreamFEI3
Definition: PixelConditionsSummaryTool.h:95
SlotSpecificObj.h
Maintain a set of objects, one per slot.
PixelConditionsSummaryTool::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: PixelConditionsSummaryTool.h:119
PixelConditionsSummaryTool::m_useByteStreamRD53
Gaudi::Property< bool > m_useByteStreamRD53
Definition: PixelConditionsSummaryTool.h:98
PixelConditionsSummaryTool::m_missingErrorInfo
const uint64_t m_missingErrorInfo
Definition: PixelConditionsSummaryTool.h:129
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
PixelID
Definition: PixelID.h:67
PixelConditionsSummaryTool::m_activeOnly
Gaudi::Property< bool > m_activeOnly
Definition: PixelConditionsSummaryTool.h:127
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelConditionsSummaryTool::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< std::mutex > m_cacheMutex ATLAS_THREAD_SAFE
Definition: PixelConditionsSummaryTool.h:131
PixelConditionsSummaryTool::interfaceID
static InterfaceID & interfaceID()
Definition: PixelConditionsSummaryTool.h:170
PixelConditionsSummaryTool::m_activeStatus
std::vector< int > m_activeStatus
Definition: PixelConditionsSummaryTool.h:87
ServiceHandle< InDetDD::IPixelReadoutManager >
IInDetConditionsTool::IDCCacheEntry
Definition: IInDetConditionsTool.h:33
PixelConditionsSummaryTool::m_isActiveStatus
std::vector< std::string > m_isActiveStatus
Definition: PixelConditionsSummaryTool.h:84
Identifier
Definition: IdentifierFieldParser.cxx:14