Skip to content

Commit bc080b9

Browse files
authored
Merge pull request #7424 from sevdokim/cpv-fix-cluster-packing-to-ctf
CPV: fix in cluster to ctf packing
1 parent ccf0ec1 commit bc080b9

File tree

4 files changed

+100
-8
lines changed

4 files changed

+100
-8
lines changed

DataFormats/Detectors/CPV/include/DataFormatsCPV/Cluster.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define ALICEO2_CPV_CLUSTER_H_
1414

1515
#include "DataFormatsCPV/Digit.h"
16+
#include <cmath>
1617

1718
namespace o2
1819
{
@@ -26,7 +27,7 @@ constexpr float kMinX = -72.32; // Minimal coordinate in X direction
2627
constexpr float kStepX = 0.0025; // digitization step in X direction
2728
constexpr float kMinZ = -63.3; // Minimal coordinate in Z direction
2829
constexpr float kStepZ = 0.002; // digitization step in Z direction
29-
constexpr float kStepE = 1.; // Amplitude digitization step
30+
constexpr float kStepE = 0.036; // Amplitude digitization parameter
3031

3132
class Cluster
3233
{
@@ -80,22 +81,22 @@ class Cluster
8081
uint16_t getPackedPosZ() const { return uint16_t((mLocalPosZ - kMinZ) / kStepZ); }
8182
void setPackedPosZ(uint16_t v) { mLocalPosZ = kMinZ + kStepZ * v; }
8283

83-
uint8_t getPackedEnergy() const { return uint8_t(std::min(255, int(mEnergy / kStepE))); }
84-
void setPackedEnergy(uint16_t v) { mEnergy = v * kStepE; }
84+
uint8_t getPackedEnergy() const { return uint8_t(std::min(255, int((mEnergy > 100.) ? (log(mEnergy - 63.) / kStepE) : mEnergy))); }
85+
void setPackedEnergy(uint8_t v) { mEnergy = ((v > 100) ? (exp(kStepE * v) + 63.) : (v * 1.)); }
8586

8687
uint8_t getPackedClusterStatus() const
8788
{
8889
CluStatus s = {0};
8990
s.multiplicity = std::min(mMulDigit, static_cast<unsigned char>(31)); //5 bits available
90-
s.module = mModule;
91+
s.module = mModule - 2;
9192
s.unfolded = mNExMax > 1;
9293
return s.mBits;
9394
}
9495
void setPackedClusterStatus(uint8_t v)
9596
{
9697
CluStatus s = {v};
9798
mMulDigit = s.multiplicity;
98-
mModule = s.module;
99+
mModule = s.module + 2;
99100
mNExMax = s.unfolded ? 1 : 2;
100101
}
101102

Detectors/CPV/calib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ if(BUILD_TESTING)
4343
PUBLIC_LINK_LIBRARIES O2::CCDB O2::CPVBase
4444
LABELS CPV COMPILE_ONLY)
4545

46+
o2_add_test_root_macro(macros/makeBadMapFromPedestalRun.C
47+
PUBLIC_LINK_LIBRARIES O2::CCDB O2::CPVBase O2::DataFormatsCPV
48+
LABELS CPV COMPILE_ONLY)
49+
4650
o2_add_test_root_macro(macros/PostBadMapCCDB.C
4751
PUBLIC_LINK_LIBRARIES O2::CCDB O2::DataFormatsCPV
4852
LABELS CPV COMPILE_ONLY)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#if !defined(__CLING__) || defined(__ROOTCLING__)
2+
#include "CCDB/BasicCCDBManager.h"
3+
#include "TH2I.h"
4+
#include "TCanvas.h"
5+
#include "CCDB/CCDBTimeStampUtils.h"
6+
#include "CPVBase/Geometry.h"
7+
#include "DataFormatsCPV/BadChannelMap.h"
8+
#endif
9+
10+
void makeBadMapFromPedestalRun(const char* ccdbURI = "http://ccdb-test.cern.ch:8080", long timeStamp = 0)
11+
{
12+
// ccdbURI -> CCDB instance
13+
// timeStamp -> time in milliseconds (wow!) (starting at 00:00 on 1.1.1970)
14+
// timeStamp == 0 -> current time
15+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
16+
ccdbMgr.setURL(ccdbURI);
17+
if (!ccdbMgr.isHostReachable()) {
18+
std::cerr << ccdbURI << " is not reachable!" << std::endl;
19+
return;
20+
}
21+
if (timeStamp == 0) {
22+
timeStamp = o2::ccdb::getCurrentTimestamp();
23+
}
24+
ccdbMgr.setTimestamp(timeStamp);
25+
std::vector<float>* effs = ccdbMgr.get<std::vector<float>>("CPV/PedestalRun/ChannelEfficiencies");
26+
if (!effs) {
27+
std::cerr << "Cannot get Efficiencies from CCDB/CPV/PedestalRun/ChannelEfficiencies!" << std::endl;
28+
}
29+
30+
std::vector<int>* dead = ccdbMgr.get<std::vector<int>>("CPV/PedestalRun/DeadChannels");
31+
if (!dead) {
32+
std::cerr << "Cannot get dead channels from CCDB/CPV/PedestalRun/DeadChannels!" << std::endl;
33+
}
34+
35+
std::vector<int>* highPed = ccdbMgr.get<std::vector<int>>("CPV/PedestalRun/HighPedChannels");
36+
if (!highPed) {
37+
std::cerr << "Cannot get high ped channels from CCDB/CPV/PedestalRun/HighPedChannels!" << std::endl;
38+
}
39+
40+
bool badMapBool[23040] = {false};
41+
for (int i = 0; i < 23040; i++) {
42+
badMapBool[i] = false;
43+
if (effs->at(i) > 1.1) {
44+
badMapBool[i] = true;
45+
}
46+
}
47+
48+
for (int i = 0; i < dead->size(); i++) {
49+
badMapBool[dead->at(i)] = true;
50+
}
51+
52+
for (int i = 0; i < highPed->size(); i++) {
53+
badMapBool[highPed->at(i)] = true;
54+
}
55+
56+
o2::cpv::Geometry geo;
57+
short relId[3];
58+
o2::cpv::BadChannelMap badMap(1);
59+
TH2I* hBadMap[3];
60+
for (int iMod = 0; iMod < 3; iMod++) {
61+
hBadMap[iMod] = new TH2I(Form("hBadMapM%d", iMod + 2),
62+
Form("Bad channels in M%d", iMod + 2),
63+
128, 0., 128., 60, 0., 60);
64+
for (int iCh = iMod * 7680; iCh < (iMod + 1) * 7680; iCh++) {
65+
if (badMapBool[iCh]) {
66+
geo.absToRelNumbering(iCh, relId);
67+
hBadMap[iMod]->SetBinContent(relId[1] + 1, relId[2] + 1, 1);
68+
badMap.addBadChannel(iCh);
69+
}
70+
}
71+
TCanvas* can = new TCanvas(Form("canM%d", iMod + 2), Form("module M%d", iMod + 2), 10 * iMod, 0, 1000 + 10 * iMod, 1000);
72+
can->Divide(1, 1);
73+
can->cd(1);
74+
hBadMap[iMod]->Draw("colz");
75+
}
76+
77+
o2::ccdb::CcdbApi api;
78+
map<string, string> metadata; // can be empty
79+
api.init(ccdbURI); // or http://localhost:8080 for a local installation
80+
api.storeAsTFileAny(&badMap, "CPV/Calib/BadChannelMap", metadata, timeStamp, timeStamp + 31536000000);
81+
}

Detectors/CTF/test/test_ctf_io_cpv.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "DetectorsCommonDataFormats/NameConf.h"
1717
#include "CPVReconstruction/CTFCoder.h"
1818
#include "DataFormatsCPV/CTF.h"
19+
#include "DataFormatsCPV/Cluster.h"
1920
#include "Framework/Logger.h"
2021
#include <TFile.h>
2122
#include <TRandom.h>
@@ -40,11 +41,11 @@ BOOST_AUTO_TEST_CASE(CTFTest)
4041
int n = 1 + gRandom->Poisson(100);
4142
for (int i = n; i--;) {
4243
char mult = gRandom->Integer(30);
43-
char mod = 1 + gRandom->Integer(3);
44+
char mod = 2 + gRandom->Integer(3); // there are M2, M3 and M4
4445
char exMax = gRandom->Integer(3);
4546
float x = 72.3 * 2. * (gRandom->Rndm() - 0.5);
4647
float z = 63.3 * 2. * (gRandom->Rndm() - 0.5);
47-
float e = 254. * gRandom->Rndm();
48+
float e = 10000. * gRandom->Rndm(); // we need high energy range
4849
clusters.emplace_back(mult, mod, exMax, x, z, e);
4950
}
5051
triggers.emplace_back(ir, start, clusters.size() - start);
@@ -118,7 +119,12 @@ BOOST_AUTO_TEST_CASE(CTFTest)
118119
const auto& cdc = clustersD[i];
119120
BOOST_CHECK(cor.getMultiplicity() == cdc.getMultiplicity());
120121
BOOST_CHECK(cor.getModule() == cdc.getModule());
121-
BOOST_CHECK(TMath::Abs(cor.getEnergy() - cdc.getEnergy()) < 1.);
122+
if (cor.getEnergy() < 100.) {
123+
BOOST_CHECK(TMath::Abs(cor.getEnergy() - cdc.getEnergy()) < 1.);
124+
} else {
125+
float eTr = cor.getEnergy();
126+
BOOST_CHECK(TMath::Abs(eTr - cdc.getEnergy()) <= eTr * (exp(kStepE * eTr) - 1.)); // increasing discretisation step size
127+
}
122128
float xCor, zCor, xCdc, zCdc;
123129
cor.getLocalPosition(xCor, zCor);
124130
cdc.getLocalPosition(xCdc, zCdc);

0 commit comments

Comments
 (0)