]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSDigit.cxx
added tcsh UI
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 //  PHOS digit: Id
20 //              energy
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 //
24 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
25
26
27 // --- ROOT system ---
28
29 // --- Standard library ---
30
31 #include <iostream.h>
32
33 // --- AliRoot header files ---
34
35 #include "AliPHOSDigit.h"
36
37
38 ClassImp(AliPHOSDigit)
39
40 //____________________________________________________________________________
41   AliPHOSDigit::AliPHOSDigit() 
42 {
43   // default ctor 
44
45   fIndexInList = -1 ; 
46   fNprimary    = 0 ;  
47   fNMaxPrimary = 5 ; 
48 }
49
50 //____________________________________________________________________________
51 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Int_t index) 
52 {  
53   // ctor with all data 
54
55   fNMaxPrimary = 5 ; 
56   fAmp         = digEnergy ;
57   fId          = id ;
58   fIndexInList = index ; 
59   if( primary != -1){
60     fNprimary    = 1 ; 
61     fPrimary[0]  = primary ;
62   }
63   else{  //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
64     fNprimary    = 0 ; 
65     fPrimary[0]  = -1 ;
66   }
67   Int_t i ;
68   for ( i = 1; i < fNMaxPrimary ; i++)
69     fPrimary[i]  = -1 ; 
70 }
71
72 //____________________________________________________________________________
73 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) 
74 {
75   // copy ctor
76   
77
78   fNMaxPrimary = digit.fNMaxPrimary ;  
79   Int_t i ;
80   for ( i = 0; i < fNMaxPrimary ; i++)
81     fPrimary[i]  = digit.fPrimary[i] ;
82   fAmp         = digit.fAmp ;
83   fId          = digit.fId;
84   fIndexInList = digit.fIndexInList ; 
85   fNprimary    = digit.fNprimary ;
86 }
87
88 //____________________________________________________________________________
89 AliPHOSDigit::~AliPHOSDigit() 
90 {
91   // Delete array of primiries if any
92   
93 }
94
95 //____________________________________________________________________________
96 Int_t AliPHOSDigit::Compare(const TObject * obj) const
97 {
98   // Compares two digits with respect to its Id
99   // to sort according increasing Id
100
101   Int_t rv ;
102
103   AliPHOSDigit * digit = (AliPHOSDigit *)obj ; 
104
105   Int_t iddiff = fId - digit->GetId() ; 
106
107   if ( iddiff > 0 ) 
108     rv = 1 ;
109   else if ( iddiff < 0 )
110     rv = -1 ; 
111   else
112     rv = 0 ;
113   
114   return rv ; 
115
116 }
117
118 //____________________________________________________________________________
119 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
120 {
121   // retrieves the primary particle number given its index in the list 
122   Int_t rv = -1 ;
123   if ( index <= fNprimary ){
124     rv = fPrimary[index-1] ;
125   } 
126
127   return rv ; 
128   
129 }
130 //____________________________________________________________________________
131 void AliPHOSDigit::Print(Option_t *option) const
132 {
133   printf("PHOS digit: Amp=%d, Id=%d\n",fAmp,fId);
134 }
135 //____________________________________________________________________________
136 void AliPHOSDigit::ShiftPrimary(Int_t shift)
137 {
138   //shifts primary number to BIG offset, to separate primary in different TreeK
139   Int_t index  ;
140   for(index = 0; index <fNprimary; index ++ ){
141     fPrimary[index] = fPrimary[index]+ shift * 10000000   ;
142   } 
143 }
144 //____________________________________________________________________________
145 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const 
146 {
147   // Two digits are equal if they have the same Id
148   
149   if ( fId == digit.fId ) 
150     return kTRUE ;
151   else 
152     return kFALSE ;
153 }
154  
155 //____________________________________________________________________________
156 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) 
157 {
158   // Adds the amplitude of digits and completes the list of primary particles
159   // if amplitude is larger than 
160   
161   fAmp += digit.fAmp ;
162   
163   Int_t max1 = fNprimary ; 
164   
165   Int_t index ; 
166   for (index = 0 ; index < digit.fNprimary ; index++){
167     Bool_t deja = kTRUE ;
168     Int_t old ;
169     for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
170       if(fPrimary[old] == (digit.fPrimary)[index])
171         deja = kFALSE;
172     }
173     if(deja){
174       fPrimary[fNprimary] = (digit.fPrimary)[index] ; 
175       fNprimary++ ;
176       if(fNprimary>fNMaxPrimary) {
177         cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ;
178         return *this ;
179       }
180     }
181   }
182   
183   return *this ;
184 }
185
186 //____________________________________________________________________________
187 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
188 {
189   // Prints the data of the digit
190   
191   out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ; 
192   Int_t i ;
193   for(i=0;i<digit.fNprimary;i++)
194     out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
195   out << "Position in list = " << digit.fIndexInList << endl ; 
196   return out ;
197 }
198
199