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(){
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): AliITSdigit(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){
59 // Protected function used by standard constructors
61 for(Int_t i=0; i<fgkSsdd; i++) {
62 fTcharges[i] = charges[i];
63 fTracks[i] = tracks[i];
68 //_____________________________________________________________________________
69 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
70 const Int_t *tracks,const Int_t *hits,
71 const Float_t *charges):AliITSdigit(digits){
73 // standard constructor
74 InitObject(phys,tracks,hits,charges);
75 SetSignalExpanded(-1000);
77 //_____________________________________________________________________________
78 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
79 const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits) {
81 //constructor setting also fSignalExpanded
82 InitObject(phys,tracks,hits,charges);
83 SetSignalExpanded(sige);
86 //_____________________________________________________________________________
87 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
88 const Int_t *tracks,const Int_t *hits,const Float_t *charges,
89 AliITSCalibrationSDD* resp): AliITSdigit(digits) {
91 //constructor setting fSignalExpanded through AliITSCalibrationSDD
92 InitObject(phys,tracks,hits,charges);
93 AliITSresponseSDD* pd = (AliITSresponseSDD*)resp->GetResponse();
94 SetSignalExpanded(pd->Convert8to10(digits[2]));
97 //______________________________________________________________________
98 Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
100 // Fills the TArrayI t with the tracks found in fTracks removing
101 // duplicated tracks, summing up their charge, and ordering the tracks
102 // by the charge contributed to this digit. It will return
103 // the number of tracks and fill the remaining elements to the array
106 // TArrayI &t Reference to a TArrayI to contain the list of
107 // nonduplicated track numbers.
108 // TArrayF &c Reference to a TArrayF to contain the summed charge
109 // contributed by each track.
111 // TArrayI &t The input array filled with the nonduplicated track
113 // TArrayF &c The input array filled with the summed charge
114 // contributed by the corresponding track in the array t.
116 // Int_t The number of none -1 entries in the TArrayI t.
117 Int_t nt = t.GetSize();
118 nt = TMath::Min(nt,c.GetSize());
119 Int_t nth = this->GetNTracks();
121 Bool_t inlist = kFALSE;
123 t.Reset(-1); // -1 array.
124 c.Reset(0.0); // zero array.
126 if(this->GetTrack(i) == -1) continue;
128 for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
130 c.AddAt(this->GetCharge(i)+c.At(j),j);
131 } // end for j/end if
132 if(!inlist){ // add to end of list
133 t.AddAt(this->GetTrack(i),n);
134 c.AddAt(this->GetCharge(i),n);
139 // Now lets sort the TArrays according to the charge. This algorithm
140 // is based on the method from Chapter 8 section 1 Straight Insertion
141 // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling
142 // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific
143 // Computing", second Edition page 330 (1997).
150 while(j>-1 && c.At(j)>ch){
151 t.AddAt(t.At(j+1),j);
152 c.AddAt(c.At(j+1),j);
163 //______________________________________________________________________
164 void AliITSdigitSDD::Print(ostream *os){
167 //Standard output format for this class
170 AliITSdigit::Print(os);
171 *os <<","<< fPhysics;
172 for(i=0; i<fgkSsdd; i++) *os <<","<< fTcharges[i];
173 for(i=0; i<fgkSsdd; i++) *os <<","<< fTracks[i];
174 for(i=0; i<fgkSsdd; i++) *os <<","<< fHits[i];
175 *os <<","<< fSignalExpanded;
177 //______________________________________________________________________
178 void AliITSdigitSDD::Read(istream *os){
180 //Standard input for this class
183 AliITSdigit::Read(os);
185 for(i=0; i<fgkSsdd; i++) *os >> fTcharges[i];
186 for(i=0; i<fgkSsdd; i++) *os >> fTracks[i];
187 for(i=0; i<fgkSsdd; i++) *os >> fHits[i];
188 *os >>fSignalExpanded;
190 //______________________________________________________________________
191 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
193 // Standard output streaming function.
198 //______________________________________________________________________
199 istream &operator>>(istream &os,AliITSdigitSDD &source){
201 // Standard output streaming function.