Skip to content

Commit 797d80e

Browse files
authored
HMPID_NewDigitStructure (#5795)
* Version * Fix C-Lang * Fix Coding conventions * Fix C-Lang 2 * @shahor02 requested changes 26/03/21 * fix clang * Fix bugs in Cluster place holders
1 parent c19bfc7 commit 797d80e

75 files changed

Lines changed: 3215 additions & 2063 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DataFormats/Detectors/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_subdirectory(ITSMFT)
1616
add_subdirectory(MUON)
1717
add_subdirectory(TOF)
1818
add_subdirectory(FIT)
19+
add_subdirectory(HMPID)
1920
add_subdirectory(EMCAL)
2021
add_subdirectory(ZDC)
2122
add_subdirectory(TRD)

DataFormats/Detectors/HMPID/CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11-
# o2_add_library(DataFormatsHMP
12-
# SOURCES src/Cluster.cxx
13-
# PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
14-
# Boost::serialization)
11+
o2_add_library(DataFormatsHMP
12+
SOURCES src/Digit.cxx src/Cluster.cxx src/Trigger.cxx
13+
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
14+
O2::HMPIDBase
15+
O2::CommonDataFormat
16+
O2::SimulationDataFormat)
1517

16-
# o2_target_root_dictionary(DataFormatsHMP
17-
# HEADERS include/DataFormatsHMP/DataFormat.h
18+
o2_target_root_dictionary(DataFormatsHMP
19+
HEADERS include/DataFormatsHMP/DataFormat.h
20+
include/DataFormatsHMP/Digit.h
21+
include/DataFormatsHMP/Trigger.h
22+
include/DataFormatsHMP/Cluster.h
23+
include/DataFormatsHMP/Hit.h)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_CLUSTER_H_
12+
#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_CLUSTER_H_
13+
14+
namespace o2
15+
{
16+
namespace hmpid
17+
{
18+
/// \class Cluster
19+
/// \brief HMPID cluster implementation
20+
class Cluster
21+
{
22+
public:
23+
Cluster() = default;
24+
25+
Cluster(int chamber, int size, int NlocMax, float QRaw, float Q, float X, float Y);
26+
~Cluster() = default;
27+
28+
int getCh() const { return mChamber; }
29+
void setCh(int chamber) { mChamber = chamber; }
30+
31+
int getSize() const { return mSize; }
32+
void setSize(int size) { mSize = size; }
33+
34+
int getQRaw() const { return mQRaw; }
35+
void setQRaw(int QRaw) { mQRaw = QRaw; }
36+
37+
int getQ() const { return mQ; }
38+
void setQ(int Q) { mQ = Q; }
39+
40+
int getX() const { return mX; }
41+
void setX(int X) { mX = X; }
42+
43+
int getY() const { return mY; }
44+
void setY(int Y) { mY = Y; }
45+
46+
protected:
47+
int mChamber; /// chamber number
48+
int mSize; /// size of the formed cluster from which this cluster deduced
49+
int mNlocMax; /// number of local maxima in formed cluster
50+
float mQRaw; /// QDC value of the raw cluster
51+
float mQ; /// QDC value of the actual cluster
52+
float mX; /// local x postion, [cm]
53+
float mY; /// local y postion, [cm]
54+
55+
ClassDefNV(Cluster, 1);
56+
};
57+
58+
} // namespace hmpid
59+
} // namespace o2
60+
61+
#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_CLUSTER_H_ */
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
///
12+
/// \file Digit.h
13+
/// \author Antonio Franco - INFN Bari
14+
/// \version 1.0
15+
/// \date 15/02/2021
16+
17+
// History
18+
// 10/03/2021 Complete review
19+
20+
#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_
21+
#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_
22+
23+
#include <iosfwd>
24+
#include <vector>
25+
#include "DataFormatsHMP/Hit.h" // for hit
26+
#include "HMPIDBase/Param.h" // for param
27+
28+
namespace o2
29+
{
30+
namespace hmpid
31+
{
32+
/// \class Digit
33+
/// \brief HMPID Digit declaration
34+
class Digit
35+
{
36+
public:
37+
// Coordinates Conversion Functions
38+
static inline uint32_t abs(int ch, int pc, int x, int y) { return ch << 24 | pc << 16 | x << 8 | y; }
39+
static inline int ddl2C(int ddl) { return ddl >> 1; } //ddl -> chamber
40+
static inline int a2C(uint32_t pad) { return (pad & 0xFF000000) >> 24; } //abs pad -> chamber
41+
static inline int a2P(uint32_t pad) { return (pad & 0x00FF0000) >> 16; } //abs pad -> pc
42+
static inline int a2X(uint32_t pad) { return (pad & 0x0000FF00) >> 8; } //abs pad -> pad X
43+
static inline int a2Y(uint32_t pad) { return (pad & 0x000000FF); } //abs pad -> pad Y
44+
static inline uint32_t photo2Pad(int ch, int pc, int x, int y) { return abs(ch, pc, x, y); }
45+
static uint32_t equipment2Pad(int Equi, int Colu, int Dilo, int Chan);
46+
static uint32_t absolute2Pad(int Module, int x, int y);
47+
static void pad2Equipment(uint32_t pad, int* Equi, int* Colu, int* Dilo, int* Chan);
48+
static void pad2Absolute(uint32_t pad, int* Module, int* x, int* y);
49+
static void pad2Photo(uint32_t pad, uint8_t* chamber, uint8_t* photo, uint8_t* x, uint8_t* y);
50+
static void absolute2Equipment(int Module, int x, int y, int* Equi, int* Colu, int* Dilo, int* Chan);
51+
static void equipment2Absolute(int Equi, int Colu, int Dilo, int Chan, int* Module, int* x, int* y);
52+
53+
// Trigger time Conversion Functions
54+
// static inline uint64_t orbitBcToEventId(uint32_t Orbit, uint16_t BC) { return ((Orbit << 12) | (0x0FFF & BC)); };
55+
// static inline uint32_t eventIdToOrbit(uint64_t EventId) { return (EventId >> 12); };
56+
// static inline uint16_t EventIdToBc(uint64_t EventId) { return (EventId & 0x0FFF); };
57+
// static double OrbitBcToTimeNs(uint32_t Orbit, uint16_t BC);
58+
// static uint32_t TimeNsToOrbit(double TimeNs);
59+
// static uint16_t TimeNsToBc(double TimeNs);
60+
// static void TimeNsToOrbitBc(double TimeNs, uint32_t& Orbit, uint16_t& Bc);
61+
62+
// Operators definition !
63+
friend inline bool operator<(const Digit& l, const Digit& r) { return l.getPadID() < r.getPadID(); };
64+
friend inline bool operator==(const Digit& l, const Digit& r) { return l.getPadID() == r.getPadID(); };
65+
friend inline bool operator>(const Digit& l, const Digit& r) { return r < l; };
66+
friend inline bool operator<=(const Digit& l, const Digit& r) { return !(l > r); };
67+
friend inline bool operator>=(const Digit& l, const Digit& r) { return !(l < r); };
68+
friend inline bool operator!=(const Digit& l, const Digit& r) { return !(l == r); };
69+
70+
friend std::ostream& operator<<(std::ostream& os, const Digit& d);
71+
72+
public:
73+
Digit() = default;
74+
Digit(int pad, uint16_t charge);
75+
Digit(int chamber, int photo, int x, int y, uint16_t charge);
76+
Digit(uint16_t charge, int equipment, int column, int dilogic, int channel);
77+
Digit(uint16_t charge, int module, int x, int y);
78+
79+
// Getter & Setters
80+
uint16_t getCharge() const { return mQ; }
81+
void setCharge(uint16_t Q)
82+
{
83+
mQ = Q;
84+
return;
85+
};
86+
int getPadID() const { return mCh << 24 | mPh << 16 | mX << 8 | mY; }
87+
void setPadID(uint32_t pad)
88+
{
89+
mCh = pad >> 24;
90+
mPh = (pad & 0x00FF0000) >> 16;
91+
mX = (pad & 0x0000FF00) >> 8;
92+
mY = (pad & 0x000000FF);
93+
return;
94+
};
95+
96+
bool isValid() { return (mCh == 0xFF ? true : false); };
97+
void setInvalid()
98+
{
99+
mCh = 0xFF;
100+
return;
101+
};
102+
103+
// // convenience wrapper function for conversion to x-y pad coordinates
104+
// int getPx() const { return A2X(mPad); }
105+
// int getPy() const { return A2Y(mPad); }
106+
// int getPhC() const { return A2P(mPad); }
107+
// int getCh() const { return A2C(mPad); }
108+
109+
// Charge management functions
110+
static void getPadAndTotalCharge(o2::hmpid::HitType const& hit, int& chamber, int& pc, int& px, int& py, float& totalcharge);
111+
static float getFractionalContributionForPad(o2::hmpid::HitType const& hit, int somepad);
112+
void addCharge(float q)
113+
{
114+
mQ += q;
115+
if (mQ > 0x0FFF) {
116+
mQ = 0x0FFF;
117+
}
118+
}
119+
void subCharge(float q) { mQ -= q; }
120+
121+
public:
122+
// Members
123+
uint16_t mQ = 0;
124+
uint8_t mCh = 0; // 0xFF indicates invalid digit
125+
uint8_t mPh = 0;
126+
uint8_t mX = 0;
127+
uint8_t mY = 0;
128+
129+
// The Pad Unique Id, code a pad inside one HMPID chamber.
130+
// Bit Map : 0000.0000.cccc.pppp.xxxx.xxxx.yyyy.yyyy
131+
// cccc := chamber [0..6]
132+
// pppp := photo cathode [0..5]
133+
// xxxx.xxxx := horizontal displacement [0..79]
134+
// yyyy.yyyy := vertical displacement [0..47]
135+
//uint32_t mPad = 0; // 0xFFFFFFFF indicates invalid digit
136+
137+
// Get the Geometric center of the pad
138+
static float lorsX(int pad) { return Param::lorsX(a2P(pad), a2X(pad)); } //center of the pad x, [cm]
139+
static float lorsY(int pad) { return Param::lorsY(a2P(pad), a2Y(pad)); } //center of the pad y, [cm]
140+
141+
// determines the total charge created by a hit
142+
// might modify the localX, localY coordiates associated to the hit
143+
static Double_t qdcTot(Double_t e, Double_t time, Int_t pc, Int_t px, Int_t py, Double_t& localX, Double_t& localY);
144+
static Double_t intPartMathiX(Double_t x, Int_t pad);
145+
static Double_t intPartMathiY(Double_t y, Int_t pad);
146+
static Double_t inMathieson(Double_t localX, Double_t localY, int pad);
147+
148+
ClassDefNV(Digit, 2);
149+
};
150+
151+
} // namespace hmpid
152+
} // namespace o2
153+
154+
#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_ */

Detectors/HMPID/base/include/HMPIDBase/Hit.h renamed to DataFormats/Detectors/HMPID/include/DataFormatsHMP/Hit.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11-
#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_HIT_H_
12-
#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_HIT_H_
11+
///
12+
/// \file Digit.h
13+
/// \author Antonio Franco - INFN Bari
14+
/// \version 1.0
15+
/// \date 15/02/2021
1316

14-
#include "SimulationDataFormat/BaseHits.h"
17+
// History
18+
//
19+
#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_HIT_H_
20+
#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_HIT_H_
21+
22+
#include "SimulationDataFormat/BaseHits.h" // for BasicXYZEHit
1523
#include "CommonUtils/ShmAllocator.h"
1624

1725
namespace o2
@@ -20,11 +28,12 @@ namespace hmpid
2028
{
2129

2230
// define HMPID hit type
31+
// class Hit : public o2::BasicXYZQHit<float>
2332
class HitType : public o2::BasicXYZEHit<float>
2433
{
2534
public:
26-
using Base = o2::BasicXYZEHit<float>;
27-
using Base::Base;
35+
using BasicXYZEHit<float>::BasicXYZEHit;
36+
2837
ClassDef(HitType, 1);
2938
};
3039

@@ -41,4 +50,4 @@ class allocator<o2::hmpid::HitType> : public o2::utils::ShmAllocator<o2::hmpid::
4150
} // namespace std
4251
#endif
4352

44-
#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_HIT_H_ */
53+
#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_HIT_H_ */
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
///
12+
/// \file Trigger.h
13+
/// \author Antonio Franco - INFN Bari
14+
/// \version 1.0
15+
/// \date 2/03/2021
16+
17+
#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_TRIGGER_H_
18+
#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_TRIGGER_H_
19+
20+
#include <iosfwd>
21+
#include "CommonDataFormat/InteractionRecord.h"
22+
23+
namespace o2
24+
{
25+
namespace hmpid
26+
{
27+
/// \class Trigger
28+
/// \brief HMPID Trigger declaration
29+
class Event
30+
{
31+
public:
32+
static inline uint64_t getTriggerID(uint32_t Orbit, uint16_t BC) { return ((Orbit << 12) | (0x0FFF & BC)); };
33+
34+
public:
35+
Event() = default;
36+
Event(InteractionRecord ir, int32_t first, int32_t last)
37+
{
38+
mIr.bc = ir.bc;
39+
mIr.orbit = ir.orbit;
40+
mFirstDigit = first;
41+
mLastDigit = last;
42+
};
43+
const InteractionRecord& getIr() const { return mIr; };
44+
uint32_t getOrbit() const { return mIr.orbit; };
45+
uint16_t getBc() const { return mIr.bc; };
46+
uint64_t getTriggerID() const { return ((mIr.orbit << 12) | (0x0FFF & mIr.bc)); };
47+
void setOrbit(uint32_t orbit)
48+
{
49+
mIr.orbit = orbit;
50+
return;
51+
}
52+
void setBC(uint16_t bc)
53+
{
54+
mIr.bc = bc;
55+
return;
56+
}
57+
void setTriggerID(uint64_t trigger)
58+
{
59+
mIr.orbit = (trigger >> 12);
60+
mIr.bc = (trigger & 0x0FFF);
61+
return;
62+
}
63+
void setDigitsPointer(int32_t first, int32_t last)
64+
{
65+
mFirstDigit = first;
66+
mLastDigit = last;
67+
return;
68+
}
69+
70+
// Operators definition !
71+
friend inline bool operator<(const Event& l, const Event& r) { return l.getTriggerID() < r.getTriggerID(); };
72+
friend inline bool operator==(const Event& l, const Event& r) { return l.getTriggerID() == r.getTriggerID(); };
73+
friend inline bool operator>(const Event& l, const Event& r) { return r < l; };
74+
friend inline bool operator<=(const Event& l, const Event& r) { return !(l > r); };
75+
friend inline bool operator>=(const Event& l, const Event& r) { return !(l < r); };
76+
friend inline bool operator!=(const Event& l, const Event& r) { return !(l == r); };
77+
78+
// Digit ASCII format (Orbit,BunchCrossing)[LHC Time nSec]
79+
friend std::ostream& operator<<(std::ostream& os, const Event& d);
80+
81+
public:
82+
int32_t mFirstDigit = 0;
83+
int32_t mLastDigit = -1;
84+
85+
private:
86+
// Members
87+
InteractionRecord mIr;
88+
89+
ClassDefNV(Event, 2);
90+
};
91+
92+
} // namespace hmpid
93+
} // namespace o2
94+
95+
#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_TRIGGER_H_ */

0 commit comments

Comments
 (0)