Project
Loading...
Searching...
No Matches
ClusterShape.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
15
#include <iostream>
16
#include <algorithm>
17
#include <TBits.h>
18
#include <TRandom.h>
19
20
#include "
ITSMFTSimulation/ClusterShape.h
"
21
22
ClassImp
(
o2::itsmft::ClusterShape
);
23
24
using namespace
o2::itsmft
;
25
26
//______________________________________________________________________
27
ClusterShape::ClusterShape
() : mNrows(0),
28
mNcols(0),
29
mCenterR(0),
30
mCenterC(0)
31
{
32
mShape.clear();
33
}
34
35
//______________________________________________________________________
36
ClusterShape::ClusterShape
(UInt_t Nrows, UInt_t Ncols) : mNrows(Nrows),
37
mNcols(Ncols)
38
{
39
mCenterR = ComputeCenter(Nrows);
40
mCenterC = ComputeCenter(Ncols);
41
mShape.clear();
42
}
43
44
//______________________________________________________________________
45
ClusterShape::ClusterShape
(UInt_t Nrows, UInt_t Ncols,
const
std::vector<UInt_t>& Shape) : mNrows(Nrows),
46
mNcols(Ncols)
47
{
48
mCenterR = ComputeCenter(Nrows);
49
mCenterC = ComputeCenter(Ncols);
50
mShape = Shape;
51
}
52
53
//______________________________________________________________________
54
ClusterShape::~ClusterShape
() =
default
;
55
56
//______________________________________________________________________
57
Bool_t
ClusterShape::IsValidShape
()
58
{
59
// Check the size
60
if
(mShape.size() > mNrows * mNcols) {
61
return
false
;
62
}
63
64
// Check for duplicates and the validity of the position
65
std::sort(mShape.begin(), mShape.end());
66
for
(
size_t
i
= 0;
i
< mShape.size() - 1;
i
++) {
67
if
(mShape[
i
] >= mNrows * mNcols || mShape[
i
+ 1] >= mNrows * mNcols) {
68
return
false
;
69
}
70
if
(mShape[
i
] == mShape[
i
+ 1]) {
71
return
false
;
72
}
73
}
74
75
return
true
;
76
}
77
78
//______________________________________________________________________
79
Long64_t
ClusterShape::GetShapeID
()
const
80
{
81
// DJBX33X
82
Long64_t
id
= 5381;
83
id
= ((
id
<< 5) +
id
) ^ mNrows;
84
id
= ((
id
<< 5) +
id
) ^ mNcols;
85
for
(UInt_t
i
= 0;
i
< mShape.size(); ++
i
) {
86
id
= ((
id
<< 5) +
id
) ^ mShape[
i
];
87
}
88
return
id
;
89
}
90
91
//______________________________________________________________________
92
Bool_t
ClusterShape::HasElement
(UInt_t
value
)
const
93
{
94
for
(
auto
& el : mShape) {
95
if
(el >
value
) {
96
break
;
97
}
98
if
(el ==
value
) {
99
return
true
;
100
}
101
}
102
return
false
;
103
}
104
105
//______________________________________________________________________
106
UInt_t ClusterShape::ComputeCenter(UInt_t
n
)
107
{
108
UInt_t
c
= 0;
109
if
(
n
% 2 == 0) {
110
UInt_t
r
= gRandom->Integer(2);
// 0 or 1
111
c
= (UInt_t)
r
+
n
/ 2;
112
}
else
{
113
c
= (UInt_t)(
n
+ 1) / 2;
114
}
115
return
c
- 1;
// 0-based
116
}
ClassImp
ClassImp(o2::itsmft::ClusterShape)
ClusterShape.h
Cluster shape class for the ALPIDE response simulation.
i
int32_t i
Definition
GPUCommonAlgorithm.h:431
c
uint32_t c
Definition
RawData.h:2
o2::itsmft::ClusterShape
Definition
ClusterShape.h:35
o2::itsmft::ClusterShape::IsValidShape
Bool_t IsValidShape()
Definition
ClusterShape.cxx:57
o2::itsmft::ClusterShape::HasElement
Bool_t HasElement(UInt_t) const
Definition
ClusterShape.cxx:92
o2::itsmft::ClusterShape::ClusterShape
ClusterShape()
Definition
ClusterShape.cxx:27
o2::itsmft::ClusterShape::GetShapeID
Long64_t GetShapeID() const
Definition
ClusterShape.cxx:79
o2::itsmft::ClusterShape::~ClusterShape
~ClusterShape() override
n
GLdouble n
Definition
glcorearb.h:1982
value
GLsizei const GLfloat * value
Definition
glcorearb.h:819
r
GLboolean r
Definition
glcorearb.h:1233
id
GLuint id
Definition
glcorearb.h:650
o2::itsmft
Definition
SimTraits.h:123
Detectors
ITSMFT
common
simulation
src
ClusterShape.cxx
Generated on Fri Apr 4 2025 15:09:43 for Project by
1.9.8