Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nptool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
np
nptool
Commits
8e24293a
Commit
8e24293a
authored
4 years ago
by
Cyril Lenain
Browse files
Options
Downloads
Patches
Plain Diff
* updating NPCrossTalk
parent
d66041cd
No related branches found
No related tags found
No related merge requests found
Pipeline
#94004
passed
4 years ago
Stage: build-NPLib
Stage: build-NPSimulation
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
NPLib/Neutron/NPCrossTalk.cxx
+32
-49
32 additions, 49 deletions
NPLib/Neutron/NPCrossTalk.cxx
with
32 additions
and
49 deletions
NPLib/Neutron/NPCrossTalk.cxx
+
32
−
49
View file @
8e24293a
...
@@ -67,15 +67,17 @@ vector<int> CrossTalk::ComputeCrossTalk(){
...
@@ -67,15 +67,17 @@ vector<int> CrossTalk::ComputeCrossTalk(){
static
double
Dist
,
dR1
,
dR2
;
static
double
Dist
,
dR1
,
dR2
;
//Attribute a new index based on the time arrive from the first to the last hit
//Attribute a new index based on the time arrive from the first to the last hit
//Using vector of pairs
//Using vector of pairs (ID,Time)
static
vector
<
pair
<
int
,
double
>>
pairSortedID
;
static
vector
<
pair
<
int
,
double
>>
pairSortedID
;
pairSortedID
.
clear
();
pairSortedID
.
clear
();
for
(
int
i
=
0
;
i
<
sizeHit
;
i
++
){
for
(
int
i
=
0
;
i
<
sizeHit
;
i
++
){
pairSortedID
.
emplace_back
(
i
,
(
*
HitT
)[
i
]);
pairSortedID
.
emplace_back
(
i
,
(
*
HitT
)[
i
]);
}
}
//Sort pair vector (ID,Time) in Time
sort
(
pairSortedID
.
begin
(),
pairSortedID
.
end
(),
cmp
);
sort
(
pairSortedID
.
begin
(),
pairSortedID
.
end
(),
cmp
);
static
vector
<
unsigned
int
>
SortedID
;
static
vector
<
unsigned
int
>
SortedID
;
SortedID
.
clear
();
//Put new ID sorted in a vector
for
(
int
i
=
0
;
i
<
sizeHit
;
i
++
){
for
(
int
i
=
0
;
i
<
sizeHit
;
i
++
){
SortedID
.
push_back
(
pairSortedID
[
i
].
first
);
SortedID
.
push_back
(
pairSortedID
[
i
].
first
);
}
}
...
@@ -87,13 +89,18 @@ vector<int> CrossTalk::ComputeCrossTalk(){
...
@@ -87,13 +89,18 @@ vector<int> CrossTalk::ComputeCrossTalk(){
ID_ClustHit
.
push_back
(
i
+
1
);
ID_ClustHit
.
push_back
(
i
+
1
);
}
}
FirstHit
=
SortedID
[
0
];
//Test each Dist(n-n) to find clusters
//Test each Dist(n-n) to find clusters
//When 2 neutrons are part of a the same cluster, change their ID_ClustHit for the lowest
//When 2 neutrons are part of a the same cluster, change their ID_ClustHit for the lowest
//Create a map to hold the Hit_ID for each cluster
static
map
<
unsigned
int
,
vector
<
unsigned
int
>>
mapOfClust
;
mapOfClust
.
clear
();
for
(
int
j
=
0
;
j
<
sizeHit
-
1
;
j
++
){
for
(
int
j
=
0
;
j
<
sizeHit
-
1
;
j
++
){
x1
=
(
*
HitX
)[
j
],
y1
=
(
*
HitY
)[
j
],
z1
=
(
*
HitZ
)[
j
],
dx1
=
(
*
HitdX
)[
j
],
dy1
=
(
*
HitdY
)[
j
],
dz1
=
(
*
HitdZ
)[
j
],
t1
=
(
*
HitT
)[
j
];
x1
=
(
*
HitX
)[
SortedID
[
j
]
]
,
y1
=
(
*
HitY
)[
SortedID
[
j
]
],
z1
=
(
*
HitZ
)[
SortedID
[
j
]
],
dx1
=
(
*
HitdX
)[
SortedID
[
j
]
],
dy1
=
(
*
HitdY
)[
SortedID
[
j
]
],
dz1
=
(
*
HitdZ
)[
SortedID
[
j
]
],
t1
=
(
*
HitT
)[
SortedID
[
j
]
];
dR1
=
sqrt
(
dx1
*
dx1
+
dy1
*
dy1
+
dz1
*
dz1
);
dR1
=
sqrt
(
dx1
*
dx1
+
dy1
*
dy1
+
dz1
*
dz1
);
for
(
int
jj
=
j
+
1
;
jj
<
sizeHit
;
jj
++
){
for
(
int
jj
=
j
+
1
;
jj
<
sizeHit
;
jj
++
){
x2
=
(
*
HitX
)[
jj
],
y2
=
(
*
HitY
)[
jj
],
z2
=
(
*
HitZ
)[
jj
];
x2
=
(
*
HitX
)[
SortedID
[
jj
]
]
,
y2
=
(
*
HitY
)[
SortedID
[
jj
]
]
,
z2
=
(
*
HitZ
)[
SortedID
[
jj
]
]
;
Dist
=
sqrt
((
x2
-
x1
)
*
(
x2
-
x1
)
+
(
y2
-
y1
)
*
(
y2
-
y1
)
+
(
z2
-
z1
)
*
(
z2
-
z1
));
Dist
=
sqrt
((
x2
-
x1
)
*
(
x2
-
x1
)
+
(
y2
-
y1
)
*
(
y2
-
y1
)
+
(
z2
-
z1
)
*
(
z2
-
z1
));
if
(
Dist
<
coef
*
dR1
){
if
(
Dist
<
coef
*
dR1
){
if
(
ID_ClustHit
[
jj
]
<
ID_ClustHit
[
j
]){
if
(
ID_ClustHit
[
jj
]
<
ID_ClustHit
[
j
]){
...
@@ -105,75 +112,51 @@ vector<int> CrossTalk::ComputeCrossTalk(){
...
@@ -105,75 +112,51 @@ vector<int> CrossTalk::ComputeCrossTalk(){
}
}
}
}
}
}
//Create a map to hold the Hit_ID for each cluster
static
map
<
unsigned
int
,
vector
<
unsigned
int
>>
mapOfClust
;
mapOfClust
.
clear
();
for
(
unsigned
int
i
=
0
;
i
<
sizeHit
;
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
sizeHit
;
i
++
){
mapOfClust
[
ID_ClustHit
[
i
]].
push_back
(
i
);
mapOfClust
[
ID_ClustHit
[
i
]].
push_back
(
SortedID
[
i
]
);
}
}
//Put first hit in time of each cluster in a new map mapOfFirstN
//Put first hit in time of each cluster in a new map mapOfHead and remake the numbering of clusters (1,2,3...)
//And also find the first hit of all : FirstN
static
map
<
unsigned
int
,
unsigned
int
>
mapOfHead
;
static
map
<
unsigned
int
,
unsigned
int
>
mapOfFirstN
;
static
unsigned
int
NbrOfClust
;
static
unsigned
int
NbrOfClust
,
FirstN
;
mapOfHead
.
clear
();
static
int
FirstClust
;
NbrOfClust
=
0
;
NbrOfClust
=
mapOfClust
.
size
();
NbrOfClust
=
mapOfClust
.
size
();
static
double
GeneralTmin
;
GeneralTmin
=
1000000
;
static
unsigned
int
count
;
for
(
int
i
=
1
;
i
<=
NbrOfClust
;
i
++
){
count
=
1
;
static
unsigned
int
clustSize
;
for
(
auto
itr
=
mapOfClust
.
begin
();
itr
!=
mapOfClust
.
end
();
itr
++
){
static
double
TminClust
;
mapOfHead
[
count
]
=
itr
->
second
[
0
];
TminClust
=
10000000
;
count
++
;
clustSize
=
mapOfClust
[
i
].
size
();
}
for
(
int
j
=
0
;
j
<
clustSize
;
j
++
){
if
((
*
HitT
)[
mapOfClust
[
i
][
j
]]
<
TminClust
){
TminClust
=
(
*
HitT
)[
mapOfClust
[
i
][
j
]];
mapOfFirstN
[
i
]
=
mapOfClust
[
i
][
j
];
}
if
((
*
HitT
)[
mapOfClust
[
i
][
j
]]
<
GeneralTmin
){
GeneralTmin
=
(
*
HitT
)[
mapOfClust
[
i
][
j
]];
FirstN
=
mapOfClust
[
i
][
j
];
FirstClust
=
i
;
}
}
}
FirstHit
=
FirstN
;
static
double
v_n
,
Dmax
;
static
double
v_n
,
Dmax
;
static
vector
<
double
>
CrossTalk
;
static
vector
<
double
>
CrossTalk
;
CrossTalk
.
clear
();
CrossTalk
.
clear
();
//Test now the "Friend" clusters
//Test now the "Friend" clusters
for
(
int
i
=
1
;
i
<
NbrOfClust
-
1
;
i
++
){
for
(
int
i
=
1
;
i
<
NbrOfClust
-
1
;
i
++
){
x1
=
(
*
HitX
)[
mapOf
FirstN
[
i
]],
y1
=
(
*
HitY
)[
mapOf
FirstN
[
i
]],
z1
=
(
*
HitZ
)[
mapOf
FirstN
[
i
]],
t1
=
(
*
HitT
)[
mapOf
FirstN
[
i
]];
x1
=
(
*
HitX
)[
mapOf
Head
[
i
]],
y1
=
(
*
HitY
)[
mapOf
Head
[
i
]],
z1
=
(
*
HitZ
)[
mapOf
Head
[
i
]],
t1
=
(
*
HitT
)[
mapOf
Head
[
i
]];
v_n
=
sqrt
(
x1
*
x1
+
y1
*
y1
+
z1
*
z1
)
/
t1
;
v_n
=
sqrt
(
x1
*
x1
+
y1
*
y1
+
z1
*
z1
)
/
t1
;
for
(
int
j
=
i
+
1
;
i
<
NbrOfClust
;
i
++
){
for
(
int
j
=
i
+
1
;
i
<
NbrOfClust
;
i
++
){
x2
=
(
*
HitX
)[
mapOf
FirstN
[
i
]],
y2
=
(
*
HitY
)[
mapOf
FirstN
[
i
]],
z2
=
(
*
HitZ
)[
mapOf
FirstN
[
i
]],
t2
=
(
*
HitT
)[
mapOf
FirstN
[
i
]];
x2
=
(
*
HitX
)[
mapOf
Head
[
i
]],
y2
=
(
*
HitY
)[
mapOf
Head
[
i
]],
z2
=
(
*
HitZ
)[
mapOf
Head
[
i
]],
t2
=
(
*
HitT
)[
mapOf
Head
[
i
]];
Dist
=
sqrt
((
x2
-
x1
)
*
(
x2
-
x1
)
+
(
y2
-
y1
)
*
(
y2
-
y1
)
+
(
z2
-
z1
)
*
(
z2
-
z1
));
Dist
=
sqrt
((
x2
-
x1
)
*
(
x2
-
x1
)
+
(
y2
-
y1
)
*
(
y2
-
y1
)
+
(
z2
-
z1
)
*
(
z2
-
z1
));
Dmax
=
(
t2
-
t1
)
*
v_n
;
Dmax
=
(
t2
-
t1
)
*
v_n
;
cout
<<
Dmax
<<
endl
;
if
(
Dist
<
Dmax
){
if
(
Dist
<
Dmax
){
if
(
t1
<
t2
){
CrossTalk
.
push_back
(
j
);
CrossTalk
.
push_back
(
j
);
}
else
{
CrossTalk
.
push_back
(
i
);
}
}
}
}
}
}
}
//elimate potential CrossTalk in mapOf
FirstN
//elimate potential CrossTalk in mapOf
Head
static
unsigned
int
sizeCT
;
static
unsigned
int
sizeCT
;
sizeCT
=
CrossTalk
.
size
();
sizeCT
=
CrossTalk
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
sizeCT
;
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
sizeCT
;
i
++
){
mapOf
FirstN
.
erase
(
i
);
mapOf
Head
.
erase
(
CrossTalk
[
i
]
);
}
}
//return vector of real neutrons IDs
//return vector of real neutrons IDs
m_Neutrons
.
clear
();
m_Neutrons
.
clear
();
for
(
auto
itr
=
mapOf
FirstN
.
begin
();
itr
!=
mapOf
FirstN
.
end
();
itr
++
){
for
(
auto
itr
=
mapOf
Head
.
begin
();
itr
!=
mapOf
Head
.
end
();
itr
++
){
m_Neutrons
.
push_back
(
itr
->
second
);
m_Neutrons
.
push_back
(
itr
->
second
);
}
}
...
...
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