ATLAS Offline Software
Loading...
Searching...
No Matches
ModifySlices.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "ModifySlices.h"
7
8namespace LVL1BS {
9
10// Return new triggered slice offset
11
12int ModifySlices::peak(const int oldPeak, const int oldSlices,
13 const int newSlices)
14{
15 return oldPeak + (newSlices - oldSlices)/2;
16}
17
18// Return modified data vector<int>
19
20void ModifySlices::data(const std::vector<int>& oldVec,
21 std::vector<int>& newVec, const int newSlices)
22{
23 const int oldSlices = oldVec.size();
24 const int offset = (newSlices - oldSlices)/2;
25 newVec.resize(newSlices);
26 for (int sl = 0; sl < newSlices; ++sl) {
27 const int oldSl = sl - offset;
28 if (oldSl < 0) newVec[sl] = oldVec[0];
29 else if (oldSl >= oldSlices) newVec[sl] = oldVec[oldSlices - 1];
30 else newVec[sl] = oldVec[oldSl];
31 }
32}
33
34// Return modified data vector<unsigned int>
35
36void ModifySlices::data(const std::vector<unsigned int>& oldVec,
37 std::vector<unsigned int>& newVec,
38 const int newSlices)
39{
40 const int oldSlices = oldVec.size();
41 const int offset = (newSlices - oldSlices)/2;
42 newVec.resize(newSlices);
43 for (int sl = 0; sl < newSlices; ++sl) {
44 const int oldSl = sl - offset;
45 if (oldSl < 0) newVec[sl] = oldVec[0];
46 else if (oldSl >= oldSlices) newVec[sl] = oldVec[oldSlices - 1];
47 else newVec[sl] = oldVec[oldSl];
48 }
49}
50
51} // end namespace
static void data(const std::vector< int > &oldVec, std::vector< int > &newVec, int newSlices)
Return modified data vector<int>
static int peak(int oldPeak, int oldSlices, int newSlices)
Return new triggered slice offset.