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>
18 #include <AliITSresponseSDD.h>
22 ///////////////////////////////////////////////////////////////////
24 // Class defining the digit object
26 // Inherits from AliITSdigit
28 ///////////////////////////////////////////////////////////////////
30 ClassImp(AliITSdigitSDD)
33 //______________________________________________________________________
34 AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
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.
42 for(i=0;i<fgkSsdd;i++) fTracks[i] = -3;
43 for(i=0;i<fgkSsdd;i++) fHits[i] = -1;
44 for(i=0;i<fgkSsdd;i++) fTcharges[i] = 0;
45 SetSignalExpanded(-1000);
47 //________________________________________________________________________
48 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
52 // Creates a simulated SDD digit object to be updated
54 SetSignalExpanded(-1000);
57 //________________________________________________________________________
58 void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
59 const Int_t *hits,const Float_t *charges){
61 // Protected function used by standard constructors
63 for(Int_t i=0; i<fgkSsdd; i++) {
64 fTcharges[i] = charges[i];
65 fTracks[i] = tracks[i];
70 //_____________________________________________________________________________
71 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
72 const Int_t *tracks,const Int_t *hits,
73 const Float_t *charges):AliITSdigit(digits),
77 // standard constructor
78 InitObject(phys,tracks,hits,charges);
79 SetSignalExpanded(-1000);
81 //_____________________________________________________________________________
82 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
83 const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
87 //constructor setting also fSignalExpanded
88 InitObject(phys,tracks,hits,charges);
89 SetSignalExpanded(sige);
92 //_____________________________________________________________________________
93 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
94 const Int_t *tracks,const Int_t *hits,const Float_t *charges,
95 AliITSCalibrationSDD* resp): AliITSdigit(digits),
99 //constructor setting fSignalExpanded through AliITSCalibrationSDD
100 InitObject(phys,tracks,hits,charges);
101 AliITSresponseSDD* pd = (AliITSresponseSDD*)resp->GetResponse();
102 SetSignalExpanded(pd->Convert8to10(digits[2]));
105 //______________________________________________________________________
106 Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
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
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.
119 // TArrayI &t The input array filled with the nonduplicated track
121 // TArrayF &c The input array filled with the summed charge
122 // contributed by the corresponding track in the array t.
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();
129 Bool_t inlist = kFALSE;
131 t.Reset(-1); // -1 array.
132 c.Reset(0.0); // zero array.
134 if(this->GetTrack(i) == -1) continue;
136 for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
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);
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).
158 while(j>-1 && c.At(j)>ch){
159 t.AddAt(t.At(j+1),j);
160 c.AddAt(c.At(j+1),j);
171 //______________________________________________________________________
172 void AliITSdigitSDD::Print(ostream *os){
175 //Standard output format for this class
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];
183 *os <<","<< fSignalExpanded;
185 //______________________________________________________________________
186 void AliITSdigitSDD::Read(istream *os){
188 //Standard input for this class
191 AliITSdigit::Read(os);
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];
196 *os >>fSignalExpanded;
198 //______________________________________________________________________
199 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
201 // Standard output streaming function.
206 //______________________________________________________________________
207 istream &operator>>(istream &os,AliITSdigitSDD &source){
209 // Standard output streaming function.