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 module by module efficiency of the SSD,
18 // evaluated by tracks
19 // (Inherits from AliITSPlaneEff)
21 // giuseppe.bruno@ba.infn.it
23 ///////////////////////////////////////////////////////////////////////////
28 #include "AliITSPlaneEffSSD.h"
30 #include "AliCDBStorage.h"
31 #include "AliCDBEntry.h"
32 #include "AliCDBManager.h"
33 //#include "AliCDBRunRange.h"
34 #include "AliITSCalibrationSSD.h"
36 ClassImp(AliITSPlaneEffSSD)
37 //______________________________________________________________________
38 AliITSPlaneEffSSD::AliITSPlaneEffSSD():
40 // Default constructor
41 for (UInt_t i=0; i<kNModule; i++){
45 // default constructor
46 AliDebug(1,Form("Calling default constructor"));
48 //______________________________________________________________________
49 AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){
58 //______________________________________________________________________
59 AliITSPlaneEffSSD::AliITSPlaneEffSSD(const AliITSPlaneEffSSD &s) : AliITSPlaneEff(s) //,
64 // AliITSPlaneEffSSD &s The original class for which
65 // this class is a copy of
70 //_________________________________________________________________________
71 AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){
74 // const AliITSPlaneEffSSD &add simulation class to be added
79 for (UInt_t i=0; i<kNModule; i++){
80 fFound[i] += add.fFound[i];
81 fTried[i] += add.fTried[i];
85 //______________________________________________________________________
86 AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator=(const
87 AliITSPlaneEffSSD &s){
88 // Assignment operator
90 // AliITSPlaneEffSSD &s The original class for which
91 // this class is a copy of
96 if(this==&s) return *this;
100 //______________________________________________________________________
101 void AliITSPlaneEffSSD::Copy(TObject &obj) const {
102 // protected method. copy this to obj
103 AliITSPlaneEff::Copy(obj);
104 for(Int_t i=0;i<kNModule;i++) {
105 ((AliITSPlaneEffSSD& ) obj).fFound[i] = fFound[i];
106 ((AliITSPlaneEffSSD& ) obj).fTried[i] = fTried[i];
109 //______________________________________________________________________
110 AliITSPlaneEff& AliITSPlaneEffSSD::operator=(const
112 // Assignment operator
114 // AliITSPlaneEffSSD &s The original class for which
115 // this class is a copy of
120 if(&s == this) return *this;
121 Error("AliITSPlaneEffSSD","Not allowed to make a = with "
122 "AliITSPlaneEffSSD","Using default creater instead");
126 //_______________________________________________________________________
127 Int_t AliITSPlaneEffSSD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
130 // Estimate the number of tracks still to be collected to attain a
131 // given efficiency eff, with relative error RelErr
133 // eff -> Expected efficiency (e.g. those from actual estimate)
134 // RelErr -> tollerance [0,1]
135 // im -> module number [0,1697]
137 // Return: the estimated n. of tracks
140 {Error("AliITSPlaneEffSSD","you asked for a non existing module");
142 else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)];
144 //_________________________________________________________________________
145 Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const {
146 // Compute the efficiency for a basic block,
148 // im -> module number [0,1697]
150 {Error("AliITSPlaneEffSSD","you asked for a non existing module"); return -1.;}
151 Int_t nf=fFound[GetKey(im)];
152 Int_t nt=fTried[GetKey(im)];
153 return AliITSPlaneEff::PlaneEff(nf,nt);
155 //_________________________________________________________________________
156 Double_t AliITSPlaneEffSSD::ErrPlaneEff(const UInt_t im) const {
157 // Compute the statistical error on efficiency for a basic block,
158 // using binomial statistics
160 // im -> module number [0,1697]
162 {Error("AliITSPlaneEffSSD","you asked for a non existing module"); return -1.;}
163 Int_t nf=fFound[GetKey(im)];
164 Int_t nt=fTried[GetKey(im)];
165 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
167 //_________________________________________________________________________
168 Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) {
169 // Update efficiency for a basic block
171 {Error("AliITSPlaneEffSSD","you asked for a non existing module"); return kFALSE;}
172 fTried[GetKey(im)]++;
173 if(Kfound) fFound[GetKey(im)]++;
176 //_________________________________________________________________________
177 UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const {
178 // get key given a basic block
180 {Error("AliITSPlaneEffSSD::GetKey","you asked for a non existing block"); return 99999;}
183 //__________________________________________________________________________
184 UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const {
187 {Error("AliITSPlaneEffSSD::GetModFromKey","you asked for a non existing key"); return 9999;}
190 //__________________________________________________________________________
191 Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const {
192 // returns plane efficieny after adding the fraction of sensor which is bad
194 {Error("AliITSPlaneEffSSD::LivePlaneEff","you asked for a non existing key");
196 Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
197 leff=PlaneEff(key)+GetFracBad(key);
198 return leff>1?1:leff;
200 //____________________________________________________________________________
201 Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const {
202 // returns error on live plane efficiency
204 {Error("AliITSPlaneEffSSD::ErrLivePlaneEff","you asked for a non existing key");
206 Int_t nf=fFound[key];
207 Double_t triedInLive=GetFracLive(key)*fTried[key];
208 Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
209 return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
211 //_____________________________________________________________________________
212 Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const {
213 // returns the fraction of the sensor which is OK
215 {Error("AliITSPlaneEffSSD::GetFracLive","you asked for a non existing key");
217 // Compute the fraction of bad (dead+noisy) detector
219 GetBadInModule(key,bad);
221 live/=(kNChip*kNSide*kNStrip);
224 //_____________________________________________________________________________
225 void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const {
226 // returns the number of dead and noisy pixels
229 {Error("AliITSPlaneEffSSD::GetDeadAndNoisyInModule","you asked for a non existing key");
231 // Compute the number of bad (dead+noisy) pixel in a module
234 {Error("AliITSPlaneEffSSD::GetDeadAndNoisyInModule","CDB not inizialized: call InitCDB first");
236 AliCDBManager* man = AliCDBManager::Instance();
237 // retrieve map of dead Pixel
238 AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber);
241 ssdEntry = (TObjArray*)cdbSSD->GetObject();
243 {Error("AliITSPlaneEffSSD::GetDeadAndNoisyInChip"," SSDEntry not found in CDB");
246 Error("AliITSPlaneEffSSD::GetDeadAndNoisyInChip","Did not find Calib/BadChannelsSSD");
250 UInt_t mod=GetModFromKey(key);
252 AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod);
253 // count the number of bad channels on the p side
254 nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize();
255 // add the number of bad channels on the s side
256 nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize();
259 //_____________________________________________________________________________
260 Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const {
261 // returns 1-fractional live
263 {Error("AliITSPlaneEffSSD::GetFracBad","you asked for a non existing key");
265 return 1.-GetFracLive(key);
267 //_____________________________________________________________________________
268 Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const {
271 {Error("AliITSPlaneEffSSD::WriteIntoCDB","CDB not inizialized: call InitCDB first");
273 // to be written properly: now only for debugging
274 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
275 md->SetObjectClassName("AliITSPlaneEff");
276 md->SetResponsible("Giuseppe Eugenio Bruno");
277 md->SetBeamPeriod(0);
278 md->SetAliRootVersion("head 02/01/08"); //root version
279 AliCDBId id("ITS/PlaneEff/PlaneEffSSD",0,AliCDBRunRange::Infinity());
280 AliITSPlaneEffSSD eff;
282 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
286 //_____________________________________________________________________________
287 Bool_t AliITSPlaneEffSSD::ReadFromCDB() {
290 {Error("AliITSPlaneEffSSD::ReadFromCDB","CDB not inizialized: call InitCDB first");
292 //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
293 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
295 AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
296 AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
297 if(this==eff) return kFALSE;