]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSSD.cxx
moved component registration to agent; added component configuration/initialization...
[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
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
36ClassImp(AliITSPlaneEffSSD)
37//______________________________________________________________________
38AliITSPlaneEffSSD::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//______________________________________________________________________
48AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){
49 // destructor
50 // Inputs:
51 // none.
52 // Outputs:
53 // none.
54 // Return:
55 // none.
56}
57//______________________________________________________________________
58AliITSPlaneEffSSD::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//_________________________________________________________________________
70AliITSPlaneEffSSD& 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//______________________________________________________________________
85AliITSPlaneEffSSD& 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//______________________________________________________________________
100void 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//______________________________________________________________________
109AliITSPlaneEff& 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//_______________________________________________________________________
124Int_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 //
136if (im>=kNModule)
7167ae53 137 {AliError("GetMissingTracksForGivenEff: you asked for a non existing module");
6344adcc 138 return -1;}
139else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)];
140}
141//_________________________________________________________________________
142Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const {
143// Compute the efficiency for a basic block,
144// Inputs:
145// im -> module number [0,1697]
146if (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)];
150return AliITSPlaneEff::PlaneEff(nf,nt);
151}
152//_________________________________________________________________________
153Double_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]
158if (im>=kNModule)
7167ae53 159 {AliError("ErrPlaneEff(UInt_t): you asked for a non existing module"); return -1.;}
6344adcc 160Int_t nf=fFound[GetKey(im)];
161Int_t nt=fTried[GetKey(im)];
162return AliITSPlaneEff::ErrPlaneEff(nf,nt);
163}
164//_________________________________________________________________________
165Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) {
166 // Update efficiency for a basic block
167if (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//_________________________________________________________________________
174UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const {
175 // get key given a basic block
176if(mod>=kNModule)
7167ae53 177 {AliError("GetKey: you asked for a non existing block"); return 99999;}
6344adcc 178return mod;
179}
180//__________________________________________________________________________
181UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const {
182 // get mod. from key
183if(key>=kNModule)
7167ae53 184 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
6344adcc 185return key;
186}
187//__________________________________________________________________________
188Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const {
189 // returns plane efficieny after adding the fraction of sensor which is bad
190if(key>=kNModule)
7167ae53 191 {AliError("LivePlaneEff: you asked for a non existing key");
6344adcc 192 return -1.;}
193Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
194leff=PlaneEff(key)+GetFracBad(key);
195return leff>1?1:leff;
196}
197//____________________________________________________________________________
198Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const {
199 // returns error on live plane efficiency
200if(key>=kNModule)
7167ae53 201 {AliError("ErrLivePlaneEff: you asked for a non existing key");
6344adcc 202 return -1.;}
203Int_t nf=fFound[key];
204Double_t triedInLive=GetFracLive(key)*fTried[key];
205Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
206return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
207}
208//_____________________________________________________________________________
209Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const {
210 // returns the fraction of the sensor which is OK
211if(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
215UInt_t bad=0;
216GetBadInModule(key,bad);
217Double_t live=bad;
218live/=(kNChip*kNSide*kNStrip);
219return 1.-live;
220}
221//_____________________________________________________________________________
222void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const {
223 // returns the number of dead and noisy pixels
224nrBadInMod=0;
225if(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//
230if(!fInitCDBCalled)
7167ae53 231 {AliError("GetBadInModule: CDB not inizialized: call InitCDB first");
6344adcc 232 return;};
233AliCDBManager* man = AliCDBManager::Instance();
234// retrieve map of dead Pixel
235AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber);
236TObjArray* ssdEntry;
237if(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//
247UInt_t mod=GetModFromKey(key);
248//
249AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod);
250// count the number of bad channels on the p side
251nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize();
252// add the number of bad channels on the s side
253nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize();
254return;
255}
256//_____________________________________________________________________________
257Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const {
258 // returns 1-fractional live
259if(key>=kNModule)
7167ae53 260 {AliError("GetFracBad: you asked for a non existing key");
6344adcc 261 return -1.;}
262return 1.-GetFracLive(key);
263}
264//_____________________________________________________________________________
265Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const {
266// write onto CDB
267if(!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//_____________________________________________________________________________
284Bool_t AliITSPlaneEffSSD::ReadFromCDB() {
285// read from CDB
286if(!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// }
292AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
293AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
294if(this==eff) return kFALSE;
295eff->Copy(*this);
296return kTRUE;
297}
7167ae53 298//_____________________________________________________________________________
299UInt_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)
302UInt_t key=999999;
303if(ilay<4 || ilay>5)
304 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
305 return key;}
306if(ilay==4 && (idet<0 || idet>747))
307 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
308 return key;}
309if(ilay==5 && (idet<0 || idet>949))
310 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
311 return key;}
312
313UInt_t mod=idet;
314if(ilay==1) mod+=748;
315key=GetKey(mod);
316return key;
317}