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
24 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
27 // --- ROOT system ---
29 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliPHOSDigit.h"
36 ClassImp(AliPHOSDigit)
38 //____________________________________________________________________________
39 AliPHOSDigit::AliPHOSDigit()
48 //____________________________________________________________________________
49 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
57 fIndexInList = index ;
60 fPrimary[0] = primary ;
62 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
67 for ( i = 1; i < fNMaxPrimary ; i++)
71 //____________________________________________________________________________
72 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
77 fNMaxPrimary = digit.fNMaxPrimary ;
79 for ( i = 0; i < fNMaxPrimary ; i++)
80 fPrimary[i] = digit.fPrimary[i] ;
84 fIndexInList = digit.fIndexInList ;
85 fNprimary = digit.fNprimary ;
88 //____________________________________________________________________________
89 AliPHOSDigit::~AliPHOSDigit()
91 // Delete array of primiries if any
95 //____________________________________________________________________________
96 Int_t AliPHOSDigit::Compare(const TObject * obj) const
98 // Compares two digits with respect to its Id
99 // to sort according increasing Id
103 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
105 Int_t iddiff = fId - digit->GetId() ;
109 else if ( iddiff < 0 )
118 //____________________________________________________________________________
119 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
121 // retrieves the primary particle number given its index in the list
123 if ( index <= fNprimary && index > 0){
124 rv = fPrimary[index-1] ;
130 //____________________________________________________________________________
131 void AliPHOSDigit::Print(Option_t *option) const
133 printf("PHOS digit: Amp=%d, Id=%d\n",fAmp,fId);
135 //____________________________________________________________________________
136 void AliPHOSDigit::ShiftPrimary(Int_t shift)
138 //shifts primary number to BIG offset, to separate primary in different TreeK
140 for(index = 0; index <fNprimary; index ++ ){
141 fPrimary[index] = fPrimary[index]+ shift ;
144 //____________________________________________________________________________
145 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
147 // Two digits are equal if they have the same Id
149 if ( fId == digit.fId )
155 //____________________________________________________________________________
156 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
158 // Adds the amplitude of digits and completes the list of primary particles
159 // if amplitude is larger than
161 Int_t toAdd = fNprimary ;
162 if(digit.fNprimary>0){
163 if(fAmp < digit.fAmp){//most energetic primary in second digit => first primaries in list from second digit
164 for (Int_t index = 0 ; index < digit.fNprimary ; index++){
165 for (Int_t old = 0 ; old < fNprimary ; old++) { //already have this primary?
166 if(fPrimary[old] == (digit.fPrimary)[index]){
167 fPrimary[old] = -1 ; //removed
173 Int_t nNewPrimaries = digit.fNprimary+toAdd ;
174 if(nNewPrimaries >fNMaxPrimary) //Do not change primary list
175 Error("Operator +", "Increase NMaxPrimary") ;
177 for(Int_t index = fNprimary-1 ; index >=0 ; index--){ //move old primaries
178 if(fPrimary[index]>-1){
179 fPrimary[fNprimary+toAdd]=fPrimary[index] ;
184 for(Int_t index = 0; index < digit.fNprimary ; index++){
185 fPrimary[index] = (digit.fPrimary)[index] ;
187 fNprimary = nNewPrimaries ;
190 else{ //add new primaries to the end
191 for(Int_t index = 0 ; index < digit.fNprimary ; index++){
192 Bool_t deja = kTRUE ;
193 for(Int_t old = 0 ; old < fNprimary; old++) { //already have this primary?
194 if(fPrimary[old] == (digit.fPrimary)[index]){
200 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
202 if(fNprimary>fNMaxPrimary) {
203 Error("Operator +", "Increase NMaxPrimary") ;
213 if(fTime > digit.fTime)
214 fTime = digit.fTime ;
219 //____________________________________________________________________________
220 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
222 // Prints the data of the digit
224 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
226 // for(i=0;i<digit.fNprimary;i++)
227 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
228 // out << "Position in list = " << digit.fIndexInList << endl ;
229 digit.Warning("operator <<", "Implement differently") ;