Skip to content

Commit ecb7932

Browse files
committed
Move bulk of the code to cxx to not expose extra headers
1 parent fa3dd7b commit ecb7932

File tree

3 files changed

+113
-91
lines changed

3 files changed

+113
-91
lines changed

DataFormats/Detectors/ITSMFT/common/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ o2_add_library(DataFormatsITSMFT
1818
src/ClusterPattern.cxx
1919
src/ClusterTopology.cxx
2020
src/TopologyDictionary.cxx
21+
src/TimeDeadMap.cxx
2122
src/CTF.cxx
2223
PUBLIC_LINK_LIBRARIES O2::ITSMFTBase
2324
O2::ReconstructionDataFormats
2425
Microsoft.GSL::GSL)
2526

2627
o2_target_root_dictionary(DataFormatsITSMFT
2728
HEADERS include/DataFormatsITSMFT/ROFRecord.h
28-
include/DataFormatsITSMFT/Digit.h
29-
include/DataFormatsITSMFT/GBTCalibData.h
30-
include/DataFormatsITSMFT/NoiseMap.h
31-
include/DataFormatsITSMFT/TimeDeadMap.h
29+
include/DataFormatsITSMFT/Digit.h
30+
include/DataFormatsITSMFT/GBTCalibData.h
31+
include/DataFormatsITSMFT/NoiseMap.h
32+
include/DataFormatsITSMFT/TimeDeadMap.h
3233
include/DataFormatsITSMFT/Cluster.h
3334
include/DataFormatsITSMFT/CompCluster.h
3435
include/DataFormatsITSMFT/ClusterPattern.h

DataFormats/Detectors/ITSMFT/common/include/DataFormatsITSMFT/TimeDeadMap.h

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#define ALICEO2_ITSMFT_TIMEDEADMAP_H
1616

1717
#include "Rtypes.h"
18-
#include "DetectorsCommonDataFormats/DetID.h"
19-
#include <iostream>
2018
#include <vector>
2119
#include <map>
2220

@@ -26,6 +24,8 @@ namespace o2
2624
namespace itsmft
2725
{
2826

27+
class NoiseMap;
28+
2929
class TimeDeadMap
3030
{
3131
public:
@@ -56,96 +56,17 @@ class TimeDeadMap
5656
mStaticDeadMap.clear();
5757
}
5858

59-
void decodeMap(o2::itsmft::NoiseMap& noisemap)
60-
{ // for static part only
61-
if (mMAP_VERSION == "3") {
62-
LOG(error) << "Trying to decode static part of deadmap version " << mMAP_VERSION << ". Not implemented, doing nothing.";
63-
return;
64-
}
65-
for (int iel = 0; iel < mStaticDeadMap.size(); iel++) {
66-
uint16_t w = mStaticDeadMap[iel];
67-
noisemap.maskFullChip(w & 0x7FFF);
68-
if (w & 0x8000) {
69-
for (int w2 = (w & 0x7FFF) + 1; w2 < mStaticDeadMap.at(iel + 1); w2++) {
70-
noisemap.maskFullChip(w2);
71-
}
72-
}
73-
}
74-
}
75-
76-
void decodeMap(unsigned long orbit, o2::itsmft::NoiseMap& noisemap, bool includeStaticMap = true, long orbitGapAllowed = 330000)
77-
{ // for time-dependent and (optionally) static part. Use orbitGapAllowed = -1 to ignore check on orbit difference
78-
79-
if (mMAP_VERSION != "3" && mMAP_VERSION != "4") {
80-
LOG(error) << "Trying to decode time-dependent deadmap version " << mMAP_VERSION << ". Not implemented, doing nothing.";
81-
return;
82-
}
83-
84-
if (mEvolvingDeadMap.empty()) {
85-
LOG(warning) << "Time-dependent dead map is empty. Doing nothing.";
86-
return;
87-
}
88-
89-
std::vector<uint16_t> closestVec;
90-
long dT = getMapAtOrbit(orbit, closestVec);
91-
92-
if (orbitGapAllowed >= 0 && std::abs(dT) > orbitGapAllowed) {
93-
LOG(warning) << "Requested orbit " << orbit << ", found " << orbit - dT << ". Orbit gap is too high, skipping time-dependent map.";
94-
closestVec.clear();
95-
}
96-
97-
// add static part if requested. something may be masked twice
98-
if (includeStaticMap && mMAP_VERSION != "3") {
99-
closestVec.insert(closestVec.end(), mStaticDeadMap.begin(), mStaticDeadMap.end());
100-
}
101-
102-
// vector encoding: if 1<<15 = 0x8000 is set, the word encodes the first element of a range, with mask (1<<15)-1 = 0x7FFF. The last element of the range is the next in the vector.
103-
104-
for (int iel = 0; iel < closestVec.size(); iel++) {
105-
uint16_t w = closestVec.at(iel);
106-
noisemap.maskFullChip(w & 0x7FFF);
107-
if (w & 0x8000) {
108-
for (int w2 = (w & 0x7FFF) + 1; w2 < closestVec.at(iel + 1); w2++) {
109-
noisemap.maskFullChip(w2);
110-
}
111-
}
112-
}
113-
};
114-
59+
void decodeMap(NoiseMap& noisemap) const;
60+
void decodeMap(unsigned long orbit, o2::itsmft::NoiseMap& noisemap, bool includeStaticMap = true, long orbitGapAllowed = 330000) const;
11561
std::string getMapVersion() const { return mMAP_VERSION; };
11662

11763
unsigned long getEvolvingMapSize() const { return mEvolvingDeadMap.size(); };
118-
119-
std::vector<unsigned long> getEvolvingMapKeys()
120-
{
121-
std::vector<unsigned long> keys;
122-
std::transform(mEvolvingDeadMap.begin(), mEvolvingDeadMap.end(), std::back_inserter(keys),
123-
[](const auto& O) { return O.first; });
124-
return keys;
125-
}
126-
127-
void getStaticMap(std::vector<uint16_t>& mmap) { mmap = mStaticDeadMap; };
128-
129-
long getMapAtOrbit(unsigned long orbit, std::vector<uint16_t>& mmap)
130-
{ // fills mmap and returns requested_orbit - found_orbit. Found orbit is the highest key lower or equal to the requested one
131-
if (mEvolvingDeadMap.empty()) {
132-
LOG(warning) << "Requested orbit " << orbit << "from an empty time-dependent map. Doing nothing";
133-
return (long)orbit;
134-
}
135-
auto closest = mEvolvingDeadMap.upper_bound(orbit);
136-
if (closest != mEvolvingDeadMap.begin()) {
137-
--closest;
138-
mmap = closest->second;
139-
return (long)orbit - closest->first;
140-
} else {
141-
mmap = mEvolvingDeadMap.begin()->second;
142-
return (long)(orbit)-mEvolvingDeadMap.begin()->first;
143-
}
144-
}
145-
64+
std::vector<unsigned long> getEvolvingMapKeys() const;
65+
void getStaticMap(std::vector<uint16_t>& mmap) const { mmap = mStaticDeadMap; };
66+
long getMapAtOrbit(unsigned long orbit, std::vector<uint16_t>& mmap) const;
14667
void setMapVersion(std::string version) { mMAP_VERSION = version; };
14768

148-
bool isDefault() { return mIsDefaultObject; };
69+
bool isDefault() const { return mIsDefaultObject; };
14970
void setAsDefault(bool isdef = true) { mIsDefaultObject = isdef; };
15071

15172
private:
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file TimeDeadMap.cxx
13+
/// \brief Implementation of the time-dependent map
14+
15+
#include "DataFormatsITSMFT/TimeDeadMap.h"
16+
#include "DataFormatsITSMFT/NoiseMap.h"
17+
#include "Framework/Logger.h"
18+
19+
using namespace o2::itsmft;
20+
21+
void TimeDeadMap::decodeMap(o2::itsmft::NoiseMap& noisemap) const
22+
{ // for static part only
23+
if (mMAP_VERSION == "3") {
24+
LOG(error) << "Trying to decode static part of deadmap version " << mMAP_VERSION << ". Not implemented, doing nothing.";
25+
return;
26+
}
27+
for (int iel = 0; iel < mStaticDeadMap.size(); iel++) {
28+
uint16_t w = mStaticDeadMap[iel];
29+
noisemap.maskFullChip(w & 0x7FFF);
30+
if (w & 0x8000) {
31+
for (int w2 = (w & 0x7FFF) + 1; w2 < mStaticDeadMap.at(iel + 1); w2++) {
32+
noisemap.maskFullChip(w2);
33+
}
34+
}
35+
}
36+
}
37+
38+
void TimeDeadMap::decodeMap(unsigned long orbit, o2::itsmft::NoiseMap& noisemap, bool includeStaticMap, long orbitGapAllowed) const
39+
{ // for time-dependent and (optionally) static part. Use orbitGapAllowed = -1 to ignore check on orbit difference
40+
41+
if (mMAP_VERSION != "3" && mMAP_VERSION != "4") {
42+
LOG(error) << "Trying to decode time-dependent deadmap version " << mMAP_VERSION << ". Not implemented, doing nothing.";
43+
return;
44+
}
45+
46+
if (mEvolvingDeadMap.empty()) {
47+
LOG(warning) << "Time-dependent dead map is empty. Doing nothing.";
48+
return;
49+
}
50+
51+
std::vector<uint16_t> closestVec;
52+
long dT = getMapAtOrbit(orbit, closestVec);
53+
54+
if (orbitGapAllowed >= 0 && std::abs(dT) > orbitGapAllowed) {
55+
LOG(warning) << "Requested orbit " << orbit << ", found " << orbit - dT << ". Orbit gap is too high, skipping time-dependent map.";
56+
closestVec.clear();
57+
}
58+
59+
// add static part if requested. something may be masked twice
60+
if (includeStaticMap && mMAP_VERSION != "3") {
61+
closestVec.insert(closestVec.end(), mStaticDeadMap.begin(), mStaticDeadMap.end());
62+
}
63+
64+
// vector encoding: if 1<<15 = 0x8000 is set, the word encodes the first element of a range, with mask (1<<15)-1 = 0x7FFF. The last element of the range is the next in the vector.
65+
66+
for (int iel = 0; iel < closestVec.size(); iel++) {
67+
uint16_t w = closestVec.at(iel);
68+
noisemap.maskFullChip(w & 0x7FFF);
69+
if (w & 0x8000) {
70+
for (int w2 = (w & 0x7FFF) + 1; w2 < closestVec.at(iel + 1); w2++) {
71+
noisemap.maskFullChip(w2);
72+
}
73+
}
74+
}
75+
}
76+
77+
std::vector<unsigned long> TimeDeadMap::getEvolvingMapKeys() const
78+
{
79+
std::vector<unsigned long> keys;
80+
std::transform(mEvolvingDeadMap.begin(), mEvolvingDeadMap.end(), std::back_inserter(keys),
81+
[](const auto& O) { return O.first; });
82+
return keys;
83+
}
84+
85+
long TimeDeadMap::getMapAtOrbit(unsigned long orbit, std::vector<uint16_t>& mmap) const
86+
{ // fills mmap and returns requested_orbit - found_orbit. Found orbit is the highest key lower or equal to the requested one
87+
if (mEvolvingDeadMap.empty()) {
88+
LOG(warning) << "Requested orbit " << orbit << "from an empty time-dependent map. Doing nothing";
89+
return (long)orbit;
90+
}
91+
auto closest = mEvolvingDeadMap.upper_bound(orbit);
92+
if (closest != mEvolvingDeadMap.begin()) {
93+
--closest;
94+
mmap = closest->second;
95+
return (long)orbit - closest->first;
96+
} else {
97+
mmap = mEvolvingDeadMap.begin()->second;
98+
return (long)(orbit)-mEvolvingDeadMap.begin()->first;
99+
}
100+
}

0 commit comments

Comments
 (0)