ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtPSAFull.cxx
Go to the documentation of this file.
1 #include "AtPSAFull.h"
2 
3 #include "AtHit.h"
4 #include "AtPad.h" // for AtPad
5 
6 #include <FairLogger.h> // for LOG
7 
8 #include <Math/Point2D.h> // for PositionVector2D
9 #include <Math/Point3D.h> // for PositionVector3D
10 #include <Math/Point3Dfwd.h> // for XYZPoint
11 #include <TVector3.h> // for TVector3
12 
13 #include <array> // for array
14 #include <iostream> // for basic_ostream::operator<<, operator<<
15 #include <map>
16 #include <memory> // for allocator_traits<>::value_type
17 #include <utility> // for pair
18 
19 /*
20 #ifdef _OPENMP
21 #include <omp.h>
22 #endif
23 */
25 
27 {
28 
29  Int_t PadNum = pad->GetPadNum();
30  Int_t PadHitNum = 0;
31  TVector3 HitPos;
32 
33  Double_t charge = 0;
34  Int_t maxAdcIdx = 0;
35  Int_t numPeaks = 0;
36 
37  if (!(pad->IsPedestalSubtracted())) {
38  LOG(ERROR) << "Pedestal should be subtracted to use this class!";
39  // return;
40  }
41 
42  auto adc = pad->GetADC();
43  Double_t floatADC[512] = {0};
44  Double_t dummy[512] = {0};
45 
46  Int_t divider = 50;
47  Int_t initial = 0;
48  Int_t final = 0;
49  Int_t endInterval = 0;
50  Float_t max = 0.0;
51  Int_t maxTime = 0;
52 
53  std::map<Int_t, Int_t> interval;
54 
55  for (Int_t iTb = 0; iTb < fNumTbs; iTb++)
56  floatADC[iTb] = adc[iTb];
57 
58  for (Int_t ij = 20; ij < 500; ij++) { // Excluding first and last 12 Time Buckets
59  if (floatADC[ij] > max) {
60  max = floatADC[ij];
61  maxTime = ij;
62  }
63  }
64 
65  Int_t size = 0;
66  // maxAdcIdx = maxTime;
67 
68  for (Int_t iTb = 0; iTb < fNumTbs; iTb++) {
69 
70  if (floatADC[iTb] > getThreshold(pad->GetSizeID())) {
71  if (iTb == 0)
72  initial = 0;
73  else if (floatADC[iTb - 1] < getThreshold(pad->GetSizeID()))
74  initial = iTb;
75  if (iTb == (fNumTbs - 1)) {
76  final = iTb;
77  if (final - initial > divider)
78  size = final - initial;
79  interval.insert(std::pair<Int_t, Int_t>(initial, final));
80  } else if (floatADC[iTb + 1] < getThreshold(pad->GetSizeID())) {
81  final = iTb;
82  if (final - initial > divider)
83  size = final - initial;
84  interval.insert(std::pair<Int_t, Int_t>(initial, final));
85  }
86  }
87  }
88 
89  HitVector hits;
90  if (size < divider) {
91  double zPos = CalculateZGeo(maxTime);
92  auto pos = pad->GetPadCoord();
93  if ((pos.X() < -9000 || pos.Y() < -9000) && pad->GetPadNum() != -1)
94  std::cout << " AtPSAFull::Analysis Warning! Wrong Coordinates for Pad : " << pad->GetPadNum() << std::endl;
95 
96  auto hit = std::make_unique<AtHit>(PadNum, XYZPoint(pos.X(), pos.Y(), zPos), charge);
97  hit->SetTimeStamp(maxTime);
98  hits.push_back(std::move(hit));
99 
100  } else {
101  auto ite = interval.begin();
102  // Double_t *thePar = new Double_t[3];
103  while (ite != interval.end()) {
104  final = (ite->second);
105  initial = (ite->first);
106  Int_t reducedPoints = (final - initial) / divider;
107  for (Int_t points = 0; points < reducedPoints + 1; points++) {
108  Int_t initInterval = initial + points * divider;
109  if (points == reducedPoints)
110  endInterval = final;
111  else
112  endInterval = initial + ((points + 1) * divider) - 1;
113 
114  double zPos = CalculateZGeo(initInterval);
115  auto pos = pad->GetPadCoord();
116  if ((pos.X() < -9000 || pos.Y() < -9000) && pad->GetPadNum() != -1)
117  std::cout << " AtPSAFull::Analysis Warning! Wrong Coordinates for Pad : " << pad->GetPadNum()
118  << std::endl;
119 
120  for (Int_t iIn = initInterval; iIn < endInterval; iIn++)
121  charge += floatADC[iIn] / divider; // reduced by divider!!!
122 
123  auto hit = std::make_unique<AtHit>(PadNum, XYZPoint(pos.X(), pos.Y(), zPos), charge);
124  hit->SetTimeStamp(initInterval);
125  charge = 0;
126  hits.push_back(std::move(hit));
127  }
128  ite++;
129  }
130  interval.clear();
131  }
132  return hits;
133 }
134 
AtPad.h
AtPSAFull.h
AtPSA::CalculateZGeo
Double_t CalculateZGeo(Double_t peakIdx)
Definition: AtPSA.cxx:90
ClassImp
ClassImp(AtFindVertex)
AtPSAFull
Definition: AtPSAFull.h:15
AtPad::GetSizeID
Int_t GetSizeID() const
Definition: AtPad.h:98
AtPSA::HitVector
std::vector< std::unique_ptr< AtHit > > HitVector
Definition: AtPSA.h:50
AtPSAFull::AnalyzePad
HitVector AnalyzePad(AtPad *pad) override
Definition: AtPSAFull.cxx:26
AtPSA::fNumTbs
Int_t fNumTbs
Definition: AtPSA.h:44
XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtPatternCircle2D.h:18
AtPad::GetPadCoord
XYPoint GetPadCoord() const
Definition: AtPad.h:107
AtPSA::getThreshold
Double_t getThreshold(int padSize=-1)
Definition: AtPSA.cxx:179
AtHit.h
XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtPSAFull.cxx:24
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
AtPad
Container class for AtPadBase objects.
Definition: AtPad.h:38