1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
21 // 3 identifiers for the primary particle(s) at the origine of the digit
22 // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
23 // It would be nice to replace the 3 identifiers by an array, but, because digits are kept in a TClonesQArray,
24 // it is not possible to stream such an array... (beyond my understqnding!)
26 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
29 // --- ROOT system ---
31 // --- Standard library ---
35 // --- AliRoot header files ---
37 #include "AliPHOSDigit.h"
40 ClassImp(AliPHOSDigit)
42 //____________________________________________________________________________
43 AliPHOSDigit::AliPHOSDigit()
50 fPrimary = new Int_t[fNMaxPrimary] ;
53 //____________________________________________________________________________
54 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index)
59 fPrimary = new Int_t[fNMaxPrimary] ;
62 fIndexInList = index ;
65 fPrimary[0] = primary ;
67 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
72 for ( i = 1; i < fNMaxPrimary ; i++)
76 //____________________________________________________________________________
77 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
82 fPrimary = new Int_t[fNMaxPrimary] ;
85 fIndexInList = digit.fIndexInList ;
86 fNprimary = digit.fNprimary ;
87 fNMaxPrimary = digit.fNMaxPrimary ;
89 for ( i = 0; i < fNMaxPrimary ; i++)
90 fPrimary[i] = digit.fPrimary[i] ;
93 //____________________________________________________________________________
94 AliPHOSDigit::~AliPHOSDigit()
96 // Delete array of primiries if any
101 //____________________________________________________________________________
102 Int_t AliPHOSDigit::Compare(TObject * obj)
104 // Compares two digits with respect to its Id
105 // to sort according increasing Id
109 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
111 Int_t iddiff = fId - digit->GetId() ;
115 else if ( iddiff < 0 )
124 //____________________________________________________________________________
125 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
127 // Returns the primary particle id index =1,2,3
130 if ( index > fNMaxPrimary )
131 cout << "AliPHOSDigit ERROR > only " << fNMaxPrimary << " primaries allowed" << endl ;
133 rv = fPrimary[index-1] ;
139 //____________________________________________________________________________
140 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
142 // Two digits are equal if they have the same Id
144 if ( fId == digit.fId )
150 //____________________________________________________________________________
151 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
153 // Adds the amplitude of digits and completes the list of primary particles
154 // if amplitude is larger than
158 Int_t max1 = fNprimary ;
159 Int_t max2 = digit.fNprimary ;
161 if ( fNprimary >= fNMaxPrimary )
162 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
164 fNprimary += digit.fNprimary ;
165 if ( fNprimary > fNMaxPrimary ) {
166 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
167 fNprimary = fNMaxPrimary ;
170 for (index = 0 ; index < max2 ; index++)
171 fPrimary[index+max1] = (digit.fPrimary)[index] ;
177 //____________________________________________________________________________
178 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
180 // Prints the data of the digit
182 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl
183 << "Primary 1 = " << digit.fPrimary[0] << endl
184 << "Primary 2 = " << digit.fPrimary[1] << endl
185 << "Primary 3 = " << digit.fPrimary[2] << endl
186 << "Primary 4 = " << digit.fPrimary[3] << endl
187 << "Primary 5 = " << digit.fPrimary[4] << endl
188 << "Position in list = " << digit.fIndexInList << endl ;