Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
e9cb05a7
Commit
e9cb05a7
authored
10 years ago
by
Marko Petric
Browse files
Options
Downloads
Patches
Plain Diff
The template to add the new segmentation with vector input
parent
3d3a4392
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h
+95
-0
95 additions, 0 deletions
DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h
DDSegmentation/src/PolarGridRPhi2.cpp
+63
-0
63 additions, 0 deletions
DDSegmentation/src/PolarGridRPhi2.cpp
with
158 additions
and
0 deletions
DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h
0 → 100644
+
95
−
0
View file @
e9cb05a7
/*
* PolarGridRPhi2.h
*
* Created on: Sept 13, 2014
* Author: Marko Petric
*/
#ifndef DDSegmentation_PolarGridRPhi2_H_
#define DDSegmentation_PolarGridRPhi2_H_
#include
"DDSegmentation/PolarGrid.h"
#include
<math.h>
#include
<vector>
namespace
DD4hep
{
namespace
DDSegmentation
{
class
PolarGridRPhi2
:
public
PolarGrid
{
public:
/// Default constructor passing the encoding string
PolarGridRPhi2
(
const
std
::
string
&
cellEncoding
=
""
);
/// destructor
virtual
~
PolarGridRPhi2
();
/// determine the position based on the cell ID
virtual
Vector3D
position
(
const
CellID
&
cellID
)
const
;
/// determine the cell ID based on the position
virtual
CellID
cellID
(
const
Vector3D
&
localPosition
,
const
Vector3D
&
globalPosition
,
const
VolumeID
&
volumeID
)
const
;
/// access the grid size in R
std
::
vector
<
double
>
gridRValues
()
const
{
return
_gridRValues
;
}
/// access the grid size in Phi
double
gridSizePhi
()
const
{
return
_gridSizePhi
;
}
/// access the coordinate offset in R
double
offsetR
()
const
{
return
_offsetR
;
}
/// access the coordinate offset in Phi
double
offsetPhi
()
const
{
return
_offsetPhi
;
}
/// access the field name used for R
const
std
::
string
&
fieldNameR
()
const
{
return
_rId
;
}
/// access the field name used for Phi
const
std
::
string
&
fieldNamePhi
()
const
{
return
_phiId
;
}
/// set the grid size in R
void
setgridRValues
(
double
cellSize
,
int
value
)
{
_gridRValues
[
value
]
=
cellSize
;
}
/// set the grid size in Phi
void
setGridSizePhi
(
double
cellSize
)
{
_gridSizePhi
=
cellSize
;
}
/// set the coordinate offset in R
void
setOffsetR
(
double
offset
)
{
_offsetR
=
offset
;
}
/// set the coordinate offset in Phi
void
setOffsetPhi
(
double
offset
)
{
_offsetPhi
=
offset
;
}
/// set the field name used for X
void
setFieldNameR
(
const
std
::
string
&
name
)
{
_rId
=
name
;
}
/// set the field name used for Y
void
setFieldNamePhi
(
const
std
::
string
&
name
)
{
_phiId
=
name
;
}
protected
:
/// the grid size in X
std
::
vector
<
double
>
_gridRValues
;
/// the coordinate offset in X
double
_offsetR
;
/// the grid size in Y
double
_gridSizePhi
;
/// the coordinate offset in Y
double
_offsetPhi
;
/// the field name used for X
std
::
string
_rId
;
/// the field name used for Y
std
::
string
_phiId
;
};
}
/* namespace DDSegmentation */
}
/* namespace DD4hep */
#endif
/* DDSegmentation_PolarGridRPhi2_H_ */
This diff is collapsed.
Click to expand it.
DDSegmentation/src/PolarGridRPhi2.cpp
0 → 100644
+
63
−
0
View file @
e9cb05a7
/*
* PolarGridRPhi2.cpp
*
* Created on: Sept 16, 2014
* Author: Marko Petric
*/
#include
"DDSegmentation/PolarGridRPhi2.h"
namespace
DD4hep
{
namespace
DDSegmentation
{
using
std
::
string
;
/// default constructor using an encoding string
PolarGridRPhi2
::
PolarGridRPhi2
(
const
string
&
cellEncoding
)
:
PolarGrid
(
cellEncoding
)
{
// define type and description
_type
=
"PolarGridRPhi2"
;
_description
=
"Polar RPhi segmentation in the local XY-plane"
;
// register all necessary parameters
registerParameter
(
"grid_r_values"
,
"Vector or R values"
,
_gridRValues
,
std
::
vector
<
double
>
(),
SegmentationParameter
::
NoUnit
,
true
);
registerParameter
(
"grid_size_phi"
,
"Cell size in Phi"
,
_gridSizePhi
,
1.
,
SegmentationParameter
::
AngleUnit
);
registerParameter
(
"offset_r"
,
"Cell offset in R"
,
_offsetR
,
0.
,
SegmentationParameter
::
LengthUnit
,
true
);
registerParameter
(
"offset_phi"
,
"Cell offset in Phi"
,
_offsetPhi
,
0.
,
SegmentationParameter
::
AngleUnit
,
true
);
registerIdentifier
(
"identifier_r"
,
"Cell ID identifier for R"
,
_rId
,
"r"
);
registerIdentifier
(
"identifier_phi"
,
"Cell ID identifier for Phi"
,
_phiId
,
"phi"
);
}
/// destructor
PolarGridRPhi2
::~
PolarGridRPhi2
()
{
}
/// determine the position based on the cell ID
Vector3D
PolarGridRPhi2
::
position
(
const
CellID
&
cellID
)
const
{
_decoder
->
setValue
(
cellID
);
Vector3D
position
;
double
R
=
binToPosition
((
*
_decoder
)[
_rId
].
value
(),
_gridRValues
[
0
],
_offsetR
);
double
phi
=
binToPosition
((
*
_decoder
)[
_phiId
].
value
(),
_gridSizePhi
,
_offsetPhi
);
position
.
X
=
R
*
cos
(
phi
);
position
.
Y
=
R
*
sin
(
phi
);
return
position
;
}
/// determine the cell ID based on the position
CellID
PolarGridRPhi2
::
cellID
(
const
Vector3D
&
localPosition
,
const
Vector3D
&
/* globalPosition */
,
const
VolumeID
&
volumeID
)
const
{
_decoder
->
setValue
(
volumeID
);
double
phi
=
atan2
(
localPosition
.
Y
,
localPosition
.
X
);
double
R
=
sqrt
(
localPosition
.
X
*
localPosition
.
X
+
localPosition
.
Y
*
localPosition
.
Y
);
(
*
_decoder
)[
_rId
]
=
positionToBin
(
R
,
_gridRValues
[
0
],
_offsetR
);
(
*
_decoder
)[
_phiId
]
=
positionToBin
(
phi
,
_gridSizePhi
,
_offsetPhi
);
return
_decoder
->
getValue
();
}
REGISTER_SEGMENTATION
(
PolarGridRPhi2
)
}
/* namespace DDSegmentation */
}
/* namespace DD4hep */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment