ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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< TileCondToolPulseShapem_tileToolPulseShape
 
ToolHandle< TileCondToolAutoCrm_tileToolAutoCr
 
const TileInfom_tileInfo
 
int m_nSamples
 
int m_t0Sample
 
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 40 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  , m_tileInfo(nullptr)
20 {
21  declareProperty("nSamples", m_nSamples = 7, "number of samples used in the run");
22  declareProperty("OptFilterDeltaCorrelation", m_deltaCorrelation = false
23  , "true=> use delta correlation; false=>use calculation obtained from data");
24 
25  m_t0Sample = (m_nSamples - 1) / 2;
26 }

◆ ~TileCondToolOfc()

TileCondToolOfc::~TileCondToolOfc ( )
virtual

Definition at line 30 of file TileCondToolOfc.cxx.

30  {
31 
32 }

Member Function Documentation

◆ finalize()

StatusCode TileCondToolOfc::finalize ( )
overridevirtual

Definition at line 90 of file TileCondToolOfc.cxx.

90  {
91  ATH_MSG_DEBUG( "TileCondToolOfc finalize called" );
92 
93  return StatusCode::SUCCESS;
94 }

◆ 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 100 of file TileCondToolOfc.cxx.

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

◆ initialize()

StatusCode TileCondToolOfc::initialize ( )
overridevirtual

Definition at line 36 of file TileCondToolOfc.cxx.

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

Member Data Documentation

◆ m_deltaCorrelation

bool TileCondToolOfc::m_deltaCorrelation
private

Definition at line 74 of file TileCondToolOfc.h.

◆ m_nSamples

int TileCondToolOfc::m_nSamples
private

Definition at line 72 of file TileCondToolOfc.h.

◆ m_t0Sample

int TileCondToolOfc::m_t0Sample
private

Definition at line 73 of file TileCondToolOfc.h.

◆ m_tileInfo

const TileInfo* TileCondToolOfc::m_tileInfo
private

Definition at line 69 of file TileCondToolOfc.h.

◆ m_tileToolAutoCr

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

Definition at line 66 of file TileCondToolOfc.h.

◆ m_tileToolPulseShape

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

Definition at line 63 of file TileCondToolOfc.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
TileCondToolOfc::m_tileInfo
const TileInfo * m_tileInfo
Definition: TileCondToolOfc.h:69
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileInfo::NdigitSamples
int NdigitSamples() const
Returns the number of sammples (digits) per event.
Definition: TileInfo.h:75
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TileCondToolOfc::m_t0Sample
int m_t0Sample
Definition: TileCondToolOfc.h:73
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TileInfo::ItrigSample
int ItrigSample() const
The sample at which the pulse should ideally peak.
Definition: TileInfo.h:77
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
TileCablingService
Definition: TileCablingService.h:23
TileCondToolOfc::m_tileToolAutoCr
ToolHandle< TileCondToolAutoCr > m_tileToolAutoCr
Definition: TileCondToolOfc.h:66
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Amg::py
@ py
Definition: GeoPrimitives.h:39
Result
Definition: fbtTestBasics.cxx:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TileCondToolOfc::m_tileToolPulseShape
ToolHandle< TileCondToolPulseShape > m_tileToolPulseShape
Definition: TileCondToolOfc.h:63
weights
Definition: herwig7_interface.h:38
TileCondToolOfc::m_nSamples
int m_nSamples
Definition: TileCondToolOfc.h:72
a
TList * a
Definition: liststreamerinfos.cxx:10
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
TileCondToolOfc::m_deltaCorrelation
bool m_deltaCorrelation
Definition: TileCondToolOfc.h:74
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ServiceHandle< TileCablingSvc >