ATLAS Offline Software
Loading...
Searching...
No Matches
Digitizer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef GLOBALSIM_DIGITIZER_H
6#define GLOBALSIM_DIGITIZER_H
7
8#include "ap_int.h"
9#include <vector>
10#include <algorithm>
11
12namespace GlobalSim {
13
14 //Scale factor to digitize cell energies to the hardware scale
15 //Current best estimate
16 static auto sf = [](double v) {
17 if (v < 0) {return 0.;}
18 if (v < 8000) {return v / 31.25;}
19 if (v < 40000) {return 192. + v / 125;}
20 if (v < 168000) {return 432. + v / 500;}
21 if (v < 678000) {return 686. + v / 2000;}
22 return 1023.;
23 };
24
25 struct digitizer{
26 //Outupt scaled cell energies to 10bit ints
27 static std::vector<ap_int<10>>
28 digitize10(const std::vector<double>& v) {
29 auto result = std::vector<ap_int<10>>();
30 result.reserve(v.size());
31
32 std::transform(std::cbegin(v),
33 std::cend(v),
34 std::back_inserter(result),
35 sf);
36
37 return result;
38 }
39
40 //Outupt scaled cell energies to 16bit ints
41 static std::vector<ap_int<16>>
42 digitize16(const std::vector<double>& v) {
43 auto result = std::vector<ap_int<16>>();
44 result.reserve(v.size());
45
46 std::transform(std::cbegin(v),
47 std::cend(v),
48 std::back_inserter(result),
49 sf);
50
51 return result;
52 }
53 };
54}
55
56#endif
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
static auto sf
Definition Digitizer.h:16
static std::vector< ap_int< 10 > > digitize10(const std::vector< double > &v)
Definition Digitizer.h:28
static std::vector< ap_int< 16 > > digitize16(const std::vector< double > &v)
Definition Digitizer.h:42