ATLAS Offline Software
Loading...
Searching...
No Matches
LArOFCComplete.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7
8const std::vector<float> LArOFCComplete::m_empty;
9
12
14
15/* Fill transient object in ATHENA *****************************************
16 */
17void LArOFCComplete::set(const HWIdentifier& CellID, int gain,
18 const std::vector<std::vector<float> >& vOFC_a,
19 const std::vector<std::vector<float> >& vOFC_b,
20 float timeOffset,float timeBinWidth)
21{
22 LArOFCP1 t (timeOffset, timeBinWidth, vOFC_a, vOFC_b);
23 setPdata(CellID, t, gain) ;
24}
25
26/* retrieve OFC_a coefficients for a given tbin using online ID ****************************
27 */
30 int gain,
31 int tbin) const
32{
33 CONTAINER::ConstReference t = get(CellID,gain) ;
34 if (!t.isValid() || tbin<0 || tbin>=(int)t.OFC_aSize())
35 return m_empty;
36 return t.OFC_a (tbin);
37}
38
39/* retrieve OFC_b coefficients for a given tbin using online ID ****************************
40 */
43 int gain,
44 int tbin) const
45{
46 CONTAINER::ConstReference t = get(CellID,gain) ;
47 if (!t.isValid() || tbin<0 || tbin>=(int)t.OFC_bSize())
48 return m_empty;
49 return t.OFC_b (tbin);
50}
51
52
53//retrieving time offset using online ID
54float LArOFCComplete::timeOffset(const HWIdentifier& CellID, int gain) const {
55 if (gain<0 || gain>3) {
56 std::cout << "ERROR! LArOFCComplete::timeOffset time offset called for gain " << gain << std::endl;
57 std::cout.flush();
58 return 0;
59 }
60
61 CONTAINER::ConstReference t = get(CellID,gain) ;
62 if (!t.isValid()) return 0;
63 return t.timeOffset();
64}
65
66//For the TB / cosmic case: retrieve the number of time-bins (aka "phases")
67unsigned LArOFCComplete::nTimeBins(const HWIdentifier& CellID, int gain) const {
68 if (gain<0 || gain>3) {
69 std::cout << "ERROR! LArOFCComplete::nTimeBins time offset called for gain " << gain << std::endl;
70 std::cout.flush();
71 }
72 CONTAINER::ConstReference t = get(CellID,gain) ;
73 if (!t.isValid()) return 0;
74 return t.OFC_aSize(); //Check also b-coefficient?
75}
76
77 //For the TB / cosmic case: retrieve the width of the time bin (default 24 bins in 25 ns)
78float LArOFCComplete::timeBinWidth(const HWIdentifier& CellID, int gain) const {
79 if (gain<0 || gain>3) {
80 std::cout << "ERROR! LArOFCComplete::timeBinWidth time offset called for gain " << gain << std::endl;
81 std::cout.flush();
82 }
83 CONTAINER::ConstReference t = get(CellID,gain) ;
84 if (!t.isValid()) return 0;
85 return t.timeBinWidth();
86}
87
88
89#include <stdio.h>
90// dump entire LArOFCComplete structure to an ascii file dumpOFC.txt
91// useful for debug
92void LArOFCComplete::dumpOFC(const std::string& output_file_name) const {
93 FILE* f = fopen( output_file_name.c_str() , "w" ) ;
94 if (!f) {
95 std::cerr << "Can't open output file: " << output_file_name << "\n";
96 return;
97 }
98
99 for (unsigned int iGain = minGain(); iGain < nGains(); ++iGain) {
100
101 ConstConditionsMapIterator it_chan = begin(iGain);
102 ConstConditionsMapIterator it_chan_e = end (iGain);
103
104 for ( ; it_chan !=it_chan_e ;++it_chan ) {
105 const LArOFCP1& chunkOFC = *it_chan ;
106 unsigned int chID = it_chan.channelId().get_identifier32().get_compact();
107 fprintf( f , "---------------------- Gain = %1u ; Channel = %10x ----------------------\n",
108 iGain, chID ) ;
109 unsigned nTbin = chunkOFC.OFC_aSize() ;
110 assert( nTbin == chunkOFC.OFC_bSize() ) ;
111 // fprintf( f , "\t bin \t a-coefficients \t \t \t \t \t \t b-coefficients \n" ) ;
112 for ( unsigned kBin=0 ; kBin<nTbin ; kBin++ ) {
113 unsigned nSample = (chunkOFC.OFC_a (kBin)).size() ;
114 assert( nSample == (chunkOFC.OFC_b (kBin)).size() ) ;
115 fprintf( f , "\t%2u\t |" , kBin ) ;
116 for ( unsigned kSample=0 ; kSample<nSample ; kSample++ ) {
117 fprintf( f , "\t%8.3f" , chunkOFC.OFC_a(kBin)[kSample] ) ;
118 }
119 fprintf( f , "\t |" ) ;
120 for ( unsigned kSample=0 ; kSample<nSample ; kSample++ ) {
121 fprintf( f , "\t%8.3f" , chunkOFC.OFC_b(kBin)[kSample] ) ;
122 }
123 fprintf( f , "\n" ) ;
124 }
125 }
126 }
127 fclose(f) ;
128}
129
130
const_iterator end() const noexcept
const_iterator begin() const noexcept
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
void setPdata(const HWIdentifier id, const LArOFCP1 &payload, unsigned int gain=0)
ConditionsMap::const_iterator ConstConditionsMapIterator
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
virtual ~LArOFCComplete()
ILArOFC::OFCRef_t OFCRef_t
virtual OFCRef_t OFC_a(const HWIdentifier &CellID, int gain, int tbin=0) const override
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
virtual float timeOffset(const HWIdentifier &CellID, int gain) const override
void dumpOFC(const std::string &output_file_name) const
virtual OFCRef_t OFC_b(const HWIdentifier &CellID, int gain, int tbin=0) const override
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const override
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const override
void set(const HWIdentifier &CellID, int gain, const std::vector< std::vector< float > > &vOFC_a, const std::vector< std::vector< float > > &vOFC_b, float timeOffset=0, float timeBinWidth=25./24.)
static const std::vector< float > m_empty
c-struct reproducing the structure of the persistent data
Definition LArOFCP1.h:22
size_t OFC_aSize() const
Definition LArOFCP1.h:42
OFCRef_t OFC_a(size_t tbin) const
Definition LArOFCP1.h:45
size_t OFC_bSize() const
Definition LArOFCP1.h:43
OFCRef_t OFC_b(size_t tbin) const
Definition LArOFCP1.h:46