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