ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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. More...
 
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 44 of file SCT_CalibLbTool.cxx.

44  :
45  base_class(type, name, parent)
46 {
47 }

◆ ~SCT_CalibLbTool()

virtual SCT_CalibLbTool::~SCT_CalibLbTool ( )
virtualdefault

Member Function Documentation

◆ book()

bool SCT_CalibLbTool::book ( )
virtual

Definition at line 85 of file SCT_CalibLbTool.cxx.

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

◆ fill()

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

Definition at line 189 of file SCT_CalibLbTool.cxx.

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

◆ fillFromData()

bool SCT_CalibLbTool::fillFromData ( )
virtual

Definition at line 216 of file SCT_CalibLbTool.cxx.

216  {
217  if (!m_evtInfo) {
218  ATH_MSG_ERROR("The evtInfo pointer is nullptr");
219  return false;
220  }
221  m_numberOfEventsHisto->Fill(m_lumiBlock);
222  bool result{true};
223  //--- Retrieve the RDO container
224  using SCTRawDataType = SCT_RDORawData;
226  if (not p_rdoContainer.isValid()) {
227  ATH_MSG_ERROR("Failed to retrieve SCT RDO container");
228  }
229 
230  SCT_RDO_Container::const_iterator itr{p_rdoContainer->begin()};
231  SCT_RDO_Container::const_iterator itrE{p_rdoContainer->end()};
232  for (; itr != itrE; ++itr) {
233  const InDetRawDataCollection<SCTRawDataType>* SCT_Collection{*itr};
234  if (SCT_Collection==nullptr) continue;// select only SCT RDOs
235  Identifier waferId{SCT_Collection->identify()};
236  IdentifierHash waferHash{m_pSCTHelper->wafer_hash(waferId)};
238  TH2F* pThisHisto2D{m_phistoVector2D[static_cast<int>(waferHash)]};
240  DataVector<SCTRawDataType>::const_iterator rdoItr{SCT_Collection->begin()};
241  DataVector<SCTRawDataType>::const_iterator rdoItrE{SCT_Collection->end()};
242  for (; rdoItr != rdoItrE; ++rdoItr ) {
243  int theFirstStrip{m_pSCTHelper->strip((*rdoItr)->identify())};
245  int strip{m_pSCTHelper->strip((*rdoItr)->identify())};
246  const int endStrip{(*rdoItr)->getGroupSize() + strip};
247  for (; strip != endStrip; ++strip) {
248  pThisHisto2D->Fill( strip, m_lumiBlock );
249  }
251  int rdoGroupSize{(*rdoItr)->getGroupSize()};
252  fillLbForWafer(waferHash, theFirstStrip, rdoGroupSize);
253  }
254  }
255 
256  return result;
257 }

◆ fillLbForWafer()

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

Definition at line 260 of file SCT_CalibLbTool.cxx.

260  {
261  int stripNumber{m_swapPhiReadoutDirection[waferHash] ? lastStrip - theFirstStrip : theFirstStrip};
262  int index{static_cast<int>(waferHash)*n_chipsPerSide + stripNumber/n_stripsPerChip};
263  //--- Fill LB histograms
264  for (int j{0}; j != groupSize; ++j) {
265  m_phistoVector[index]->Fill(m_lumiBlock);
266  }
267 
268 }

◆ initialize()

StatusCode SCT_CalibLbTool::initialize ( )
virtual

Definition at line 50 of file SCT_CalibLbTool.cxx.

50  {
51 
52  ATH_MSG_INFO("Initializing");
53  ATH_CHECK(service("THistSvc", m_thistSvc));
54 
55  ATH_CHECK(detStore()->retrieve(m_pSCTHelper, "SCT_ID"));
57 
58  const InDetDD::SCT_DetectorManager* manager{nullptr};
59  ATH_CHECK(detStore()->retrieve(manager, "SCT"));
60  const InDetDD::SiDetectorElementCollection* sctDetElementColl{manager->getDetectorElementCollection()};
61  for (const InDetDD::SiDetectorElement* element: *sctDetElementColl) {
62  if (element->swapPhiReadoutDirection()) {
63  m_swapPhiReadoutDirection[element->identifyHash()] = true;
64  }
65  }
66 
67  std::pair<std::string, bool> msgCode{retrievedTool(m_evtInfo)};
68  if (not msgCode.second) {
69  ATH_MSG_ERROR(msgCode.first);
70  return StatusCode::FAILURE;
71  }
72  //
75 
76  m_LbRange = numberOfLb();
77 
78  // Read Handle Key
79  ATH_CHECK(m_rdoContainerKey.initialize());
80 
81  return StatusCode::SUCCESS;
82 }

◆ read()

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

Definition at line 138 of file SCT_CalibLbTool.cxx.

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

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.

◆ m_LbRange

int SCT_CalibLbTool::m_LbRange {0}
private

Definition at line 68 of file SCT_CalibLbTool.h.

◆ m_LbsToMerge

int SCT_CalibLbTool::m_LbsToMerge {0}
private

Definition at line 69 of file SCT_CalibLbTool.h.

◆ m_pSCTHelper

const SCT_ID* SCT_CalibLbTool::m_pSCTHelper {nullptr}
private

Definition at line 59 of file SCT_CalibLbTool.h.

◆ 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.

◆ m_sct_firstStrip

VecInt* SCT_CalibLbTool::m_sct_firstStrip {nullptr}
private

Definition at line 64 of file SCT_CalibLbTool.h.

◆ m_sct_rdoGroupSize

VecInt* SCT_CalibLbTool::m_sct_rdoGroupSize {nullptr}
private

Definition at line 65 of file SCT_CalibLbTool.h.

◆ m_sct_waferHash

VecInt* SCT_CalibLbTool::m_sct_waferHash {nullptr}
private

Definition at line 63 of file SCT_CalibLbTool.h.

◆ m_swapPhiReadoutDirection

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

Swap phi readout direction.

Definition at line 72 of file SCT_CalibLbTool.h.

◆ 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:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_CalibAlgs::bec2Index
unsigned int bec2Index(const int bec)
Definition: SCT_CalibUtilities.cxx:60
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
get_generator_info.result
result
Definition: get_generator_info.py:21
SiliconTech::strip
@ strip
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
SCT_CalibLbTool::m_pSCTHelper
const SCT_ID * m_pSCTHelper
Definition: SCT_CalibLbTool.h:59
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:272
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
SCT_CalibLbTool::m_LbsToMerge
int m_LbsToMerge
Definition: SCT_CalibLbTool.h:69
InDetRawDataCollection::identify
virtual Identifier identify() const override final
SCT_ID::wafer_begin
const_id_iterator wafer_begin(void) const
Iterators over full set of ids. Wafer iterator is sorted.
Definition: SCT_ID.cxx:648
SCT_ID::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition: SCT_ID.h:73
SCT_RDORawData
Definition: SCT_RDORawData.h:24
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
SCT_CalibAlgs::lastStrip
@ lastStrip
Definition: SCT_CalibNumbers.h:10
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
SCT_CalibAlgs::formatPosition
std::string formatPosition(const Identifier &waferId, const SCT_ID *helper, const std::string &delimiter, const bool includeSide)
Definition: SCT_CalibUtilities.cxx:36
SCT_CalibLbTool::m_rdoContainerKey
SG::ReadHandleKey< SCT_RDO_Container > m_rdoContainerKey
Definition: SCT_CalibLbTool.h:74
SCT_CalibLbTool::m_sct_waferHash
VecInt * m_sct_waferHash
Definition: SCT_CalibLbTool.h:63
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
SCT_CalibLbTool::fillLbForWafer
void fillLbForWafer(const IdentifierHash &waferHash, const int theFirstStrip, const int groupSize)
Definition: SCT_CalibLbTool.cxx:260
SCT_CalibLbTool::m_LbRange
int m_LbRange
Definition: SCT_CalibLbTool.h:68
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
SCT_CalibLbTool::m_waferItrBegin
SCT_ID::const_id_iterator m_waferItrBegin
Definition: SCT_CalibLbTool.h:60
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SCT_CalibLbTool::m_swapPhiReadoutDirection
std::vector< bool > m_swapPhiReadoutDirection
Swap phi readout direction.
Definition: SCT_CalibLbTool.h:72
SCT_CalibLbTool::fillFromData
virtual bool fillFromData()
Definition: SCT_CalibLbTool.cxx:216
DeMoScan.index
string index
Definition: DeMoScan.py:362
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCT_ID::wafer_end
const_id_iterator wafer_end(void) const
Definition: SCT_ID.cxx:652
SCT_CalibAlgs::firstStrip
@ firstStrip
Definition: SCT_CalibNumbers.h:10
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
SCT_CalibLbTool::m_waferItrEnd
SCT_ID::const_id_iterator m_waferItrEnd
Definition: SCT_CalibLbTool.h:61
SCT_CalibLbTool::m_evtInfo
ToolHandle< ISCT_CalibEvtInfo > m_evtInfo
Definition: SCT_CalibLbTool.h:57