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