Project
Loading...
Searching...
No Matches
TimeDeadMap.cxx
Go to the documentation of this file.
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
14
17#include "Framework/Logger.h"
18
19using namespace o2::itsmft;
20
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
38void 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
77std::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
85long 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}
uint64_t orbit
Definition RawEventData.h:6
Definition of the ITSMFT NoiseMap.
Definition of the ITSMFT time-dependend dead map.
NoiseMap class for the ITS and MFT.
Definition NoiseMap.h:39
void maskFullChip(int chip, bool cleanNoisyPixels=false)
Definition NoiseMap.h:178
long getMapAtOrbit(unsigned long orbit, std::vector< uint16_t > &mmap) const
std::vector< unsigned long > getEvolvingMapKeys() const
void decodeMap(NoiseMap &noisemap) const
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"