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

Calculates OFCs on the fly using pulse shapes and A/C matrix from database. More...

#include <TileCondToolOfc.h>

Inheritance diagram for TileCondToolOfc:
Collaboration diagram for TileCondToolOfc:

Public Member Functions

 TileCondToolOfc (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TileCondToolOfc ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode getOfcWeights (unsigned int drawerIdx, unsigned int channel, unsigned int adc, float &phase, bool of2, TileOfcWeightsStruct &weights, const EventContext &ctx) const override

Private Attributes

ToolHandle< TileCondToolPulseShape > m_tileToolPulseShape
ToolHandle< TileCondToolAutoCr > m_tileToolAutoCr
const TileInfo * m_tileInfo {nullptr}
Gaudi::Property< int > m_nSamples {this, "nSamples", 7, "number of samples used in the run"}
int m_t0Sample
Gaudi::Property< bool > m_deltaCorrelation

Detailed Description

Calculates OFCs on the fly using pulse shapes and A/C matrix from database.

Optionally, it can create cache table of OFCs with 1-ns step to minimize CPU time. Also, by request, unity A/C matrix can be used.

Definition at line 41 of file TileCondToolOfc.h.

Constructor & Destructor Documentation

◆ TileCondToolOfc()

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

Definition at line 16 of file TileCondToolOfc.cxx.

18 : base_class(type, name, parent)
19{
20 m_t0Sample = (m_nSamples - 1) / 2;
21}
Gaudi::Property< int > m_nSamples

◆ ~TileCondToolOfc()

TileCondToolOfc::~TileCondToolOfc ( )
virtual

Definition at line 25 of file TileCondToolOfc.cxx.

25 {
26
27}

Member Function Documentation

◆ finalize()

StatusCode TileCondToolOfc::finalize ( )
overridevirtual

Definition at line 85 of file TileCondToolOfc.cxx.

85 {
86 ATH_MSG_DEBUG( "TileCondToolOfc finalize called" );
87
88 return StatusCode::SUCCESS;
89}
#define ATH_MSG_DEBUG(x,...)

◆ getOfcWeights()

StatusCode TileCondToolOfc::getOfcWeights ( unsigned int drawerIdx,
unsigned int channel,
unsigned int adc,
float & phase,
bool of2,
TileOfcWeightsStruct & weights,
const EventContext & ctx ) const
overridevirtual

Definition at line 95 of file TileCondToolOfc.cxx.

102{
103 ATH_MSG_DEBUG( "TileCondToolOfc weights, drawerIdx:" << drawerIdx
104 << " channel: " << channel
105 << " gain: " << gain
106 << " phase: " << phase );
107
108 std::fill (std::begin(weights.g), std::end(weights.g), 0);
109 std::fill (std::begin(weights.dg), std::end(weights.dg), 0);
110 std::fill (std::begin(weights.w_a), std::end(weights.w_a), 0);
111 std::fill (std::begin(weights.w_b), std::end(weights.w_b), 0);
112 std::fill (std::begin(weights.w_c), std::end(weights.w_c), 0);
113
114
115 CLHEP::HepMatrix Correlation(m_nSamples, m_nSamples, 1);
116 //aa , Inverse(m_nSamples,m_nSamples,0), Zero(m_nSamples,m_nSamples,0);
117 CLHEP::HepMatrix PulseShape(m_nSamples, 1, 0), DPulseShape(m_nSamples, 1, 0);
118 CLHEP::HepMatrix a(m_nSamples, 1, 0), b(m_nSamples, 1, 0);
119
120
121 //int ierr=0;
122
123 if (msgLvl(MSG::DEBUG)) {
124 msg(MSG::DEBUG) << " Calculating " << (of2 ? "OF2" : "OF1") << " weights ";
125
127 msg(MSG::DEBUG) << "with Delta correlation matrix " << endmsg;
128 else
129 msg(MSG::DEBUG) << "with correlation matrix obtained from DB " << endmsg;
130
131 msg(MSG::DEBUG) << "for drawerIdx= " << drawerIdx
132 << " channel=" << channel
133 << " gain=" << gain
134 << " phase " << phase << endmsg;
135 }
136
137 int npr = 2;
138 if (of2) npr = 3;
139 weights.n_samples = m_nSamples;
140 weights.of2 = of2;
141
142 if (!m_deltaCorrelation) { //=== Retrieve autocorrelations from COOL DB
143 std::vector<float> vecAutoCr;
144 m_tileToolAutoCr->getAutoCorr(drawerIdx, channel, gain, vecAutoCr);
145
146 ATH_MSG_DEBUG( " vecAutoCr size: " << vecAutoCr.size() );
147 ATH_MSG_VERBOSE( " vecAutoCr " << vecAutoCr );
148 if (vecAutoCr[0] > -1233.){
149 if (vecAutoCr.size() == 28){
150 int AutoCrPosition = 0;
151 for (int i = 0; i < m_nSamples; ++i)
152 for (int j = i; j < m_nSamples; ++j){
153 Correlation[i][j] = vecAutoCr[AutoCrPosition];
154 Correlation[j][i] = vecAutoCr[AutoCrPosition];
155 ++AutoCrPosition;
156 }
157 } else {
158 for (int i = 0; i < m_nSamples; i++)
159 Correlation[i][i] = 1.;
160 for (int i = 0; i < m_nSamples - 1; i++) {// Fill non-diag. elements
161 for (int j = 0; j < m_nSamples - i - 1; j++) {
162 Correlation[i][j + i + 1] = vecAutoCr[j];
163 Correlation[j + i + 1][i] = vecAutoCr[j];
164 }
165 }
166 }
167 }
168 }
169
170 ATH_MSG_VERBOSE( " Correlation: " << Correlation );
171
172 float py = 0.;
173 float pdy = 0.;
174 //if (ierr==0)
175
176 {
177 for (int i = 0; i < m_nSamples; i++) {
178 m_tileToolPulseShape->getPulseShapeYDY(drawerIdx, channel, gain
179 , phase + 25 * (i - m_t0Sample), py, pdy, ctx);
180
181 // If overflow/underflow using boundary value of y and dy=0, OF affected when the number of samples is high. Set y=0 and dy=0 for OF weights computation
182 if( (phase + 25 * (i - m_t0Sample) < -150) || (phase + 25 * (i - m_t0Sample) > 150) ){
183 py=0;
184 pdy=0;
185 }
186
187
188 PulseShape[i][0] = py;
189 DPulseShape[i][0] = pdy;
190 weights.g[i] = PulseShape[i][0];
191 weights.dg[i] = DPulseShape[i][0];
192
193 ATH_MSG_VERBOSE( " Pulse shape: isamp " << i
194 << " phase " << phase
195 << " py " << py
196 << " pdy " << pdy );
197
198 }
199
200 // Build System Matrix with Correlations and pulse function points
201
202 CLHEP::HepMatrix SystemMatrix(m_nSamples + npr, m_nSamples + npr, 0);
203 CLHEP::HepVector Result(m_nSamples + npr, 0);
204 CLHEP::HepVector IndependTermsAmp(m_nSamples + npr, 0);
205 CLHEP::HepVector IndependTermsTime(m_nSamples + npr, 0);
206 CLHEP::HepVector IndependTermsPed(m_nSamples + npr, 0);
207
208 for (int i = 0; i < m_nSamples; i++) {
209 for (int j = 0; j < m_nSamples; j++) {
210 SystemMatrix[i][j] = Correlation[i][j];
211 }
212
213 SystemMatrix[m_nSamples][i] = PulseShape[i][0];
214 SystemMatrix[i][m_nSamples] = PulseShape[i][0];
215
216 SystemMatrix[m_nSamples + 1][i] = DPulseShape[i][0];
217 SystemMatrix[i][m_nSamples + 1] = DPulseShape[i][0];
218
219 if (of2) {
220 SystemMatrix[m_nSamples + 2][i] = 1.;
221 SystemMatrix[i][m_nSamples + 2] = 1.;
222 }
223 }
224
225 IndependTermsAmp[m_nSamples] = 1.;
226 IndependTermsTime[m_nSamples + 1] = -1.;
227
228 if (of2) IndependTermsPed[m_nSamples + 2] = 1.;
229
230 Result = solve(SystemMatrix, IndependTermsAmp);
231
232 for (int ismp = 0; ismp < m_nSamples; ismp++) {
233 weights.w_a[ismp] = (double) Result[ismp];
234// ATH_MSG_DEBUG( "w_a " << weights.w_a[ismp] << " ismp " << ismp );
235
236 }
237
238 Result = solve(SystemMatrix, IndependTermsTime);
239
240 for (int ismp = 0; ismp < m_nSamples; ismp++) {
241 weights.w_b[ismp] = (double) Result[ismp];
242// ATH_MSG_DEBUG( "w_b " << weights.w_b[ismp] << " ismp " << ismp );
243 }
244
245 if (of2) { // OF2
246 Result = solve(SystemMatrix, IndependTermsPed);
247
248 for (int ismp = 0; ismp < m_nSamples; ismp++) {
249 weights.w_c[ismp] = (double) Result[ismp];
250// ATH_MSG_DEBUG( "w_c " << weights.w_c[ismp] << " ismp " << ismp );
251 }
252 }
253
254 }
255
256#if 0
257 else {
258 for (int ismp=0; ismp<m_nSamples; ismp++) {
259 weights.w_a[ismp] = 0.;
260 weights.w_b[ismp] = 0.;
261 weights.w_c[ismp] = 0.;
262 weights.g[ismp] = 0.;
263 weights.dg[ismp] = 0.;
264 }
265 }
266#endif
267
268 ATH_MSG_DEBUG( "...OFC weights fixed-phase calculated" );
269
270 return StatusCode::SUCCESS;
271}
#define endmsg
#define ATH_MSG_VERBOSE(x,...)
ICscStripFitter::Result Result
static Double_t a
ToolHandle< TileCondToolAutoCr > m_tileToolAutoCr
Gaudi::Property< bool > m_deltaCorrelation
ToolHandle< TileCondToolPulseShape > m_tileToolPulseShape
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
MsgStream & msg
Definition testRead.cxx:32

◆ initialize()

StatusCode TileCondToolOfc::initialize ( )
overridevirtual

Definition at line 31 of file TileCondToolOfc.cxx.

31 {
32
33 ATH_MSG_INFO( "In initialize()" );
34
35 //=== Get TileCondToolPulseShape
36 ATH_CHECK( m_tileToolPulseShape.retrieve() );
37
38 if (!m_deltaCorrelation) {
39 ATH_CHECK(m_tileToolAutoCr.retrieve());
40 } else {
41 m_tileToolAutoCr.disable();
42 }
43
44 //==== TileInfo
45 ATH_CHECK( detStore()->retrieve(m_tileInfo, "TileInfo") );
46
47 if (m_nSamples != m_tileInfo->NdigitSamples()) {
48 ATH_MSG_WARNING( "Changing number of samples from " << m_nSamples.value()
49 << " to " << m_tileInfo->NdigitSamples() );
50
51 m_nSamples = m_tileInfo->NdigitSamples();
52 } else {
53 ATH_MSG_INFO( "Number of samples is " << m_nSamples.value() );
54 }
55
56 m_t0Sample = (m_nSamples - 1) / 2;
57 if (m_t0Sample != m_tileInfo->ItrigSample()) {
58 ATH_MSG_WARNING( "Changing T0 sample from " << m_t0Sample
59 << " to " << m_tileInfo->ItrigSample() );
60
61 m_t0Sample = m_tileInfo->ItrigSample();
62 } else {
63 ATH_MSG_INFO( "T0 sample is " << m_t0Sample );
64 }
65
66 //=== Initialize max values
67 ServiceHandle<TileCablingSvc> cablingSvc("TileCablingSvc", name());
68 ATH_CHECK( cablingSvc.retrieve());
69
70 const TileCablingService* cabling = cablingSvc->cablingService();
71 if (!cabling) {
72 ATH_MSG_ERROR( "Unable to retrieve TileCablingService" );
73 return StatusCode::FAILURE;
74 }
75
76
77 //--------------------------------------------------------
78 ATH_MSG_INFO( "TileCondToolOfc initialization completed. " );
79
80 return StatusCode::SUCCESS;
81}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
const TileInfo * m_tileInfo

Member Data Documentation

◆ m_deltaCorrelation

Gaudi::Property<bool> TileCondToolOfc::m_deltaCorrelation
private
Initial value:
{this, "OptFilterDeltaCorrelation", false,
"true=> use delta correlation; false=>use calculation obtained from data"}

Definition at line 75 of file TileCondToolOfc.h.

75 {this, "OptFilterDeltaCorrelation", false,
76 "true=> use delta correlation; false=>use calculation obtained from data"};

◆ m_nSamples

Gaudi::Property<int> TileCondToolOfc::m_nSamples {this, "nSamples", 7, "number of samples used in the run"}
private

Definition at line 73 of file TileCondToolOfc.h.

73{this, "nSamples", 7, "number of samples used in the run"};

◆ m_t0Sample

int TileCondToolOfc::m_t0Sample
private

Definition at line 74 of file TileCondToolOfc.h.

◆ m_tileInfo

const TileInfo* TileCondToolOfc::m_tileInfo {nullptr}
private

Definition at line 70 of file TileCondToolOfc.h.

70{nullptr};

◆ m_tileToolAutoCr

ToolHandle<TileCondToolAutoCr> TileCondToolOfc::m_tileToolAutoCr
private
Initial value:
{this,
"TileCondToolAutoCr", "TileCondToolAutoCr", "Tile auto correlation matrix tool"}

Definition at line 67 of file TileCondToolOfc.h.

67 {this,
68 "TileCondToolAutoCr", "TileCondToolAutoCr", "Tile auto correlation matrix tool"};

◆ m_tileToolPulseShape

ToolHandle<TileCondToolPulseShape> TileCondToolOfc::m_tileToolPulseShape
private
Initial value:
{this,
"TileCondToolPulseShape", "TileCondToolPulseShape", "Tile pulse shape tool"}

Definition at line 64 of file TileCondToolOfc.h.

64 {this,
65 "TileCondToolPulseShape", "TileCondToolPulseShape", "Tile pulse shape tool"};

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