Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computing
cbmroot
Commits
1df6f163
Commit
1df6f163
authored
3 years ago
by
Sergei Zharko
Committed by
Sergey Gorbunov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
New init for L1Algo: moved L1Utils.h to L1Algo directory
parent
9849ed6b
No related branches found
No related tags found
No related merge requests found
Pipeline
#16036
passed
3 years ago
Stage: checkRepository
Stage: checkFormat
Stage: build
Stage: finalise
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
reco/L1/CMakeLists.txt
+1
-1
1 addition, 1 deletion
reco/L1/CMakeLists.txt
reco/L1/L1Algo/L1InitManager.h
+1
-1
1 addition, 1 deletion
reco/L1/L1Algo/L1InitManager.h
reco/L1/L1Algo/L1Utils.h
+73
-0
73 additions, 0 deletions
reco/L1/L1Algo/L1Utils.h
with
75 additions
and
2 deletions
reco/L1/CMakeLists.txt
+
1
−
1
View file @
1df6f163
...
...
@@ -276,7 +276,7 @@ Install(FILES CbmL1Counters.h
L1Algo/L1InitManager.h
L1Algo/L1CAIteration.h
L1Algo/L1Parameters.h
L1Algo/
utils/
L1Utils.h
L1Algo/L1Utils.h
vectors/vec_arithmetic.h
vectors/std_alloc.h
DESTINATION include
...
...
This diff is collapsed.
Click to expand it.
reco/L1/L1Algo/L1InitManager.h
+
1
−
1
View file @
1df6f163
...
...
@@ -14,7 +14,7 @@
#include
"L1BaseStationInfo.h"
#include
"L1Field.h"
#include
"L1Parameters.h"
#include
"
utils/
L1Utils.h"
#include
"L1Utils.h"
//#include <string>
#include
<bitset>
...
...
This diff is collapsed.
Click to expand it.
reco/L1/L1Algo/L1Utils.h
0 → 100644
+
73
−
0
View file @
1df6f163
/* Copyright (C) 2016-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergey Gorbunov, Sergei Zharko [committer] */
/************************************************************************************************************
* @file L1Utils.h
* @brief File contains some general purpose functions for L1Algo
* @since 12.01.2022
***********************************************************************************************************/
#include
<iomanip>
#include
<map>
#include
<sstream>
#include
<string>
#include
<unordered_map>
/// Class contains some utility functions for L1Algo
struct
L1Utils
{
/// Hash for unordered_map with enum class keys
struct
EnumClassHash
{
template
<
typename
T
>
int
operator
()(
T
t
)
const
{
return
static_cast
<
int
>
(
t
);
}
};
/// Template function, which sets a value to an element of the map with a particular key
/// \param key Key of the element to be modified
/// \param value New value of the element under the selected key
/// \param aMap A reference to the map, which element is to be modified
template
<
class
Key
,
class
T
,
class
Hash
=
std
::
hash
<
Key
>
>
static
void
SetSingleValueToMap
(
Key
key
,
T
value
,
std
::
unordered_map
<
Key
,
T
,
Hash
>&
aMap
)
{
aMap
[
key
]
=
value
;
}
/// Template function, which sets a value to ALL elements of the map
/// \param value New value of the element under the selected key
/// \param aMap A reference to the map, which element is to be modified
template
<
class
Key
,
class
T
,
class
Hash
=
std
::
hash
<
Key
>
>
static
void
SetSameValueToMap
(
T
value
,
std
::
unordered_map
<
Key
,
T
,
Hash
>&
aMap
)
{
for
(
auto
it
=
aMap
.
begin
();
it
!=
aMap
.
end
();
++
it
)
{
it
->
second
=
value
;
}
}
/// Template function, which resets the elements of one map with the values defined in another map
/// \param inMap A constant reference to the map containing new parameters
/// \param aMap A reference to the map, which is going to be modified
template
<
class
Key
,
class
T
,
class
Hash
=
std
::
hash
<
Key
>
>
static
void
SetMappedValuesToMap
(
const
std
::
unordered_map
<
Key
,
T
,
Hash
>&
inMap
,
std
::
unordered_map
<
Key
,
T
,
Hash
>&
aMap
)
{
for
(
auto
it
=
aMap
.
begin
();
it
!=
aMap
.
end
();
++
it
)
{
if
(
inMap
.
find
(
it
->
first
)
!=
inMap
.
end
())
{
it
->
second
=
inMap
.
at
(
it
->
first
);
}
}
}
/// Template function to represent mapped contents into std::string
/// NOTE: operator<< must be defined for value of the map
template
<
class
Key
,
class
T
,
class
Hash
=
std
::
hash
<
Key
>
>
static
std
::
string
RepresentMapWithString
(
const
std
::
unordered_map
<
Key
,
T
,
Hash
>&
aMap
,
int
entryWidth
=
15
)
{
std
::
stringstream
token
;
for
(
auto
it
=
aMap
.
begin
();
it
!=
aMap
.
end
();
++
it
)
{
token
<<
std
::
setw
(
entryWidth
)
<<
std
::
setfill
(
' '
)
<<
it
->
second
<<
' '
;
}
return
token
.
str
();
}
};
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