Project
Loading...
Searching...
No Matches
CRU.h
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
12#ifndef AliceO2_TPC_CRU_H
13#define AliceO2_TPC_CRU_H
14
15#include "DataFormatsTPC/Defs.h"
16#include "TPCBase/Sector.h"
17#include "TPCBase/ROC.h"
18
19namespace o2
20{
21namespace tpc
22{
23// enum RocType {ICRU=0, OCRU=1};
24
25class CRU
26{
27 public:
28 enum { CRUperPartition = 2,
31 MaxCRU = 360 };
32 CRU() = default;
33 CRU(unsigned short cru) : mCRU(cru % MaxCRU) {}
34 CRU(const CRU& cru) : mCRU(cru.mCRU) {}
35 CRU(const Sector& sec, const unsigned char regionNum) : mCRU(sec.getSector() * CRUperSector + regionNum) {}
36 // CRU(RocType t, Side s, unsigned char r):mCRU( (s==Side::A)*18 + (t==RocType::OCRU)*18 + r%18 ) {}
37 // CRU(Side t) {}
38
40 {
41 mCRU = other.mCRU;
42 return *this;
43 }
44 CRU& operator=(const unsigned short cru)
45 {
46 mCRU = cru;
47 return *this;
48 }
49
50 bool operator==(const CRU& other) const { return mCRU == other.mCRU; }
51 bool operator!=(const CRU& other) const { return mCRU != other.mCRU; }
52 bool operator<(const CRU& other) const { return mCRU < other.mCRU; }
54 {
55 mLoop = ++mCRU >= MaxCRU;
56 mCRU %= MaxCRU;
57 return mLoop;
58 }
59
60 unsigned short number() const { return mCRU; }
61 const ROC roc() const { return ROC(sector(), rocType()); }
62 Side side() const { return (mCRU < (MaxCRU / SIDES)) ? Side::A : Side::C; }
63 unsigned char partition() const { return (mCRU % CRUperSector) / CRUperPartition; }
64 unsigned char region() const { return (mCRU % CRUperSector); }
65 const Sector sector() const { return Sector(mCRU / CRUperSector); }
67 bool isIROC() const { return mCRU % CRUperSector < CRUperIROC; }
68 bool isOROC() const { return mCRU % CRUperSector >= CRUperIROC; }
69 GEMstack gemStack() const;
70
73 operator int() const { return int(mCRU); }
74
75 bool looped() const { return mLoop; }
76
77 private:
78 unsigned short mCRU{};
79 bool mLoop{};
80};
81
82inline GEMstack CRU::gemStack() const
83{
84 const int reg = int(region());
85
86 if (reg < CRUperIROC) {
87 return GEMstack::IROCgem;
88 } else if (reg - CRUperIROC < CRUperPartition) {
89 return GEMstack::OROC1gem;
90 } else if (reg - CRUperIROC - CRUperPartition < CRUperPartition) {
91 return GEMstack::OROC2gem;
92 } else {
93 return GEMstack::OROC3gem;
94 }
95}
96} // namespace tpc
97} // namespace o2
98
99#endif
CRU & operator=(const unsigned short cru)
Definition CRU.h:44
unsigned char region() const
Definition CRU.h:64
GEMstack gemStack() const
Definition CRU.h:82
CRU(const CRU &cru)
Definition CRU.h:34
bool isOROC() const
Definition CRU.h:68
CRU & operator=(const CRU &other)
Definition CRU.h:39
CRU()=default
unsigned short number() const
Definition CRU.h:60
@ CRUperIROC
Definition CRU.h:29
@ CRUperSector
Definition CRU.h:30
@ MaxCRU
Definition CRU.h:31
@ CRUperPartition
Definition CRU.h:28
Side side() const
Definition CRU.h:62
bool operator==(const CRU &other) const
Definition CRU.h:50
bool looped() const
Definition CRU.h:75
bool operator!=(const CRU &other) const
Definition CRU.h:51
CRU(unsigned short cru)
Definition CRU.h:33
bool operator++()
Definition CRU.h:53
bool isIROC() const
Definition CRU.h:67
const Sector sector() const
Definition CRU.h:65
RocType rocType() const
Definition CRU.h:66
bool operator<(const CRU &other) const
Definition CRU.h:52
const ROC roc() const
Definition CRU.h:61
CRU(const Sector &sec, const unsigned char regionNum)
Definition CRU.h:35
unsigned char partition() const
Definition CRU.h:63
GEMstack
TPC GEM stack types.
Definition Defs.h:53
@ IROCgem
Definition Defs.h:53
@ OROC1gem
Definition Defs.h:54
@ OROC3gem
Definition Defs.h:56
@ OROC2gem
Definition Defs.h:55
RocType
TPC ROC types.
Definition Defs.h:48
@ OROC
Definition Defs.h:49
@ IROC
Definition Defs.h:48
constexpr unsigned char SIDES
Definition Defs.h:41
Side
TPC readout sidE.
Definition Defs.h:35
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other