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