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 (eventually with sui-bwing division
18 // along the drift direction) of the SDD,
19 // evaluated by tracks
20 // (Inherits from AliITSPlaneEff)
22 // giuseppe.bruno@ba.infn.it
24 ///////////////////////////////////////////////////////////////////////////
33 #include "AliITSPlaneEffSDD.h"
35 #include "AliCDBStorage.h"
36 #include "AliCDBEntry.h"
37 #include "AliCDBManager.h"
38 //#include "AliCDBRunRange.h"
39 #include "AliITSgeom.h"
40 #include "AliITSCalibrationSDD.h"
41 #include "AliITSsegmentationSDD.h"
43 ClassImp(AliITSPlaneEffSDD)
44 //______________________________________________________________________
45 AliITSPlaneEffSDD::AliITSPlaneEffSDD():
55 fProfClustSizeXvsX(0),
56 fProfClustSizeZvsX(0){
57 for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){
61 // default constructor
62 AliDebug(1,Form("Calling default constructor"));
64 //______________________________________________________________________
65 AliITSPlaneEffSDD::~AliITSPlaneEffSDD(){
75 //______________________________________________________________________
76 AliITSPlaneEffSDD::AliITSPlaneEffSDD(const AliITSPlaneEffSDD &s) : AliITSPlaneEff(s),
86 fProfClustSizeXvsX(0),
91 // AliITSPlaneEffSDD &s The original class for which
92 // this class is a copy of
97 for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){
98 fFound[i]=s.fFound[i];
99 fTried[i]=s.fTried[i];
103 for(Int_t i=0; i<kNHisto; i++) {
104 s.fHisResX[i]->Copy(*fHisResX[i]);
105 s.fHisResZ[i]->Copy(*fHisResZ[i]);
106 s.fHisResXZ[i]->Copy(*fHisResXZ[i]);
107 s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]);
108 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
109 s.fHisResXclu[i][clu]->Copy(*fHisResXclu[i][clu]);
110 s.fHisResZclu[i][clu]->Copy(*fHisResZclu[i][clu]);
112 s.fProfResXvsX[i]->Copy(*fProfResXvsX[i]);
113 s.fProfResZvsX[i]->Copy(*fProfResZvsX[i]);
114 s.fProfClustSizeXvsX[i]->Copy(*fProfClustSizeXvsX[i]);
115 s.fProfClustSizeZvsX[i]->Copy(*fProfClustSizeZvsX[i]);
119 //_________________________________________________________________________
120 AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator+=(const AliITSPlaneEffSDD &add){
121 // Add-to-me operator
123 // const AliITSPlaneEffSDD &add simulation class to be added
128 for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){
129 fFound[i] += add.fFound[i];
130 fTried[i] += add.fTried[i];
132 if(fHis && add.fHis) {
133 for(Int_t i=0; i<kNHisto; i++) {
134 fHisResX[i]->Add(add.fHisResX[i]);
135 fHisResZ[i]->Add(add.fHisResZ[i]);
136 fHisResXZ[i]->Add(add.fHisResXZ[i]);
137 fHisClusterSize[i]->Add(add.fHisClusterSize[i]);
138 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
139 fHisResXclu[i][clu]->Add(add.fHisResXclu[i][clu]);
140 fHisResZclu[i][clu]->Add(add.fHisResZclu[i][clu]);
142 fProfResXvsX[i]->Add(add.fProfResXvsX[i]);
143 fProfResZvsX[i]->Add(add.fProfResZvsX[i]);
144 fProfClustSizeXvsX[i]->Add(add.fProfClustSizeXvsX[i]);
145 fProfClustSizeZvsX[i]->Add(add.fProfClustSizeZvsX[i]);
150 //______________________________________________________________________
151 AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator=(const
152 AliITSPlaneEffSDD &s){
153 // Assignment operator
155 // AliITSPlaneEffSDD &s The original class for which
156 // this class is a copy of
161 if(this==&s) return *this;
165 //______________________________________________________________________
166 void AliITSPlaneEffSDD::Copy(TObject &obj) const {
167 // protected method. copy this to obj
168 AliITSPlaneEff::Copy(obj);
169 AliITSPlaneEffSDD& target = (AliITSPlaneEffSDD &) obj;
170 for(Int_t i=0;i<kNModule*kNChip*kNWing*kNSubWing;i++) {
171 target.fFound[i] = fFound[i];
172 target.fTried[i] = fTried[i];
177 //_______________________________________________________________________
178 void AliITSPlaneEffSDD::CopyHistos(AliITSPlaneEffSDD &target) const {
179 // protected method: copy histos from this to target
180 target.fHis = fHis; // this is redundant only in some cases. Leave as it is.
182 target.fHisResX=new TH1F*[kNHisto];
183 target.fHisResZ=new TH1F*[kNHisto];
184 target.fHisResXZ=new TH2F*[kNHisto];
185 target.fHisClusterSize=new TH2I*[kNHisto];
186 target.fHisResXclu=new TH1F**[kNHisto];
187 target.fHisResZclu=new TH1F**[kNHisto];
188 target.fProfResXvsX=new TProfile*[kNHisto];
189 target.fProfResZvsX=new TProfile*[kNHisto];
190 target.fProfClustSizeXvsX=new TProfile*[kNHisto];
191 target.fProfClustSizeZvsX=new TProfile*[kNHisto];
193 for(Int_t i=0; i<kNHisto; i++) {
194 target.fHisResX[i] = new TH1F(*fHisResX[i]);
195 target.fHisResZ[i] = new TH1F(*fHisResZ[i]);
196 target.fHisResXZ[i] = new TH2F(*fHisResXZ[i]);
197 target.fHisClusterSize[i] = new TH2I(*fHisClusterSize[i]);
198 target.fHisResXclu[i]=new TH1F*[kNclu];
199 target.fHisResZclu[i]=new TH1F*[kNclu];
200 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
201 target.fHisResXclu[i][clu] = new TH1F(*fHisResXclu[i][clu]);
202 target.fHisResZclu[i][clu] = new TH1F(*fHisResZclu[i][clu]);
204 target.fProfResXvsX[i]=new TProfile(*fProfResXvsX[i]);
205 target.fProfResZvsX[i]=new TProfile(*fProfResZvsX[i]);
206 target.fProfClustSizeXvsX[i]=new TProfile(*fProfClustSizeXvsX[i]);
207 target.fProfClustSizeZvsX[i]=new TProfile(*fProfClustSizeZvsX[i]);
212 //______________________________________________________________________
213 AliITSPlaneEff& AliITSPlaneEffSDD::operator=(const
215 // Assignment operator
217 // AliITSPlaneEffSDD &s The original class for which
218 // this class is a copy of
223 if(&s == this) return *this;
224 AliError("operator=: Not allowed to make a =, use default creater instead");
227 //_______________________________________________________________________
228 Int_t AliITSPlaneEffSDD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
229 UInt_t im, UInt_t ic, UInt_t iw, UInt_t is) const {
231 // Estimate the number of tracks still to be collected to attain a
232 // given efficiency eff, with relative error RelErr
234 // eff -> Expected efficiency (e.g. those from actual estimate)
235 // RelErr -> tollerance [0,1]
236 // im -> module number [0,259]
237 // ic -> chip number [0,3]
238 // iw -> wing number [0,1]
239 // is -> chip number [0,kNSubWing-1]
241 // Return: the estimated n. of tracks
243 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing)
244 {AliError("GetMissingTracksForGivenEff: you asked for a non existing block");
246 else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic,iw,is)];
248 //_________________________________________________________________________
249 Double_t AliITSPlaneEffSDD::PlaneEff(const UInt_t im,const UInt_t ic,
250 const UInt_t iw,const UInt_t is) const {
251 // Compute the efficiency for a basic block,
253 // im -> module number [0,259]
254 // ic -> chip number [0,3]
255 // iw -> wing number [0,1]
256 // is -> chip number [0,kNSubWing-1]
257 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing)
258 {AliError("PlaneEff(UInt_t,UInt_t,UInt_t,UInt_t): you asked for a non existing block"); return -1.;}
259 Int_t nf=fFound[GetKey(im,ic,iw,is)];
260 Int_t nt=fTried[GetKey(im,ic,iw,is)];
261 return AliITSPlaneEff::PlaneEff(nf,nt);
263 //_________________________________________________________________________
264 Double_t AliITSPlaneEffSDD::ErrPlaneEff(const UInt_t im,const UInt_t ic,
265 const UInt_t iw,const UInt_t is) const {
266 // Compute the statistical error on efficiency for a basic block,
267 // using binomial statistics
269 // im -> module number [0,259]
270 // ic -> chip number [0,3]
271 // iw -> wing number [0,1]
272 // is -> chip number [0,kNSubWing-1]
273 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing)
274 {AliError("ErrPlaneEff(UInt_t,UInt_t,UInt_t,UInt_t): you asked for a non existing block"); return -1.;}
275 Int_t nf=fFound[GetKey(im,ic,iw,is)];
276 Int_t nt=fTried[GetKey(im,ic,iw,is)];
277 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
279 //_________________________________________________________________________
280 Bool_t AliITSPlaneEffSDD::UpDatePlaneEff(const Bool_t Kfound,
281 const UInt_t im, const UInt_t ic,
282 const UInt_t iw, const UInt_t is) {
283 // Update efficiency for a basic block
284 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing)
285 {AliError("UpDatePlaneEff: you asked for a non existing block"); return kFALSE;}
286 fTried[GetKey(im,ic,iw,is)]++;
287 if(Kfound) fFound[GetKey(im,ic,iw,is)]++;
290 //_________________________________________________________________________
291 void AliITSPlaneEffSDD::ChipAndWingFromAnode(const UInt_t anode, UInt_t& chip,
292 UInt_t& wing) const {
293 // Retun the chip number [0,3] and the wing number [0,1] given the anode number
294 // input: anode number [0,511]
295 if(anode>=kNAnode*kNChip*kNWing)
296 {AliError("ChipAndWingFromAnode: you asked for a non existing anode");
302 if(anode>=kNChip*kNAnode) wing=1;
303 if(wing==1) chip-=kNChip;
306 //_________________________________________________________________________
307 UInt_t AliITSPlaneEffSDD::ChipFromAnode(const UInt_t anode) const {
308 // Retun the chip number [0,3] given the anode number
309 // input: anode number [0,511]
310 if(anode>=kNAnode*kNChip*kNWing)
311 {AliError("ChipFromAnode: you asked for a non existing anode"); return 999;}
313 Int_t chip=anode/kNAnode;
314 if(anode>=kNChip*kNAnode) wing=1;
315 if(wing==1)chip-=kNChip;
318 //_________________________________________________________________________
319 UInt_t AliITSPlaneEffSDD::WingFromAnode(const UInt_t anode) const {
320 // return the wing number [0,1] given the anode number
321 // input: anode number [0,511]
322 if(anode>=kNAnode*kNChip*kNWing)
323 {AliError("WingFromAnode: you asked for a non existing anode"); return 99;}
325 if(anode>=kNChip*kNAnode) wing=1;
328 //__________________________________________________________________________
329 UInt_t AliITSPlaneEffSDD::GetKey(const UInt_t mod, const UInt_t chip,
330 const UInt_t wing, const UInt_t subw) const {
331 // get key given a basic block
332 if(mod>=kNModule || chip>=kNChip || wing>= kNWing || subw>=kNSubWing)
333 {AliError("GetKey: you asked for a non existing block"); return 99999;}
334 return mod*kNChip*kNWing*kNSubWing+chip*kNWing*kNSubWing+wing*kNSubWing+subw;
336 //__________________________________________________________________________
337 UInt_t AliITSPlaneEffSDD::GetModFromKey(const UInt_t key) const {
339 if(key>=kNModule*kNChip*kNWing*kNSubWing)
340 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
341 return key/(kNChip*kNWing*kNSubWing);
343 //__________________________________________________________________________
344 UInt_t AliITSPlaneEffSDD::GetChipFromKey(const UInt_t key) const {
345 // retrieves chip from key
346 if(key>=kNModule*kNChip*kNWing*kNSubWing)
347 {AliError("GetChipFromKey: you asked for a non existing key"); return 999;}
348 return (key%(kNChip*kNWing*kNSubWing))/(kNWing*kNSubWing);
350 //__________________________________________________________________________
351 UInt_t AliITSPlaneEffSDD::GetWingFromKey(const UInt_t key) const {
352 // retrieves wing from key
353 if(key>=kNModule*kNChip*kNWing*kNSubWing)
354 {AliError("GetWingFromKey: you asked for a non existing key"); return 99;}
355 return ((key%(kNChip*kNWing*kNSubWing))%(kNWing*kNSubWing))/(kNSubWing);
357 //__________________________________________________________________________
358 UInt_t AliITSPlaneEffSDD::GetSubWingFromKey(const UInt_t key) const {
359 // retrieves sub-wing from key
360 if(key>=kNModule*kNChip*kNWing*kNSubWing)
361 {AliError("GetSubWingFromKey: you asked for a non existing key"); return 9;}
362 return ((key%(kNChip*kNWing*kNSubWing))%(kNWing*kNSubWing))%(kNSubWing);
364 //__________________________________________________________________________
365 void AliITSPlaneEffSDD::GetAllFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip,
366 UInt_t& wing,UInt_t& subw) const {
367 // get module, chip, wing and subwing from a key
368 if(key>=kNModule*kNChip*kNWing*kNSubWing)
369 {AliError("GetAllFromKey: you asked for a non existing key");
375 mod=GetModFromKey(key);
376 chip=GetChipFromKey(key);
377 wing=GetWingFromKey(key);
378 subw=GetSubWingFromKey(key);
381 //____________________________________________________________________________
382 Double_t AliITSPlaneEffSDD::LivePlaneEff(UInt_t key) const {
383 // returns plane efficieny after adding the fraction of sensor which is bad
384 if(key>=kNModule*kNChip*kNWing*kNSubWing)
385 {AliError("LivePlaneEff: you asked for a non existing key");
387 Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
388 leff=PlaneEff(key)+GetFracBad(key);
389 return leff>1?1:leff;
391 //____________________________________________________________________________
392 Double_t AliITSPlaneEffSDD::ErrLivePlaneEff(UInt_t key) const {
393 // returns error on live plane efficiency
394 if(key>=kNModule*kNChip*kNWing*kNSubWing)
395 {AliError("ErrLivePlaneEff: you asked for a non existing key");
397 Int_t nf=fFound[key];
398 Double_t triedInLive=GetFracLive(key)*fTried[key];
399 Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
400 return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
402 //_____________________________________________________________________________
403 Double_t AliITSPlaneEffSDD::GetFracLive(const UInt_t key) const {
404 // returns the fraction of the sensor which is OK
405 if(key>=kNModule*kNChip*kNWing*kNSubWing)
406 {AliError("GetFracLive: you asked for a non existing key");
408 // Compute the fraction of bad (dead+noisy) detector
410 GetBadInBlock(key,bad);
415 //_____________________________________________________________________________
416 void AliITSPlaneEffSDD::GetBadInBlock(const UInt_t key, UInt_t& nrBadInBlock) const {
417 // Compute the number of bad (dead+noisy) anodes inside a block
418 // (it depends on the chip, not on the sub-wing)
420 if(key>=kNModule*kNChip*kNWing*kNSubWing)
421 {AliError("GetBadInBlock: you asked for a non existing key");
425 {AliError("GetBadInBlock: CDB not inizialized: call InitCDB first");
427 AliCDBManager* man = AliCDBManager::Instance();
428 // retrieve map of dead Pixel
429 AliCDBEntry *cdbSDD = man->Get("ITS/Calib/CalibSDD", fRunNumber);
432 sddEntry = (TObjArray*)cdbSDD->GetObject();
434 {AliError("GetBadInBlock: SDDEntry not found in CDB");
437 AliError("GetBadInBlock: Did not find Calib/CalibSDD");
441 UInt_t mod=GetModFromKey(key);
442 UInt_t chip=GetChipFromKey(key);
443 UInt_t wing=GetWingFromKey(key);
444 // count number of dead
445 AliITSCalibrationSDD* calibSDD=(AliITSCalibrationSDD*) sddEntry->At(mod);
446 UInt_t nrBad = calibSDD-> GetDeadChannels();
447 for (UInt_t index=0; index<nrBad; index++) {
448 if(ChipFromAnode(calibSDD->GetBadChannel(index))==chip &&
449 WingFromAnode(calibSDD->GetBadChannel(index))==wing ) nrBadInBlock++;
453 //_____________________________________________________________________________
454 Double_t AliITSPlaneEffSDD::GetFracBad(const UInt_t key) const {
455 // returns 1-fractional live
456 if(key>=kNModule*kNChip*kNWing*kNSubWing)
457 {AliError("GetFracBad: you asked for a non existing key");
459 return 1.-GetFracLive(key);
461 //_____________________________________________________________________________
462 Bool_t AliITSPlaneEffSDD::WriteIntoCDB() const {
465 {AliError("WriteIntoCDB: CDB not inizialized: call InitCDB first");
467 // to be written properly: now only for debugging
468 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
469 md->SetObjectClassName("AliITSPlaneEff");
470 md->SetResponsible("Giuseppe Eugenio Bruno");
471 md->SetBeamPeriod(0);
472 md->SetAliRootVersion("head 02/01/08"); //root version
473 AliCDBId id("ITS/PlaneEff/PlaneEffSDD",0,AliCDBRunRange::Infinity());
474 AliITSPlaneEffSDD eff;
476 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
480 //_____________________________________________________________________________
481 Bool_t AliITSPlaneEffSDD::ReadFromCDB() {
484 {AliError("ReadFromCDB: CDB not inizialized: call InitCDB first");
486 //if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
487 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
489 AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSDD",fRunNumber);
490 AliITSPlaneEffSDD* eff= (AliITSPlaneEffSDD*)cdbEntry->GetObject();
491 if(this==eff) return kFALSE;
492 if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff
493 eff->Copy(*this); // copy everything (statistics and histos) from eff to this
496 //_____________________________________________________________________________
497 UInt_t AliITSPlaneEffSDD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet,
498 Float_t locx, Float_t locz) const {
499 // method to locate a basic block from Detector Local coordinate (to be used in tracking)
501 // If kNSubWing = 1, i.e. no sub-wing subdivision, then the numbering scheme of the
502 // unique key is the following, e.g. for the first detector (idet=0, ilayer=2)
506 // _________________________|__________________________ 3.5085
510 // | key=1 | key=3 | key=5 | key=7 |
512 // |____________|____________|____________|____________|_0_____\ local z (cm)
515 // | key=0 | key=2 | key=4 | key=6 |
518 // |____________|____________|____________|____________| -3.5085
519 //-3.7632 -1.8816 0 1.1186 3.7632
521 // for the second detector (idet=2, ilay=2), first key is 8 (bottom-left),
522 // last one is 15 (upper-right), and so on.
524 // If subwing division has been applied, then you count in each wing, starting from
525 // the one with negative local , from the anode side (outer part) towards the
526 // cathod strip (center).
528 // bottom wing (from below): 0,1,..,kNSubWing-1,
529 // upper wing (from up): kNSubWing, ... , 2*kNSubWing-1
531 // bottom wing (from below): 2*kNSubWing, .. , 3*kNSubWing-1
532 // upper wing (from up): 3*kNSubWing, ... ,4*kNSubWing-1
534 // 4nd (last) column :
535 // bottom wing (from below): 6*kNSubWing, .. , 7*kNSubWing-1
536 // upper wing (from up): 7*kNSubWing, ... ,8*kNSubWing-1
542 // _________________________|__________________________ 3.5085
544 // | key=2 | key=6 | key=10 | key=14 |
545 // |____________|____________|____________|____________|
547 // | key=3 | key=7 | key=11 | key=15 |
548 // |____________|____________|____________|____________|_0_____\ local z (cm)
550 // | key=1 | key=5 | key=9 | key=13 |
551 // |____________|____________|____________|____________|
553 // | key=0 | key=4 | key=8 | key=12 |
554 // |____________|____________|____________|____________| -3.5085
555 //-3.7632 -1.8816 0 1.1186 3.7632
557 //___________________________________________________________________________
561 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
563 if(ilay==2 && (idet<0 || idet>83))
564 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
566 if(ilay==3 && (idet<0 || idet>175))
567 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
571 UInt_t chip=0,wing=0,subw=0;
572 ChipAndWingAndSubWingFromLocCoor(locx,locz,chip,wing,subw);
573 key=GetKey(mod,chip,wing,subw);
576 //_____________________________________________________________________________
577 void AliITSPlaneEffSDD::ChipAndWingAndSubWingFromLocCoor(Float_t xloc, Float_t zloc,
578 UInt_t& chip, UInt_t& wing, UInt_t& subw) const {
579 AliITSgeom* geom=NULL;
580 //AliITSsegmentationSDD* sdd=new AliITSsegmentationSDD(geom);
581 AliITSsegmentationSDD sdd=AliITSsegmentationSDD(geom);
582 sdd.SetDriftSpeed(sdd.GetDriftSpeed()); // this only for setting fSetDriftSpeed=kTRUE !!!
586 if(sdd.LocalToDet(xloc,zloc,ix,iz)) {
588 ChipAndWingFromAnode(anode,chip,wing);
589 if(sdd.LocalToDet(0.,0.,ntb,iz)) { // in this way the sub-division along time coordinate
590 subw=SubWingFromTimeBin(ix,ntb); } // is purely geometrical one and it does not
591 else { // depen on the drift-velocity.
592 AliError("ChipAndWingAndSubWingFromLocCoor: cannot calculate n. of time bins for SubWing.");
596 AliError("ChipAndWingAndSubWingFromLocCoor: cannot calculate anode number and time bin.");
603 //__________________________________________________________________________________
604 UInt_t AliITSPlaneEffSDD::SubWingFromTimeBin(const Int_t tb, const Int_t ntb) const {
605 if(tb<0 || tb>ntb || ntb<0) {
606 AliError(Form("SubWingFromTimeBin: you asked time bin = %d with %d n. of bins",tb,ntb));
609 //AliDebug(Form("tb = %d, ntb= %d , NSubWing = %d",tb,ntb,kNSubWing));
613 return TMath::Nint(h);
615 //________________________________________________________
616 Bool_t AliITSPlaneEffSDD::GetBlockBoundaries(const UInt_t key, Float_t& xmn,Float_t& xmx,
617 Float_t& zmn,Float_t& zmx) const {
619 // This method return the geometrical boundaries of the active volume of a given
620 // basic block, in the detector reference system.
621 // Input: unique key to locate a basic block.
623 // Output: Ymin, Ymax, Zmin, Zmax of a basic block (chip for SPD)
624 // Return: kTRUE if computation was succesfully, kFALSE otherwise
626 // the following scheemes will help in following the method implementation
630 // _________________________|__________________________ 3.5085
631 // | wing=1 | wing=1 | wing=1 | wing=1 |
632 // | chip=0 | chip=1 | chip=2 | chip=3 |
633 // | key=1 | key=3 | key=5 | key=7 |
634 // |____________|____________|____________|____________|_0_____\ local z (cm)
635 // | wing=0 | wing=0 | wing=0 | wing=0 | /
636 // | chip=0 | chip=1 | chip=2 | chip=3 |
637 // | key=0 | key=2 | key=4 | key=6 |
638 // |____________|____________|____________|____________| -3.5085
639 //-3.7632 -1.8816 0 1.1186 3.7632
644 // _________________________|__________________________ 3.5085
645 // | chip=0 | chip=1 | chip=2 | chip=3 |
646 // | key=2 | key=6 | key=10 | key=14 | subw=0
647 // |____________|____________|____________|____________| wing=1
648 // | chip=0 | chip=1 | chip=2 | chip=3 | subw=1
649 // | key=3 | key=7 | key=11 | key=15 |
650 // |____________|____________|____________|____________|_0________\ local z (cm)
651 // | chip=0 | chip=1 | chip=2 | chip=3 | /
652 // | key=1 | key=5 | key=9 | key=13 | subw=1
653 // |____________|____________|____________|____________| wing=0
654 // | chip=0 | chip=1 | chip=2 | chip=3 | subw=0
655 // | key=0 | key=4 | key=8 | key=12 |
656 // |____________|____________|____________|____________| -3.5085
657 //-3.7632 -1.8816 0 1.1186 3.7632
659 if(key>=kNModule*kNChip*kNWing*kNSubWing)
660 {AliWarning("GetBlockBoundaries: you asked for a non existing key"); return kFALSE;}
662 const Float_t kDxDefault = 35085.; // For Plane Eff. purpouses, default values
663 const Float_t kDzDefault = 75264.; // are precise enough !!!
664 const Float_t kconv = 1.0E-04; //converts microns to cm.
665 UInt_t chip=GetChipFromKey(key);
666 UInt_t wing=GetWingFromKey(key);
667 UInt_t subw=GetSubWingFromKey(key);
668 zmn=kconv*(kDzDefault/kNChip*chip-0.5*kDzDefault);
669 zmx=kconv*(kDzDefault/kNChip*(chip+1)-0.5*kDzDefault);
670 if(wing==0) { // count from below
671 xmn=kconv*(kDxDefault/kNSubWing*subw-kDxDefault);
672 xmx=kconv*(kDxDefault/kNSubWing*(subw+1)-kDxDefault);
674 else if(wing==1) { // count from top
675 xmx=kconv*(kDxDefault-kDxDefault/kNSubWing*subw);
676 xmn=kconv*(kDxDefault-kDxDefault/kNSubWing*(subw+1));
678 else {AliError("GetBlockBoundaries: you got wrong n. of wing"); return kFALSE;}
681 //__________________________________________________________
682 void AliITSPlaneEffSDD::InitHistos() {
683 // for the moment let's create the histograms
685 TString histnameResX="HistResX_mod_",aux;
686 TString histnameResZ="HistResZ_mod_";
687 TString histnameResXZ="HistResXZ_mod_";
688 TString histnameClusterType="HistClusterType_mod_";
689 TString histnameResXclu="HistResX_mod_";
690 TString histnameResZclu="HistResZ_mod_";
691 TString profnameResXvsX="ProfResXvsX_mod_";
692 TString profnameResZvsX="ProfResZvsX_mod_";
693 TString profnameClustSizeXvsX="ProfClustSizeXvsX_mod_";
694 TString profnameClustSizeZvsX="ProfClustSizeZvsX_mod_";
696 fHisResX=new TH1F*[kNHisto];
697 fHisResZ=new TH1F*[kNHisto];
698 fHisResXZ=new TH2F*[kNHisto];
699 fHisClusterSize=new TH2I*[kNHisto];
700 fHisResXclu=new TH1F**[kNHisto];
701 fHisResZclu=new TH1F**[kNHisto];
702 fProfResXvsX=new TProfile*[kNHisto];
703 fProfResZvsX=new TProfile*[kNHisto];
704 fProfClustSizeXvsX=new TProfile*[kNHisto];
705 fProfClustSizeZvsX=new TProfile*[kNHisto];
707 for (Int_t nhist=0;nhist<kNHisto;nhist++){
710 fHisResX[nhist]=new TH1F("histname","histname",1500,-0.15,0.15); // +- 1500 micron; 1 bin=2 micron
711 fHisResX[nhist]->SetName(aux.Data());
712 fHisResX[nhist]->SetTitle(aux.Data());
716 fHisResZ[nhist]=new TH1F("histname","histname",500,-0.05,0.05); // +-500 micron; 1 bin=2 micron
717 fHisResZ[nhist]->SetName(aux.Data());
718 fHisResZ[nhist]->SetTitle(aux.Data());
722 fHisResXZ[nhist]=new TH2F("histname","histname",50,-0.1,0.1,30,-0.03,0.03); // binning:
725 fHisResXZ[nhist]->SetName(aux.Data());
726 fHisResXZ[nhist]->SetTitle(aux.Data());
728 aux=histnameClusterType;
730 fHisClusterSize[nhist]=new TH2I("histname","histname",10,0.5,10.5,10,0.5,10.5);
731 fHisClusterSize[nhist]->SetName(aux.Data());
732 fHisClusterSize[nhist]->SetTitle(aux.Data());
734 fHisResXclu[nhist]=new TH1F*[kNclu];
735 fHisResZclu[nhist]=new TH1F*[kNclu];
736 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
740 aux+=clu+1; // clu=0 --> cluster size 1
741 fHisResXclu[nhist][clu]=new TH1F("histname","histname",1500,-0.15,0.15);// +- 1500 micron; 1 bin=2 micron
742 fHisResXclu[nhist][clu]->SetName(aux.Data());
743 fHisResXclu[nhist][clu]->SetTitle(aux.Data());
748 aux+=clu+1; // clu=0 --> cluster size 1
749 fHisResZclu[nhist][clu]=new TH1F("histname","histname",500,-0.05,0.05); // +-500 micron; 1 bin=2 micron
750 fHisResZclu[nhist][clu]->SetName(aux.Data());
751 fHisResZclu[nhist][clu]->SetTitle(aux.Data());
756 fProfResXvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5);
757 fProfResXvsX[nhist]->SetName(aux.Data());
758 fProfResXvsX[nhist]->SetTitle(aux.Data());
762 fProfResZvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5);
763 fProfResZvsX[nhist]->SetName(aux.Data());
764 fProfResZvsX[nhist]->SetTitle(aux.Data());
766 aux=profnameClustSizeXvsX;
768 fProfClustSizeXvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5);
769 fProfClustSizeXvsX[nhist]->SetName(aux.Data());
770 fProfClustSizeXvsX[nhist]->SetTitle(aux.Data());
772 aux=profnameClustSizeZvsX;
774 fProfClustSizeZvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5);
775 fProfClustSizeZvsX[nhist]->SetName(aux.Data());
776 fProfClustSizeZvsX[nhist]->SetTitle(aux.Data());
781 //__________________________________________________________
782 void AliITSPlaneEffSDD::DeleteHistos() {
784 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
785 delete [] fHisResX; fHisResX=0;
788 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
789 delete [] fHisResZ; fHisResZ=0;
792 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
793 delete [] fHisResXZ; fHisResXZ=0;
795 if(fHisClusterSize) {
796 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
797 delete [] fHisClusterSize; fHisClusterSize=0;
800 for (Int_t i=0; i<kNHisto; i++ ) {
801 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResXclu[i][clu]) delete fHisResXclu[i][clu];
802 delete [] fHisResXclu[i];
804 delete [] fHisResXclu;
808 for (Int_t i=0; i<kNHisto; i++ ) {
809 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResZclu[i][clu]) delete fHisResZclu[i][clu];
810 delete [] fHisResZclu[i];
812 delete [] fHisResZclu;
816 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResXvsX[i];
817 delete [] fProfResXvsX; fProfResXvsX=0;
820 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResZvsX[i];
821 delete [] fProfResZvsX; fProfResZvsX=0;
823 if(fProfClustSizeXvsX) {
824 for (Int_t i=0; i<kNHisto; i++ ) delete fProfClustSizeXvsX[i];
825 delete [] fProfClustSizeXvsX; fProfClustSizeXvsX=0;
827 if(fProfClustSizeZvsX) {
828 for (Int_t i=0; i<kNHisto; i++ ) delete fProfClustSizeZvsX[i];
829 delete [] fProfClustSizeZvsX; fProfClustSizeZvsX=0;
834 //__________________________________________________________
835 Bool_t AliITSPlaneEffSDD::FillHistos(UInt_t key, Bool_t found,
836 Float_t tXZ[2], Float_t cXZ[2], Int_t ctXZ[2]) {
837 // this method fill the histograms
838 // input: - key: unique key of the basic block
839 // - found: Boolean to asses whether a cluster has been associated to the track or not
840 // - tXZ[2] local X and Z coordinates of the track prediction
841 // - cXZ[2] local X and Z coordinates of the cluster associated to the track
842 // - ctXZ[2] cluster size in X and Z (min =1 for real cluster)
843 // output: kTRUE if filling was succesfull kFALSE otherwise
844 // side effects: updating of the histograms.
847 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
850 if(key>=kNModule*kNChip*kNWing*kNSubWing)
851 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
852 Int_t id=GetModFromKey(key);
854 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
856 Float_t resx=tXZ[0]-cXZ[0];
857 Float_t resz=tXZ[1]-cXZ[1];
858 fHisResX[id]->Fill(resx);
859 fHisResZ[id]->Fill(resz);
860 fHisResXZ[id]->Fill(resx,resz);
861 fHisClusterSize[id]->Fill((Double_t)ctXZ[0],(Double_t)ctXZ[1]);
862 if(ctXZ[0]>0 && ctXZ[0]<=kNclu) fHisResXclu[id][ctXZ[0]-1]->Fill(resx);
863 if(ctXZ[1]>0 && ctXZ[1]<=kNclu) fHisResZclu[id][ctXZ[1]-1]->Fill(resx);
864 fProfResXvsX[id]->Fill(cXZ[0],resx);
865 fProfResZvsX[id]->Fill(cXZ[0],resz);
866 fProfClustSizeXvsX[id]->Fill(cXZ[0],(Double_t)ctXZ[0]);
867 fProfClustSizeZvsX[id]->Fill(cXZ[0],(Double_t)ctXZ[1]);
871 //__________________________________________________________
872 Bool_t AliITSPlaneEffSDD::WriteHistosToFile(TString filename, Option_t* option) {
874 // Saves the histograms into a tree and saves the trees into a file
876 if (!fHis) return kFALSE;
877 if (filename.Data()=="") {
878 AliWarning("WriteHistosToFile: null output filename!");
882 TFile *hFile=new TFile(filename.Data(),option,
883 "The File containing the TREEs with ITS PlaneEff Histos");
884 TTree *SDDTree=new TTree("SDDTree","Tree whith Residuals and Cluster Type distributions for SDD");
887 TH2I *histClusterType;
888 TH1F *histXclu[kNclu];
889 TH1F *histZclu[kNclu];
890 TProfile *profileResXvsX, *profileResZvsX, *profileClSizXvsX, *profileClSizZvsX;
895 histClusterType=new TH2I();
896 for(Int_t clu=0;clu<kNclu;clu++) {
897 histXclu[clu]=new TH1F();
898 histZclu[clu]=new TH1F();
900 profileResXvsX=new TProfile();
901 profileResZvsX=new TProfile();
902 profileClSizXvsX=new TProfile();
903 profileClSizZvsX=new TProfile();
905 SDDTree->Branch("histX","TH1F",&histX,128000,0);
906 SDDTree->Branch("histZ","TH1F",&histZ,128000,0);
907 SDDTree->Branch("histXZ","TH2F",&histXZ,128000,0);
908 SDDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
909 for(Int_t clu=0;clu<kNclu;clu++) {
910 sprintf(branchname,"histXclu_%d",clu+1);
911 SDDTree->Branch(branchname,"TH1F",&histXclu[clu],128000,0);
912 sprintf(branchname,"histZclu_%d",clu+1);
913 SDDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0);
915 SDDTree->Branch("profileResXvsX","TProfile",&profileResXvsX,128000,0);
916 SDDTree->Branch("profileResZvsX","TProfile",&profileResZvsX,128000,0);
917 SDDTree->Branch("profileClSizXvsX","TProfile",&profileClSizXvsX,128000,0);
918 SDDTree->Branch("profileClSizZvsX","TProfile",&profileClSizZvsX,128000,0);
920 for(Int_t j=0;j<kNHisto;j++){
924 histClusterType=fHisClusterSize[j];
925 for(Int_t clu=0;clu<kNclu;clu++) {
926 histXclu[clu]=fHisResXclu[j][clu];
927 histZclu[clu]=fHisResZclu[j][clu];
929 profileResXvsX=fProfResXvsX[j];
930 profileResZvsX=fProfResZvsX[j];
931 profileClSizXvsX=fProfClustSizeXvsX[j];
932 profileClSizZvsX=fProfClustSizeZvsX[j];
940 //__________________________________________________________
941 Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
943 // Read histograms from an already existing file
945 if (!fHis) return kFALSE;
946 if (filename.Data()=="") {
947 AliWarning("ReadHistosFromFile: incorrect output filename!");
957 TFile *file=TFile::Open(filename.Data(),"READONLY");
959 if (!file || file->IsZombie()) {
960 AliWarning(Form("Can't open %s !",filename.Data()));
964 TTree *tree = (TTree*) file->Get("SDDTree");
966 TBranch *histX = (TBranch*) tree->GetBranch("histX");
967 TBranch *histZ = (TBranch*) tree->GetBranch("histZ");
968 TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ");
969 TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType");
971 TBranch *histXclu[kNclu], *histZclu[kNclu];
972 for(Int_t clu=0; clu<kNclu; clu++) {
973 sprintf(branchname,"histXclu_%d",clu+1);
974 histXclu[clu]= (TBranch*) tree->GetBranch(branchname);
975 sprintf(branchname,"histZclu_%d",clu+1);
976 histZclu[clu]= (TBranch*) tree->GetBranch(branchname);
978 TBranch *profileResXvsX = (TBranch*) tree->GetBranch("profileResXvsX");
979 TBranch *profileResZvsX = (TBranch*) tree->GetBranch("profileResZvsX");
980 TBranch *profileClSizXvsX = (TBranch*) tree->GetBranch("profileClSizXvsX");
981 TBranch *profileClSizZvsX = (TBranch*) tree->GetBranch("profileClSizZvsX");
985 Int_t nevent = (Int_t)histX->GetEntries();
987 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
988 histX->SetAddress(&h);
989 for(Int_t j=0;j<kNHisto;j++){
995 nevent = (Int_t)histZ->GetEntries();
997 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
998 histZ->SetAddress(&h);
999 for(Int_t j=0;j<kNHisto;j++){
1002 fHisResZ[j]->Add(h);
1005 nevent = (Int_t)histXZ->GetEntries();
1007 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1008 histXZ->SetAddress(&h2);
1009 for(Int_t j=0;j<kNHisto;j++){
1011 histXZ->GetEntry(j);
1012 fHisResXZ[j]->Add(h2);
1015 nevent = (Int_t)histClusterType->GetEntries();
1017 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1018 histClusterType->SetAddress(&h2i);
1019 for(Int_t j=0;j<kNHisto;j++){
1021 histClusterType->GetEntry(j);
1022 fHisClusterSize[j]->Add(h2i);
1025 for(Int_t clu=0; clu<kNclu; clu++) {
1027 nevent = (Int_t)histXclu[clu]->GetEntries();
1029 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1030 histXclu[clu]->SetAddress(&h);
1031 for(Int_t j=0;j<kNHisto;j++){
1033 histXclu[clu]->GetEntry(j);
1034 fHisResXclu[j][clu]->Add(h);
1037 nevent = (Int_t)histZclu[clu]->GetEntries();
1039 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1040 histZclu[clu]->SetAddress(&h);
1041 for(Int_t j=0;j<kNHisto;j++){
1043 histZclu[clu]->GetEntry(j);
1044 fHisResZclu[j][clu]->Add(h);
1048 nevent = (Int_t)profileResXvsX->GetEntries();
1050 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1051 profileResXvsX->SetAddress(&p);
1052 for(Int_t j=0;j<kNHisto;j++){
1054 profileResXvsX->GetEntry(j);
1055 fProfResXvsX[j]->Add(p);
1058 nevent = (Int_t)profileResZvsX->GetEntries();
1060 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1061 profileResZvsX->SetAddress(&p);
1062 for(Int_t j=0;j<kNHisto;j++){
1064 profileResZvsX->GetEntry(j);
1065 fProfResZvsX[j]->Add(p);
1068 nevent = (Int_t)profileClSizXvsX->GetEntries();
1070 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1071 profileClSizXvsX->SetAddress(&p);
1072 for(Int_t j=0;j<kNHisto;j++){
1074 profileClSizXvsX->GetEntry(j);
1075 fProfClustSizeXvsX[j]->Add(p);
1078 nevent = (Int_t)profileClSizZvsX->GetEntries();
1080 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1081 profileClSizZvsX->SetAddress(&p);
1082 for(Int_t j=0;j<kNHisto;j++){
1084 profileClSizZvsX->GetEntry(j);
1085 fProfClustSizeZvsX[j]->Add(p);