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)
60 fIndexInList = index ;
63 fPrimary[0] = primary ;
65 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
70 for ( i = 1; i < fNMaxPrimary ; i++)
74 //____________________________________________________________________________
75 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
81 fIndexInList = digit.fIndexInList ;
82 fNprimary = digit.fNprimary ;
83 fNMaxPrimary = digit.fNMaxPrimary ;
85 for ( i = 0; i < fNMaxPrimary ; i++)
86 fPrimary[i] = digit.fPrimary[i] ;
89 //____________________________________________________________________________
90 Int_t AliPHOSDigit::Compare(TObject * obj)
92 // Compares two digits with respect to its Id
93 // to sort according increasing Id
97 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
99 Int_t iddiff = fId - digit->GetId() ;
103 else if ( iddiff < 0 )
112 //____________________________________________________________________________
113 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
115 // Returns the primary particle id index =1,2,3
118 if ( index > fNMaxPrimary )
119 cout << "AliPHOSDigit ERROR > only " << fNMaxPrimary << " primaries allowed" << endl ;
121 rv = fPrimary[index-1] ;
127 //____________________________________________________________________________
128 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
130 // Two digits are equal if they have the same Id
132 if ( fId == digit.fId )
138 //____________________________________________________________________________
139 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
141 // Adds the amplitude of digits and completes the list of primary particles
142 // if amplitude is larger than
146 Int_t max1 = fNprimary ;
147 Int_t max2 = digit.fNprimary ;
149 if ( fNprimary >= fNMaxPrimary )
150 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
152 fNprimary += digit.fNprimary ;
153 if ( fNprimary > fNMaxPrimary ) {
154 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
155 fNprimary = fNMaxPrimary ;
158 for (index = 0 ; index < max2 ; index++)
159 fPrimary[index+max1] = (digit.fPrimary)[index] ;
165 //____________________________________________________________________________
166 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
168 // Prints the data of the digit
170 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl
171 << "Primary 1 = " << digit.fPrimary[0] << endl
172 << "Primary 2 = " << digit.fPrimary[1] << endl
173 << "Primary 3 = " << digit.fPrimary[2] << endl
174 << "Primary 4 = " << digit.fPrimary[3] << endl
175 << "Primary 5 = " << digit.fPrimary[4] << endl
176 << "Position in list = " << digit.fIndexInList << endl ;