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

#include <SCT_CalibHvTool.h>

Inheritance diagram for SCT_CalibHvTool:
Collaboration diagram for SCT_CalibHvTool:

Public Member Functions

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

Private Types

enum  {
  n_chipPerSide = 6 , n_chipPerModule = 12 , n_stripPerChip = 128 , n_etaInBarrel = 12 ,
  n_phiBinsB0 = 32 , n_phiBinsB1 = 40 , n_phiBinsB2 = 48 , n_phiBinsB3 = 56 ,
  n_phiBinsECShort = 40 , n_phiBinsECMiddle = 40 , n_phiBinsECOuter = 52 , n_elements =8176 ,
  n_BSErrorType = 15 , firstBSErrorType = 0 , lastBSErrorType = 14
}
typedef std::vector< int > VecInt

Private Member Functions

template<class T>
bool retrievedTool (T &tool, const std::string &toolName) const
 retrieve a tool and report if it failed

Private Attributes

ToolHandle< ISCT_DCSConditionsToolm_DCSConditionsTool {this, "SCT_DCSConditionsTool", "SCT_DCSConditionsTool", "Tool to retrieve SCT DCS information"}
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_numHitsInWafer {nullptr}
int m_maxq {100}
std::vector< std::queue< int > > m_phvtripQueue
std::queue< int > m_prevLBN
VecInt m_phvtripRunningTotalInt
VecInt m_phvtripProcessedEventsInt
VecInt m_phvtripHasItTripped
VecInt m_phvtripHasItTripped_prev
int m_phvtripPrevTime {0}
int m_phvtripFirstTime {0}
double m_absolutetriplimit {0}
double m_relativetriplimit {0}
int m_tq [100] {0}
std::vector< std::vector< std::pair< int, int > > > m_summarytrips
std::vector< std::vector< std::pair< int, int > > > m_summarytripslb
bool m_outputLowHits {false}
int m_lowHitCut {100}

Detailed Description

Definition at line 38 of file SCT_CalibHvTool.h.

Member Typedef Documentation

◆ VecInt

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

Definition at line 68 of file SCT_CalibHvTool.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
n_chipPerSide 
n_chipPerModule 
n_stripPerChip 
n_etaInBarrel 
n_phiBinsB0 
n_phiBinsB1 
n_phiBinsB2 
n_phiBinsB3 
n_phiBinsECShort 
n_phiBinsECMiddle 
n_phiBinsECOuter 
n_elements 
n_BSErrorType 
firstBSErrorType 
lastBSErrorType 

Definition at line 57 of file SCT_CalibHvTool.h.

Constructor & Destructor Documentation

◆ SCT_CalibHvTool()

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

Definition at line 24 of file SCT_CalibHvTool.cxx.

24 :
25 base_class(type, name, parent)
26{
27}

◆ ~SCT_CalibHvTool()

virtual SCT_CalibHvTool::~SCT_CalibHvTool ( )
virtualdefault

Member Function Documentation

◆ book()

bool SCT_CalibHvTool::book ( )
virtual

Definition at line 41 of file SCT_CalibHvTool.cxx.

41 {
42 bool result{true};
43 ATH_MSG_DEBUG("Book HVTrips");
44 //now initialize the queues (fill 100 spots with 0):
45 std::queue<int> qtemp;
46 initQueue(qtemp, m_maxq,0);
47 // need to keep previous bins lbn 4 deep.
48 initQueue(m_prevLBN, 4, 0);
49 std::vector<std::pair <int,int>> dummy;
50 //first set num events processed to 0
54 m_phvtripQueue.insert(m_phvtripQueue.end(), n_elements, qtemp);
55 m_summarytrips.insert(m_summarytrips.end(),n_elements, dummy);
56 m_summarytripslb.insert(m_summarytripslb.end(), n_elements, dummy);
58 return result;
59}
#define ATH_MSG_DEBUG(x)
VecInt m_phvtripProcessedEventsInt
std::vector< std::vector< std::pair< int, int > > > m_summarytripslb
VecInt m_phvtripRunningTotalInt
VecInt m_phvtripHasItTripped_prev
std::queue< int > m_prevLBN
VecInt m_phvtripHasItTripped
std::vector< std::queue< int > > m_phvtripQueue
std::vector< std::vector< std::pair< int, int > > > m_summarytrips

◆ fill()

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

calculate the limit for an individual module, limit is m_relativetriplimit (default = 4) times the running average in that module. limits are given in hits/second. need to convert numhits in bin to average (within bin) hits/sec.

Definition at line 62 of file SCT_CalibHvTool.cxx.

62 {
63 const EventContext& ctx = Gaudi::Hive::currentContext();
64
65 if (fromData) {
66 return fillFromData();
67 }
68 bool result{true};
69 int lumi_block{0}; //fix me!
70 const int wafersize{static_cast<int>(m_sct_waferHash->size())};
71 int time_stamp{static_cast<int>(ctx.eventID().time_stamp())};
72 int curr_time{time_stamp};
73 int dtime{curr_time - m_phvtripPrevTime};
74 int totalHits{0};
75 if (curr_time<m_phvtripPrevTime) {
76 ATH_MSG_ERROR("Events not sorted properly (time is going backwards!) ");
77 return false;
78 }
79 // for first event
80 if (m_phvtripFirstTime > curr_time) {
81 m_phvtripFirstTime = curr_time;
82 }
83 bool newbin{false};
84 // check if we have a new time bin, if we do pop off the back (oldest) part
85 // of the queue and enqueue 0 for every wafer
86 int maxtbins{5};
87 if (dtime > maxtbins) {
88 newbin = true;
89 ATH_MSG_DEBUG(" new t bin " << dtime <<" since start "<< (curr_time-(m_phvtripFirstTime-1.01)));
91 for (int iwaf{0}; iwaf!=n_elements; ++iwaf) {
92 m_phvtripQueue[iwaf].pop();
93 m_phvtripQueue[iwaf].push(0);
95 }
96 }
97 // Loop over all hits in the event
98 bool isgoodnow;
99 for( int itrk{0}; itrk!=wafersize; ++itrk) {
100 int waferhash{(*m_sct_waferHash)[itrk]};
101 Identifier waferId{m_pSCTHelper->wafer_id(waferhash)};
102 Identifier moduleId{m_pSCTHelper->module_id(waferId)};
103 //step one is to make sure this one isn't already know to be messed up:
104 isgoodnow = m_DCSConditionsTool->isGood(moduleId,InDetConditions::SCT_MODULE);
105 ATH_MSG_DEBUG("checked is good "<< isgoodnow);
106 if (isgoodnow) {
107 int numhits{(*m_sct_numHitsInWafer)[itrk]};
108 totalHits += numhits;
113 double limit{m_relativetriplimit * static_cast<double>(m_phvtripRunningTotalInt[waferhash]) / (static_cast<double>(curr_time)-(static_cast<double>(m_phvtripFirstTime-0.01)))};
114
115 ATH_MSG_DEBUG("waferhash "<<waferhash<<" itrk "<<itrk <<" run tot "<< m_phvtripRunningTotalInt[waferhash]
116 <<" num hits "<<numhits<<" evnts processed "<< m_phvtripProcessedEventsInt[waferhash] <<" limit "<<limit
117 <<" abs limit, rel limit "<<m_absolutetriplimit<<","<< m_relativetriplimit<<" max bins "<<maxtbins);
118
119 if ( ((numhits + m_phvtripQueue[waferhash].back() )/ static_cast<double>(maxtbins) ) > m_absolutetriplimit
120 and ((numhits + m_phvtripQueue[waferhash].back() )/ static_cast<double>(maxtbins) ) > limit) {
121 //read back queue and see if the high hit rate is persistant for 3 previous bins (a bin is 5 seconds by default)
122 for (int iq{0}; iq<m_maxq; ++iq) {
123 m_tq[iq]=m_phvtripQueue[waferhash].front();
124 m_phvtripQueue[waferhash].pop();
125 }
126 if (m_tq[m_maxq-2]/static_cast<double>(maxtbins) > limit && m_tq[m_maxq-3]/static_cast<double>(maxtbins) > limit && m_tq[m_maxq-4]/static_cast<double>(maxtbins) > limit) {
127 // found a persistent trip/thing
128 ATH_MSG_DEBUG("Found a potential trip in SCT wafer " << waferhash);
129 ATH_MSG_DEBUG("TRIP more info: limit = " << limit << " abslimit = " << m_absolutetriplimit
130 << " hits/secs now = " << ((numhits + m_tq[m_maxq-1])/ maxtbins )
131 << " running total = " << m_phvtripRunningTotalInt[waferhash]
132 << " running average = " << m_phvtripRunningTotalInt[waferhash] / (curr_time-(m_phvtripFirstTime-1.01)));
133 m_phvtripHasItTripped[waferhash] = (numhits + m_tq[m_maxq-1] );
134 } // end trip found
135
136 //put queue back the way we found it:
137 for (int iq{0}; iq < m_maxq; ++iq) {
138 m_phvtripQueue[waferhash].push(m_tq[iq]);
139 }
140 } // end potential trip id
141 //incriment event counter
142 m_phvtripProcessedEventsInt[waferhash] += 1;
143 //recalcuate running total:
144 m_phvtripRunningTotalInt[waferhash] += numhits;
145 m_phvtripQueue[waferhash].back() += numhits;
146 } //end is good check
147 else {
148 ATH_MSG_DEBUG("Was a bad module already: " << waferhash);
149 }
150 } //end loop over tracks
151
152 // text output, summarizing the event
153 //if new bin summarzie the previous event.
154 if (newbin) {
157 for (; waferItr not_eq waferItrE; ++waferItr) {
158 Identifier waferId{*waferItr};
159 IdentifierHash waferHash{m_pSCTHelper->wafer_hash(waferId)};
160 if (m_phvtripHasItTripped_prev[waferHash]>0) {
161 std::pair<int, int> wp;
162 wp.first = (m_phvtripPrevTime - 3*maxtbins);
163 wp.second = (m_phvtripPrevTime + maxtbins);
164 m_summarytrips[waferHash].push_back(wp);
165 std::pair<int,int> lbn;
166 lbn.first = m_prevLBN.front();
167 lbn.second = m_prevLBN.back();
168 m_summarytripslb[waferHash].push_back(lbn);
169 }
170 }
171 m_phvtripPrevTime = curr_time; //reset prev and current time
172 m_prevLBN.pop();
173 m_prevLBN.push(lumi_block);
174 }
175
176 for (int iwaf{0}; iwaf!=n_elements; ++iwaf) {
177 ATH_MSG_DEBUG("mod "<< iwaf <<" events with that waf " <<m_phvtripProcessedEventsInt[iwaf] << " numhits "<<m_phvtripRunningTotalInt[iwaf]);
178 ATH_MSG_DEBUG("did it trip "<<m_phvtripHasItTripped[iwaf]);
179 if (m_phvtripHasItTripped[iwaf]) {
180 ATH_MSG_DEBUG("TRIP more info: abslimit = "<< m_absolutetriplimit
181 <<" hits/secs now = "<< ( m_phvtripQueue[iwaf].back() / maxtbins )
182 <<" running total = "<< m_phvtripRunningTotalInt[iwaf]
183 <<" running average = "<< m_phvtripRunningTotalInt[iwaf] / (curr_time-(m_phvtripFirstTime-1.01)));
184 }
185 }
186 if (m_outputLowHits && (totalHits < m_lowHitCut) ) {
187 }
188 return result;
189}
#define ATH_MSG_ERROR(x)
ToolHandle< ISCT_DCSConditionsTool > m_DCSConditionsTool
SCT_ID::const_id_iterator m_waferItrBegin
virtual bool fillFromData()
SCT_ID::const_id_iterator m_waferItrEnd
VecInt * m_sct_waferHash
const SCT_ID * m_pSCTHelper
std::vector< Identifier >::const_iterator const_id_iterator
Definition SCT_ID.h:73

◆ fillFromData()

bool SCT_CalibHvTool::fillFromData ( )
virtual

Definition at line 192 of file SCT_CalibHvTool.cxx.

192 {
193 bool result{true};
194 return result;
195}

◆ finalize()

StatusCode SCT_CalibHvTool::finalize ( )
virtual

Definition at line 36 of file SCT_CalibHvTool.cxx.

36 {
37 return StatusCode::SUCCESS;
38}

◆ initialize()

StatusCode SCT_CalibHvTool::initialize ( )
virtual

Definition at line 30 of file SCT_CalibHvTool.cxx.

30 {
32 return StatusCode::SUCCESS;
33}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ retrievedTool()

template<class T>
bool SCT_CalibHvTool::retrievedTool ( T & tool,
const std::string & toolName ) const
inlineprivate

retrieve a tool and report if it failed

Definition at line 94 of file SCT_CalibHvTool.h.

94 {
95 if (tool.retrieve().isFailure()) {
96 ATH_MSG_ERROR("Unable to retrieve " << toolName);
97 return false;
98 }
99 return true;
100 }

Member Data Documentation

◆ m_absolutetriplimit

double SCT_CalibHvTool::m_absolutetriplimit {0}
private

Definition at line 84 of file SCT_CalibHvTool.h.

84{0};

◆ m_DCSConditionsTool

ToolHandle<ISCT_DCSConditionsTool> SCT_CalibHvTool::m_DCSConditionsTool {this, "SCT_DCSConditionsTool", "SCT_DCSConditionsTool", "Tool to retrieve SCT DCS information"}
private

Definition at line 63 of file SCT_CalibHvTool.h.

63{this, "SCT_DCSConditionsTool", "SCT_DCSConditionsTool", "Tool to retrieve SCT DCS information"};

◆ m_lowHitCut

int SCT_CalibHvTool::m_lowHitCut {100}
private

Definition at line 91 of file SCT_CalibHvTool.h.

91{100};

◆ m_maxq

int SCT_CalibHvTool::m_maxq {100}
private

Definition at line 73 of file SCT_CalibHvTool.h.

73{100};

◆ m_outputLowHits

bool SCT_CalibHvTool::m_outputLowHits {false}
private

Definition at line 90 of file SCT_CalibHvTool.h.

90{false};

◆ m_phvtripFirstTime

int SCT_CalibHvTool::m_phvtripFirstTime {0}
private

Definition at line 83 of file SCT_CalibHvTool.h.

83{0};

◆ m_phvtripHasItTripped

VecInt SCT_CalibHvTool::m_phvtripHasItTripped
private

Definition at line 79 of file SCT_CalibHvTool.h.

◆ m_phvtripHasItTripped_prev

VecInt SCT_CalibHvTool::m_phvtripHasItTripped_prev
private

Definition at line 80 of file SCT_CalibHvTool.h.

◆ m_phvtripPrevTime

int SCT_CalibHvTool::m_phvtripPrevTime {0}
private

Definition at line 82 of file SCT_CalibHvTool.h.

82{0};

◆ m_phvtripProcessedEventsInt

VecInt SCT_CalibHvTool::m_phvtripProcessedEventsInt
private

Definition at line 78 of file SCT_CalibHvTool.h.

◆ m_phvtripQueue

std::vector<std::queue<int> > SCT_CalibHvTool::m_phvtripQueue
private

Definition at line 75 of file SCT_CalibHvTool.h.

◆ m_phvtripRunningTotalInt

VecInt SCT_CalibHvTool::m_phvtripRunningTotalInt
private

Definition at line 77 of file SCT_CalibHvTool.h.

◆ m_prevLBN

std::queue<int> SCT_CalibHvTool::m_prevLBN
private

Definition at line 76 of file SCT_CalibHvTool.h.

◆ m_pSCTHelper

const SCT_ID* SCT_CalibHvTool::m_pSCTHelper {nullptr}
private

Definition at line 65 of file SCT_CalibHvTool.h.

65{nullptr};

◆ m_relativetriplimit

double SCT_CalibHvTool::m_relativetriplimit {0}
private

Definition at line 85 of file SCT_CalibHvTool.h.

85{0};

◆ m_sct_numHitsInWafer

VecInt* SCT_CalibHvTool::m_sct_numHitsInWafer {nullptr}
private

Definition at line 70 of file SCT_CalibHvTool.h.

70{nullptr};

◆ m_sct_waferHash

VecInt* SCT_CalibHvTool::m_sct_waferHash {nullptr}
private

Definition at line 69 of file SCT_CalibHvTool.h.

69{nullptr};

◆ m_summarytrips

std::vector<std::vector<std::pair<int, int> > > SCT_CalibHvTool::m_summarytrips
private

Definition at line 88 of file SCT_CalibHvTool.h.

◆ m_summarytripslb

std::vector<std::vector<std::pair<int, int> > > SCT_CalibHvTool::m_summarytripslb
private

Definition at line 89 of file SCT_CalibHvTool.h.

◆ m_tq

int SCT_CalibHvTool::m_tq[100] {0}
private

Definition at line 86 of file SCT_CalibHvTool.h.

86{0};

◆ m_waferItrBegin

SCT_ID::const_id_iterator SCT_CalibHvTool::m_waferItrBegin
private

Definition at line 66 of file SCT_CalibHvTool.h.

◆ m_waferItrEnd

SCT_ID::const_id_iterator SCT_CalibHvTool::m_waferItrEnd
private

Definition at line 67 of file SCT_CalibHvTool.h.


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