ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkEvent
TrkParametersIdentificationHelpers
exe
TestTrkParametersIdentificationHelpers.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrkParametersIdentificationHelpers/TrackParametersIdentificationHelper.h
"
6
7
#include <iostream>
8
#include <iomanip>
9
#include <bitset>
10
11
void
testBitField
(){
12
Trk::BitField<unsigned int>
field(31,1);
13
TrackParametersIdentifier
id
=0;
14
unsigned
int
max
= -1;
15
std::cout <<
" starting loop "
<<
max
<< std::endl;
16
for
(
unsigned
int
i=0;i<
max
;++i ){
17
if
( !field.encode(i,
id
) ){
18
std::cout <<
" encoding failed for "
<< i << std::endl;
19
break
;
20
}
21
unsigned
int
value = field.decode(
id
);
22
std::cout <<
" i "
<< std::setw(3) << i <<
" value "
<< std::setw(3) << value <<
" "
<< std::bitset<32>(i) <<
" id "
<< std::bitset<32>(
id
) << std::endl;
23
}
24
}
25
26
void
testCalo
() {
27
28
Trk::TrackParametersIdHelper
helper;
29
unsigned
int
good = 0;
30
unsigned
int
bad
= 0;
31
unsigned
int
goodCalo = 0;
32
unsigned
int
badCalo = 0;
33
34
// loop over technologies
35
for
(
unsigned
int
tech =
AtlasDetDescr::fFirstAtlasDetTechnology
; tech <
AtlasDetDescr::fNumAtlasDetTechnologies
; ++tech ){
36
37
bool
isCalo = (tech >=
AtlasDetDescr::fFirstAtlasCaloTechnology
) && (tech <=
AtlasDetDescr::fLastAtlasCaloTechnology
);
38
39
// loop over samplings
40
for
(
unsigned
int
sample = CaloSampling::PreSamplerB; sample < CaloSampling::Unknown; ++sample ){
41
42
for
(
unsigned
int
isEntry = 0; isEntry < 2 ; ++isEntry ){
43
bool
entry = isEntry == 1;
44
TrackParametersIdentifier
id
= helper.encode(
static_cast<
AtlasDetDescr::AtlasDetTechnology
>
(tech),
45
static_cast<
CaloSampling::CaloSample
>
(sample), entry );
46
AtlasDetDescr::AtlasDetTechnology
itech = helper.technology(
id
);
47
CaloSampling::CaloSample
isample = helper.caloSample(
id
);
48
bool
ientry = helper.isEntryToVolume(
id
);
49
bool
ivalid = helper.isValid(
id
);
50
bool
printDetails =
false
;
51
if
( !ivalid || sample != isample || entry != ientry ) {
52
++
bad
;
53
if
( isCalo ) {
54
std::cout <<
"WARNING bad decoding/encoding "
<< std::endl;
55
++badCalo;
56
printDetails =
true
;
57
}
58
}
else
{
59
++good;
60
if
( isCalo ) { ++goodCalo;
61
}
else
{
62
std::cout <<
" good but no calo!!! "
<< std::endl;
63
printDetails =
true
;
64
}
65
}
66
if
( printDetails ){
67
std::cout <<
" tech "
<< std::setw(4) << tech <<
" sample "
<< std::setw(4) << sample <<
" isEntry "
<< entry << std::endl
68
<<
" itech "
<< std::setw(4) << itech <<
" isample "
<< std::setw(4) << isample <<
" isEntry "
<< ientry
69
<<
" valid "
<< ivalid <<
" id "
<< std::bitset<32>(
id
) << std::endl;
70
}
71
}
72
}
73
}
74
std::cout <<
"all: good "
<< good <<
" bad "
<<
bad
<< std::endl;
75
std::cout <<
"calo: good "
<< goodCalo <<
" bad "
<< badCalo << std::endl;
76
77
}
78
79
80
int
main
() {
81
82
testBitField
();
83
testCalo
();
84
}
bad
@ bad
Definition
SUSYToolsTester.cxx:95
testCalo
void testCalo()
Definition
TestTrkParametersIdentificationHelpers.cxx:26
main
int main()
Definition
TestTrkParametersIdentificationHelpers.cxx:80
testBitField
void testBitField()
Definition
TestTrkParametersIdentificationHelpers.cxx:11
TrackParametersIdentifier
unsigned int TrackParametersIdentifier
Definition
TrackParametersIdHelper.h:13
TrackParametersIdentificationHelper.h
max
#define max(a, b)
Definition
cfImp.cxx:41
CaloSampling::CaloSample
CaloSample
Definition
Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
Trk::BitField
A class managing bits belonging to a range of bits.
Definition
BitField.h:14
Trk::TrackParametersIdHelper
helper class to encode and decode a TrackParametersIdentifier
Definition
TrackParametersIdHelper.h:18
AtlasDetDescr::AtlasDetTechnology
AtlasDetTechnology
A simple enum of ATLAS detector technologies.
Definition
AtlasDetTechnology.h:28
AtlasDetDescr::fFirstAtlasDetTechnology
@ fFirstAtlasDetTechnology
Definition
AtlasDetTechnology.h:32
AtlasDetDescr::fFirstAtlasCaloTechnology
@ fFirstAtlasCaloTechnology
Definition
AtlasDetTechnology.h:40
AtlasDetDescr::fNumAtlasDetTechnologies
@ fNumAtlasDetTechnologies
Definition
AtlasDetTechnology.h:57
AtlasDetDescr::fLastAtlasCaloTechnology
@ fLastAtlasCaloTechnology
Definition
AtlasDetTechnology.h:46
Generated on
for ATLAS Offline Software by
1.17.0