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 <AliITSresponseSDD.h>
22 ///////////////////////////////////////////////////////////////////
24 // Class defining the digit object
26 // Inherits from AliITSdigit
28 ///////////////////////////////////////////////////////////////////
30 ClassImp(AliITSdigitSDD)
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.
40 for(i=0;i<fgkSsdd;i++) fTracks[i] = -3;
41 for(i=0;i<fgkSsdd;i++) fHits[i] = -1;
43 for(i=0;i<fgkSsdd;i++) fTcharges[i] = 0;
44 SetSignalExpanded(-1000);
46 //________________________________________________________________________
47 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits):
49 // Creates a simulated SDD digit object to be updated
52 SetSignalExpanded(-1000);
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
60 for(Int_t i=0; i<fgkSsdd; i++) {
61 fTcharges[i] = charges[i];
62 fTracks[i] = tracks[i];
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):
72 // standard constructor
73 InitObject(phys,tracks,hits,charges);
74 SetSignalExpanded(-1000);
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):
80 //constructor setting also fSignalExpanded
81 InitObject(phys,tracks,hits,charges);
82 SetSignalExpanded(sige);
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):
90 //constructor setting fSignalExpanded through AliITSresponseSDD
91 InitObject(phys,tracks,hits,charges);
92 SetSignalExpanded(resp->Convert8to10(digits[2]));
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
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){
162 //Standard output format for this class
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];
170 *os <<","<< fSignalExpanded;
172 //______________________________________________________________________
173 void AliITSdigitSDD::Read(istream *os){
174 //Standard input for this class
177 AliITSdigit::Read(os);
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];
182 *os >>fSignalExpanded;
184 //______________________________________________________________________
185 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
186 // Standard output streaming function.
191 //______________________________________________________________________
192 istream &operator>>(istream &os,AliITSdigitSDD &source){
193 // Standard output streaming function.