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