]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSPD.cxx
Protection against events with no or insufficient number of clusters. Plus some chang...
[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"
7167ae53 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 {
507UInt_t col=0;
508/* note: as it is now, the AliITSsegmentationSPD::Init() does not properly initialize (6 chips !!!)
509AliITSsegmentationSPD spd;
510spd.Init();
511Int_t ix,iz;
512if(spd.LocalToDet(0,zloc,ix,iz)) col+=iz;
513else {
514 AliError("GetColFromLocZ: cannot compute column number from local z");
515 col=99999;}
516return col;
517*/
518const Float_t kconv = 1.0E-04; // converts microns to cm.
519Float_t bz[160];
520for(Int_t i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
521bz[ 31] = bz[ 32] = 625.0; // first chip boundry
522bz[ 63] = bz[ 64] = 625.0; // first chip boundry
523bz[ 95] = bz[ 96] = 625.0; // first chip boundry
524bz[127] = bz[128] = 625.0; // first chip boundry
525//
526Int_t j=-1;
527Float_t dz=0;
528for(Int_t i=000;i<160;i++) dz+=bz[i];
529dz = -0.5*kconv*dz;
530if(zloc<dz || zloc>-1*dz) { // outside z range
531 AliDebug(1,Form("GetColFromLocZ: cannot compute column number from local z=%f",zloc));
532 return 99999;}
533for(j=0;j<160;j++){
534 dz += kconv*bz[j];
535 if(zloc<dz) break;
536} // end for j
537col+=j;
538//
539return col;
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);
559Float_t tmp=zmn;
560if(zmx<zmn) {zmn=zmx; zmx=tmp;}
561tmp=xmn;
562if(xmx<xmn) {xmn=xmx; xmx=tmp;}
563return kTRUE;
564}
565//________________________________________________________
566Float_t AliITSPlaneEffSPD::GetLocXFromRow(const UInt_t row) const {
567//
568// This method return the local (i.e. detector reference system) lower x coordinate
569// of the row. To get the central value of a given row, you can do
570// 1/2*[LocXFromRow(row)+LocXFromRow(row+1)].
571//
572// Input: row number in the range [0,kNRow]
573// Output: lower local X coordinate of this row.
574//
575if(row>kNRow) // not >= ! allow also computation of upper limit of the last row.
576 {AliError("LocYFromRow: you asked for a non existing row"); return 9999999.;}
577const Float_t kconv = 1.0E-04; // converts microns to cm.
578Float_t bx[256];
579for(Int_t i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
580//
581Float_t dx=0;
582for(Int_t i=000;i<256;i++) dx+=bx[i];
583dx = -0.5*kconv*dx;
584for(UInt_t j=0;j<row;j++){
585 dx += kconv*bx[j];
586} // end for j
587return dx;
588}
589//________________________________________________________
590Float_t AliITSPlaneEffSPD::GetLocZFromCol(const UInt_t col) const {
591//
592// This method return the local (i.e. detector reference system) lower Z coordinate
593// of the column. To get the central value of a given column, you can do
594// 1/2*[LocZFromCol(col)+LocZFromCol(col+1)].
595//
596// Input: col number in the range [0,kNChip*kNCol]
597// Output: lower local Y coordinate of this row.
598//
599if(col>kNChip*kNCol) // not >= ! allow also computation of upper limit of the last column
600 {AliError("LocZFromCol: you asked for a non existing column"); return 9999999.;}
601const Float_t kconv = 1.0E-04; // converts microns to cm.
602Float_t bz[160];
603for(Int_t i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
604bz[ 31] = bz[ 32] = 625.0; // first chip boundry
605bz[ 63] = bz[ 64] = 625.0; // first chip boundry
606bz[ 95] = bz[ 96] = 625.0; // first chip boundry
607bz[127] = bz[128] = 625.0; // first chip boundry
608//
609Float_t dz=0;
610for(Int_t i=000;i<160;i++) dz+=bz[i];
611dz = -0.5*kconv*dz;
612for(UInt_t j=0;j<col;j++){
613 dz += kconv*bz[j];
614} // end for j
615return dz;
616}
5fbd4fd6 617//__________________________________________________________
618void AliITSPlaneEffSPD::InitHistos() {
619 // for the moment let's create the histograms
620 // module by module
621 TString histnameResX="HistResX_mod_",aux;
622 TString histnameResZ="HistResZ_mod_";
623 TString histnameResXZ="HistResXZ_mod_";
624 TString histnameClusterType="HistClusterType_mod_";
625 TString histnameResXclu="HistResX_mod_";
626 TString histnameResZclu="HistResZ_mod_";
1cc5cedc 627 TString histnameResXchip="HistResX_mod_";
628 TString histnameResZchip="HistResZ_mod_";
629 TString histnameTrackErrX="HistTrackErrX_mod_";
630 TString histnameTrackErrZ="HistTrackErrZ_mod_";
631 TString histnameClusErrX="HistClusErrX_mod_";
632 TString histnameClusErrZ="HistClusErrZ_mod_";
5fbd4fd6 633//
634 fHisResX=new TH1F*[kNHisto];
635 fHisResZ=new TH1F*[kNHisto];
636 fHisResXZ=new TH2F*[kNHisto];
637 fHisClusterSize=new TH2I*[kNHisto];
638 fHisResXclu=new TH1F**[kNHisto];
639 fHisResZclu=new TH1F**[kNHisto];
1cc5cedc 640 fHisResXchip=new TH1F**[kNHisto];
641 fHisResZchip=new TH1F**[kNHisto];
642 fHisTrackErrX=new TH1F*[kNHisto];
643 fHisTrackErrZ=new TH1F*[kNHisto];
644 fHisClusErrX=new TH1F*[kNHisto];
645 fHisClusErrZ=new TH1F*[kNHisto];
5fbd4fd6 646
647 for (Int_t nhist=0;nhist<kNHisto;nhist++){
648 aux=histnameResX;
649 aux+=nhist;
1cc5cedc 650 fHisResX[nhist]=new TH1F("histname","histname",800,-0.16,0.16); // +- 1600 micron; 1 bin=4 micron
5fbd4fd6 651 fHisResX[nhist]->SetName(aux.Data());
652 fHisResX[nhist]->SetTitle(aux.Data());
653
654 aux=histnameResZ;
655 aux+=nhist;
656 fHisResZ[nhist]=new TH1F("histname","histname",800,-0.32,0.32); // +-3200 micron; 1 bin=8 micron
657 fHisResZ[nhist]->SetName(aux.Data());
658 fHisResZ[nhist]->SetTitle(aux.Data());
659
660 aux=histnameResXZ;
661 aux+=nhist;
1cc5cedc 662 fHisResXZ[nhist]=new TH2F("histname","histname",40,-0.08,0.08,40,-0.16,0.16); // binning:
663 fHisResXZ[nhist]->SetName(aux.Data()); // 40 micron in x;
664 fHisResXZ[nhist]->SetTitle(aux.Data()); // 80 micron in z;
5fbd4fd6 665
666 aux=histnameClusterType;
667 aux+=nhist;
668 fHisClusterSize[nhist]=new TH2I("histname","histname",10,0.5,10.5,10,0.5,10.5);
669 fHisClusterSize[nhist]->SetName(aux.Data());
670 fHisClusterSize[nhist]->SetTitle(aux.Data());
671
672 fHisResXclu[nhist]=new TH1F*[kNclu];
673 fHisResZclu[nhist]=new TH1F*[kNclu];
674 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
675 aux=histnameResXclu;
676 aux+=nhist;
677 aux+="_clu_";
678 aux+=clu+1; // clu=0 --> cluster size 1
1cc5cedc 679 fHisResXclu[nhist][clu]=new TH1F("histname","histname",800,-0.16,0.16); // +- 1600 micron; 1 bin=4 micron
5fbd4fd6 680 fHisResXclu[nhist][clu]->SetName(aux.Data());
681 fHisResXclu[nhist][clu]->SetTitle(aux.Data());
682
683 aux=histnameResZclu;
684 aux+=nhist;
685 aux+="_clu_";
686 aux+=clu+1; // clu=0 --> cluster size 1
687 fHisResZclu[nhist][clu]=new TH1F("histname","histname",800,-0.32,0.32); // +-3200 micron; 1 bin=8 micron
688 fHisResZclu[nhist][clu]->SetName(aux.Data());
689 fHisResZclu[nhist][clu]->SetTitle(aux.Data());
690 }
691
1cc5cedc 692 fHisResXchip[nhist]=new TH1F*[kNChip];
693 fHisResZchip[nhist]=new TH1F*[kNChip];
694 for(Int_t chip=0; chip<kNChip; chip++) {
695 aux=histnameResXchip;
696 aux+=nhist;
697 aux+="_chip_";
698 aux+=chip;
699 fHisResXchip[nhist][chip]=new TH1F("histname","histname",200,-0.08,0.08); // +- 800 micron; 1 bin=8 micron
700 fHisResXchip[nhist][chip]->SetName(aux.Data());
701 fHisResXchip[nhist][chip]->SetTitle(aux.Data());
702
703 aux=histnameResZchip;
704 aux+=nhist;
705 aux+="_chip_";
706 aux+=chip;
707 fHisResZchip[nhist][chip]=new TH1F("histname","histname",200,-0.32,0.32); // +-3200 micron; 1 bin=32 micron
708 fHisResZchip[nhist][chip]->SetName(aux.Data());
709 fHisResZchip[nhist][chip]->SetTitle(aux.Data());
710 }
711
712 aux=histnameTrackErrX;
713 aux+=nhist;
714 fHisTrackErrX[nhist]=new TH1F("histname","histname",200,0.,0.16); // 0-1600 micron; 1 bin=8 micron
715 fHisTrackErrX[nhist]->SetName(aux.Data());
716 fHisTrackErrX[nhist]->SetTitle(aux.Data());
717
718 aux=histnameTrackErrZ;
719 aux+=nhist;
720 fHisTrackErrZ[nhist]=new TH1F("histname","histname",200,0.,0.32); // 0-3200 micron; 1 bin=16 micron
721 fHisTrackErrZ[nhist]->SetName(aux.Data());
722 fHisTrackErrZ[nhist]->SetTitle(aux.Data());
723
724 aux=histnameClusErrX;
725 aux+=nhist;
726 fHisClusErrX[nhist]=new TH1F("histname","histname",200,0.,0.04); // 0-400 micron; 1 bin=2 micron
727 fHisClusErrX[nhist]->SetName(aux.Data());
728 fHisClusErrX[nhist]->SetTitle(aux.Data());
729
730 aux=histnameClusErrZ;
731 aux+=nhist;
732 fHisClusErrZ[nhist]=new TH1F("histname","histname",200,0.,0.16); // 0-1600 micron; 1 bin=8 micron
733 fHisClusErrZ[nhist]->SetName(aux.Data());
734 fHisClusErrZ[nhist]->SetTitle(aux.Data());
735
5fbd4fd6 736 }
737return;
738}
739//__________________________________________________________
740void AliITSPlaneEffSPD::DeleteHistos() {
741 if(fHisResX) {
742 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
3ebe30ad 743 delete [] fHisResX; fHisResX=0;
5fbd4fd6 744 }
745 if(fHisResZ) {
746 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
3ebe30ad 747 delete [] fHisResZ; fHisResZ=0;
5fbd4fd6 748 }
749 if(fHisResXZ) {
750 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
3ebe30ad 751 delete [] fHisResXZ; fHisResXZ=0;
5fbd4fd6 752 }
753 if(fHisClusterSize) {
754 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
3ebe30ad 755 delete [] fHisClusterSize; fHisClusterSize=0;
5fbd4fd6 756 }
757 if(fHisResXclu) {
758 for (Int_t i=0; i<kNHisto; i++ ) {
759 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResXclu[i][clu]) delete fHisResXclu[i][clu];
760 delete [] fHisResXclu[i];
761 }
762 delete [] fHisResXclu;
763 fHisResXclu = 0;
764 }
765 if(fHisResZclu) {
766 for (Int_t i=0; i<kNHisto; i++ ) {
767 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResZclu[i][clu]) delete fHisResZclu[i][clu];
768 delete [] fHisResZclu[i];
769 }
770 delete [] fHisResZclu;
771 fHisResZclu = 0;
772 }
1cc5cedc 773 if(fHisResXchip) {
774 for (Int_t i=0; i<kNHisto; i++ ) {
775 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResXchip[i][chip]) delete fHisResXchip[i][chip];
776 delete [] fHisResXchip[i];
777 }
778 delete [] fHisResXchip;
779 fHisResXchip = 0;
780 }
781 if(fHisResZchip) {
782 for (Int_t i=0; i<kNHisto; i++ ) {
783 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResZchip[i][chip]) delete fHisResZchip[i][chip];
784 delete [] fHisResZchip[i];
785 }
786 delete [] fHisResZchip;
787 fHisResZchip = 0;
788 }
789 if(fHisTrackErrX) {
790 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrX[i];
791 delete [] fHisTrackErrX; fHisTrackErrX=0;
792 }
793 if(fHisTrackErrZ) {
794 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrZ[i];
795 delete [] fHisTrackErrZ; fHisTrackErrZ=0;
796 }
797 if(fHisClusErrX) {
798 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrX[i];
799 delete [] fHisClusErrX; fHisClusErrX=0;
800 }
801 if(fHisClusErrZ) {
802 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrZ[i];
803 delete [] fHisClusErrZ; fHisClusErrZ=0;
804 }
5fbd4fd6 805
806return;
807}
808//__________________________________________________________
809Bool_t AliITSPlaneEffSPD::FillHistos(UInt_t key, Bool_t found,
1cc5cedc 810 // Float_t tXZ[2], Float_t cXZ[2], Int_t ctXZ[2]) {
811 Float_t *tr, Float_t *clu, Int_t *csize) {
5fbd4fd6 812// this method fill the histograms
813// input: - key: unique key of the basic block
814// - found: Boolean to asses whether a cluster has been associated to the track or not
1cc5cedc 815// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
816// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
817// - clu[0],clu[1] local X and Z coordinates of the cluster associated to the track, respectively
818// - clu[2],clu[3] error on local X and Z coordinates of the cluster associated to the track, respectively
819// - csize[0][1] cluster size in X and Z, respectively
5fbd4fd6 820// output: kTRUE if filling was succesfull kFALSE otherwise
821// side effects: updating of the histograms.
822//
823 if (!fHis) {
824 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
825 return kFALSE;
826 }
827 if(key>=kNModule*kNChip)
828 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
829 Int_t id=GetModFromKey(key);
1cc5cedc 830 Int_t chip=GetChipFromKey(key);
5fbd4fd6 831 if(id>=kNHisto)
832 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
833 if(found) {
1cc5cedc 834 Float_t resx=tr[0]-clu[0];
835 Float_t resz=tr[1]-clu[1];
5fbd4fd6 836 fHisResX[id]->Fill(resx);
837 fHisResZ[id]->Fill(resz);
838 fHisResXZ[id]->Fill(resx,resz);
1cc5cedc 839 fHisClusterSize[id]->Fill((Double_t)csize[0],(Double_t)csize[1]);
840 if(csize[0]>0 && csize[0]<=kNclu) fHisResXclu[id][csize[0]-1]->Fill(resx);
841 if(csize[1]>0 && csize[1]<=kNclu) fHisResZclu[id][csize[1]-1]->Fill(resz);
842 fHisResXchip[id][chip]->Fill(resx);
843 fHisResZchip[id][chip]->Fill(resz);
5fbd4fd6 844 }
1cc5cedc 845 fHisTrackErrX[id]->Fill(tr[2]);
846 fHisTrackErrZ[id]->Fill(tr[3]);
847 fHisClusErrX[id]->Fill(clu[2]);
848 fHisClusErrZ[id]->Fill(clu[3]);
5fbd4fd6 849 return kTRUE;
850}
851//__________________________________________________________
852Bool_t AliITSPlaneEffSPD::WriteHistosToFile(TString filename, Option_t* option) {
853 //
854 // Saves the histograms into a tree and saves the trees into a file
855 //
856 if (!fHis) return kFALSE;
857 if (filename.Data()=="") {
858 AliWarning("WriteHistosToFile: null output filename!");
859 return kFALSE;
860 }
861 char branchname[30];
862 TFile *hFile=new TFile(filename.Data(),option,
863 "The File containing the TREEs with ITS PlaneEff Histos");
864 TTree *SPDTree=new TTree("SPDTree","Tree whith Residuals and Cluster Type distributions for SPD");
865 TH1F *histZ,*histX;
866 TH2F *histXZ;
867 TH2I *histClusterType;
868 TH1F *histXclu[kNclu];
869 TH1F *histZclu[kNclu];
1cc5cedc 870 TH1F *histXchip[kNChip];
871 TH1F *histZchip[kNChip];
872 TH1F *histTrErrZ,*histTrErrX;
873 TH1F *histClErrZ,*histClErrX;
5fbd4fd6 874
875 histZ=new TH1F();
876 histX=new TH1F();
877 histXZ=new TH2F();
878 histClusterType=new TH2I();
879 for(Int_t clu=0;clu<kNclu;clu++) {
880 histXclu[clu]=new TH1F();
881 histZclu[clu]=new TH1F();
882 }
1cc5cedc 883 for(Int_t chip=0;chip<kNChip;chip++) {
884 histXchip[chip]=new TH1F();
885 histZchip[chip]=new TH1F();
886 }
887 histTrErrX=new TH1F();
888 histTrErrZ=new TH1F();
889 histClErrX=new TH1F();
890 histClErrZ=new TH1F();
5fbd4fd6 891
892 SPDTree->Branch("histX","TH1F",&histX,128000,0);
893 SPDTree->Branch("histZ","TH1F",&histZ,128000,0);
894 SPDTree->Branch("histXZ","TH2F",&histXZ,128000,0);
895 SPDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
896 for(Int_t clu=0;clu<kNclu;clu++) {
897 sprintf(branchname,"histXclu_%d",clu+1);
898 SPDTree->Branch(branchname,"TH1F",&histXclu[clu],128000,0);
899 sprintf(branchname,"histZclu_%d",clu+1);
900 SPDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0);
901 }
1cc5cedc 902 for(Int_t chip=0;chip<kNChip;chip++) {
903 sprintf(branchname,"histXchip_%d",chip);
904 SPDTree->Branch(branchname,"TH1F",&histXchip[chip],128000,0);
905 sprintf(branchname,"histZchip_%d",chip);
906 SPDTree->Branch(branchname,"TH1F",&histZchip[chip],128000,0);
907 }
908 SPDTree->Branch("histTrErrX","TH1F",&histTrErrX,128000,0);
909 SPDTree->Branch("histTrErrZ","TH1F",&histTrErrZ,128000,0);
910 SPDTree->Branch("histClErrX","TH1F",&histClErrX,128000,0);
911 SPDTree->Branch("histClErrZ","TH1F",&histClErrZ,128000,0);
5fbd4fd6 912
913 for(Int_t j=0;j<kNHisto;j++){
914 histX=fHisResX[j];
915 histZ=fHisResZ[j];
916 histXZ=fHisResXZ[j];
917 histClusterType=fHisClusterSize[j];
918 for(Int_t clu=0;clu<kNclu;clu++) {
919 histXclu[clu]=fHisResXclu[j][clu];
920 histZclu[clu]=fHisResZclu[j][clu];
921 }
1cc5cedc 922 for(Int_t chip=0;chip<kNChip;chip++) {
923 histXchip[chip]=fHisResXchip[j][chip];
924 histZchip[chip]=fHisResZchip[j][chip];
925 }
926 histTrErrX=fHisTrackErrX[j];
927 histTrErrZ=fHisTrackErrZ[j];
928 histClErrX=fHisClusErrX[j];
929 histClErrZ=fHisClusErrZ[j];
5fbd4fd6 930 SPDTree->Fill();
931 }
932 hFile->Write();
933 hFile->Close();
934return kTRUE;
935}
936//__________________________________________________________
937Bool_t AliITSPlaneEffSPD::ReadHistosFromFile(TString filename) {
938 //
939 // Read histograms from an already existing file
940 //
941 if (!fHis) return kFALSE;
942 if (filename.Data()=="") {
943 AliWarning("ReadHistosFromFile: incorrect output filename!");
944 return kFALSE;
945 }
946 char branchname[30];
947
948 TH1F *h = 0;
949 TH2F *h2 = 0;
950 TH2I *h2i= 0;
951
952 TFile *file=TFile::Open(filename.Data(),"READONLY");
953
954 if (!file || file->IsZombie()) {
955 AliWarning(Form("Can't open %s !",filename.Data()));
956 delete file;
957 return kFALSE;
958 }
959 TTree *tree = (TTree*) file->Get("SPDTree");
960
961 TBranch *histX = (TBranch*) tree->GetBranch("histX");
962 TBranch *histZ = (TBranch*) tree->GetBranch("histZ");
963 TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ");
964 TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType");
965
966 TBranch *histXclu[kNclu], *histZclu[kNclu];
967 for(Int_t clu=0; clu<kNclu; clu++) {
968 sprintf(branchname,"histXclu_%d",clu+1);
969 histXclu[clu]= (TBranch*) tree->GetBranch(branchname);
970 sprintf(branchname,"histZclu_%d",clu+1);
971 histZclu[clu]= (TBranch*) tree->GetBranch(branchname);
972 }
973
1cc5cedc 974 TBranch *histXchip[kNChip], *histZchip[kNChip];
975 for(Int_t chip=0; chip<kNChip; chip++) {
976 sprintf(branchname,"histXchip_%d",chip);
977 histXchip[chip]= (TBranch*) tree->GetBranch(branchname);
978 sprintf(branchname,"histZchip_%d",chip);
979 histZchip[chip]= (TBranch*) tree->GetBranch(branchname);
980 }
981
982 TBranch *histTrErrX = (TBranch*) tree->GetBranch("histTrErrX");
983 TBranch *histTrErrZ = (TBranch*) tree->GetBranch("histTrErrZ");
984 TBranch *histClErrX = (TBranch*) tree->GetBranch("histClErrX");
985 TBranch *histClErrZ = (TBranch*) tree->GetBranch("histClErrZ");
986
5fbd4fd6 987 gROOT->cd();
988
989 Int_t nevent = (Int_t)histX->GetEntries();
990 if(nevent!=kNHisto)
991 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
992 histX->SetAddress(&h);
993 for(Int_t j=0;j<kNHisto;j++){
994 delete h; h=0;
995 histX->GetEntry(j);
996 fHisResX[j]->Add(h);
997 }
998
999 nevent = (Int_t)histZ->GetEntries();
1000 if(nevent!=kNHisto)
1001 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1002 histZ->SetAddress(&h);
1003 for(Int_t j=0;j<kNHisto;j++){
1004 delete h; h=0;
1005 histZ->GetEntry(j);
1006 fHisResZ[j]->Add(h);
1007 }
1008
1009 nevent = (Int_t)histXZ->GetEntries();
1010 if(nevent!=kNHisto)
1011 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1012 histXZ->SetAddress(&h2);
1013 for(Int_t j=0;j<kNHisto;j++){
1014 delete h2; h2=0;
1015 histXZ->GetEntry(j);
1016 fHisResXZ[j]->Add(h2);
1017 }
1018
1019 nevent = (Int_t)histClusterType->GetEntries();
1020 if(nevent!=kNHisto)
1021 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1022 histClusterType->SetAddress(&h2i);
1023 for(Int_t j=0;j<kNHisto;j++){
1024 delete h2i; h2i=0;
1025 histClusterType->GetEntry(j);
1026 fHisClusterSize[j]->Add(h2i);
1027 }
1028
1029 for(Int_t clu=0; clu<kNclu; clu++) {
1030
1031 nevent = (Int_t)histXclu[clu]->GetEntries();
1032 if(nevent!=kNHisto)
1033 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1034 histXclu[clu]->SetAddress(&h);
1035 for(Int_t j=0;j<kNHisto;j++){
1036 delete h; h=0;
1037 histXclu[clu]->GetEntry(j);
1038 fHisResXclu[j][clu]->Add(h);
1039 }
1040
1041 nevent = (Int_t)histZclu[clu]->GetEntries();
1042 if(nevent!=kNHisto)
1043 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1044 histZclu[clu]->SetAddress(&h);
1045 for(Int_t j=0;j<kNHisto;j++){
1046 delete h; h=0;
1047 histZclu[clu]->GetEntry(j);
1048 fHisResZclu[j][clu]->Add(h);
1049 }
1050 }
1051
1cc5cedc 1052
1053 for(Int_t chip=0; chip<kNChip; chip++) {
1054
1055 nevent = (Int_t)histXchip[chip]->GetEntries();
1056 if(nevent!=kNHisto)
1057 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1058 histXchip[chip]->SetAddress(&h);
1059 for(Int_t j=0;j<kNHisto;j++){
1060 delete h; h=0;
1061 histXchip[chip]->GetEntry(j);
1062 fHisResXchip[j][chip]->Add(h);
1063 }
1064
1065 nevent = (Int_t)histZchip[chip]->GetEntries();
1066 if(nevent!=kNHisto)
1067 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1068 histZchip[chip]->SetAddress(&h);
1069 for(Int_t j=0;j<kNHisto;j++){
1070 delete h; h=0;
1071 histZchip[chip]->GetEntry(j);
1072 fHisResZchip[j][chip]->Add(h);
1073 }
1074 }
1075
1076 nevent = (Int_t)histTrErrX->GetEntries();
1077 if(nevent!=kNHisto)
1078 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1079 histTrErrX->SetAddress(&h);
1080 for(Int_t j=0;j<kNHisto;j++){
1081 delete h; h=0;
1082 histTrErrX->GetEntry(j);
1083 fHisTrackErrX[j]->Add(h);
1084 }
1085
1086 nevent = (Int_t)histTrErrZ->GetEntries();
1087 if(nevent!=kNHisto)
1088 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1089 histTrErrZ->SetAddress(&h);
1090 for(Int_t j=0;j<kNHisto;j++){
1091 delete h; h=0;
1092 histTrErrZ->GetEntry(j);
1093 fHisTrackErrZ[j]->Add(h);
1094 }
1095
1096 nevent = (Int_t)histClErrX->GetEntries();
1097 if(nevent!=kNHisto)
1098 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1099 histClErrX->SetAddress(&h);
1100 for(Int_t j=0;j<kNHisto;j++){
1101 delete h; h=0;
1102 histClErrX->GetEntry(j);
1103 fHisClusErrX[j]->Add(h);
1104 }
1105
1106 nevent = (Int_t)histClErrZ->GetEntries();
1107 if(nevent!=kNHisto)
1108 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1109 histClErrZ->SetAddress(&h);
1110 for(Int_t j=0;j<kNHisto;j++){
1111 delete h; h=0;
1112 histClErrZ->GetEntry(j);
1113 fHisClusErrZ[j]->Add(h);
1114 }
1115
5fbd4fd6 1116 delete h; h=0;
1117 delete h2; h2=0;
1118 delete h2i; h2i=0;
1119
1120 if (file) {
1121 file->Close();
1122 }
5fbd4fd6 1123return kTRUE;
1124}