Another histos for lumi
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSPD.cxx
CommitLineData
4a66240a 1/**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15///////////////////////////////////////////////////////////////////////////
16// Plane Efficiency class for ITS
17// It is used for chip by chip efficiency of the SPD,
18// evaluated by tracks
19// (Inherits from AliITSPlaneEff)
20// Author: G.E. Bruno
21// giuseppe.bruno@ba.infn.it
22//
23///////////////////////////////////////////////////////////////////////////
24
25/* $Id$ */
26
6344adcc 27#include <TMath.h>
5fbd4fd6 28#include <TH1F.h>
29#include <TFile.h>
30#include <TTree.h>
31#include <TROOT.h>
4a66240a 32#include "AliITSPlaneEffSPD.h"
33#include "AliLog.h"
34#include "AliCDBStorage.h"
35#include "AliCDBEntry.h"
36#include "AliCDBManager.h"
37//#include "AliCDBRunRange.h"
41d18cd2 38#include "AliITSsegmentationSPD.h"
4a66240a 39#include "AliITSCalibrationSPD.h"
40
41ClassImp(AliITSPlaneEffSPD)
42//______________________________________________________________________
43AliITSPlaneEffSPD::AliITSPlaneEffSPD():
5fbd4fd6 44 AliITSPlaneEff(),
5fbd4fd6 45 fHisResX(0),
46 fHisResZ(0),
47 fHisResXZ(0),
48 fHisClusterSize(0),
49 fHisResXclu(0),
1cc5cedc 50 fHisResZclu(0),
51 fHisResXchip(0),
52 fHisResZchip(0),
879cdb02 53 fProfResXvsPhi(0),
54 fProfResZvsDip(0),
55 fProfResXvsPhiclu(0),
56 fProfResZvsDipclu(0),
1cc5cedc 57 fHisTrackErrX(0),
58 fHisTrackErrZ(0),
59 fHisClusErrX(0),
1f1e7832 60 fHisClusErrZ(0),
61 fHisTrackXFOtrue(0),
62 fHisTrackZFOtrue(0),
63 fHisTrackXFOfalse(0),
64 fHisTrackZFOfalse(0),
65 fHisTrackXZFOtrue(0),
66 fHisTrackXZFOfalse(0){
67 for (UInt_t i=0; i<kNModule*kNChip*(kNClockPhase+1); i++){
4a66240a 68 fFound[i]=0;
69 fTried[i]=0;
70 }
1f1e7832 71 // default constructor
4a66240a 72 AliDebug(1,Form("Calling default constructor"));
73}
74//______________________________________________________________________
75AliITSPlaneEffSPD::~AliITSPlaneEffSPD(){
76 // destructor
77 // Inputs:
78 // none.
79 // Outputs:
80 // none.
81 // Return:
82 // none.
5fbd4fd6 83 DeleteHistos();
4a66240a 84}
85//______________________________________________________________________
5fbd4fd6 86AliITSPlaneEffSPD::AliITSPlaneEffSPD(const AliITSPlaneEffSPD &s) : AliITSPlaneEff(s),
4a66240a 87//fHis(s.fHis),
5fbd4fd6 88fHisResX(0),
89fHisResZ(0),
90fHisResXZ(0),
91fHisClusterSize(0),
92fHisResXclu(0),
1cc5cedc 93fHisResZclu(0),
94fHisResXchip(0),
95fHisResZchip(0),
879cdb02 96fProfResXvsPhi(0),
97fProfResZvsDip(0),
98fProfResXvsPhiclu(0),
99fProfResZvsDipclu(0),
1cc5cedc 100fHisTrackErrX(0),
101fHisTrackErrZ(0),
102fHisClusErrX(0),
1f1e7832 103fHisClusErrZ(0),
104fHisTrackXFOtrue(0),
105fHisTrackZFOtrue(0),
106fHisTrackXFOfalse(0),
107fHisTrackZFOfalse(0),
108fHisTrackXZFOtrue(0),
109fHisTrackXZFOfalse(0)
4a66240a 110{
111 // Copy Constructor
112 // Inputs:
113 // AliITSPlaneEffSPD &s The original class for which
114 // this class is a copy of
115 // Outputs:
116 // none.
117 // Return:
118
1f1e7832 119 for (UInt_t i=0; i<kNModule*kNChip*(kNClockPhase+1); i++){
5fbd4fd6 120 fFound[i]=s.fFound[i];
121 fTried[i]=s.fTried[i];
122 }
123 if(fHis) {
124 InitHistos();
125 for(Int_t i=0; i<kNHisto; i++) {
126 s.fHisResX[i]->Copy(*fHisResX[i]);
127 s.fHisResZ[i]->Copy(*fHisResZ[i]);
128 s.fHisResXZ[i]->Copy(*fHisResXZ[i]);
129 s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]);
130 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
131 s.fHisResXclu[i][clu]->Copy(*fHisResXclu[i][clu]);
132 s.fHisResZclu[i][clu]->Copy(*fHisResZclu[i][clu]);
879cdb02 133 s.fProfResXvsPhiclu[i][clu]->Copy(*fProfResXvsPhiclu[i][clu]);
134 s.fProfResZvsDipclu[i][clu]->Copy(*fProfResZvsDipclu[i][clu]);
5fbd4fd6 135 }
1cc5cedc 136 for(Int_t chip=0; chip<kNChip; chip++) {
137 s.fHisResXchip[i][chip]->Copy(*fHisResXchip[i][chip]);
138 s.fHisResZchip[i][chip]->Copy(*fHisResZchip[i][chip]);
139 }
879cdb02 140 s.fProfResXvsPhi[i]->Copy(*fProfResXvsPhi[i]);
141 s.fProfResZvsDip[i]->Copy(*fProfResZvsDip[i]);
1cc5cedc 142 s.fHisTrackErrX[i]->Copy(*fHisTrackErrX[i]);
143 s.fHisTrackErrZ[i]->Copy(*fHisTrackErrZ[i]);
144 s.fHisClusErrX[i]->Copy(*fHisClusErrX[i]);
145 s.fHisClusErrZ[i]->Copy(*fHisClusErrZ[i]);
1f1e7832 146 for(Int_t phas=0; phas<kNClockPhase;phas++){
147 s.fHisTrackXFOtrue[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
148 s.fHisTrackZFOtrue[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
149 s.fHisTrackXFOfalse[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
150 s.fHisTrackZFOfalse[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
151 s.fHisTrackXZFOtrue[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
152 s.fHisTrackXZFOfalse[i][phas]->Copy(*fHisTrackXFOtrue[i][phas]);
153 }
5fbd4fd6 154 }
155 }
4a66240a 156}
157//_________________________________________________________________________
158AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator+=(const AliITSPlaneEffSPD &add){
159 // Add-to-me operator
160 // Inputs:
161 // const AliITSPlaneEffSPD &add simulation class to be added
162 // Outputs:
163 // none.
164 // Return:
165 // none
1f1e7832 166 for (UInt_t i=0; i<kNModule*kNChip*(kNClockPhase+1); i++){
4a66240a 167 fFound[i] += add.fFound[i];
168 fTried[i] += add.fTried[i];
169 }
5fbd4fd6 170 if(fHis && add.fHis) {
171 for(Int_t i=0; i<kNHisto; i++) {
172 fHisResX[i]->Add(add.fHisResX[i]);
173 fHisResZ[i]->Add(add.fHisResZ[i]);
174 fHisResXZ[i]->Add(add.fHisResXZ[i]);
175 fHisClusterSize[i]->Add(add.fHisClusterSize[i]);
176 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
177 fHisResXclu[i][clu]->Add(add.fHisResXclu[i][clu]);
178 fHisResZclu[i][clu]->Add(add.fHisResZclu[i][clu]);
879cdb02 179 fProfResXvsPhiclu[i][clu]->Add(add.fProfResXvsPhiclu[i][clu]);
180 fProfResZvsDipclu[i][clu]->Add(add.fProfResZvsDipclu[i][clu]);
5fbd4fd6 181 }
1cc5cedc 182 for(Int_t chip=0; chip<kNChip; chip++) {
183 fHisResXchip[i][chip]->Add(add.fHisResXchip[i][chip]);
184 fHisResZchip[i][chip]->Add(add.fHisResZchip[i][chip]);
185 }
879cdb02 186 fProfResXvsPhi[i]->Add(add.fProfResXvsPhi[i]);
187 fProfResZvsDip[i]->Add(add.fProfResZvsDip[i]);
1cc5cedc 188 fHisTrackErrX[i]->Add(add.fHisTrackErrX[i]);
189 fHisTrackErrZ[i]->Add(add.fHisTrackErrZ[i]);
190 fHisClusErrX[i]->Add(add.fHisClusErrX[i]);
191 fHisClusErrZ[i]->Add(add.fHisClusErrZ[i]);
1f1e7832 192 for(Int_t phas=0; phas<kNClockPhase;phas++){
193 fHisTrackXFOtrue[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
194 fHisTrackZFOtrue[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
195 fHisTrackXFOfalse[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
196 fHisTrackZFOfalse[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
197 fHisTrackXZFOtrue[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
198 fHisTrackXZFOfalse[i][phas]->Add(add.fHisTrackXFOtrue[i][phas]);
199 }
5fbd4fd6 200 }
201 }
4a66240a 202 return *this;
203}
204//______________________________________________________________________
205AliITSPlaneEffSPD& AliITSPlaneEffSPD::operator=(const
206 AliITSPlaneEffSPD &s){
207 // Assignment operator
208 // Inputs:
209 // AliITSPlaneEffSPD &s The original class for which
210 // this class is a copy of
211 // Outputs:
212 // none.
213 // Return:
214
215 if(this==&s) return *this;
31bfdbde 216 this->~AliITSPlaneEffSPD();
217 new(this) AliITSPlaneEffSPD();
4a66240a 218 s.Copy(*this);
4a66240a 219 return *this;
220}
221//______________________________________________________________________
222void AliITSPlaneEffSPD::Copy(TObject &obj) const {
223 // protected method. copy this to obj
224 AliITSPlaneEff::Copy(obj);
5fbd4fd6 225 AliITSPlaneEffSPD& target = (AliITSPlaneEffSPD &) obj;
1f1e7832 226 for(Int_t i=0;i<kNModule*kNChip*(kNClockPhase+1);i++) {
5fbd4fd6 227 target.fFound[i] = fFound[i];
228 target.fTried[i] = fTried[i];
229 }
230 CopyHistos(target);
231 return;
232}
233//_______________________________________________________________________
234void AliITSPlaneEffSPD::CopyHistos(AliITSPlaneEffSPD &target) const {
235 // protected method: copy histos from this to target
236 target.fHis = fHis; // this is redundant only in some cases. Leave as it is.
237 if(fHis) {
238 target.fHisResX=new TH1F*[kNHisto];
239 target.fHisResZ=new TH1F*[kNHisto];
240 target.fHisResXZ=new TH2F*[kNHisto];
241 target.fHisClusterSize=new TH2I*[kNHisto];
242 target.fHisResXclu=new TH1F**[kNHisto];
243 target.fHisResZclu=new TH1F**[kNHisto];
1cc5cedc 244 target.fHisResXchip=new TH1F**[kNHisto];
245 target.fHisResZchip=new TH1F**[kNHisto];
879cdb02 246 target.fProfResXvsPhi=new TProfile*[kNHisto];
247 target.fProfResZvsDip=new TProfile*[kNHisto];
248 target.fProfResXvsPhiclu=new TProfile**[kNHisto];
249 target.fProfResZvsDipclu=new TProfile**[kNHisto];
1cc5cedc 250 target.fHisTrackErrX=new TH1F*[kNHisto];
251 target.fHisTrackErrZ=new TH1F*[kNHisto];
252 target.fHisClusErrX=new TH1F*[kNHisto];
253 target.fHisClusErrZ=new TH1F*[kNHisto];
1f1e7832 254 target.fHisTrackXFOtrue=new TH1F**[kNHisto];
255 target.fHisTrackZFOtrue=new TH1F**[kNHisto];
256 target.fHisTrackXFOfalse=new TH1F**[kNHisto];
257 target.fHisTrackZFOfalse=new TH1F**[kNHisto];
258 target.fHisTrackXZFOtrue=new TH2F**[kNHisto];
259 target.fHisTrackXZFOfalse=new TH2F**[kNHisto];
5fbd4fd6 260 for(Int_t i=0; i<kNHisto; i++) {
261 target.fHisResX[i] = new TH1F(*fHisResX[i]);
262 target.fHisResZ[i] = new TH1F(*fHisResZ[i]);
263 target.fHisResXZ[i] = new TH2F(*fHisResXZ[i]);
264 target.fHisClusterSize[i] = new TH2I(*fHisClusterSize[i]);
265 target.fHisResXclu[i]=new TH1F*[kNclu];
266 target.fHisResZclu[i]=new TH1F*[kNclu];
879cdb02 267 target.fProfResXvsPhiclu[i]=new TProfile*[kNclu];
268 target.fProfResZvsDipclu[i]=new TProfile*[kNclu];
5fbd4fd6 269 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
270 target.fHisResXclu[i][clu] = new TH1F(*fHisResXclu[i][clu]);
271 target.fHisResZclu[i][clu] = new TH1F(*fHisResZclu[i][clu]);
879cdb02 272 target.fProfResXvsPhiclu[i][clu] = new TProfile(*fProfResXvsPhiclu[i][clu]);
273 target.fProfResZvsDipclu[i][clu] = new TProfile(*fProfResZvsDipclu[i][clu]);
5fbd4fd6 274 }
1cc5cedc 275 target.fHisResXchip[i]=new TH1F*[kNChip];
276 target.fHisResZchip[i]=new TH1F*[kNChip];
277 for(Int_t chip=0; chip<kNChip; chip++) {
278 target.fHisResXchip[i][chip] = new TH1F(*fHisResXchip[i][chip]);
279 target.fHisResZchip[i][chip] = new TH1F(*fHisResZchip[i][chip]);
280 }
879cdb02 281 target.fProfResXvsPhi[i] = new TProfile(*fProfResXvsPhi[i]);
282 target.fProfResZvsDip[i] = new TProfile(*fProfResZvsDip[i]);
1cc5cedc 283 target.fHisTrackErrX[i] = new TH1F(*fHisTrackErrX[i]);
284 target.fHisTrackErrZ[i] = new TH1F(*fHisTrackErrZ[i]);
285 target.fHisClusErrX[i] = new TH1F(*fHisClusErrX[i]);
286 target.fHisClusErrZ[i] = new TH1F(*fHisClusErrZ[i]);
1f1e7832 287
288 target.fHisTrackXFOtrue[i]=new TH1F*[kNClockPhase];
289 target.fHisTrackZFOtrue[i]=new TH1F*[kNClockPhase];
290 target.fHisTrackXFOfalse[i]=new TH1F*[kNClockPhase];
291 target.fHisTrackZFOfalse[i]=new TH1F*[kNClockPhase];
292 target.fHisTrackXZFOtrue[i]=new TH2F*[kNClockPhase];
293 target.fHisTrackXZFOfalse[i]=new TH2F*[kNClockPhase];
294 for(Int_t phas=0; phas<kNClockPhase;phas++){
295 target.fHisTrackXFOtrue[i][phas]=new TH1F(*fHisTrackXFOtrue[i][phas]);
296 target.fHisTrackZFOtrue[i][phas]=new TH1F(*fHisTrackZFOtrue[i][phas]);
297 target.fHisTrackXFOfalse[i][phas]=new TH1F(*fHisTrackXFOfalse[i][phas]);
298 target.fHisTrackZFOfalse[i][phas]=new TH1F(*fHisTrackZFOfalse[i][phas]);
299 target.fHisTrackXZFOtrue[i][phas]=new TH2F(*fHisTrackXZFOtrue[i][phas]);
300 target.fHisTrackXZFOfalse[i][phas]=new TH2F(*fHisTrackXZFOfalse[i][phas]);
301 }
5fbd4fd6 302 }
4a66240a 303 }
5fbd4fd6 304return;
4a66240a 305}
4a66240a 306
4a66240a 307//_______________________________________________________________________
308Int_t AliITSPlaneEffSPD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
309 UInt_t im, UInt_t ic) const {
310
311 // Estimate the number of tracks still to be collected to attain a
312 // given efficiency eff, with relative error RelErr
313 // Inputs:
314 // eff -> Expected efficiency (e.g. those from actual estimate)
315 // RelErr -> tollerance [0,1]
1f1e7832 316 // im -> module number [0,239]
6344adcc 317 // ic -> chip number [0,4]
4a66240a 318 // Outputs: none
319 // Return: the estimated n. of tracks
320 //
321if (im>=kNModule || ic>=kNChip)
7167ae53 322 {AliError("GetMissingTracksForGivenEff: you asked for a non existing chip");
4a66240a 323 return -1;}
879cdb02 324else {
325 UInt_t key=GetKey(im,ic);
326 if(key<kNModule*kNChip) return GetNTracksForGivenEff(eff,RelErr)-fTried[key];
327 else return -1;
328}
4a66240a 329}
330//_________________________________________________________________________
1f1e7832 331Double_t AliITSPlaneEffSPD::PlaneEff(const UInt_t im,const UInt_t ic, const Bool_t fo, const UInt_t bcm4) const {
4a66240a 332// Compute the efficiency for a basic block,
333// Inputs:
1f1e7832 334// im -> module number [0,239]
6344adcc 335// ic -> chip number [0,4]
1f1e7832 336// fo -> boolean, true in case of Fast Or studies
337// bcm4 -> for Fast Or: bunch crossing % 4
4a66240a 338if (im>=kNModule || ic>=kNChip)
7167ae53 339 {AliError("PlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
1f1e7832 340if(fo && bcm4>=kNClockPhase)
341 {AliError("PlaneEff(Uint_t,Uint_t): you asked for Fast Or in a wrong phase"); return -1.;}
879cdb02 342Int_t nf=-1;
343Int_t nt=-1;
1f1e7832 344if(fo) {
345 AliWarning("PlaneEff: you asked for FO efficiency");
712843e5 346 UInt_t key=GetKey(im,ic,fo,bcm4);
347 if(key<kNModule*kNChip*(kNClockPhase+1)) {
348 nf=fFound[key];
349 nt=fTried[key];
350 }
1f1e7832 351} else {
712843e5 352 UInt_t key=GetKey(im,ic);
353 if (key<kNModule*kNChip) {
354 nf=fFound[key];
355 nt=fTried[key];
356 }
879cdb02 357}
4a66240a 358return AliITSPlaneEff::PlaneEff(nf,nt);
359}
360//_________________________________________________________________________
1f1e7832 361Double_t AliITSPlaneEffSPD::ErrPlaneEff(const UInt_t im,const UInt_t ic, const Bool_t fo, const UInt_t bcm4) const {
4a66240a 362 // Compute the statistical error on efficiency for a basic block,
363 // using binomial statistics
364 // Inputs:
1f1e7832 365 // im -> module number [0,239]
6344adcc 366 // ic -> chip number [0,4]
1f1e7832 367// fo -> boolean, true in case of Fast Or studies
368// bcm4 -> for Fast Or: bunch crossing % 4
4a66240a 369if (im>=kNModule || ic>=kNChip)
7167ae53 370 {AliError("ErrPlaneEff(Uint_t,Uint_t): you asked for a non existing chip"); return -1.;}
1f1e7832 371if(fo && bcm4>=kNClockPhase)
372 {AliError("PlaneEff(Uint_t,Uint_t): you asked for Fast Or in a wrong phase"); return -1.;}
879cdb02 373Int_t nf=-1;
374Int_t nt=-1;
1f1e7832 375if(fo) {
376 AliWarning("ErrPlaneEff: you asked for FO efficiency");
712843e5 377 UInt_t key=GetKey(im,ic,fo,bcm4);
378 if(key<kNModule*kNChip*(kNClockPhase+1)) {
379 nf=fFound[key];
380 nt=fTried[key];
381 }
1f1e7832 382} else {
712843e5 383 UInt_t key=GetKey(im,ic);
384 if (key<kNModule*kNChip) {
385 nf=fFound[key];
386 nt=fTried[key];
387 }
879cdb02 388}
4a66240a 389return AliITSPlaneEff::ErrPlaneEff(nf,nt);
390}
391//_________________________________________________________________________
392Bool_t AliITSPlaneEffSPD::UpDatePlaneEff(const Bool_t Kfound,
1f1e7832 393 const UInt_t im, const UInt_t ic, const Bool_t fo, const UInt_t bcm4) {
4a66240a 394 // Update efficiency for a basic block
395if (im>=kNModule || ic>=kNChip)
7167ae53 396 {AliError("UpDatePlaneEff: you asked for a non existing chip"); return kFALSE;}
1f1e7832 397if(fo && bcm4>=kNClockPhase)
398 {AliError("UpDatePlaneEff: you asked for Fast Or in a wrong phase"); return kFALSE;}
399if (!fo) {
712843e5 400 UInt_t key=GetKey(im,ic);
401 if(key<kNModule*kNChip) {
402 fTried[key]++;
403 if(Kfound) fFound[key]++;
404 return kTRUE;
405 }
1f1e7832 406}
407else {
712843e5 408 UInt_t key=GetKey(im,ic,fo,bcm4);
d66f160c 409 if(key<kNModule*kNChip*(kNClockPhase+1)) {
712843e5 410 fTried[key]++;
411 if(Kfound) fFound[key]++;
412 return kTRUE;
413 }
1f1e7832 414}
415return kFALSE;
4a66240a 416}
417//_________________________________________________________________________
6344adcc 418UInt_t AliITSPlaneEffSPD::GetChipFromCol(const UInt_t col) const {
4a66240a 419 // get chip given the column
420if(col>=kNCol*kNChip)
7167ae53 421 {AliDebug(1,Form("GetChipFromCol: you asked for a non existing column %d",col)); return 10;}
4a66240a 422return col/kNCol;
423}
424//__________________________________________________________________________
1f1e7832 425UInt_t AliITSPlaneEffSPD::GetKey(const UInt_t mod, const UInt_t chip, const Bool_t FO, const UInt_t BCm4) const {
4a66240a 426 // get key given a basic block
1f1e7832 427UInt_t key=99999;
4a66240a 428if(mod>=kNModule || chip>=kNChip)
73f56096 429 {AliDebug(1,"GetKey: you asked for a non existing block"); return 99999;}
1f1e7832 430key = mod*kNChip+chip;
431if(FO) {
73f56096 432 if(BCm4>= kNClockPhase) {AliDebug(1,"GetKey: you have asked Fast OR and a non exisiting BC modulo 4"); return 99999;}
1f1e7832 433 key += kNModule*kNChip*(BCm4+1);
434}
435return key;
436}
437//__________________________________________________________________________
438UInt_t AliITSPlaneEffSPD::SwitchChipKeyNumbering(UInt_t key) const {
439
440// methods to switch from offline chip key numbering
441// to online Raw Stream chip numbering and viceversa.
442// Used for Fast-Or studies.
443// Implemented by valerio.altini@ba.infn.it
444
445if(key>=kNModule*kNChip*(kNClockPhase+1))
73f56096 446 {AliDebug(1,"SwitchChipKeyNumbering: you asked for a non existing key"); return 99999;}
1f1e7832 447UInt_t mod=9999,chip=9999,phase=9999;
448GetModAndChipFromKey(key,mod,chip);
449if(mod<kNModuleLy1) chip = kNChip-(chip+1);
450if(IsForFO(key))phase = GetBCm4FromKey(key);
451
452return GetKey(mod,chip,IsForFO(key),phase);
453
4a66240a 454}
455//__________________________________________________________________________
456UInt_t AliITSPlaneEffSPD::GetModFromKey(const UInt_t key) const {
457 // get mod. from key
1f1e7832 458if(key>=kNModule*kNChip*(kNClockPhase+1))
7167ae53 459 {AliError("GetModFromKey: you asked for a non existing key"); return 9999;}
1f1e7832 460return (key%(kNModule*kNChip))/kNChip;
4a66240a 461}
462//__________________________________________________________________________
463UInt_t AliITSPlaneEffSPD::GetChipFromKey(const UInt_t key) const {
464 // retrieves chip from key
1f1e7832 465if(key>=kNModule*kNChip*(kNClockPhase+1))
7167ae53 466 {AliError("GetChipFromKey: you asked for a non existing key"); return 999;}
1f1e7832 467return ((key%(kNModule*kNChip))%(kNModule*kNChip))%kNChip;
468}
469//__________________________________________________________________________
470UInt_t AliITSPlaneEffSPD::GetBCm4FromKey(const UInt_t key) const {
471 // retrieves the "Bunch Crossing modulo 4" (for Fast Or studies)
472if(key>=kNModule*kNChip*(kNClockPhase+1))
473 {AliError("GetBCm4FromKey: you asked for a non existing key"); return 999;}
474if(key<kNModule*kNChip)
73f56096 475 {AliDebug(1,"GetBCm4FromKey: key is below 1200, why are you asking for FO related stuff"); return 999;}
1f1e7832 476
477return key/(kNModule*kNChip) - 1 ;
478}
479//__________________________________________________________________________
480Bool_t AliITSPlaneEffSPD::IsForFO(const UInt_t key) const {
481if(key>=kNModule*kNChip) return kTRUE;
482else return kFALSE;
4a66240a 483}
484//__________________________________________________________________________
485void AliITSPlaneEffSPD::GetModAndChipFromKey(const UInt_t key,UInt_t& mod,UInt_t& chip) const {
486 // get module and chip from a key
1f1e7832 487if(key>=kNModule*kNChip*(kNClockPhase+1))
7167ae53 488 {AliError("GetModAndChipFromKey: you asked for a non existing key");
4a66240a 489 mod=9999;
490 chip=999;
491 return;}
1f1e7832 492mod=GetModFromKey(key);
493chip=GetChipFromKey(key);
4a66240a 494return;
495}
496//____________________________________________________________________________
497Double_t AliITSPlaneEffSPD::LivePlaneEff(UInt_t key) const {
6344adcc 498 // returns plane efficieny after adding the fraction of sensor which is bad
4a66240a 499if(key>=kNModule*kNChip)
7167ae53 500 {AliError("LivePlaneEff: you asked for a non existing key");
4a66240a 501 return -1.;}
6344adcc 502Double_t leff=AliITSPlaneEff::LivePlaneEff(0); // this just for the Warning
503leff=PlaneEff(key)+GetFracBad(key);
504return leff>1?1:leff;
4a66240a 505}
506//____________________________________________________________________________
507Double_t AliITSPlaneEffSPD::ErrLivePlaneEff(UInt_t key) const {
508 // returns error on live plane efficiency
509if(key>=kNModule*kNChip)
7167ae53 510 {AliError("ErrLivePlaneEff: you asked for a non existing key");
4a66240a 511 return -1.;}
6344adcc 512Int_t nf=fFound[key];
513Double_t triedInLive=GetFracLive(key)*fTried[key];
514Int_t nt=TMath::Max(nf,TMath::Nint(triedInLive));
515return AliITSPlaneEff::ErrPlaneEff(nf,nt); // for the time being: to be checked
4a66240a 516}
517//_____________________________________________________________________________
518Double_t AliITSPlaneEffSPD::GetFracLive(const UInt_t key) const {
519 // returns the fraction of the sensor which is OK
520if(key>=kNModule*kNChip)
7167ae53 521 {AliError("GetFracLive: you asked for a non existing key");
4a66240a 522 return -1.;}
523 // Compute the fraction of bad (dead+noisy) detector
524UInt_t dead=0,noisy=0;
525GetDeadAndNoisyInChip(key,dead,noisy);
526Double_t live=dead+noisy;
527live/=(kNRow*kNCol);
528return 1.-live;
529}
530//_____________________________________________________________________________
531void AliITSPlaneEffSPD::GetDeadAndNoisyInChip(const UInt_t key,
532 UInt_t& nrDeadInChip, UInt_t& nrNoisyInChip) const {
533 // returns the number of dead and noisy pixels
534nrDeadInChip=0;
535nrNoisyInChip=0;
536if(key>=kNModule*kNChip)
7167ae53 537 {AliError("GetDeadAndNoisyInChip: you asked for a non existing key");
4a66240a 538 return;}
539 // Compute the number of bad (dead+noisy) pixel in a chip
540//
541if(!fInitCDBCalled)
7167ae53 542 {AliError("GetDeadAndNoisyInChip: CDB not inizialized: call InitCDB first");
4a66240a 543 return;};
544AliCDBManager* man = AliCDBManager::Instance();
545// retrieve map of dead Pixel
546AliCDBEntry *cdbSPDDead = man->Get("ITS/Calib/SPDDead", fRunNumber);
547TObjArray* spdDead;
548if(cdbSPDDead) {
549 spdDead = (TObjArray*)cdbSPDDead->GetObject();
550 if(!spdDead)
7167ae53 551 {AliError("GetDeadAndNoisyInChip: SPDDead not found in CDB");
4a66240a 552 return;}
553} else {
7167ae53 554 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDDead.");
4a66240a 555 return;
556}
9806b6f8 557// retrieve map of sparse dead Pixel
558AliCDBEntry *cdbSPDSparseDead = man->Get("ITS/Calib/SPDSparseDead", fRunNumber);
559TObjArray* spdSparseDead;
560if(cdbSPDSparseDead) {
561 spdSparseDead = (TObjArray*)cdbSPDSparseDead->GetObject();
562 if(!spdSparseDead)
563 {AliError("GetDeadAndNoisyInChip: SPDSparseDead not found in CDB");
564 return;}
565} else {
566 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDSparseDead.");
567 return;
568}
569
4a66240a 570// retrieve map of noisy Pixel
571AliCDBEntry *cdbSPDNoisy = man->Get("ITS/Calib/SPDNoisy", fRunNumber);
572TObjArray* spdNoisy;
573if(cdbSPDNoisy) {
574 spdNoisy = (TObjArray*)cdbSPDNoisy->GetObject();
575 if(!spdNoisy)
7167ae53 576 {AliError("GetDeadAndNoisyInChip: SPDNoisy not found in CDB");
4a66240a 577 return;}
578} else {
7167ae53 579 AliError("GetDeadAndNoisyInChip: did not find Calib/SPDNoisy.");
4a66240a 580 return;
581}
582//
583UInt_t mod=GetModFromKey(key);
584UInt_t chip=GetChipFromKey(key);
585// count number of dead
586AliITSCalibrationSPD* calibSPD=(AliITSCalibrationSPD*) spdDead->At(mod);
587UInt_t nrDead = calibSPD->GetNrBad();
588for (UInt_t index=0; index<nrDead; index++) {
6344adcc 589 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
4a66240a 590}
9806b6f8 591// add the number of sparse dead to the previous dead
592calibSPD=(AliITSCalibrationSPD*) spdSparseDead->At(mod);
593UInt_t nrSparseDead = calibSPD->GetNrBad();
594for (UInt_t index=0; index<nrSparseDead; index++) {
595 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrDeadInChip++;
596}
4a66240a 597calibSPD=(AliITSCalibrationSPD*) spdNoisy->At(mod);
598UInt_t nrNoisy = calibSPD->GetNrBad();
599for (UInt_t index=0; index<nrNoisy; index++) {
6344adcc 600 if(GetChipFromCol(calibSPD->GetBadColAt(index))==chip) nrNoisyInChip++;
4a66240a 601}
602return;
603}
604//_____________________________________________________________________________
605Double_t AliITSPlaneEffSPD::GetFracBad(const UInt_t key) const {
606 // returns 1-fractional live
607if(key>=kNModule*kNChip)
7167ae53 608 {AliError("GetFracBad: you asked for a non existing key");
4a66240a 609 return -1.;}
610return 1.-GetFracLive(key);
611}
612//_____________________________________________________________________________
613Bool_t AliITSPlaneEffSPD::WriteIntoCDB() const {
614// write onto CDB
615if(!fInitCDBCalled)
7167ae53 616 {AliError("WriteIntoCDB: CDB not inizialized. Call InitCDB first");
4a66240a 617 return kFALSE;}
618// to be written properly: now only for debugging
619 AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
1cc5cedc 620 //md->SetObjectClassName("AliITSPlaneEff");
4a66240a 621 md->SetResponsible("Giuseppe Eugenio Bruno");
622 md->SetBeamPeriod(0);
623 md->SetAliRootVersion("head 19/11/07"); //root version
624 AliCDBId id("ITS/PlaneEff/PlaneEffSPD",0,AliCDBRunRange::Infinity());
625 AliITSPlaneEffSPD eff;
626 eff=*this;
627 Bool_t r=AliCDBManager::Instance()->GetDefaultStorage()->Put(&eff,id,md);
628 delete md;
629 return r;
630}
631//_____________________________________________________________________________
632Bool_t AliITSPlaneEffSPD::ReadFromCDB() {
633// read from CDB
634if(!fInitCDBCalled)
7167ae53 635 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first");
4a66240a 636 return kFALSE;}
4a66240a 637AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
1cc5cedc 638if(!cdbEntry) return kFALSE;
4a66240a 639AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
640if(this==eff) return kFALSE;
5fbd4fd6 641if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff
642eff->Copy(*this); // copy everything (statistics and histos) from eff to this
4a66240a 643return kTRUE;
644}
7167ae53 645//_____________________________________________________________________________
1cc5cedc 646Bool_t AliITSPlaneEffSPD::AddFromCDB(AliCDBId *cdbId) {
647AliCDBEntry *cdbEntry=0;
648if (!cdbId) {
649 if(!fInitCDBCalled)
650 {AliError("ReadFromCDB: CDB not inizialized. Call InitCDB first"); return kFALSE;}
651 cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSPD",fRunNumber);
652} else {
653 cdbEntry = AliCDBManager::Instance()->Get(*cdbId);
654}
655if(!cdbEntry) return kFALSE;
656AliITSPlaneEffSPD* eff= (AliITSPlaneEffSPD*)cdbEntry->GetObject();
657*this+=*eff;
658return kTRUE;
659}
660//_____________________________________________________________________________
7167ae53 661UInt_t AliITSPlaneEffSPD::GetKeyFromDetLocCoord(Int_t ilay, Int_t idet,
662 Float_t, Float_t locz) const {
663// method to locate a basic block from Detector Local coordinate (to be used in tracking)
664UInt_t key=999999;
665if(ilay<0 || ilay>1)
666 {AliError("GetKeyFromDetLocCoord: you asked for a non existing layer");
667 return key;}
668if(ilay==0 && (idet<0 || idet>79))
669 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
670 return key;}
671if(ilay==1 && (idet<0 || idet>159))
672 {AliError("GetKeyFromDetLocCoord: you asked for a non existing detector");
673 return key;}
674
675UInt_t mod=idet;
676if(ilay==1) mod+=80;
677key=GetKey(mod,GetChipFromCol(GetColFromLocZ(locz)));
678return key;
679}
680//_____________________________________________________________________________
681UInt_t AliITSPlaneEffSPD::GetColFromLocZ(Float_t zloc) const {
41d18cd2 682// method to retrieve column number from the local z coordinate
683 UInt_t col=0;
684 AliITSsegmentationSPD spd;
685 Int_t ix,iz;
686 if(spd.LocalToDet(0,zloc,ix,iz)) col+=iz;
687 else {
275a301c 688 AliDebug(1,Form("cannot compute column number from local z=%f",zloc));
41d18cd2 689 col=99999;}
690 return col;
691/*
7167ae53 692const Float_t kconv = 1.0E-04; // converts microns to cm.
693Float_t bz[160];
694for(Int_t i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
695bz[ 31] = bz[ 32] = 625.0; // first chip boundry
696bz[ 63] = bz[ 64] = 625.0; // first chip boundry
697bz[ 95] = bz[ 96] = 625.0; // first chip boundry
698bz[127] = bz[128] = 625.0; // first chip boundry
699//
700Int_t j=-1;
701Float_t dz=0;
702for(Int_t i=000;i<160;i++) dz+=bz[i];
703dz = -0.5*kconv*dz;
704if(zloc<dz || zloc>-1*dz) { // outside z range
705 AliDebug(1,Form("GetColFromLocZ: cannot compute column number from local z=%f",zloc));
706 return 99999;}
707for(j=0;j<160;j++){
708 dz += kconv*bz[j];
709 if(zloc<dz) break;
710} // end for j
711col+=j;
712//
713return col;
41d18cd2 714*/
7167ae53 715}
716//________________________________________________________
aa0de373 717Bool_t AliITSPlaneEffSPD::GetBlockBoundaries(const UInt_t key, Float_t& xmn,Float_t& xmx,
718 Float_t& zmn,Float_t& zmx) const {
719//
720// This method return the geometrical boundaries of the active volume of a given
721// basic block, in the detector reference system.
722// Input: unique key to locate a basic block.
723//
724// Output: Ymin, Ymax, Zmin, Zmax of a basic block (chip for SPD)
725// Return: kTRUE if computation was succesfully, kFALSE otherwise
726//
727if(key>=kNModule*kNChip)
73f56096 728 {AliDebug(1,"GetBlockBoundaries: you asked for a non existing key"); return kFALSE;}
aa0de373 729UInt_t chip=GetChipFromKey(key);
730zmn=GetLocZFromCol(chip*kNCol);
731zmx=GetLocZFromCol((chip+1)*kNCol);
732xmn=GetLocXFromRow(0);
733xmx=GetLocXFromRow(kNRow);
41d18cd2 734//
aa0de373 735Float_t tmp=zmn;
736if(zmx<zmn) {zmn=zmx; zmx=tmp;}
737tmp=xmn;
738if(xmx<xmn) {xmn=xmx; xmx=tmp;}
739return kTRUE;
740}
741//________________________________________________________
742Float_t AliITSPlaneEffSPD::GetLocXFromRow(const UInt_t row) const {
743//
744// This method return the local (i.e. detector reference system) lower x coordinate
745// of the row. To get the central value of a given row, you can do
746// 1/2*[LocXFromRow(row)+LocXFromRow(row+1)].
747//
748// Input: row number in the range [0,kNRow]
749// Output: lower local X coordinate of this row.
750//
751if(row>kNRow) // not >= ! allow also computation of upper limit of the last row.
752 {AliError("LocYFromRow: you asked for a non existing row"); return 9999999.;}
41d18cd2 753// Use only AliITSsegmentationSPD
754AliITSsegmentationSPD spd;
755Double_t dummy,x;
756if(row==kNRow) spd.CellBoundries((Int_t)row-1,0,dummy,x,dummy,dummy);
757else spd.CellBoundries((Int_t)row,0,x,dummy,dummy,dummy);
758return (Float_t)x;
759
aa0de373 760}
761//________________________________________________________
762Float_t AliITSPlaneEffSPD::GetLocZFromCol(const UInt_t col) const {
763//
764// This method return the local (i.e. detector reference system) lower Z coordinate
765// of the column. To get the central value of a given column, you can do
766// 1/2*[LocZFromCol(col)+LocZFromCol(col+1)].
767//
768// Input: col number in the range [0,kNChip*kNCol]
769// Output: lower local Y coordinate of this row.
770//
771if(col>kNChip*kNCol) // not >= ! allow also computation of upper limit of the last column
772 {AliError("LocZFromCol: you asked for a non existing column"); return 9999999.;}
41d18cd2 773// Use only AliITSsegmentationSPD
774AliITSsegmentationSPD spd;
775Double_t dummy,y;
776if(col==kNChip*kNCol) spd.CellBoundries(0,(Int_t)col-1,dummy,dummy,dummy,y);
777else spd.CellBoundries(0,(Int_t)col,dummy,dummy,y,dummy);
778return (Float_t)y;
779
aa0de373 780}
5fbd4fd6 781//__________________________________________________________
782void AliITSPlaneEffSPD::InitHistos() {
783 // for the moment let's create the histograms
784 // module by module
785 TString histnameResX="HistResX_mod_",aux;
786 TString histnameResZ="HistResZ_mod_";
787 TString histnameResXZ="HistResXZ_mod_";
788 TString histnameClusterType="HistClusterType_mod_";
789 TString histnameResXclu="HistResX_mod_";
790 TString histnameResZclu="HistResZ_mod_";
1cc5cedc 791 TString histnameResXchip="HistResX_mod_";
792 TString histnameResZchip="HistResZ_mod_";
879cdb02 793 TString profnameResXvsPhi="ProfResXvsPhi_mod_";
794 TString profnameResZvsDip="ProfResZvsDip_mod_";
795 TString profnameResXvsPhiclu="ProfResXvsPhi_mod_";
796 TString profnameResZvsDipclu="ProfResZvsDip_mod_";
1cc5cedc 797 TString histnameTrackErrX="HistTrackErrX_mod_";
798 TString histnameTrackErrZ="HistTrackErrZ_mod_";
799 TString histnameClusErrX="HistClusErrX_mod_";
800 TString histnameClusErrZ="HistClusErrZ_mod_";
1f1e7832 801 TString histnameTrackXFOtrue="HistTrackXFOok_mod_";
802 TString histnameTrackZFOtrue="HistTrackZFOok_mod_";
803 TString histnameTrackXFOfalse="HistTrackXFOko_mod_";
804 TString histnameTrackZFOfalse="HistTrackZFOko_mod_";
805 TString histnameTrackXZFOtrue="HistTrackZvsXFOok_mod_";
806 TString histnameTrackXZFOfalse="HistTrackZvsXFOko_mod_";
5fbd4fd6 807//
4c555563 808
809 TH1::AddDirectory(kFALSE);
810
5fbd4fd6 811 fHisResX=new TH1F*[kNHisto];
812 fHisResZ=new TH1F*[kNHisto];
813 fHisResXZ=new TH2F*[kNHisto];
814 fHisClusterSize=new TH2I*[kNHisto];
815 fHisResXclu=new TH1F**[kNHisto];
816 fHisResZclu=new TH1F**[kNHisto];
1cc5cedc 817 fHisResXchip=new TH1F**[kNHisto];
818 fHisResZchip=new TH1F**[kNHisto];
879cdb02 819 fProfResXvsPhi=new TProfile*[kNHisto];
820 fProfResZvsDip=new TProfile*[kNHisto];
821 fProfResXvsPhiclu=new TProfile**[kNHisto];
822 fProfResZvsDipclu=new TProfile**[kNHisto];
1cc5cedc 823 fHisTrackErrX=new TH1F*[kNHisto];
824 fHisTrackErrZ=new TH1F*[kNHisto];
825 fHisClusErrX=new TH1F*[kNHisto];
826 fHisClusErrZ=new TH1F*[kNHisto];
1f1e7832 827 fHisTrackXFOtrue=new TH1F**[kNHisto];
828 fHisTrackZFOtrue=new TH1F**[kNHisto];
829 fHisTrackXFOfalse=new TH1F**[kNHisto];
830 fHisTrackZFOfalse=new TH1F**[kNHisto];
831 fHisTrackXZFOtrue=new TH2F**[kNHisto];
832 fHisTrackXZFOfalse=new TH2F**[kNHisto];
5fbd4fd6 833
834 for (Int_t nhist=0;nhist<kNHisto;nhist++){
835 aux=histnameResX;
836 aux+=nhist;
061c42a0 837 fHisResX[nhist]=new TH1F("histname","histname",1600,-0.32,0.32); // +- 3200 micron; 1 bin=4 micron
5fbd4fd6 838 fHisResX[nhist]->SetName(aux.Data());
839 fHisResX[nhist]->SetTitle(aux.Data());
840
841 aux=histnameResZ;
842 aux+=nhist;
061c42a0 843 fHisResZ[nhist]=new TH1F("histname","histname",1200,-0.48,0.48); // +-4800 micron; 1 bin=8 micron
5fbd4fd6 844 fHisResZ[nhist]->SetName(aux.Data());
845 fHisResZ[nhist]->SetTitle(aux.Data());
846
847 aux=histnameResXZ;
848 aux+=nhist;
061c42a0 849 fHisResXZ[nhist]=new TH2F("histname","histname",80,-0.16,0.16,80,-0.32,0.32); // binning:
1cc5cedc 850 fHisResXZ[nhist]->SetName(aux.Data()); // 40 micron in x;
851 fHisResXZ[nhist]->SetTitle(aux.Data()); // 80 micron in z;
5fbd4fd6 852
853 aux=histnameClusterType;
854 aux+=nhist;
855 fHisClusterSize[nhist]=new TH2I("histname","histname",10,0.5,10.5,10,0.5,10.5);
856 fHisClusterSize[nhist]->SetName(aux.Data());
857 fHisClusterSize[nhist]->SetTitle(aux.Data());
858
859 fHisResXclu[nhist]=new TH1F*[kNclu];
860 fHisResZclu[nhist]=new TH1F*[kNclu];
1f1e7832 861 fHisTrackXFOtrue[nhist]=new TH1F*[kNClockPhase];
862 fHisTrackZFOtrue[nhist]=new TH1F*[kNClockPhase];
863 fHisTrackXFOfalse[nhist]=new TH1F*[kNClockPhase];
864 fHisTrackZFOfalse[nhist]=new TH1F*[kNClockPhase];
865 fHisTrackXZFOtrue[nhist]=new TH2F*[kNClockPhase];
866 fHisTrackXZFOfalse[nhist]=new TH2F*[kNClockPhase];
867
5fbd4fd6 868 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
869 aux=histnameResXclu;
870 aux+=nhist;
871 aux+="_clu_";
872 aux+=clu+1; // clu=0 --> cluster size 1
061c42a0 873 fHisResXclu[nhist][clu]=new TH1F("histname","histname",1600,-0.32,0.32); // +- 3200 micron; 1 bin=4 micron
5fbd4fd6 874 fHisResXclu[nhist][clu]->SetName(aux.Data());
875 fHisResXclu[nhist][clu]->SetTitle(aux.Data());
876
877 aux=histnameResZclu;
878 aux+=nhist;
879 aux+="_clu_";
880 aux+=clu+1; // clu=0 --> cluster size 1
061c42a0 881 fHisResZclu[nhist][clu]=new TH1F("histname","histname",1200,-0.48,0.48); // +-4800 micron; 1 bin=8 micron
5fbd4fd6 882 fHisResZclu[nhist][clu]->SetName(aux.Data());
883 fHisResZclu[nhist][clu]->SetTitle(aux.Data());
884 }
885
1cc5cedc 886 fHisResXchip[nhist]=new TH1F*[kNChip];
887 fHisResZchip[nhist]=new TH1F*[kNChip];
888 for(Int_t chip=0; chip<kNChip; chip++) {
889 aux=histnameResXchip;
890 aux+=nhist;
891 aux+="_chip_";
892 aux+=chip;
061c42a0 893 fHisResXchip[nhist][chip]=new TH1F("histname","histname",800,-0.32,0.32); // +- 3200 micron; 1 bin=8 micron
1cc5cedc 894 fHisResXchip[nhist][chip]->SetName(aux.Data());
895 fHisResXchip[nhist][chip]->SetTitle(aux.Data());
896
897 aux=histnameResZchip;
898 aux+=nhist;
899 aux+="_chip_";
900 aux+=chip;
061c42a0 901 fHisResZchip[nhist][chip]=new TH1F("histname","histname",300,-0.48,0.48); // +-4800 micron; 1 bin=32 micron
1cc5cedc 902 fHisResZchip[nhist][chip]->SetName(aux.Data());
903 fHisResZchip[nhist][chip]->SetTitle(aux.Data());
904 }
905
906 aux=histnameTrackErrX;
907 aux+=nhist;
061c42a0 908 fHisTrackErrX[nhist]=new TH1F("histname","histname",400,0.,0.32); // 0-3200 micron; 1 bin=8 micron
1cc5cedc 909 fHisTrackErrX[nhist]->SetName(aux.Data());
910 fHisTrackErrX[nhist]->SetTitle(aux.Data());
911
912 aux=histnameTrackErrZ;
913 aux+=nhist;
914 fHisTrackErrZ[nhist]=new TH1F("histname","histname",200,0.,0.32); // 0-3200 micron; 1 bin=16 micron
915 fHisTrackErrZ[nhist]->SetName(aux.Data());
916 fHisTrackErrZ[nhist]->SetTitle(aux.Data());
917
918 aux=histnameClusErrX;
919 aux+=nhist;
061c42a0 920 fHisClusErrX[nhist]=new TH1F("histname","histname",400,0.,0.08); // 0-800 micron; 1 bin=2 micron
1cc5cedc 921 fHisClusErrX[nhist]->SetName(aux.Data());
922 fHisClusErrX[nhist]->SetTitle(aux.Data());
923
924 aux=histnameClusErrZ;
925 aux+=nhist;
061c42a0 926 fHisClusErrZ[nhist]=new TH1F("histname","histname",400,0.,0.32); // 0-3200 micron; 1 bin=8 micron
1cc5cedc 927 fHisClusErrZ[nhist]->SetName(aux.Data());
928 fHisClusErrZ[nhist]->SetTitle(aux.Data());
929
879cdb02 930 aux=profnameResXvsPhi;
931 aux+=nhist;
932 fProfResXvsPhi[nhist]=new TProfile("histname","histname",40,-40.,40.0); // binning: range: -40°- 40°
933 fProfResXvsPhi[nhist]->SetName(aux.Data()); // bin width: 2°
934 fProfResXvsPhi[nhist]->SetTitle(aux.Data());
935
936 aux=profnameResZvsDip;
937 aux+=nhist;
938 fProfResZvsDip[nhist]=new TProfile("histname","histname",48,-72.,72.0); // binning: range: -70°-4°
939 fProfResZvsDip[nhist]->SetName(aux.Data()); // bin width: 3°
940 fProfResZvsDip[nhist]->SetTitle(aux.Data());
941
942 fProfResXvsPhiclu[nhist]=new TProfile*[kNclu];
943 fProfResZvsDipclu[nhist]=new TProfile*[kNclu];
944 for(Int_t clu=0; clu<kNclu; clu++) { // clu=0 --> cluster size 1
945 aux=profnameResXvsPhiclu;
946 aux+=nhist;
947 aux+="_clu_";
948 aux+=clu+1; // clu=0 --> cluster size 1
949 fProfResXvsPhiclu[nhist][clu]=new TProfile("histname","histname",40,-40.,40.0); // binning: range: -40°- 40
1f1e7832 950 fProfResXvsPhiclu[nhist][clu]->SetName(aux.Data()); // bin width: 2°
879cdb02 951 fProfResXvsPhiclu[nhist][clu]->SetTitle(aux.Data());
952
953 aux=profnameResZvsDipclu;
954 aux+=nhist;
955 aux+="_clu_";
956 aux+=clu+1; // clu=0 --> cluster size 1
957 fProfResZvsDipclu[nhist][clu]= new TProfile("histname","histname",48,-72.,72.0); // binning: range: -70°-7°
958 fProfResZvsDipclu[nhist][clu]->SetName(aux.Data()); // bin width: 3°
959 fProfResZvsDipclu[nhist][clu]->SetTitle(aux.Data());
960 }
961
1f1e7832 962 fHisTrackXFOtrue[nhist]=new TH1F*[kNClockPhase];
963 fHisTrackZFOtrue[nhist]=new TH1F*[kNClockPhase];
964 fHisTrackXFOfalse[nhist]=new TH1F*[kNClockPhase];
965 fHisTrackZFOfalse[nhist]=new TH1F*[kNClockPhase];
966 fHisTrackXZFOtrue[nhist]=new TH2F*[kNClockPhase];
967 fHisTrackXZFOfalse[nhist]=new TH2F*[kNClockPhase];
968 for(Int_t phas=0; phas<kNClockPhase;phas++){
969 aux=histnameTrackXFOtrue;
970 aux+=nhist;
971 aux+="_BCmod4_";
972 aux+=phas;
973 fHisTrackXFOtrue[nhist][phas]=new TH1F("histname","histname",128,-0.64,0.64); // +- 6.4 mm; 1 bin=0.1 mm
974 fHisTrackXFOtrue[nhist][phas]->SetName(aux.Data());
975 fHisTrackXFOtrue[nhist][phas]->SetTitle(aux.Data());
976
977 aux=histnameTrackZFOtrue;
978 aux+=nhist;
979 aux+="_BCmod4_";
980 aux+=phas;
981 fHisTrackZFOtrue[nhist][phas]=new TH1F("histname","histname",350,-3.5,3.5); // +- 35. mm; 1 bin=0.2 mm
982 fHisTrackZFOtrue[nhist][phas]->SetName(aux.Data());
983 fHisTrackZFOtrue[nhist][phas]->SetTitle(aux.Data());
984
985 aux=histnameTrackXFOfalse;
986 aux+=nhist;
987 aux+="_BCmod4_";
988 aux+=phas;
989 fHisTrackXFOfalse[nhist][phas]=new TH1F("histname","histname",128,-0.64,0.64); // +- 6.4 mm; 1 bin=0.1 mm
990 fHisTrackXFOfalse[nhist][phas]->SetName(aux.Data());
991 fHisTrackXFOfalse[nhist][phas]->SetTitle(aux.Data());
992
993 aux=histnameTrackZFOfalse;
994 aux+=nhist;
995 aux+="_BCmod4_";
996 aux+=phas;
997 fHisTrackZFOfalse[nhist][phas]=new TH1F("histname","histname",350,-3.5,3.5); // +- 35. mm; 1 bin=0.2 mm
998 fHisTrackZFOfalse[nhist][phas]->SetName(aux.Data());
999 fHisTrackZFOfalse[nhist][phas]->SetTitle(aux.Data());
1000
1001 aux=histnameTrackXZFOtrue;
1002 aux+=nhist;
1003 aux+="_BCmod4_";
1004 aux+=phas;
1005 fHisTrackXZFOtrue[nhist][phas]=new TH2F("histname","histname",22,-3.5,3.5,32,-0.64,0.64); // localZ +- 35. mm; 1 bin=3.2 mm
1006 fHisTrackXZFOtrue[nhist][phas]->SetName(aux.Data()); // localX +- 6.4 mm; 1 bin=0.4 mm
1007 fHisTrackXZFOtrue[nhist][phas]->SetTitle(aux.Data());
1008
1009 aux=histnameTrackXZFOfalse;
1010 aux+=nhist;
1011 aux+="_BCmod4_";
1012 aux+=phas;
1013 fHisTrackXZFOfalse[nhist][phas]=new TH2F("histname","histname",22,-3.5,3.5,32,-0.64,0.64); // localZ +- 35. mm; 1 bin=3.2 mm
1014 fHisTrackXZFOfalse[nhist][phas]->SetName(aux.Data()); // localX +- 6.4 mm; 1 bin=0.4 mm
1015 fHisTrackXZFOfalse[nhist][phas]->SetTitle(aux.Data());
1016 }
879cdb02 1017 } // end loop on module
4c555563 1018
1019 TH1::AddDirectory(kTRUE);
1020
5fbd4fd6 1021return;
1022}
1023//__________________________________________________________
1024void AliITSPlaneEffSPD::DeleteHistos() {
1025 if(fHisResX) {
1026 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
3ebe30ad 1027 delete [] fHisResX; fHisResX=0;
5fbd4fd6 1028 }
1029 if(fHisResZ) {
1030 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
3ebe30ad 1031 delete [] fHisResZ; fHisResZ=0;
5fbd4fd6 1032 }
1033 if(fHisResXZ) {
1034 for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
3ebe30ad 1035 delete [] fHisResXZ; fHisResXZ=0;
5fbd4fd6 1036 }
1037 if(fHisClusterSize) {
1038 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
3ebe30ad 1039 delete [] fHisClusterSize; fHisClusterSize=0;
5fbd4fd6 1040 }
1041 if(fHisResXclu) {
1042 for (Int_t i=0; i<kNHisto; i++ ) {
1043 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResXclu[i][clu]) delete fHisResXclu[i][clu];
1044 delete [] fHisResXclu[i];
1045 }
1046 delete [] fHisResXclu;
1047 fHisResXclu = 0;
1048 }
1049 if(fHisResZclu) {
1050 for (Int_t i=0; i<kNHisto; i++ ) {
1051 for (Int_t clu=0; clu<kNclu; clu++) if (fHisResZclu[i][clu]) delete fHisResZclu[i][clu];
1052 delete [] fHisResZclu[i];
1053 }
1054 delete [] fHisResZclu;
1055 fHisResZclu = 0;
1056 }
1cc5cedc 1057 if(fHisResXchip) {
1058 for (Int_t i=0; i<kNHisto; i++ ) {
1059 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResXchip[i][chip]) delete fHisResXchip[i][chip];
1060 delete [] fHisResXchip[i];
1061 }
1062 delete [] fHisResXchip;
1063 fHisResXchip = 0;
1064 }
1065 if(fHisResZchip) {
1066 for (Int_t i=0; i<kNHisto; i++ ) {
1067 for (Int_t chip=0; chip<kNChip; chip++) if (fHisResZchip[i][chip]) delete fHisResZchip[i][chip];
1068 delete [] fHisResZchip[i];
1069 }
1070 delete [] fHisResZchip;
1071 fHisResZchip = 0;
1072 }
1073 if(fHisTrackErrX) {
1074 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrX[i];
1075 delete [] fHisTrackErrX; fHisTrackErrX=0;
1076 }
1077 if(fHisTrackErrZ) {
1078 for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrZ[i];
1079 delete [] fHisTrackErrZ; fHisTrackErrZ=0;
1080 }
1081 if(fHisClusErrX) {
1082 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrX[i];
1083 delete [] fHisClusErrX; fHisClusErrX=0;
1084 }
1085 if(fHisClusErrZ) {
1086 for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrZ[i];
1087 delete [] fHisClusErrZ; fHisClusErrZ=0;
1088 }
879cdb02 1089 if(fProfResXvsPhi) {
1090 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResXvsPhi[i];
1091 delete [] fProfResXvsPhi; fProfResXvsPhi=0;
1092 }
1093 if(fProfResZvsDip) {
1094 for (Int_t i=0; i<kNHisto; i++ ) delete fProfResZvsDip[i];
1095 delete [] fProfResZvsDip; fProfResZvsDip=0;
1096 }
1097 if(fProfResXvsPhiclu) {
1098 for (Int_t i=0; i<kNHisto; i++ ) {
1099 for (Int_t clu=0; clu<kNclu; clu++) if (fProfResXvsPhiclu[i][clu]) delete fProfResXvsPhiclu[i][clu];
1100 delete [] fProfResXvsPhiclu[i];
1101 }
1102 delete [] fProfResXvsPhiclu;
1103 fProfResXvsPhiclu = 0;
1104 }
1105 if(fProfResZvsDipclu) {
1106 for (Int_t i=0; i<kNHisto; i++ ) {
1107 for (Int_t clu=0; clu<kNclu; clu++) if (fProfResZvsDipclu[i][clu]) delete fProfResZvsDipclu[i][clu];
1108 delete [] fProfResZvsDipclu[i];
1109 }
1110 delete [] fProfResZvsDipclu;
1111 fProfResZvsDipclu = 0;
1112 }
1f1e7832 1113 if(fHisTrackXFOtrue) {
1114 for (Int_t i=0; i<kNHisto; i++ ) {
1115 for (Int_t phas=0; phas<kNClockPhase; phas++) if (fHisTrackXFOtrue[i][phas]) delete fHisTrackXFOtrue[i][phas];
1116 delete [] fHisTrackXFOtrue[i];
1117 }
1118 delete [] fHisTrackXFOtrue;
1119 fHisTrackXFOtrue = 0;
1120 }
1121 if(fHisTrackZFOtrue) {
1122 for (Int_t i=0; i<kNHisto; i++ ) {
1123 for (Int_t phas=0; phas<kNClockPhase; phas++) if (fHisTrackZFOtrue[i][phas]) delete fHisTrackZFOtrue[i][phas];
1124 delete [] fHisTrackZFOtrue[i];
1125 }
1126 delete [] fHisTrackZFOtrue;
1127 fHisTrackZFOtrue = 0;
1128 }
1129 if(fHisTrackXFOfalse) {
1130 for (Int_t i=0; i<kNHisto; i++ ) {
1131 for (Int_t phas=0; phas<kNClockPhase; phas++) if (fHisTrackXFOfalse[i][phas]) delete fHisTrackXFOfalse[i][phas];
1132 delete [] fHisTrackXFOfalse[i];
1133 }
1134 delete [] fHisTrackXFOfalse;
1135 fHisTrackXFOfalse = 0;
1136 }
1137 if(fHisTrackZFOfalse) {
1138 for (Int_t i=0; i<kNHisto; i++ ) {
1139 for (Int_t phas=0; phas<kNClockPhase; phas++) if (fHisTrackZFOfalse[i][phas]) delete fHisTrackZFOfalse[i][phas];
1140 delete [] fHisTrackZFOfalse[i];
1141 }
1142 delete [] fHisTrackZFOfalse;
1143 fHisTrackZFOfalse = 0;
1144 }
5fbd4fd6 1145return;
1146}
1147//__________________________________________________________
1f1e7832 1148Bool_t AliITSPlaneEffSPD::FillHistos(UInt_t key, Bool_t found,
1149 Float_t *tr, Float_t *clu, Int_t *csize, Float_t *angtrkmod) {
1150//
1151// depending on the value of key this method
1152// either call the standard one for clusters
1153// or the one for FO studies
1154// if key < 1200 --> call FillHistosST
1155// if key >= 1200 --> call FillHistosFO
1156if(key>=kNModule*kNChip*(kNClockPhase+1))
1157 {AliError("GetChipFromKey: you asked for a non existing key"); return kFALSE;}
1158if(key<kNModule*kNChip) return FillHistosStd(key,found,tr,clu,csize,angtrkmod);
1159else return FillHistosFO(key,found,tr);
1160return kFALSE;
1161}
1162//__________________________________________________________
1163Bool_t AliITSPlaneEffSPD::FillHistosFO(UInt_t key, Bool_t found, Float_t *tr) {
1164// this method fill the histograms for FastOr studies
1165// input: - key: unique key of the basic block
1166// - found: Boolean to asses whether a FastOr bit has been associated to the track or not
1167// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
1168// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
1169// output: kTRUE if filling was succesfull kFALSE otherwise
1170// side effects: updating of the histograms.
1171 if (!fHis) {
1172 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
1173 return kFALSE;
1174 }
1175 if(key>=kNModule*kNChip*(kNClockPhase+1))
1176 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
1177 if(key<kNModule*kNChip)
1178 {AliWarning("FillHistos: you asked for a key which is not for FO studies"); return kFALSE;}
1179 Int_t id=GetModFromKey(key);
1180 Int_t BCm4=GetBCm4FromKey(key);
1181 if(id>=kNHisto)
1182 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
1183 if(found) {
1184 fHisTrackXFOtrue[id][BCm4]->Fill(tr[0]);
1185 fHisTrackZFOtrue[id][BCm4]->Fill(tr[1]);
1186 fHisTrackXZFOtrue[id][BCm4]->Fill(tr[1],tr[0]);
1187 }
1188 else {
1189 fHisTrackXFOfalse[id][BCm4]->Fill(tr[0]);
1190 fHisTrackZFOfalse[id][BCm4]->Fill(tr[1]);
1191 fHisTrackXZFOfalse[id][BCm4]->Fill(tr[1],tr[0]);
1192 }
1193return kTRUE;
1194}
1195//__________________________________________________________
1196Bool_t AliITSPlaneEffSPD::FillHistosStd(UInt_t key, Bool_t found,
879cdb02 1197 Float_t *tr, Float_t *clu, Int_t *csize, Float_t *angtrkmod) {
5fbd4fd6 1198// this method fill the histograms
1199// input: - key: unique key of the basic block
1200// - found: Boolean to asses whether a cluster has been associated to the track or not
1cc5cedc 1201// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
1202// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
1203// - clu[0],clu[1] local X and Z coordinates of the cluster associated to the track, respectively
1204// - clu[2],clu[3] error on local X and Z coordinates of the cluster associated to the track, respectively
1205// - csize[0][1] cluster size in X and Z, respectively
879cdb02 1206// - angtrkmod[0],angtrkmod[1]
5fbd4fd6 1207// output: kTRUE if filling was succesfull kFALSE otherwise
1208// side effects: updating of the histograms.
1209//
1210 if (!fHis) {
1211 AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
1212 return kFALSE;
1213 }
1214 if(key>=kNModule*kNChip)
1215 {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;}
1216 Int_t id=GetModFromKey(key);
1cc5cedc 1217 Int_t chip=GetChipFromKey(key);
5fbd4fd6 1218 if(id>=kNHisto)
1219 {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;}
1220 if(found) {
1cc5cedc 1221 Float_t resx=tr[0]-clu[0];
1222 Float_t resz=tr[1]-clu[1];
5fbd4fd6 1223 fHisResX[id]->Fill(resx);
1224 fHisResZ[id]->Fill(resz);
1225 fHisResXZ[id]->Fill(resx,resz);
1cc5cedc 1226 fHisClusterSize[id]->Fill((Double_t)csize[0],(Double_t)csize[1]);
1227 if(csize[0]>0 && csize[0]<=kNclu) fHisResXclu[id][csize[0]-1]->Fill(resx);
1228 if(csize[1]>0 && csize[1]<=kNclu) fHisResZclu[id][csize[1]-1]->Fill(resz);
1229 fHisResXchip[id][chip]->Fill(resx);
1230 fHisResZchip[id][chip]->Fill(resz);
879cdb02 1231 fProfResXvsPhi[id]->Fill(angtrkmod[0],resx);
1232 fProfResZvsDip[id]->Fill(angtrkmod[1],resz);
1233 if(csize[0]>0 && csize[0]<=kNclu) fProfResXvsPhiclu[id][csize[0]-1]->Fill(angtrkmod[0],resx);
1234 if(csize[1]>0 && csize[1]<=kNclu) fProfResZvsDipclu[id][csize[1]-1]->Fill(angtrkmod[1],resz);
5fbd4fd6 1235 }
1cc5cedc 1236 fHisTrackErrX[id]->Fill(tr[2]);
1237 fHisTrackErrZ[id]->Fill(tr[3]);
1238 fHisClusErrX[id]->Fill(clu[2]);
1239 fHisClusErrZ[id]->Fill(clu[3]);
5fbd4fd6 1240 return kTRUE;
1241}
1242//__________________________________________________________
1243Bool_t AliITSPlaneEffSPD::WriteHistosToFile(TString filename, Option_t* option) {
1244 //
1245 // Saves the histograms into a tree and saves the trees into a file
1246 //
1247 if (!fHis) return kFALSE;
5af4a2d0 1248 if (filename.IsNull() || filename.IsWhitespace()) {
5fbd4fd6 1249 AliWarning("WriteHistosToFile: null output filename!");
1250 return kFALSE;
1251 }
943fb20f 1252 char branchname[51];
5fbd4fd6 1253 TFile *hFile=new TFile(filename.Data(),option,
1254 "The File containing the TREEs with ITS PlaneEff Histos");
1255 TTree *SPDTree=new TTree("SPDTree","Tree whith Residuals and Cluster Type distributions for SPD");
1256 TH1F *histZ,*histX;
1257 TH2F *histXZ;
1258 TH2I *histClusterType;
1259 TH1F *histXclu[kNclu];
1260 TH1F *histZclu[kNclu];
1cc5cedc 1261 TH1F *histXchip[kNChip];
1262 TH1F *histZchip[kNChip];
1263 TH1F *histTrErrZ,*histTrErrX;
1264 TH1F *histClErrZ,*histClErrX;
879cdb02 1265 TProfile *profXvsPhi,*profZvsDip;
1266 TProfile *profXvsPhiclu[kNclu],*profZvsDipclu[kNclu];
1f1e7832 1267 TH1F *histXtrkFOtrue[kNClockPhase];
1268 TH1F *histZtrkFOtrue[kNClockPhase];
1269 TH1F *histXtrkFOfalse[kNClockPhase];
1270 TH1F *histZtrkFOfalse[kNClockPhase];
1271 TH2F *histXZtrkFOtrue[kNClockPhase];
1272 TH2F *histXZtrkFOfalse[kNClockPhase];
5fbd4fd6 1273
1274 histZ=new TH1F();
1275 histX=new TH1F();
1276 histXZ=new TH2F();
1277 histClusterType=new TH2I();
1278 for(Int_t clu=0;clu<kNclu;clu++) {
1279 histXclu[clu]=new TH1F();
1280 histZclu[clu]=new TH1F();
1281 }
1cc5cedc 1282 for(Int_t chip=0;chip<kNChip;chip++) {
1283 histXchip[chip]=new TH1F();
1284 histZchip[chip]=new TH1F();
1285 }
1f1e7832 1286
1cc5cedc 1287 histTrErrX=new TH1F();
1288 histTrErrZ=new TH1F();
1289 histClErrX=new TH1F();
1290 histClErrZ=new TH1F();
879cdb02 1291 profXvsPhi=new TProfile();
1292 profZvsDip=new TProfile();
1293 for(Int_t clu=0;clu<kNclu;clu++) {
1294 profXvsPhiclu[clu]=new TProfile();
1295 profZvsDipclu[clu]=new TProfile();
1296 }
1297
1f1e7832 1298 for(Int_t phas=0; phas<kNClockPhase;phas++){
1299 histXtrkFOtrue[phas]=new TH1F();
1300 histZtrkFOtrue[phas]=new TH1F();
1301 histXtrkFOfalse[phas]=new TH1F();
1302 histZtrkFOfalse[phas]=new TH1F();
1303 histXZtrkFOtrue[phas]=new TH2F();
1304 histXZtrkFOfalse[phas]=new TH2F();
1305 }
5fbd4fd6 1306
1307 SPDTree->Branch("histX","TH1F",&histX,128000,0);
1308 SPDTree->Branch("histZ","TH1F",&histZ,128000,0);
1309 SPDTree->Branch("histXZ","TH2F",&histXZ,128000,0);
1310 SPDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
1311 for(Int_t clu=0;clu<kNclu;clu++) {
943fb20f 1312 snprintf(branchname,50,"histXclu_%d",clu+1);
5fbd4fd6 1313 SPDTree->Branch(branchname,"TH1F",&histXclu[clu],128000,0);
943fb20f 1314 snprintf(branchname,50,"histZclu_%d",clu+1);
5fbd4fd6 1315 SPDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0);
1316 }
1cc5cedc 1317 for(Int_t chip=0;chip<kNChip;chip++) {
943fb20f 1318 snprintf(branchname,50,"histXchip_%d",chip);
1cc5cedc 1319 SPDTree->Branch(branchname,"TH1F",&histXchip[chip],128000,0);
943fb20f 1320 snprintf(branchname,50,"histZchip_%d",chip);
1cc5cedc 1321 SPDTree->Branch(branchname,"TH1F",&histZchip[chip],128000,0);
1322 }
1323 SPDTree->Branch("histTrErrX","TH1F",&histTrErrX,128000,0);
1324 SPDTree->Branch("histTrErrZ","TH1F",&histTrErrZ,128000,0);
1325 SPDTree->Branch("histClErrX","TH1F",&histClErrX,128000,0);
1326 SPDTree->Branch("histClErrZ","TH1F",&histClErrZ,128000,0);
879cdb02 1327 SPDTree->Branch("profXvsPhi","TProfile",&profXvsPhi,128000,0);
1328 SPDTree->Branch("profZvsDip","TProfile",&profZvsDip,128000,0);
1329 for(Int_t clu=0;clu<kNclu;clu++) {
943fb20f 1330 snprintf(branchname,50,"profXvsPhiclu_%d",clu+1);
879cdb02 1331 SPDTree->Branch(branchname,"TProfile",&profXvsPhiclu[clu],128000,0);
943fb20f 1332 snprintf(branchname,50,"profZvsDipclu_%d",clu+1);
879cdb02 1333 SPDTree->Branch(branchname,"TProfile",&profZvsDipclu[clu],128000,0);
1334 }
1f1e7832 1335 for(Int_t phas=0; phas<kNClockPhase;phas++){
1336 snprintf(branchname,50,"histTrXFOokBCmod4_%d",phas);
1337 SPDTree->Branch(branchname,"TH1F",&histXtrkFOtrue[phas],128000,0);
1338 snprintf(branchname,50,"histTrZFOokBCmod4_%d",phas);
1339 SPDTree->Branch(branchname,"TH1F",&histZtrkFOtrue[phas],128000,0);
1340 snprintf(branchname,50,"histTrXFOkoBCmod4_%d",phas);
1341 SPDTree->Branch(branchname,"TH1F",&histXtrkFOfalse[phas],128000,0);
1342 snprintf(branchname,50,"histTrZFOkoBCmod4_%d",phas);
1343 SPDTree->Branch(branchname,"TH1F",&histZtrkFOfalse[phas],128000,0);
1344 snprintf(branchname,50,"histTrXZFOokBCmod4_%d",phas);
1345 SPDTree->Branch(branchname,"TH2F",&histXZtrkFOtrue[phas],128000,0);
1346 snprintf(branchname,50,"histTrXZFOkoBCmod4_%d",phas);
1347 SPDTree->Branch(branchname,"TH2F",&histXZtrkFOfalse[phas],128000,0);
1348 }
5fbd4fd6 1349
1350 for(Int_t j=0;j<kNHisto;j++){
1351 histX=fHisResX[j];
1352 histZ=fHisResZ[j];
1353 histXZ=fHisResXZ[j];
1354 histClusterType=fHisClusterSize[j];
1355 for(Int_t clu=0;clu<kNclu;clu++) {
1356 histXclu[clu]=fHisResXclu[j][clu];
1357 histZclu[clu]=fHisResZclu[j][clu];
1358 }
1cc5cedc 1359 for(Int_t chip=0;chip<kNChip;chip++) {
1360 histXchip[chip]=fHisResXchip[j][chip];
1361 histZchip[chip]=fHisResZchip[j][chip];
1362 }
1363 histTrErrX=fHisTrackErrX[j];
1364 histTrErrZ=fHisTrackErrZ[j];
1365 histClErrX=fHisClusErrX[j];
1366 histClErrZ=fHisClusErrZ[j];
879cdb02 1367 profXvsPhi=fProfResXvsPhi[j];
1368 profZvsDip=fProfResZvsDip[j];
1369 for(Int_t clu=0;clu<kNclu;clu++) {
1370 profXvsPhiclu[clu]=fProfResXvsPhiclu[j][clu];
1371 profZvsDipclu[clu]=fProfResZvsDipclu[j][clu];
1372 }
1f1e7832 1373 for(Int_t phas=0; phas<kNClockPhase;phas++){
1374 histXtrkFOtrue[phas]=fHisTrackXFOtrue[j][phas];
1375 histZtrkFOtrue[phas]=fHisTrackZFOtrue[j][phas];
1376 histXtrkFOfalse[phas]=fHisTrackXFOfalse[j][phas];
1377 histZtrkFOfalse[phas]=fHisTrackZFOfalse[j][phas];
1378 histXZtrkFOtrue[phas]=fHisTrackXZFOtrue[j][phas];
1379 histXZtrkFOfalse[phas]=fHisTrackXZFOfalse[j][phas];
1380 }
879cdb02 1381
5fbd4fd6 1382 SPDTree->Fill();
1383 }
1384 hFile->Write();
1385 hFile->Close();
1386return kTRUE;
1387}
1388//__________________________________________________________
1389Bool_t AliITSPlaneEffSPD::ReadHistosFromFile(TString filename) {
1390 //
1391 // Read histograms from an already existing file
1392 //
1393 if (!fHis) return kFALSE;
5af4a2d0 1394 if (filename.IsNull() || filename.IsWhitespace()) {
5fbd4fd6 1395 AliWarning("ReadHistosFromFile: incorrect output filename!");
1396 return kFALSE;
1397 }
943fb20f 1398 char branchname[51];
5fbd4fd6 1399
1400 TH1F *h = 0;
1401 TH2F *h2 = 0;
1402 TH2I *h2i= 0;
879cdb02 1403 TProfile *p = 0;
5fbd4fd6 1404
1405 TFile *file=TFile::Open(filename.Data(),"READONLY");
1406
1407 if (!file || file->IsZombie()) {
1408 AliWarning(Form("Can't open %s !",filename.Data()));
1409 delete file;
1410 return kFALSE;
1411 }
1412 TTree *tree = (TTree*) file->Get("SPDTree");
1413
1414 TBranch *histX = (TBranch*) tree->GetBranch("histX");
1415 TBranch *histZ = (TBranch*) tree->GetBranch("histZ");
1416 TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ");
1417 TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType");
1418
1419 TBranch *histXclu[kNclu], *histZclu[kNclu];
1420 for(Int_t clu=0; clu<kNclu; clu++) {
943fb20f 1421 snprintf(branchname,50,"histXclu_%d",clu+1);
5fbd4fd6 1422 histXclu[clu]= (TBranch*) tree->GetBranch(branchname);
943fb20f 1423 snprintf(branchname,50,"histZclu_%d",clu+1);
5fbd4fd6 1424 histZclu[clu]= (TBranch*) tree->GetBranch(branchname);
1425 }
1426
1cc5cedc 1427 TBranch *histXchip[kNChip], *histZchip[kNChip];
1428 for(Int_t chip=0; chip<kNChip; chip++) {
943fb20f 1429 snprintf(branchname,50,"histXchip_%d",chip);
1cc5cedc 1430 histXchip[chip]= (TBranch*) tree->GetBranch(branchname);
943fb20f 1431 snprintf(branchname,50,"histZchip_%d",chip);
1cc5cedc 1432 histZchip[chip]= (TBranch*) tree->GetBranch(branchname);
1433 }
1434
1435 TBranch *histTrErrX = (TBranch*) tree->GetBranch("histTrErrX");
1436 TBranch *histTrErrZ = (TBranch*) tree->GetBranch("histTrErrZ");
1437 TBranch *histClErrX = (TBranch*) tree->GetBranch("histClErrX");
1438 TBranch *histClErrZ = (TBranch*) tree->GetBranch("histClErrZ");
879cdb02 1439 TBranch *profXvsPhi = (TBranch*) tree->GetBranch("profXvsPhi");
1440 TBranch *profZvsDip = (TBranch*) tree->GetBranch("profZvsDip");
1441
1442 TBranch *profXvsPhiclu[kNclu], *profZvsDipclu[kNclu];
1443 for(Int_t clu=0; clu<kNclu; clu++) {
943fb20f 1444 snprintf(branchname,50,"profXvsPhiclu_%d",clu+1);
879cdb02 1445 profXvsPhiclu[clu]= (TBranch*) tree->GetBranch(branchname);
943fb20f 1446 snprintf(branchname,50,"profZvsDipclu_%d",clu+1);
879cdb02 1447 profZvsDipclu[clu]= (TBranch*) tree->GetBranch(branchname);
1448 }
1cc5cedc 1449
1f1e7832 1450 TBranch *histXtrkFOtrue[kNClockPhase], *histZtrkFOtrue[kNClockPhase],
1451 *histXtrkFOfalse[kNClockPhase], *histZtrkFOfalse[kNClockPhase],
1452 *histXZtrkFOtrue[kNClockPhase], *histXZtrkFOfalse[kNClockPhase];
1453 for(Int_t phas=0; phas<kNClockPhase;phas++){
1454 snprintf(branchname,50,"histTrXFOokBCmod4_%d",phas);
1455 histXtrkFOtrue[phas] = (TBranch*) tree->GetBranch(branchname);
1456 snprintf(branchname,50,"histTrZFOokBCmod4_%d",phas);
1457 histZtrkFOtrue[phas] = (TBranch*) tree->GetBranch(branchname);
1458 snprintf(branchname,50,"histTrXFOkoBCmod4_%d",phas);
1459 histXtrkFOfalse[phas] = (TBranch*) tree->GetBranch(branchname);
1460 snprintf(branchname,50,"histTrZFOkoBCmod4_%d",phas);
1461 histZtrkFOfalse[phas] = (TBranch*) tree->GetBranch(branchname);
1462 snprintf(branchname,50,"histTrXZFOokBCmod4_%d",phas);
1463 histXZtrkFOtrue[phas] = (TBranch*) tree->GetBranch(branchname);
1464 snprintf(branchname,50,"histTrXZFOkoBCmod4_%d",phas);
1465 histXZtrkFOfalse[phas] = (TBranch*) tree->GetBranch(branchname);
1466 }
1467
5fbd4fd6 1468 gROOT->cd();
1469
1470 Int_t nevent = (Int_t)histX->GetEntries();
1471 if(nevent!=kNHisto)
1472 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1473 histX->SetAddress(&h);
1474 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1475 histX->GetEntry(j);
1476 fHisResX[j]->Add(h);
1477 }
1478
1479 nevent = (Int_t)histZ->GetEntries();
1480 if(nevent!=kNHisto)
1481 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1482 histZ->SetAddress(&h);
1483 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1484 histZ->GetEntry(j);
1485 fHisResZ[j]->Add(h);
1486 }
1487
1488 nevent = (Int_t)histXZ->GetEntries();
1489 if(nevent!=kNHisto)
1490 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1491 histXZ->SetAddress(&h2);
1492 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1493 histXZ->GetEntry(j);
1494 fHisResXZ[j]->Add(h2);
1495 }
1496
1497 nevent = (Int_t)histClusterType->GetEntries();
1498 if(nevent!=kNHisto)
1499 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1500 histClusterType->SetAddress(&h2i);
1501 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1502 histClusterType->GetEntry(j);
1503 fHisClusterSize[j]->Add(h2i);
1504 }
1505
1506 for(Int_t clu=0; clu<kNclu; clu++) {
1507
1508 nevent = (Int_t)histXclu[clu]->GetEntries();
1509 if(nevent!=kNHisto)
1510 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1511 histXclu[clu]->SetAddress(&h);
1512 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1513 histXclu[clu]->GetEntry(j);
1514 fHisResXclu[j][clu]->Add(h);
1515 }
1516
1517 nevent = (Int_t)histZclu[clu]->GetEntries();
1518 if(nevent!=kNHisto)
1519 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1520 histZclu[clu]->SetAddress(&h);
1521 for(Int_t j=0;j<kNHisto;j++){
5fbd4fd6 1522 histZclu[clu]->GetEntry(j);
1523 fHisResZclu[j][clu]->Add(h);
1524 }
1525 }
1526
1cc5cedc 1527
1528 for(Int_t chip=0; chip<kNChip; chip++) {
1529
1530 nevent = (Int_t)histXchip[chip]->GetEntries();
1531 if(nevent!=kNHisto)
1532 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1533 histXchip[chip]->SetAddress(&h);
1534 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1535 histXchip[chip]->GetEntry(j);
1536 fHisResXchip[j][chip]->Add(h);
1537 }
1538
1539 nevent = (Int_t)histZchip[chip]->GetEntries();
1540 if(nevent!=kNHisto)
1541 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1542 histZchip[chip]->SetAddress(&h);
1543 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1544 histZchip[chip]->GetEntry(j);
1545 fHisResZchip[j][chip]->Add(h);
1546 }
1547 }
1548
1549 nevent = (Int_t)histTrErrX->GetEntries();
1550 if(nevent!=kNHisto)
1551 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1552 histTrErrX->SetAddress(&h);
1553 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1554 histTrErrX->GetEntry(j);
1555 fHisTrackErrX[j]->Add(h);
1556 }
1557
1558 nevent = (Int_t)histTrErrZ->GetEntries();
1559 if(nevent!=kNHisto)
1560 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1561 histTrErrZ->SetAddress(&h);
1562 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1563 histTrErrZ->GetEntry(j);
1564 fHisTrackErrZ[j]->Add(h);
1565 }
1566
1567 nevent = (Int_t)histClErrX->GetEntries();
1568 if(nevent!=kNHisto)
1569 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1570 histClErrX->SetAddress(&h);
1571 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1572 histClErrX->GetEntry(j);
1573 fHisClusErrX[j]->Add(h);
1574 }
1575
1576 nevent = (Int_t)histClErrZ->GetEntries();
1577 if(nevent!=kNHisto)
1578 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1579 histClErrZ->SetAddress(&h);
1580 for(Int_t j=0;j<kNHisto;j++){
1cc5cedc 1581 histClErrZ->GetEntry(j);
1582 fHisClusErrZ[j]->Add(h);
1583 }
879cdb02 1584 nevent = (Int_t)profXvsPhi->GetEntries();
1585 if(nevent!=kNHisto)
1586 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1587 profXvsPhi->SetAddress(&p);
1588 for(Int_t j=0;j<kNHisto;j++){
879cdb02 1589 profXvsPhi->GetEntry(j);
1590 fProfResXvsPhi[j]->Add(p);
1591 }
1592
1593 nevent = (Int_t)profZvsDip->GetEntries();
1594 if(nevent!=kNHisto)
1595 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1596 profZvsDip->SetAddress(&p);
943fb20f 1597 for(Int_t j=0;j<kNHisto;j++){
879cdb02 1598 profZvsDip->GetEntry(j);
1599 fProfResZvsDip[j]->Add(p);
1600 }
1601
1602 for(Int_t clu=0; clu<kNclu; clu++) {
1603
1604 nevent = (Int_t)profXvsPhiclu[clu]->GetEntries();
1605 if(nevent!=kNHisto)
1606 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1607 profXvsPhiclu[clu]->SetAddress(&p);
1608 for(Int_t j=0;j<kNHisto;j++){
879cdb02 1609 profXvsPhiclu[clu]->GetEntry(j);
1610 fProfResXvsPhiclu[j][clu]->Add(p);
1611 }
1612
1613 nevent = (Int_t)profZvsDipclu[clu]->GetEntries();
1614 if(nevent!=kNHisto)
1615 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1616 profZvsDipclu[clu]->SetAddress(&p);
943fb20f 1617 for(Int_t j=0;j<kNHisto;j++){
879cdb02 1618 profZvsDipclu[clu]->GetEntry(j);
1619 fProfResZvsDipclu[j][clu]->Add(p);
1620 }
1621 }
1622
1f1e7832 1623 for(Int_t phas=0; phas<kNClockPhase;phas++){
1624
1625 nevent = (Int_t)histXtrkFOtrue[phas]->GetEntries();
1626 if(nevent!=kNHisto)
1627 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1628 histXtrkFOtrue[phas]->SetAddress(&h);
1629 for(Int_t j=0;j<kNHisto;j++){
1630 histXtrkFOtrue[phas]->GetEntry(j);
1631 fHisTrackXFOtrue[j][phas]->Add(h);
1632 }
1633
1634 nevent = (Int_t)histZtrkFOtrue[phas]->GetEntries();
1635 if(nevent!=kNHisto)
1636 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1637 histZtrkFOtrue[phas]->SetAddress(&h);
1638 for(Int_t j=0;j<kNHisto;j++){
1639 histZtrkFOtrue[phas]->GetEntry(j);
1640 fHisTrackZFOtrue[j][phas]->Add(h);
1641 }
1642
1643 nevent = (Int_t)histXtrkFOfalse[phas]->GetEntries();
1644 if(nevent!=kNHisto)
1645 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1646 histXtrkFOfalse[phas]->SetAddress(&h);
1647 for(Int_t j=0;j<kNHisto;j++){
1648 histXtrkFOfalse[phas]->GetEntry(j);
1649 fHisTrackXFOfalse[j][phas]->Add(h);
1650 }
1651
1652 nevent = (Int_t)histZtrkFOfalse[phas]->GetEntries();
1653 if(nevent!=kNHisto)
1654 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1655 histZtrkFOfalse[phas]->SetAddress(&h);
1656 for(Int_t j=0;j<kNHisto;j++){
1657 histZtrkFOfalse[phas]->GetEntry(j);
1658 fHisTrackZFOfalse[j][phas]->Add(h);
1659 }
1660
1661 nevent = (Int_t)histXZtrkFOtrue[phas]->GetEntries();
1662 if(nevent!=kNHisto)
1663 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1664 histXZtrkFOtrue[phas]->SetAddress(&h2);
1665 for(Int_t j=0;j<kNHisto;j++){
1666 histXZtrkFOtrue[phas]->GetEntry(j);
1667 fHisTrackXZFOtrue[j][phas]->Add(h2);
1668 }
1669
1670 nevent = (Int_t)histXZtrkFOfalse[phas]->GetEntries();
1671 if(nevent!=kNHisto)
1672 {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
1673 histXZtrkFOfalse[phas]->SetAddress(&h2);
1674 for(Int_t j=0;j<kNHisto;j++){
1675 histXZtrkFOfalse[phas]->GetEntry(j);
1676 fHisTrackXZFOfalse[j][phas]->Add(h2);
1677 }
1678
1679 }
879cdb02 1680
943fb20f 1681 delete h;
1682 delete h2;
1683 delete h2i;
1684 delete p;
5fbd4fd6 1685
1686 if (file) {
1687 file->Close();
943fb20f 1688 delete file;
5fbd4fd6 1689 }
5fbd4fd6 1690return kTRUE;
1691}
061c42a0 1692