new SDD preprocessor + removal of eff C++ warning (base) - E. Crescio
[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>
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
30ClassImp(AliITSdigitSDD)
7f1a504b 31
32
e869281d 33//______________________________________________________________________
e56160b8 34AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
35fPhysics(0),
36fSignalExpanded(0){
e869281d 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;
e869281d 44 for(i=0;i<fgkSsdd;i++) fTcharges[i] = 0;
7f1a504b 45 SetSignalExpanded(-1000);
e869281d 46}
47//________________________________________________________________________
e56160b8 48AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
49fPhysics(phys),
50fSignalExpanded(0){
7d62fb64 51
52 // Creates a simulated SDD digit object to be updated
e869281d 53
7f1a504b 54 SetSignalExpanded(-1000);
e869281d 55}
7f1a504b 56
57//________________________________________________________________________
58void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
59 const Int_t *hits,const Float_t *charges){
7d62fb64 60
7f1a504b 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
e869281d 70//_____________________________________________________________________________
71AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
72 const Int_t *tracks,const Int_t *hits,
e56160b8 73 const Float_t *charges):AliITSdigit(digits),
74fPhysics(0),
75fSignalExpanded(0){
7d62fb64 76
77// standard constructor
7f1a504b 78 InitObject(phys,tracks,hits,charges);
79 SetSignalExpanded(-1000);
80}
81//_____________________________________________________________________________
82AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
e56160b8 83 const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
84fPhysics(0),
85fSignalExpanded(0){
7d62fb64 86
7f1a504b 87 //constructor setting also fSignalExpanded
88 InitObject(phys,tracks,hits,charges);
89 SetSignalExpanded(sige);
90}
e869281d 91
7f1a504b 92//_____________________________________________________________________________
93AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
94 const Int_t *tracks,const Int_t *hits,const Float_t *charges,
e56160b8 95 AliITSCalibrationSDD* resp): AliITSdigit(digits),
96fPhysics(0),
97fSignalExpanded(0){
7d62fb64 98
fcf95fc7 99 //constructor setting fSignalExpanded through AliITSCalibrationSDD
7f1a504b 100 InitObject(phys,tracks,hits,charges);
fcf95fc7 101 AliITSresponseSDD* pd = (AliITSresponseSDD*)resp->GetResponse();
102 SetSignalExpanded(pd->Convert8to10(digits[2]));
e869281d 103}
7f1a504b 104
e869281d 105//______________________________________________________________________
106Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
7d62fb64 107
e869281d 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}
7f1a504b 169
170
e869281d 171//______________________________________________________________________
172void AliITSdigitSDD::Print(ostream *os){
7d62fb64 173
174
175 //Standard output format for this class
e869281d 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];
7f1a504b 183 *os <<","<< fSignalExpanded;
e869281d 184}
185//______________________________________________________________________
186void AliITSdigitSDD::Read(istream *os){
7d62fb64 187
188 //Standard input for this class
189 Int_t i;
e869281d 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];
7f1a504b 196 *os >>fSignalExpanded;
e869281d 197}
198//______________________________________________________________________
199ostream &operator<<(ostream &os,AliITSdigitSDD &source){
7d62fb64 200
201 // Standard output streaming function.
e869281d 202
203 source.Print(&os);
204 return os;
205}
206//______________________________________________________________________
207istream &operator>>(istream &os,AliITSdigitSDD &source){
7d62fb64 208
209 // Standard output streaming function.
e869281d 210
211 source.Read(&os);
212 return os;
213}