ATLAS Offline Software
ZdcRecChannelTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * ZdcRecChannelTool.h
7  *
8  * Reconstruct the channel data extracting Energy, timing and quality factor.
9  * Should also get from the database the noise, pedestal and calibration
10  *
11  *FIXME nsamples is a property of a digits collection, not individual
12  * digits (fix ZdcEvenet/ZdcDigits.h. This is confusing, allow too much
13  * room for error (PPM will never run with different number of samples in
14  * a same configuration)
15  *
16  *FIXME ZdcRawChannel missing quality parameter
17  *FIXME ZdcRawChannelCollection must have Identifier (that's why it exists !)
18  *FIXME and not rely on storage order. See a trouble if you create unordered
19  *FIXME sequence
20  *
21  *
22  *TODO This probably should be called ZdcRecTool
23  *
24  *
25  * Created on: Nov 24, 2009
26  * Author: leite
27  */
28 
29 #ifndef ZDCRECCHANNELTOOL_H_
30 #define ZDCRECCHANNELTOOL_H_
31 
32 
33 #include <string>
34 #include <map>
35 
36 #include <gsl/gsl_errno.h>
37 #include <gsl/gsl_spline.h>
38 #include <gsl/gsl_math.h>
39 #include <gsl/gsl_roots.h>
40 
41 
43 #include "GaudiKernel/ToolHandle.h"
44 
46 
47 class IInterface;
48 class InterfaceID;
49 class StatusCode;
50 class Identifier;
52 class ZdcID ;
53 
54 //ROOT is pick expanding typedefs, play safe.
55 typedef std::pair<int, int> T_gain_delay_pair;
56 
57 typedef std::map< std::pair<int, int>, std::vector<int> > T_wfm_map;
58 typedef std::pair<std::pair<int, int>, std::vector<int> > T_wfm_pair;
59 
60 
61 inline bool negnum (float x) { return (x<0); }
62 inline bool posnum (float x) { return (x>0); }
63 
64 class ZdcRecChannelTool;
65 
67 {
69 };
70 
72 {
73 public:
74  ZdcRecChannelTool(const std::string& type,
75  const std::string& name,
76  const IInterface* parent);
77 
78  virtual ~ZdcRecChannelTool();
79 
81  static const InterfaceID& interfaceID();
82 
83  virtual StatusCode initialize();
84  virtual StatusCode finalize();
85 
86 
87 
88  int makeRawFromDigits(const ZdcDigitsCollection& data_collection, ZdcRawChannelCollection & raw_collection);
89 
90  int getCalibration(const ZdcDigitsCollection& data_collection, ZdcRawChannelCollection & raw_collection);
91 
92 
93 
94 
95 
96 private:
97 
98  int getTimingCFD (const Identifier& id, const std::vector< std::vector <int> >& wfm);
99 
100  gsl_interp_accel *m_interp_acc{};
101  gsl_spline *m_spline{};
102 
103  static double fx(double x0, void *params);
104 
105  static double fxCallback(double d,void* v)
106  {
107  CCallbackHolder* h = static_cast<CCallbackHolder*>(v);
108  return h->cls->fx(d, h->cls);
109  }
110 
111  std::vector<float> m_cfd_result;
112 
113  //Bandwidth limited interpolation (sin(x)/x) method
114  //variables
116  std::vector<float> m_wfm_bwl;
117  std::vector<float> m_bwl_vpeak;
118  std::vector<float> m_bwl_tpeak;
119  int getTimingSinc(const Identifier& id, const std::vector<std::vector <int> >& wfm );
120 
121 
122  std::vector<float> m_bwl_vpeak2;
123  std::vector<float> m_bwl_tpeak2;
124  int getTimingSinc2(const Identifier& id, const std::vector<std::vector <int> >& wfm );
125 
126 
127 
128  //ZdcRawChannelCollection m_ChannelCollection;
129 
130  unsigned int m_nsamples;
132 
133  int m_delta; // A number to check for signal
135 
136 
137  static const int s_FADC_SATURATION = 1022;
138 
139  //Timing Algorithms Constants
140  // CFD method
142  float m_cfd_delay ; //ns
143 
144  static const int s_CFD_FRACTION = -3;
145  static const int s_SAMPLING_TIME = 25000; // ps
146  static const int s_HALF_SAMPLING_TIME = 12500; //ps
147 
148  // According to Andrei: 1 ADC count = 1 GeV High Gain
149  // = 10 GeV High Gain
150  // Electronic gain: x 16 (??)
151  // Keeps as 1 until we understand it
152  static const int s_GAIN_RATIO = 1;
153 
154  //ZdcDigitsCollection* m_pedestalData;
155 
156  const ZdcID* m_zdcId{};
157 
158 };
159 
160 
161 #endif /* ZDCRECCHANNELTOOL_H_ */
ZdcRecChannelTool::finalize
virtual StatusCode finalize()
Definition: ZdcRecChannelTool.cxx:138
ZdcRecChannelTool::getTimingSinc2
int getTimingSinc2(const Identifier &id, const std::vector< std::vector< int > > &wfm)
Definition: ZdcRecChannelTool.cxx:764
ZdcRecChannelTool::ZdcRecChannelTool
ZdcRecChannelTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ZdcRecChannelTool.cxx:52
ZdcRecChannelTool::initialize
virtual StatusCode initialize()
Definition: ZdcRecChannelTool.cxx:85
hist_file_dump.d
d
Definition: hist_file_dump.py:137
ZdcRecChannelTool::s_FADC_SATURATION
static const int s_FADC_SATURATION
Definition: ZdcRecChannelTool.h:137
ZdcRecChannelTool::m_zdcId
const ZdcID * m_zdcId
Definition: ZdcRecChannelTool.h:156
ZdcRecChannelTool::m_cfd_delay
float m_cfd_delay
Definition: ZdcRecChannelTool.h:142
ZdcRecChannelTool::m_cfd_result
std::vector< float > m_cfd_result
Definition: ZdcRecChannelTool.h:111
ZdcRawChannelCollection.h
ZdcRecChannelTool::s_SAMPLING_TIME
static const int s_SAMPLING_TIME
Definition: ZdcRecChannelTool.h:145
ZdcRecChannelTool::m_bwl_tpeak2
std::vector< float > m_bwl_tpeak2
Definition: ZdcRecChannelTool.h:123
CCallbackHolder::cls
ZdcRecChannelTool * cls
Definition: ZdcRecChannelTool.h:68
ZdcRecChannelTool::m_cfd_fraction
float m_cfd_fraction
Definition: ZdcRecChannelTool.h:141
T_wfm_map
std::map< std::pair< int, int >, std::vector< int > > T_wfm_map
Definition: ZdcRecChannelTool.h:57
ZdcRecChannelTool::m_bwl_tpeak
std::vector< float > m_bwl_tpeak
Definition: ZdcRecChannelTool.h:118
x
#define x
ZdcRecChannelTool::fx
static double fx(double x0, void *params)
Definition: ZdcRecChannelTool.cxx:617
ZdcRecChannelTool::makeRawFromDigits
int makeRawFromDigits(const ZdcDigitsCollection &data_collection, ZdcRawChannelCollection &raw_collection)
Definition: ZdcRecChannelTool.cxx:151
CCallbackHolder
Definition: ZdcRecChannelTool.h:67
ZdcRecChannelTool::s_HALF_SAMPLING_TIME
static const int s_HALF_SAMPLING_TIME
Definition: ZdcRecChannelTool.h:146
ZdcRecChannelTool::m_wfm_bwl
std::vector< float > m_wfm_bwl
Definition: ZdcRecChannelTool.h:116
ZdcRecChannelTool::s_GAIN_RATIO
static const int s_GAIN_RATIO
Definition: ZdcRecChannelTool.h:152
posnum
bool posnum(float x)
Definition: ZdcRecChannelTool.h:62
ZdcRecChannelTool::m_nsamples
unsigned int m_nsamples
Definition: ZdcRecChannelTool.h:130
ZdcRecChannelTool
Definition: ZdcRecChannelTool.h:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ZdcRecChannelTool::m_interp_acc
gsl_interp_accel * m_interp_acc
Definition: ZdcRecChannelTool.h:100
AthAlgTool.h
ZdcRecChannelTool::getTimingCFD
int getTimingCFD(const Identifier &id, const std::vector< std::vector< int > > &wfm)
Definition: ZdcRecChannelTool.cxx:473
ZdcRecChannelTool::~ZdcRecChannelTool
virtual ~ZdcRecChannelTool()
Definition: ZdcRecChannelTool.cxx:78
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ZdcRecChannelTool::s_CFD_FRACTION
static const int s_CFD_FRACTION
Definition: ZdcRecChannelTool.h:144
ZdcRecChannelTool::m_sample_time
float m_sample_time
Definition: ZdcRecChannelTool.h:131
ZdcRawChannelCollection
Definition: ZdcRawChannelCollection.h:20
ZdcRecChannelTool::fxCallback
static double fxCallback(double d, void *v)
Definition: ZdcRecChannelTool.h:105
negnum
bool negnum(float x)
Definition: ZdcRecChannelTool.h:61
ZdcRecChannelTool::m_bwl_vpeak2
std::vector< float > m_bwl_vpeak2
Definition: ZdcRecChannelTool.h:122
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
T_wfm_pair
std::pair< std::pair< int, int >, std::vector< int > > T_wfm_pair
Definition: ZdcRecChannelTool.h:58
ZdcRecChannelTool::m_delta
int m_delta
Definition: ZdcRecChannelTool.h:133
python.PyAthena.v
v
Definition: PyAthena.py:154
ZdcRecChannelTool::getTimingSinc
int getTimingSinc(const Identifier &id, const std::vector< std::vector< int > > &wfm)
Definition: ZdcRecChannelTool.cxx:633
ZdcRecChannelTool::m_bwl_vpeak
std::vector< float > m_bwl_vpeak
Definition: ZdcRecChannelTool.h:117
h
ZdcRecChannelTool::m_bwl_time_resolution
int m_bwl_time_resolution
Definition: ZdcRecChannelTool.h:115
ZdcRecChannelTool::getCalibration
int getCalibration(const ZdcDigitsCollection &data_collection, ZdcRawChannelCollection &raw_collection)
Definition: ZdcRecChannelTool.cxx:457
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ZdcDigitsCollection
Definition: ZdcDigitsCollection.h:20
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
AthAlgTool
Definition: AthAlgTool.h:26
ZdcRecChannelTool::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition: ZdcRecChannelTool.cxx:44
ZdcID
Definition: ZdcID.h:25
ZdcRecChannelTool::m_spline
gsl_spline * m_spline
Definition: ZdcRecChannelTool.h:101
ZdcRecChannelTool::m_zeroSupress
int m_zeroSupress
Definition: ZdcRecChannelTool.h:134
T_gain_delay_pair
std::pair< int, int > T_gain_delay_pair
Definition: ZdcRecChannelTool.h:52
Identifier
Definition: IdentifierFieldParser.cxx:14