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