Adding some further mother volumes to speed-up the overlap checking and particle...
[u/mrichter/AliRoot.git] / ITS / AliITSdigitSDD.cxx
CommitLineData
e869281d 1/**************************************************************************
2 * Copyright(c) 2004-2006, 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#include <AliITSdigitSDD.h>
fcf95fc7 17#include <AliITSCalibrationSDD.h>
e869281d 18#include <TArrayI.h>
19#include <TArrayF.h>
e869281d 20
21///////////////////////////////////////////////////////////////////
22// //
23// Class defining the digit object
24// for SDD
25// Inherits from AliITSdigit
26// //
27///////////////////////////////////////////////////////////////////
28
29ClassImp(AliITSdigitSDD)
7f1a504b 30
31
e869281d 32//______________________________________________________________________
e56160b8 33AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
34fPhysics(0),
35fSignalExpanded(0){
e869281d 36 // default constructor, zero coordinates and set array
37 // elements to clearly unphysical values. A value of 0 may
38 // be a valide track of hit number.
39 Int_t i;
40
0599a018 41 for(i=0;i<fgkSize;i++) fTracks[i] = -3;
42 for(i=0;i<fgkSize;i++) fHits[i] = -1;
43 for(i=0;i<fgkSize;i++) fTcharges[i] = 0;
7f1a504b 44 SetSignalExpanded(-1000);
e869281d 45}
46//________________________________________________________________________
e56160b8 47AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
48fPhysics(phys),
49fSignalExpanded(0){
7d62fb64 50
51 // Creates a simulated SDD digit object to be updated
0599a018 52 for(Int_t i=0;i<fgkSize;i++) fTracks[i] = -3;
53 for(Int_t i=0;i<fgkSize;i++) fHits[i] = -1;
54 for(Int_t i=0;i<fgkSize;i++) fTcharges[i] = 0;
55
56 SetSignalExpanded(-1000);
e869281d 57}
7f1a504b 58
59//________________________________________________________________________
60void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
61 const Int_t *hits,const Float_t *charges){
7d62fb64 62
7f1a504b 63 // Protected function used by standard constructors
64 fPhysics = phys;
0599a018 65 for(Int_t i=0; i<fgkSize; i++) {
7f1a504b 66 fTcharges[i] = charges[i];
67 fTracks[i] = tracks[i];
68 fHits[i] = hits[i];
69 }
70}
71
e869281d 72//_____________________________________________________________________________
73AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
74 const Int_t *tracks,const Int_t *hits,
e56160b8 75 const Float_t *charges):AliITSdigit(digits),
76fPhysics(0),
77fSignalExpanded(0){
7d62fb64 78
79// standard constructor
7f1a504b 80 InitObject(phys,tracks,hits,charges);
81 SetSignalExpanded(-1000);
82}
83//_____________________________________________________________________________
84AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
e56160b8 85 const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
86fPhysics(0),
87fSignalExpanded(0){
7d62fb64 88
7f1a504b 89 //constructor setting also fSignalExpanded
90 InitObject(phys,tracks,hits,charges);
91 SetSignalExpanded(sige);
92}
e869281d 93
7f1a504b 94//_____________________________________________________________________________
e869281d 95Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
7d62fb64 96
e869281d 97 // Fills the TArrayI t with the tracks found in fTracks removing
98 // duplicated tracks, summing up their charge, and ordering the tracks
99 // by the charge contributed to this digit. It will return
100 // the number of tracks and fill the remaining elements to the array
101 // t with -1.
102 // Inputs:
103 // TArrayI &t Reference to a TArrayI to contain the list of
104 // nonduplicated track numbers.
105 // TArrayF &c Reference to a TArrayF to contain the summed charge
106 // contributed by each track.
107 // Output:
108 // TArrayI &t The input array filled with the nonduplicated track
109 // numbers.
110 // TArrayF &c The input array filled with the summed charge
111 // contributed by the corresponding track in the array t.
112 // Return:
113 // Int_t The number of none -1 entries in the TArrayI t.
114 Int_t nt = t.GetSize();
115 nt = TMath::Min(nt,c.GetSize());
116 Int_t nth = this->GetNTracks();
117 Int_t n = 0,i,j;
118 Bool_t inlist = kFALSE;
119
120 t.Reset(-1); // -1 array.
121 c.Reset(0.0); // zero array.
122 for(i=0;i<nth;i++) {
123 if(this->GetTrack(i) == -1) continue;
124 inlist = kFALSE;
125 for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
126 inlist = kTRUE;
127 c.AddAt(this->GetCharge(i)+c.At(j),j);
128 } // end for j/end if
129 if(!inlist){ // add to end of list
130 t.AddAt(this->GetTrack(i),n);
131 c.AddAt(this->GetCharge(i),n);
132 if(n<nt) n++;
133 } // end if
134 } // end for i
135
136 // Now lets sort the TArrays according to the charge. This algorithm
137 // is based on the method from Chapter 8 section 1 Straight Insertion
138 // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling
139 // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific
140 // Computing", second Edition page 330 (1997).
141 Int_t tr;
142 Float_t ch;
143 for(i=0;i<n;i++){
144 tr = t.At(i);
145 ch = c.At(i);
146 j = i-1;
147 while(j>-1 && c.At(j)>ch){
148 t.AddAt(t.At(j+1),j);
149 c.AddAt(c.At(j+1),j);
150 j--;
151 } // end while
152 t.AddAt(tr,j+1);
153 c.AddAt(ch,j+1);
154 } // end for i
155 //
156 return n;
157}
7f1a504b 158
159
e869281d 160//______________________________________________________________________
161void AliITSdigitSDD::Print(ostream *os){
7d62fb64 162
163
164 //Standard output format for this class
e869281d 165 Int_t i;
166
167 AliITSdigit::Print(os);
168 *os <<","<< fPhysics;
0599a018 169 for(i=0; i<fgkSize; i++) *os <<","<< fTcharges[i];
170 for(i=0; i<fgkSize; i++) *os <<","<< fTracks[i];
171 for(i=0; i<fgkSize; i++) *os <<","<< fHits[i];
7f1a504b 172 *os <<","<< fSignalExpanded;
e869281d 173}
174//______________________________________________________________________
175void AliITSdigitSDD::Read(istream *os){
7d62fb64 176
177 //Standard input for this class
178 Int_t i;
e869281d 179
180 AliITSdigit::Read(os);
181 *os >>fPhysics;
0599a018 182 for(i=0; i<fgkSize; i++) *os >> fTcharges[i];
183 for(i=0; i<fgkSize; i++) *os >> fTracks[i];
184 for(i=0; i<fgkSize; i++) *os >> fHits[i];
7f1a504b 185 *os >>fSignalExpanded;
e869281d 186}
187//______________________________________________________________________
188ostream &operator<<(ostream &os,AliITSdigitSDD &source){
7d62fb64 189
190 // Standard output streaming function.
e869281d 191
192 source.Print(&os);
193 return os;
194}
195//______________________________________________________________________
196istream &operator>>(istream &os,AliITSdigitSDD &source){
7d62fb64 197
198 // Standard output streaming function.
e869281d 199
200 source.Read(&os);
201 return os;
202}