ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <iostream>
8#include <iomanip>
9#include <bitset>
10
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
26void testCalo() {
27
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
36
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
80int main() {
81
83 testCalo();
84}
unsigned int TrackParametersIdentifier
#define max(a, b)
Definition cfImp.cxx:41
A class managing bits belonging to a range of bits.
Definition BitField.h:14
helper class to encode and decode a TrackParametersIdentifier
AtlasDetTechnology
A simple enum of ATLAS detector technologies.