14 vector<TVector3> hitPosition;
15 vector<double> hitEnergy;
16 double energyInFiducial = 0;
18 for (
size_t hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) {
19 const auto position = fInputHitsEvent->GetPosition(hitIndex);
20 const auto energy = fInputHitsEvent->GetEnergy(hitIndex);
21 const auto time = fInputHitsEvent->GetTime(hitIndex);
22 const auto type = fInputHitsEvent->GetType(hitIndex);
23 fOutputHitsEvent->
AddHit(position, energy, time, type);
27 cerr <<
"TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : "
28 <<
"Negative or zero energy found in hit " << hitIndex << endl;
32 const auto daqId = fReadout->
GetDaqId(position,
false);
33 const auto channelType = fReadout->GetTypeForChannelDaqId(daqId);
39 hitPosition.push_back(position);
40 hitEnergy.push_back(energy);
42 if (fFiducialDiameter > 0) {
43 TVector3 relativePosition = position - fFiducialPosition;
44 relativePosition.SetZ(0);
45 const double distance = relativePosition.Mag();
46 if (distance > fFiducialDiameter / 2) {
49 energyInFiducial += energy;
53 const double readoutEnergy = accumulate(hitEnergy.begin(), hitEnergy.end(), 0.0);
55 if (fRemoveZeroEnergyEvents && readoutEnergy <= 0) {
59 TVector3 positionAverage;
60 for (
size_t i = 0; i < hitPosition.size(); i++) {
61 positionAverage += hitPosition[i] * hitEnergy[i];
63 positionAverage *= 1.0 / readoutEnergy;
66 TVector3 positionSigma;
67 for (
size_t i = 0; i < hitPosition.size(); i++) {
68 TVector3 diff2 = hitPosition[i] - positionAverage;
69 diff2.SetX(diff2.X() * diff2.X());
70 diff2.SetY(diff2.Y() * diff2.Y());
71 diff2.SetZ(diff2.Z() * diff2.Z());
72 positionSigma += diff2 * hitEnergy[i];
74 positionSigma *= 1.0 / readoutEnergy;
75 positionSigma.SetX(sqrt(positionSigma.X()));
76 positionSigma.SetY(sqrt(positionSigma.Y()));
77 positionSigma.SetZ(sqrt(positionSigma.Z()));
92 return fOutputHitsEvent;
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.