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
2624namespace itsmft
2725{
2826
27+ class NoiseMap ;
28+
2929class 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:
0 commit comments