ATLAS Offline Software
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 
8 namespace LVL1BS {
9 
10 // Return new triggered slice offset
11 
12 int 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 
20 void 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 
36 void 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
LVL1BS::ModifySlices::peak
static int peak(int oldPeak, int oldSlices, int newSlices)
Return new triggered slice offset.
Definition: ModifySlices.cxx:12
ModifySlices.h
LVL1BS::ModifySlices::data
static void data(const std::vector< int > &oldVec, std::vector< int > &newVec, int newSlices)
Return modified data vector<int>
Definition: ModifySlices.cxx:20
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71