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