]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEff.cxx
Fix of parsing bug related to the reading of the calib header. Added consistency...
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEff.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// Base Plane Efficiency class for ITS
17// Specific subdetector implementation is done in
18// AliITSPlaneEffSPD
19// AliITSPlaneEffSDD
20// AliITSPlaneEffSSD
21//
22// Author: G.E. Bruno
23// giuseppe.bruno@ba.infn.it
24//
25///////////////////////////////////////////////////////////////////////////
26
27/* $Id$ */
28
29#include <TMath.h>
30#include "AliITSPlaneEff.h"
31#include "AliLog.h"
32#include "AliCDBManager.h"
33#include "AliCDBStorage.h"
34
35ClassImp(AliITSPlaneEff)
36//______________________________________________________________________
37AliITSPlaneEff::AliITSPlaneEff(): TObject(),
38fRunNumber(0),
39fCDBUri(""),
40fInitCDBCalled(kFALSE)
41{
42 // Default constructor
43 // Inputs:
44 // none.
45 // Outputs:
46 // none.
47 // Return:
48 // a default constructed AliITSPlaneEff class
49 InitCDB();
50}
51//______________________________________________________________________
52AliITSPlaneEff::AliITSPlaneEff(const AliITSPlaneEff &s) : TObject(s),
53fRunNumber(s.fRunNumber),
54fCDBUri(s.fCDBUri),
55fInitCDBCalled(s.fInitCDBCalled)
56{
57 // Copy Constructor
58 // Inputs:
59 // const AliITSPlaneEff &s simulation class to copy from
60 // Outputs:
61 // none.
62 // Return:
63 // a standard constructed AliITSPlaneEff class with values the same
64 // as that of s.
65
66}
67//_________________________________________________________________________
68//void AliITSPlaneEff::operator+=(const AliITSPlaneEff &add){
69 // Add to me operator
70 // Inputs:
71 // const AliITSPlaneEff &add simulation class to be added
72 // Outputs:
73 // none.
74 // Return:
75 // none
76
77// return;
78//}
79//_________________________________________________________________________
80AliITSPlaneEff& AliITSPlaneEff::operator=(const AliITSPlaneEff &source){
81 // Assignment operator
82 // Inputs:
83 // const AliITSPlaneEff &source simulation class to copy from
84 // Outputs:
85 // none.
86 // Return:
87 // a standard constructed AliITSPlaneEff class with values the same
88 // as that of s.
89 if(this != &source){
90 source.Copy(*this);
91 }
92 return *this;
93// if(&s == this) return *this;
94// this->fRunNumber = s.fRunNumber;
95// this->fCDBUri = s.fCDBUri;
96// this->fInitCDBCalled = s.fInitCDBCalled;
97// return *this;
98}
99//_____________________________________________________________
100void AliITSPlaneEff::Copy(TObject &obj) const {
101 // copy this to obj
102 ((AliITSPlaneEff& ) obj).fRunNumber = fRunNumber;
103 ((AliITSPlaneEff& ) obj).fCDBUri = fCDBUri;
104 ((AliITSPlaneEff& ) obj).fInitCDBCalled = fInitCDBCalled;
105}
106//_________________________________________________________________________
107Double_t AliITSPlaneEff::PlaneEff(Int_t nf,Int_t nt) const {
108 // Compute the efficiency for a basic block,
109 // Inputs:
110 // number of associated cluslters (nf)
111 // number of used tracks (nt)
112 // Outputs:
113 // none.
114 // Return:
115 // the efficiency
116if(nf<0 || nt<=0 || nt<nf) {
117 AliInfo(Form("AliITSPlaneEff::PlaneEff: nfound= %i, ntried= %i",nf,nt));
118 return -1.;}
119 Double_t eff=nf;
120 return eff/=nt;
121}
122//_________________________________________________________________________
123Double_t AliITSPlaneEff::ErrPlaneEff(Int_t nf,Int_t nt) const{
124 // Compute the statistical error on efficiency for a basic block,
125 // using binomial statistics
126 // Inputs:
127 // number of associated cluslters (nf)
128 // number of used tracks (nt)
129 // Outputs:
130 // none.
131 // Return:
132 // the error on the efficiency
133if(nf<0 || nt<=0 || nt<nf) {
134 AliInfo(Form("AliITSPlaneEff::ErrPlaneEff: nfound= %i, ntried= %i",nf,nt));
135 return -1.;}
136 Double_t err=TMath::Sqrt(nf*(1.-nf/nt));
137 return err/=nt;
138}
139//______________________________________________________________________
140Int_t AliITSPlaneEff::GetNTracksForGivenEff(Double_t eff, Double_t RelErr) const {
141 // Estimate of the number of tracks needed for measuring efficiency
142 // with a given relative error using binomial statistics
143 // Inputs:
144 // exspected efficiency eff (e.g. from previous measurements)
145 // wished relative error RelErr
146 // Outputs:
147 // none.
148 // Return: number of tracks given as the nearest integer
149if(eff<=0 || eff>1 || RelErr<=0 ) {
150 AliInfo(Form("AliITSPlaneEff::GetNTracksForGivenEff: eff= %f, RelErr= %f",eff,RelErr));
151 return -1;}
152return TMath::Nint((1-eff)/(eff*RelErr*RelErr));
153}
154//________________________________________________________________________
155void AliITSPlaneEff::InitCDB()
156{
157// activate a default CDB storage
158// First check if we have any CDB storage set, because it is used
159// to retrieve the calibration and alignment constants
160
161 if (fInitCDBCalled) return;
162 fInitCDBCalled = kTRUE;
163
164 AliCDBManager* man = AliCDBManager::Instance();
165 if (man->IsDefaultStorageSet())
166 {
167 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
168 AliWarning("Default CDB storage has been already set !");
169 AliWarning(Form("Ignoring the default storage declared in AliITSPlaneEff: %s",fCDBUri.Data()));
170 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
171 fCDBUri = man->GetDefaultStorage()->GetURI();
172 }
173 else {
174 if (fCDBUri.Length() > 0)
175 {
176 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
177 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
178 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
179 } else {
180 fCDBUri="local://$ALICE_ROOT";
181 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
182 AliWarning("Default CDB storage not yet set !!!!");
183 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
184 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
185
186 }
187 man->SetDefaultStorage(fCDBUri);
188 }
189}
190//_____________________________________________________________________________
191void AliITSPlaneEff::SetDefaultStorage(const char* uri) {
192// Store the desired default CDB storage location
193// Activate it later within the Run() method
194
195 fCDBUri = uri;
196
197}
198