ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtPSATBAvg.cxx
Go to the documentation of this file.
1 #include "AtPSATBAvg.h"
2 
3 #include "AtHit.h"
4 #include "AtPad.h"
5 #include "AtPadArray.h"
6 #include "AtPadBase.h"
7 
8 #include <FairLogger.h>
9 
10 #include <Math/Point3D.h> // for PositionVector3D
11 #include <Math/Point3Dfwd.h> // for XYZPoint
12 
13 #include <algorithm>
14 #include <array> // for array
15 #include <memory> // for unique_ptr, make_unique
16 #include <numeric>
17 #include <utility> // for pair
18 
19 //#ifdef _OPENMP
20 //#include <omp.h>
21 //#endif
23 
25 
27 {
28  LOG(debug) << "Running PSA on pad " << pad->GetPadNum();
29  Int_t PadNum = pad->GetPadNum();
30 
31  XYZPoint pos(pad->GetPadCoord().X(), pad->GetPadCoord().Y(), 0);
32 
33  if (pos.X() < -9000 || pos.Y() < -9000) {
34  LOG(debug) << "Skipping pad, position is invalid";
35  return {};
36  }
37 
38  if (!(pad->IsPedestalSubtracted())) {
39  LOG(ERROR) << "Pedestal should be subtracted to use this class!";
40  }
41 
42  std::array<Double_t, 512> floatADC{};
43  if (fUseAug) {
44  floatADC = dynamic_cast<AtPadArray *>(pad->GetAugment(fAugName))->GetArray();
45  } else {
46  floatADC = pad->GetADC();
47  }
48 
49  // Skip pad if we think it is saturated
50  if (*std::max_element(floatADC.begin(), floatADC.end()) > fMaxThreshold)
51  return {};
52 
53  Double_t traceIntegral = std::accumulate(floatADC.begin(), floatADC.end(), 0);
54 
55  HitVector hits;
56  for (int i = 0; i < 512 / fTBtoAvg; ++i) {
57  Int_t idx = i * fTBtoAvg;
58  Double_t charge = std::accumulate(floatADC.begin() + idx, floatADC.begin() + idx + fTBtoAvg, 0);
59  charge /= fTBtoAvg;
60 
61  if (charge < getThreshold(pad->GetSizeID()))
62  continue;
63 
64  Double_t zTB = idx + static_cast<double>(fTBtoAvg) / 2;
65  pos.SetZ(CalculateZGeo(zTB));
66 
67  auto hit = std::make_unique<AtHit>(PadNum, pos, charge);
68 
69  hit->SetTimeStamp(zTB);
70  hit->SetTimeStampCorr(zTB);
71  hit->SetTimeStampCorrInter(zTB);
72  hit->SetTraceIntegral(traceIntegral);
73  hits.push_back(std::move(hit));
74  }
75  return hits;
76 }
AtPad.h
XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtPSATBAvg.cxx:22
AtPSA::CalculateZGeo
Double_t CalculateZGeo(Double_t peakIdx)
Definition: AtPSA.cxx:90
AtPad::GetSizeID
Int_t GetSizeID() const
Definition: AtPad.h:98
AtPSA::HitVector
std::vector< std::unique_ptr< AtHit > > HitVector
Definition: AtPSA.h:50
XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtPatternCircle2D.h:18
AtPad::GetPadCoord
XYPoint GetPadCoord() const
Definition: AtPad.h:107
AtPadArray.h
AtPSA::getThreshold
Double_t getThreshold(int padSize=-1)
Definition: AtPSA.cxx:179
AtHit.h
AtPSATBAvg.h
AtPad::GetAugment
AtPadBase * GetAugment(std::string name)
Definition: AtPad.cxx:82
AtPSATBAvg
Constructs a hit from averaged TBs.
Definition: AtPSATBAvg.h:21
AtPad::GetPadNum
Int_t GetPadNum() const
Definition: AtPad.h:96
AtPad::GetADC
const trace & GetADC() const
Definition: AtPad.cxx:97
AtPad::IsPedestalSubtracted
Bool_t IsPedestalSubtracted() const
Definition: AtPad.h:94
AtPadArray
Holds an addition array of doubles for an AtPad.
Definition: AtPadArray.h:24
AtPad
Container class for AtPadBase objects.
Definition: AtPad.h:38
AtPadBase.h
ClassImp
ClassImp(AtPSATBAvg)
AtPSATBAvg::AnalyzePad
HitVector AnalyzePad(AtPad *pad) override
Definition: AtPSATBAvg.cxx:26