Skip to content

Commit 2a8851b

Browse files
Andreas Mathissawenzel
authored andcommitted
Noise and pedestal retrieval from CDB interface
1 parent a5db2d6 commit 2a8851b

File tree

7 files changed

+42
-255
lines changed

7 files changed

+42
-255
lines changed

Detectors/TPC/simulation/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ O2_SETUP(NAME ${MODULE_NAME})
1313
link_directories( ${LINK_DIRECTORIES})
1414

1515
set(SRCS
16-
src/Baseline.cxx
1716
src/Detector.cxx
1817
src/DigitMCMetaData.cxx
1918
src/DigitContainer.cxx
@@ -30,7 +29,6 @@ set(SRCS
3029
)
3130

3231
set(HEADERS
33-
include/${MODULE_NAME}/Baseline.h
3432
include/${MODULE_NAME}/Detector.h
3533
include/${MODULE_NAME}/DigitMCMetaData.h
3634
include/${MODULE_NAME}/DigitContainer.h

Detectors/TPC/simulation/include/TPCSimulation/Baseline.h

Lines changed: 0 additions & 125 deletions
This file was deleted.

Detectors/TPC/simulation/include/TPCSimulation/SAMPAProcessing.h

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
#include <Vc/Vc>
1919

20-
#include "TPCBase/PadSecPos.h"
20+
#include "TPCBase/PadPos.h"
21+
#include "TPCBase/CalDet.h"
22+
#include "TPCBase/CRU.h"
23+
#include "TPCBase/RandomRing.h"
2124
#include "TPCBase/ParameterDetector.h"
2225
#include "TPCBase/ParameterElectronics.h"
2326
#include "TPCBase/ParameterGas.h"
24-
#include "TPCSimulation/Baseline.h"
2527

2628
#include "TSpline.h"
2729

@@ -59,11 +61,12 @@ class SAMPAProcessing
5961
/// \return ADC value of the (saturated) SAMPA
6062
float getADCSaturation(const float signal) const;
6163

62-
/// Make the full signal including noise and pedestals from the Baseline class
64+
/// Make the full signal including noise and pedestals from the OCDB
6365
/// \param ADCcounts ADC value of the signal (common mode already subtracted)
64-
/// \param padSecPos PadSecPos of the signal
66+
/// \param cru CRU of the signal
67+
/// \param padPos PadPos of the signal
6568
/// \return ADC value after application of noise, pedestal and saturation
66-
float makeSignal(float ADCcounts, const PadSecPos& padSecPos, float& pedestal, float& noise) const;
69+
float makeSignal(float ADCcounts, const CRU& cru, const PadPos& pos, float& pedestal, float& noise);
6770

6871
/// A delta signal is shaped by the FECs and thus spread over several time bins
6972
/// This function returns an array with the signal spread into the following time bins
@@ -106,6 +109,18 @@ class SAMPAProcessing
106109
/// \return Time of the time bin of the charge
107110
float getTimeBinTime(float time) const;
108111

112+
/// Get the noise for a given channel
113+
/// \param cru CRU of the channel of interest
114+
/// \param padPos PadPos of the channel of interest
115+
/// \return Noise on the channel of interest
116+
float getNoise(const CRU& cru, const PadPos& pos);
117+
118+
/// Get the pedestal for a given channel
119+
/// \param cru CRU of the channel of interest
120+
/// \param padPos PadPos of the channel of interest
121+
/// \return Pedestal on the channel of interest
122+
float getPedestal(const CRU& cru, const PadPos& pos) const;
123+
109124
private:
110125
SAMPAProcessing();
111126

@@ -120,6 +135,9 @@ class SAMPAProcessing
120135
const ParameterGas* mGasParam; ///< Caching of the parameter class to avoid multiple CDB calls
121136
const ParameterDetector* mDetParam; ///< Caching of the parameter class to avoid multiple CDB calls
122137
const ParameterElectronics* mEleParam; ///< Caching of the parameter class to avoid multiple CDB calls
138+
const CalPad* mNoiseMap; ///< Caching of the parameter class to avoid multiple CDB calls
139+
const CalPad* mPedestalMap; ///< Caching of the parameter class to avoid multiple CDB calls
140+
RandomRing mRandomNoiseRing; ///< Ring with random number for noise
123141
};
124142

125143
template <typename T>
@@ -130,14 +148,12 @@ inline T SAMPAProcessing::getADCvalue(T nElectrons) const
130148
return nElectrons * conversion;
131149
}
132150

133-
inline float SAMPAProcessing::makeSignal(float ADCcounts, const PadSecPos& padSecPos,
134-
float& pedestal, float& noise) const
151+
inline float SAMPAProcessing::makeSignal(float ADCcounts, const CRU& cru, const PadPos& pos,
152+
float& pedestal, float& noise)
135153
{
136-
static Baseline baseline;
137154
float signal = ADCcounts;
138-
/// \todo Pedestal to be implemented in baseline class
139-
// pedestal = baseline.getPedestal(padSecPos);
140-
noise = baseline.getNoise(padSecPos);
155+
pedestal = getPedestal(cru, pos);
156+
noise = getNoise(cru, pos);
141157
switch (mEleParam->getDigitizationMode()) {
142158
case DigitzationMode::FullMode: {
143159
signal += noise;
@@ -216,6 +232,16 @@ inline float SAMPAProcessing::getTimeBinTime(float time) const
216232
TimeBin timeBin = getTimeBinFromTime(time);
217233
return getTimeFromBin(timeBin);
218234
}
235+
236+
inline float SAMPAProcessing::getNoise(const CRU& cru, const PadPos& pos)
237+
{
238+
return mRandomNoiseRing.getNextValue() * mNoiseMap->getValue(cru, pos.getRow(), pos.getPad());
239+
}
240+
241+
inline float SAMPAProcessing::getPedestal(const CRU& cru, const PadPos& pos) const
242+
{
243+
return mPedestalMap->getValue(cru, pos.getRow(), pos.getPad());
244+
}
219245
}
220246
}
221247

Detectors/TPC/simulation/src/Baseline.cxx

Lines changed: 0 additions & 113 deletions
This file was deleted.

Detectors/TPC/simulation/src/DigitGlobalPad.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void DigitGlobalPad::fillOutputContainer(std::vector<Digit>* output,
2929
GlobalPadNumber globalPad, float commonMode)
3030
{
3131
const static Mapper& mapper = Mapper::instance();
32-
const static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance();
32+
static SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance();
3333
const PadPos pad = mapper.padPos(globalPad);
3434

3535
/// The charge accumulated on that pad is converted into ADC counts, saturation of the SAMPA is applied and a Digit
@@ -38,7 +38,7 @@ void DigitGlobalPad::fillOutputContainer(std::vector<Digit>* output,
3838
// pedestals and saturation of the SAMPA
3939

4040
float noise, pedestal;
41-
const float mADC = sampaProcessing.makeSignal(totalADC, PadSecPos(cru.sector(), pad), pedestal, noise);
41+
const float mADC = sampaProcessing.makeSignal(totalADC, cru, pad, pedestal, noise);
4242

4343
/// only write out the data if there is actually charge on that pad
4444
if (mADC > 0 && mChargePad > 0) {

Detectors/TPC/simulation/src/SAMPAProcessing.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
using namespace o2::TPC;
2525

26-
SAMPAProcessing::SAMPAProcessing() : mSaturationSpline()
26+
SAMPAProcessing::SAMPAProcessing() : mSaturationSpline(), mRandomNoiseRing(RandomRing::RandomType::Gaus)
2727
{
2828
updateParameters();
2929
importSaturationCurve("SAMPA_saturation.dat");
@@ -37,6 +37,8 @@ void SAMPAProcessing::updateParameters()
3737
mGasParam = &(cdb.getParameterGas());
3838
mDetParam = &(cdb.getParameterDetector());
3939
mEleParam = &(cdb.getParameterElectronics());
40+
mPedestalMap = &(cdb.getPedestals());
41+
mNoiseMap = &(cdb.getNoise());
4042
}
4143

4244
bool SAMPAProcessing::importSaturationCurve(std::string file)

Detectors/TPC/simulation/src/TPCSimulationLinkDef.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#pragma link off all classes;
1515
#pragma link off all functions;
1616

17-
#pragma link C++ class o2::TPC::Baseline + ;
1817
#pragma link C++ class o2::TPC::Detector + ;
1918
#pragma link C++ class o2::Base::DetImpl < o2::TPC::Detector > +;
2019
#pragma link C++ class o2::TPC::DigitMCMetaData + ;

0 commit comments

Comments
 (0)