@@ -15,42 +15,18 @@ using namespace o2::phos;
1515
1616ClassImp (Digit);
1717
18- constexpr int Digit::kMaxLabels ;
19-
2018Digit::Digit (Int_t absId, Double_t amplitude, Double_t time, Int_t label)
21- : DigitBase(time), mAbsId(absId), mAmplitude(amplitude), mTime(time), mNlabels( 0 )
19+ : DigitBase(time), mAbsId(absId), mAmplitude(amplitude), mTime(time), mLabel(label )
2220{
23- if (label >= 0 ) {
24- mLabels [0 ] = label; // sofar there is no lables, no need to to sort
25- mEProp [0 ] = 1 .;
26- mNlabels = 1 ;
27- }
2821}
29- Digit::Digit (Hit hit) : mAbsId(hit.GetDetectorID()), mAmplitude(hit.GetEnergyLoss()), mTime(hit.GetTime()), mNlabels( 0 )
22+ Digit::Digit (Hit hit, int label ) : mAbsId(hit.GetDetectorID()), mAmplitude(hit.GetEnergyLoss()), mTime(hit.GetTime()), mLabel(label )
3023{
31- mLabels [0 ] = hit.GetTrackID (); // so far there is no lables, no need to to sort
32- mEProp [0 ] = 1 .;
33- for (Int_t i = 1 ; i < kMaxLabels ; i++) {
34- mLabels [i] = -1 ;
35- mEProp [i] = 0 .;
36- }
3724}
3825void Digit::FillFromHit (Hit hit)
3926{
4027 mAbsId = hit.GetDetectorID ();
4128 mAmplitude = hit.GetEnergyLoss ();
4229 mTime = hit.GetTime ();
43- if (hit.GetTrackID () >= 0 ) {
44- mLabels [0 ] = hit.GetTrackID (); // so far there is no lables, no need to to sort
45- mEProp [0 ] = 1 .;
46- mNlabels = 1 ;
47- } else {
48- mNlabels = 0 ;
49- }
50- for (Int_t i = 1 ; i < kMaxLabels ; i++) {
51- mLabels [i] = 0 ;
52- mEProp [i] = 0 .;
53- }
5430}
5531
5632bool Digit::operator <(const Digit& other) const
@@ -79,64 +55,7 @@ bool Digit::canAdd(const Digit other) const
7955Digit& Digit::operator +=(const Digit& other)
8056{
8157
82- // Adds the amplitude of digits and completes the list of primary particles
83- double scaleThis = mAmplitude / (mAmplitude + other.mAmplitude );
84- double scaleOther = other.mAmplitude / (mAmplitude + other.mAmplitude );
85- for (Int_t i = 0 ; i < mNlabels ; i++) {
86- mEProp [i] *= scaleThis;
87- }
88- if (other.mNlabels > 0 ) {
89- // copy and scale EProp of other digit
90- double otherEProp[kMaxLabels ];
91- for (Int_t i = 0 ; i < other.mNlabels ; i++) {
92- otherEProp[i] = scaleOther * other.mEProp [i];
93- }
94- double tmpEProp[kMaxLabels ];
95- Label tmpLabels[kMaxLabels ];
96-
97- // Now find largest Energy Proportion
98- int i1 = 0 , i2 = 0 , i = 0 ;
99- while (i < kMaxLabels ) {
100- if (i1 >= mNlabels ) {
101- while (i2 < other.mNlabels ) {
102- tmpEProp[i] = otherEProp[i2];
103- tmpLabels[i] = other.mLabels [i2];
104- i++;
105- i2++;
106- }
107- break ;
108- }
109- if (i2 >= other.mNlabels ) {
110- while (i1 < mNlabels ) {
111- tmpEProp[i] = mEProp [i1];
112- tmpLabels[i] = mLabels [i1];
113- i++;
114- i1++;
115- }
116- break ;
117- }
118-
119- if (mEProp [i1] > otherEProp[i2]) {
120- tmpEProp[i] = mEProp [i1];
121- tmpLabels[i] = mLabels [i1];
122- i++;
123- i1++;
124- } else {
125- tmpEProp[i] = otherEProp[i2];
126- tmpLabels[i] = other.mLabels [i2];
127- i++;
128- i2++;
129- }
130- }
131- // Copy to current digit
132- for (Int_t ii = 0 ; ii < i; ii++) {
133- mEProp [ii] = tmpEProp[ii];
134- mLabels [ii] = tmpLabels[ii];
135- }
136- }
137-
138- mNlabels = std::min (kMaxLabels , other.mNlabels + mNlabels );
139-
58+ // Adds the amplitude of digits
14059 // TODO: What about time? Should we assign time of more energetic digit? More complicated treatment?
14160 if (mAmplitude < other.mAmplitude ) {
14261 mTime = other.mTime ;
0 commit comments