add new mergeable classes for chamber status and trigger statistics
[u/mrichter/AliRoot.git] / PWGPP / TRD / AliTRDcalibration.cxx
CommitLineData
1ee39b3a 1
2/**************************************************************************
3* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4* *
5* Author: The ALICE Off-line Project. *
6* Contributors are mentioned in the code where appropriate. *
7* *
8* Permission to use, copy, modify and distribute this software and its *
9* documentation strictly for non-commercial purposes is hereby granted *
10* without fee, provided that the above copyright notice appears in all *
11* copies and that both the copyright notice and this permission notice *
12* appear in the supporting documentation. The authors make no claims *
13* about the suitability of this software for any purpose. It is *
14* provided "as is" without express or implied warranty. *
15**************************************************************************/
16
17/////////////////////////////////////////////////////////////////////////////////
18//
19// AliTRDcalibration
20//
21// Task to run the calibration offline.
22// Author:
23// R. Bailhache (rbailhache@ikf.uni-frankfurt.de, R.Bailhache@gsi.de)
24//
25//////////////////////////////////////////////////////////////////////////////////
26
27
28#include "Riostream.h"
29#include "TChain.h"
30#include "TTree.h"
31#include "TProfile2D.h"
32#include "TH2I.h"
33#include "TH1F.h"
34#include "TList.h"
35#include "TMath.h"
36#include "TCanvas.h"
37#include "TObject.h"
38#include "TFile.h"
39#include "TObjArray.h"
40#include "TGraph.h"
41#include "TStyle.h"
42#include "TLegend.h"
43#include "TGraphErrors.h"
44
45#include "AliTRDrecoTask.h"
46#include "AliAnalysisManager.h"
47
48#include "AliESDInputHandler.h"
49#include "AliTRDtrackV1.h"
50#include "AliTRDseedV1.h"
51#include "AliTRDcluster.h"
52#include "info/AliTRDtrackInfo.h"
53#include "AliTRDcalibDB.h"
54
55#include "AliTRDCalibraFillHisto.h"
56#include "AliTRDCalibraFit.h"
57#include "AliTRDCalibraVdriftLinearFit.h"
58#include "AliTRDCalibraMode.h"
59#include "AliTRDCalibraVector.h"
60#include "./Cal/AliTRDCalPad.h"
61#include "./Cal/AliTRDCalDet.h"
1ee39b3a 62
63#include "AliLog.h"
64
65#include "AliTRDcalibration.h"
66
67
68ClassImp(AliTRDcalibration)
69
70//________________________________________________________________________
71AliTRDcalibration::AliTRDcalibration()
f8f46e4d 72 :AliTRDrecoTask()
1ee39b3a 73 ,fTrackInfo(0)
74 ,ftrdTrack(0)
75 ,fcl(0)
76 ,fTRDCalibraFillHisto(0)
77 ,fNbTRDTrack(0)
78 ,fNbTRDTrackOffline(0)
79 ,fNbTRDTrackStandalone(0)
80 ,fNbTRDTracklet(0)
81 ,fNbTRDTrackletOffline(0)
82 ,fNbTRDTrackletStandalone(0)
83 ,fNbTimeBin(0x0)
84 ,fNbTimeBinOffline(0x0)
85 ,fNbTimeBinStandalone(0x0)
86 ,fNbClusters(0)
87 ,fNbClustersOffline(0)
88 ,fNbClustersStandalone(0)
1fb72fc9 89 ,fPHSM(0)
90 ,fCHSM(0)
1ee39b3a 91 ,fPHSum(0)
92 ,fCHSum(0)
93 ,fDetSum(0)
94 ,fDetSumVector(0)
95 ,fHisto2d(kTRUE)
96 ,fVector2d(kFALSE)
97 ,fVdriftLinear(kTRUE)
98 ,flow(0)
99 ,fhigh(30)
41753415 100 ,fNbTimeBins(0)
1ee39b3a 101 ,ffillZero(kFALSE)
102 ,fnormalizeNbOfCluster(kFALSE)
103 ,fmaxCluster(0)
104 ,fOfflineTracks(kFALSE)
105 ,fStandaloneTracks(kFALSE)
106 ,fCompressPerDetector(kFALSE)
1ee39b3a 107 ,fGraph(0x0)
1fb72fc9 108 ,fArrayCalib(0x0)
1ee39b3a 109 ,fPostProcess(kFALSE)
110{
111 // Constructor
112
113 fNRefFigures = 17;
114
115 for(Int_t k = 0; k < 3; k++)
116 {
117 fNz[k]=0;
118 fNrphi[k]=0;
119 }
120
121}
f8f46e4d 122
123AliTRDcalibration::AliTRDcalibration(char* name)
124 :AliTRDrecoTask(name, "Calibration on tracks")
125 ,fTrackInfo(0)
126 ,ftrdTrack(0)
127 ,fcl(0)
128 ,fTRDCalibraFillHisto(0)
129 ,fNbTRDTrack(0)
130 ,fNbTRDTrackOffline(0)
131 ,fNbTRDTrackStandalone(0)
132 ,fNbTRDTracklet(0)
133 ,fNbTRDTrackletOffline(0)
134 ,fNbTRDTrackletStandalone(0)
135 ,fNbTimeBin(0x0)
136 ,fNbTimeBinOffline(0x0)
137 ,fNbTimeBinStandalone(0x0)
138 ,fNbClusters(0)
139 ,fNbClustersOffline(0)
140 ,fNbClustersStandalone(0)
141 ,fPHSM(0)
142 ,fCHSM(0)
143 ,fPHSum(0)
144 ,fCHSum(0)
145 ,fDetSum(0)
146 ,fDetSumVector(0)
147 ,fHisto2d(kTRUE)
148 ,fVector2d(kFALSE)
149 ,fVdriftLinear(kTRUE)
150 ,flow(0)
151 ,fhigh(30)
152 ,fNbTimeBins(0)
153 ,ffillZero(kFALSE)
154 ,fnormalizeNbOfCluster(kFALSE)
155 ,fmaxCluster(0)
156 ,fOfflineTracks(kFALSE)
157 ,fStandaloneTracks(kFALSE)
158 ,fCompressPerDetector(kFALSE)
159 ,fGraph(0x0)
160 ,fArrayCalib(0x0)
161 ,fPostProcess(kFALSE)
162{
163 // Constructor
164
165 fNRefFigures = 17;
166
167 for(Int_t k = 0; k < 3; k++)
168 {
169 fNz[k]=0;
170 fNrphi[k]=0;
171 }
172
173}
174
1ee39b3a 175//________________________________________________________________________
176AliTRDcalibration::~AliTRDcalibration()
177{
178 // Default destructor
4860c9db 179 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
180 //
1ee39b3a 181 if(fNbTRDTrack) delete fNbTRDTrack;
182 if(fNbTRDTrackOffline) delete fNbTRDTrackOffline;
183 if(fNbTRDTrackStandalone) delete fNbTRDTrackStandalone;
184 if(fNbTRDTracklet) delete fNbTRDTracklet;
185 if(fNbTRDTrackletOffline) delete fNbTRDTrackletOffline;
186 if(fNbTRDTrackletStandalone) delete fNbTRDTrackletStandalone;
187 if(fNbTimeBin) delete fNbTimeBin;
188 if(fNbTimeBinOffline) delete fNbTimeBinOffline;
189 if(fNbTimeBinStandalone) delete fNbTimeBinStandalone;
190 if(fNbClusters) delete fNbClusters;
191 if(fNbClustersOffline) delete fNbClustersOffline;
192 if(fNbClustersStandalone) delete fNbClustersStandalone;
1fb72fc9 193 if(fPHSM) delete fPHSM;
194 if(fCHSM) delete fCHSM;
1ee39b3a 195 if(fPHSum) delete fPHSum;
196 if(fCHSum) delete fCHSum;
197 if(fDetSum) delete fDetSum;
198 if(fDetSumVector) delete fDetSumVector;
1ee39b3a 199 if(fGraph){fGraph->Delete(); delete fGraph;}
1fb72fc9 200 if(fArrayCalib){fArrayCalib->Delete(); delete fArrayCalib;}
201
1ee39b3a 202}
203//________________________________________________________________________
f8f46e4d 204void AliTRDcalibration::UserCreateOutputObjects()
1ee39b3a 205{
206 // Create output objects
207
1ee39b3a 208 // Number of time bins
41753415 209 if(fNbTimeBins==0) {
210 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
211 fNbTimeBins = cal->GetNumberOfTimeBinsDCS();
212 if(fNbTimeBins <= 0){
213 AliWarning(Form("No of TimeBins from DB [%d] use default [30]", fNbTimeBins));
214 fNbTimeBins = 30;
215 }
216 }
1ee39b3a 217
218 // instance calibration: what to calibrate
219 fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
220 fTRDCalibraFillHisto->SetHisto2d(fHisto2d); // choose to use histograms
221 fTRDCalibraFillHisto->SetVector2d(fVector2d); // choose to use vectors
222 fTRDCalibraFillHisto->SetCH2dOn(); // choose to calibrate the gain
223 fTRDCalibraFillHisto->SetPH2dOn(); // choose to calibrate the drift velocity
224 fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF
225 fTRDCalibraFillHisto->SetLinearFitterOn(fVdriftLinear); // Other possibility vdrift VDRIFT
226 fTRDCalibraFillHisto->SetLinearFitterDebugOn(fVdriftLinear); // Other possibility vdrift
227
228 // segmentation (should be per default the max and add at the end)
229 for(Int_t k = 0; k < 3; k++){
230 if(((fNz[k] != 10) && (fNrphi[k] != 10)) && ((fNz[k] != 100) && (fNrphi[k] != 100))) {
231 fTRDCalibraFillHisto->SetNz(k,fNz[k]); // Mode calibration
232 fTRDCalibraFillHisto->SetNrphi(k,fNrphi[k]); // Mode calibration
233 }
234 else {
235 if((fNz[k] == 100) && (fNrphi[k] == 100)) {
236 if(fVector2d) AliInfo("The mode all together is not supported by the vector method");
237 fTRDCalibraFillHisto->SetAllTogether(k);
238 }
239 if((fNz[k] == 10) && (fNrphi[k] == 10)) {
240 if(fVector2d) AliInfo("The mode per supermodule is not supported by the vector method");
241 fTRDCalibraFillHisto->SetPerSuperModule(k);
242 }
243 }
244 }
245
246 // Debug level
247 fTRDCalibraFillHisto->SetDebugLevel(DebugLevel()); //debug stuff
248
249 // Init the stuff
41753415 250 fTRDCalibraFillHisto->Init2Dhistos(fNbTimeBins); // initialise the histos
1ee39b3a 251
252 // cuts
253 fTRDCalibraFillHisto->SetNumberClusters(flow); // At least flow clusters
254 fTRDCalibraFillHisto->SetNumberClustersf(fhigh); // The more fhigh clusters
255 fTRDCalibraFillHisto->SetFillWithZero(ffillZero); // Fill zeros
256 fTRDCalibraFillHisto->SetNormalizeNbOfCluster(fnormalizeNbOfCluster); // For iterations
257
258 // Add them to the container
259 fContainer = new TObjArray();
260 if(fHisto2d) {
261 fContainer->Add(fTRDCalibraFillHisto->GetCH2d()); //TH2I
262 fContainer->Add(fTRDCalibraFillHisto->GetPH2d()); //TProfile2D
263 fContainer->Add(fTRDCalibraFillHisto->GetPRF2d()); //TProfile2D
264 }
265 if(fVdriftLinear) fContainer->Add(fTRDCalibraFillHisto->GetVdriftLinearFit()); // Other drift velocity
266 if(fVector2d) fContainer->Add(fTRDCalibraFillHisto->GetCalibraVector()); //calibra vector
267
268 if(DebugLevel()) {
269
270 // Init the debug histos
271 fNbTRDTrack = new TH1F("TRDTrack","TRDTrack",500,0,500);
272 fNbTRDTrack->Sumw2();
273 fNbTRDTrackOffline = new TH1F("TRDTrackOffline","TRDTrackOffline",500,0,500);
274 fNbTRDTrackOffline->Sumw2();
275 fNbTRDTrackStandalone = new TH1F("TRDTrackStandalone","TRDTrackStandalone",500,0,500);
276 fNbTRDTrackStandalone->Sumw2();
277 //
278 fNbTRDTracklet = new TH1F("TRDTracklet","TRDTracklet",540,0.,540.);
279 fNbTRDTracklet->Sumw2();
280 fNbTRDTrackletOffline = new TH1F("TRDTrackletOffline","TRDTrackletOffline",540,0.,540.);
281 fNbTRDTrackletOffline->Sumw2();
282 fNbTRDTrackletStandalone = new TH1F("TRDTrackletStandalone","TRDTrackletStandalone",540,0.,540.);
283 fNbTRDTrackletStandalone->Sumw2();
284 //
285 fNbTimeBin = new TH1F("TimeBin","TimeBin",35,0,35);
286 fNbTimeBin->Sumw2();
287 fNbTimeBinOffline = new TH1F("TimeBinOffline","TimeBinOffline",35,0,35);
288 fNbTimeBinOffline->Sumw2();
289 fNbTimeBinStandalone = new TH1F("TimeBinStandalone","TimeBinStandalone",35,0,35);
290 fNbTimeBinStandalone->Sumw2();
291 //
292 fNbClusters = new TH1F("NbClusters","",35,0,35);
293 fNbClusters->Sumw2();
294 fNbClustersOffline = new TH1F("NbClustersOffline","",35,0,35);
295 fNbClustersOffline->Sumw2();
296 fNbClustersStandalone = new TH1F("NbClustersStandalone","",35,0,35);
297 fNbClustersStandalone->Sumw2();
298 //
1fb72fc9 299 fPHSM = new TProfile2D("PH2dSM","Nz10Nrphi10"
300 ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
301 ,18,0,18);
302 fPHSM->SetYTitle("Det/pad groups");
303 fPHSM->SetXTitle("time [#mus]");
304 fPHSM->SetZTitle("<PH> [a.u.]");
305 fPHSM->SetStats(0);
306 //
307 fCHSM = new TH2I("CH2dSM","Nz10Nrphi10",50,0,300,18,0,18);
308 fCHSM->SetYTitle("Det/pad groups");
309 fCHSM->SetXTitle("charge deposit [a.u]");
310 fCHSM->SetZTitle("counts");
311 fCHSM->SetStats(0);
312 fCHSM->Sumw2();
313 //
314 fPHSum = new TProfile2D("PH2dSum","Nz100Nrphi100"
315 ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
316 ,1,0,1);
1ee39b3a 317 fPHSum->SetYTitle("Det/pad groups");
318 fPHSum->SetXTitle("time [#mus]");
319 fPHSum->SetZTitle("<PH> [a.u.]");
320 fPHSum->SetStats(0);
321 //
1fb72fc9 322 fCHSum = new TH2I("CH2dSum","Nz100Nrphi100",50,0,300,1,0,1);
1ee39b3a 323 fCHSum->SetYTitle("Det/pad groups");
324 fCHSum->SetXTitle("charge deposit [a.u]");
325 fCHSum->SetZTitle("counts");
326 fCHSum->SetStats(0);
327 fCHSum->Sumw2();
328
329 // Add them
330 fContainer->Add(fNbTRDTrack);
331 fContainer->Add(fNbTRDTrackOffline);
332 fContainer->Add(fNbTRDTrackStandalone);
333 fContainer->Add(fNbTRDTracklet);
334 fContainer->Add(fNbTRDTrackletOffline);
335 fContainer->Add(fNbTRDTrackletStandalone);
336 fContainer->Add(fNbTimeBin);
337 fContainer->Add(fNbTimeBinOffline);
338 fContainer->Add(fNbTimeBinStandalone);
339 fContainer->Add(fNbClusters);
340 fContainer->Add(fNbClustersOffline);
341 fContainer->Add(fNbClustersStandalone);
1fb72fc9 342 fContainer->Add(fPHSM);
343 fContainer->Add(fCHSM);
1ee39b3a 344 fContainer->Add(fPHSum);
345 fContainer->Add(fCHSum);
346
347 }
068e2c00 348 // Post output data
349 PostData(1, fContainer);
1ee39b3a 350}
351
352//________________________________________________________________________
f8f46e4d 353void AliTRDcalibration::UserExec(Option_t *)
1ee39b3a 354{
355 //
356 // Execute function where the reference data are filled
357 //
358
359 if(!fTracks) return;
360
361 // In total
362 Int_t nbTrdTracks = 0;
363 // standalone
364 Int_t nbTrdTracksStandalone = 0;
365 // offline
366 Int_t nbTrdTracksOffline = 0;
367
368
369 //
370 // Loop on track in the event
371 //
372 //printf("Total of %d\n",fTracks->GetEntriesFast());
373 for(Int_t itrk=0; itrk < fTracks->GetEntriesFast(); itrk++){
374
375 //printf("itrk %d\n",itrk);
376
377 fTrackInfo = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
378 ftrdTrack = fTrackInfo->GetTrack();
379 if(!ftrdTrack) continue;
380
381 nbTrdTracks++;
382
383 fTRDCalibraFillHisto->UpdateHistogramsV1(ftrdTrack);
384
385 if(DebugLevel()) {
386
387 Bool_t standalonetracklet = kFALSE;
388 const AliTRDseedV1 *tracklet = 0x0;
389 //
390 // Loop on tracklet in the event
391 //
392 for(Int_t itr = 0; itr < 6; itr++){
393 //printf("itr %d\n",itr);
394 if(!(tracklet = ftrdTrack->GetTracklet(itr))) continue;
395 if(!tracklet->IsOK()) continue;
396 // standalone
397 if(tracklet->IsStandAlone()) standalonetracklet = kTRUE;
398 Int_t nbclusters = 0;
399 // For PH
400 Double_t phtb[AliTRDseedV1::kNtb];
401 memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
402 // For CH
403 Double_t sum = 0.0;
404 // normalisation
405 Float_t normalisation = 6.67;
406 Int_t detector = 0;
1fb72fc9 407 Int_t sector = 0;
1ee39b3a 408 Int_t crossrow = 0;
1fb72fc9 409 // Check no shared clusters
410 for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
411 if((fcl = tracklet->GetClusters(icc))) crossrow = 1;
412 }
413 // Loop on clusters
1ee39b3a 414 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
1ee39b3a 415 if(!(fcl = tracklet->GetClusters(ic))) continue;
416 nbclusters++;
417 Int_t time = fcl->GetPadTime();
418 Float_t ch = tracklet->GetdQdl(ic);
419 Float_t qcl = TMath::Abs(fcl->GetQ());
420 detector = fcl->GetDetector();
421 if((time>-1) && (time<fNbTimeBins)) phtb[time]=qcl;
422 sum += ch/normalisation;
423 fNbTimeBin->Fill(time);
424 if(tracklet->IsStandAlone()) fNbTimeBinStandalone->Fill(time);
425 else fNbTimeBinOffline->Fill(time);
426 }
1fb72fc9 427 sector = AliTRDgeometry::GetSector(detector);
1ee39b3a 428
429 fNbTRDTracklet->Fill(detector);
430 if(tracklet->IsStandAlone()) fNbTRDTrackletStandalone->Fill(detector);
431 else fNbTRDTrackletOffline->Fill(detector);
432
433 fNbClusters->Fill(nbclusters);
434 if(tracklet->IsStandAlone()) fNbClustersStandalone->Fill(nbclusters);
435 else fNbClustersOffline->Fill(nbclusters);
436
437 if((nbclusters > flow) && (nbclusters < fhigh)){
1fb72fc9 438 fCHSM->Fill(sum/20.0,sector+0.5);
439 fCHSum->Fill(sum/20.0,0.5);
1ee39b3a 440 for(int ic=0; ic<fNbTimeBins; ic++){
1fb72fc9 441 if(ffillZero) {
442 fPHSum->Fill((Double_t)(ic/10.0),0.5,(Double_t)phtb[ic]);
443 fPHSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
444 }
1ee39b3a 445 else {
1fb72fc9 446 if(phtb[ic] > 0.0) {
447 fPHSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
448 fPHSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
449 }
1ee39b3a 450 }
451 }
452 }
453 }
454
455 if(standalonetracklet) nbTrdTracksStandalone++;
456 else nbTrdTracksOffline++;
457
458 }
459
460 }
461
462 if(DebugLevel()) {
463
464 //Fill Histos
465 fNbTRDTrack->Fill(nbTrdTracks);
466 fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
467 fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
468
469 }
068e2c00 470}
471
1ee39b3a 472//________________________________________________________________________
473void AliTRDcalibration::Terminate(Option_t *)
474{
475 // Draw result to the screen
476 // Called once at the end of the query
477
478 //printf("terminate\n");
479
480 if(fTRDCalibraFillHisto) fTRDCalibraFillHisto->DestroyDebugStreamer();
481
482}
483//________________________________________________________
484Bool_t AliTRDcalibration::GetRefFigure(Int_t ifig)
485{
486 //
487 // Draw filled histos
488 //
489
490 gStyle->SetPalette(1);
491 gStyle->SetOptStat(1111);
492 gStyle->SetPadBorderMode(0);
493 gStyle->SetCanvasColor(10);
494 gStyle->SetPadLeftMargin(0.13);
495 gStyle->SetPadRightMargin(0.13);
496
497 if(!fContainer) return kFALSE;
498
499 switch(ifig){
500 case kNbTrack:{
501 TCanvas *c0 = new TCanvas("c0","c0",10,10,510,510);
502 TLegend *legNbTrack = new TLegend(.7, .7, .98, .98);
503 legNbTrack->SetBorderSize(1);
504 TH1F *h = 0x0;
505 TH1F *ho = 0x0;
506 TH1F *hs = 0x0;
507 if(!(h = (TH1F *)fContainer->FindObject("TRDTrack"))) break;
508 if(!(ho = (TH1F *)fContainer->FindObject("TRDTrackOffline"))) break;
509 if(!(hs = (TH1F *)fContainer->FindObject("TRDTrackStandalone"))) break;
510 c0->cd();
511 //gPad->SetLogy();
512 gPad->SetGridy();
513 gPad->SetGridx();
514 h->Draw();
515 ho->Draw("same");
516 hs->Draw("same");
517 legNbTrack->AddEntry(h, "all", "p");
518 legNbTrack->AddEntry(ho, "offline", "p");
519 legNbTrack->AddEntry(hs, "standalone", "p");
520 legNbTrack->Draw("same");
521 return kTRUE;
522 }
523 case kNbTracklet:{
524 TLegend *legNbTracklet = new TLegend(.7, .7, .98, .98);
525 legNbTracklet->SetBorderSize(1);
526 TH1F *h = 0x0;
527 TH1F *ho = 0x0;
528 TH1F *hs = 0x0;
529 if(!(h = (TH1F *)fContainer->FindObject("TRDTracklet"))) break;
530 if(!(ho = (TH1F *)fContainer->FindObject("TRDTrackletOffline"))) break;
531 if(!(hs = (TH1F *)fContainer->FindObject("TRDTrackletStandalone"))) break;
532 h->Draw();
533 ho->Draw("same");
534 hs->Draw("same");
535 legNbTracklet->AddEntry(h, "all", "p");
536 legNbTracklet->AddEntry(ho, "offline", "p");
537 legNbTracklet->AddEntry(hs, "standalone", "p");
538 legNbTracklet->Draw("same");
539 gPad->SetLogy();
540 gPad->SetGridy();
541 gPad->SetGridx();
542 return kTRUE;
543 }
544 case kNbTimeBin:{
545 TLegend *legNbTimeBin = new TLegend(.7, .7, .98, .98);
546 legNbTimeBin->SetBorderSize(1);
547 TH1F *h = 0x0;
548 TH1F *ho = 0x0;
549 TH1F *hs = 0x0;
550 if(!(h = (TH1F *)fContainer->FindObject("TimeBin"))) break;
551 if(!(ho = (TH1F *)fContainer->FindObject("TimeBinOffline"))) break;
552 if(!(hs = (TH1F *)fContainer->FindObject("TimeBinStandalone"))) break;
553 h->Draw();
554 ho->Draw("same");
555 hs->Draw("same");
556 legNbTimeBin->AddEntry(h, "all", "p");
557 legNbTimeBin->AddEntry(ho, "offline", "p");
558 legNbTimeBin->AddEntry(hs, "standalone", "p");
559 legNbTimeBin->Draw("same");
560 //gPad->SetLogy();
561 gPad->SetGridy();
562 gPad->SetGridx();
563 return kTRUE;
564 }
565 case kNbClusters:{
566 TLegend *legNbClusters = new TLegend(.7, .7, .98, .98);
567 legNbClusters->SetBorderSize(1);
568 TH1F *h = 0x0;
569 TH1F *ho = 0x0;
570 TH1F *hs = 0x0;
571 if(!(h = (TH1F *)fContainer->FindObject("NbClusters"))) break;
572 if(!(ho = (TH1F *)fContainer->FindObject("NbClustersOffline"))) break;
573 if(!(hs = (TH1F *)fContainer->FindObject("NbClustersStandalone"))) break;
574 h->Draw();
575 ho->Draw("same");
576 hs->Draw("same");
577 legNbClusters->AddEntry(h, "all", "p");
578 legNbClusters->AddEntry(ho, "offline", "p");
579 legNbClusters->AddEntry(hs, "standalone", "p");
580 legNbClusters->Draw("same");
581 gPad->SetLogy();
582 gPad->SetGridy();
583 gPad->SetGridx();
584 return kTRUE;
585 }
586 case kPHSum:{
587 TProfile2D *h = 0x0;
588 if(!(h = (TProfile2D *)fContainer->FindObject("PH2dSum"))) break;
589 TH1D *projh = h->ProjectionX("projh",1,1,"e");
590 projh->Draw();
591 gPad->SetGridy();
592 gPad->SetGridx();
593 return kTRUE;
594 }
595 case kCHSum:{
596 TH2I *h = 0x0;
597 if(!(h = (TH2I *)fContainer->FindObject("CH2dSum"))) break;
598 TH1D *projh = h->ProjectionX("projhh",1,1,"e");
599 projh->Draw();
600 gPad->SetGridy();
601 gPad->SetGridx();
602 return kTRUE;
603 }
604 case kPH2D:{
605 if(!fHisto2d) {
606 AliInfo("Histo was not filled!");
607 break;
608 }
609 TProfile2D *h = 0x0;
610 if(!(h = (TProfile2D *)fContainer->FindObject("PH2d"))) break;
611 h->Draw("lego");
612 return kTRUE;
613 }
614 case kCH2D:{
615 if(!fHisto2d) {
616 AliInfo("Histo was not filled!");
617 break;
618 }
619 TH2I *h = 0x0;
620 if(!(h = (TH2I *)fContainer->FindObject("CH2d"))) break;
621 h->Draw("lego");
622 return kTRUE;
623 }
624 case kPRF2D:{
625 if(!fHisto2d) {
626 AliInfo("Histo was not filled!");
627 break;
628 }
629 TProfile2D *h = 0x0;
630 if(!(h = (TProfile2D *)fContainer->FindObject("PRF2d"))) break;
631 h->Draw("lego");
632 return kTRUE;
633 }
634 case kPH2DVector:{
635 if(!fVector2d) {
636 AliInfo("vector was not filled!");
637 break;
638 }
639 AliTRDCalibraVector *v = 0x0;
640 TGraphErrors *vdet = 0x0;
641 if(!(v = (AliTRDCalibraVector *)fContainer->FindObject("AliTRDCalibraVector"))) break;
642 Int_t detectormax = -1;
643 Int_t groupmax = -1;
644 if(!v->FindTheMaxEntries(1,detectormax,groupmax)) break;
645 if(!(vdet = v->ConvertVectorPHTGraphErrors((Int_t)detectormax,groupmax,"plotPH2dVector"))) break;
646 Int_t nbeentries = 0;
647 TH1F *ko = v->CorrectTheError(vdet,nbeentries);
648 ko->Draw();
649 AliInfo(Form("There are %d entries in the detector %d and group %d",nbeentries,detectormax,groupmax));
650 return kTRUE;
651 }
652case kCH2DVector:{
653 if(!fVector2d) {
654 AliInfo("vector was not filled!");
655 break;
656 }
657 AliTRDCalibraVector *v = 0x0;
658 TH1F *vdet = 0x0;
659 if(!(v = (AliTRDCalibraVector *)fContainer->FindObject("AliTRDCalibraVector"))) break;
660 Int_t detectormax = -1;
661 Int_t groupmax = -1;
662 if(!v->FindTheMaxEntries(0,detectormax,groupmax)) break;
663 if(!(vdet = v->ConvertVectorCHHisto((Int_t)detectormax,groupmax,"plotCH2dVector"))) break;
664 vdet->Draw();
665 AliInfo(Form("The detectormax and groupmax are %d and %d",detectormax,groupmax));
666 return kTRUE;
667 }
668 case kPRF2DVector:{
669 if(!fVector2d) {
670 AliInfo("vector was not filled!");
671 break;
672 }
673 AliTRDCalibraVector *v = 0x0;
674 TGraphErrors *vdet = 0x0;
675 if(!(v = (AliTRDCalibraVector *)fContainer->FindObject("AliTRDCalibraVector"))) break;
676 Int_t detectormax = -1;
677 Int_t groupmax = -1;
678 Int_t nbeentries = 0;
679 if(!v->FindTheMaxEntries(2,detectormax,groupmax)) break;
680 if(!(vdet = v->ConvertVectorPRFTGraphErrors((Int_t)detectormax,groupmax,"plotPRF2dVector"))) break;
681 TH1F *ko = v->CorrectTheError(vdet,nbeentries);
682 ko->Draw();
683 AliInfo(Form("The detectormax and groupmax are %d and %d",detectormax,groupmax));
684 return kTRUE;
685 }
686 case kLinearFitter:{
687 if(!fVdriftLinear) {
688 AliInfo("vdrift linear was not filled!");
689 break;
690 }
691 AliTRDCalibraVdriftLinearFit *h = 0x0;
692 TH2S *hdetector = 0x0;
693 if(!(h = (AliTRDCalibraVdriftLinearFit *)fContainer->FindObject("AliTRDCalibraVdriftLinearFit"))) break;
694 Double_t entries[540];
695 for(Int_t k = 0; k < 540; k++){
696 entries[k] = 0.0;
697 hdetector = 0x0;
698 if(!(hdetector = (TH2S *)h->GetLinearFitterHisto(k,kFALSE))) continue;
699 entries[k] = hdetector->GetEntries();
700 }
701 Double_t max = -10.0;
702 Double_t detectormax = -1;
703 for(Int_t k = 0; k < 540; k++){
704 if(entries[k] > max) {
705 max = entries[k];
706 detectormax = k;
707 }
708 }
709 hdetector = 0x0;
710 if((TMath::Abs(max) <= 0.001) || (detectormax <0.0) || (detectormax >=540.0)) break;
711 if(!(hdetector = (TH2S *)h->GetLinearFitterHisto((Int_t)detectormax,kFALSE))) break;
ca50a37e 712 AliInfo(Form("The detector with the maximum of entries is %f",detectormax));
1ee39b3a 713 hdetector->Draw();
714 return kTRUE;
715 }
716 case kGainFactor:{
717 if(!fPostProcess){
718 if(!PostProcess()) break;
719 }
720 TGraph *fgain = (TGraph *) fGraph->At(0);
721 if(!fgain) break;
722 fgain->Draw("ALP");
723 return kTRUE;
724 }
725 case kVdriftT0Factor:{
726 if(!fPostProcess){
727 if(!PostProcess()) break;
728 }
729 TCanvas *c = new TCanvas("c","c",10,10,510,510);
730 c->Divide(2,1);
731 TGraph *fvd = (TGraph *) fGraph->At(1);
732 if(fvd){
733 c->cd(1);
734 fvd->Draw("ALP");
735 }
736 TGraph *ft0 = (TGraph *) fGraph->At(2);
737 if(ft0){
738 c->cd(2);
739 ft0->Draw("ALP");
740 }
741 return kTRUE;
742 }
743 case kVdriftLorentzAngleFactor:{
744 if(!fVdriftLinear) {
745 AliInfo("vdrift linear was not filled!");
746 break;
747 }
748 if(!fPostProcess){
749 if(!PostProcess()) break;
750 }
751 TCanvas *c = new TCanvas("c","c",10,10,510,510);
752 c->Divide(2,1);
753 TGraph *fvdl = (TGraph *) fGraph->At(3);
754 if(fvdl){
755 c->cd(1);
756 fvdl->Draw("ALP");
757 }
758 TGraph *flal = (TGraph *) fGraph->At(4);
759 if(flal){
760 c->cd(2);
761 flal->Draw("ALP");
762 }
763 return kTRUE;
764 }
765 case kPRFFactor:{
766 if(!fPostProcess){
767 if(!PostProcess()) break;
768 }
769 TGraph *fprf = (TGraph *) fGraph->At(5);
770 if(!fprf) break;
771 fprf->Draw("ALP");
772 return kTRUE;
773 }
774 }
775
776 return kFALSE;
777
778}
779//________________________________________________________________________
780Bool_t AliTRDcalibration::PostProcess()
781{
782 //
783 // Fit the filled histos
1fb72fc9 784 // Put the calibration object in fArrayCalib
785 // 0 and 1 AliTRDCalDet and AliTRDCalPad gain
786 // 2 and 3 AliTRDCalDet and AliTRDCalPad vdrift PH
787 // 4 and 5 AliTRDCalDet and AliTRDCalPad timeoffset PH
788 // 6 AliTRDCalPad PRF
789 // 7 and 8 AliTRDCalDet and AliTRDCalPad vdrift second
790 // 9 and 10 AliTRDCalDet and AliTRDCalPad lorentz angle second
1ee39b3a 791 //
792
1fb72fc9 793 if(!fArrayCalib){
794 fArrayCalib = new TObjArray(11);
795 fArrayCalib->SetOwner();
796 }
797 else {
798 delete fArrayCalib;
799 PostProcess();
800 }
801
1ee39b3a 802 if(!fGraph){
803 fGraph = new TObjArray(6);
804 fGraph->SetOwner();
805 }
806 else {
807 delete fGraph;
808 PostProcess();
809 }
810
811 Bool_t storage[3] = {kFALSE,kFALSE,kFALSE};
812
1ee39b3a 813 // Objects for fitting
814 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
815 calibra->SetDebugLevel(2); // 0 rien, 1 fitvoir, 2 debug files, 3 one detector
816
817 // Take the stuff
818 if (!fContainer) {
819 Printf("ERROR: list not available");
820 return kFALSE;
821 }
822
823 if(fHisto2d && fVector2d) AliInfo("We will only look at histos. Set fHisto2d off if you don't want");
824 AliTRDCalibraVector *calibraVector = 0x0;
825 if(fVector2d) calibraVector = (AliTRDCalibraVector *) fContainer->FindObject("CalibraVector");
826 //
827 // GAIN TH2I
828 //
829 Bool_t pass = kFALSE;
830 AliTRDCalibraVector *vvect = 0x0;
831 if(fHisto2d) {
832 TH2I *histogain = (TH2I *) fContainer->FindObject("CH2d");
833 if(histogain) {
834 histogain->SetDirectory(0);
835 calibra->SetMinEntries(20);
836 if(fCompressPerDetector){
837 if(AddStatsPerDetector(histogain)) pass = calibra->AnalyseCH(fCHSum);
838 }
839 else pass = calibra->AnalyseCH(histogain);
840 }
841 }
842 else {
843 if(fVector2d && calibraVector) {
844 calibra->SetMinEntries(20);
845 if(fCompressPerDetector){
846 if(!(vvect = calibraVector->AddStatsPerDetectorCH())) return kFALSE;
847 pass = calibra->AnalyseCH(vvect);
848 }
849 else pass = calibra->AnalyseCH(calibraVector);
850 }
851 }
852
853 if(pass)
854 {
855 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
856 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
857 Int_t nbfit = calibra->GetNumberFit(); //Number of fits
858 Int_t nbE = calibra->GetNumberEnt(); //Number of detector mit entries
859 // enough statistics
860 if ((nbtg > 0) &&
861 (nbfit >= 0.001*nbE))
862 {
863 // create the cal objects
864 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
865 TObjArray object = calibra->GetVectorFit();
866 AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object);
867 TObject *objgainpad = calibra->CreatePadObjectGain();
868 // store
1fb72fc9 869 fArrayCalib->AddAt(objgaindet,0);
870 fArrayCalib->AddAt(objgainpad,1);
1ee39b3a 871 storage[0] = kTRUE;
872 // Make graph
873 TGraph *graph = 0x0;
874 if(FillGraphIndex(&object,graph)){
875 fGraph->AddAt(graph,0);
876 }
877 }//if(enough statistics?)
878 calibra->ResetVectorFit();
879 }
880 else return kFALSE;
881
882 //
883 // VDRIFT average pulse height
884 //
885 pass = kFALSE;
886 if(fHisto2d) {
887 TProfile2D *histodriftvelocity = (TProfile2D *) fContainer->FindObject("PH2d");
888 if(histodriftvelocity) {
889 histodriftvelocity->SetDirectory(0);
890 calibra->SetMinEntries(20*20);
891 if(fCompressPerDetector){
892 if(AddStatsPerDetector(histodriftvelocity,1)) {
893 pass = calibra->AnalysePH(fDetSumVector);
894 }
895 }
896 else pass = calibra->AnalysePH(histodriftvelocity);
897 }
898 }
899 else {
900 if(fVector2d && calibraVector) {
901 calibra->SetMinEntries(20*20);
902 if(fCompressPerDetector){
903 if(!(vvect = calibraVector->AddStatsPerDetectorPH())) return kFALSE;
904 pass = calibra->AnalysePH(vvect);
905 }
906 else pass = calibra->AnalysePH(calibraVector);
907 }
908 }
909
910 if(pass) {
911 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
912 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
913 Int_t nbfit = calibra->GetNumberFit();
914 Int_t nbE = calibra->GetNumberEnt();
915 // enough statistics
916 if ((nbtg > 0) &&
917 (nbfit >= 0.001*nbE))
918 {
919 // create the cal objects
920 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
921 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
922 TObjArray object = calibra->GetVectorFit();
923 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
924 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
925 TObjArray objectt = calibra->GetVectorFit2();
926 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
927 TObject *objtime0pad = calibra->CreatePadObjectT0();
928 // store
1fb72fc9 929 fArrayCalib->AddAt(objdriftvelocitydet,2);
930 fArrayCalib->AddAt(objdriftvelocitypad,3);
1ee39b3a 931 //
1fb72fc9 932 fArrayCalib->AddAt(objtime0det,4);
933 fArrayCalib->AddAt(objtime0pad,5);
1ee39b3a 934 // Make graph
935 TGraph *graph = 0x0;
936 if(FillGraphIndex(&object,graph)){
937 fGraph->AddAt(graph,1);
938 }
939 TGraph *graphh = 0x0;
940 if(FillGraphIndex(&objectt,graphh)){
941 fGraph->AddAt(graphh,2);
942 }
943 }//if(enough statistics)
944 calibra->ResetVectorFit();
945 }
946 else return kFALSE;
947
948 //
949 // PRF
950 //
951 pass = kFALSE;
952 if(fHisto2d) {
953 TProfile2D *histoprf = (TProfile2D *) fContainer->FindObject("PRF2d");
954 if (histoprf) {
955 histoprf->SetDirectory(0);
956 calibra->SetMinEntries(600);
957 if(fCompressPerDetector){
958 if(AddStatsPerDetector(histoprf,2)) pass = calibra->AnalysePRFMarianFit(fDetSumVector);
959 }
960 else pass = calibra->AnalysePRFMarianFit(histoprf);
961 }
962 }
963 else {
964 if(fVector2d && calibraVector) {
965 calibra->SetMinEntries(600);
966 if(fCompressPerDetector){
967 if(!(vvect =calibraVector->AddStatsPerDetectorPRF())) return kFALSE;
968 pass = calibra->AnalysePRFMarianFit(vvect);
969 }
970 else pass = calibra->AnalysePRFMarianFit(calibraVector);
971 }
972 }
973
974 if(pass){
975 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
976 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
977 Int_t nbfit = calibra->GetNumberFit();
978 Int_t nbE = calibra->GetNumberEnt();
979 // enough statistics
980 if ((nbtg > 0) &&
981 (nbfit >= 0.001*nbE)) {
982 TObjArray object = calibra->GetVectorFit();
983 TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
984 // store
1fb72fc9 985 fArrayCalib->AddAt(objPRFpad,6);
1ee39b3a 986 // Make graph
987 TGraph *graph = 0x0;
988 if(FillGraphIndex(&object,graph)){
989 fGraph->AddAt(graph,5);
990 }
991 }
992 calibra->ResetVectorFit();
993 }
994 else return kFALSE;
995
996 //
997 // VDRIFT linear fit
998 //
999 AliTRDCalibraVdriftLinearFit *vlinearfit = (AliTRDCalibraVdriftLinearFit *) fContainer->FindObject("LinearVdriftFit");
1000 if (vlinearfit) {
1001 calibra->SetMinEntries(20*20);
1002 if(calibra->AnalyseLinearFitters(vlinearfit)) {
1003
1004 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
1005 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
1006 Int_t nbfit = calibra->GetNumberFit();
1007 Int_t nbE = calibra->GetNumberEnt();
1008 // enough statistics
1009 if ((nbtg > 0) &&
1010 (nbfit >= 0.001*nbE))
1011 {
1012 // create the cal objects
1013 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
1014 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
1015 TObjArray object = calibra->GetVectorFit();
1016 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
1017 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
1018 TObjArray objectt = calibra->GetVectorFit2();
1019 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
1020 TObject *objtime0pad = calibra->CreatePadObjectT0();
1021 // store dummy
1fb72fc9 1022 fArrayCalib->AddAt(objdriftvelocitydet,7);
1023 fArrayCalib->AddAt(objdriftvelocitypad,8);
1ee39b3a 1024 //
1fb72fc9 1025 fArrayCalib->AddAt(objtime0det,9);
1026 fArrayCalib->AddAt(objtime0pad,10);
1ee39b3a 1027 // Make graph
1028 TGraph *graph = 0x0;
1029 if(FillGraphIndex(&object,graph)){
1030 fGraph->AddAt(graph,3);
1031 }
1032 TGraph *graphh = 0x0;
1033 if(FillGraphIndex(&objectt,graphh)){
1034 fGraph->AddAt(graphh,4);
1035 }
1036 }//if(enough statistics)
1037 }// if fit
1038 calibra->ResetVectorFit();
1039 }
1040 else return kFALSE;
1041
1042 fPostProcess = kTRUE;
1043
1044 return kTRUE;
1045
1046}
1047
1048//________________________________________________________________________
1049Bool_t AliTRDcalibration::FillGraphIndex(const TObjArray *vectora,TGraph *graph) const
1050{
1051 //
1052 // Fill one value (the first one) per detector
1053 //
1054
1055 Int_t loop = (Int_t) vectora->GetEntriesFast();
1056 if(loop != 540) {
1057 AliInfo("The Vector Fit is not complete!");
1058 return kFALSE;
1059 }
1060
1061 Double_t x[540];
1062 Double_t y[540];
1063 for (Int_t k = 0; k < loop; k++) {
1064 if(!vectora->At(k)){
1065 x[k] = -1.0;
1066 y[k] = -1.0;
1067 continue;
1068 }
1069 x[k] = ((AliTRDCalibraFit::AliTRDFitInfo *) vectora->At(k))->GetDetector();
1070 y[k] = ((Float_t *)((AliTRDCalibraFit::AliTRDFitInfo *) vectora->At(k))->GetCoef())[0];
1071 }
1072
7fe4e88b 1073 if(!graph){
1074 graph = new TGraph(540,&x[0],&y[0]);
1075 graph->SetMarkerStyle(20);
1076 } else{
1ee39b3a 1077 graph->~TGraph();
1078 new(graph) TGraph(540,&x[0],&y[0]);
1079 }
1080
1081 return kTRUE;
1082
1083}
1084//________________________________________________________________________
1085Bool_t AliTRDcalibration::AddStatsPerDetector(const TH2I *ch)
1086{
1087 //
1088 // Add statistic per detector
1089 //
1090
1091 AliTRDCalibraMode calibMode = AliTRDCalibraMode();
1092 const char *name = ch->GetTitle();
1093 if(!SetNzFromTObject(name,0,&calibMode)) return 0x0;
1094 if(!SetNrphiFromTObject(name,0,&calibMode)) return 0x0;
1095 if(((calibMode.GetNz(0) == 100) && (calibMode.GetNrphi(0) == 100)) || ((calibMode.GetNz(0) == 10) && (calibMode.GetNrphi(0) == 10))) return kFALSE;
1096
1097 Int_t nybins = ch->GetNbinsY();// groups number
1098 Int_t nxbins = ch->GetNbinsX();// number of bins X
1099 TAxis *xaxis = ch->GetXaxis();
1100 Double_t lowedge = xaxis->GetBinLowEdge(1);
1101 Double_t upedge = xaxis->GetBinUpEdge(nxbins);
1102
1103 // number per chamber 2
1104 calibMode.ModePadCalibration(2,0);
1105 calibMode.ModePadFragmentation(0,2,0,0);
1106 calibMode.SetDetChamb2(0);
1107 Int_t perChamber2 = (Int_t) calibMode.GetDetChamb2(0);
1108
1109 // number per other chamber
1110 calibMode.ModePadCalibration(0,0);
1111 calibMode.ModePadFragmentation(0,0,0,0);
1112 calibMode.SetDetChamb0(0);
1113 Int_t perChamber0 = (Int_t) calibMode.GetDetChamb0(0);
1114
1115 if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return kFALSE;
1116
1117 // Create Histo
1118 TString nname((const char *)ch->GetName());
1119 nname += "PerDetector";
1120 TString title("Nz");
1121 title += 0;
1122 title += "Nrphi";
1123 title += 0;
1124 if(!fCHSum) fCHSum = new TH2I((const char *)nname,(const char *)title
1125 ,nxbins,lowedge,upedge,540,0,540);
1126 else{
1127 fCHSum->~TH2I();
1128 new(fCHSum) TH2I((const Char_t *) nname,(const char *)title
1129 ,nxbins,lowedge,upedge,540,0,540);
1130 }
1131 fCHSum->SetYTitle("Detector number");
1132 fCHSum->SetXTitle("charge deposit [a.u]");
1133 fCHSum->SetZTitle("counts");
1134 fCHSum->SetStats(0);
1135 fCHSum->Sumw2();
1136
1137 Int_t counter = 0;
1138
1139 for(Int_t det = 0; det < 540; det++){
1140
1141 Int_t numberofgroup = 0;
1142 if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
1143 else numberofgroup = perChamber0;
1144 TH1I *projch = (TH1I *) ch->ProjectionX("projch",counter+1,counter+numberofgroup,(Option_t *)"e");
1145 projch->SetDirectory(0);
1146
1147 for(Int_t nx = 0; nx <= nxbins; nx++) {
1148 fCHSum->SetBinContent(nx,det+1,projch->GetBinContent(nx));
1149 fCHSum->SetBinError(nx,det+1,projch->GetBinError(nx));
1150 }
1151
1152 counter += numberofgroup;
1153
1154 delete projch;
1155
1156 }
1157
1158 return kTRUE;
1159
1160}
1161//_____________________________________________________________________________________________________________________
1162Bool_t AliTRDcalibration::AddStatsPerDetector(const TProfile2D *ph,Int_t i)
1163{
1164 //
1165 // Add statistic per detector
1166 //
1167
1168 AliTRDCalibraMode calibMode = AliTRDCalibraMode();
1169 const char *name = ph->GetTitle();
1170 //printf("name %s\n",name);
1171 if(!SetNzFromTObject(name,0,&calibMode)) return kFALSE;
1172 if(!SetNrphiFromTObject(name,0,&calibMode)) return kFALSE;
1173 if(((calibMode.GetNz(0) == 100) && (calibMode.GetNrphi(0) == 100)) || ((calibMode.GetNz(0) == 10) && (calibMode.GetNrphi(0) == 10))) return kFALSE;
1174 //printf("Found mode Mz %d, Nrphi %d\n",calibMode.GetNz(0),calibMode.GetNrphi(0));
1175
1176
1177 Int_t nybins = ph->GetNbinsY();// groups number
1178 Int_t nxbins = ph->GetNbinsX();// number of bins X
1179 TAxis *xaxis = ph->GetXaxis();
1180 Double_t lowedge = xaxis->GetBinLowEdge(1);
1181 Double_t upedge = xaxis->GetBinUpEdge(nxbins);
1182
1183 // number per chamber 2
1184 calibMode.ModePadCalibration(2,0);
1185 calibMode.ModePadFragmentation(0,2,0,0);
1186 calibMode.SetDetChamb2(0);
1187 Int_t perChamber2 = (Int_t) calibMode.GetDetChamb2(0);
1188
1189 // number per other chamber
1190 calibMode.ModePadCalibration(0,0);
1191 calibMode.ModePadFragmentation(0,0,0,0);
1192 calibMode.SetDetChamb0(0);
1193 Int_t perChamber0 = (Int_t) calibMode.GetDetChamb0(0);
1194
1195 if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return kFALSE;
1196
1197 // Create calvector
1198 TString nbname((const char *)ph->GetName());
1199 nbname += "PerDetectorVector";
1200 if(!fDetSumVector) fDetSumVector = new AliTRDCalibraVector();
1201 else{
1202 fDetSumVector->~AliTRDCalibraVector();
1203 new(fDetSumVector) AliTRDCalibraVector();
1204 }
1205 if(i==1){
1206 fDetSumVector->SetTimeMax(nxbins);
1207 }
1208 if(i==2){
1209 fDetSumVector->SetNumberBinPRF(nxbins);
1210 fDetSumVector->SetPRFRange(TMath::Abs(lowedge));
1211 }
1212 fDetSumVector->SetDetCha0(i,1);
1213 fDetSumVector->SetDetCha2(i,1);
1214 fDetSumVector->SetNzNrphi(i,0,0);
1215 if(i==2) {
1216 Int_t nbg = GetNumberOfGroupsPRF((const char *)name);
1217 fDetSumVector->SetNbGroupPRF(nbg);
1218 }
1219
1220 // Create Histo
1221 TString nname((const char *)ph->GetName());
1222 nname += "PerDetector";
1223 TString title("Nz");
1224 title += 0;
1225 title += "Nrphi";
1226 title += 0;
1227 if(!fDetSum) fDetSum = new TH2D((const char *)nname,(const Char_t *) title
1228 ,nxbins,lowedge,upedge,540,0,540);
1229 else{
1230 fDetSum->~TH2D();
1231 new(fDetSum) TH2D((const Char_t *) nname,(const Char_t *) title
1232 ,nxbins,lowedge,upedge,540,0,540);
1233 }
1234 fDetSum->SetYTitle("Detector number");
1235 fDetSum->SetXTitle(xaxis->GetTitle());
1236 fDetSum->SetStats(0);
1237
1238 Int_t counter = 0;
1239
1240 for(Int_t det = 0; det < 540; det++){
1241
1242 Int_t numberofgroup = 0;
1243 if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
1244 else numberofgroup = perChamber0;
1245
1246 for(Int_t nx = 1; nx <= nxbins; nx++) {
1247
1248 Double_t entries = 0.0;
1249 Double_t sumw2 = 0.0;
1250 Double_t sumw = 0.0;
1251
1252 for(Int_t k = counter+1; k <= (counter+numberofgroup); k++){
1253 Int_t binnumber = ph->GetBin(nx,k);
1254 entries += ph->GetBinEntries(binnumber);
1255 sumw2 += (ph->GetBinError(binnumber)*ph->GetBinError(binnumber)+ph->GetBinContent(binnumber)*ph->GetBinContent(binnumber))*ph->GetBinEntries(binnumber);
1256 sumw += ph->GetBinContent(binnumber)*ph->GetBinEntries(binnumber);
1257 }
1258
1259 Double_t mean = 0.0;
1260 if(entries > 0.0) mean = sumw/entries;
1261 Double_t squaremean = 0.0;
1262 if(entries > 0.0) squaremean = sumw2/entries;
1263 Double_t errorf = squaremean - mean*mean;
1264 Double_t error = 0.0;
1265 if(entries > 0.0) error = TMath::Sqrt(TMath::Abs(errorf)/entries);
1266
1267 fDetSum->SetBinContent(nx,det+1,mean);
1268 fDetSum->SetBinError(nx,det+1,error);
1269
1270 if(i==1) fDetSumVector->FillVectorPH(det,0,nx-1,(Int_t)entries,(Float_t)mean,(Float_t)squaremean);
1271 if(i==2) fDetSumVector->FillVectorPRF(det,0,nx-1,(Int_t)entries,(Float_t)mean,(Float_t)squaremean);
1272
1273 }
1274
1275 counter += numberofgroup;
1276
1277 }
1278
1279 return kTRUE;
1280
1281
1282}
1283//_____________________________________________________________________________
1284Bool_t AliTRDcalibration::SetNrphiFromTObject(const char *name, Int_t i, AliTRDCalibraMode *calibMode) const
1285{
1286 //
1287 // Set the granularity from object
1288 //
1289
1290 const Char_t *patternrphi0 = "Nrphi0";
1291 const Char_t *patternrphi1 = "Nrphi1";
1292 const Char_t *patternrphi2 = "Nrphi2";
1293 const Char_t *patternrphi3 = "Nrphi3";
1294 const Char_t *patternrphi4 = "Nrphi4";
1295 const Char_t *patternrphi5 = "Nrphi5";
1296 const Char_t *patternrphi6 = "Nrphi6";
1297
1298
1299 const Char_t *patternrphi10 = "Nrphi10";
1300 const Char_t *patternrphi100 = "Nrphi100";
1301 const Char_t *patternz10 = "Nz10";
1302 const Char_t *patternz100 = "Nz100";
1303
1304 // Nrphi mode
1305 if ((strstr(name,patternrphi100)) && (strstr(name,patternz100))) {
1306 calibMode->SetAllTogether(i);
1307 return kTRUE;
1308 }
1309 if ((strstr(name,patternrphi10)) && (strstr(name,patternz10))) {
1310 calibMode->SetPerSuperModule(i);
1311 return kTRUE;
1312 }
1313
1314 if (strstr(name,patternrphi0)) {
1315 calibMode->SetNrphi(i ,0);
1316 return kTRUE;
1317 }
1318 if (strstr(name,patternrphi1)) {
1319 calibMode->SetNrphi(i, 1);
1320 return kTRUE;
1321 }
1322 if (strstr(name,patternrphi2)) {
1323 calibMode->SetNrphi(i, 2);
1324 return kTRUE;
1325 }
1326 if (strstr(name,patternrphi3)) {
1327 calibMode->SetNrphi(i, 3);
1328 return kTRUE;
1329 }
1330 if (strstr(name,patternrphi4)) {
1331 calibMode->SetNrphi(i, 4);
1332 return kTRUE;
1333 }
1334 if (strstr(name,patternrphi5)) {
1335 calibMode->SetNrphi(i, 5);
1336 return kTRUE;
1337 }
1338 if (strstr(name,patternrphi6)) {
1339 calibMode->SetNrphi(i, 6);
1340 return kTRUE;
1341 }
1342
1343 calibMode->SetNrphi(i ,0);
1344 return kFALSE;
1345
1346}
1347//_____________________________________________________________________________
1348Bool_t AliTRDcalibration::SetNzFromTObject(const char *name, Int_t i, AliTRDCalibraMode *calibMode) const
1349{
1350 //
1351 // Set fNz[i] of the AliTRDCalibraFit::Instance()
1352 // corresponding to the given TObject
1353 //
1354
1355 // Some patterns
1356 const Char_t *patternz0 = "Nz0";
1357 const Char_t *patternz1 = "Nz1";
1358 const Char_t *patternz2 = "Nz2";
1359 const Char_t *patternz3 = "Nz3";
1360 const Char_t *patternz4 = "Nz4";
1361
1362 const Char_t *patternrphi10 = "Nrphi10";
1363 const Char_t *patternrphi100 = "Nrphi100";
1364 const Char_t *patternz10 = "Nz10";
1365 const Char_t *patternz100 = "Nz100";
1366
1367 if ((strstr(name,patternrphi100)) && (strstr(name,patternz100))) {
1368 calibMode->SetAllTogether(i);
1369 return kTRUE;
1370 }
1371 if ((strstr(name,patternrphi10)) && (strstr(name,patternz10))) {
1372 calibMode->SetPerSuperModule(i);
1373 return kTRUE;
1374 }
1375 if (strstr(name,patternz0)) {
1376 calibMode->SetNz(i, 0);
1377 return kTRUE;
1378 }
1379 if (strstr(name,patternz1)) {
1380 calibMode->SetNz(i ,1);
1381 return kTRUE;
1382 }
1383 if (strstr(name,patternz2)) {
1384 calibMode->SetNz(i ,2);
1385 return kTRUE;
1386 }
1387 if (strstr(name,patternz3)) {
1388 calibMode->SetNz(i ,3);
1389 return kTRUE;
1390 }
1391 if (strstr(name,patternz4)) {
1392 calibMode->SetNz(i ,4);
1393 return kTRUE;
1394 }
1395
1396 calibMode->SetNz(i ,0);
1397 return kFALSE;
1398}
1399//____________________________________________________________________________________________________
1400Int_t AliTRDcalibration::GetNumberOfGroupsPRF(const char* nametitle) const
1401{
1402 //
1403 // Get numberofgroupsprf
1404 //
1405
1406 // Some patterns
1407 const Char_t *pattern0 = "Ngp0";
1408 const Char_t *pattern1 = "Ngp1";
1409 const Char_t *pattern2 = "Ngp2";
1410 const Char_t *pattern3 = "Ngp3";
1411 const Char_t *pattern4 = "Ngp4";
1412 const Char_t *pattern5 = "Ngp5";
1413 const Char_t *pattern6 = "Ngp6";
1414
1415 // Nrphi mode
1416 if (strstr(nametitle,pattern0)) {
1417 return 0;
1418 }
1419 if (strstr(nametitle,pattern1)) {
1420 return 1;
1421 }
1422 if (strstr(nametitle,pattern2)) {
1423 return 2;
1424 }
1425 if (strstr(nametitle,pattern3)) {
1426 return 3;
1427 }
1428 if (strstr(nametitle,pattern4)) {
1429 return 4;
1430 }
1431 if (strstr(nametitle,pattern5)) {
1432 return 5;
1433 }
1434 if (strstr(nametitle,pattern6)){
1435 return 6;
1436 }
1437 else return -1;
1ee39b3a 1438}