]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSdcsSSD.cxx
Fixed error with deleting a deleted object.
[u/mrichter/AliRoot.git] / ITS / AliITSdcsSSD.cxx
1
2 #include "AliITSdcsSSD.h"
3 #include "AliITSresponseSSD.h"
4 #include "AliITSsegmentationSSD.h"
5
6 ClassImp(AliITSdcsSSD)
7
8
9 //_____________________________________________________________________
10 //
11 // Constructor and Destructor
12 //_____________________________________________________________________
13
14
15 AliITSdcsSSD::AliITSdcsSSD(AliITSsegmentation *seg, AliITSresponse *resp) 
16 {
17   // constructor
18
19     fRandom = new TRandom();
20
21     fNstrips = seg->Npx();
22     
23     fInvalidP = new TArrayS();
24     fInvalidN = new TArrayS();
25
26     Int_t npar=resp->NDetParam();
27     if (npar < 6) {
28        Warning("AliITSdcsSSD","I need 6 parameters ");
29        npar=6;
30     }
31
32     Float_t *detpar = new Float_t [npar];
33     resp->GetDetParam(detpar);
34
35     fNInvalid = detpar[0];
36     fISigma = detpar[1];
37
38     fCouplingPR = detpar[2];
39     fCouplingPL = detpar[3];
40     fCouplingNR = detpar[4];
41     fCouplingNL = detpar[5]; 
42
43
44     Option_t *opt,*dummy;
45     resp->ParamOptions(opt,dummy);
46     if (strstr(opt,"SetInvalid")) SetInvalidMC(fNInvalid,fISigma);
47          
48          delete [] detpar;
49
50 }
51
52 //_____________________________________________________________________
53
54
55 AliITSdcsSSD::~AliITSdcsSSD() {
56   // destructor
57     delete fInvalidP;
58     delete fInvalidN;
59 }
60
61 //__________________________________________________________________________
62 AliITSdcsSSD::AliITSdcsSSD(const AliITSdcsSSD &source){
63   //     Copy Constructor 
64   if(&source == this) return;
65   this->fCouplingPR = source.fCouplingPR;
66   this->fCouplingPL = source.fCouplingPL;
67   this->fCouplingNR = source.fCouplingNR;
68   this->fCouplingNL = source.fCouplingNL;
69   this->fNstrips = source.fNstrips;
70   this->fNInvalid = source.fNInvalid;
71   this->fISigma = source.fISigma;
72   this->fInvalidP = source.fInvalidP;
73   this->fInvalidN = source.fInvalidN;
74   this->fRandom = source.fRandom;
75   return;
76 }
77
78 //_________________________________________________________________________
79 AliITSdcsSSD& 
80   AliITSdcsSSD::operator=(const AliITSdcsSSD &source) {
81   //    Assignment operator
82   if(&source == this) return *this;
83   this->fCouplingPR = source.fCouplingPR;
84   this->fCouplingPL = source.fCouplingPL;
85   this->fCouplingNR = source.fCouplingNR;
86   this->fCouplingNL = source.fCouplingNL;
87   this->fNstrips = source.fNstrips;
88   this->fNInvalid = source.fNInvalid;
89   this->fISigma = source.fISigma;
90   this->fInvalidP = source.fInvalidP;
91   this->fInvalidN = source.fInvalidN;
92   this->fRandom = source.fRandom;
93   return *this;
94 }
95
96 //_____________________________________________________________________
97 //
98 //  Methods for creating invalid strips
99 //_____________________________________________________________________
100 //
101
102
103 void AliITSdcsSSD::SetInvalidMC(Float_t mean, Float_t sigma) {
104   // set invalid MC
105     SetInvalidParam(mean, sigma);
106     SetInvalidMC();
107 }
108
109 //_____________________________________________________________________
110
111 void AliITSdcsSSD::SetInvalidMC() {
112   // set invalid MC
113     Int_t pside;
114     Int_t nside;
115     Int_t i;
116     Int_t strip;
117
118     pside = (Int_t)fRandom->Gaus(fNInvalid, fISigma);
119     nside = (Int_t)fRandom->Gaus(fNInvalid, fISigma);
120     
121     fInvalidP->Set(pside);
122     fInvalidN->Set(nside);
123      
124     for(i=0 ;i<pside; i++) {
125        strip = (Int_t)(fRandom->Rndm() * fNstrips);
126        fInvalidP->AddAt(strip, i); 
127     }
128     
129     for(i=0 ;i<nside; i++) {
130        strip = (Int_t)(fRandom->Rndm() * fNstrips);
131        fInvalidN->AddAt(strip, i); 
132     }  
133 }
134
135 //_____________________________________________________________________
136
137
138 void AliITSdcsSSD::SetInvalidParam(Float_t mean, Float_t sigma) {
139   // set invalid param
140     fNInvalid = mean;
141     fISigma = sigma;
142
143     fNInvalid = (fNInvalid<0)? 0 : fNInvalid;
144     fNInvalid = (fNInvalid>fNstrips)? fNstrips: fNInvalid;
145     
146     fISigma = (fISigma < 0)? 0 : fISigma;
147     fISigma = (fISigma > fNstrips/10) ? fNstrips/10 : fISigma;
148 }
149
150
151 //_____________________________________________________________________
152
153
154 void AliITSdcsSSD::GetInvalidParam(Float_t &mean, Float_t &sigma) {
155   // get invalid param
156     mean = fNInvalid;
157     sigma = fISigma;
158
159 }
160
161
162 //_____________________________________________________________________
163 //
164 //  Methods for accessing to invalid strips
165 //_____________________________________________________________________
166 //
167
168
169 Bool_t AliITSdcsSSD::IsValidP(Int_t strip) {
170   // isvalidP
171     Int_t nElem = fInvalidP->GetSize();
172     Int_t i;
173     for(i = 0; i<nElem; i++)
174        if(fInvalidP->At(i) == strip) return kFALSE;
175     return kTRUE;
176 }
177
178 //_____________________________________________________________________
179
180 Bool_t AliITSdcsSSD::IsValidN(Int_t strip) {
181   // is valid N
182     Int_t nElem = fInvalidN->GetSize();
183     Int_t i;
184     for(i = 0; i<nElem; i++)
185        if(fInvalidN->At(i) == strip) return kFALSE;
186     return kTRUE;
187 }
188
189 //_____________________________________________________________________
190
191
192 TArrayS* AliITSdcsSSD::GetInvalidP() {
193   // get invalid P
194     return fInvalidP;
195 }
196
197 TArrayS* AliITSdcsSSD::GetInvalidN() {
198   // get invalid N
199     return fInvalidN;
200 }
201
202 Int_t AliITSdcsSSD::GetNInvalidP(){
203   // get numeber of invalid P    
204     return fInvalidP->GetSize();
205 }
206
207 Int_t AliITSdcsSSD::GetNInvalidN() {
208   // // get number of invalid N
209     return fInvalidN->GetSize();
210 }
211
212 //_____________________________________________________________________
213
214
215
216
217
218
219