]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPlaneEffSSD.cxx
SDD DA updated: baseline equalized to 20 for each hybrid. Added Carlos thresholds...
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSSD.cxx
CommitLineData
1cc5cedc 1/**************************************************************************
6344adcc 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 module by module efficiency of the SSD,
18// evaluated by tracks
19// (Inherits from AliITSPlaneEff)
20// Author: G.E. Bruno
21// giuseppe.bruno@ba.infn.it
22//
23///////////////////////////////////////////////////////////////////////////
24
7167ae53 25/* $Id$ */
6344adcc 26
27#include <TMath.h>
3ebe30ad 28#include <TH1F.h>
29#include <TFile.h>
30#include <TTree.h>
31#include <TROOT.h>
6344adcc 32#include "AliITSPlaneEffSSD.h"
33#include "AliLog.h"
34#include "AliCDBStorage.h"
35#include "AliCDBEntry.h"
36#include "AliCDBManager.h"
37//#include "AliCDBRunRange.h"
38#include "AliITSCalibrationSSD.h"
39
40ClassImp(AliITSPlaneEffSSD)
41//______________________________________________________________________
42AliITSPlaneEffSSD::AliITSPlaneEffSSD():
3ebe30ad 43 AliITSPlaneEff(),
44 fHisResX(0),
45 fHisResZ(0),
46 fHisResXZ(0),
47 fHisClusterSize(0){
6344adcc 48 for (UInt_t i=0; i<kNModule; i++){
49 fFound[i]=0;
50 fTried[i]=0;
51 }
52 // default constructor
53 AliDebug(1,Form("Calling default constructor"));
54}
55//______________________________________________________________________
56AliITSPlaneEffSSD::~AliITSPlaneEffSSD(){
57 // destructor
58 // Inputs:
59 // none.
60 // Outputs:
61 // none.
62 // Return:
63 // none.
3ebe30ad 64 DeleteHistos();
6344adcc 65}
66//______________________________________________________________________
3ebe30ad 67AliITSPlaneEffSSD::AliITSPlaneEffSSD(const AliITSPlaneEffSSD &s) : AliITSPlaneEff(s),
68fHisResX(0),
69fHisResZ(0),
70fHisResXZ(0),
71fHisClusterSize(0)
6344adcc 72{
73 // Copy Constructor
74 // Inputs:
75 // AliITSPlaneEffSSD &s The original class for which
76 // this class is a copy of
77 // Outputs:
78 // none.
79 // Return:
3ebe30ad 80
81 for (UInt_t i=0; i<kNModule; i++){
82 fFound[i]=s.fFound[i];
83 fTried[i]=s.fTried[i];
84 }
85 if(fHis) {
86 InitHistos();
87 for(Int_t i=0; i<kNHisto; i++) {
88 s.fHisResX[i]->Copy(*fHisResX[i]);
89 s.fHisResZ[i]->Copy(*fHisResZ[i]);
90 s.fHisResXZ[i]->Copy(*fHisResXZ[i]);
91 s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]);
92 }
93 }
6344adcc 94}
95//_________________________________________________________________________
96AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){
97 // Add-to-me operator
98 // Inputs:
99 // const AliITSPlaneEffSSD &add simulation class to be added
100 // Outputs:
101 // none.
102 // Return:
103 // none
104 for (UInt_t i=0; i<kNModule; i++){
105 fFound[i] += add.fFound[i];
106 fTried[i] += add.fTried[i];
107 }
3ebe30ad 108 if(fHis && add.fHis) {
109 for(Int_t i=0; i<kNHisto; i++) {
110 fHisResX[i]->Add(add.fHisResX[i]);
111 fHisResZ[i]->Add(add.fHisResZ[i]);
112 fHisResXZ[i]->Add(add.fHisResXZ[i]);
113 fHisClusterSize[i]->Add(add.fHisClusterSize[i]);
114 }
115 }
6344adcc 116 return *this;
117}
118//______________________________________________________________________
119AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator=(const
120 AliITSPlaneEffSSD &s){
121 // Assignment operator
122 // Inputs:
123 // AliITSPlaneEffSSD &s The original class for which
124 // this class is a copy of
125 // Outputs:
126 // none.
127 // Return:
128
129 if(this==&s) return *this;
130 s.Copy(*this);
131 return *this;
132}
133//______________________________________________________________________
134void AliITSPlaneEffSSD::Copy(TObject &obj) const {
135 // protected method. copy this to obj
136 AliITSPlaneEff::Copy(obj);
3ebe30ad 137 AliITSPlaneEffSSD& target = (AliITSPlaneEffSSD &) obj;
6344adcc 138 for(Int_t i=0;i<kNModule;i++) {
3ebe30ad 139 target.fFound[i] = fFound[i];
140 target.fTried[i] = fTried[i];
141 }
142 CopyHistos(target);
143 return;
144}
145//_______________________________________________________________________
146void AliITSPlaneEffSSD::CopyHistos(AliITSPlaneEffSSD &target) const {
147 // protected method: copy histos from this to target
148 target.fHis = fHis; // this is redundant only in some cases. Leave as it is.
149 if(fHis) {
150 target.fHisResX=new TH1F*[kNHisto];
151 target.fHisResZ=new TH1F*[kNHisto];
152 target.fHisResXZ=new TH2F*[kNHisto];
153 target.fHisClusterSize=new TH2I*[kNHisto];
154 for(Int_t i=0; i<kNHisto; i++) {
155 target.fHisResX[i] = new TH1F(*fHisResX[i]);
156 target.fHisResZ[i] = new TH1F(*fHisResZ[i]);
157 target.fHisResXZ[i] = new TH2F(*fHisResXZ[i]);
158 target.fHisClusterSize[i] = new TH2I(*fHisClusterSize[i]);
159 }
6344adcc 160 }
3ebe30ad 161return;
6344adcc 162}
163//______________________________________________________________________
164AliITSPlaneEff& AliITSPlaneEffSSD::operator=(const
165 AliITSPlaneEff &s){
166 // Assignment operator
167 // Inputs:
168 // AliITSPlaneEffSSD &s The original class for which
169 // this class is a copy of
170 // Outputs:
171 // none.
172 // Return:
173
174 if(&s == this) return *this;
7167ae53 175 AliError("operator=: Not allowed to make a =, use default creater instead");
6344adcc 176 return *this;
177}
178//_______________________________________________________________________
179Int_t AliITSPlaneEffSSD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
180 UInt_t im) const {
181
182 // Estimate the number of tracks still to be collected to attain a
183 // given efficiency eff, with relative error RelErr
184 // Inputs:
185 // eff -> Expected efficiency (e.g. those from actual estimate)
186 // RelErr -> tollerance [0,1]
187 // im -> module number [0,1697]
188 // Outputs: none
189 // Return: the estimated n. of tracks
190 //
191if (im>=kNModule)
7167ae53 192 {AliError("GetMissingTracksForGivenEff: you asked for a non existing module");
6344adcc 193 return -1;}
194else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im)];
195}
196//_________________________________________________________________________
197Double_t AliITSPlaneEffSSD::PlaneEff(const UInt_t im) const {
198// Compute the efficiency for a basic block,
199// Inputs:
200// im -> module number [0,1697]
201if (im>=kNModule)
7167ae53 202 {AliError("PlaneEff(UInt_t): you asked for a non existing module"); return -1.;}
6344adcc 203 Int_t nf=fFound[GetKey(im)];
204 Int_t nt=fTried[GetKey(im)];
205return AliITSPlaneEff::PlaneEff(nf,nt);
206}
207//_________________________________________________________________________
208Double_t AliITSPlaneEffSSD::ErrPlaneEff(const UInt_t im) const {
209 // Compute the statistical error on efficiency for a basic block,
210 // using binomial statistics
211 // Inputs:
212 // im -> module number [0,1697]
213if (im>=kNModule)
7167ae53 214 {AliError("ErrPlaneEff(UInt_t): you asked for a non existing module"); return -1.;}
6344adcc 215Int_t nf=fFound[GetKey(im)];
216Int_t nt=fTried[GetKey(im)];
217return AliITSPlaneEff::ErrPlaneEff(nf,nt);
218}
219//_________________________________________________________________________
220Bool_t AliITSPlaneEffSSD::UpDatePlaneEff(const Bool_t Kfound, const UInt_t im) {
221 // Update efficiency for a basic block
222if (im>=kNModule)
7167ae53 223 {AliError("UpDatePlaneEff: you asked for a non existing module"); return kFALSE;}
6344adcc 224 fTried[GetKey(im)]++;
225 if(Kfound) fFound[GetKey(im)]++;
226 return kTRUE;
227}
228//_________________________________________________________________________
229UInt_t AliITSPlaneEffSSD::GetKey(const UInt_t mod) const {
230 // get key given a basic block
231if(mod>=kNModule)
7167ae53 232 {AliError("GetKey: you asked for a non existing block"); return 99999;}
6344adcc 233return mod;
234}
235//__________________________________________________________________________
236UInt_t AliITSPlaneEffSSD::GetModFromKey(const UInt_t key) const {
237 // get mod. from key
238if(key>=kNModule)
7167ae53 239 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
6344adcc 240return key;
241}
242//__________________________________________________________________________
243Double_t AliITSPlaneEffSSD::LivePlaneEff(UInt_t key) const {
244 // returns plane efficieny after adding the fraction of sensor which is bad
245if(key>=kNModule)
7167ae53 246 {AliError("LivePlaneEff: you asked for a non existing key");
6344adcc 247 return -1.;}
248Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
249leff=PlaneEff(key)+GetFracBad(key);
250return leff>1?1:leff;
251}
252//____________________________________________________________________________
253Double_t AliITSPlaneEffSSD::ErrLivePlaneEff(UInt_t key) const {
254 // returns error on live plane efficiency
255if(key>=kNModule)
7167ae53 256 {AliError("ErrLivePlaneEff: you asked for a non existing key");
6344adcc 257 return -1.;}
258Int_t nf=fFound[key];
259Double_t triedInLive=GetFracLive(key)*fTried[key];
260Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
261return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
262}
263//_____________________________________________________________________________
264Double_t AliITSPlaneEffSSD::GetFracLive(const UInt_t key) const {
3ebe30ad 265 // returns the fraction of the sensor area which is OK (neither noisy nor dead)
266 // As for now, it computes only the fraction of good strips / total strips.
267 // If this fraction is large, then the computation is a good approximation.
268 // In any case, it is a lower limit of the fraction of the live area.
269 // The next upgrades would be to add the fraction of area of superoposition
270 // between bad N-side strips and bad P-side strips.
6344adcc 271if(key>=kNModule)
7167ae53 272 {AliError("GetFracLive: you asked for a non existing key");
6344adcc 273 return -1.;}
3ebe30ad 274AliInfo("GetFracLive: it computes only the fraction of working strips (N+P side) / total strips");
6344adcc 275UInt_t bad=0;
276GetBadInModule(key,bad);
277Double_t live=bad;
278live/=(kNChip*kNSide*kNStrip);
279return 1.-live;
280}
281//_____________________________________________________________________________
282void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const {
3ebe30ad 283 // returns the number of dead and noisy strips (sum of P and N sides).
6344adcc 284nrBadInMod=0;
285if(key>=kNModule)
7167ae53 286 {AliError("GetBadInModule: you asked for a non existing key");
6344adcc 287 return;}
288 // Compute the number of bad (dead+noisy) pixel in a module
289//
290if(!fInitCDBCalled)
7167ae53 291 {AliError("GetBadInModule: CDB not inizialized: call InitCDB first");
6344adcc 292 return;};
293AliCDBManager* man = AliCDBManager::Instance();
294// retrieve map of dead Pixel
295AliCDBEntry *cdbSSD = man->Get("ITS/Calib/BadChannelsSSD", fRunNumber);
296TObjArray* ssdEntry;
297if(cdbSSD) {
298 ssdEntry = (TObjArray*)cdbSSD->GetObject();
299 if(!ssdEntry)
7167ae53 300 {AliError("GetBadInChip: SSDEntry not found in CDB");
6344adcc 301 return;}
302} else {
7167ae53 303 AliError("GetBadInChip: did not find Calib/BadChannelsSSD");
6344adcc 304 return;
305}
306//
307UInt_t mod=GetModFromKey(key);
308//
309AliITSBadChannelsSSD* badchannels=(AliITSBadChannelsSSD*) ssdEntry->At(mod);
310// count the number of bad channels on the p side
311nrBadInMod += (badchannels->GetBadPChannelsList()).GetSize();
312// add the number of bad channels on the s side
313nrBadInMod += (badchannels->GetBadNChannelsList()).GetSize();
314return;
315}
316//_____________________________________________________________________________
317Double_t AliITSPlaneEffSSD::GetFracBad(const UInt_t key) const {
318 // returns 1-fractional live
319if(key>=kNModule)
7167ae53 320 {AliError("GetFracBad: you asked for a non existing key");
6344adcc 321 return -1.;}
322return 1.-GetFracLive(key);
323}
324//_____________________________________________________________________________
325Bool_t AliITSPlaneEffSSD::WriteIntoCDB() const {
326// write onto CDB
327if(!fInitCDBCalled)
7167ae53 328 {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first");
6344adcc 329 return kFALSE;}
330// to be written properly: now only for debugging
331 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
332 md->SetObjectClassName("AliITSPlaneEff");
333 md->SetResponsible("Giuseppe Eugenio Bruno");
334 md->SetBeamPeriod(0);
335 md->SetAliRootVersion("head 02/01/08"); //root version
336 AliCDBId id("ITS/PlaneEff/PlaneEffSSD",0,AliCDBRunRange::Infinity());
337 AliITSPlaneEffSSD eff;
338 eff=*this;
339 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
340 delete md;
341 return r;
342}
343//_____________________________________________________________________________
344Bool_t AliITSPlaneEffSSD::ReadFromCDB() {
345// read from CDB
346if(!fInitCDBCalled)
7167ae53 347 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first");
6344adcc 348 return kFALSE;}
6344adcc 349AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
1cc5cedc 350if(!cdbEntry) return kFALSE;
6344adcc 351AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
352if(this==eff) return kFALSE;
3ebe30ad 353if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff
354eff->Copy(*this); // copy everything (statistics and histos) from eff to this
6344adcc 355return kTRUE;
356}
7167ae53 357//_____________________________________________________________________________
1cc5cedc 358Bool_t AliITSPlaneEffSSD::AddFromCDB(AliCDBId *cdbId) {
359AliCDBEntry *cdbEntry=0;
360if (!cdbId) {
361 if(!fInitCDBCalled)
362 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first"); return kFALSE;}
363 cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber);
364} else {
365 cdbEntry = AliCDBManager::Instance()->Get(*cdbId);
366}
367if(!cdbEntry) return kFALSE;
368AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject();
369*this+=*eff;
370return kTRUE;
371}
372//_____________________________________________________________________________
7167ae53 373UInt_t AliITSPlaneEffSSD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet,
374 Float_t, Float_t) const {
375// method to locate a basic block from Detector Local coordinate (to be used in tracking)
376UInt_t key=999999;
377if(ilay<4 || ilay>5)
378 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
379 return key;}
380if(ilay==4 && (idet<0 || idet>747))
381 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
382 return key;}
383if(ilay==5 && (idet<0 || idet>949))
384 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
385 return key;}
386
387UInt_t mod=idet;
388if(ilay==1) mod+=748;
389key=GetKey(mod);
390return key;
391}
3ebe30ad 392//__________________________________________________________
393void AliITSPlaneEffSSD::InitHistos() {
394 // for the moment let's create the histograms
395 // module by module
396 TString histnameResX="HistResX_mod_",aux;
397 TString histnameResZ="HistResZ_mod_";
398 TString histnameResXZ="HistResXZ_mod_";
399 TString histnameClusterType="HistClusterType_mod_";
400
401//
402 fHisResX=new TH1F*[kNHisto];
403 fHisResZ=new TH1F*[kNHisto];
404 fHisResXZ=new TH2F*[kNHisto];
405 fHisClusterSize=new TH2I*[kNHisto];
406
407 for (Int_t nhist=0;nhist<kNHisto;nhist++){
408 aux=histnameResX;
409 aux+=nhist;
410 fHisResX[nhist]=new TH1F("histname","histname",500,-0.05,0.05); // +- 500 micron; 1 bin=2 micron
411 fHisResX[nhist]->SetName(aux.Data());
412 fHisResX[nhist]->SetTitle(aux.Data());
413
414 aux=histnameResZ;
415 aux+=nhist;
416 fHisResZ[nhist]=new TH1F("histname","histname",500,-0.50,0.50); // +-5000 micron; 1 bin=20 micron
417 fHisResZ[nhist]->SetName(aux.Data());
418 fHisResZ[nhist]->SetTitle(aux.Data());
419
420 aux=histnameResXZ;
421 aux+=nhist;
422 fHisResXZ[nhist]=new TH2F("histname","histname",40,-0.02,0.02,40,-0.16,0.16); // binning:
423 // 10 micron in x;
424 // 80 micron in z;
425 fHisResXZ[nhist]->SetName(aux.Data());
426 fHisResXZ[nhist]->SetTitle(aux.Data());
427
428 aux=histnameClusterType;
429 aux+=nhist;
430 fHisClusterSize[nhist]=new TH2I("histname","histname",6,0.5,6.5,6,0.5,6.5);
431 fHisClusterSize[nhist]->SetName(aux.Data());
432 fHisClusterSize[nhist]->SetTitle(aux.Data());
433
434 }
435return;
436}
437//__________________________________________________________
438void AliITSPlaneEffSSD::DeleteHistos() {
439 if(fHisResX) {
440 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
441 delete [] fHisResX; fHisResX=0;
442 }
443 if(fHisResZ) {
444 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
445 delete [] fHisResZ; fHisResZ=0;
446 }
447 if(fHisResXZ) {
448 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
449 delete [] fHisResXZ; fHisResXZ=0;
450 }
451 if(fHisClusterSize) {
452 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
453 delete [] fHisClusterSize; fHisClusterSize=0;
454 }
455
456return;
457}
458//__________________________________________________________
459Bool_t AliITSPlaneEffSSD::FillHistos(UInt_t key, Bool_t found,
1cc5cedc 460 // Float_t tXZ[2], Float_t cXZ[2], Int_t ctXZ[2]) {
461 Float_t *tr, Float_t *clu, Int_t *csize) {
3ebe30ad 462// this method fill the histograms
463// input: - key: unique key of the basic block
464// - found: Boolean to asses whether a cluster has been associated to the track or not
1cc5cedc 465// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
466// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
467// - clu[0],clu[1] local X and Z coordinates of the cluster associated to the track, respectively
468// - clu[2],clu[3] error on local X and Z coordinates of the cluster associated to the track, respectively
469// - csize[0][1] cluster size in X and Z, respectively
3ebe30ad 470// output: kTRUE if filling was succesfull kFALSE otherwise
471// side effects: updating of the histograms.
472//
473 if (!fHis) {
474 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
475 return kFALSE;
476 }
477 if(key>=kNModule)
478 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
479 Int_t id=GetModFromKey(key);
480 if(id>=kNHisto)
481 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
482 if(found) {
1cc5cedc 483 Float_t resx=tr[0]-clu[0];
484 Float_t resz=tr[1]-clu[1];
3ebe30ad 485 fHisResX[id]->Fill(resx);
486 fHisResZ[id]->Fill(resz);
487 fHisResXZ[id]->Fill(resx,resz);
1cc5cedc 488 fHisClusterSize[id]->Fill((Double_t)csize[0],(Double_t)csize[1]);
3ebe30ad 489 }
490 return kTRUE;
491}
492//__________________________________________________________
493Bool_t AliITSPlaneEffSSD::WriteHistosToFile(TString filename, Option_t* option) {
494 //
495 // Saves the histograms into a tree and saves the trees into a file
496 //
497 if (!fHis) return kFALSE;
498 if (filename.Data()=="") {
499 AliWarning("WriteHistosToFile: null output filename!");
500 return kFALSE;
501 }
502// char branchname[30];
503 TFile *hFile=new TFile(filename.Data(),option,
504 "The File containing the TREEs with ITS PlaneEff Histos");
505 TTree *SSDTree=new TTree("SSDTree","Tree whith Residuals and Cluster Type distributions for SSD");
506 TH1F *histZ,*histX;
507 TH2F *histXZ;
508 TH2I *histClusterType;
509
510 histZ=new TH1F();
511 histX=new TH1F();
512 histXZ=new TH2F();
513 histClusterType=new TH2I();
514
515 SSDTree->Branch("histX","TH1F",&histX,128000,0);
516 SSDTree->Branch("histZ","TH1F",&histZ,128000,0);
517 SSDTree->Branch("histXZ","TH2F",&histXZ,128000,0);
518 SSDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
519
520 for(Int_t j=0;j<kNHisto;j++){
521 histX=fHisResX[j];
522 histZ=fHisResZ[j];
523 histXZ=fHisResXZ[j];
524 histClusterType=fHisClusterSize[j];
525
526 SSDTree->Fill();
527 }
528 hFile->Write();
529 hFile->Close();
530return kTRUE;
531}
532//__________________________________________________________
533Bool_t AliITSPlaneEffSSD::ReadHistosFromFile(TString filename) {
534 //
535 // Read histograms from an already existing file
536 //
537 if (!fHis) return kFALSE;
538 if (filename.Data()=="") {
539 AliWarning("ReadHistosFromFile: incorrect output filename!");
540 return kFALSE;
541 }
1cc5cedc 542 //char branchname[30];
3ebe30ad 543
544 TH1F *h = 0;
545 TH2F *h2 = 0;
546 TH2I *h2i= 0;
547
548 TFile *file=TFile::Open(filename.Data(),"READONLY");
549
550 if (!file || file->IsZombie()) {
551 AliWarning(Form("Can't open %s !",filename.Data()));
552 delete file;
553 return kFALSE;
554 }
555 TTree *tree = (TTree*) file->Get("SSDTree");
556
557 TBranch *histX = (TBranch*) tree->GetBranch("histX");
558 TBranch *histZ = (TBranch*) tree->GetBranch("histZ");
559 TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ");
560 TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType");
561
562 gROOT->cd();
563
564 Int_t nevent = (Int_t)histX->GetEntries();
565 if(nevent!=kNHisto)
566 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
567 histX->SetAddress(&h);
568 for(Int_t j=0;j<kNHisto;j++){
569 delete h; h=0;
570 histX->GetEntry(j);
571 fHisResX[j]->Add(h);
572 }
573
574 nevent = (Int_t)histZ->GetEntries();
575 if(nevent!=kNHisto)
576 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
577 histZ->SetAddress(&h);
578 for(Int_t j=0;j<kNHisto;j++){
579 delete h; h=0;
580 histZ->GetEntry(j);
581 fHisResZ[j]->Add(h);
582 }
583
584 nevent = (Int_t)histXZ->GetEntries();
585 if(nevent!=kNHisto)
586 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
587 histXZ->SetAddress(&h2);
588 for(Int_t j=0;j<kNHisto;j++){
589 delete h2; h2=0;
590 histXZ->GetEntry(j);
591 fHisResXZ[j]->Add(h2);
592 }
593
594 nevent = (Int_t)histClusterType->GetEntries();
595 if(nevent!=kNHisto)
596 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
597 histClusterType->SetAddress(&h2i);
598 for(Int_t j=0;j<kNHisto;j++){
599 delete h2i; h2i=0;
600 histClusterType->GetEntry(j);
601 fHisClusterSize[j]->Add(h2i);
602 }
603
604 delete h; h=0;
605 delete h2; h2=0;
606 delete h2i; h2i=0;
607
608 if (file) {
609 file->Close();
610 }
611return kTRUE;
612}
613