ATLAS Offline Software
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 
8 const std::vector<float> LArOFCComplete::m_empty;
9 
11 }
12 
14 
15 /* Fill transient object in ATHENA *****************************************
16  */
17 void 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
54 float 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")
67 unsigned 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)
78 float 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
92 void 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 
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
LArOFCP1
c-struct reproducing the structure of the persistent data
Definition: LArOFCP1.h:22
LArConditionsContainer< LArOFCP1 >::setPdata
void setPdata(const HWIdentifier id, const LArOFCP1 &payload, unsigned int gain=0)
put payload in persistent data
LArOFCP1::OFC_aSize
size_t OFC_aSize() const
Definition: LArOFCP1.h:42
LArConditionsContainerDB::iteratorT::channelId
HWIdentifier channelId() const
LArOFCComplete::set
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.)
Definition: LArOFCComplete.cxx:17
LArConditionsContainerDB::iteratorT
Declaration of const iterator.
Definition: LArConditionsContainerDB.h:72
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArOFCComplete::OFC_a
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)
Definition: LArOFCComplete.cxx:29
LArOFCComplete::m_empty
static const std::vector< float > m_empty
Definition: LArOFCComplete.h:67
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
HWIdentifier
Definition: HWIdentifier.h:13
LArOFCP1::OFC_b
OFCRef_t OFC_b(size_t tbin) const
Definition: LArOFCP1.h:46
LArConditionsContainer< LArOFCP1 >::nGains
unsigned int nGains() const
Number of gain values.
LArConditionsContainer< LArOFCP1 >::minGain
unsigned int minGain() const
Mininum gain value.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LArOFCComplete::OFC_b
virtual OFCRef_t OFC_b(const HWIdentifier &CellID, int gain, int tbin=0) const override
Definition: LArOFCComplete.cxx:42
LArOFCComplete::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, int gain) const override
Definition: LArOFCComplete.cxx:54
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
LArConditionsContainer< LArOFCP1 >::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArOFCComplete.h
LArOFCP1::OFC_a
OFCRef_t OFC_a(size_t tbin) const
Definition: LArOFCP1.h:45
LArConditionsContainer< LArOFCP1 >::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
LArOFCComplete::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const override
Definition: LArOFCComplete.cxx:67
rename_histos_in_files_from_old_code.output_file_name
string output_file_name
Definition: rename_histos_in_files_from_old_code.py:253
LArOFCComplete::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const override
Definition: LArOFCComplete.cxx:78
LArOFCP1::OFC_bSize
size_t OFC_bSize() const
Definition: LArOFCP1.h:43
LArOFCComplete::~LArOFCComplete
virtual ~LArOFCComplete()
Definition: LArOFCComplete.cxx:13
LArConditionsContainer::ConstReference
Subset::ConstReference ConstReference
Definition: LArConditionsContainer.h:80
LArConditionsContainer< LArOFCP1 >::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
LArOFCComplete::dumpOFC
void dumpOFC(const std::string &output_file_name) const
Definition: LArOFCComplete.cxx:92
LArOFCComplete::LArOFCComplete
LArOFCComplete()
Definition: LArOFCComplete.cxx:10
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38