]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSPD.cxx
Adding new classes AliMUONClusterFinderPeakFit, AliMUONClusterFinderPeakCOG
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSPD.cxx
CommitLineData
4a66240a 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 of the SPD,
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 "AliITSPlaneEffSPD.h"
28#include "AliLog.h"
29#include "AliCDBStorage.h"
30#include "AliCDBEntry.h"
31#include "AliCDBManager.h"
32//#include "AliCDBRunRange.h"
33#include "AliITSCalibrationSPD.h"
34
35ClassImp(AliITSPlaneEffSPD)
36//______________________________________________________________________
37AliITSPlaneEffSPD::AliITSPlaneEffSPD():
38 AliITSPlaneEff(){
39// for (UInt_t im=0; im<kNModule; im++){
40// for (UInt_t ic=0; ic<kNChip; ic++){
41// fFound[im][ic]=0;
42// fTried[im][ic]=0;
43// }}
44 for (UInt_t i=0; i<kNModule*kNChip; i++){
45 fFound[i]=0;
46 fTried[i]=0;
47 }
48 // default constructor
49 AliDebug(1,Form("Calling default constructor"));
50}
51//______________________________________________________________________
52AliITSPlaneEffSPD::~AliITSPlaneEffSPD(){
53 // destructor
54 // Inputs:
55 // none.
56 // Outputs:
57 // none.
58 // Return:
59 // none.
60}
61//______________________________________________________________________
62AliITSPlaneEffSPD::AliITSPlaneEffSPD(const AliITSPlaneEffSPD &s) : AliITSPlaneEff(s) //,
63//fHis(s.fHis),
64{
65 // Copy Constructor
66 // Inputs:
67 // AliITSPlaneEffSPD &s The original class for which
68 // this class is a copy of
69 // Outputs:
70 // none.
71 // Return:
72
73}
74//_________________________________________________________________________
75AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator+=(const AliITSPlaneEffSPD &add){
76 // Add-to-me operator
77 // Inputs:
78 // const AliITSPlaneEffSPD &add simulation class to be added
79 // Outputs:
80 // none.
81 // Return:
82 // none
83 for (UInt_t i=0; i<kNModule*kNChip; i++){
84 fFound[i] += add.fFound[i];
85 fTried[i] += add.fTried[i];
86 }
87 return *this;
88}
89//______________________________________________________________________
90AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator=(const
91 AliITSPlaneEffSPD &s){
92 // Assignment operator
93 // Inputs:
94 // AliITSPlaneEffSPD &s The original class for which
95 // this class is a copy of
96 // Outputs:
97 // none.
98 // Return:
99
100 if(this==&s) return *this;
101 s.Copy(*this);
102// if(&s == this) return *this;
103// for (UInt_t i=0; i<kNModule*kNChip; i++){
104// this->fFound[i] = s.fFound[i];
105// this->fTried[i] = s.fTried[i];
106// }
107 return *this;
108}
109//______________________________________________________________________
110void AliITSPlaneEffSPD::Copy(TObject &obj) const {
111 // protected method. copy this to obj
112 AliITSPlaneEff::Copy(obj);
113 //((AliITSPlaneEffSPD& ) obj).fNpx = fNpx;
114 for(Int_t i=0;i<kNModule*kNChip;i++) {
115 ((AliITSPlaneEffSPD& ) obj).fFound[i] = fFound[i];
116 ((AliITSPlaneEffSPD& ) obj).fTried[i] = fTried[i];
117 }
118}
119//______________________________________________________________________
120AliITSPlaneEff& AliITSPlaneEffSPD::operator=(const
121 AliITSPlaneEff &s){
122 // Assignment operator
123 // Inputs:
124 // AliITSPlaneEffSPD &s The original class for which
125 // this class is a copy of
126 // Outputs:
127 // none.
128 // Return:
129
130 if(&s == this) return *this;
131 Error("AliITSPlaneEffSPD","Not allowed to make a = with "
132 "AliITSPlaneEffSPD","Using default creater instead");
133
134 return *this;
135}
136//_______________________________________________________________________
137Int_t AliITSPlaneEffSPD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
138 UInt_t im, UInt_t ic) const {
139
140 // Estimate the number of tracks still to be collected to attain a
141 // given efficiency eff, with relative error RelErr
142 // Inputs:
143 // eff -> Expected efficiency (e.g. those from actual estimate)
144 // RelErr -> tollerance [0,1]
145 // im -> module number [0,249]
146 // ic -> chip number [0,5]
147 // Outputs: none
148 // Return: the estimated n. of tracks
149 //
150if (im>=kNModule || ic>=kNChip)
151 {Error("AliITSPlaneEffSPD","you asked for a non existing chip");
152 return -1;}
153else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic)];
154}
155//_________________________________________________________________________
156Double_t AliITSPlaneEffSPD::PlaneEff(const UInt_t im,const UInt_t ic) const {
157// Compute the efficiency for a basic block,
158// Inputs:
159// number of associated cluslters (nf)
160// number of used tracks (nt)
161if (im>=kNModule || ic>=kNChip)
162 {Error("AliITSPlaneEffSPD","you asked for a non existing chip"); return -1.;}
163 Int_t nf=fFound[GetKey(im,ic)];
164 Int_t nt=fTried[GetKey(im,ic)];
165return AliITSPlaneEff::PlaneEff(nf,nt);
166}
167//_________________________________________________________________________
168Double_t AliITSPlaneEffSPD::ErrPlaneEff(const UInt_t im,const UInt_t ic) const {
169 // Compute the statistical error on efficiency for a basic block,
170 // using binomial statistics
171 // Inputs:
172 // number of associated cluslters (nf)
173 // number of used tracks (nt)
174if (im>=kNModule || ic>=kNChip)
175 {Error("AliITSPlaneEffSPD","you asked for a non existing chip"); return -1.;}
176Int_t nf=fFound[GetKey(im,ic)];
177Int_t nt=fTried[GetKey(im,ic)];
178return AliITSPlaneEff::ErrPlaneEff(nf,nt);
179}
180//_________________________________________________________________________
181Bool_t AliITSPlaneEffSPD::UpDatePlaneEff(const Bool_t Kfound,
182 const UInt_t im, const UInt_t ic) {
183 // Update efficiency for a basic block
184if (im>=kNModule || ic>=kNChip)
185 {Error("AliITSPlaneEffSPD","you asked for a non existing chip"); return kFALSE;}
186 fTried[GetKey(im,ic)]++;
187 if(Kfound) fFound[GetKey(im,ic)]++;
188 return kTRUE;
189}
190//_________________________________________________________________________
191UInt_t AliITSPlaneEffSPD::GetChip(const UInt_t col) const {
192 // get chip given the column
193if(col>=kNCol*kNChip)
194 {Error("AliITSPlaneEffSPD","you asked for a non existing column"); return 10;}
195return col/kNCol;
196}
197//__________________________________________________________________________
198UInt_t AliITSPlaneEffSPD::GetKey(const UInt_t mod, const UInt_t chip) const {
199 // get key given a basic block
200if(mod>=kNModule || chip>=kNChip)
201 {Error("AliITSPlaneEffSPD::GetKey","you asked for a non existing block"); return 99999;}
202return mod*kNChip+chip;
203}
204//__________________________________________________________________________
205UInt_t AliITSPlaneEffSPD::GetModFromKey(const UInt_t key) const {
206 // get mod. from key
207if(key>=kNModule*kNChip)
208 {Error("AliITSPlaneEffSPD::GetModFromKey","you asked for a non existing key"); return 9999;}
209return key/kNChip;
210}
211//__________________________________________________________________________
212UInt_t AliITSPlaneEffSPD::GetChipFromKey(const UInt_t key) const {
213 // retrieves chip from key
214if(key>=kNModule*kNChip)
215 {Error("AliITSPlaneEffSPD::GetChipFromKey","you asked for a non existing key"); return 999;}
216return (key%(kNModule*kNChip))%kNChip;
217}
218//__________________________________________________________________________
219void AliITSPlaneEffSPD::GetModAndChipFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip) const {
220 // get module and chip from a key
221if(key>=kNModule*kNChip)
222 {Error("AliITSPlaneEffSPD::GetModAndChipFromKey","you asked for a non existing key");
223 mod=9999;
224 chip=999;
225 return;}
226mod=key/kNChip;
227chip=(key%(kNModule*kNChip))%kNChip;
228return;
229}
230//____________________________________________________________________________
231Double_t AliITSPlaneEffSPD::LivePlaneEff(UInt_t key) const {
232 // returns plane efficieny multiplied by the fraction of sensor which is OK
233if(key>=kNModule*kNChip)
234 {Error("AliITSPlaneEffSPD::LivePlaneEff","you asked for a non existing key");
235 return -1.;}
236return PlaneEff(key)*GetFracLive(key);
237}
238//____________________________________________________________________________
239Double_t AliITSPlaneEffSPD::ErrLivePlaneEff(UInt_t key) const {
240 // returns error on live plane efficiency
241if(key>=kNModule*kNChip)
242 {Error("AliITSPlaneEffSPD::LivePlaneEff","you asked for a non existing key");
243 return -1.;}
244return ErrPlaneEff(key); // for the time being: to be checked
245}
246//_____________________________________________________________________________
247Double_t AliITSPlaneEffSPD::GetFracLive(const UInt_t key) const {
248 // returns the fraction of the sensor which is OK
249if(key>=kNModule*kNChip)
250 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","you asked for a non existing key");
251 return -1.;}
252 // Compute the fraction of bad (dead+noisy) detector
253UInt_t dead=0,noisy=0;
254GetDeadAndNoisyInChip(key,dead,noisy);
255Double_t live=dead+noisy;
256live/=(kNRow*kNCol);
257return 1.-live;
258}
259//_____________________________________________________________________________
260void AliITSPlaneEffSPD::GetDeadAndNoisyInChip(const UInt_t key,
261 UInt_t& nrDeadInChip, UInt_t& nrNoisyInChip) const {
262 // returns the number of dead and noisy pixels
263nrDeadInChip=0;
264nrNoisyInChip=0;
265if(key>=kNModule*kNChip)
266 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","you asked for a non existing key");
267 return;}
268 // Compute the number of bad (dead+noisy) pixel in a chip
269//
270if(!fInitCDBCalled)
271 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","CDB not inizialized: call InitCDB first");
272 return;};
273AliCDBManager* man = AliCDBManager::Instance();
274// retrieve map of dead Pixel
275AliCDBEntry *cdbSPDDead = man->Get("ITS/Calib/SPDDead", fRunNumber);
276TObjArray* spdDead;
277if(cdbSPDDead) {
278 spdDead = (TObjArray*)cdbSPDDead->GetObject();
279 if(!spdDead)
280 {Error("AliITSPlaneEffSPD::GetRelLiveDetector"," SPDDead not found in CDB");
281 return;}
282} else {
283 Error("AliITSPlaneEffSPD::GetRelLiveDetector","Did not find Calib/SPDDead.");
284 return;
285}
286// retrieve map of noisy Pixel
287AliCDBEntry *cdbSPDNoisy = man->Get("ITS/Calib/SPDNoisy", fRunNumber);
288TObjArray* spdNoisy;
289if(cdbSPDNoisy) {
290 spdNoisy = (TObjArray*)cdbSPDNoisy->GetObject();
291 if(!spdNoisy)
292 {Error("AliITSPlaneEffSPD::GetRelLiveDetector"," SPDNoisy not found in CDB");
293 return;}
294} else {
295 Error("AliITSPlaneEffSPD::GetRelLiveDetector","Did not find Calib/SPDNoisy.");
296 return;
297}
298//
299UInt_t mod=GetModFromKey(key);
300UInt_t chip=GetChipFromKey(key);
301// count number of dead
302AliITSCalibrationSPD* calibSPD=(AliITSCalibrationSPD*) spdDead->At(mod);
303UInt_t nrDead = calibSPD->GetNrBad();
304for (UInt_t index=0; index<nrDead; index++) {
305 if(GetChip(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
306}
307calibSPD=(AliITSCalibrationSPD*) spdNoisy->At(mod);
308UInt_t nrNoisy = calibSPD->GetNrBad();
309for (UInt_t index=0; index<nrNoisy; index++) {
310 if(GetChip(calibSPD->GetBadColAt(index))==chip) nrNoisyInChip++;
311}
312return;
313}
314//_____________________________________________________________________________
315Double_t AliITSPlaneEffSPD::GetFracBad(const UInt_t key) const {
316 // returns 1-fractional live
317if(key>=kNModule*kNChip)
318 {Error("AliITSPlaneEffSPD::GetRelDeadDetector","you asked for a non existing key");
319 return -1.;}
320return 1.-GetFracLive(key);
321}
322//_____________________________________________________________________________
323Bool_t AliITSPlaneEffSPD::WriteIntoCDB() const {
324// write onto CDB
325if(!fInitCDBCalled)
326 {Error("AliITSPlaneEffSPD::WriteIntoCDB","CDB not inizialized: call InitCDB first");
327 return kFALSE;}
328// to be written properly: now only for debugging
329 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
330 md->SetObjectClassName("AliITSPlaneEff");
331 md->SetResponsible("Giuseppe Eugenio Bruno");
332 md->SetBeamPeriod(0);
333 md->SetAliRootVersion("head 19/11/07"); //root version
334 AliCDBId id("ITS/PlaneEff/PlaneEffSPD",0,AliCDBRunRange::Infinity());
335 AliITSPlaneEffSPD eff;
336 eff=*this;
337 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
338 delete md;
339 return r;
340}
341//_____________________________________________________________________________
342Bool_t AliITSPlaneEffSPD::ReadFromCDB() {
343// read from CDB
344if(!fInitCDBCalled)
345 {Error("AliITSPlaneEffSPD::ReadFromCDB","CDB not inizialized: call InitCDB first");
346 return kFALSE;}
347//if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
348// AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
349// }
350AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
351AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
352if(this==eff) return kFALSE;
353eff->Copy(*this);
354return kTRUE;
355}