]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSRawCluster.cxx
Changes by Massimo Masera to allow Recpoints and Clusters to be written
[u/mrichter/AliRoot.git] / ITS / AliITSRawCluster.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 /*
17 $Log$
18 */
19 #include <iostream.h>
20 #include <TMath.h>
21  
22 #include "AliITSRawCluster.h"
23
24 ClassImp(AliITSRawCluster)
25 ClassImp(AliITSRawClusterSDD)
26
27 //______________________________________________________________________
28 AliITSRawClusterSDD::AliITSRawClusterSDD(Int_t wing,
29                                          Float_t Anode,Float_t Time,
30                                          Float_t Charge,Float_t PeakAmplitude,
31                                          Int_t PeakPosition,
32                                          Float_t Asigma,Float_t Tsigma,
33                                          Float_t DriftPath,
34                                          Float_t AnodeOffset,
35                                          Int_t Samples,Int_t Tstart,
36                                          Int_t Tstop,Int_t Tstartf,
37                                          Int_t Tstopf,Int_t Anodes, 
38                                          Int_t Astart, Int_t Astop){
39     // constructor
40
41     fWing          = wing;
42     fAnode         = Anode;
43     fTime          = Time;
44     fQ             = Charge;
45     fPeakAmplitude = PeakAmplitude;
46     fPeakPosition  = PeakPosition;
47     fAsigma        = Asigma;
48     fTsigma        = Tsigma;
49     fNanodes       = Anodes;
50     fTstart        = Tstart;
51     fTstop         = Tstop;
52     fTstartf       = Tstartf;
53     fTstopf        = Tstopf;
54     fAstart        = Astart;
55     fAstop         = Astop;
56     fMultiplicity  = Samples;
57     fSumAmplitude  = 0;
58
59     Int_t sign = 1;
60     for(Int_t i=0;i<fWing; i++) sign *= (-1);
61     fX = DriftPath*sign/10000.;
62     fZ = AnodeOffset/10000.;
63 }
64 //______________________________________________________________________
65 AliITSRawClusterSDD::AliITSRawClusterSDD( const AliITSRawClusterSDD & source){
66     // copy constructor
67
68     fWing          = source.fWing;
69     fAnode         = source.fAnode;
70     fTime          = source.fTime;
71     fQ             = source.fQ;
72     fPeakAmplitude = source.fPeakAmplitude;
73     fPeakPosition  = source.fPeakPosition;
74     fAsigma        = source.fAsigma;
75     fTsigma        = source.fTsigma;
76     fNanodes       = source.fNanodes;
77     fTstart        = source.fTstart;
78     fTstop         = source.fTstop;
79     fTstartf       = source.fTstartf;
80     fTstopf        = source.fTstopf;
81     fAstart        = source.fAstart;
82     fAstop         = source.fAstop;
83
84     fMultiplicity  = source.fMultiplicity;
85     fSumAmplitude  = source.fSumAmplitude;
86     fX             = source.fX;
87     fZ             = source.fZ;
88 }
89 //______________________________________________________________________
90 void AliITSRawClusterSDD::Add(AliITSRawClusterSDD* clJ) {
91     // add
92
93     fAnode = (fAnode*fQ + clJ->A()*clJ->Q())/(fQ+clJ->Q());
94     fTime  = ( fTime*fQ + clJ->T()*clJ->Q())/(fQ+clJ->Q());
95     fX     = (    fX*fQ + clJ->X()*clJ->Q())/(fQ+clJ->Q());
96     fZ     = (    fZ*fQ + clJ->Z()*clJ->Q())/(fQ+clJ->Q());
97     fQ += clJ->Q();
98     if(fSumAmplitude == 0) fSumAmplitude += fPeakAmplitude;
99     /*
100       fAnode = (fAnode*fSumAmplitude+clJ->A()*clJ->PeakAmpl())/
101                (fSumAmplitude+clJ->PeakAmpl());
102       fTime = (fTime*fSumAmplitude +clJ->T()*clJ->PeakAmpl())/
103               (fSumAmplitude+clJ->PeakAmpl());
104       fX = (fX*fSumAmplitude +clJ->X()*clJ->PeakAmpl())/
105            (fSumAmplitude+clJ->PeakAmpl());
106       fZ = (fZ*fSumAmplitude +clJ->Z()*clJ->PeakAmpl())/
107            (fSumAmplitude+clJ->PeakAmpl());
108     */
109     fSumAmplitude += clJ->PeakAmpl();
110
111     fTstart = clJ->Tstart();
112     fTstop  = clJ->Tstop();
113     if(fTstartf > clJ->Tstartf()) fTstartf = clJ->Tstartf();
114     if( fTstopf < clJ->Tstopf() ) fTstopf  = clJ->Tstopf();
115     if(  fAstop < clJ->Astop()  ) fAstop   = clJ->Astop();
116
117     fMultiplicity += (Int_t) (clJ->Samples());
118     (fNanodes)++;
119     if(clJ->PeakAmpl() > fPeakAmplitude) {
120         fPeakAmplitude = clJ->PeakAmpl();
121         fPeakPosition = clJ->PeakPos();
122     } // end if
123
124     return;
125 }
126 //______________________________________________________________________
127 Bool_t AliITSRawClusterSDD::Brother(AliITSRawClusterSDD* cluster,
128                                     Float_t danode,Float_t dtime) {
129
130     Bool_t brother = kFALSE;
131
132     Bool_t test2 = kFALSE;
133     Bool_t test3 = kFALSE;
134     Bool_t test4 = kFALSE;
135     Bool_t test5 = kFALSE;
136   
137     if(fWing != cluster->W()) return brother;
138
139     if(fTstopf >= cluster->Tstart() &&
140        fTstartf <= cluster->Tstop()) test2 = kTRUE;
141     if(cluster->Astop() == (fAstop+1)) test3 = kTRUE;
142
143     if(TMath::Abs(fTime-cluster->T()) < dtime) test4 = kTRUE;
144     if(TMath::Abs(fAnode-cluster->A()) < danode) test5 = kTRUE;
145
146     if((test2 && test3) || (test4 && test5) ) {
147         return brother = kTRUE;
148     } // end if
149   
150     return brother;
151 }
152 //______________________________________________________________________
153 void AliITSRawClusterSDD::PrintInfo() {
154     // print
155
156     cout << ", Anode " << fAnode << ", Time: " << fTime << ", Charge: " << fQ;
157     cout << ", Samples: " << fMultiplicity;
158     cout << ", X: " << fX << ", Z: " << fZ << "tstart " << fTstart 
159          << "tstop "<< fTstop <<endl;
160 }
161 //======================================================================
162 ClassImp(AliITSRawClusterSPD)
163 //______________________________________________________________________
164 AliITSRawClusterSPD::AliITSRawClusterSPD(Float_t clz,Float_t clx,
165                                          Float_t Charge,Int_t ClusterSizeZ,
166                                          Int_t ClusterSizeX,Int_t xstart,
167                                          Int_t xstop,Int_t xstartf,
168                                          Int_t xstopf,
169                                          Float_t zstart,Float_t zstop,
170                                          Int_t zend) {
171     // constructor
172
173     fZ       = clz;
174     fX       = clx;
175     fQ       = Charge;
176     fNClZ    = ClusterSizeZ;
177     fNClX    = ClusterSizeX;
178     fXStart  = xstart;
179     fXStop   = xstop;
180     fXStartf = xstartf;
181     fXStopf  = xstopf;
182     fZStart  = zstart;
183     fZStop   = zstop;
184     fZend    = zend;
185 }
186 //______________________________________________________________________
187 void AliITSRawClusterSPD::Add(AliITSRawClusterSPD* clJ) {
188     // Recolculate the new center of gravity coordinate and cluster sizes
189     // in both directions after grouping of clusters
190
191     if(this->fZStop < clJ->ZStop()) this->fZStop = clJ->ZStop();
192     this->fZ      = this->fZ + clJ->Z();
193     this->fX      = (this->fX + clJ->X())/2.;
194     this->fQ      = this->fQ + clJ->Q();
195     this->fXStart = clJ->XStart(); // for a comparison with the next
196     this->fXStop  = clJ->XStop();  // z column
197     if(this->fXStartf > clJ->XStartf()) this->fXStartf = clJ->XStartf();
198     if(this->fXStopf < clJ->XStopf())   this->fXStopf  = clJ->XStopf();
199     if(this->fZend < clJ->Zend())       this->fZend    = clJ->Zend();
200     this->fNClX   = this->fXStopf - this->fXStartf + 1; 
201     (this->fNClZ)++;
202
203     return;
204 }
205 //______________________________________________________________________
206 Bool_t AliITSRawClusterSPD::Brother(AliITSRawClusterSPD* cluster,
207                                     Float_t dz,Float_t dx) {
208     // fXStart, fXstop and fZend information is used now instead of dz and dx
209     // to check an absent (or a present) of the gap between two pixels in 
210     // both x and z directions. The increasing order of fZend is used.
211     Bool_t brother = kFALSE;  
212     Bool_t test2 = kFALSE;  
213     Bool_t test3 = kFALSE;
214
215     // Diagonal clusters are included:
216     if(fXStop >= (cluster->XStart() -1) && 
217        fXStart <= (cluster->XStop()+1)) test2 = kTRUE;
218
219     // Diagonal clusters are excluded:   
220     // if(fXStop >= cluster->XStart() &&
221     //    fXStart <= cluster->XStop()) test2 = kTRUE;
222     if(cluster->Zend() == (fZend + 1)) test3 = kTRUE; 
223     if(test2 && test3) {
224         // cout<<"test 2,3 0k, brother = true "<<endl;
225         return brother = kTRUE;
226     } // end if
227     return brother;
228 }
229 //______________________________________________________________________
230 void AliITSRawClusterSPD::PrintInfo(){
231     // print
232
233     cout << ", Z: " << fZ << ", X: " << fX << ", Charge: " << fQ<<endl;
234     cout << " Z cluster size: " << fNClZ <<", X cluster size "<< fNClX <<endl;
235     cout <<" XStart, XStop, XStartf,XStopf,Zend ="<<fXStart<<","
236          <<fXStop<<","<<fXStartf<<","<<fXStopf<<","<<fZend<<endl;
237 }
238 //======================================================================
239 ClassImp(AliITSRawClusterSSD)
240 //______________________________________________________________________
241 AliITSRawClusterSSD::AliITSRawClusterSSD(Float_t Prob,Int_t Sp,Int_t Sn) {  
242     // constructor
243
244     //fProbability   = Prob;
245     fMultiplicity  = Sp;
246     fMultiplicityN = Sn;
247 }