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