]>
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> | |
20 | #include <TMath.h> | |
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 | //________________________________________________________________________ | |
47 | AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): | |
48 | AliITSdigit(digits){ | |
49 | // Creates a simulated SDD digit object to be updated | |
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){ | |
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, | |
70 | const Float_t *charges): | |
71 | AliITSdigit(digits){ | |
7f1a504b | 72 | // standard constructor |
73 | InitObject(phys,tracks,hits,charges); | |
74 | SetSignalExpanded(-1000); | |
75 | } | |
76 | //_____________________________________________________________________________ | |
77 | AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits, | |
78 | const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): | |
79 | AliITSdigit(digits) { | |
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, | |
88 | AliITSresponseSDD* resp): | |
89 | AliITSdigit(digits) { | |
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){ | |
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 | //______________________________________________________________________ |
161 | void AliITSdigitSDD::Print(ostream *os){ | |
162 | //Standard output format for this class | |
163 | Int_t i; | |
164 | ||
165 | AliITSdigit::Print(os); | |
166 | *os <<","<< fPhysics; | |
167 | for(i=0; i<fgkSsdd; i++) *os <<","<< fTcharges[i]; | |
168 | for(i=0; i<fgkSsdd; i++) *os <<","<< fTracks[i]; | |
169 | for(i=0; i<fgkSsdd; i++) *os <<","<< fHits[i]; | |
7f1a504b | 170 | *os <<","<< fSignalExpanded; |
e869281d | 171 | } |
172 | //______________________________________________________________________ | |
173 | void AliITSdigitSDD::Read(istream *os){ | |
174 | //Standard input for this class | |
175 | Int_t i; | |
176 | ||
177 | AliITSdigit::Read(os); | |
178 | *os >>fPhysics; | |
179 | for(i=0; i<fgkSsdd; i++) *os >> fTcharges[i]; | |
180 | for(i=0; i<fgkSsdd; i++) *os >> fTracks[i]; | |
181 | for(i=0; i<fgkSsdd; i++) *os >> fHits[i]; | |
7f1a504b | 182 | *os >>fSignalExpanded; |
e869281d | 183 | } |
184 | //______________________________________________________________________ | |
185 | ostream &operator<<(ostream &os,AliITSdigitSDD &source){ | |
186 | // Standard output streaming function. | |
187 | ||
188 | source.Print(&os); | |
189 | return os; | |
190 | } | |
191 | //______________________________________________________________________ | |
192 | istream &operator>>(istream &os,AliITSdigitSDD &source){ | |
193 | // Standard output streaming function. | |
194 | ||
195 | source.Read(&os); | |
196 | return os; | |
197 | } |