ATTPCROOT
0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
|
Go to the documentation of this file.
10 #include <FairLogger.h>
11 #include <FairParSet.h>
13 #include <FairRuntimeDb.h>
15 #include <Math/Point3D.h>
16 #include <Math/Point3Dfwd.h>
19 #include <TVirtualFFT.h>
34 : fEventResponse(r.fEventResponse), fResponse(r.fResponse), fFFT(nullptr), fFFTbackward(nullptr),
35 fFilterOrder(r.fFilterOrder), fCutoffFreq(r.fCutoffFreq), fUseSimulatedCharge(r.fUseSimulatedCharge)
43 LOG(error) <<
"We only support even order filters!";
56 std::vector<Int_t> dimSize = {512};
59 fFFT = std::unique_ptr<TVirtualFFT>(TVirtualFFT::FFT(1, dimSize.data(),
"R2C M K"));
62 fFFTbackward = std::unique_ptr<TVirtualFFT>(TVirtualFFT::FFT(1, dimSize.data(),
"C2R M K"));
72 LOG(debug2) <<
"Getting pad " << padNum <<
" from response event.";
89 auto fft =
dynamic_cast<AtPadFFT *
>(pad.GetAugment(
"fft"));
92 LOG(debug) <<
"Adding FFT to pad " << padNum;
93 fFFT->SetPoints(pad.GetADC().data());
95 auto fftNew = std::make_unique<AtPadFFT>();
96 fftNew->GetDataFromFFT(
fFFT.get());
97 fft =
dynamic_cast<AtPadFFT *
>(pad.AddAugment(
"fft", std::move(fftNew)));
113 auto filter =
dynamic_cast<AtPadFFT *
>(pad.GetAugment(
"filter"));
115 if (filter ==
nullptr) {
116 LOG(debug) <<
"Adding filter to pad " << padNum;
117 filter =
dynamic_cast<AtPadFFT *
>(pad.AddAugment(
"filter", std::make_unique<AtPadFFT>()));
124 LOG(debug) <<
"Updating filter ";
125 for (
int i = 0; i < 512 / 2 + 1; ++i) {
129 LOG(debug2) << i <<
" " << TComplex::Abs(R) <<
" " <<
getFilterKernel(i) <<
" " << filterVal;
137 LOG(debug) <<
"Creating response pad for " << padNum;
138 auto fPar =
dynamic_cast<AtDigiPar *
>(FairRun::Instance()->GetRuntimeDb()->getContainer(
"AtDigiPar"));
142 LOG(debug) <<
"Filling response pad for " << padNum;
143 for (
int i = 0; i < 512; ++i) {
144 auto time = (i + 0.5) * tbTime;
169 auto filter =
dynamic_cast<AtPadFFT *
>(pad->GetAugment(
"filter"));
170 if (filter !=
nullptr)
178 LOG(debug) <<
"Analyzing pad " << pad.
GetPadNum();
180 auto recoFFT =
dynamic_cast<AtPadFFT *
>(pad.
AddAugment(
"Qreco-fft", std::make_unique<AtPadFFT>()));
181 LOG(debug) <<
"Getting response filter";
183 LOG(debug) <<
"Got response filter";
185 if (padFFT ==
nullptr)
186 throw std::runtime_error(
"Missing FFT information in pad");
189 for (
int i = 0; i < 512 / 2 + 1; ++i) {
190 auto a = padFFT->GetPointComplex(i);
191 auto b = respFFT.GetPointComplex(i);
192 LOG(debug2) << i <<
" " << a <<
" " << b <<
" " << a * b;
195 recoFFT->SetPoint(i, z);
206 auto charge = std::make_unique<AtPadArray>();
208 for (
int i = 0; i < 512; ++i)
209 charge->SetArray(i,
fFFTbackward->GetPointReal(i) - baseline);
241 LOG(debug) <<
"PadNum: " << pad.
GetPadNum();
242 auto hitVec =
getZandQ(charge->GetArray());
244 for (
auto &ZandQ : hitVec) {
250 LOG(debug) <<
"Z(tb): " << ZandQ.z <<
" +- " << std::sqrt(ZandQ.zVar);
251 LOG(debug) <<
"Z(mm): " << pos.Z() <<
" +- " << std::sqrt(posVarZ);
253 auto hit = std::make_unique<AtHit>(pad.
GetPadNum(), pos, ZandQ.q);
254 hit->SetPositionVariance({posVarXY.first, posVarXY.second, posVarZ});
255 hit->SetChargeVariance(ZandQ.qVar);
257 ret.push_back(std::move(hit));
266 double q = std::accumulate(charge.begin(), charge.end(), 0.0);
268 for (
int i = 0; i < charge.size(); ++i)
274 for (
int i = 0; i < charge.size(); ++i) {
275 zVar += charge[i] * (i - z) * (i - z);
282 return {{z, zVar, q, qVar}};
static std::unique_ptr< AtPadFFT > CreateFromFFT(const TVirtualFFT *fft)
void initFilter()
Update all "filter" augments in fEventResponse with the new parameters.
AtPad * GetPad(Int_t padNum)
void SetCutoffFreq(int freq)
virtual HitVector chargeToHits(AtPad &charge, std::string qName)
Double_t CalculateZGeo(Double_t peakIdx)
virtual HitVector AnalyzePad(AtPad *pad) override
AtRawEvent fEventResponse
void SetPointIm(int i, Double_t val)
Sets the imaginary value of the ith frequency component.
std::unique_ptr< TVirtualFFT > fFFT
void updateFilter(const AtPadFFT &fft, AtPadFFT *filter)
virtual HitData getZandQ(const AtPad::trace &charge)
void SetPointRe(int i, Double_t val)
Sets the real value of the ith frequency component.
virtual double getZhitVariance(double zLoc, double zLocVar) const override
std::array< Double_t, 512 > trace
std::vector< std::unique_ptr< AtHit > > HitVector
void SetADC(const trace &val)
Int_t GetTBTime() const
returns the time duration of a time bucket in given sampling time in ns.
AtPad & GetResponse(int padNum)
Get the AtPad describing the response of the electronics.
ROOT::Math::XYZPoint XYZPoint
std::unique_ptr< TVirtualFFT > fFFTbackward
const AtPadFFT & GetResponseFFT(int padNum)
Get the fourier transform describing the response of the electronics.
virtual std::pair< double, double > getXYhitVariance() const
XYPoint GetPadCoord() const
void SetFilterOrder(int order)
const PadVector & GetPads() const
double getFilterKernel(int freq)
const AtPadFFT & GetResponseFilter(int padNum)
Get the filter in fourier space describing the response of the electronics.
ROOT::Math::XYZPoint XYZPoint
AtPad * createResponsePad(int padNum)
Abstract base class for getting current through deconvolution.
AtPadBase * GetAugment(std::string name)
const trace & GetADC() const
AtPad * AddPad(Ts &&...params)
Create a new pad in this event.
TComplex GetPointComplex(int i) const
std::vector< ZHitData > HitData
Data structure for Z loc (TB), Z variance (TB), Charge (arb), Charge variance (arb)
Holds an addition array of doubles for an AtPad.
Container class for AtPadBase objects.
HitVector AnalyzeFFTpad(AtPad &pad)
Assumes that the pad has it's fourier transform information filled.
AtPadBase * AddAugment(std::string name, std::unique_ptr< AtPadBase > augment)