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