1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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)
21 // giuseppe.bruno@ba.infn.it
23 ///////////////////////////////////////////////////////////////////////////
27 #include "AliITSPlaneEffSPD.h"
29 #include "AliCDBStorage.h"
30 #include "AliCDBEntry.h"
31 #include "AliCDBManager.h"
32 //#include "AliCDBRunRange.h"
33 #include "AliITSCalibrationSPD.h"
35 ClassImp(AliITSPlaneEffSPD)
36 //______________________________________________________________________
37 AliITSPlaneEffSPD::AliITSPlaneEffSPD():
39 // for (UInt_t im=0; im<kNModule; im++){
40 // for (UInt_t ic=0; ic<kNChip; ic++){
44 for (UInt_t i=0; i<kNModule*kNChip; i++){
48 // default constructor
49 AliDebug(1,Form("Calling default constructor"));
51 //______________________________________________________________________
52 AliITSPlaneEffSPD::~AliITSPlaneEffSPD(){
61 //______________________________________________________________________
62 AliITSPlaneEffSPD::AliITSPlaneEffSPD(const AliITSPlaneEffSPD &s) : AliITSPlaneEff(s) //,
67 // AliITSPlaneEffSPD &s The original class for which
68 // this class is a copy of
74 //_________________________________________________________________________
75 AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator+=(const AliITSPlaneEffSPD &add){
78 // const AliITSPlaneEffSPD &add simulation class to be added
83 for (UInt_t i=0; i<kNModule*kNChip; i++){
84 fFound[i] += add.fFound[i];
85 fTried[i] += add.fTried[i];
89 //______________________________________________________________________
90 AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator=(const
91 AliITSPlaneEffSPD &s){
92 // Assignment operator
94 // AliITSPlaneEffSPD &s The original class for which
95 // this class is a copy of
100 if(this==&s) return *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];
109 //______________________________________________________________________
110 void 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];
119 //______________________________________________________________________
120 AliITSPlaneEff& AliITSPlaneEffSPD::operator=(const
122 // Assignment operator
124 // AliITSPlaneEffSPD &s The original class for which
125 // this class is a copy of
130 if(&s == this) return *this;
131 Error("AliITSPlaneEffSPD","Not allowed to make a = with "
132 "AliITSPlaneEffSPD","Using default creater instead");
136 //_______________________________________________________________________
137 Int_t AliITSPlaneEffSPD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
138 UInt_t im, UInt_t ic) const {
140 // Estimate the number of tracks still to be collected to attain a
141 // given efficiency eff, with relative error RelErr
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]
148 // Return: the estimated n. of tracks
150 if (im>=kNModule || ic>=kNChip)
151 {Error("AliITSPlaneEffSPD","you asked for a non existing chip");
153 else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic)];
155 //_________________________________________________________________________
156 Double_t AliITSPlaneEffSPD::PlaneEff(const UInt_t im,const UInt_t ic) const {
157 // Compute the efficiency for a basic block,
159 // number of associated cluslters (nf)
160 // number of used tracks (nt)
161 if (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)];
165 return AliITSPlaneEff::PlaneEff(nf,nt);
167 //_________________________________________________________________________
168 Double_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
172 // number of associated cluslters (nf)
173 // number of used tracks (nt)
174 if (im>=kNModule || ic>=kNChip)
175 {Error("AliITSPlaneEffSPD","you asked for a non existing chip"); return -1.;}
176 Int_t nf=fFound[GetKey(im,ic)];
177 Int_t nt=fTried[GetKey(im,ic)];
178 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
180 //_________________________________________________________________________
181 Bool_t AliITSPlaneEffSPD::UpDatePlaneEff(const Bool_t Kfound,
182 const UInt_t im, const UInt_t ic) {
183 // Update efficiency for a basic block
184 if (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)]++;
190 //_________________________________________________________________________
191 UInt_t AliITSPlaneEffSPD::GetChip(const UInt_t col) const {
192 // get chip given the column
193 if(col>=kNCol*kNChip)
194 {Error("AliITSPlaneEffSPD","you asked for a non existing column"); return 10;}
197 //__________________________________________________________________________
198 UInt_t AliITSPlaneEffSPD::GetKey(const UInt_t mod, const UInt_t chip) const {
199 // get key given a basic block
200 if(mod>=kNModule || chip>=kNChip)
201 {Error("AliITSPlaneEffSPD::GetKey","you asked for a non existing block"); return 99999;}
202 return mod*kNChip+chip;
204 //__________________________________________________________________________
205 UInt_t AliITSPlaneEffSPD::GetModFromKey(const UInt_t key) const {
207 if(key>=kNModule*kNChip)
208 {Error("AliITSPlaneEffSPD::GetModFromKey","you asked for a non existing key"); return 9999;}
211 //__________________________________________________________________________
212 UInt_t AliITSPlaneEffSPD::GetChipFromKey(const UInt_t key) const {
213 // retrieves chip from key
214 if(key>=kNModule*kNChip)
215 {Error("AliITSPlaneEffSPD::GetChipFromKey","you asked for a non existing key"); return 999;}
216 return (key%(kNModule*kNChip))%kNChip;
218 //__________________________________________________________________________
219 void AliITSPlaneEffSPD::GetModAndChipFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip) const {
220 // get module and chip from a key
221 if(key>=kNModule*kNChip)
222 {Error("AliITSPlaneEffSPD::GetModAndChipFromKey","you asked for a non existing key");
227 chip=(key%(kNModule*kNChip))%kNChip;
230 //____________________________________________________________________________
231 Double_t AliITSPlaneEffSPD::LivePlaneEff(UInt_t key) const {
232 // returns plane efficieny multiplied by the fraction of sensor which is OK
233 if(key>=kNModule*kNChip)
234 {Error("AliITSPlaneEffSPD::LivePlaneEff","you asked for a non existing key");
236 return PlaneEff(key)*GetFracLive(key);
238 //____________________________________________________________________________
239 Double_t AliITSPlaneEffSPD::ErrLivePlaneEff(UInt_t key) const {
240 // returns error on live plane efficiency
241 if(key>=kNModule*kNChip)
242 {Error("AliITSPlaneEffSPD::LivePlaneEff","you asked for a non existing key");
244 return ErrPlaneEff(key); // for the time being: to be checked
246 //_____________________________________________________________________________
247 Double_t AliITSPlaneEffSPD::GetFracLive(const UInt_t key) const {
248 // returns the fraction of the sensor which is OK
249 if(key>=kNModule*kNChip)
250 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","you asked for a non existing key");
252 // Compute the fraction of bad (dead+noisy) detector
253 UInt_t dead=0,noisy=0;
254 GetDeadAndNoisyInChip(key,dead,noisy);
255 Double_t live=dead+noisy;
259 //_____________________________________________________________________________
260 void AliITSPlaneEffSPD::GetDeadAndNoisyInChip(const UInt_t key,
261 UInt_t& nrDeadInChip, UInt_t& nrNoisyInChip) const {
262 // returns the number of dead and noisy pixels
265 if(key>=kNModule*kNChip)
266 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","you asked for a non existing key");
268 // Compute the number of bad (dead+noisy) pixel in a chip
271 {Error("AliITSPlaneEffSPD::GetRelLiveDetector","CDB not inizialized: call InitCDB first");
273 AliCDBManager* man = AliCDBManager::Instance();
274 // retrieve map of dead Pixel
275 AliCDBEntry *cdbSPDDead = man->Get("ITS/Calib/SPDDead", fRunNumber);
278 spdDead = (TObjArray*)cdbSPDDead->GetObject();
280 {Error("AliITSPlaneEffSPD::GetRelLiveDetector"," SPDDead not found in CDB");
283 Error("AliITSPlaneEffSPD::GetRelLiveDetector","Did not find Calib/SPDDead.");
286 // retrieve map of noisy Pixel
287 AliCDBEntry *cdbSPDNoisy = man->Get("ITS/Calib/SPDNoisy", fRunNumber);
290 spdNoisy = (TObjArray*)cdbSPDNoisy->GetObject();
292 {Error("AliITSPlaneEffSPD::GetRelLiveDetector"," SPDNoisy not found in CDB");
295 Error("AliITSPlaneEffSPD::GetRelLiveDetector","Did not find Calib/SPDNoisy.");
299 UInt_t mod=GetModFromKey(key);
300 UInt_t chip=GetChipFromKey(key);
301 // count number of dead
302 AliITSCalibrationSPD* calibSPD=(AliITSCalibrationSPD*) spdDead->At(mod);
303 UInt_t nrDead = calibSPD->GetNrBad();
304 for (UInt_t index=0; index<nrDead; index++) {
305 if(GetChip(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
307 calibSPD=(AliITSCalibrationSPD*) spdNoisy->At(mod);
308 UInt_t nrNoisy = calibSPD->GetNrBad();
309 for (UInt_t index=0; index<nrNoisy; index++) {
310 if(GetChip(calibSPD->GetBadColAt(index))==chip) nrNoisyInChip++;
314 //_____________________________________________________________________________
315 Double_t AliITSPlaneEffSPD::GetFracBad(const UInt_t key) const {
316 // returns 1-fractional live
317 if(key>=kNModule*kNChip)
318 {Error("AliITSPlaneEffSPD::GetRelDeadDetector","you asked for a non existing key");
320 return 1.-GetFracLive(key);
322 //_____________________________________________________________________________
323 Bool_t AliITSPlaneEffSPD::WriteIntoCDB() const {
326 {Error("AliITSPlaneEffSPD::WriteIntoCDB","CDB not inizialized: call InitCDB first");
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;
337 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
341 //_____________________________________________________________________________
342 Bool_t AliITSPlaneEffSPD::ReadFromCDB() {
345 {Error("AliITSPlaneEffSPD::ReadFromCDB","CDB not inizialized: call InitCDB first");
347 //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
348 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
350 AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
351 AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
352 if(this==eff) return kFALSE;