]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSPD.cxx
Completely reengineered version of CMake build system (Johny)
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSPD.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// 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)
20// Author: G.E. Bruno
21// giuseppe.bruno@ba.infn.it
22//
23///////////////////////////////////////////////////////////////////////////
24
25/* $Id$ */
26
6344adcc 27#include <TMath.h>
5fbd4fd6 28#include <TH1F.h>
29#include <TFile.h>
30#include <TTree.h>
31#include <TROOT.h>
4a66240a 32#include "AliITSPlaneEffSPD.h"
33#include "AliLog.h"
34#include "AliCDBStorage.h"
35#include "AliCDBEntry.h"
36#include "AliCDBManager.h"
37//#include "AliCDBRunRange.h"
41d18cd2 38#include "AliITSsegmentationSPD.h"
4a66240a 39#include "AliITSCalibrationSPD.h"
40
41ClassImp(AliITSPlaneEffSPD)
42//______________________________________________________________________
43AliITSPlaneEffSPD::AliITSPlaneEffSPD():
5fbd4fd6 44 AliITSPlaneEff(),
5fbd4fd6 45 fHisResX(0),
46 fHisResZ(0),
47 fHisResXZ(0),
48 fHisClusterSize(0),
49 fHisResXclu(0),
1cc5cedc 50 fHisResZclu(0),
51 fHisResXchip(0),
52 fHisResZchip(0),
879cdb02 53 fProfResXvsPhi(0),
54 fProfResZvsDip(0),
55 fProfResXvsPhiclu(0),
56 fProfResZvsDipclu(0),
1cc5cedc 57 fHisTrackErrX(0),
58 fHisTrackErrZ(0),
59 fHisClusErrX(0),
60 fHisClusErrZ(0){
4a66240a 61 for (UInt_t i=0; i<kNModule*kNChip; i++){
62 fFound[i]=0;
63 fTried[i]=0;
64 }
65 // default constructor
66 AliDebug(1,Form("Calling default constructor"));
67}
68//______________________________________________________________________
69AliITSPlaneEffSPD::~AliITSPlaneEffSPD(){
70 // destructor
71 // Inputs:
72 // none.
73 // Outputs:
74 // none.
75 // Return:
76 // none.
5fbd4fd6 77 DeleteHistos();
4a66240a 78}
79//______________________________________________________________________
5fbd4fd6 80AliITSPlaneEffSPD::AliITSPlaneEffSPD(const AliITSPlaneEffSPD &s) : AliITSPlaneEff(s),
4a66240a 81//fHis(s.fHis),
5fbd4fd6 82fHisResX(0),
83fHisResZ(0),
84fHisResXZ(0),
85fHisClusterSize(0),
86fHisResXclu(0),
1cc5cedc 87fHisResZclu(0),
88fHisResXchip(0),
89fHisResZchip(0),
879cdb02 90fProfResXvsPhi(0),
91fProfResZvsDip(0),
92fProfResXvsPhiclu(0),
93fProfResZvsDipclu(0),
1cc5cedc 94fHisTrackErrX(0),
95fHisTrackErrZ(0),
96fHisClusErrX(0),
97fHisClusErrZ(0)
4a66240a 98{
99 // Copy Constructor
100 // Inputs:
101 // AliITSPlaneEffSPD &s The original class for which
102 // this class is a copy of
103 // Outputs:
104 // none.
105 // Return:
106
5fbd4fd6 107 for (UInt_t i=0; i<kNModule*kNChip; i++){
108 fFound[i]=s.fFound[i];
109 fTried[i]=s.fTried[i];
110 }
111 if(fHis) {
112 InitHistos();
113 for(Int_t i=0; i<kNHisto; i++) {
114 s.fHisResX[i]->Copy(*fHisResX[i]);
115 s.fHisResZ[i]->Copy(*fHisResZ[i]);
116 s.fHisResXZ[i]->Copy(*fHisResXZ[i]);
117 s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]);
118 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
119 s.fHisResXclu[i][clu]->Copy(*fHisResXclu[i][clu]);
120 s.fHisResZclu[i][clu]->Copy(*fHisResZclu[i][clu]);
879cdb02 121 s.fProfResXvsPhiclu[i][clu]->Copy(*fProfResXvsPhiclu[i][clu]);
122 s.fProfResZvsDipclu[i][clu]->Copy(*fProfResZvsDipclu[i][clu]);
5fbd4fd6 123 }
1cc5cedc 124 for(Int_t chip=0; chip<kNChip; chip++) {
125 s.fHisResXchip[i][chip]->Copy(*fHisResXchip[i][chip]);
126 s.fHisResZchip[i][chip]->Copy(*fHisResZchip[i][chip]);
127 }
879cdb02 128 s.fProfResXvsPhi[i]->Copy(*fProfResXvsPhi[i]);
129 s.fProfResZvsDip[i]->Copy(*fProfResZvsDip[i]);
1cc5cedc 130 s.fHisTrackErrX[i]->Copy(*fHisTrackErrX[i]);
131 s.fHisTrackErrZ[i]->Copy(*fHisTrackErrZ[i]);
132 s.fHisClusErrX[i]->Copy(*fHisClusErrX[i]);
133 s.fHisClusErrZ[i]->Copy(*fHisClusErrZ[i]);
5fbd4fd6 134 }
135 }
4a66240a 136}
137//_________________________________________________________________________
138AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator+=(const AliITSPlaneEffSPD &add){
139 // Add-to-me operator
140 // Inputs:
141 // const AliITSPlaneEffSPD &add simulation class to be added
142 // Outputs:
143 // none.
144 // Return:
145 // none
146 for (UInt_t i=0; i<kNModule*kNChip; i++){
147 fFound[i] += add.fFound[i];
148 fTried[i] += add.fTried[i];
149 }
5fbd4fd6 150 if(fHis && add.fHis) {
151 for(Int_t i=0; i<kNHisto; i++) {
152 fHisResX[i]->Add(add.fHisResX[i]);
153 fHisResZ[i]->Add(add.fHisResZ[i]);
154 fHisResXZ[i]->Add(add.fHisResXZ[i]);
155 fHisClusterSize[i]->Add(add.fHisClusterSize[i]);
156 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
157 fHisResXclu[i][clu]->Add(add.fHisResXclu[i][clu]);
158 fHisResZclu[i][clu]->Add(add.fHisResZclu[i][clu]);
879cdb02 159 fProfResXvsPhiclu[i][clu]->Add(add.fProfResXvsPhiclu[i][clu]);
160 fProfResZvsDipclu[i][clu]->Add(add.fProfResZvsDipclu[i][clu]);
5fbd4fd6 161 }
1cc5cedc 162 for(Int_t chip=0; chip<kNChip; chip++) {
163 fHisResXchip[i][chip]->Add(add.fHisResXchip[i][chip]);
164 fHisResZchip[i][chip]->Add(add.fHisResZchip[i][chip]);
165 }
879cdb02 166 fProfResXvsPhi[i]->Add(add.fProfResXvsPhi[i]);
167 fProfResZvsDip[i]->Add(add.fProfResZvsDip[i]);
1cc5cedc 168 fHisTrackErrX[i]->Add(add.fHisTrackErrX[i]);
169 fHisTrackErrZ[i]->Add(add.fHisTrackErrZ[i]);
170 fHisClusErrX[i]->Add(add.fHisClusErrX[i]);
171 fHisClusErrZ[i]->Add(add.fHisClusErrZ[i]);
5fbd4fd6 172 }
173 }
4a66240a 174 return *this;
175}
176//______________________________________________________________________
177AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator=(const
178 AliITSPlaneEffSPD &s){
179 // Assignment operator
180 // Inputs:
181 // AliITSPlaneEffSPD &s The original class for which
182 // this class is a copy of
183 // Outputs:
184 // none.
185 // Return:
186
187 if(this==&s) return *this;
188 s.Copy(*this);
4a66240a 189 return *this;
190}
191//______________________________________________________________________
192void AliITSPlaneEffSPD::Copy(TObject &obj) const {
193 // protected method. copy this to obj
194 AliITSPlaneEff::Copy(obj);
5fbd4fd6 195 AliITSPlaneEffSPD& target = (AliITSPlaneEffSPD &) obj;
4a66240a 196 for(Int_t i=0;i<kNModule*kNChip;i++) {
5fbd4fd6 197 target.fFound[i] = fFound[i];
198 target.fTried[i] = fTried[i];
199 }
200 CopyHistos(target);
201 return;
202}
203//_______________________________________________________________________
204void AliITSPlaneEffSPD::CopyHistos(AliITSPlaneEffSPD &target) const {
205 // protected method: copy histos from this to target
206 target.fHis = fHis; // this is redundant only in some cases. Leave as it is.
207 if(fHis) {
208 target.fHisResX=new TH1F*[kNHisto];
209 target.fHisResZ=new TH1F*[kNHisto];
210 target.fHisResXZ=new TH2F*[kNHisto];
211 target.fHisClusterSize=new TH2I*[kNHisto];
212 target.fHisResXclu=new TH1F**[kNHisto];
213 target.fHisResZclu=new TH1F**[kNHisto];
1cc5cedc 214 target.fHisResXchip=new TH1F**[kNHisto];
215 target.fHisResZchip=new TH1F**[kNHisto];
879cdb02 216 target.fProfResXvsPhi=new TProfile*[kNHisto];
217 target.fProfResZvsDip=new TProfile*[kNHisto];
218 target.fProfResXvsPhiclu=new TProfile**[kNHisto];
219 target.fProfResZvsDipclu=new TProfile**[kNHisto];
1cc5cedc 220 target.fHisTrackErrX=new TH1F*[kNHisto];
221 target.fHisTrackErrZ=new TH1F*[kNHisto];
222 target.fHisClusErrX=new TH1F*[kNHisto];
223 target.fHisClusErrZ=new TH1F*[kNHisto];
5fbd4fd6 224 for(Int_t i=0; i<kNHisto; i++) {
225 target.fHisResX[i] = new TH1F(*fHisResX[i]);
226 target.fHisResZ[i] = new TH1F(*fHisResZ[i]);
227 target.fHisResXZ[i] = new TH2F(*fHisResXZ[i]);
228 target.fHisClusterSize[i] = new TH2I(*fHisClusterSize[i]);
229 target.fHisResXclu[i]=new TH1F*[kNclu];
230 target.fHisResZclu[i]=new TH1F*[kNclu];
879cdb02 231 target.fProfResXvsPhiclu[i]=new TProfile*[kNclu];
232 target.fProfResZvsDipclu[i]=new TProfile*[kNclu];
5fbd4fd6 233 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
234 target.fHisResXclu[i][clu] = new TH1F(*fHisResXclu[i][clu]);
235 target.fHisResZclu[i][clu] = new TH1F(*fHisResZclu[i][clu]);
879cdb02 236 target.fProfResXvsPhiclu[i][clu] = new TProfile(*fProfResXvsPhiclu[i][clu]);
237 target.fProfResZvsDipclu[i][clu] = new TProfile(*fProfResZvsDipclu[i][clu]);
5fbd4fd6 238 }
1cc5cedc 239 target.fHisResXchip[i]=new TH1F*[kNChip];
240 target.fHisResZchip[i]=new TH1F*[kNChip];
241 for(Int_t chip=0; chip<kNChip; chip++) {
242 target.fHisResXchip[i][chip] = new TH1F(*fHisResXchip[i][chip]);
243 target.fHisResZchip[i][chip] = new TH1F(*fHisResZchip[i][chip]);
244 }
879cdb02 245 target.fProfResXvsPhi[i] = new TProfile(*fProfResXvsPhi[i]);
246 target.fProfResZvsDip[i] = new TProfile(*fProfResZvsDip[i]);
1cc5cedc 247 target.fHisTrackErrX[i] = new TH1F(*fHisTrackErrX[i]);
248 target.fHisTrackErrZ[i] = new TH1F(*fHisTrackErrZ[i]);
249 target.fHisClusErrX[i] = new TH1F(*fHisClusErrX[i]);
250 target.fHisClusErrZ[i] = new TH1F(*fHisClusErrZ[i]);
5fbd4fd6 251 }
4a66240a 252 }
5fbd4fd6 253return;
4a66240a 254}
85f5e9c2 255/* commented out by M.Masera 8/3/08
4a66240a 256//______________________________________________________________________
257AliITSPlaneEff& AliITSPlaneEffSPD::operator=(const
258 AliITSPlaneEff &s){
259 // Assignment operator
260 // Inputs:
261 // AliITSPlaneEffSPD &s The original class for which
262 // this class is a copy of
263 // Outputs:
264 // none.
265 // Return:
266
267 if(&s == this) return *this;
7167ae53 268 AliError("operator=: Not allowed to make a =, use default creater instead");
4a66240a 269 return *this;
270}
85f5e9c2 271*/
4a66240a 272//_______________________________________________________________________
273Int_t AliITSPlaneEffSPD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
274 UInt_t im, UInt_t ic) const {
275
276 // Estimate the number of tracks still to be collected to attain a
277 // given efficiency eff, with relative error RelErr
278 // Inputs:
279 // eff -> Expected efficiency (e.g. those from actual estimate)
280 // RelErr -> tollerance [0,1]
281 // im -> module number [0,249]
6344adcc 282 // ic -> chip number [0,4]
4a66240a 283 // Outputs: none
284 // Return: the estimated n. of tracks
285 //
286if (im>=kNModule || ic>=kNChip)
7167ae53 287 {AliError("GetMissingTracksForGivenEff: you asked for a non existing chip");
4a66240a 288 return -1;}
879cdb02 289else {
290 UInt_t key=GetKey(im,ic);
291 if(key<kNModule*kNChip) return GetNTracksForGivenEff(eff,RelErr)-fTried[key];
292 else return -1;
293}
4a66240a 294}
295//_________________________________________________________________________
296Double_t AliITSPlaneEffSPD::PlaneEff(const UInt_t im,const UInt_t ic) const {
297// Compute the efficiency for a basic block,
298// Inputs:
6344adcc 299// im -> module number [0,249]
300// ic -> chip number [0,4]
4a66240a 301if (im>=kNModule || ic>=kNChip)
7167ae53 302 {AliError("PlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
879cdb02 303UInt_t key=GetKey(im,ic);
304Int_t nf=-1;
305Int_t nt=-1;
306if(key<kNModule*kNChip) {
307 nf=fFound[key];
308 nt=fTried[key];
309}
4a66240a 310return AliITSPlaneEff::PlaneEff(nf,nt);
311}
312//_________________________________________________________________________
313Double_t AliITSPlaneEffSPD::ErrPlaneEff(const UInt_t im,const UInt_t ic) const {
314 // Compute the statistical error on efficiency for a basic block,
315 // using binomial statistics
316 // Inputs:
6344adcc 317 // im -> module number [0,249]
318 // ic -> chip number [0,4]
4a66240a 319if (im>=kNModule || ic>=kNChip)
7167ae53 320 {AliError("ErrPlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
879cdb02 321UInt_t key=GetKey(im,ic);
322Int_t nf=-1;
323Int_t nt=-1;
324if(key<kNModule*kNChip) {
325 nf=fFound[key];
326 nt=fTried[key];
327}
4a66240a 328return AliITSPlaneEff::ErrPlaneEff(nf,nt);
329}
330//_________________________________________________________________________
331Bool_t AliITSPlaneEffSPD::UpDatePlaneEff(const Bool_t Kfound,
332 const UInt_t im, const UInt_t ic) {
333 // Update efficiency for a basic block
334if (im>=kNModule || ic>=kNChip)
7167ae53 335 {AliError("UpDatePlaneEff: you asked for a non existing chip"); return kFALSE;}
879cdb02 336 UInt_t key=GetKey(im,ic);
337 if(key<kNModule*kNChip) {
338 fTried[key]++;
339 if(Kfound) fFound[key]++;
340 return kTRUE;
341 }
4a66240a 342}
343//_________________________________________________________________________
6344adcc 344UInt_t AliITSPlaneEffSPD::GetChipFromCol(const UInt_t col) const {
4a66240a 345 // get chip given the column
346if(col>=kNCol*kNChip)
7167ae53 347 {AliDebug(1,Form("GetChipFromCol: you asked for a non existing column %d",col)); return 10;}
4a66240a 348return col/kNCol;
349}
350//__________________________________________________________________________
351UInt_t AliITSPlaneEffSPD::GetKey(const UInt_t mod, const UInt_t chip) const {
352 // get key given a basic block
353if(mod>=kNModule || chip>=kNChip)
7167ae53 354 {AliWarning("GetKey: you asked for a non existing block"); return 99999;}
4a66240a 355return mod*kNChip+chip;
356}
357//__________________________________________________________________________
358UInt_t AliITSPlaneEffSPD::GetModFromKey(const UInt_t key) const {
359 // get mod. from key
360if(key>=kNModule*kNChip)
7167ae53 361 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
4a66240a 362return key/kNChip;
363}
364//__________________________________________________________________________
365UInt_t AliITSPlaneEffSPD::GetChipFromKey(const UInt_t key) const {
366 // retrieves chip from key
367if(key>=kNModule*kNChip)
7167ae53 368 {AliError("GetChipFromKey: you asked for a non existing key"); return 999;}
4a66240a 369return (key%(kNModule*kNChip))%kNChip;
370}
371//__________________________________________________________________________
372void AliITSPlaneEffSPD::GetModAndChipFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip) const {
373 // get module and chip from a key
374if(key>=kNModule*kNChip)
7167ae53 375 {AliError("GetModAndChipFromKey: you asked for a non existing key");
4a66240a 376 mod=9999;
377 chip=999;
378 return;}
379mod=key/kNChip;
380chip=(key%(kNModule*kNChip))%kNChip;
381return;
382}
383//____________________________________________________________________________
384Double_t AliITSPlaneEffSPD::LivePlaneEff(UInt_t key) const {
6344adcc 385 // returns plane efficieny after adding the fraction of sensor which is bad
4a66240a 386if(key>=kNModule*kNChip)
7167ae53 387 {AliError("LivePlaneEff: you asked for a non existing key");
4a66240a 388 return -1.;}
6344adcc 389Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
390leff=PlaneEff(key)+GetFracBad(key);
391return leff>1?1:leff;
4a66240a 392}
393//____________________________________________________________________________
394Double_t AliITSPlaneEffSPD::ErrLivePlaneEff(UInt_t key) const {
395 // returns error on live plane efficiency
396if(key>=kNModule*kNChip)
7167ae53 397 {AliError("ErrLivePlaneEff: you asked for a non existing key");
4a66240a 398 return -1.;}
6344adcc 399Int_t nf=fFound[key];
400Double_t triedInLive=GetFracLive(key)*fTried[key];
401Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
402return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
4a66240a 403}
404//_____________________________________________________________________________
405Double_t AliITSPlaneEffSPD::GetFracLive(const UInt_t key) const {
406 // returns the fraction of the sensor which is OK
407if(key>=kNModule*kNChip)
7167ae53 408 {AliError("GetFracLive: you asked for a non existing key");
4a66240a 409 return -1.;}
410 // Compute the fraction of bad (dead+noisy) detector
411UInt_t dead=0,noisy=0;
412GetDeadAndNoisyInChip(key,dead,noisy);
413Double_t live=dead+noisy;
414live/=(kNRow*kNCol);
415return 1.-live;
416}
417//_____________________________________________________________________________
418void AliITSPlaneEffSPD::GetDeadAndNoisyInChip(const UInt_t key,
419 UInt_t& nrDeadInChip, UInt_t& nrNoisyInChip) const {
420 // returns the number of dead and noisy pixels
421nrDeadInChip=0;
422nrNoisyInChip=0;
423if(key>=kNModule*kNChip)
7167ae53 424 {AliError("GetDeadAndNoisyInChip: you asked for a non existing key");
4a66240a 425 return;}
426 // Compute the number of bad (dead+noisy) pixel in a chip
427//
428if(!fInitCDBCalled)
7167ae53 429 {AliError("GetDeadAndNoisyInChip: CDB not inizialized: call InitCDB first");
4a66240a 430 return;};
431AliCDBManager* man = AliCDBManager::Instance();
432// retrieve map of dead Pixel
433AliCDBEntry *cdbSPDDead = man->Get("ITS/Calib/SPDDead", fRunNumber);
434TObjArray* spdDead;
435if(cdbSPDDead) {
436 spdDead = (TObjArray*)cdbSPDDead->GetObject();
437 if(!spdDead)
7167ae53 438 {AliError("GetDeadAndNoisyInChip: SPDDead not found in CDB");
4a66240a 439 return;}
440} else {
7167ae53 441 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDDead.");
4a66240a 442 return;
443}
444// retrieve map of noisy Pixel
445AliCDBEntry *cdbSPDNoisy = man->Get("ITS/Calib/SPDNoisy", fRunNumber);
446TObjArray* spdNoisy;
447if(cdbSPDNoisy) {
448 spdNoisy = (TObjArray*)cdbSPDNoisy->GetObject();
449 if(!spdNoisy)
7167ae53 450 {AliError("GetDeadAndNoisyInChip: SPDNoisy not found in CDB");
4a66240a 451 return;}
452} else {
7167ae53 453 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDNoisy.");
4a66240a 454 return;
455}
456//
457UInt_t mod=GetModFromKey(key);
458UInt_t chip=GetChipFromKey(key);
459// count number of dead
460AliITSCalibrationSPD* calibSPD=(AliITSCalibrationSPD*) spdDead->At(mod);
461UInt_t nrDead = calibSPD->GetNrBad();
462for (UInt_t index=0; index<nrDead; index++) {
6344adcc 463 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
4a66240a 464}
465calibSPD=(AliITSCalibrationSPD*) spdNoisy->At(mod);
466UInt_t nrNoisy = calibSPD->GetNrBad();
467for (UInt_t index=0; index<nrNoisy; index++) {
6344adcc 468 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrNoisyInChip++;
4a66240a 469}
470return;
471}
472//_____________________________________________________________________________
473Double_t AliITSPlaneEffSPD::GetFracBad(const UInt_t key) const {
474 // returns 1-fractional live
475if(key>=kNModule*kNChip)
7167ae53 476 {AliError("GetFracBad: you asked for a non existing key");
4a66240a 477 return -1.;}
478return 1.-GetFracLive(key);
479}
480//_____________________________________________________________________________
481Bool_t AliITSPlaneEffSPD::WriteIntoCDB() const {
482// write onto CDB
483if(!fInitCDBCalled)
7167ae53 484 {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first");
4a66240a 485 return kFALSE;}
486// to be written properly: now only for debugging
487 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
1cc5cedc 488 //md->SetObjectClassName("AliITSPlaneEff");
4a66240a 489 md->SetResponsible("Giuseppe Eugenio Bruno");
490 md->SetBeamPeriod(0);
491 md->SetAliRootVersion("head 19/11/07"); //root version
492 AliCDBId id("ITS/PlaneEff/PlaneEffSPD",0,AliCDBRunRange::Infinity());
493 AliITSPlaneEffSPD eff;
494 eff=*this;
495 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
496 delete md;
497 return r;
498}
499//_____________________________________________________________________________
500Bool_t AliITSPlaneEffSPD::ReadFromCDB() {
501// read from CDB
502if(!fInitCDBCalled)
7167ae53 503 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first");
4a66240a 504 return kFALSE;}
4a66240a 505AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
1cc5cedc 506if(!cdbEntry) return kFALSE;
4a66240a 507AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
508if(this==eff) return kFALSE;
5fbd4fd6 509if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff
510eff->Copy(*this); // copy everything (statistics and histos) from eff to this
4a66240a 511return kTRUE;
512}
7167ae53 513//_____________________________________________________________________________
1cc5cedc 514Bool_t AliITSPlaneEffSPD::AddFromCDB(AliCDBId *cdbId) {
515AliCDBEntry *cdbEntry=0;
516if (!cdbId) {
517 if(!fInitCDBCalled)
518 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first"); return kFALSE;}
519 cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
520} else {
521 cdbEntry = AliCDBManager::Instance()->Get(*cdbId);
522}
523if(!cdbEntry) return kFALSE;
524AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
525*this+=*eff;
526return kTRUE;
527}
528//_____________________________________________________________________________
7167ae53 529UInt_t AliITSPlaneEffSPD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet,
530 Float_t, Float_t locz) const {
531// method to locate a basic block from Detector Local coordinate (to be used in tracking)
532UInt_t key=999999;
533if(ilay<0 || ilay>1)
534 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
535 return key;}
536if(ilay==0 && (idet<0 || idet>79))
537 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
538 return key;}
539if(ilay==1 && (idet<0 || idet>159))
540 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
541 return key;}
542
543UInt_t mod=idet;
544if(ilay==1) mod+=80;
545key=GetKey(mod,GetChipFromCol(GetColFromLocZ(locz)));
546return key;
547}
548//_____________________________________________________________________________
549UInt_t AliITSPlaneEffSPD::GetColFromLocZ(Float_t zloc) const {
41d18cd2 550// method to retrieve column number from the local z coordinate
551 UInt_t col=0;
552 AliITSsegmentationSPD spd;
553 Int_t ix,iz;
554 if(spd.LocalToDet(0,zloc,ix,iz)) col+=iz;
555 else {
275a301c 556 AliDebug(1,Form("cannot compute column number from local z=%f",zloc));
41d18cd2 557 col=99999;}
558 return col;
559/*
7167ae53 560const Float_t kconv = 1.0E-04; // converts microns to cm.
561Float_t bz[160];
562for(Int_t i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
563bz[ 31] = bz[ 32] = 625.0; // first chip boundry
564bz[ 63] = bz[ 64] = 625.0; // first chip boundry
565bz[ 95] = bz[ 96] = 625.0; // first chip boundry
566bz[127] = bz[128] = 625.0; // first chip boundry
567//
568Int_t j=-1;
569Float_t dz=0;
570for(Int_t i=000;i<160;i++) dz+=bz[i];
571dz = -0.5*kconv*dz;
572if(zloc<dz || zloc>-1*dz) { // outside z range
573 AliDebug(1,Form("GetColFromLocZ: cannot compute column number from local z=%f",zloc));
574 return 99999;}
575for(j=0;j<160;j++){
576 dz += kconv*bz[j];
577 if(zloc<dz) break;
578} // end for j
579col+=j;
580//
581return col;
41d18cd2 582*/
7167ae53 583}
584//________________________________________________________
aa0de373 585Bool_t AliITSPlaneEffSPD::GetBlockBoundaries(const UInt_t key, Float_t& xmn,Float_t& xmx,
586 Float_t& zmn,Float_t& zmx) const {
587//
588// This method return the geometrical boundaries of the active volume of a given
589// basic block, in the detector reference system.
590// Input: unique key to locate a basic block.
591//
592// Output: Ymin, Ymax, Zmin, Zmax of a basic block (chip for SPD)
593// Return: kTRUE if computation was succesfully, kFALSE otherwise
594//
595if(key>=kNModule*kNChip)
596 {AliWarning("GetBlockBoundaries: you asked for a non existing key"); return kFALSE;}
597UInt_t chip=GetChipFromKey(key);
598zmn=GetLocZFromCol(chip*kNCol);
599zmx=GetLocZFromCol((chip+1)*kNCol);
600xmn=GetLocXFromRow(0);
601xmx=GetLocXFromRow(kNRow);
41d18cd2 602//
aa0de373 603Float_t tmp=zmn;
604if(zmx<zmn) {zmn=zmx; zmx=tmp;}
605tmp=xmn;
606if(xmx<xmn) {xmn=xmx; xmx=tmp;}
607return kTRUE;
608}
609//________________________________________________________
610Float_t AliITSPlaneEffSPD::GetLocXFromRow(const UInt_t row) const {
611//
612// This method return the local (i.e. detector reference system) lower x coordinate
613// of the row. To get the central value of a given row, you can do
614// 1/2*[LocXFromRow(row)+LocXFromRow(row+1)].
615//
616// Input: row number in the range [0,kNRow]
617// Output: lower local X coordinate of this row.
618//
619if(row>kNRow) // not >= ! allow also computation of upper limit of the last row.
620 {AliError("LocYFromRow: you asked for a non existing row"); return 9999999.;}
41d18cd2 621// Use only AliITSsegmentationSPD
622AliITSsegmentationSPD spd;
623Double_t dummy,x;
624if(row==kNRow) spd.CellBoundries((Int_t)row-1,0,dummy,x,dummy,dummy);
625else spd.CellBoundries((Int_t)row,0,x,dummy,dummy,dummy);
626return (Float_t)x;
627
aa0de373 628}
629//________________________________________________________
630Float_t AliITSPlaneEffSPD::GetLocZFromCol(const UInt_t col) const {
631//
632// This method return the local (i.e. detector reference system) lower Z coordinate
633// of the column. To get the central value of a given column, you can do
634// 1/2*[LocZFromCol(col)+LocZFromCol(col+1)].
635//
636// Input: col number in the range [0,kNChip*kNCol]
637// Output: lower local Y coordinate of this row.
638//
639if(col>kNChip*kNCol) // not >= ! allow also computation of upper limit of the last column
640 {AliError("LocZFromCol: you asked for a non existing column"); return 9999999.;}
41d18cd2 641// Use only AliITSsegmentationSPD
642AliITSsegmentationSPD spd;
643Double_t dummy,y;
644if(col==kNChip*kNCol) spd.CellBoundries(0,(Int_t)col-1,dummy,dummy,dummy,y);
645else spd.CellBoundries(0,(Int_t)col,dummy,dummy,y,dummy);
646return (Float_t)y;
647
aa0de373 648}
5fbd4fd6 649//__________________________________________________________
650void AliITSPlaneEffSPD::InitHistos() {
651 // for the moment let's create the histograms
652 // module by module
653 TString histnameResX="HistResX_mod_",aux;
654 TString histnameResZ="HistResZ_mod_";
655 TString histnameResXZ="HistResXZ_mod_";
656 TString histnameClusterType="HistClusterType_mod_";
657 TString histnameResXclu="HistResX_mod_";
658 TString histnameResZclu="HistResZ_mod_";
1cc5cedc 659 TString histnameResXchip="HistResX_mod_";
660 TString histnameResZchip="HistResZ_mod_";
879cdb02 661 TString profnameResXvsPhi="ProfResXvsPhi_mod_";
662 TString profnameResZvsDip="ProfResZvsDip_mod_";
663 TString profnameResXvsPhiclu="ProfResXvsPhi_mod_";
664 TString profnameResZvsDipclu="ProfResZvsDip_mod_";
1cc5cedc 665 TString histnameTrackErrX="HistTrackErrX_mod_";
666 TString histnameTrackErrZ="HistTrackErrZ_mod_";
667 TString histnameClusErrX="HistClusErrX_mod_";
668 TString histnameClusErrZ="HistClusErrZ_mod_";
5fbd4fd6 669//
4c555563 670
671 TH1::AddDirectory(kFALSE);
672
5fbd4fd6 673 fHisResX=new TH1F*[kNHisto];
674 fHisResZ=new TH1F*[kNHisto];
675 fHisResXZ=new TH2F*[kNHisto];
676 fHisClusterSize=new TH2I*[kNHisto];
677 fHisResXclu=new TH1F**[kNHisto];
678 fHisResZclu=new TH1F**[kNHisto];
1cc5cedc 679 fHisResXchip=new TH1F**[kNHisto];
680 fHisResZchip=new TH1F**[kNHisto];
879cdb02 681 fProfResXvsPhi=new TProfile*[kNHisto];
682 fProfResZvsDip=new TProfile*[kNHisto];
683 fProfResXvsPhiclu=new TProfile**[kNHisto];
684 fProfResZvsDipclu=new TProfile**[kNHisto];
1cc5cedc 685 fHisTrackErrX=new TH1F*[kNHisto];
686 fHisTrackErrZ=new TH1F*[kNHisto];
687 fHisClusErrX=new TH1F*[kNHisto];
688 fHisClusErrZ=new TH1F*[kNHisto];
5fbd4fd6 689
690 for (Int_t nhist=0;nhist<kNHisto;nhist++){
691 aux=histnameResX;
692 aux+=nhist;
061c42a0 693 fHisResX[nhist]=new TH1F("histname","histname",1600,-0.32,0.32); // +- 3200 micron; 1 bin=4 micron
5fbd4fd6 694 fHisResX[nhist]->SetName(aux.Data());
695 fHisResX[nhist]->SetTitle(aux.Data());
696
697 aux=histnameResZ;
698 aux+=nhist;
061c42a0 699 fHisResZ[nhist]=new TH1F("histname","histname",1200,-0.48,0.48); // +-4800 micron; 1 bin=8 micron
5fbd4fd6 700 fHisResZ[nhist]->SetName(aux.Data());
701 fHisResZ[nhist]->SetTitle(aux.Data());
702
703 aux=histnameResXZ;
704 aux+=nhist;
061c42a0 705 fHisResXZ[nhist]=new TH2F("histname","histname",80,-0.16,0.16,80,-0.32,0.32); // binning:
1cc5cedc 706 fHisResXZ[nhist]->SetName(aux.Data()); // 40 micron in x;
707 fHisResXZ[nhist]->SetTitle(aux.Data()); // 80 micron in z;
5fbd4fd6 708
709 aux=histnameClusterType;
710 aux+=nhist;
711 fHisClusterSize[nhist]=new TH2I("histname","histname",10,0.5,10.5,10,0.5,10.5);
712 fHisClusterSize[nhist]->SetName(aux.Data());
713 fHisClusterSize[nhist]->SetTitle(aux.Data());
714
715 fHisResXclu[nhist]=new TH1F*[kNclu];
716 fHisResZclu[nhist]=new TH1F*[kNclu];
717 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
718 aux=histnameResXclu;
719 aux+=nhist;
720 aux+="_clu_";
721 aux+=clu+1; // clu=0 --> cluster size 1
061c42a0 722 fHisResXclu[nhist][clu]=new TH1F("histname","histname",1600,-0.32,0.32); // +- 3200 micron; 1 bin=4 micron
5fbd4fd6 723 fHisResXclu[nhist][clu]->SetName(aux.Data());
724 fHisResXclu[nhist][clu]->SetTitle(aux.Data());
725
726 aux=histnameResZclu;
727 aux+=nhist;
728 aux+="_clu_";
729 aux+=clu+1; // clu=0 --> cluster size 1
061c42a0 730 fHisResZclu[nhist][clu]=new TH1F("histname","histname",1200,-0.48,0.48); // +-4800 micron; 1 bin=8 micron
5fbd4fd6 731 fHisResZclu[nhist][clu]->SetName(aux.Data());
732 fHisResZclu[nhist][clu]->SetTitle(aux.Data());
733 }
734
1cc5cedc 735 fHisResXchip[nhist]=new TH1F*[kNChip];
736 fHisResZchip[nhist]=new TH1F*[kNChip];
737 for(Int_t chip=0; chip<kNChip; chip++) {
738 aux=histnameResXchip;
739 aux+=nhist;
740 aux+="_chip_";
741 aux+=chip;
061c42a0 742 fHisResXchip[nhist][chip]=new TH1F("histname","histname",800,-0.32,0.32); // +- 3200 micron; 1 bin=8 micron
1cc5cedc 743 fHisResXchip[nhist][chip]->SetName(aux.Data());
744 fHisResXchip[nhist][chip]->SetTitle(aux.Data());
745
746 aux=histnameResZchip;
747 aux+=nhist;
748 aux+="_chip_";
749 aux+=chip;
061c42a0 750 fHisResZchip[nhist][chip]=new TH1F("histname","histname",300,-0.48,0.48); // +-4800 micron; 1 bin=32 micron
1cc5cedc 751 fHisResZchip[nhist][chip]->SetName(aux.Data());
752 fHisResZchip[nhist][chip]->SetTitle(aux.Data());
753 }
754
755 aux=histnameTrackErrX;
756 aux+=nhist;
061c42a0 757 fHisTrackErrX[nhist]=new TH1F("histname","histname",400,0.,0.32); // 0-3200 micron; 1 bin=8 micron
1cc5cedc 758 fHisTrackErrX[nhist]->SetName(aux.Data());
759 fHisTrackErrX[nhist]->SetTitle(aux.Data());
760
761 aux=histnameTrackErrZ;
762 aux+=nhist;
763 fHisTrackErrZ[nhist]=new TH1F("histname","histname",200,0.,0.32); // 0-3200 micron; 1 bin=16 micron
764 fHisTrackErrZ[nhist]->SetName(aux.Data());
765 fHisTrackErrZ[nhist]->SetTitle(aux.Data());
766
767 aux=histnameClusErrX;
768 aux+=nhist;
061c42a0 769 fHisClusErrX[nhist]=new TH1F("histname","histname",400,0.,0.08); // 0-800 micron; 1 bin=2 micron
1cc5cedc 770 fHisClusErrX[nhist]->SetName(aux.Data());
771 fHisClusErrX[nhist]->SetTitle(aux.Data());
772
773 aux=histnameClusErrZ;
774 aux+=nhist;
061c42a0 775 fHisClusErrZ[nhist]=new TH1F("histname","histname",400,0.,0.32); // 0-3200 micron; 1 bin=8 micron
1cc5cedc 776 fHisClusErrZ[nhist]->SetName(aux.Data());
777 fHisClusErrZ[nhist]->SetTitle(aux.Data());
778
879cdb02 779 aux=profnameResXvsPhi;
780 aux+=nhist;
781 fProfResXvsPhi[nhist]=new TProfile("histname","histname",40,-40.,40.0); // binning: range: -40°- 40°
782 fProfResXvsPhi[nhist]->SetName(aux.Data()); // bin width: 2°
783 fProfResXvsPhi[nhist]->SetTitle(aux.Data());
784
785 aux=profnameResZvsDip;
786 aux+=nhist;
787 fProfResZvsDip[nhist]=new TProfile("histname","histname",48,-72.,72.0); // binning: range: -70°-4°
788 fProfResZvsDip[nhist]->SetName(aux.Data()); // bin width: 3°
789 fProfResZvsDip[nhist]->SetTitle(aux.Data());
790
791 fProfResXvsPhiclu[nhist]=new TProfile*[kNclu];
792 fProfResZvsDipclu[nhist]=new TProfile*[kNclu];
793 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
794 aux=profnameResXvsPhiclu;
795 aux+=nhist;
796 aux+="_clu_";
797 aux+=clu+1; // clu=0 --> cluster size 1
798 fProfResXvsPhiclu[nhist][clu]=new TProfile("histname","histname",40,-40.,40.0); // binning: range: -40°- 40
799 fProfResXvsPhiclu[nhist][clu]->SetName(aux.Data()); // bin width: 2°
800 fProfResXvsPhiclu[nhist][clu]->SetTitle(aux.Data());
801
802 aux=profnameResZvsDipclu;
803 aux+=nhist;
804 aux+="_clu_";
805 aux+=clu+1; // clu=0 --> cluster size 1
806 fProfResZvsDipclu[nhist][clu]= new TProfile("histname","histname",48,-72.,72.0); // binning: range: -70°-7°
807 fProfResZvsDipclu[nhist][clu]->SetName(aux.Data()); // bin width: 3°
808 fProfResZvsDipclu[nhist][clu]->SetTitle(aux.Data());
809 }
810
811 } // end loop on module
4c555563 812
813 TH1::AddDirectory(kTRUE);
814
5fbd4fd6 815return;
816}
817//__________________________________________________________
818void AliITSPlaneEffSPD::DeleteHistos() {
819 if(fHisResX) {
820 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
3ebe30ad 821 delete [] fHisResX; fHisResX=0;
5fbd4fd6 822 }
823 if(fHisResZ) {
824 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
3ebe30ad 825 delete [] fHisResZ; fHisResZ=0;
5fbd4fd6 826 }
827 if(fHisResXZ) {
828 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
3ebe30ad 829 delete [] fHisResXZ; fHisResXZ=0;
5fbd4fd6 830 }
831 if(fHisClusterSize) {
832 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
3ebe30ad 833 delete [] fHisClusterSize; fHisClusterSize=0;
5fbd4fd6 834 }
835 if(fHisResXclu) {
836 for (Int_t i=0; i<kNHisto; i++ ) {
837 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResXclu[i][clu]) delete fHisResXclu[i][clu];
838 delete [] fHisResXclu[i];
839 }
840 delete [] fHisResXclu;
841 fHisResXclu = 0;
842 }
843 if(fHisResZclu) {
844 for (Int_t i=0; i<kNHisto; i++ ) {
845 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResZclu[i][clu]) delete fHisResZclu[i][clu];
846 delete [] fHisResZclu[i];
847 }
848 delete [] fHisResZclu;
849 fHisResZclu = 0;
850 }
1cc5cedc 851 if(fHisResXchip) {
852 for (Int_t i=0; i<kNHisto; i++ ) {
853 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResXchip[i][chip]) delete fHisResXchip[i][chip];
854 delete [] fHisResXchip[i];
855 }
856 delete [] fHisResXchip;
857 fHisResXchip = 0;
858 }
859 if(fHisResZchip) {
860 for (Int_t i=0; i<kNHisto; i++ ) {
861 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResZchip[i][chip]) delete fHisResZchip[i][chip];
862 delete [] fHisResZchip[i];
863 }
864 delete [] fHisResZchip;
865 fHisResZchip = 0;
866 }
867 if(fHisTrackErrX) {
868 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrX[i];
869 delete [] fHisTrackErrX; fHisTrackErrX=0;
870 }
871 if(fHisTrackErrZ) {
872 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrZ[i];
873 delete [] fHisTrackErrZ; fHisTrackErrZ=0;
874 }
875 if(fHisClusErrX) {
876 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrX[i];
877 delete [] fHisClusErrX; fHisClusErrX=0;
878 }
879 if(fHisClusErrZ) {
880 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrZ[i];
881 delete [] fHisClusErrZ; fHisClusErrZ=0;
882 }
879cdb02 883 if(fProfResXvsPhi) {
884 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResXvsPhi[i];
885 delete [] fProfResXvsPhi; fProfResXvsPhi=0;
886 }
887 if(fProfResZvsDip) {
888 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResZvsDip[i];
889 delete [] fProfResZvsDip; fProfResZvsDip=0;
890 }
891 if(fProfResXvsPhiclu) {
892 for (Int_t i=0; i<kNHisto; i++ ) {
893 for (Int_t clu=0; clu<kNclu; clu++) if (fProfResXvsPhiclu[i][clu]) delete fProfResXvsPhiclu[i][clu];
894 delete [] fProfResXvsPhiclu[i];
895 }
896 delete [] fProfResXvsPhiclu;
897 fProfResXvsPhiclu = 0;
898 }
899 if(fProfResZvsDipclu) {
900 for (Int_t i=0; i<kNHisto; i++ ) {
901 for (Int_t clu=0; clu<kNclu; clu++) if (fProfResZvsDipclu[i][clu]) delete fProfResZvsDipclu[i][clu];
902 delete [] fProfResZvsDipclu[i];
903 }
904 delete [] fProfResZvsDipclu;
905 fProfResZvsDipclu = 0;
906 }
5fbd4fd6 907
908return;
909}
910//__________________________________________________________
911Bool_t AliITSPlaneEffSPD::FillHistos(UInt_t key, Bool_t found,
879cdb02 912 Float_t *tr, Float_t *clu, Int_t *csize, Float_t *angtrkmod) {
5fbd4fd6 913// this method fill the histograms
914// input: - key: unique key of the basic block
915// - found: Boolean to asses whether a cluster has been associated to the track or not
1cc5cedc 916// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
917// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
918// - clu[0],clu[1] local X and Z coordinates of the cluster associated to the track, respectively
919// - clu[2],clu[3] error on local X and Z coordinates of the cluster associated to the track, respectively
920// - csize[0][1] cluster size in X and Z, respectively
879cdb02 921// - angtrkmod[0],angtrkmod[1]
5fbd4fd6 922// output: kTRUE if filling was succesfull kFALSE otherwise
923// side effects: updating of the histograms.
924//
925 if (!fHis) {
926 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
927 return kFALSE;
928 }
929 if(key>=kNModule*kNChip)
930 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
931 Int_t id=GetModFromKey(key);
1cc5cedc 932 Int_t chip=GetChipFromKey(key);
5fbd4fd6 933 if(id>=kNHisto)
934 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
935 if(found) {
1cc5cedc 936 Float_t resx=tr[0]-clu[0];
937 Float_t resz=tr[1]-clu[1];
5fbd4fd6 938 fHisResX[id]->Fill(resx);
939 fHisResZ[id]->Fill(resz);
940 fHisResXZ[id]->Fill(resx,resz);
1cc5cedc 941 fHisClusterSize[id]->Fill((Double_t)csize[0],(Double_t)csize[1]);
942 if(csize[0]>0 && csize[0]<=kNclu) fHisResXclu[id][csize[0]-1]->Fill(resx);
943 if(csize[1]>0 && csize[1]<=kNclu) fHisResZclu[id][csize[1]-1]->Fill(resz);
944 fHisResXchip[id][chip]->Fill(resx);
945 fHisResZchip[id][chip]->Fill(resz);
879cdb02 946 fProfResXvsPhi[id]->Fill(angtrkmod[0],resx);
947 fProfResZvsDip[id]->Fill(angtrkmod[1],resz);
948 if(csize[0]>0 && csize[0]<=kNclu) fProfResXvsPhiclu[id][csize[0]-1]->Fill(angtrkmod[0],resx);
949 if(csize[1]>0 && csize[1]<=kNclu) fProfResZvsDipclu[id][csize[1]-1]->Fill(angtrkmod[1],resz);
5fbd4fd6 950 }
1cc5cedc 951 fHisTrackErrX[id]->Fill(tr[2]);
952 fHisTrackErrZ[id]->Fill(tr[3]);
953 fHisClusErrX[id]->Fill(clu[2]);
954 fHisClusErrZ[id]->Fill(clu[3]);
5fbd4fd6 955 return kTRUE;
956}
957//__________________________________________________________
958Bool_t AliITSPlaneEffSPD::WriteHistosToFile(TString filename, Option_t* option) {
959 //
960 // Saves the histograms into a tree and saves the trees into a file
961 //
962 if (!fHis) return kFALSE;
5af4a2d0 963 if (filename.IsNull() || filename.IsWhitespace()) {
5fbd4fd6 964 AliWarning("WriteHistosToFile: null output filename!");
965 return kFALSE;
966 }
967 char branchname[30];
968 TFile *hFile=new TFile(filename.Data(),option,
969 "The File containing the TREEs with ITS PlaneEff Histos");
970 TTree *SPDTree=new TTree("SPDTree","Tree whith Residuals and Cluster Type distributions for SPD");
971 TH1F *histZ,*histX;
972 TH2F *histXZ;
973 TH2I *histClusterType;
974 TH1F *histXclu[kNclu];
975 TH1F *histZclu[kNclu];
1cc5cedc 976 TH1F *histXchip[kNChip];
977 TH1F *histZchip[kNChip];
978 TH1F *histTrErrZ,*histTrErrX;
979 TH1F *histClErrZ,*histClErrX;
879cdb02 980 TProfile *profXvsPhi,*profZvsDip;
981 TProfile *profXvsPhiclu[kNclu],*profZvsDipclu[kNclu];
5fbd4fd6 982
983 histZ=new TH1F();
984 histX=new TH1F();
985 histXZ=new TH2F();
986 histClusterType=new TH2I();
987 for(Int_t clu=0;clu<kNclu;clu++) {
988 histXclu[clu]=new TH1F();
989 histZclu[clu]=new TH1F();
990 }
1cc5cedc 991 for(Int_t chip=0;chip<kNChip;chip++) {
992 histXchip[chip]=new TH1F();
993 histZchip[chip]=new TH1F();
994 }
995 histTrErrX=new TH1F();
996 histTrErrZ=new TH1F();
997 histClErrX=new TH1F();
998 histClErrZ=new TH1F();
879cdb02 999 profXvsPhi=new TProfile();
1000 profZvsDip=new TProfile();
1001 for(Int_t clu=0;clu<kNclu;clu++) {
1002 profXvsPhiclu[clu]=new TProfile();
1003 profZvsDipclu[clu]=new TProfile();
1004 }
1005
5fbd4fd6 1006
1007 SPDTree->Branch("histX","TH1F",&histX,128000,0);
1008 SPDTree->Branch("histZ","TH1F",&histZ,128000,0);
1009 SPDTree->Branch("histXZ","TH2F",&histXZ,128000,0);
1010 SPDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
1011 for(Int_t clu=0;clu<kNclu;clu++) {
1012 sprintf(branchname,"histXclu_%d",clu+1);
1013 SPDTree->Branch(branchname,"TH1F",&histXclu[clu],128000,0);
1014 sprintf(branchname,"histZclu_%d",clu+1);
1015 SPDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0);
1016 }
1cc5cedc 1017 for(Int_t chip=0;chip<kNChip;chip++) {
1018 sprintf(branchname,"histXchip_%d",chip);
1019 SPDTree->Branch(branchname,"TH1F",&histXchip[chip],128000,0);
1020 sprintf(branchname,"histZchip_%d",chip);
1021 SPDTree->Branch(branchname,"TH1F",&histZchip[chip],128000,0);
1022 }
1023 SPDTree->Branch("histTrErrX","TH1F",&histTrErrX,128000,0);
1024 SPDTree->Branch("histTrErrZ","TH1F",&histTrErrZ,128000,0);
1025 SPDTree->Branch("histClErrX","TH1F",&histClErrX,128000,0);
1026 SPDTree->Branch("histClErrZ","TH1F",&histClErrZ,128000,0);
879cdb02 1027 SPDTree->Branch("profXvsPhi","TProfile",&profXvsPhi,128000,0);
1028 SPDTree->Branch("profZvsDip","TProfile",&profZvsDip,128000,0);
1029 for(Int_t clu=0;clu<kNclu;clu++) {
1030 sprintf(branchname,"profXvsPhiclu_%d",clu+1);
1031 SPDTree->Branch(branchname,"TProfile",&profXvsPhiclu[clu],128000,0);
1032 sprintf(branchname,"profZvsDipclu_%d",clu+1);
1033 SPDTree->Branch(branchname,"TProfile",&profZvsDipclu[clu],128000,0);
1034 }
5fbd4fd6 1035
1036 for(Int_t j=0;j<kNHisto;j++){
1037 histX=fHisResX[j];
1038 histZ=fHisResZ[j];
1039 histXZ=fHisResXZ[j];
1040 histClusterType=fHisClusterSize[j];
1041 for(Int_t clu=0;clu<kNclu;clu++) {
1042 histXclu[clu]=fHisResXclu[j][clu];
1043 histZclu[clu]=fHisResZclu[j][clu];
1044 }
1cc5cedc 1045 for(Int_t chip=0;chip<kNChip;chip++) {
1046 histXchip[chip]=fHisResXchip[j][chip];
1047 histZchip[chip]=fHisResZchip[j][chip];
1048 }
1049 histTrErrX=fHisTrackErrX[j];
1050 histTrErrZ=fHisTrackErrZ[j];
1051 histClErrX=fHisClusErrX[j];
1052 histClErrZ=fHisClusErrZ[j];
879cdb02 1053 profXvsPhi=fProfResXvsPhi[j];
1054 profZvsDip=fProfResZvsDip[j];
1055 for(Int_t clu=0;clu<kNclu;clu++) {
1056 profXvsPhiclu[clu]=fProfResXvsPhiclu[j][clu];
1057 profZvsDipclu[clu]=fProfResZvsDipclu[j][clu];
1058 }
1059
5fbd4fd6 1060 SPDTree->Fill();
1061 }
1062 hFile->Write();
1063 hFile->Close();
1064return kTRUE;
1065}
1066//__________________________________________________________
1067Bool_t AliITSPlaneEffSPD::ReadHistosFromFile(TString filename) {
1068 //
1069 // Read histograms from an already existing file
1070 //
1071 if (!fHis) return kFALSE;
5af4a2d0 1072 if (filename.IsNull() || filename.IsWhitespace()) {
5fbd4fd6 1073 AliWarning("ReadHistosFromFile: incorrect output filename!");
1074 return kFALSE;
1075 }
1076 char branchname[30];
1077
1078 TH1F *h = 0;
1079 TH2F *h2 = 0;
1080 TH2I *h2i= 0;
879cdb02 1081 TProfile *p = 0;
5fbd4fd6 1082
1083 TFile *file=TFile::Open(filename.Data(),"READONLY");
1084
1085 if (!file || file->IsZombie()) {
1086 AliWarning(Form("Can't open %s !",filename.Data()));
1087 delete file;
1088 return kFALSE;
1089 }
1090 TTree *tree = (TTree*) file->Get("SPDTree");
1091
1092 TBranch *histX = (TBranch*) tree->GetBranch("histX");
1093 TBranch *histZ = (TBranch*) tree->GetBranch("histZ");
1094 TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ");
1095 TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType");
1096
1097 TBranch *histXclu[kNclu], *histZclu[kNclu];
1098 for(Int_t clu=0; clu<kNclu; clu++) {
1099 sprintf(branchname,"histXclu_%d",clu+1);
1100 histXclu[clu]= (TBranch*) tree->GetBranch(branchname);
1101 sprintf(branchname,"histZclu_%d",clu+1);
1102 histZclu[clu]= (TBranch*) tree->GetBranch(branchname);
1103 }
1104
1cc5cedc 1105 TBranch *histXchip[kNChip], *histZchip[kNChip];
1106 for(Int_t chip=0; chip<kNChip; chip++) {
1107 sprintf(branchname,"histXchip_%d",chip);
1108 histXchip[chip]= (TBranch*) tree->GetBranch(branchname);
1109 sprintf(branchname,"histZchip_%d",chip);
1110 histZchip[chip]= (TBranch*) tree->GetBranch(branchname);
1111 }
1112
1113 TBranch *histTrErrX = (TBranch*) tree->GetBranch("histTrErrX");
1114 TBranch *histTrErrZ = (TBranch*) tree->GetBranch("histTrErrZ");
1115 TBranch *histClErrX = (TBranch*) tree->GetBranch("histClErrX");
1116 TBranch *histClErrZ = (TBranch*) tree->GetBranch("histClErrZ");
879cdb02 1117 TBranch *profXvsPhi = (TBranch*) tree->GetBranch("profXvsPhi");
1118 TBranch *profZvsDip = (TBranch*) tree->GetBranch("profZvsDip");
1119
1120 TBranch *profXvsPhiclu[kNclu], *profZvsDipclu[kNclu];
1121 for(Int_t clu=0; clu<kNclu; clu++) {
1122 sprintf(branchname,"profXvsPhiclu_%d",clu+1);
1123 profXvsPhiclu[clu]= (TBranch*) tree->GetBranch(branchname);
1124 sprintf(branchname,"profZvsDipclu_%d",clu+1);
1125 profZvsDipclu[clu]= (TBranch*) tree->GetBranch(branchname);
1126 }
1cc5cedc 1127
5fbd4fd6 1128 gROOT->cd();
1129
1130 Int_t nevent = (Int_t)histX->GetEntries();
1131 if(nevent!=kNHisto)
1132 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1133 histX->SetAddress(&h);
1134 for(Int_t j=0;j<kNHisto;j++){
1135 delete h; h=0;
1136 histX->GetEntry(j);
1137 fHisResX[j]->Add(h);
1138 }
1139
1140 nevent = (Int_t)histZ->GetEntries();
1141 if(nevent!=kNHisto)
1142 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1143 histZ->SetAddress(&h);
1144 for(Int_t j=0;j<kNHisto;j++){
1145 delete h; h=0;
1146 histZ->GetEntry(j);
1147 fHisResZ[j]->Add(h);
1148 }
1149
1150 nevent = (Int_t)histXZ->GetEntries();
1151 if(nevent!=kNHisto)
1152 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1153 histXZ->SetAddress(&h2);
1154 for(Int_t j=0;j<kNHisto;j++){
1155 delete h2; h2=0;
1156 histXZ->GetEntry(j);
1157 fHisResXZ[j]->Add(h2);
1158 }
1159
1160 nevent = (Int_t)histClusterType->GetEntries();
1161 if(nevent!=kNHisto)
1162 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1163 histClusterType->SetAddress(&h2i);
1164 for(Int_t j=0;j<kNHisto;j++){
1165 delete h2i; h2i=0;
1166 histClusterType->GetEntry(j);
1167 fHisClusterSize[j]->Add(h2i);
1168 }
1169
1170 for(Int_t clu=0; clu<kNclu; clu++) {
1171
1172 nevent = (Int_t)histXclu[clu]->GetEntries();
1173 if(nevent!=kNHisto)
1174 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1175 histXclu[clu]->SetAddress(&h);
1176 for(Int_t j=0;j<kNHisto;j++){
1177 delete h; h=0;
1178 histXclu[clu]->GetEntry(j);
1179 fHisResXclu[j][clu]->Add(h);
1180 }
1181
1182 nevent = (Int_t)histZclu[clu]->GetEntries();
1183 if(nevent!=kNHisto)
1184 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1185 histZclu[clu]->SetAddress(&h);
1186 for(Int_t j=0;j<kNHisto;j++){
1187 delete h; h=0;
1188 histZclu[clu]->GetEntry(j);
1189 fHisResZclu[j][clu]->Add(h);
1190 }
1191 }
1192
1cc5cedc 1193
1194 for(Int_t chip=0; chip<kNChip; chip++) {
1195
1196 nevent = (Int_t)histXchip[chip]->GetEntries();
1197 if(nevent!=kNHisto)
1198 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1199 histXchip[chip]->SetAddress(&h);
1200 for(Int_t j=0;j<kNHisto;j++){
1201 delete h; h=0;
1202 histXchip[chip]->GetEntry(j);
1203 fHisResXchip[j][chip]->Add(h);
1204 }
1205
1206 nevent = (Int_t)histZchip[chip]->GetEntries();
1207 if(nevent!=kNHisto)
1208 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1209 histZchip[chip]->SetAddress(&h);
1210 for(Int_t j=0;j<kNHisto;j++){
1211 delete h; h=0;
1212 histZchip[chip]->GetEntry(j);
1213 fHisResZchip[j][chip]->Add(h);
1214 }
1215 }
1216
1217 nevent = (Int_t)histTrErrX->GetEntries();
1218 if(nevent!=kNHisto)
1219 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1220 histTrErrX->SetAddress(&h);
1221 for(Int_t j=0;j<kNHisto;j++){
1222 delete h; h=0;
1223 histTrErrX->GetEntry(j);
1224 fHisTrackErrX[j]->Add(h);
1225 }
1226
1227 nevent = (Int_t)histTrErrZ->GetEntries();
1228 if(nevent!=kNHisto)
1229 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1230 histTrErrZ->SetAddress(&h);
1231 for(Int_t j=0;j<kNHisto;j++){
1232 delete h; h=0;
1233 histTrErrZ->GetEntry(j);
1234 fHisTrackErrZ[j]->Add(h);
1235 }
1236
1237 nevent = (Int_t)histClErrX->GetEntries();
1238 if(nevent!=kNHisto)
1239 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1240 histClErrX->SetAddress(&h);
1241 for(Int_t j=0;j<kNHisto;j++){
1242 delete h; h=0;
1243 histClErrX->GetEntry(j);
1244 fHisClusErrX[j]->Add(h);
1245 }
1246
1247 nevent = (Int_t)histClErrZ->GetEntries();
1248 if(nevent!=kNHisto)
1249 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1250 histClErrZ->SetAddress(&h);
1251 for(Int_t j=0;j<kNHisto;j++){
1252 delete h; h=0;
1253 histClErrZ->GetEntry(j);
1254 fHisClusErrZ[j]->Add(h);
1255 }
1256
879cdb02 1257 nevent = (Int_t)profXvsPhi->GetEntries();
1258 if(nevent!=kNHisto)
1259 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1260 profXvsPhi->SetAddress(&p);
1261 for(Int_t j=0;j<kNHisto;j++){
1262 delete p; p=0;
1263 profXvsPhi->GetEntry(j);
1264 fProfResXvsPhi[j]->Add(p);
1265 }
1266
1267 nevent = (Int_t)profZvsDip->GetEntries();
1268 if(nevent!=kNHisto)
1269 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1270 profZvsDip->SetAddress(&p);
1271 for(Int_t j=0;j<kNHisto;j++){
1272 delete p; p=0;
1273 profZvsDip->GetEntry(j);
1274 fProfResZvsDip[j]->Add(p);
1275 }
1276
1277 for(Int_t clu=0; clu<kNclu; clu++) {
1278
1279 nevent = (Int_t)profXvsPhiclu[clu]->GetEntries();
1280 if(nevent!=kNHisto)
1281 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1282 profXvsPhiclu[clu]->SetAddress(&p);
1283 for(Int_t j=0;j<kNHisto;j++){
1284 delete p; p=0;
1285 profXvsPhiclu[clu]->GetEntry(j);
1286 fProfResXvsPhiclu[j][clu]->Add(p);
1287 }
1288
1289 nevent = (Int_t)profZvsDipclu[clu]->GetEntries();
1290 if(nevent!=kNHisto)
1291 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1292 profZvsDipclu[clu]->SetAddress(&p);
1293 for(Int_t j=0;j<kNHisto;j++){
1294 delete p; p=0;
1295 profZvsDipclu[clu]->GetEntry(j);
1296 fProfResZvsDipclu[j][clu]->Add(p);
1297 }
1298 }
1299
1300
5fbd4fd6 1301 delete h; h=0;
1302 delete h2; h2=0;
1303 delete h2i; h2i=0;
879cdb02 1304 delete p; p=0;
5fbd4fd6 1305
1306 if (file) {
1307 file->Close();
1308 }
5fbd4fd6 1309return kTRUE;
1310}
061c42a0 1311