1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 ///////////////////////////////////////////////////////////////////////////
16 // Plane Efficiency class for ITS
17 // It is used for chip by chip efficiency of the SPD,
18 // evaluated by tracks
19 // (Inherits from AliITSPlaneEff)
21 // giuseppe.bruno@ba.infn.it
23 ///////////////////////////////////////////////////////////////////////////
32 #include "AliITSPlaneEffSPD.h"
34 #include "AliCDBStorage.h"
35 #include "AliCDBEntry.h"
36 #include "AliCDBManager.h"
37 //#include "AliCDBRunRange.h"
38 #include "AliITSsegmentationSPD.h"
39 #include "AliITSCalibrationSPD.h"
41 ClassImp(AliITSPlaneEffSPD)
42 //______________________________________________________________________
43 AliITSPlaneEffSPD::AliITSPlaneEffSPD():
57 for (UInt_t i=0; i<kNModule*kNChip; i++){
61 // default constructor
62 AliDebug(1,Form("Calling default constructor"));
64 //______________________________________________________________________
65 AliITSPlaneEffSPD::~AliITSPlaneEffSPD(){
75 //______________________________________________________________________
76 AliITSPlaneEffSPD::AliITSPlaneEffSPD(const AliITSPlaneEffSPD &s) : AliITSPlaneEff(s),
93 // AliITSPlaneEffSPD &s The original class for which
94 // this class is a copy of
99 for (UInt_t i=0; i<kNModule*kNChip; i++){
100 fFound[i]=s.fFound[i];
101 fTried[i]=s.fTried[i];
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]);
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]);
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]);
125 //_________________________________________________________________________
126 AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator+=(const AliITSPlaneEffSPD &add){
127 // Add-to-me operator
129 // const AliITSPlaneEffSPD &add simulation class to be added
134 for (UInt_t i=0; i<kNModule*kNChip; i++){
135 fFound[i] += add.fFound[i];
136 fTried[i] += add.fTried[i];
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]);
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]);
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]);
160 //______________________________________________________________________
161 AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator=(const
162 AliITSPlaneEffSPD &s){
163 // Assignment operator
165 // AliITSPlaneEffSPD &s The original class for which
166 // this class is a copy of
171 if(this==&s) return *this;
175 //______________________________________________________________________
176 void AliITSPlaneEffSPD::Copy(TObject &obj) const {
177 // protected method. copy this to obj
178 AliITSPlaneEff::Copy(obj);
179 AliITSPlaneEffSPD& target = (AliITSPlaneEffSPD &) obj;
180 for(Int_t i=0;i<kNModule*kNChip;i++) {
181 target.fFound[i] = fFound[i];
182 target.fTried[i] = fTried[i];
187 //_______________________________________________________________________
188 void 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.
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];
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];
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]);
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]);
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]);
229 /* commented out by M.Masera 8/3/08
230 //______________________________________________________________________
231 AliITSPlaneEff& AliITSPlaneEffSPD::operator=(const
233 // Assignment operator
235 // AliITSPlaneEffSPD &s The original class for which
236 // this class is a copy of
241 if(&s == this) return *this;
242 AliError("operator=: Not allowed to make a =, use default creater instead");
246 //_______________________________________________________________________
247 Int_t AliITSPlaneEffSPD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
248 UInt_t im, UInt_t ic) const {
250 // Estimate the number of tracks still to be collected to attain a
251 // given efficiency eff, with relative error RelErr
253 // eff -> Expected efficiency (e.g. those from actual estimate)
254 // RelErr -> tollerance [0,1]
255 // im -> module number [0,249]
256 // ic -> chip number [0,4]
258 // Return: the estimated n. of tracks
260 if (im>=kNModule || ic>=kNChip)
261 {AliError("GetMissingTracksForGivenEff: you asked for a non existing chip");
263 else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic)];
265 //_________________________________________________________________________
266 Double_t AliITSPlaneEffSPD::PlaneEff(const UInt_t im,const UInt_t ic) const {
267 // Compute the efficiency for a basic block,
269 // im -> module number [0,249]
270 // ic -> chip number [0,4]
271 if (im>=kNModule || ic>=kNChip)
272 {AliError("PlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
273 Int_t nf=fFound[GetKey(im,ic)];
274 Int_t nt=fTried[GetKey(im,ic)];
275 return AliITSPlaneEff::PlaneEff(nf,nt);
277 //_________________________________________________________________________
278 Double_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
282 // im -> module number [0,249]
283 // ic -> chip number [0,4]
284 if (im>=kNModule || ic>=kNChip)
285 {AliError("ErrPlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
286 Int_t nf=fFound[GetKey(im,ic)];
287 Int_t nt=fTried[GetKey(im,ic)];
288 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
290 //_________________________________________________________________________
291 Bool_t AliITSPlaneEffSPD::UpDatePlaneEff(const Bool_t Kfound,
292 const UInt_t im, const UInt_t ic) {
293 // Update efficiency for a basic block
294 if (im>=kNModule || ic>=kNChip)
295 {AliError("UpDatePlaneEff: you asked for a non existing chip"); return kFALSE;}
296 fTried[GetKey(im,ic)]++;
297 if(Kfound) fFound[GetKey(im,ic)]++;
300 //_________________________________________________________________________
301 UInt_t AliITSPlaneEffSPD::GetChipFromCol(const UInt_t col) const {
302 // get chip given the column
303 if(col>=kNCol*kNChip)
304 {AliDebug(1,Form("GetChipFromCol: you asked for a non existing column %d",col)); return 10;}
307 //__________________________________________________________________________
308 UInt_t AliITSPlaneEffSPD::GetKey(const UInt_t mod, const UInt_t chip) const {
309 // get key given a basic block
310 if(mod>=kNModule || chip>=kNChip)
311 {AliWarning("GetKey: you asked for a non existing block"); return 99999;}
312 return mod*kNChip+chip;
314 //__________________________________________________________________________
315 UInt_t AliITSPlaneEffSPD::GetModFromKey(const UInt_t key) const {
317 if(key>=kNModule*kNChip)
318 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
321 //__________________________________________________________________________
322 UInt_t AliITSPlaneEffSPD::GetChipFromKey(const UInt_t key) const {
323 // retrieves chip from key
324 if(key>=kNModule*kNChip)
325 {AliError("GetChipFromKey: you asked for a non existing key"); return 999;}
326 return (key%(kNModule*kNChip))%kNChip;
328 //__________________________________________________________________________
329 void AliITSPlaneEffSPD::GetModAndChipFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip) const {
330 // get module and chip from a key
331 if(key>=kNModule*kNChip)
332 {AliError("GetModAndChipFromKey: you asked for a non existing key");
337 chip=(key%(kNModule*kNChip))%kNChip;
340 //____________________________________________________________________________
341 Double_t AliITSPlaneEffSPD::LivePlaneEff(UInt_t key) const {
342 // returns plane efficieny after adding the fraction of sensor which is bad
343 if(key>=kNModule*kNChip)
344 {AliError("LivePlaneEff: you asked for a non existing key");
346 Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
347 leff=PlaneEff(key)+GetFracBad(key);
348 return leff>1?1:leff;
350 //____________________________________________________________________________
351 Double_t AliITSPlaneEffSPD::ErrLivePlaneEff(UInt_t key) const {
352 // returns error on live plane efficiency
353 if(key>=kNModule*kNChip)
354 {AliError("ErrLivePlaneEff: you asked for a non existing key");
356 Int_t nf=fFound[key];
357 Double_t triedInLive=GetFracLive(key)*fTried[key];
358 Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
359 return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
361 //_____________________________________________________________________________
362 Double_t AliITSPlaneEffSPD::GetFracLive(const UInt_t key) const {
363 // returns the fraction of the sensor which is OK
364 if(key>=kNModule*kNChip)
365 {AliError("GetFracLive: you asked for a non existing key");
367 // Compute the fraction of bad (dead+noisy) detector
368 UInt_t dead=0,noisy=0;
369 GetDeadAndNoisyInChip(key,dead,noisy);
370 Double_t live=dead+noisy;
374 //_____________________________________________________________________________
375 void AliITSPlaneEffSPD::GetDeadAndNoisyInChip(const UInt_t key,
376 UInt_t& nrDeadInChip, UInt_t& nrNoisyInChip) const {
377 // returns the number of dead and noisy pixels
380 if(key>=kNModule*kNChip)
381 {AliError("GetDeadAndNoisyInChip: you asked for a non existing key");
383 // Compute the number of bad (dead+noisy) pixel in a chip
386 {AliError("GetDeadAndNoisyInChip: CDB not inizialized: call InitCDB first");
388 AliCDBManager* man = AliCDBManager::Instance();
389 // retrieve map of dead Pixel
390 AliCDBEntry *cdbSPDDead = man->Get("ITS/Calib/SPDDead", fRunNumber);
393 spdDead = (TObjArray*)cdbSPDDead->GetObject();
395 {AliError("GetDeadAndNoisyInChip: SPDDead not found in CDB");
398 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDDead.");
401 // retrieve map of noisy Pixel
402 AliCDBEntry *cdbSPDNoisy = man->Get("ITS/Calib/SPDNoisy", fRunNumber);
405 spdNoisy = (TObjArray*)cdbSPDNoisy->GetObject();
407 {AliError("GetDeadAndNoisyInChip: SPDNoisy not found in CDB");
410 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDNoisy.");
414 UInt_t mod=GetModFromKey(key);
415 UInt_t chip=GetChipFromKey(key);
416 // count number of dead
417 AliITSCalibrationSPD* calibSPD=(AliITSCalibrationSPD*) spdDead->At(mod);
418 UInt_t nrDead = calibSPD->GetNrBad();
419 for (UInt_t index=0; index<nrDead; index++) {
420 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
422 calibSPD=(AliITSCalibrationSPD*) spdNoisy->At(mod);
423 UInt_t nrNoisy = calibSPD->GetNrBad();
424 for (UInt_t index=0; index<nrNoisy; index++) {
425 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrNoisyInChip++;
429 //_____________________________________________________________________________
430 Double_t AliITSPlaneEffSPD::GetFracBad(const UInt_t key) const {
431 // returns 1-fractional live
432 if(key>=kNModule*kNChip)
433 {AliError("GetFracBad: you asked for a non existing key");
435 return 1.-GetFracLive(key);
437 //_____________________________________________________________________________
438 Bool_t AliITSPlaneEffSPD::WriteIntoCDB() const {
441 {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first");
443 // to be written properly: now only for debugging
444 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
445 //md->SetObjectClassName("AliITSPlaneEff");
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;
452 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
456 //_____________________________________________________________________________
457 Bool_t AliITSPlaneEffSPD::ReadFromCDB() {
460 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first");
462 AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
463 if(!cdbEntry) return kFALSE;
464 AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
465 if(this==eff) return kFALSE;
466 if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff
467 eff->Copy(*this); // copy everything (statistics and histos) from eff to this
470 //_____________________________________________________________________________
471 Bool_t AliITSPlaneEffSPD::AddFromCDB(AliCDBId *cdbId) {
472 AliCDBEntry *cdbEntry=0;
475 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first"); return kFALSE;}
476 cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
478 cdbEntry = AliCDBManager::Instance()->Get(*cdbId);
480 if(!cdbEntry) return kFALSE;
481 AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
485 //_____________________________________________________________________________
486 UInt_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)
491 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
493 if(ilay==0 && (idet<0 || idet>79))
494 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
496 if(ilay==1 && (idet<0 || idet>159))
497 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
502 key=GetKey(mod,GetChipFromCol(GetColFromLocZ(locz)));
505 //_____________________________________________________________________________
506 UInt_t AliITSPlaneEffSPD::GetColFromLocZ(Float_t zloc) const {
507 // method to retrieve column number from the local z coordinate
509 AliITSsegmentationSPD spd;
511 if(spd.LocalToDet(0,zloc,ix,iz)) col+=iz;
513 AliDebug(1,Form("cannot compute column number from local z=%f",zloc));
517 const Float_t kconv = 1.0E-04; // converts microns to cm.
519 for(Int_t i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
520 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
521 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
522 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
523 bz[127] = bz[128] = 625.0; // first chip boundry
527 for(Int_t i=000;i<160;i++) dz+=bz[i];
529 if(zloc<dz || zloc>-1*dz) { // outside z range
530 AliDebug(1,Form("GetColFromLocZ: cannot compute column number from local z=%f",zloc));
541 //________________________________________________________
542 Bool_t AliITSPlaneEffSPD::GetBlockBoundaries(const UInt_t key, Float_t& xmn,Float_t& xmx,
543 Float_t& zmn,Float_t& zmx) const {
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.
549 // Output: Ymin, Ymax, Zmin, Zmax of a basic block (chip for SPD)
550 // Return: kTRUE if computation was succesfully, kFALSE otherwise
552 if(key>=kNModule*kNChip)
553 {AliWarning("GetBlockBoundaries: you asked for a non existing key"); return kFALSE;}
554 UInt_t chip=GetChipFromKey(key);
555 zmn=GetLocZFromCol(chip*kNCol);
556 zmx=GetLocZFromCol((chip+1)*kNCol);
557 xmn=GetLocXFromRow(0);
558 xmx=GetLocXFromRow(kNRow);
561 if(zmx<zmn) {zmn=zmx; zmx=tmp;}
563 if(xmx<xmn) {xmn=xmx; xmx=tmp;}
566 //________________________________________________________
567 Float_t AliITSPlaneEffSPD::GetLocXFromRow(const UInt_t row) const {
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)].
573 // Input: row number in the range [0,kNRow]
574 // Output: lower local X coordinate of this row.
576 if(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.;}
578 // Use only AliITSsegmentationSPD
579 AliITSsegmentationSPD spd;
581 if(row==kNRow) spd.CellBoundries((Int_t)row-1,0,dummy,x,dummy,dummy);
582 else spd.CellBoundries((Int_t)row,0,x,dummy,dummy,dummy);
586 //________________________________________________________
587 Float_t AliITSPlaneEffSPD::GetLocZFromCol(const UInt_t col) const {
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)].
593 // Input: col number in the range [0,kNChip*kNCol]
594 // Output: lower local Y coordinate of this row.
596 if(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.;}
598 // Use only AliITSsegmentationSPD
599 AliITSsegmentationSPD spd;
601 if(col==kNChip*kNCol) spd.CellBoundries(0,(Int_t)col-1,dummy,dummy,dummy,y);
602 else spd.CellBoundries(0,(Int_t)col,dummy,dummy,y,dummy);
606 //__________________________________________________________
607 void AliITSPlaneEffSPD::InitHistos() {
608 // for the moment let's create the histograms
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_";
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_";
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];
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];
636 for (Int_t nhist=0;nhist<kNHisto;nhist++){
639 fHisResX[nhist]=new TH1F("histname","histname",800,-0.16,0.16); // +- 1600 micron; 1 bin=4 micron
640 fHisResX[nhist]->SetName(aux.Data());
641 fHisResX[nhist]->SetTitle(aux.Data());
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());
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;
655 aux=histnameClusterType;
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());
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
667 aux+=clu+1; // clu=0 --> cluster size 1
668 fHisResXclu[nhist][clu]=new TH1F("histname","histname",800,-0.16,0.16); // +- 1600 micron; 1 bin=4 micron
669 fHisResXclu[nhist][clu]->SetName(aux.Data());
670 fHisResXclu[nhist][clu]->SetTitle(aux.Data());
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());
681 fHisResXchip[nhist]=new TH1F*[kNChip];
682 fHisResZchip[nhist]=new TH1F*[kNChip];
683 for(Int_t chip=0; chip<kNChip; chip++) {
684 aux=histnameResXchip;
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());
692 aux=histnameResZchip;
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());
701 aux=histnameTrackErrX;
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());
707 aux=histnameTrackErrZ;
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());
713 aux=histnameClusErrX;
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());
719 aux=histnameClusErrZ;
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());
728 //__________________________________________________________
729 void AliITSPlaneEffSPD::DeleteHistos() {
731 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
732 delete [] fHisResX; fHisResX=0;
735 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
736 delete [] fHisResZ; fHisResZ=0;
739 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
740 delete [] fHisResXZ; fHisResXZ=0;
742 if(fHisClusterSize) {
743 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
744 delete [] fHisClusterSize; fHisClusterSize=0;
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];
751 delete [] fHisResXclu;
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];
759 delete [] fHisResZclu;
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];
767 delete [] fHisResXchip;
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];
775 delete [] fHisResZchip;
779 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrX[i];
780 delete [] fHisTrackErrX; fHisTrackErrX=0;
783 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrZ[i];
784 delete [] fHisTrackErrZ; fHisTrackErrZ=0;
787 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrX[i];
788 delete [] fHisClusErrX; fHisClusErrX=0;
791 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrZ[i];
792 delete [] fHisClusErrZ; fHisClusErrZ=0;
797 //__________________________________________________________
798 Bool_t AliITSPlaneEffSPD::FillHistos(UInt_t key, Bool_t found,
799 // Float_t tXZ[2], Float_t cXZ[2], Int_t ctXZ[2]) {
800 Float_t *tr, Float_t *clu, Int_t *csize) {
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
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
809 // output: kTRUE if filling was succesfull kFALSE otherwise
810 // side effects: updating of the histograms.
813 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
816 if(key>=kNModule*kNChip)
817 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
818 Int_t id=GetModFromKey(key);
819 Int_t chip=GetChipFromKey(key);
821 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
823 Float_t resx=tr[0]-clu[0];
824 Float_t resz=tr[1]-clu[1];
825 fHisResX[id]->Fill(resx);
826 fHisResZ[id]->Fill(resz);
827 fHisResXZ[id]->Fill(resx,resz);
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);
834 fHisTrackErrX[id]->Fill(tr[2]);
835 fHisTrackErrZ[id]->Fill(tr[3]);
836 fHisClusErrX[id]->Fill(clu[2]);
837 fHisClusErrZ[id]->Fill(clu[3]);
840 //__________________________________________________________
841 Bool_t AliITSPlaneEffSPD::WriteHistosToFile(TString filename, Option_t* option) {
843 // Saves the histograms into a tree and saves the trees into a file
845 if (!fHis) return kFALSE;
846 if (filename.Data()=="") {
847 AliWarning("WriteHistosToFile: null output filename!");
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");
856 TH2I *histClusterType;
857 TH1F *histXclu[kNclu];
858 TH1F *histZclu[kNclu];
859 TH1F *histXchip[kNChip];
860 TH1F *histZchip[kNChip];
861 TH1F *histTrErrZ,*histTrErrX;
862 TH1F *histClErrZ,*histClErrX;
867 histClusterType=new TH2I();
868 for(Int_t clu=0;clu<kNclu;clu++) {
869 histXclu[clu]=new TH1F();
870 histZclu[clu]=new TH1F();
872 for(Int_t chip=0;chip<kNChip;chip++) {
873 histXchip[chip]=new TH1F();
874 histZchip[chip]=new TH1F();
876 histTrErrX=new TH1F();
877 histTrErrZ=new TH1F();
878 histClErrX=new TH1F();
879 histClErrZ=new TH1F();
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);
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);
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);
902 for(Int_t j=0;j<kNHisto;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];
911 for(Int_t chip=0;chip<kNChip;chip++) {
912 histXchip[chip]=fHisResXchip[j][chip];
913 histZchip[chip]=fHisResZchip[j][chip];
915 histTrErrX=fHisTrackErrX[j];
916 histTrErrZ=fHisTrackErrZ[j];
917 histClErrX=fHisClusErrX[j];
918 histClErrZ=fHisClusErrZ[j];
925 //__________________________________________________________
926 Bool_t AliITSPlaneEffSPD::ReadHistosFromFile(TString filename) {
928 // Read histograms from an already existing file
930 if (!fHis) return kFALSE;
931 if (filename.Data()=="") {
932 AliWarning("ReadHistosFromFile: incorrect output filename!");
941 TFile *file=TFile::Open(filename.Data(),"READONLY");
943 if (!file || file->IsZombie()) {
944 AliWarning(Form("Can't open %s !",filename.Data()));
948 TTree *tree = (TTree*) file->Get("SPDTree");
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");
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);
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);
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");
978 Int_t nevent = (Int_t)histX->GetEntries();
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++){
988 nevent = (Int_t)histZ->GetEntries();
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++){
998 nevent = (Int_t)histXZ->GetEntries();
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++){
1004 histXZ->GetEntry(j);
1005 fHisResXZ[j]->Add(h2);
1008 nevent = (Int_t)histClusterType->GetEntries();
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++){
1014 histClusterType->GetEntry(j);
1015 fHisClusterSize[j]->Add(h2i);
1018 for(Int_t clu=0; clu<kNclu; clu++) {
1020 nevent = (Int_t)histXclu[clu]->GetEntries();
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++){
1026 histXclu[clu]->GetEntry(j);
1027 fHisResXclu[j][clu]->Add(h);
1030 nevent = (Int_t)histZclu[clu]->GetEntries();
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++){
1036 histZclu[clu]->GetEntry(j);
1037 fHisResZclu[j][clu]->Add(h);
1042 for(Int_t chip=0; chip<kNChip; chip++) {
1044 nevent = (Int_t)histXchip[chip]->GetEntries();
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++){
1050 histXchip[chip]->GetEntry(j);
1051 fHisResXchip[j][chip]->Add(h);
1054 nevent = (Int_t)histZchip[chip]->GetEntries();
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++){
1060 histZchip[chip]->GetEntry(j);
1061 fHisResZchip[j][chip]->Add(h);
1065 nevent = (Int_t)histTrErrX->GetEntries();
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++){
1071 histTrErrX->GetEntry(j);
1072 fHisTrackErrX[j]->Add(h);
1075 nevent = (Int_t)histTrErrZ->GetEntries();
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++){
1081 histTrErrZ->GetEntry(j);
1082 fHisTrackErrZ[j]->Add(h);
1085 nevent = (Int_t)histClErrX->GetEntries();
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++){
1091 histClErrX->GetEntry(j);
1092 fHisClusErrX[j]->Add(h);
1095 nevent = (Int_t)histClErrZ->GetEntries();
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++){
1101 histClErrZ->GetEntry(j);
1102 fHisClusErrZ[j]->Add(h);