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