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

#include <SCT_CalibLbTool.h>

Inheritance diagram for SCT_CalibLbTool:
Collaboration diagram for SCT_CalibLbTool:

Public Member Functions

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

Private Types

typedef std::vector< int > VecInt

Private Member Functions

void fillLbForWafer (const IdentifierHash &waferHash, const int theFirstStrip, const int groupSize)

Private Attributes

ToolHandle< ISCT_CalibEvtInfom_evtInfo {this, "SCT_CalibEventInfo", "SCT_CalibEventInfo"}
const SCT_IDm_pSCTHelper {nullptr}
SCT_ID::const_id_iterator m_waferItrBegin
SCT_ID::const_id_iterator m_waferItrEnd
VecIntm_sct_waferHash {nullptr}
VecIntm_sct_firstStrip {nullptr}
VecIntm_sct_rdoGroupSize {nullptr}
int m_LbRange {0}
int m_LbsToMerge {0}
std::vector< bool > m_swapPhiReadoutDirection {}
 Swap phi readout direction.
SG::ReadHandleKey< SCT_RDO_Containerm_rdoContainerKey {this, "RDOContainer", "SCT_RDOs"}

Detailed Description

Definition at line 38 of file SCT_CalibLbTool.h.

Member Typedef Documentation

◆ VecInt

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

Definition at line 62 of file SCT_CalibLbTool.h.

Constructor & Destructor Documentation

◆ SCT_CalibLbTool()

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

Definition at line 42 of file SCT_CalibLbTool.cxx.

42 :
43 base_class(type, name, parent)
44{
45}

◆ ~SCT_CalibLbTool()

virtual SCT_CalibLbTool::~SCT_CalibLbTool ( )
virtualdefault

Member Function Documentation

◆ book()

bool SCT_CalibLbTool::book ( )
virtual

Definition at line 83 of file SCT_CalibLbTool.cxx.

83 {
84 ATH_MSG_INFO("book()");
85 bool result{true};
86 //pointers to the histos are deleted by m_thistSvc methods
87 m_phistoVector.clear();
88 m_phistoVector2D.clear();
89 std::string histoName{pathRoot+"GENERAL/"};
90 m_LbRange = numberOfLb();
91 m_numberOfEventsHisto = new TH1I{"events", "Events", m_LbRange, 0.5, m_LbRange+0.5};
92
93 m_LbsToMerge = LbToMerge();
94 int yAxisBins{static_cast<int>(TMath::Ceil(1.0*m_LbRange/m_LbsToMerge))};
95
96 if (m_thistSvc->regHist( histoName.c_str(), m_numberOfEventsHisto ).isFailure()) {
97 ATH_MSG_ERROR("Error in booking EventNumber histogram");
98 }
99 //histograms for each wafer
102 std::string hitmapPaths[3];
103 for (int i{0}; i<3; ++i) {
104 hitmapPaths[i] = pathRoot+detectorPaths[i];
105 }
107 for (; waferItr !=m_waferItrEnd; ++waferItr) {
108 const Identifier& waferId{*waferItr};
109 const int bec{m_pSCTHelper->barrel_ec(waferId)};
110 const std::string formattedPosition{formatPosition(waferId, m_pSCTHelper)+"_"};
112 std::string histotitle{std::string{"SCT "} + detectorNames[bec2Index(bec)] + std::string{" Hitmap: plane "} + formattedPosition};
113 std::string formattedPosition2D{formattedPosition + "_2D"};
114 std::string name2D{hitmapPaths[bec2Index(m_pSCTHelper->barrel_ec(waferId))] + formattedPosition + "_2D"};
115 TH2F* hitmapHistoLB_tmp2D{new TH2F{TString{formattedPosition2D}, TString{histotitle}, nbins, firstStrip-0.5, lastStrip+0.5, yAxisBins, 0.5, m_LbsToMerge*yAxisBins+0.5}};
116 if (m_thistSvc->regHist(name2D.c_str(), hitmapHistoLB_tmp2D).isFailure()) {
117 ATH_MSG_ERROR("Error in booking 2D Hitmap histogram");
118 } else {
119 m_phistoVector2D.push_back(hitmapHistoLB_tmp2D);
120 }
122 for (int iChip(0); iChip!=n_chipsPerSide; ++iChip) {
123 int chipId{m_pSCTHelper->side(waferId)==0 ? iChip:iChip+n_chipsPerSide};
124 const std::string formattedChipPosition{formattedPosition + std::to_string(chipId)};
125 const std::string hname{pathRoot + detectorPaths[bec2Index(bec)] + "/" + formattedChipPosition};
126 const std::string histTitle{std::string{"SCT"} + detectorNames[bec2Index(bec)] + std::string{" LB: chip "} + formattedChipPosition};
127 TH1F* hist_tmp{new TH1F{TString{formattedChipPosition}, TString{histTitle}, m_LbRange, 0.5, m_LbRange+0.5}};
128 if (m_thistSvc->regHist(hname.c_str(), hist_tmp).isFailure()) ATH_MSG_ERROR("Error in booking LB histogram");
129 m_phistoVector.push_back(hist_tmp);
130 }
131 }
132 return result;
133}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static const std::string detectorPaths[]
static const std::string pathRoot
static const std::string detectorNames[]
static const int n_chipsPerSide
const SCT_ID * m_pSCTHelper
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)
TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ fill()

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

Definition at line 187 of file SCT_CalibLbTool.cxx.

187 {
188 if (fromData) {
189 return fillFromData();
190 }
191 m_numberOfEventsHisto->Fill(m_lumiBlock);
192 bool result{true};
193 int maxEntry{static_cast<int>(m_sct_waferHash->size())};
194 for (int i{0}; i != maxEntry; ++i) {
195 int theFirstStrip{(*m_sct_firstStrip)[i]};
196 //
197 int endStrip{(*m_sct_rdoGroupSize)[i] + theFirstStrip};
198 int index{(*m_sct_waferHash)[i]};
199 TH2F* pThisHisto2D{m_phistoVector2D[index]};
200
201 for (int strip{theFirstStrip}; strip !=endStrip; ++strip) {
202 pThisHisto2D->Fill(strip, m_lumiBlock);
203 }
204 //
205 int rdoGroupSize{(*m_sct_rdoGroupSize)[i]};
206 IdentifierHash waferHash{static_cast<unsigned int>((*m_sct_waferHash)[i])};
207 fillLbForWafer(waferHash, theFirstStrip, rdoGroupSize);
208 }
209
210 return result;
211}
VecInt * m_sct_waferHash
void fillLbForWafer(const IdentifierHash &waferHash, const int theFirstStrip, const int groupSize)
virtual bool fillFromData()
str index
Definition DeMoScan.py:362

◆ fillFromData()

bool SCT_CalibLbTool::fillFromData ( )
virtual

Definition at line 214 of file SCT_CalibLbTool.cxx.

214 {
215 if (!m_evtInfo) {
216 ATH_MSG_ERROR("The evtInfo pointer is nullptr");
217 return false;
218 }
219 m_numberOfEventsHisto->Fill(m_lumiBlock);
220 bool result{true};
221 //--- Retrieve the RDO container
222 using SCTRawDataType = SCT_RDORawData;
223 SG::ReadHandle<SCT_RDO_Container> p_rdoContainer{m_rdoContainerKey};
224 if (not p_rdoContainer.isValid()) {
225 ATH_MSG_ERROR("Failed to retrieve SCT RDO container");
226 }
227
228 SCT_RDO_Container::const_iterator itr{p_rdoContainer->begin()};
229 SCT_RDO_Container::const_iterator itrE{p_rdoContainer->end()};
230 for (; itr != itrE; ++itr) {
231 const InDetRawDataCollection<SCTRawDataType>* SCT_Collection{*itr};
232 if (SCT_Collection==nullptr) continue;// select only SCT RDOs
233 Identifier waferId{SCT_Collection->identify()};
234 IdentifierHash waferHash{m_pSCTHelper->wafer_hash(waferId)};
236 TH2F* pThisHisto2D{m_phistoVector2D[static_cast<int>(waferHash)]};
238 DataVector<SCTRawDataType>::const_iterator rdoItr{SCT_Collection->begin()};
239 DataVector<SCTRawDataType>::const_iterator rdoItrE{SCT_Collection->end()};
240 for (; rdoItr != rdoItrE; ++rdoItr ) {
241 int theFirstStrip{m_pSCTHelper->strip((*rdoItr)->identify())};
243 int strip{m_pSCTHelper->strip((*rdoItr)->identify())};
244 const int endStrip{(*rdoItr)->getGroupSize() + strip};
245 for (; strip != endStrip; ++strip) {
246 pThisHisto2D->Fill( strip, m_lumiBlock );
247 }
249 int rdoGroupSize{(*rdoItr)->getGroupSize()};
250 fillLbForWafer(waferHash, theFirstStrip, rdoGroupSize);
251 }
252 }
253
254 return result;
255}
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual Identifier identify() const override final
SG::ReadHandleKey< SCT_RDO_Container > m_rdoContainerKey
ToolHandle< ISCT_CalibEvtInfo > m_evtInfo
virtual bool isValid() override final
Can the handle be successfully dereferenced?

◆ fillLbForWafer()

void SCT_CalibLbTool::fillLbForWafer ( const IdentifierHash & waferHash,
const int theFirstStrip,
const int groupSize )
private

Definition at line 258 of file SCT_CalibLbTool.cxx.

258 {
259 int stripNumber{m_swapPhiReadoutDirection[waferHash] ? lastStrip - theFirstStrip : theFirstStrip};
260 int index{static_cast<int>(waferHash)*n_chipsPerSide + stripNumber/n_stripsPerChip};
261 //--- Fill LB histograms
262 for (int j{0}; j != groupSize; ++j) {
263 m_phistoVector[index]->Fill(m_lumiBlock);
264 }
265
266}
static const int n_stripsPerChip
std::vector< bool > m_swapPhiReadoutDirection
Swap phi readout direction.

◆ initialize()

StatusCode SCT_CalibLbTool::initialize ( )
virtual

Definition at line 48 of file SCT_CalibLbTool.cxx.

48 {
49
50 ATH_MSG_INFO("Initializing");
51 ATH_CHECK( (m_thistSvc = service("THistSvc")).isValid() );
52
54 m_swapPhiReadoutDirection.resize(m_pSCTHelper->wafer_hash_max(), false);
55
56 const InDetDD::SCT_DetectorManager* manager{nullptr};
57 ATH_CHECK(detStore()->retrieve(manager, "SCT"));
58 const InDetDD::SiDetectorElementCollection* sctDetElementColl{manager->getDetectorElementCollection()};
59 for (const InDetDD::SiDetectorElement* element: *sctDetElementColl) {
60 if (element->swapPhiReadoutDirection()) {
61 m_swapPhiReadoutDirection[element->identifyHash()] = true;
62 }
63 }
64
65 std::pair<std::string, bool> msgCode{retrievedTool(m_evtInfo)};
66 if (not msgCode.second) {
67 ATH_MSG_ERROR(msgCode.first);
68 return StatusCode::FAILURE;
69 }
70 //
71 m_waferItrBegin = m_pSCTHelper->wafer_begin();
72 m_waferItrEnd = m_pSCTHelper->wafer_end();
73
74 m_LbRange = numberOfLb();
75
76 // Read Handle Key
77 ATH_CHECK(m_rdoContainerKey.initialize());
78
79 return StatusCode::SUCCESS;
80}
#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_CalibLbTool::read ( const std::string & fileName)
virtual

Definition at line 136 of file SCT_CalibLbTool.cxx.

136 {
137 ATH_MSG_INFO("read()");
138 bool result{true};
139 m_LbRange = numberOfLb();
140 //pointers to the histos are deleted by m_thistSvc methods
141 m_phistoVector.clear();
142 m_phistoVector2D.clear();
143 TFile* fileLB{TFile::Open(fileName.c_str())};
144 ATH_MSG_INFO("opening LB file : " << fileName.c_str());
145
146 if (fileLB) {
147 m_numberOfEventsHisto = static_cast<TH1I*>(fileLB->Get("GENERAL/events"));
148 } else {
149 ATH_MSG_ERROR("can not open LB file : " << fileName.c_str());
150 return result;
151 }
152
153 if (m_numberOfEventsHisto==nullptr) {
154 ATH_MSG_ERROR("Error in reading EventNumber histogram");
155 }
156 //histograms for each wafer
158 for (; waferItr !=m_waferItrEnd; ++waferItr) {
159 const Identifier& waferId{*waferItr};
160 const int bec{m_pSCTHelper->barrel_ec(waferId)};
161 const std::string formattedPosition{formatPosition(waferId, m_pSCTHelper)+"_"};
163 std::string name2D=detectorPaths[bec2Index(m_pSCTHelper->barrel_ec( waferId ))] + formattedPosition + "_2D";
164 TH2F* hitmapHistoLB_tmp2D = (TH2F*) fileLB->Get(name2D.c_str());
165
166 if (hitmapHistoLB_tmp2D==nullptr) {
167 ATH_MSG_ERROR("Error in reading Hitmap histogram");
168 } else {
169 m_phistoVector2D.push_back(hitmapHistoLB_tmp2D);
170 }
172 for (int iChip{0}; iChip!=n_chipsPerSide; ++iChip) {
173 int chipId{m_pSCTHelper->side(waferId)==0 ? iChip : iChip+n_chipsPerSide};
174 const std::string hname{detectorPaths[bec2Index(bec)] + "/" + formattedPosition + std::to_string(chipId)};
175 TH1F* hist_tmp{static_cast<TH1F*>(fileLB->Get(hname.c_str()))};
176 if (hist_tmp==nullptr) {
177 ATH_MSG_ERROR("Error in reading LB histogram");
178 } else {
179 m_phistoVector.push_back(hist_tmp);
180 }
181 }
182 }
183 return result;
184}

Member Data Documentation

◆ m_evtInfo

ToolHandle<ISCT_CalibEvtInfo> SCT_CalibLbTool::m_evtInfo {this, "SCT_CalibEventInfo", "SCT_CalibEventInfo"}
private

Definition at line 57 of file SCT_CalibLbTool.h.

57{this, "SCT_CalibEventInfo", "SCT_CalibEventInfo"};

◆ m_LbRange

int SCT_CalibLbTool::m_LbRange {0}
private

Definition at line 68 of file SCT_CalibLbTool.h.

68{0};

◆ m_LbsToMerge

int SCT_CalibLbTool::m_LbsToMerge {0}
private

Definition at line 69 of file SCT_CalibLbTool.h.

69{0};

◆ m_pSCTHelper

const SCT_ID* SCT_CalibLbTool::m_pSCTHelper {nullptr}
private

Definition at line 59 of file SCT_CalibLbTool.h.

59{nullptr};

◆ m_rdoContainerKey

SG::ReadHandleKey<SCT_RDO_Container> SCT_CalibLbTool::m_rdoContainerKey {this, "RDOContainer", "SCT_RDOs"}
private

Definition at line 74 of file SCT_CalibLbTool.h.

74{this, "RDOContainer", "SCT_RDOs"};

◆ m_sct_firstStrip

VecInt* SCT_CalibLbTool::m_sct_firstStrip {nullptr}
private

Definition at line 64 of file SCT_CalibLbTool.h.

64{nullptr};

◆ m_sct_rdoGroupSize

VecInt* SCT_CalibLbTool::m_sct_rdoGroupSize {nullptr}
private

Definition at line 65 of file SCT_CalibLbTool.h.

65{nullptr};

◆ m_sct_waferHash

VecInt* SCT_CalibLbTool::m_sct_waferHash {nullptr}
private

Definition at line 63 of file SCT_CalibLbTool.h.

63{nullptr};

◆ m_swapPhiReadoutDirection

std::vector<bool> SCT_CalibLbTool::m_swapPhiReadoutDirection {}
private

Swap phi readout direction.

Definition at line 72 of file SCT_CalibLbTool.h.

72{};

◆ m_waferItrBegin

SCT_ID::const_id_iterator SCT_CalibLbTool::m_waferItrBegin
private

Definition at line 60 of file SCT_CalibLbTool.h.

◆ m_waferItrEnd

SCT_ID::const_id_iterator SCT_CalibLbTool::m_waferItrEnd
private

Definition at line 61 of file SCT_CalibLbTool.h.


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