Skip to content

Commit 69b1cc6

Browse files
sevdokimshahor02
authored andcommitted
CPV: fix in pedestal calibration
1 parent bd11c5c commit 69b1cc6

File tree

7 files changed

+293
-60
lines changed

7 files changed

+293
-60
lines changed

Detectors/CPV/base/include/CPVBase/CPVSimParams.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,14 @@ struct CPVSimParams : public o2::conf::ConfigurableParamHelper<CPVSimParams> {
3838
float mA = 1.0; ///< Parameter to model CPV response
3939
float mB = 0.7; ///< Parameter to model CPV response
4040

41-
//Parameters used in electronic noise calculation and thresholds (Digitizer)
41+
//Parameters used in electronic noise calculation and thresholds (Digitizer, Calibration)
4242
float mReadoutTime = 5.; ///< Read-out time in ns for default simulaionts
4343
float mDeadTime = 20.; ///< PHOS dead time (includes Read-out time i.e. mDeadTime>=mReadoutTime)
4444
float mReadoutTimePU = 2000.; ///< Read-out time in ns if pileup simulation on in DigitizerSpec
4545
float mDeadTimePU = 30000.; ///< PHOS dead time if pileup simulation on in DigitizerSpec
4646
bool mApplyDigitization = true; ///< if energy digitization should be applied
47-
//float mZSthreshold = 0.01; ///< Zero Suppression threshold
48-
float mZSnSigmas = 3.; ///< Zero Suppression threshold
49-
//float mADCWidth = 0.005; ///< Widht of ADC channel used for energy digitization
50-
//float mNoise = 0.01; ///< charge noise in one pad
51-
//float mCoeffToNanoSecond = 1.e+9; ///< Conversion for time units
52-
float mSortingDelta = 0.1; ///< used in sorting clusters inverse sorting band in cm
47+
float mZSnSigmas = 3.; ///< Zero Suppression threshold
48+
float mSortingDelta = 0.1; ///< used in sorting clusters inverse sorting band in cm
5349

5450
//Parameters used in clusterization
5551
//float mDigitMinEnergy = 0.01; ///< Minimal amplitude of a digit to be used in cluster

Detectors/CPV/calib/include/CPVCalibration/PedestalCalibrator.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ class PedestalSpectrum
3333
~PedestalSpectrum() = default;
3434
PedestalSpectrum& operator+=(const PedestalSpectrum& rhs);
3535
void fill(uint16_t amplitude);
36-
uint8_t getNPeaks();
37-
float getPeakMean(uint8_t iPeak = -1); // return mean value of i-th peak. if iPeak = -1 then return total mean
38-
float getPeakRMS(uint8_t iPeak = -1); // return RMS value of i-th peak. if iPeak = -1 then return total RMS
39-
float getPedestalValue(); // return final decision for pedestal value
40-
float getPedestalRMS(); // return final decision for pedestal RMS
36+
uint16_t getNPeaks();
37+
float getPeakMean(uint16_t iPeak); // return mean value of i-th peak
38+
float getPeakRMS(uint16_t iPeak); // return RMS value of i-th peak
39+
float getPedestalValue(); // return final decision for pedestal value
40+
float getPedestalRMS(); // return final decision for pedestal RMS
4141
uint32_t getNEntries() { return mNEntries; }
4242

4343
private:
4444
void analyze();
4545
uint32_t mNEntries = 0;
46-
uint8_t mNPeaks = 0;
46+
uint16_t mNPeaks = 0;
4747
bool mIsAnalyzed = false;
4848
uint16_t mToleratedGapWidth = 5;
4949
float mZSnSigmas = 3.;
50-
float mSuspiciousPedestalRMS = 10.;
50+
float mSuspiciousPedestalRMS = 20.;
5151
float mPedestalValue;
5252
float mPedestalRMS;
5353
std::vector<float> mMeanOfPeaks, mRMSOfPeaks;
@@ -76,8 +76,17 @@ class PedestalCalibrator final : public o2::calibration::TimeSlotCalibration<o2:
7676
public:
7777
PedestalCalibrator();
7878
~PedestalCalibrator() final = default;
79-
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoVector() { return mCcdbInfoVec; }
79+
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoPedestalsVector() { return mCcdbInfoPedestalsVec; }
8080
std::vector<o2::cpv::Pedestals> getPedestalsVector() { return mPedestalsVec; }
81+
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoThresholdsFEEVector() { return mCcdbInfoThresholdsFEEVec; }
82+
std::vector<std::vector<int>> getThresholdsFEEVector() { return mThresholdsFEEVec; }
83+
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoDeadChannelsVector() { return mCcdbInfoDeadChannelsVec; }
84+
std::vector<std::vector<int>> getDeadChannelsVector() { return mDeadChannelsVec; }
85+
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoHighPedChannelsVector() { return mCcdbInfoHighPedChannelsVec; }
86+
std::vector<std::vector<int>> getHighPedChannelsVector() { return mHighPedChannelsVec; }
87+
std::vector<o2::ccdb::CcdbObjectInfo> getCcdbInfoEfficienciesVector() { return mCcdbInfoPedEfficienciesVec; }
88+
std::vector<std::vector<float>> getEfficienciesVector() { return mPedEfficienciesVec; }
89+
8190
bool hasEnoughData(const TimeSlot& slot) const final
8291
{
8392
LOG(INFO) << "hasEnoughData() is being called";
@@ -89,8 +98,17 @@ class PedestalCalibrator final : public o2::calibration::TimeSlotCalibration<o2:
8998

9099
private:
91100
int mMinEvents = 100;
92-
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoVec;
101+
float mZSnSigmas = 3.;
102+
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoPedestalsVec;
93103
std::vector<o2::cpv::Pedestals> mPedestalsVec;
104+
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoThresholdsFEEVec;
105+
std::vector<std::vector<int>> mThresholdsFEEVec;
106+
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoDeadChannelsVec;
107+
std::vector<std::vector<int>> mDeadChannelsVec;
108+
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoHighPedChannelsVec;
109+
std::vector<std::vector<int>> mHighPedChannelsVec;
110+
std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoPedEfficienciesVec;
111+
std::vector<std::vector<float>> mPedEfficienciesVec;
94112
};
95113
} //end namespace cpv
96114
} //end namespace o2
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#if !defined(__CLING__) || defined(__ROOTCLING__)
2+
#include "CCDB/BasicCCDBManager.h"
3+
#include "TH2F.h"
4+
#include "TH1F.h"
5+
#include "CCDB/CCDBTimeStampUtils.h"
6+
#include "CPVBase/Geometry.h"
7+
#endif
8+
9+
void readPedEfficienciesFromCCDB(const char* ccdbURI = "http://ccdb-test.cern.ch:8080", long timeStamp = 0)
10+
{
11+
// ccdbURI -> CCDB instance
12+
// timeStamp -> time in milliseconds (wow!) (starting at 00:00 on 1.1.1970)
13+
// timeStamp == 0 -> current time
14+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
15+
ccdbMgr.setURL(ccdbURI);
16+
if (!ccdbMgr.isHostReachable()) {
17+
std::cerr << ccdbURI << " is not reachable!" << std::endl;
18+
return;
19+
}
20+
if (timeStamp == 0) {
21+
timeStamp = o2::ccdb::getCurrentTimestamp();
22+
}
23+
ccdbMgr.setTimestamp(timeStamp);
24+
std::vector<float>* effs = ccdbMgr.get<std::vector<float>>("CPV/PedestalRun/ChannelEfficiencies");
25+
if (!effs) {
26+
std::cerr << "Cannot get FEE thresholds from CCDB/CPV/PedestalRun/ChannelEfficiencies!" << std::endl;
27+
return;
28+
}
29+
30+
TH2F* hEfficiencies[3];
31+
o2::cpv::Geometry geo;
32+
short relId[3];
33+
for (int iMod = 0; iMod < 3; iMod++) {
34+
hEfficiencies[iMod] = new TH2F(Form("hEfficienciesM%d", iMod + 2),
35+
Form("Channel efficiencies in M%d", iMod + 2),
36+
128, 0., 128., 60, 0., 60);
37+
for (int iCh = iMod * 7680; iCh < (iMod + 1) * 7680; iCh++) {
38+
geo.absToRelNumbering(iCh, relId);
39+
hEfficiencies[iMod]->SetBinContent(relId[1] + 1, relId[2] + 1, effs->at(iCh));
40+
}
41+
TCanvas* can = new TCanvas(Form("canM%d", iMod + 2), Form("module M%d", iMod + 2), 10 * iMod, 0, 1000 + 10 * iMod, 1000);
42+
can->Divide(1, 1);
43+
can->cd(1);
44+
hEfficiencies[iMod]->Draw("colz");
45+
}
46+
}

Detectors/CPV/calib/macros/readPedestalsFromCCDB.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <fstream>
1212
#endif
1313

14-
o2::cpv::Pedestals* readPedestalsFromCCDB(long timeStamp = 0, const char* ccdbURI = "http://ccdb-test.cern.ch:8080")
14+
o2::cpv::Pedestals* readPedestalsFromCCDB(const char* ccdbURI = "http://ccdb-test.cern.ch:8080", long timeStamp = 0)
1515
{
1616
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
1717
ccdbMgr.setURL(ccdbURI);
@@ -77,7 +77,7 @@ o2::cpv::Pedestals* readPedestalsFromCCDB(long timeStamp = 0, const char* ccdbUR
7777
}
7878
short ccId, dil, gas, pad;
7979
geo.absIdToHWaddress(iCh, ccId, dil, gas, pad);
80-
unsigned short addr = ccId * 4 * 5 * 48 + dil * 5 * 48 + gas * 48 + pad;
80+
unsigned short addr = ccId * 4 * 5 * 64 + dil * 5 * 64 + gas * 64 + pad;
8181
pededstalsTxt << addr << " " << threshold << std::endl;
8282
}
8383
pededstalsTxt.close();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#if !defined(__CLING__) || defined(__ROOTCLING__)
2+
#include "CCDB/BasicCCDBManager.h"
3+
#include "TH2F.h"
4+
#include "TH1F.h"
5+
#include "CCDB/CCDBTimeStampUtils.h"
6+
#include "CPVBase/Geometry.h"
7+
#endif
8+
9+
void readThresholdsFEEFromCCDB(const char* ccdbURI = "http://ccdb-test.cern.ch:8080", long timeStamp = 0)
10+
{
11+
// ccdbURI -> CCDB instance
12+
// timeStamp -> time in milliseconds (wow!) (starting at 00:00 on 1.1.1970)
13+
// timeStamp == 0 -> current time
14+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
15+
ccdbMgr.setURL(ccdbURI);
16+
if (!ccdbMgr.isHostReachable()) {
17+
std::cerr << ccdbURI << " is not reachable!" << std::endl;
18+
return;
19+
}
20+
if (timeStamp == 0) {
21+
timeStamp = o2::ccdb::getCurrentTimestamp();
22+
}
23+
ccdbMgr.setTimestamp(timeStamp);
24+
std::vector<int>* thrs = ccdbMgr.get<std::vector<int>>("CPV/PedestalRun/FEEThresholds");
25+
if (!thrs) {
26+
std::cerr << "Cannot get FEE thresholds from CCDB/CPV/PedestalRun/FEEThresholds!" << std::endl;
27+
return;
28+
}
29+
30+
TH2I* hThresholdsValues[3];
31+
o2::cpv::Geometry geo;
32+
short relId[3];
33+
std::ofstream pededstalsTxt;
34+
pededstalsTxt.open("pedestals.txt");
35+
for (int iMod = 0; iMod < 3; iMod++) {
36+
hThresholdsValues[iMod] = new TH2I(Form("hThresholdsM%d", iMod + 2),
37+
Form("Threshold values in M%d", iMod + 2),
38+
128, 0., 128., 60, 0., 60);
39+
for (int iCh = iMod * 7680; iCh < (iMod + 1) * 7680; iCh++) {
40+
geo.absToRelNumbering(iCh, relId);
41+
hThresholdsValues[iMod]->SetBinContent(relId[1] + 1, relId[2] + 1, thrs->at(iCh) & 0xffff);
42+
pededstalsTxt << (thrs->at(iCh) >> 16) << " " << (thrs->at(iCh) & 0xffff) << std::endl;
43+
}
44+
TCanvas* can = new TCanvas(Form("canM%d", iMod + 2), Form("module M%d", iMod + 2), 10 * iMod, 0, 1000 + 10 * iMod, 1000);
45+
can->Divide(1, 1);
46+
can->cd(1);
47+
hThresholdsValues[iMod]->Draw("colz");
48+
}
49+
pededstalsTxt.close();
50+
}

0 commit comments

Comments
 (0)