]>
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 chip by chip efficiency (eventually with subwing division | |
18 | // along the drift direction ) of the SDD, | |
19 | // evaluated by tracks | |
20 | // (Inherits from AliITSPlaneEff) | |
21 | // Author: G.E. Bruno | |
22 | // giuseppe.bruno@ba.infn.it | |
23 | // | |
24 | /////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | /* $Id$ */ | |
27 | ||
28 | #include <TMath.h> | |
29 | #include "AliITSPlaneEffSDD.h" | |
30 | #include "AliLog.h" | |
31 | #include "AliCDBStorage.h" | |
32 | #include "AliCDBEntry.h" | |
33 | #include "AliCDBManager.h" | |
34 | //#include "AliCDBRunRange.h" | |
35 | #include "AliITSCalibrationSDD.h" | |
36 | ||
37 | ClassImp(AliITSPlaneEffSDD) | |
38 | //______________________________________________________________________ | |
39 | AliITSPlaneEffSDD::AliITSPlaneEffSDD(): | |
40 | AliITSPlaneEff(){ | |
41 | // Default constructor | |
42 | for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){ | |
43 | fFound[i]=0; | |
44 | fTried[i]=0; | |
45 | } | |
46 | // default constructor | |
47 | AliDebug(1,Form("Calling default constructor")); | |
48 | } | |
49 | //______________________________________________________________________ | |
50 | AliITSPlaneEffSDD::~AliITSPlaneEffSDD(){ | |
51 | // destructor | |
52 | // Inputs: | |
53 | // none. | |
54 | // Outputs: | |
55 | // none. | |
56 | // Return: | |
57 | // none. | |
58 | } | |
59 | //______________________________________________________________________ | |
60 | AliITSPlaneEffSDD::AliITSPlaneEffSDD(const AliITSPlaneEffSDD &s) : AliITSPlaneEff(s) //, | |
61 | //fHis(s.fHis), | |
62 | { | |
63 | // Copy Constructor | |
64 | // Inputs: | |
65 | // AliITSPlaneEffSDD &s The original class for which | |
66 | // this class is a copy of | |
67 | // Outputs: | |
68 | // none. | |
69 | // Return: | |
70 | ||
71 | } | |
72 | //_________________________________________________________________________ | |
73 | AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator+=(const AliITSPlaneEffSDD &add){ | |
74 | // Add-to-me operator | |
75 | // Inputs: | |
76 | // const AliITSPlaneEffSDD &add simulation class to be added | |
77 | // Outputs: | |
78 | // none. | |
79 | // Return: | |
80 | // none | |
81 | for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){ | |
82 | fFound[i] += add.fFound[i]; | |
83 | fTried[i] += add.fTried[i]; | |
84 | } | |
85 | return *this; | |
86 | } | |
87 | //______________________________________________________________________ | |
88 | AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator=(const | |
89 | AliITSPlaneEffSDD &s){ | |
90 | // Assignment operator | |
91 | // Inputs: | |
92 | // AliITSPlaneEffSDD &s The original class for which | |
93 | // this class is a copy of | |
94 | // Outputs: | |
95 | // none. | |
96 | // Return: | |
97 | ||
98 | if(this==&s) return *this; | |
99 | s.Copy(*this); | |
100 | // if(&s == this) return *this; | |
101 | // for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){ | |
102 | // this->fFound[i] = s.fFound[i]; | |
103 | // this->fTried[i] = s.fTried[i]; | |
104 | // } | |
105 | return *this; | |
106 | } | |
107 | //______________________________________________________________________ | |
108 | void AliITSPlaneEffSDD::Copy(TObject &obj) const { | |
109 | // protected method. copy this to obj | |
110 | AliITSPlaneEff::Copy(obj); | |
111 | for(Int_t i=0;i<kNModule*kNChip*kNWing*kNSubWing;i++) { | |
112 | ((AliITSPlaneEffSDD& ) obj).fFound[i] = fFound[i]; | |
113 | ((AliITSPlaneEffSDD& ) obj).fTried[i] = fTried[i]; | |
114 | } | |
115 | } | |
116 | //______________________________________________________________________ | |
117 | AliITSPlaneEff& AliITSPlaneEffSDD::operator=(const | |
118 | AliITSPlaneEff &s){ | |
119 | // Assignment operator | |
120 | // Inputs: | |
121 | // AliITSPlaneEffSDD &s The original class for which | |
122 | // this class is a copy of | |
123 | // Outputs: | |
124 | // none. | |
125 | // Return: | |
126 | ||
127 | if(&s == this) return *this; | |
128 | Error("AliITSPlaneEffSDD","Not allowed to make a = with " | |
129 | "AliITSPlaneEffSDD","Using default creater instead"); | |
130 | ||
131 | return *this; | |
132 | } | |
133 | //_______________________________________________________________________ | |
134 | Int_t AliITSPlaneEffSDD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, | |
135 | UInt_t im, UInt_t ic, UInt_t iw, UInt_t is) const { | |
136 | ||
137 | // Estimate the number of tracks still to be collected to attain a | |
138 | // given efficiency eff, with relative error RelErr | |
139 | // Inputs: | |
140 | // eff -> Expected efficiency (e.g. those from actual estimate) | |
141 | // RelErr -> tollerance [0,1] | |
142 | // im -> module number [0,259] | |
143 | // ic -> chip number [0,3] | |
144 | // iw -> wing number [0,1] | |
145 | // is -> chip number [0,kNSubWing-1] | |
146 | // Outputs: none | |
147 | // Return: the estimated n. of tracks | |
148 | // | |
149 | if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) | |
150 | {Error("AliITSPlaneEffSDD","you asked for a non existing block"); | |
151 | return -1;} | |
152 | else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic,iw,is)]; | |
153 | } | |
154 | //_________________________________________________________________________ | |
155 | Double_t AliITSPlaneEffSDD::PlaneEff(const UInt_t im,const UInt_t ic, | |
156 | const UInt_t iw,const UInt_t is) const { | |
157 | // Compute the efficiency for a basic block, | |
158 | // Inputs: | |
159 | // im -> module number [0,259] | |
160 | // ic -> chip number [0,3] | |
161 | // iw -> wing number [0,1] | |
162 | // is -> chip number [0,kNSubWing-1] | |
163 | if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) | |
164 | {Error("AliITSPlaneEffSDD","you asked for a non existing block"); return -1.;} | |
165 | Int_t nf=fFound[GetKey(im,ic,iw,is)]; | |
166 | Int_t nt=fTried[GetKey(im,ic,iw,is)]; | |
167 | return AliITSPlaneEff::PlaneEff(nf,nt); | |
168 | } | |
169 | //_________________________________________________________________________ | |
170 | Double_t AliITSPlaneEffSDD::ErrPlaneEff(const UInt_t im,const UInt_t ic, | |
171 | const UInt_t iw,const UInt_t is) const { | |
172 | // Compute the statistical error on efficiency for a basic block, | |
173 | // using binomial statistics | |
174 | // Inputs: | |
175 | // im -> module number [0,259] | |
176 | // ic -> chip number [0,3] | |
177 | // iw -> wing number [0,1] | |
178 | // is -> chip number [0,kNSubWing-1] | |
179 | if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) | |
180 | {Error("AliITSPlaneEffSDD","you asked for a non existing block"); return -1.;} | |
181 | Int_t nf=fFound[GetKey(im,ic,iw,is)]; | |
182 | Int_t nt=fTried[GetKey(im,ic,iw,is)]; | |
183 | return AliITSPlaneEff::ErrPlaneEff(nf,nt); | |
184 | } | |
185 | //_________________________________________________________________________ | |
186 | Bool_t AliITSPlaneEffSDD::UpDatePlaneEff(const Bool_t Kfound, | |
187 | const UInt_t im, const UInt_t ic, | |
188 | const UInt_t iw, const UInt_t is) { | |
189 | // Update efficiency for a basic block | |
190 | if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) | |
191 | {Error("AliITSPlaneEffSDD","you asked for a non existing block"); return kFALSE;} | |
192 | fTried[GetKey(im,ic,iw,is)]++; | |
193 | if(Kfound) fFound[GetKey(im,ic,iw,is)]++; | |
194 | return kTRUE; | |
195 | } | |
196 | //_________________________________________________________________________ | |
197 | void AliITSPlaneEffSDD::ChipAndWingFromAnode(const UInt_t anode, UInt_t& chip, | |
198 | UInt_t& wing) const { | |
199 | // Retun the chip number [0,3] and the wing number [0,1] given the anode number | |
200 | // input: anode number [0,511] | |
201 | if(anode>=kNAnode*kNChip*kNWing) | |
202 | {Error("AliITSPlaneEffSDD::ChipAndWingFromAnode","you asked for a non existing anode"); | |
203 | chip=999; | |
204 | wing=99; | |
205 | return;} | |
206 | wing=0; | |
207 | chip=anode/kNAnode; | |
208 | if(anode>=kNChip*kNAnode) wing=1; | |
209 | if(wing==1) chip-=kNChip; | |
210 | return; | |
211 | } | |
212 | //_________________________________________________________________________ | |
213 | UInt_t AliITSPlaneEffSDD::ChipFromAnode(const UInt_t anode) const { | |
214 | // Retun the chip number [0,3] given the anode number | |
215 | // input: anode number [0,511] | |
216 | if(anode>=kNAnode*kNChip*kNWing) | |
217 | {Error("AliITSPlaneEffSDD::ChipFromAnode","you asked for a non existing anode"); return 999;} | |
218 | Int_t wing=0; | |
219 | Int_t chip=anode/kNAnode; | |
220 | if(anode>=kNChip*kNAnode) wing=1; | |
221 | if(wing==1)chip-=kNChip; | |
222 | return chip; | |
223 | } | |
224 | //_________________________________________________________________________ | |
225 | UInt_t AliITSPlaneEffSDD::WingFromAnode(const UInt_t anode) const { | |
226 | // return the wing number [0,1] given the anode number | |
227 | // input: anode number [0,511] | |
228 | if(anode>=kNAnode*kNChip*kNWing) | |
229 | {Error("AliITSPlaneEffSDD::GetWingFromAnode","you asked for a non existing anode"); return 99;} | |
230 | Int_t wing=0; | |
231 | if(anode>=kNChip*kNAnode) wing=1; | |
232 | return wing; | |
233 | } | |
234 | //__________________________________________________________________________ | |
235 | UInt_t AliITSPlaneEffSDD::GetKey(const UInt_t mod, const UInt_t chip, | |
236 | const UInt_t wing, const UInt_t subw) const { | |
237 | // get key given a basic block | |
238 | if(mod>=kNModule || chip>=kNChip || wing>= kNWing || subw>=kNSubWing) | |
239 | {Error("AliITSPlaneEffSDD::GetKey","you asked for a non existing block"); return 99999;} | |
240 | return mod*kNChip*kNWing*kNSubWing+chip*kNWing*kNSubWing+wing*kNSubWing+subw; | |
241 | } | |
242 | //__________________________________________________________________________ | |
243 | UInt_t AliITSPlaneEffSDD::GetModFromKey(const UInt_t key) const { | |
244 | // get mod. from key | |
245 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
246 | {Error("AliITSPlaneEffSDD::GetModFromKey","you asked for a non existing key"); return 9999;} | |
247 | return key/(kNChip*kNWing*kNSubWing); | |
248 | } | |
249 | //__________________________________________________________________________ | |
250 | UInt_t AliITSPlaneEffSDD::GetChipFromKey(const UInt_t key) const { | |
251 | // retrieves chip from key | |
252 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
253 | {Error("AliITSPlaneEffSDD::GetChipFromKey","you asked for a non existing key"); return 999;} | |
254 | return (key%(kNChip*kNWing*kNSubWing))/(kNWing*kNSubWing); | |
255 | } | |
256 | //__________________________________________________________________________ | |
257 | UInt_t AliITSPlaneEffSDD::GetWingFromKey(const UInt_t key) const { | |
258 | // retrieves wing from key | |
259 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
260 | {Error("AliITSPlaneEffSDD::GetWingFromKey","you asked for a non existing key"); return 99;} | |
261 | return ((key%(kNChip*kNWing*kNSubWing))%(kNWing*kNSubWing))/(kNSubWing); | |
262 | } | |
263 | //__________________________________________________________________________ | |
264 | UInt_t AliITSPlaneEffSDD::GetSubWingFromKey(const UInt_t key) const { | |
265 | // retrieves sub-wing from key | |
266 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
267 | {Error("AliITSPlaneEffSDD::GetSubWingFromKey","you asked for a non existing key"); return 9;} | |
268 | return ((key%(kNChip*kNWing*kNSubWing))%(kNWing*kNSubWing))%(kNSubWing); | |
269 | } | |
270 | //__________________________________________________________________________ | |
271 | void AliITSPlaneEffSDD::GetAllFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip, | |
272 | UInt_t& wing,UInt_t& subw) const { | |
273 | // get module, chip, wing and subwing from a key | |
274 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
275 | {Error("AliITSPlaneEffSDD::GetAllFromKey","you asked for a non existing key"); | |
276 | mod=9999; | |
277 | chip=999; | |
278 | wing=99; | |
279 | subw=9; | |
280 | return;} | |
281 | mod=GetModFromKey(key); | |
282 | chip=GetChipFromKey(key); | |
283 | wing=GetWingFromKey(key); | |
284 | subw=GetSubWingFromKey(key); | |
285 | return; | |
286 | } | |
287 | //____________________________________________________________________________ | |
288 | Double_t AliITSPlaneEffSDD::LivePlaneEff(UInt_t key) const { | |
289 | // returns plane efficieny after adding the fraction of sensor which is bad | |
290 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
291 | {Error("AliITSPlaneEffSDD::LivePlaneEff","you asked for a non existing key"); | |
292 | return -1.;} | |
293 | Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning | |
294 | leff=PlaneEff(key)+GetFracBad(key); | |
295 | return leff>1?1:leff; | |
296 | } | |
297 | //____________________________________________________________________________ | |
298 | Double_t AliITSPlaneEffSDD::ErrLivePlaneEff(UInt_t key) const { | |
299 | // returns error on live plane efficiency | |
300 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
301 | {Error("AliITSPlaneEffSDD::ErrLivePlaneEff","you asked for a non existing key"); | |
302 | return -1.;} | |
303 | Int_t nf=fFound[key]; | |
304 | Double_t triedInLive=GetFracLive(key)*fTried[key]; | |
305 | Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive)); | |
306 | return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked | |
307 | } | |
308 | //_____________________________________________________________________________ | |
309 | Double_t AliITSPlaneEffSDD::GetFracLive(const UInt_t key) const { | |
310 | // returns the fraction of the sensor which is OK | |
311 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
312 | {Error("AliITSPlaneEffSDD::GetFracLive","you asked for a non existing key"); | |
313 | return -1.;} | |
314 | // Compute the fraction of bad (dead+noisy) detector | |
315 | UInt_t bad=0; | |
316 | GetBadInBlock(key,bad); | |
317 | Double_t live=bad; | |
318 | live/=(kNAnode); | |
319 | return 1.-live; | |
320 | } | |
321 | //_____________________________________________________________________________ | |
322 | void AliITSPlaneEffSDD::GetBadInBlock(const UInt_t key, UInt_t& nrBadInBlock) const { | |
323 | // Compute the number of bad (dead+noisy) anodes inside a block | |
324 | // (it depends on the chip, not on the sub-wing) | |
325 | nrBadInBlock=0; | |
326 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
327 | {Error("AliITSPlaneEffSDD::GetBadInBlock","you asked for a non existing key"); | |
328 | return;} | |
329 | // | |
330 | if(!fInitCDBCalled) | |
331 | {Error("AliITSPlaneEffSDD::GetBadInBlock","CDB not inizialized: call InitCDB first"); | |
332 | return;}; | |
333 | AliCDBManager* man = AliCDBManager::Instance(); | |
334 | // retrieve map of dead Pixel | |
335 | AliCDBEntry *cdbSDD = man->Get("ITS/Calib/CalibSDD", fRunNumber); | |
336 | TObjArray* sddEntry; | |
337 | if(cdbSDD) { | |
338 | sddEntry = (TObjArray*)cdbSDD->GetObject(); | |
339 | if(!sddEntry) | |
340 | {Error("AliITSPlaneEffSDD::GetBadInBlock"," SDDEntry not found in CDB"); | |
341 | return;} | |
342 | } else { | |
343 | Error("AliITSPlaneEffSDD::GetBadInBlock","Did not find Calib/CalibSDD"); | |
344 | return; | |
345 | } | |
346 | // | |
347 | UInt_t mod=GetModFromKey(key); | |
348 | UInt_t chip=GetChipFromKey(key); | |
349 | UInt_t wing=GetWingFromKey(key); | |
350 | // count number of dead | |
351 | AliITSCalibrationSDD* calibSDD=(AliITSCalibrationSDD*) sddEntry->At(mod); | |
352 | UInt_t nrBad = calibSDD-> GetDeadChannels(); | |
353 | for (UInt_t index=0; index<nrBad; index++) { | |
354 | if(ChipFromAnode(calibSDD->GetBadChannel(index))==chip && | |
355 | WingFromAnode(calibSDD->GetBadChannel(index))==wing ) nrBadInBlock++; | |
356 | } | |
357 | return; | |
358 | } | |
359 | //_____________________________________________________________________________ | |
360 | Double_t AliITSPlaneEffSDD::GetFracBad(const UInt_t key) const { | |
361 | // returns 1-fractional live | |
362 | if(key>=kNModule*kNChip*kNWing*kNSubWing) | |
363 | {Error("AliITSPlaneEffSDD::GetFracBad","you asked for a non existing key"); | |
364 | return -1.;} | |
365 | return 1.-GetFracLive(key); | |
366 | } | |
367 | //_____________________________________________________________________________ | |
368 | Bool_t AliITSPlaneEffSDD::WriteIntoCDB() const { | |
369 | // write onto CDB | |
370 | if(!fInitCDBCalled) | |
371 | {Error("AliITSPlaneEffSDD::WriteIntoCDB","CDB not inizialized: call InitCDB first"); | |
372 | return kFALSE;} | |
373 | // to be written properly: now only for debugging | |
374 | AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object | |
375 | md->SetObjectClassName("AliITSPlaneEff"); | |
376 | md->SetResponsible("Giuseppe Eugenio Bruno"); | |
377 | md->SetBeamPeriod(0); | |
378 | md->SetAliRootVersion("head 02/01/08"); //root version | |
379 | AliCDBId id("ITS/PlaneEff/PlaneEffSDD",0,AliCDBRunRange::Infinity()); | |
380 | AliITSPlaneEffSDD eff; | |
381 | eff=*this; | |
382 | Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md); | |
383 | delete md; | |
384 | return r; | |
385 | } | |
386 | //_____________________________________________________________________________ | |
387 | Bool_t AliITSPlaneEffSDD::ReadFromCDB() { | |
388 | // read from CDB | |
389 | if(!fInitCDBCalled) | |
390 | {Error("AliITSPlaneEffSDD::ReadFromCDB","CDB not inizialized: call InitCDB first"); | |
391 | return kFALSE;} | |
392 | //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) { | |
393 | // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
394 | // } | |
395 | AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSDD",fRunNumber); | |
396 | AliITSPlaneEffSDD* eff= (AliITSPlaneEffSDD*)cdbEntry->GetObject(); | |
397 | if(this==eff) return kFALSE; | |
398 | eff->Copy(*this); | |
399 | return kTRUE; | |
400 | } |