ATLAS Offline Software
Loading...
Searching...
No Matches
FCS_StepInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "GaudiKernel/MsgStream.h"
8
9/*
10ISF_FCS_Parametrization::FCS_StepInfo::FCS_StepInfo(const FCS_StepInfo& first,
11const FCS_StepInfo& second)
12{
13 double esum = first.m_energy + second.m_energy;
14 double w1 = 0;
15 double w2 = 0;
16
17 if (esum > 0) {
18 w1 = first.m_energy/esum;
19 w2 = second.m_energy/esum;
20 }
21
22 m_pos = w1*first.m_pos + w2*second.m_pos;
23 m_time = w1*first.m_time + w2*second.m_time;
24 m_energy = esum;
25 m_valid = true;
26 m_detector = first.m_detector; //need to make sure that it's not merging hits
27from different detector parts.. m_ID = first.m_ID; //dtto
28}
29*/
30double
32 return (this->position().diff2(other.position()));
33}
34
38 if (identify() != other.identify()) {
39 ATH_MSG_WARNING("Not merging hits from different cells!!! "
40 << identify() << " / " << other.identify());
41 return *this;
42 }
43
44 if ((fabs(energy()) > 1e-9) && (fabs(other.energy()) > 1e-9)) {
45 // both !=0
46 // Use absolute energies for weighting
47 double eabssum = fabs(energy()) + fabs(other.energy());
48 double esum = energy() + other.energy();
49 double w1 = fabs(energy()) / eabssum;
50 double w2 = fabs(other.energy()) / eabssum;
51 // Average position, time, energy sum
52 m_pos = w1 * m_pos + w2 * other.m_pos;
53 setEnergy(esum);
54 setTime(w1 * time() + w2 * other.time());
55
56 } else if (fabs(energy()) < 1e-9) {
57 // original is 0, use other
58 setEnergy(other.energy());
59 setP(other.position());
60 setTime(other.time());
61 } else if (fabs(other.energy()) < 1e-9) {
62 // other is 0, use original
63 // don't need to do anything...
64 } else {
65 ATH_MSG_WARNING("merging hits something weird: "
66 << "\nOriginal hit: " << energy() << " " << position()
67 << "\nSecond hit: " << other.energy() << " "
68 << other.position());
69 }
70
71 /*
72 double esum = energy() + other.energy();
73
74 double w1 = 0;
75 double w2 = 0;
76
77 //ignore negative energies
78 if (energy() <= 0.)
79 {
80 if (other.energy()>0.)
81 {
82 //use the other hit + sum energy
83 //setEnergy(other.energy());
84 setEnergy(esum);
85 setTime(other.time());
86 setP(other.position());
87 }
88 else
89 {
90 //both are negative -> set both to 0
91 setEnergy(0.);
92 setTime(0.);
93 setP(CLHEP::Hep3Vector(0,0,0));
94 //both are negative -> set both to 0
95 }
96 }
97 else if (other.energy() <0.)
98 {
99 //keep original, but with sum energy
100 setEnergy(esum);
101 }
102 else if (esum > 0) {
103 w1 = energy()/esum;
104 w2 = other.energy()/esum;
105
106 m_pos = w1*m_pos + w2*other.m_pos;
107 setEnergy(esum);
108 setTime(w1* time()+ w2 * other.time());
109 //m_time = w1*m_time + w2*other.m_time; //average time??
110 //what about m_ID...
111 }
112 else
113 {
114 ATH_MSG_INFO("Wow, you're still here??");
115 }
116 */
117 return *this;
118}
#define ATH_MSG_WARNING(x)
CLHEP::Hep3Vector position() const
return spacial position
FCS_StepInfo & operator+=(const FCS_StepInfo &other)
energy weighted sum
void setP(const CLHEP::Hep3Vector &p)
set position
FCS_StepInfo()
empty default constructor
double diff2(const FCS_StepInfo &other) const
return spactial distance squared
CLHEP::Hep3Vector m_pos
spatial position
void setTime(float t, int ind=0)
Set time of ind-th sub-hit in a hit.
float time(int ind=0) const
Return time of ind-th sub-hit.
void setEnergy(float e, int ind=0)
Set energy of ind-th sub-hit in a hit.
float energy(int ind=0) const
Return energy of ind-th sub-hit.
Identifier identify(void) const
Return logical ID of the pmt.