]>
Commit | Line | Data |
---|---|---|
6344adcc | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | /////////////////////////////////////////////////////////////////////////// | |
16 | // Plane Efficiency class for ITS | |
17 | // It is used for module by module efficiency of the SSD, | |
18 | // evaluated by tracks | |
19 | // (Inherits from AliITSPlaneEff) | |
20 | // Author: G.E. Bruno | |
21 | // giuseppe.bruno@ba.infn.it | |
22 | // | |
23 | /////////////////////////////////////////////////////////////////////////// | |
24 | ||
7167ae53 | 25 | /* $Id$ */ |
6344adcc | 26 | |
27 | #include <TMath.h> | |
28 | #include "AliITSPlaneEffSSD.h" | |
29 | #include "AliLog.h" | |
30 | #include "AliCDBStorage.h" | |
31 | #include "AliCDBEntry.h" | |
32 | #include "AliCDBManager.h" | |
33 | //#include "AliCDBRunRange.h" | |
34 | #include "AliITSCalibrationSSD.h" | |
35 | ||
36 | ClassImp(AliITSPlaneEffSSD) | |
37 | //______________________________________________________________________ | |
38 | AliITSPlaneEffSSD::AliITSPlaneEffSSD(): | |
39 | AliITSPlaneEff(){ | |
6344adcc | 40 | for (UInt_t i=0; i<kNModule; i++){ |
41 | fFound[i]=0; | |
42 | fTried[i]=0; | |
43 | } | |
44 | // default constructor | |
45 | AliDebug(1,Form("Calling default constructor")); | |
46 | } | |
47 | //______________________________________________________________________ | |
48 | AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){ | |
49 | // destructor | |
50 | // Inputs: | |
51 | // none. | |
52 | // Outputs: | |
53 | // none. | |
54 | // Return: | |
55 | // none. | |
56 | } | |
57 | //______________________________________________________________________ | |
58 | AliITSPlaneEffSSD::AliITSPlaneEffSSD(const AliITSPlaneEffSSD &s) : AliITSPlaneEff(s) //, | |
59 | //fHis(s.fHis), | |
60 | { | |
61 | // Copy Constructor | |
62 | // Inputs: | |
63 | // AliITSPlaneEffSSD &s The original class for which | |
64 | // this class is a copy of | |
65 | // Outputs: | |
66 | // none. | |
67 | // Return: | |
68 | } | |
69 | //_________________________________________________________________________ | |
70 | AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){ | |
71 | // Add-to-me operator | |
72 | // Inputs: | |
73 | // const AliITSPlaneEffSSD &add simulation class to be added | |
74 | // Outputs: | |
75 | // none. | |
76 | // Return: | |
77 | // none | |
78 | for (UInt_t i=0; i<kNModule; i++){ | |
79 | fFound[i] += add.fFound[i]; | |
80 | fTried[i] += add.fTried[i]; | |
81 | } | |
82 | return *this; | |
83 | } | |
84 | //______________________________________________________________________ | |
85 | AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator=(const | |
86 | AliITSPlaneEffSSD &s){ | |
87 | // Assignment operator | |
88 | // Inputs: | |
89 | // AliITSPlaneEffSSD &s The original class for which | |
90 | // this class is a copy of | |
91 | // Outputs: | |
92 | // none. | |
93 | // Return: | |
94 | ||
95 | if(this==&s) return *this; | |
96 | s.Copy(*this); | |
97 | return *this; | |
98 | } | |
99 | //______________________________________________________________________ | |
100 | void AliITSPlaneEffSSD::Copy(TObject &obj) const { | |
101 | // protected method. copy this to obj | |
102 | AliITSPlaneEff::Copy(obj); | |
103 | for(Int_t i=0;i<kNModule;i++) { | |
104 | ((AliITSPlaneEffSSD& ) obj).fFound[i] = fFound[i]; | |
105 | ((AliITSPlaneEffSSD& ) obj).fTried[i] = fTried[i]; | |
106 | } | |
107 | } | |
108 | //______________________________________________________________________ | |
109 | AliITSPlaneEff& AliITSPlaneEffSSD::operator=(const | |
110 | AliITSPlaneEff &s){ | |
111 | // Assignment operator | |
112 | // Inputs: | |
113 | // AliITSPlaneEffSSD &s The original class for which | |
114 | // this class is a copy of | |
115 | // Outputs: | |
116 | // none. | |
117 | // Return: | |
118 | ||
119 | if(&s == this) return *this; | |
7167ae53 | 120 | AliError("operator=: Not allowed to make a =, use default creater instead"); |
6344adcc | 121 | return *this; |
122 | } | |
123 | //_______________________________________________________________________ | |
124 | Int_t AliITSPlaneEffSSD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, | |
125 | UInt_t im) const { | |
126 | ||
127 | // Estimate the number of tracks still to be collected to attain a | |
128 | // given efficiency eff, with relative error RelErr | |
129 | // Inputs: | |
130 | // eff -> Expected efficiency (e.g. those from actual estimate) | |
131 | // RelErr -> tollerance [0,1] | |
132 | // im -> module number [0,1697] | |
133 | // Outputs: none | |
134 | // Return: the estimated n. of tracks | |
135 | // | |
136 | if (im>=kNModule) | |
7167ae53 | 137 | {AliError("GetMissingTracksForGivenEff: you asked for a non existing module"); |
6344adcc | 138 | return -1;} |
139 | else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)]; | |
140 | } | |
141 | //_________________________________________________________________________ | |
142 | Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const { | |
143 | // Compute the efficiency for a basic block, | |
144 | // Inputs: | |
145 | // im -> module number [0,1697] | |
146 | if (im>=kNModule) | |
7167ae53 | 147 | {AliError("PlaneEff(UInt_t): you asked for a non existing module"); return -1.;} |
6344adcc | 148 | Int_t nf=fFound[GetKey(im)]; |
149 | Int_t nt=fTried[GetKey(im)]; | |
150 | return AliITSPlaneEff::PlaneEff(nf,nt); | |
151 | } | |
152 | //_________________________________________________________________________ | |
153 | Double_t AliITSPlaneEffSSD::ErrPlaneEff(const UInt_t im) const { | |
154 | // Compute the statistical error on efficiency for a basic block, | |
155 | // using binomial statistics | |
156 | // Inputs: | |
157 | // im -> module number [0,1697] | |
158 | if (im>=kNModule) | |
7167ae53 | 159 | {AliError("ErrPlaneEff(UInt_t): you asked for a non existing module"); return -1.;} |
6344adcc | 160 | Int_t nf=fFound[GetKey(im)]; |
161 | Int_t nt=fTried[GetKey(im)]; | |
162 | return AliITSPlaneEff::ErrPlaneEff(nf,nt); | |
163 | } | |
164 | //_________________________________________________________________________ | |
165 | Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) { | |
166 | // Update efficiency for a basic block | |
167 | if (im>=kNModule) | |
7167ae53 | 168 | {AliError("UpDatePlaneEff: you asked for a non existing module"); return kFALSE;} |
6344adcc | 169 | fTried[GetKey(im)]++; |
170 | if(Kfound) fFound[GetKey(im)]++; | |
171 | return kTRUE; | |
172 | } | |
173 | //_________________________________________________________________________ | |
174 | UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const { | |
175 | // get key given a basic block | |
176 | if(mod>=kNModule) | |
7167ae53 | 177 | {AliError("GetKey: you asked for a non existing block"); return 99999;} |
6344adcc | 178 | return mod; |
179 | } | |
180 | //__________________________________________________________________________ | |
181 | UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const { | |
182 | // get mod. from key | |
183 | if(key>=kNModule) | |
7167ae53 | 184 | {AliError("GetModFromKey: you asked for a non existing key"); return 9999;} |
6344adcc | 185 | return key; |
186 | } | |
187 | //__________________________________________________________________________ | |
188 | Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const { | |
189 | // returns plane efficieny after adding the fraction of sensor which is bad | |
190 | if(key>=kNModule) | |
7167ae53 | 191 | {AliError("LivePlaneEff: you asked for a non existing key"); |
6344adcc | 192 | return -1.;} |
193 | Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning | |
194 | leff=PlaneEff(key)+GetFracBad(key); | |
195 | return leff>1?1:leff; | |
196 | } | |
197 | //____________________________________________________________________________ | |
198 | Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const { | |
199 | // returns error on live plane efficiency | |
200 | if(key>=kNModule) | |
7167ae53 | 201 | {AliError("ErrLivePlaneEff: you asked for a non existing key"); |
6344adcc | 202 | return -1.;} |
203 | Int_t nf=fFound[key]; | |
204 | Double_t triedInLive=GetFracLive(key)*fTried[key]; | |
205 | Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive)); | |
206 | return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked | |
207 | } | |
208 | //_____________________________________________________________________________ | |
209 | Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const { | |
210 | // returns the fraction of the sensor which is OK | |
211 | if(key>=kNModule) | |
7167ae53 | 212 | {AliError("GetFracLive: you asked for a non existing key"); |
6344adcc | 213 | return -1.;} |
214 | // Compute the fraction of bad (dead+noisy) detector | |
215 | UInt_t bad=0; | |
216 | GetBadInModule(key,bad); | |
217 | Double_t live=bad; | |
218 | live/=(kNChip*kNSide*kNStrip); | |
219 | return 1.-live; | |
220 | } | |
221 | //_____________________________________________________________________________ | |
222 | void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const { | |
223 | // returns the number of dead and noisy pixels | |
224 | nrBadInMod=0; | |
225 | if(key>=kNModule) | |
7167ae53 | 226 | {AliError("GetBadInModule: you asked for a non existing key"); |
6344adcc | 227 | return;} |
228 | // Compute the number of bad (dead+noisy) pixel in a module | |
229 | // | |
230 | if(!fInitCDBCalled) | |
7167ae53 | 231 | {AliError("GetBadInModule: CDB not inizialized: call InitCDB first"); |
6344adcc | 232 | return;}; |
233 | AliCDBManager* man = AliCDBManager::Instance(); | |
234 | // retrieve map of dead Pixel | |
235 | AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber); | |
236 | TObjArray* ssdEntry; | |
237 | if(cdbSSD) { | |
238 | ssdEntry = (TObjArray*)cdbSSD->GetObject(); | |
239 | if(!ssdEntry) | |
7167ae53 | 240 | {AliError("GetBadInChip: SSDEntry not found in CDB"); |
6344adcc | 241 | return;} |
242 | } else { | |
7167ae53 | 243 | AliError("GetBadInChip: did not find Calib/BadChannelsSSD"); |
6344adcc | 244 | return; |
245 | } | |
246 | // | |
247 | UInt_t mod=GetModFromKey(key); | |
248 | // | |
249 | AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod); | |
250 | // count the number of bad channels on the p side | |
251 | nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize(); | |
252 | // add the number of bad channels on the s side | |
253 | nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize(); | |
254 | return; | |
255 | } | |
256 | //_____________________________________________________________________________ | |
257 | Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const { | |
258 | // returns 1-fractional live | |
259 | if(key>=kNModule) | |
7167ae53 | 260 | {AliError("GetFracBad: you asked for a non existing key"); |
6344adcc | 261 | return -1.;} |
262 | return 1.-GetFracLive(key); | |
263 | } | |
264 | //_____________________________________________________________________________ | |
265 | Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const { | |
266 | // write onto CDB | |
267 | if(!fInitCDBCalled) | |
7167ae53 | 268 | {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first"); |
6344adcc | 269 | return kFALSE;} |
270 | // to be written properly: now only for debugging | |
271 | AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object | |
272 | md->SetObjectClassName("AliITSPlaneEff"); | |
273 | md->SetResponsible("Giuseppe Eugenio Bruno"); | |
274 | md->SetBeamPeriod(0); | |
275 | md->SetAliRootVersion("head 02/01/08"); //root version | |
276 | AliCDBId id("ITS/PlaneEff/PlaneEffSSD",0,AliCDBRunRange::Infinity()); | |
277 | AliITSPlaneEffSSD eff; | |
278 | eff=*this; | |
279 | Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md); | |
280 | delete md; | |
281 | return r; | |
282 | } | |
283 | //_____________________________________________________________________________ | |
284 | Bool_t AliITSPlaneEffSSD::ReadFromCDB() { | |
285 | // read from CDB | |
286 | if(!fInitCDBCalled) | |
7167ae53 | 287 | {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first"); |
6344adcc | 288 | return kFALSE;} |
289 | //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) { | |
290 | // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
291 | // } | |
292 | AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber); | |
293 | AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject(); | |
294 | if(this==eff) return kFALSE; | |
295 | eff->Copy(*this); | |
296 | return kTRUE; | |
297 | } | |
7167ae53 | 298 | //_____________________________________________________________________________ |
299 | UInt_t AliITSPlaneEffSSD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet, | |
300 | Float_t, Float_t) const { | |
301 | // method to locate a basic block from Detector Local coordinate (to be used in tracking) | |
302 | UInt_t key=999999; | |
303 | if(ilay<4 || ilay>5) | |
304 | {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer"); | |
305 | return key;} | |
306 | if(ilay==4 && (idet<0 || idet>747)) | |
307 | {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector"); | |
308 | return key;} | |
309 | if(ilay==5 && (idet<0 || idet>949)) | |
310 | {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector"); | |
311 | return key;} | |
312 | ||
313 | UInt_t mod=idet; | |
314 | if(ilay==1) mod+=748; | |
315 | key=GetKey(mod); | |
316 | return key; | |
317 | } |