1 /**************************************************************************
2 * Copyright(c) 2004-2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #include <AliITSdigitSDD.h>
17 #include <AliITSCalibrationSDD.h>
21 ///////////////////////////////////////////////////////////////////
23 // Class defining the digit object
25 // Inherits from AliITSdigit
27 ///////////////////////////////////////////////////////////////////
29 ClassImp(AliITSdigitSDD)
32 //______________________________________________________________________
33 AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
36 // default constructor, zero coordinates and set array
37 // elements to clearly unphysical values. A value of 0 may
38 // be a valide track of hit number.
41 for(i=0;i<fgkSize;i++) fTracks[i] = -3;
42 for(i=0;i<fgkSize;i++) fHits[i] = -1;
43 for(i=0;i<fgkSize;i++) fTcharges[i] = 0;
44 SetSignalExpanded(-1000);
46 //________________________________________________________________________
47 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
51 // Creates a simulated SDD digit object to be updated
52 for(Int_t i=0;i<fgkSize;i++) fTracks[i] = -3;
53 for(Int_t i=0;i<fgkSize;i++) fHits[i] = -1;
54 for(Int_t i=0;i<fgkSize;i++) fTcharges[i] = 0;
56 SetSignalExpanded(-1000);
59 //________________________________________________________________________
60 void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
61 const Int_t *hits,const Float_t *charges){
63 // Protected function used by standard constructors
65 for(Int_t i=0; i<fgkSize; i++) {
66 fTcharges[i] = charges[i];
67 fTracks[i] = tracks[i];
72 //_____________________________________________________________________________
73 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
74 const Int_t *tracks,const Int_t *hits,
75 const Float_t *charges):AliITSdigit(digits),
79 // standard constructor
80 InitObject(phys,tracks,hits,charges);
81 SetSignalExpanded(-1000);
83 //_____________________________________________________________________________
84 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
85 const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
89 //constructor setting also fSignalExpanded
90 InitObject(phys,tracks,hits,charges);
91 SetSignalExpanded(sige);
94 //_____________________________________________________________________________
95 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
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.
108 // TArrayI &t The input array filled with the nonduplicated track
110 // TArrayF &c The input array filled with the summed charge
111 // contributed by the corresponding track in the array t.
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();
118 Bool_t inlist = kFALSE;
120 t.Reset(-1); // -1 array.
121 c.Reset(0.0); // zero array.
123 if(this->GetTrack(i) == -1) continue;
125 for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
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);
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).
147 while(j>-1 && c.At(j)>ch){
148 t.AddAt(t.At(j+1),j);
149 c.AddAt(c.At(j+1),j);
160 //______________________________________________________________________
161 void AliITSdigitSDD::Print(ostream *os){
164 //Standard output format for this class
167 AliITSdigit::Print(os);
168 *os <<","<< fPhysics;
169 for(i=0; i<fgkSize; i++) *os <<","<< fTcharges[i];
170 for(i=0; i<fgkSize; i++) *os <<","<< fTracks[i];
171 for(i=0; i<fgkSize; i++) *os <<","<< fHits[i];
172 *os <<","<< fSignalExpanded;
174 //______________________________________________________________________
175 void AliITSdigitSDD::Read(istream *os){
177 //Standard input for this class
180 AliITSdigit::Read(os);
182 for(i=0; i<fgkSize; i++) *os >> fTcharges[i];
183 for(i=0; i<fgkSize; i++) *os >> fTracks[i];
184 for(i=0; i<fgkSize; i++) *os >> fHits[i];
185 *os >>fSignalExpanded;
187 //______________________________________________________________________
188 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
190 // Standard output streaming function.
195 //______________________________________________________________________
196 istream &operator>>(istream &os,AliITSdigitSDD &source){
198 // Standard output streaming function.