]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSSD.cxx
Some more effc++ warnings.
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSSD.cxx
CommitLineData
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
36ClassImp(AliITSPlaneEffSSD)
37//______________________________________________________________________
38AliITSPlaneEffSSD::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//______________________________________________________________________
49AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){
50 // destructor
51 // Inputs:
52 // none.
53 // Outputs:
54 // none.
55 // Return:
56 // none.
57}
58//______________________________________________________________________
59AliITSPlaneEffSSD::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//_________________________________________________________________________
71AliITSPlaneEffSSD& 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//______________________________________________________________________
86AliITSPlaneEffSSD& 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//______________________________________________________________________
101void 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//______________________________________________________________________
110AliITSPlaneEff& 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//_______________________________________________________________________
127Int_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 //
139if (im>=kNModule)
140 {Error("AliITSPlaneEffSSD","you asked for a non existing module");
141 return -1;}
142else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)];
143}
144//_________________________________________________________________________
145Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const {
146// Compute the efficiency for a basic block,
147// Inputs:
148// im -> module number [0,1697]
149if (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)];
153return AliITSPlaneEff::PlaneEff(nf,nt);
154}
155//_________________________________________________________________________
156Double_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]
161if (im>=kNModule)
162 {Error("AliITSPlaneEffSSD","you asked for a non existing module"); return -1.;}
163Int_t nf=fFound[GetKey(im)];
164Int_t nt=fTried[GetKey(im)];
165return AliITSPlaneEff::ErrPlaneEff(nf,nt);
166}
167//_________________________________________________________________________
168Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) {
169 // Update efficiency for a basic block
170if (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//_________________________________________________________________________
177UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const {
178 // get key given a basic block
179if(mod>=kNModule)
180 {Error("AliITSPlaneEffSSD::GetKey","you asked for a non existing block"); return 99999;}
181return mod;
182}
183//__________________________________________________________________________
184UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const {
185 // get mod. from key
186if(key>=kNModule)
187 {Error("AliITSPlaneEffSSD::GetModFromKey","you asked for a non existing key"); return 9999;}
188return key;
189}
190//__________________________________________________________________________
191Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const {
192 // returns plane efficieny after adding the fraction of sensor which is bad
193if(key>=kNModule)
194 {Error("AliITSPlaneEffSSD::LivePlaneEff","you asked for a non existing key");
195 return -1.;}
196Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
197leff=PlaneEff(key)+GetFracBad(key);
198return leff>1?1:leff;
199}
200//____________________________________________________________________________
201Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const {
202 // returns error on live plane efficiency
203if(key>=kNModule)
204 {Error("AliITSPlaneEffSSD::ErrLivePlaneEff","you asked for a non existing key");
205 return -1.;}
206Int_t nf=fFound[key];
207Double_t triedInLive=GetFracLive(key)*fTried[key];
208Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
209return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
210}
211//_____________________________________________________________________________
212Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const {
213 // returns the fraction of the sensor which is OK
214if(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
218UInt_t bad=0;
219GetBadInModule(key,bad);
220Double_t live=bad;
221live/=(kNChip*kNSide*kNStrip);
222return 1.-live;
223}
224//_____________________________________________________________________________
225void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const {
226 // returns the number of dead and noisy pixels
227nrBadInMod=0;
228if(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//
233if(!fInitCDBCalled)
234 {Error("AliITSPlaneEffSSD::GetDeadAndNoisyInModule","CDB not inizialized: call InitCDB first");
235 return;};
236AliCDBManager* man = AliCDBManager::Instance();
237// retrieve map of dead Pixel
238AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber);
239TObjArray* ssdEntry;
240if(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//
250UInt_t mod=GetModFromKey(key);
251//
252AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod);
253// count the number of bad channels on the p side
254nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize();
255// add the number of bad channels on the s side
256nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize();
257return;
258}
259//_____________________________________________________________________________
260Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const {
261 // returns 1-fractional live
262if(key>=kNModule)
263 {Error("AliITSPlaneEffSSD::GetFracBad","you asked for a non existing key");
264 return -1.;}
265return 1.-GetFracLive(key);
266}
267//_____________________________________________________________________________
268Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const {
269// write onto CDB
270if(!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//_____________________________________________________________________________
287Bool_t AliITSPlaneEffSSD::ReadFromCDB() {
288// read from CDB
289if(!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// }
295AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
296AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
297if(this==eff) return kFALSE;
298eff->Copy(*this);
299return kTRUE;
300}