ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_CalibBsErrorTool Class Reference

#include <SCT_CalibBsErrorTool.h>

Inheritance diagram for SCT_CalibBsErrorTool:
Collaboration diagram for SCT_CalibBsErrorTool:

Public Member Functions

 SCT_CalibBsErrorTool (const std::string &, const std::string &, const IInterface *)
virtual ~SCT_CalibBsErrorTool ()=default
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual bool book ()
virtual bool read (const std::string &fileName)
virtual bool fill (const bool fromData=false)
virtual bool fillFromData ()

Private Types

typedef std::vector< int > VecInt

Private Member Functions

void fillBsErrorsForWafer (const Identifier &waferId, const int type)

Private Attributes

ToolHandle< ISCT_ByteStreamErrorsToolm_bytestreamErrorsTool {this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"}
const SCT_IDm_pSCTHelper {nullptr}
SCT_ID::const_id_iterator m_waferItrBegin
SCT_ID::const_id_iterator m_waferItrEnd
VecIntm_scterr_bec {nullptr}
VecIntm_scterr_layer {nullptr}
VecIntm_scterr_eta {nullptr}
VecIntm_scterr_phi {nullptr}
VecIntm_scterr_side {nullptr}
VecIntm_scterr_type {nullptr}
int m_maxHash {0}

Detailed Description

Definition at line 31 of file SCT_CalibBsErrorTool.h.

Member Typedef Documentation

◆ VecInt

typedef std::vector<int> SCT_CalibBsErrorTool::VecInt
private

Definition at line 57 of file SCT_CalibBsErrorTool.h.

Constructor & Destructor Documentation

◆ SCT_CalibBsErrorTool()

SCT_CalibBsErrorTool::SCT_CalibBsErrorTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 38 of file SCT_CalibBsErrorTool.cxx.

38 :
39 base_class(type, name, parent)
40{
41}

◆ ~SCT_CalibBsErrorTool()

virtual SCT_CalibBsErrorTool::~SCT_CalibBsErrorTool ( )
virtualdefault

Member Function Documentation

◆ book()

bool SCT_CalibBsErrorTool::book ( )
virtual

Definition at line 64 of file SCT_CalibBsErrorTool.cxx.

64 {
65 bool result{true};
66 m_phistoVector.clear();
67 std::string histoName{pathRoot+"GENERAL/"};
68 //histogram for numbers of events
69 m_numberOfEventsHisto = new TH1I{"events", "Events", 1, 0.5, 1.5};
70 if (m_thistSvc->regHist(histoName.c_str(), m_numberOfEventsHisto ).isFailure()) {
71 ATH_MSG_ERROR("Error in booking BSErrors histogram");
72 }
73 //--- BSErrors for each wafer
76 for (; waferItr not_eq waferItrE; ++waferItr) {
77 Identifier waferId{*waferItr};
78 const int bec{m_pSCTHelper->barrel_ec(waferId)};
79 const std::string formattedPosition{formatPosition(waferId, m_pSCTHelper)};
80 std::string histotitle{std::string{"SCT "} + detectorNames[bec2Index(bec)] + std::string{" BSErrors : plane "} + formattedPosition};
81 const std::string name{pathRoot+detectorPaths[bec2Index(m_pSCTHelper->barrel_ec(waferId))] + formattedPosition};
82 TH1F* hitmapHisto_tmp{new TH1F{TString{formattedPosition}, TString{histotitle}, n_BSErrorType, firstBSErrorType-0.5, lastBSErrorType+0.5}};
83 if (m_thistSvc->regHist(name.c_str(), hitmapHisto_tmp).isFailure()) {
84 ATH_MSG_ERROR("Error in booking BSErrors histogram");
85 }
86 m_phistoVector.push_back(hitmapHisto_tmp);
87 }
88 return result;
89}
#define ATH_MSG_ERROR(x)
static const std::string detectorPaths[]
static const int n_BSErrorType
static const std::string pathRoot
static const int lastBSErrorType
static const int firstBSErrorType
static const std::string detectorNames[]
SCT_ID::const_id_iterator m_waferItrBegin
SCT_ID::const_id_iterator m_waferItrEnd
std::vector< Identifier >::const_iterator const_id_iterator
Definition SCT_ID.h:73
std::string formatPosition(const Identifier &waferId, const SCT_ID *helper, const std::string &delimiter, const bool includeSide)
unsigned int bec2Index(const int bec)
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ fill()

bool SCT_CalibBsErrorTool::fill ( const bool fromData = false)
virtual

Definition at line 133 of file SCT_CalibBsErrorTool.cxx.

133 {
134 if (fromData) {
135 return fillFromData();
136 }
137 bool result{true};
138 //--- Number of event
139 m_numberOfEventsHisto->Fill( 1 );
140 //--- Fill BSErrors
141 const int maxEntry{static_cast<int>(m_scterr_type->size())};
142 for (int i{0}; i != maxEntry; ++i ) {
143 int bec{(*m_scterr_bec)[i]};
144 int layer{(*m_scterr_layer)[i]};
145 int phi{(*m_scterr_phi)[i]};
146 int eta{(*m_scterr_eta)[i]};
147 int side{(*m_scterr_side)[i]};
148 int type{(*m_scterr_type)[i]};
149 Identifier waferId{m_pSCTHelper->wafer_id( bec, layer, phi, eta, side )};
150 fillBsErrorsForWafer(waferId, type);
151 }
152 return result;
153}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
void fillBsErrorsForWafer(const Identifier &waferId, const int type)
@ layer
Definition HitInfo.h:79

◆ fillBsErrorsForWafer()

void SCT_CalibBsErrorTool::fillBsErrorsForWafer ( const Identifier & waferId,
const int type )
private

Definition at line 173 of file SCT_CalibBsErrorTool.cxx.

173 {
174 int iWaferHash{static_cast<int>(m_pSCTHelper->wafer_hash(waferId))};
175 const std::string osWafer{formatPosition(waferId, m_pSCTHelper,".")};
176 //--- Protection for wrong waferID
177 if ( iWaferHash < 0 || iWaferHash >= m_maxHash ) {
178 ATH_MSG_WARNING("WaferHash " << iWaferHash << " is out of range : [ bec.layer.eta.phi.side, BSErrorType ] = [ " << osWafer << ", " << type << " ]");
179 } else {
180 ATH_MSG_DEBUG("BSError : [ bec.layer.eta.phi.side, Type ] = [ " << osWafer<< ", " << type << " ]");
181 m_phistoVector[ iWaferHash ]->Fill( type );
182 }
183}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)

◆ fillFromData()

bool SCT_CalibBsErrorTool::fillFromData ( )
virtual

Definition at line 156 of file SCT_CalibBsErrorTool.cxx.

156 {
157 bool result{true};
158 //--- Number of event
159 m_numberOfEventsHisto->Fill( 1 );
160 //--- Loop over BSErrors
161 const EventContext& ctx{Gaudi::Hive::currentContext()};
162 for (int type = 0; type < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++type) {
163 const std::set<IdentifierHash> errorSet{m_bytestreamErrorsTool->getErrorSet(type, ctx)};
164 for(const auto& idHash : errorSet) {
165 Identifier waferId{m_pSCTHelper->wafer_id(idHash)};
166 fillBsErrorsForWafer(waferId, type);
167 }
168 }
169 return result;
170}
ToolHandle< ISCT_ByteStreamErrorsTool > m_bytestreamErrorsTool

◆ finalize()

StatusCode SCT_CalibBsErrorTool::finalize ( )
virtual

Definition at line 57 of file SCT_CalibBsErrorTool.cxx.

57 {
58 ATH_MSG_INFO("Finalize of SCT_CalibBsErrorTool");
59
60 return StatusCode::SUCCESS;
61}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode SCT_CalibBsErrorTool::initialize ( )
virtual

Definition at line 44 of file SCT_CalibBsErrorTool.cxx.

44 {
45 ATH_CHECK( (m_thistSvc = service("THistSvc")).isValid() );
48
49 m_maxHash = m_pSCTHelper->wafer_hash_max();
50 m_waferItrBegin = m_pSCTHelper->wafer_begin();
51 m_waferItrEnd = m_pSCTHelper->wafer_end();
52
53 return StatusCode::SUCCESS;
54}
#define ATH_CHECK
Evaluate an expression and check for errors.
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ read()

bool SCT_CalibBsErrorTool::read ( const std::string & fileName)
virtual

Definition at line 92 of file SCT_CalibBsErrorTool.cxx.

92 {
93 bool result{true};
94 //pointers to the histos are deleted by m_thistSvc methods
95 m_phistoVector.clear();
96 TFile* fileHitmap{TFile::Open(fileName.c_str())};
97 ATH_MSG_INFO("opening Hitmap file : " << fileName.c_str());
98
99 if (fileHitmap==nullptr) {
100 ATH_MSG_ERROR("can not open Hitmap file : " << fileName.c_str());
101 return result;
102 }
103 //histogram for numbers of events
104 m_numberOfEventsHisto = static_cast<TH1I*>(fileHitmap->Get("GENERAL/events"));
105 if (m_numberOfEventsHisto==nullptr) {
106 ATH_MSG_ERROR("Error in reading EventNumber histogram");
107 }
108 //histograms for each wafer
110 for (; waferItr not_eq m_waferItrEnd; ++waferItr) {
111 const Identifier& waferId{*waferItr};
112 const std::string formattedPosition{formatPosition(waferId, m_pSCTHelper)};
113 std::string name{detectorPaths[bec2Index(m_pSCTHelper->barrel_ec(waferId))] + formattedPosition};
114 TH1F* hitmapHisto_tmp{static_cast<TH1F*>(fileHitmap->Get(name.c_str()))};
115 if (hitmapHisto_tmp==nullptr) {
116 ATH_MSG_ERROR("Error in reading BSErrors histogram");
117 } else {
118 m_phistoVector.push_back(hitmapHisto_tmp);
119 }
120 }
121 return result;
122}

Member Data Documentation

◆ m_bytestreamErrorsTool

ToolHandle<ISCT_ByteStreamErrorsTool> SCT_CalibBsErrorTool::m_bytestreamErrorsTool {this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"}
private

Definition at line 51 of file SCT_CalibBsErrorTool.h.

51{this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"};

◆ m_maxHash

int SCT_CalibBsErrorTool::m_maxHash {0}
private

Definition at line 64 of file SCT_CalibBsErrorTool.h.

64{0};

◆ m_pSCTHelper

const SCT_ID* SCT_CalibBsErrorTool::m_pSCTHelper {nullptr}
private

Definition at line 52 of file SCT_CalibBsErrorTool.h.

52{nullptr};

◆ m_scterr_bec

VecInt* SCT_CalibBsErrorTool::m_scterr_bec {nullptr}
private

Definition at line 58 of file SCT_CalibBsErrorTool.h.

58{nullptr};

◆ m_scterr_eta

VecInt* SCT_CalibBsErrorTool::m_scterr_eta {nullptr}
private

Definition at line 60 of file SCT_CalibBsErrorTool.h.

60{nullptr};

◆ m_scterr_layer

VecInt* SCT_CalibBsErrorTool::m_scterr_layer {nullptr}
private

Definition at line 59 of file SCT_CalibBsErrorTool.h.

59{nullptr};

◆ m_scterr_phi

VecInt* SCT_CalibBsErrorTool::m_scterr_phi {nullptr}
private

Definition at line 61 of file SCT_CalibBsErrorTool.h.

61{nullptr};

◆ m_scterr_side

VecInt* SCT_CalibBsErrorTool::m_scterr_side {nullptr}
private

Definition at line 62 of file SCT_CalibBsErrorTool.h.

62{nullptr};

◆ m_scterr_type

VecInt* SCT_CalibBsErrorTool::m_scterr_type {nullptr}
private

Definition at line 63 of file SCT_CalibBsErrorTool.h.

63{nullptr};

◆ m_waferItrBegin

SCT_ID::const_id_iterator SCT_CalibBsErrorTool::m_waferItrBegin
private

Definition at line 55 of file SCT_CalibBsErrorTool.h.

◆ m_waferItrEnd

SCT_ID::const_id_iterator SCT_CalibBsErrorTool::m_waferItrEnd
private

Definition at line 56 of file SCT_CalibBsErrorTool.h.


The documentation for this class was generated from the following files: