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>
21 ///////////////////////////////////////////////////////////////////
23 // Class defining the digit object
25 // Inherits from AliITSdigit
27 ///////////////////////////////////////////////////////////////////
29 ClassImp(AliITSdigitSDD)
30 //______________________________________________________________________
31 AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(){
32 // default constructor, zero coordinates and set array
33 // elements to clearly unphysical values. A value of 0 may
34 // be a valide track of hit number.
37 for(i=0;i<fgkSsdd;i++) fTracks[i] = -3;
38 for(i=0;i<fgkSsdd;i++) fHits[i] = -1;
40 for(i=0;i<fgkSsdd;i++) fTcharges[i] = 0;
42 //________________________________________________________________________
43 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits):
45 // Creates a simulated SDD digit object to be updated
49 //_____________________________________________________________________________
50 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
51 const Int_t *tracks,const Int_t *hits,
52 const Float_t *charges):
54 // Creates a simulated SDD digit object
57 for(Int_t i=0; i<fgkSsdd; i++) {
58 fTcharges[i] = charges[i];
59 fTracks[i] = tracks[i];
63 //______________________________________________________________________
64 Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
65 // Fills the TArrayI t with the tracks found in fTracks removing
66 // duplicated tracks, summing up their charge, and ordering the tracks
67 // by the charge contributed to this digit. It will return
68 // the number of tracks and fill the remaining elements to the array
71 // TArrayI &t Reference to a TArrayI to contain the list of
72 // nonduplicated track numbers.
73 // TArrayF &c Reference to a TArrayF to contain the summed charge
74 // contributed by each track.
76 // TArrayI &t The input array filled with the nonduplicated track
78 // TArrayF &c The input array filled with the summed charge
79 // contributed by the corresponding track in the array t.
81 // Int_t The number of none -1 entries in the TArrayI t.
82 Int_t nt = t.GetSize();
83 nt = TMath::Min(nt,c.GetSize());
84 Int_t nth = this->GetNTracks();
86 Bool_t inlist = kFALSE;
88 t.Reset(-1); // -1 array.
89 c.Reset(0.0); // zero array.
91 if(this->GetTrack(i) == -1) continue;
93 for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
95 c.AddAt(this->GetCharge(i)+c.At(j),j);
97 if(!inlist){ // add to end of list
98 t.AddAt(this->GetTrack(i),n);
99 c.AddAt(this->GetCharge(i),n);
104 // Now lets sort the TArrays according to the charge. This algorithm
105 // is based on the method from Chapter 8 section 1 Straight Insertion
106 // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling
107 // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific
108 // Computing", second Edition page 330 (1997).
115 while(j>-1 && c.At(j)>ch){
116 t.AddAt(t.At(j+1),j);
117 c.AddAt(c.At(j+1),j);
126 //______________________________________________________________________
127 void AliITSdigitSDD::Print(ostream *os){
128 //Standard output format for this class
131 AliITSdigit::Print(os);
132 *os <<","<< fPhysics;
133 for(i=0; i<fgkSsdd; i++) *os <<","<< fTcharges[i];
134 for(i=0; i<fgkSsdd; i++) *os <<","<< fTracks[i];
135 for(i=0; i<fgkSsdd; i++) *os <<","<< fHits[i];
137 //______________________________________________________________________
138 void AliITSdigitSDD::Read(istream *os){
139 //Standard input for this class
142 AliITSdigit::Read(os);
144 for(i=0; i<fgkSsdd; i++) *os >> fTcharges[i];
145 for(i=0; i<fgkSsdd; i++) *os >> fTracks[i];
146 for(i=0; i<fgkSsdd; i++) *os >> fHits[i];
148 //______________________________________________________________________
149 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
150 // Standard output streaming function.
155 //______________________________________________________________________
156 istream &operator>>(istream &os,AliITSdigitSDD &source){
157 // Standard output streaming function.