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 for (UInt_t i=0; i<kNModule; i++){
44 // default constructor
45 AliDebug(1,Form("Calling default constructor"));
47 //______________________________________________________________________
48 AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){
57 //______________________________________________________________________
58 AliITSPlaneEffSSD::AliITSPlaneEffSSD(const AliITSPlaneEffSSD &s) : AliITSPlaneEff(s) //,
63 // AliITSPlaneEffSSD &s The original class for which
64 // this class is a copy of
69 //_________________________________________________________________________
70 AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){
73 // const AliITSPlaneEffSSD &add simulation class to be added
78 for (UInt_t i=0; i<kNModule; i++){
79 fFound[i] += add.fFound[i];
80 fTried[i] += add.fTried[i];
84 //______________________________________________________________________
85 AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator=(const
86 AliITSPlaneEffSSD &s){
87 // Assignment operator
89 // AliITSPlaneEffSSD &s The original class for which
90 // this class is a copy of
95 if(this==&s) return *this;
99 //______________________________________________________________________
100 void AliITSPlaneEffSSD::Copy(TObject &obj) const {
101 // protected method. copy this to obj
102 AliITSPlaneEff::Copy(obj);
103 for(Int_t i=0;i<kNModule;i++) {
104 ((AliITSPlaneEffSSD& ) obj).fFound[i] = fFound[i];
105 ((AliITSPlaneEffSSD& ) obj).fTried[i] = fTried[i];
108 //______________________________________________________________________
109 AliITSPlaneEff& AliITSPlaneEffSSD::operator=(const
111 // Assignment operator
113 // AliITSPlaneEffSSD &s The original class for which
114 // this class is a copy of
119 if(&s == this) return *this;
120 AliError("operator=: Not allowed to make a =, use default creater instead");
123 //_______________________________________________________________________
124 Int_t AliITSPlaneEffSSD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
127 // Estimate the number of tracks still to be collected to attain a
128 // given efficiency eff, with relative error RelErr
130 // eff -> Expected efficiency (e.g. those from actual estimate)
131 // RelErr -> tollerance [0,1]
132 // im -> module number [0,1697]
134 // Return: the estimated n. of tracks
137 {AliError("GetMissingTracksForGivenEff: you asked for a non existing module");
139 else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)];
141 //_________________________________________________________________________
142 Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const {
143 // Compute the efficiency for a basic block,
145 // im -> module number [0,1697]
147 {AliError("PlaneEff(UInt_t): you asked for a non existing module"); return -1.;}
148 Int_t nf=fFound[GetKey(im)];
149 Int_t nt=fTried[GetKey(im)];
150 return AliITSPlaneEff::PlaneEff(nf,nt);
152 //_________________________________________________________________________
153 Double_t AliITSPlaneEffSSD::ErrPlaneEff(const UInt_t im) const {
154 // Compute the statistical error on efficiency for a basic block,
155 // using binomial statistics
157 // im -> module number [0,1697]
159 {AliError("ErrPlaneEff(UInt_t): you asked for a non existing module"); return -1.;}
160 Int_t nf=fFound[GetKey(im)];
161 Int_t nt=fTried[GetKey(im)];
162 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
164 //_________________________________________________________________________
165 Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) {
166 // Update efficiency for a basic block
168 {AliError("UpDatePlaneEff: you asked for a non existing module"); return kFALSE;}
169 fTried[GetKey(im)]++;
170 if(Kfound) fFound[GetKey(im)]++;
173 //_________________________________________________________________________
174 UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const {
175 // get key given a basic block
177 {AliError("GetKey: you asked for a non existing block"); return 99999;}
180 //__________________________________________________________________________
181 UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const {
184 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
187 //__________________________________________________________________________
188 Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const {
189 // returns plane efficieny after adding the fraction of sensor which is bad
191 {AliError("LivePlaneEff: you asked for a non existing key");
193 Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
194 leff=PlaneEff(key)+GetFracBad(key);
195 return leff>1?1:leff;
197 //____________________________________________________________________________
198 Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const {
199 // returns error on live plane efficiency
201 {AliError("ErrLivePlaneEff: you asked for a non existing key");
203 Int_t nf=fFound[key];
204 Double_t triedInLive=GetFracLive(key)*fTried[key];
205 Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
206 return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
208 //_____________________________________________________________________________
209 Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const {
210 // returns the fraction of the sensor which is OK
212 {AliError("GetFracLive: you asked for a non existing key");
214 // Compute the fraction of bad (dead+noisy) detector
216 GetBadInModule(key,bad);
218 live/=(kNChip*kNSide*kNStrip);
221 //_____________________________________________________________________________
222 void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const {
223 // returns the number of dead and noisy pixels
226 {AliError("GetBadInModule: you asked for a non existing key");
228 // Compute the number of bad (dead+noisy) pixel in a module
231 {AliError("GetBadInModule: CDB not inizialized: call InitCDB first");
233 AliCDBManager* man = AliCDBManager::Instance();
234 // retrieve map of dead Pixel
235 AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber);
238 ssdEntry = (TObjArray*)cdbSSD->GetObject();
240 {AliError("GetBadInChip: SSDEntry not found in CDB");
243 AliError("GetBadInChip: did not find Calib/BadChannelsSSD");
247 UInt_t mod=GetModFromKey(key);
249 AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod);
250 // count the number of bad channels on the p side
251 nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize();
252 // add the number of bad channels on the s side
253 nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize();
256 //_____________________________________________________________________________
257 Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const {
258 // returns 1-fractional live
260 {AliError("GetFracBad: you asked for a non existing key");
262 return 1.-GetFracLive(key);
264 //_____________________________________________________________________________
265 Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const {
268 {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first");
270 // to be written properly: now only for debugging
271 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
272 md->SetObjectClassName("AliITSPlaneEff");
273 md->SetResponsible("Giuseppe Eugenio Bruno");
274 md->SetBeamPeriod(0);
275 md->SetAliRootVersion("head 02/01/08"); //root version
276 AliCDBId id("ITS/PlaneEff/PlaneEffSSD",0,AliCDBRunRange::Infinity());
277 AliITSPlaneEffSSD eff;
279 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
283 //_____________________________________________________________________________
284 Bool_t AliITSPlaneEffSSD::ReadFromCDB() {
287 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first");
289 //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
290 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
292 AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
293 AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
294 if(this==eff) return kFALSE;
298 //_____________________________________________________________________________
299 UInt_t AliITSPlaneEffSSD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet,
300 Float_t, Float_t) const {
301 // method to locate a basic block from Detector Local coordinate (to be used in tracking)
304 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
306 if(ilay==4 && (idet<0 || idet>747))
307 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
309 if(ilay==5 && (idet<0 || idet>949))
310 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
314 if(ilay==1) mod+=748;