]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDPreprocessorOffline.cxx
add missing protection against divided by zero (Raphaelle)
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessorOffline.cxx
CommitLineData
b3fcfd96 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17
18/*
4c865c34 19 Responsible: Raphaelle Bailhache (rbailhache@ikf.uni-frankfurt.de)
20 Code to analyze the TRD calibration and to produce OCDB entries
b3fcfd96 21
22
23 .x ~/rootlogon.C
24 gSystem->Load("libANALYSIS");
4c865c34 25 gSystem->Load("libTRDcalib");
b3fcfd96 26
27 AliTRDPreprocessorOffline proces;
28 TString ocdbPath="local:////"
29 ocdbPath+=gSystem->GetFromPipe("pwd");
30
31 proces.CalibTimeGain("CalibObjects.root",run0,run1,ocdbPath);
32 proces.CalibTimeVdrift("CalibObjects.root",run0,run1,ocdbPath);
33 // take the raw calibration data from the file CalibObjects.root
34 // and make a OCDB entry with run validity run0-run1
35 // results are stored at the ocdbPath - local or alien ...
36 // default storage ""- data stored at current working directory
37
38*/
00d203b6 39#include "AliLog.h"
b3fcfd96 40#include "Riostream.h"
41#include <fstream>
42#include "TFile.h"
43#include "TCanvas.h"
44#include "TLegend.h"
45#include "TH2I.h"
46#include "TH1I.h"
47#include "TH2F.h"
48#include "TH1F.h"
82b413fd 49#include "TMath.h"
83d0cc79 50#include "THnSparse.h"
b3fcfd96 51#include "TProfile2D.h"
52#include "AliTRDCalDet.h"
53#include "AliTRDCalPad.h"
54#include "AliCDBMetaData.h"
55#include "AliCDBId.h"
56#include "AliCDBManager.h"
57#include "AliCDBStorage.h"
58#include "AliTRDCalibraMode.h"
59#include "AliTRDCalibraFit.h"
60#include "AliTRDCalibraVdriftLinearFit.h"
a0bb5615 61#include "AliTRDCalibraExbAltFit.h"
b3fcfd96 62#include "AliTRDPreprocessorOffline.h"
81a5aeca 63#include "AliTRDCalChamberStatus.h"
83d0cc79 64#include "AliTRDCalibChamberStatus.h"
840ec79d 65#include "AliTRDCommonParam.h"
83d0cc79 66#include "AliCDBManager.h"
67#include "AliCDBEntry.h"
b3fcfd96 68
69
70ClassImp(AliTRDPreprocessorOffline)
71
54f2ff1c 72 AliTRDPreprocessorOffline::AliTRDPreprocessorOffline():
01239968 73 TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"),
b3fcfd96 74 fMethodSecond(kTRUE),
01239968 75 fNameList("TRDCalib"),
76 fCalDetGainUsed(0x0),
4c865c34 77 fCalDetVdriftUsed(0x0),
840ec79d 78 fCalDetExBUsed(0x0),
b3fcfd96 79 fCH2d(0x0),
80 fPH2d(0x0),
81 fPRF2d(0x0),
83d0cc79 82 fSparse(0x0),
b3fcfd96 83 fAliTRDCalibraVdriftLinearFit(0x0),
a0bb5615 84 fAliTRDCalibraExbAltFit(0x0),
b3fcfd96 85 fNEvents(0x0),
86 fAbsoluteGain(0x0),
a0bb5615 87 fPlots(new TObjArray(kNumCalibObjs)),
88 fCalibObjects(new TObjArray(kNumCalibObjs)),
83d0cc79 89 fFirstRunGainUsed(0),
4c865c34 90 fVersionGainUsed(0),
91 fSubVersionGainUsed(0),
ca7e6e64 92 fFirstRunVdriftUsed(0),
4c865c34 93 fVersionVdriftUsed(0),
00d203b6 94 fSubVersionVdriftUsed(0),
83d0cc79 95 fFirstRunExBUsed(0),
96 fVersionExBUsed(0),
97 fSubVersionExBUsed(0),
98 fNoExBUsedInReco(kFALSE),
00d203b6 99 fSwitchOnValidation(kTRUE),
100 fVdriftValidated(kFALSE),
840ec79d 101 fExBValidated(kFALSE),
a2a4ec8e 102 fT0Validated(kFALSE),
103 fMinStatsVdriftT0PH(800*20),
104 fMinStatsVdriftLinear(800),
105 fMinStatsGain(800),
54f2ff1c 106 fMinStatsPRF(600),
83d0cc79 107 fMinStatsChamberStatus(20),
54f2ff1c 108 fBackCorrectGain(kFALSE),
109 fBackCorrectVdrift(kTRUE),
110 fNotEnoughStatisticsForTheGain(kFALSE),
111 fNotEnoughStatisticsForTheVdriftLinear(kFALSE),
82b413fd 112 fStatusNeg(0),
83d0cc79 113 fStatusPos(0),
114 fBadCalibValidate(20),
115 fNoDataValidate(20),
116 fRMSBadCalibratedGain(20.0),
117 fRMSBadCalibratedVdrift(20.0),
118 fRMSBadCalibratedExB(50.0)
b3fcfd96 119{
120 //
121 // default constructor
122 //
83d0cc79 123
124 memset(fBadCalib, 0, sizeof(Int_t) * 18);
125 memset(fNoData, 0, sizeof(Int_t) * 18);
b3fcfd96 126}
00d203b6 127//_________________________________________________________________________________________________________________
b3fcfd96 128AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() {
129 //
130 // Destructor
131 //
132
01239968 133 if(fCalDetGainUsed) delete fCalDetGainUsed;
4c865c34 134 if(fCalDetVdriftUsed) delete fCalDetVdriftUsed;
840ec79d 135 if(fCalDetExBUsed) delete fCalDetExBUsed;
b3fcfd96 136 if(fCH2d) delete fCH2d;
137 if(fPH2d) delete fPH2d;
138 if(fPRF2d) delete fPRF2d;
83d0cc79 139 if(fSparse) delete fSparse;
b3fcfd96 140 if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit;
a0bb5615 141 if(fAliTRDCalibraExbAltFit) delete fAliTRDCalibraExbAltFit;
b3fcfd96 142 if(fNEvents) delete fNEvents;
143 if(fAbsoluteGain) delete fAbsoluteGain;
144 if(fPlots) delete fPlots;
145 if(fCalibObjects) delete fCalibObjects;
146
83d0cc79 147}
148//___________________________________________________________________________________
149void AliTRDPreprocessorOffline::Process(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage)
150{
151 //
152 // Process to the gain, vdrift, timeoffset, exb and chamber status calibration
153 //
154
155 if(SetCalDetGain(startRunNumber,fVersionGainUsed,fSubVersionGainUsed) && SetCalDetVdriftExB(startRunNumber,fVersionVdriftUsed,fSubVersionVdriftUsed,fVersionExBUsed,fSubVersionExBUsed)) {
156
157 CalibVdriftT0(file,startRunNumber,endRunNumber,ocdbStorage);
158 CalibGain(file,startRunNumber,endRunNumber,ocdbStorage);
159 CalibChamberStatus(file,startRunNumber,endRunNumber,ocdbStorage);
f29cf84c 160 CalibExbAlt(file,startRunNumber,endRunNumber,ocdbStorage);
83d0cc79 161
162 }
163
164 PrintStatus();
165
b3fcfd96 166}
00d203b6 167//___________________________________________________________________________________________________________________
b3fcfd96 168
169void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
170 //
171 // make calibration of the drift velocity
172 // Input parameters:
173 // file - the location of input file
174 // startRunNumber, endRunNumber - run validity period
175 // ocdbStorage - path to the OCDB storage
176 // - if empty - local storage 'pwd' uesed
177 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
178 //
179 // 1. Initialization
180 //
008817a3 181 fVdriftValidated = kTRUE;
182 fT0Validated = kTRUE;
840ec79d 183 fExBValidated = kTRUE;
54f2ff1c 184 fNotEnoughStatisticsForTheVdriftLinear = kFALSE;
b3fcfd96 185 //
186 // 2. extraction of the information
187 //
840ec79d 188 if(ReadVdriftLinearFitGlobal(file) && fCalDetVdriftUsed && fCalDetExBUsed) AnalyzeVdriftLinearFit();
54f2ff1c 189 if(ReadVdriftT0Global(file)) AnalyzeVdriftT0();
b3fcfd96 190 //
191 // 3. Append QA plots
192 //
193 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
194 //
195 //
00d203b6 196 // 4. validate OCDB entries
b3fcfd96 197 //
00d203b6 198 if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) {
82b413fd 199 //AliError("TRD vdrift OCDB parameters out of range!");
00d203b6 200 fVdriftValidated = kFALSE;
201 }
202 if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) {
82b413fd 203 //AliError("TRD t0 OCDB parameters out of range!");
00d203b6 204 fT0Validated = kFALSE;
205 }
840ec79d 206 if(fSwitchOnValidation==kTRUE && ValidateExB()==kFALSE) {
207 //AliError("TRD t0 OCDB parameters out of range!");
208 fExBValidated = kFALSE;
209 }
b3fcfd96 210 //
00d203b6 211 // 5. update of OCDB
212 //
213 //
214 if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage);
215 if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage);
840ec79d 216 if(fExBValidated) UpdateOCDBExB(startRunNumber,endRunNumber,ocdbStorage);
00d203b6 217
b3fcfd96 218}
a0bb5615 219//___________________________________________________________________________________________________________________
220
221void AliTRDPreprocessorOffline::CalibExbAlt(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
222 //
223 // make calibration of the drift velocity
224 // Input parameters:
225 // file - the location of input file
226 // startRunNumber, endRunNumber - run validity period
227 // ocdbStorage - path to the OCDB storage
228 // - if empty - local storage 'pwd' uesed
229 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
230 //
231 // 1. Initialization
232 //
233
234 //
235 // 2. extraction of the information
236 //
237 if(ReadExbAltFitGlobal(file)) AnalyzeExbAltFit();
238 //
239 // 3. Append QA plots
240 //
241 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
242 //
243 //
244 // 4. validate OCDB entries
245 //
246 //
247 // 5. update of OCDB
248 //
249 //
250 UpdateOCDBExBAlt(startRunNumber,endRunNumber,ocdbStorage);
251
252}
253
00d203b6 254//_________________________________________________________________________________________________________________
b3fcfd96 255
256void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
257 //
258 // make calibration of the drift velocity
259 // Input parameters:
260 // file - the location of input file
261 // startRunNumber, endRunNumber - run validity period
262 // ocdbStorage - path to the OCDB storage
263 // - if empty - local storage 'pwd' uesed
264 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
265 //
54f2ff1c 266 fNotEnoughStatisticsForTheGain = kFALSE;
267 //
b3fcfd96 268 // 1. Initialization
269 if(!ReadGainGlobal(file)) return;
270 //
271 //
272 // 2. extraction of the information
273 //
274 AnalyzeGain();
54f2ff1c 275 if(fBackCorrectGain) CorrectFromDetGainUsed();
a0bb5615 276 //if(fBackCorrectVdrift) CorrectFromDetVdriftUsed();
b3fcfd96 277 //
278 // 3. Append QA plots
279 //
280 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
281 //
282 //
00d203b6 283 // 4. validate OCDB entries
284 //
285 if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) {
82b413fd 286 //AliError("TRD gain OCDB parameters out of range!");
00d203b6 287 return;
288 }
b3fcfd96 289 //
00d203b6 290 // 5. update of OCDB
b3fcfd96 291 //
00d203b6 292 //
293 if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage);
294
b3fcfd96 295
296}
00d203b6 297//________________________________________________________________________________________________________________
b3fcfd96 298
299void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
300 //
301 // make calibration of the drift velocity
302 // Input parameters:
303 // file - the location of input file
304 // startRunNumber, endRunNumber - run validity period
305 // ocdbStorage - path to the OCDB storage
306 // - if empty - local storage 'pwd' uesed
307 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
308 //
309 // 1. Initialization
310 if(!ReadPRFGlobal(file)) return;
311 //
312 //
313 // 2. extraction of the information
314 //
315 AnalyzePRF();
316 //
317 // 3. Append QA plots
318 //
319 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
320 //
321 //
00d203b6 322 //
323 // 4. validate OCDB entries
324 //
325 if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) {
82b413fd 326 //AliError("TRD prf OCDB parameters out of range!");
00d203b6 327 return;
328 }
329 //
330 // 5. update of OCDB
b3fcfd96 331 //
332 //
333 UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage);
334
a5dcf618 335}
336//________________________________________________________________________________________________________________
337
83d0cc79 338void AliTRDPreprocessorOffline::CalibChamberStatus(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
a5dcf618 339 //
340 // make calibration of the chamber status
341 // Input parameters:
342 // startRunNumber, endRunNumber - run validity period
343 // ocdbStorage - path to the OCDB storage
344 // - if empty - local storage 'pwd' uesed
345 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
346 //
347 //
83d0cc79 348 // 1. Initialization
349 if(!ReadStatusGlobal(file)) return;
350 //
351 //
352 //
a5dcf618 353 // 2. extraction of the information
354 //
355 if(!AnalyzeChamberStatus()) return;
356 //
357 // 3. Append QA plots
358 //
359 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
360 //
361 //
362 //
363 // 4. validate OCDB entries
364 //
365 if(fSwitchOnValidation==kTRUE && ValidateChamberStatus()==kFALSE) {
82b413fd 366 //AliError("TRD Chamber status OCDB parameters not ok!");
a5dcf618 367 return;
368 }
369 //
370 // 5. update of OCDB
371 //
372 //
83d0cc79 373 if((!fNotEnoughStatisticsForTheVdriftLinear) && (!fNotEnoughStatisticsForTheGain)) UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage);
374 //UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage);
a5dcf618 375
b3fcfd96 376}
00d203b6 377//______________________________________________________________________________________________________
4c865c34 378Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){
379 //
380 // read the calibration used during the reconstruction
381 //
382
383 if(ReadVdriftT0Global(fileName)) {
384
385 TString nameph = fPH2d->GetTitle();
ca7e6e64 386 fFirstRunVdriftUsed = GetFirstRun(nameph);
4c865c34 387 fVersionVdriftUsed = GetVersion(nameph);
388 fSubVersionVdriftUsed = GetSubVersion(nameph);
389
390 //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed);
391
392 }
393
394 if(ReadGainGlobal(fileName)) {
395
396 TString namech = fCH2d->GetTitle();
83d0cc79 397 fFirstRunGainUsed = GetFirstRun(namech);
4c865c34 398 fVersionGainUsed = GetVersion(namech);
399 fSubVersionGainUsed = GetSubVersion(namech);
400
401 //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed);
402
403 }
83d0cc79 404
405 if(ReadVdriftLinearFitGlobal(fileName)) {
406
407 TString namelinear = fAliTRDCalibraVdriftLinearFit->GetNameCalibUsed();
408 fFirstRunExBUsed = GetFirstRun(namelinear);
409 fVersionExBUsed = GetVersion(namelinear);
410 fSubVersionExBUsed = GetSubVersion(namelinear);
411
412 //printf("Found Version %d, Subversion %d, run %d for ExB\n",fVersionExBUsed,fSubVersionExBUsed,fFirstRunExBUsed);
413
414 }
4c865c34 415
82b413fd 416 if(fVersionVdriftUsed == 0) fStatusPos = fStatusPos |kVdriftErrorOld;
417 if(fVersionGainUsed == 0) fStatusPos = fStatusPos | kGainErrorOld;
840ec79d 418
4c865c34 419 return kTRUE;
420
421}
00d203b6 422//___________________________________________________________________________________________________________________
b3fcfd96 423
83d0cc79 424Bool_t AliTRDPreprocessorOffline::ReadStatusGlobal(const Char_t* fileName){
425 //
426 // read calibration entries from file
427 //
428 if(fSparse) return kTRUE;
429 TFile fcalib(fileName);
430 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
431 if (array){
432 fSparse = (THnSparseI *) array->FindObject("NumberOfEntries");
433 if(!fSparse) return kFALSE;
434 }
435 else
436 return kFALSE;
437
438 return kTRUE;
439
440}
441//___________________________________________________________________________________________________________________
442
b3fcfd96 443Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){
444 //
445 // read calibration entries from file
446 //
4c865c34 447 if(fCH2d) return kTRUE;
b3fcfd96 448 TFile fcalib(fileName);
01239968 449 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
b3fcfd96 450 if (array){
451 TH2I *ch2d = (TH2I *) array->FindObject("CH2d");
452 if(!ch2d) return kFALSE;
453 fCH2d = (TH2I*)ch2d->Clone();
454 //fNEvents = (TH1I *) array->FindObject("NEvents");
455 //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain");
456 }else{
457 TH2I *ch2d = (TH2I *) fcalib.Get("CH2d");
458 if(!ch2d) return kFALSE;
459 fCH2d = (TH2I*)ch2d->Clone();
460 //fNEvents = (TH1I *) fcalib.Get("NEvents");
461 //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain");
462 }
463 fCH2d->SetDirectory(0);
464 //printf("title of CH2d %s\n",fCH2d->GetTitle());
465
466 return kTRUE;
467
468}
00d203b6 469//_________________________________________________________________________________________________________________
b3fcfd96 470
471Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){
472 //
473 // read calibration entries from file
474 //
4c865c34 475 if(fPH2d) return kTRUE;
b3fcfd96 476 TFile fcalib(fileName);
01239968 477 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
b3fcfd96 478 if (array){
479 TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d");
480 if(!ph2d) return kFALSE;
481 fPH2d = (TProfile2D*)ph2d->Clone();
482 //fNEvents = (TH1I *) array->FindObject("NEvents");
483 }else{
484 TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d");
485 if(!ph2d) return kFALSE;
486 fPH2d = (TProfile2D*)ph2d->Clone();
487 //fNEvents = (TH1I *) fcalib.Get("NEvents");
488 }
489 fPH2d->SetDirectory(0);
490 //printf("title of PH2d %s\n",fPH2d->GetTitle());
491
492 return kTRUE;
493
494}
00d203b6 495//___________________________________________________________________________________________________________________
b3fcfd96 496
497Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){
498 //
499 // read calibration entries from file
500 //
4c865c34 501 if(fAliTRDCalibraVdriftLinearFit) return kTRUE;
b3fcfd96 502 TFile fcalib(fileName);
01239968 503 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
b3fcfd96 504 if (array){
505 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit");
506 //fNEvents = (TH1I *) array->FindObject("NEvents");
507 }else{
508 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit");
509 //fNEvents = (TH1I *) fcalib.Get("NEvents");
510 }
511 if(!fAliTRDCalibraVdriftLinearFit) {
512 //printf("No AliTRDCalibraVdriftLinearFit\n");
513 return kFALSE;
514 }
515 return kTRUE;
516
a0bb5615 517}
518//_____________________________________________________________________________________________________________
519Bool_t AliTRDPreprocessorOffline::ReadExbAltFitGlobal(const Char_t* fileName){
520 //
521 // read calibration entries from file
522 //
523 if(fAliTRDCalibraExbAltFit) return kTRUE;
524 TFile fcalib(fileName);
525 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
526 if (array){
527 fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) array->FindObject("AliTRDCalibraExbAltFit");
528 //fNEvents = (TH1I *) array->FindObject("NEvents");
529 }else{
530 fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) fcalib.Get("AliTRDCalibraExbAltFit");
531 //fNEvents = (TH1I *) fcalib.Get("NEvents");
532 }
533 if(!fAliTRDCalibraExbAltFit) {
534 //printf("No AliTRDCalibraExbAltFit\n");
535 return kFALSE;
536 }
537 return kTRUE;
538
b3fcfd96 539}
00d203b6 540//_____________________________________________________________________________________________________________
b3fcfd96 541
542Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){
543 //
544 // read calibration entries from file
545 //
4c865c34 546 if(fPRF2d) return kTRUE;
b3fcfd96 547 TFile fcalib(fileName);
01239968 548 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
b3fcfd96 549 if (array){
550 TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d");
551 if(!prf2d) return kFALSE;
552 fPRF2d = (TProfile2D*)prf2d->Clone();
553 //fNEvents = (TH1I *) array->FindObject("NEvents");
554 }else{
555 TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d");
556 if(!prf2d) return kFALSE;
557 fPRF2d = (TProfile2D*)prf2d->Clone();
558 //fNEvents = (TH1I *) fcalib.Get("NEvents");
559 }
560 fPRF2d->SetDirectory(0);
561 //printf("title of PRF2d %s\n",fPRF2d->GetTitle());
562
563 return kTRUE;
564
565}
00d203b6 566//__________________________________________________________________________________________________________
b3fcfd96 567
568Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){
569 //
570 // Analyze gain - produce the calibration objects
571 //
572
573 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
a2a4ec8e 574 calibra->SetMinEntries(fMinStatsGain); // If there is less than 1000 entries in the histo: no fit
b3fcfd96 575 calibra->AnalyseCH(fCH2d);
576
577 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
578 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
579 Int_t nbfit = calibra->GetNumberFit();
580 Int_t nbE = calibra->GetNumberEnt();
581
582
583 Bool_t ok = kFALSE;
4c865c34 584 Bool_t meanother = kFALSE;
b3fcfd96 585 // enough statistics
586 if ((nbtg > 0) &&
587 (nbfit >= 0.5*nbE) && (nbE > 30)) {
588 // create the cal objects
54f2ff1c 589 if(!fBackCorrectGain) {
4c865c34 590 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
591 meanother = kTRUE;
592 }
b3fcfd96 593 TObjArray object = calibra->GetVectorFit();
4c865c34 594 AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother);
b3fcfd96 595 TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet();
596 // Put them in the array
597 fCalibObjects->AddAt(calDetGain,kGain);
598 fPlots->AddAt(coefGain,kGain);
599 //
600 ok = kTRUE;
601 }
54f2ff1c 602 else {
603 fNotEnoughStatisticsForTheGain = kTRUE;
dee5f636 604 Int_t minStatsGain = fMinStatsGain*30;
605 calibra->SetMinEntries(minStatsGain); // Because we do it for all, we increase this
54f2ff1c 606 Double_t gainoverallnotnormalized = calibra->AnalyseCHAllTogether(fCH2d);
607 if(fCalDetGainUsed && (gainoverallnotnormalized > 0.0)) {
608 AliTRDCalDet *calDetGain = new AliTRDCalDet(*fCalDetGainUsed);
609 Double_t oldmean = fCalDetGainUsed->CalcMean(kFALSE);
610 //printf("oldmean %f\n",oldmean);
611 if(oldmean > 0.0) {
612 Double_t scalefactor = calibra->GetScaleFactorGain();
613 //printf("Correction factor %f\n",gainoverallnotnormalized*scalefactor);
614 calDetGain->Multiply(gainoverallnotnormalized*scalefactor/oldmean);
615 //printf("newmean %f\n",calDetGain->CalcMean(kFALSE));
616 TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet();
617 fCalibObjects->AddAt(calDetGain,kGain);
618 fPlots->AddAt(coefGain,kGain);
619 //
620 ok = kTRUE;
82b413fd 621 fStatusNeg = fStatusNeg | kGainNotEnoughStatsButFill;
54f2ff1c 622 }
623 else {
82b413fd 624 fStatusPos = fStatusPos | kGainErrorOld;
54f2ff1c 625 }
626 }
627 else {
82b413fd 628 if(gainoverallnotnormalized <= 0.0) fStatusNeg = fStatusNeg | kGainNotEnoughStatsNotFill;
629 if(!fCalDetGainUsed) fStatusPos = fStatusPos | kGainErrorOld;
54f2ff1c 630 }
631 }
b3fcfd96 632
633 calibra->ResetVectorFit();
634
635 return ok;
636
637}
00d203b6 638//_____________________________________________________________________________________________________
b3fcfd96 639Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){
640 //
641 // Analyze VdriftT0 - produce the calibration objects
642 //
643
644 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
a2a4ec8e 645 calibra->SetMinEntries(fMinStatsVdriftT0PH); // If there is less than 1000 entries in the histo: no fit
b3fcfd96 646 calibra->AnalysePH(fPH2d);
647
648 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
649 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
650 Int_t nbfit = calibra->GetNumberFit();
651 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
652 Int_t nbE = calibra->GetNumberEnt();
653
654 //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess);
655
656 Bool_t ok = kFALSE;
657 if ((nbtg > 0) &&
658 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
659 //printf("Pass the cut for VdriftT0\n");
660 // create the cal objects
01239968 661 calibra->RemoveOutliers(1,kFALSE);
662 calibra->PutMeanValueOtherVectorFit(1,kFALSE);
663 calibra->RemoveOutliers2(kFALSE);
664 calibra->PutMeanValueOtherVectorFit2(1,kFALSE);
665 //
b3fcfd96 666 TObjArray object = calibra->GetVectorFit();
667 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object);
668 TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet();
669 AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift);
670 TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D();
671 object = calibra->GetVectorFit2();
672 AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object);
673 TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet();
674 AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0);
675 TH1F *coefPadT0 = calPadT0->MakeHisto1D();
676 // Put them in the array
677 fCalibObjects->AddAt(calDetT0,kT0PHDet);
678 fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet);
679 fCalibObjects->AddAt(calPadT0,kT0PHPad);
680 fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad);
681 fPlots->AddAt(coefVdriftPH,kVdriftPHDet);
682 fPlots->AddAt(coefT0,kT0PHDet);
683 fPlots->AddAt(coefPadVdrift,kVdriftPHPad);
684 fPlots->AddAt(coefPadT0,kT0PHPad);
685 //
686 ok = kTRUE;
687 }
54f2ff1c 688 else {
840ec79d 689 //printf("Not enough stats timeoffset\n");
82b413fd 690 fStatusNeg = fStatusNeg | kTimeOffsetNotEnoughStatsNotFill;
54f2ff1c 691 }
b3fcfd96 692 calibra->ResetVectorFit();
693
694 return ok;
695
696}
00d203b6 697//____________________________________________________________________________________________________________________
b3fcfd96 698Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){
699 //
700 // Analyze vdrift linear fit - produce the calibration objects
701 //
702
a5dcf618 703 //printf("Analyse linear fit\n");
704
f558cb62 705
b3fcfd96 706 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
840ec79d 707 calibra->SetCalDetVdriftExB(fCalDetVdriftUsed,fCalDetExBUsed);
a2a4ec8e 708 calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
a5dcf618 709 //printf("Fill PE Array\n");
01239968 710 fAliTRDCalibraVdriftLinearFit->FillPEArray();
a5dcf618 711 //printf("AliTRDCalibraFit\n");
b3fcfd96 712 calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit);
a5dcf618 713 //printf("After\n");
b3fcfd96 714
715 //Int_t nbtg = 540;
716 Int_t nbfit = calibra->GetNumberFit();
717 Int_t nbE = calibra->GetNumberEnt();
718
719
720 Bool_t ok = kFALSE;
721 // enough statistics
722 if ((nbfit >= 0.5*nbE) && (nbE > 30)) {
723 // create the cal objects
01239968 724 //calibra->RemoveOutliers(1,kTRUE);
725 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
726 //calibra->RemoveOutliers2(kTRUE);
727 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
728 //
b3fcfd96 729 TObjArray object = calibra->GetVectorFit();
730 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE);
731 TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet();
732 object = calibra->GetVectorFit2();
733 AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object);
734 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
eec29d56 735 //if(!calDetLorentz) printf("No lorentz created\n");
b3fcfd96 736 // Put them in the array
737 fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
738 fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
739 fPlots->AddAt(coefDriftLinear,kVdriftLinear);
740 fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
741 //
742 ok = kTRUE;
743 }
54f2ff1c 744 else {
745 fNotEnoughStatisticsForTheVdriftLinear = kTRUE;
dee5f636 746 Int_t minNumberOfEntriesForAll = fMinStatsVdriftLinear*30;
747 calibra->SetMinEntries(minNumberOfEntriesForAll); // Because we do it for all, we increase this
840ec79d 748 Double_t vdriftoverall = -100.0;
749 Double_t exboverall = 100.0;
750 calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit,vdriftoverall,exboverall);
751 //printf("Found mean vdrift %f and exb %f\n",vdriftoverall,exboverall);
752 if(fCalDetVdriftUsed && (vdriftoverall > 0.0) && (exboverall < 70.0)) {
54f2ff1c 753 AliTRDCalDet *calDetVdrift = new AliTRDCalDet(*fCalDetVdriftUsed);
840ec79d 754 AliTRDCalDet *calDetLorentz = new AliTRDCalDet(*fCalDetExBUsed);
755 Double_t oldmeanvdrift = fCalDetVdriftUsed->CalcMean(kFALSE);
756 Double_t oldmeanexb = fCalDetExBUsed->CalcMean(kFALSE);
54f2ff1c 757 //printf("oldmean %f\n",oldmean);
840ec79d 758 if((oldmeanvdrift > 0.0) && (oldmeanexb < 70.0)) {
54f2ff1c 759 //printf("Correction factor %f\n",vdriftoverall);
840ec79d 760 calDetVdrift->Multiply(vdriftoverall/oldmeanvdrift);
761 calDetLorentz->Multiply(exboverall/oldmeanexb);
54f2ff1c 762 //printf("newmean %f\n",calDetVdrift->CalcMean(kFALSE));
763 TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet();
840ec79d 764 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
54f2ff1c 765 // Put them in the array
766 fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
840ec79d 767 fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
54f2ff1c 768 fPlots->AddAt(coefDriftLinear,kVdriftLinear);
840ec79d 769 fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
54f2ff1c 770 //
771 ok = kTRUE;
82b413fd 772 fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsButFill;
54f2ff1c 773 }
82b413fd 774 else {
840ec79d 775 if(oldmeanvdrift) fStatusPos = fStatusPos | kVdriftErrorOld;
776 if(oldmeanexb) fStatusPos = fStatusPos | kExBErrorOld;
82b413fd 777 }
778 }
779 else {
840ec79d 780 if((vdriftoverall <= 0.0) && (exboverall > 70.0)) fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsNotFill;
82b413fd 781 if(!fCalDetVdriftUsed) fStatusPos = fStatusPos | kVdriftErrorOld;
840ec79d 782 if(!fCalDetExBUsed) fStatusPos = fStatusPos | kExBErrorOld;
54f2ff1c 783 }
54f2ff1c 784 }
b3fcfd96 785
786 calibra->ResetVectorFit();
787
788 return ok;
789
790}
00d203b6 791//________________________________________________________________________________________________________________
b3fcfd96 792
a0bb5615 793Bool_t AliTRDPreprocessorOffline::AnalyzeExbAltFit(){
794 //
795 // Analyze vdrift linear fit - produce the calibration objects
796 //
797
798 //printf("Analyse linear fit\n");
799
800
801 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
802 calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
803 //printf("Fill PE Array\n");
804 fAliTRDCalibraExbAltFit->FillPEArray();
805 //printf("AliTRDCalibraFit\n");
806 calibra->AnalyseExbAltFit(fAliTRDCalibraExbAltFit);
807 //printf("After\n");
808
809 //Int_t nbtg = 540;
810 Int_t nbfit = calibra->GetNumberFit();
811 Int_t nbE = calibra->GetNumberEnt();
812
813
814 Bool_t ok = kFALSE;
815 // enough statistics
816 if ((nbfit >= 0.5*nbE) && (nbE > 30)) {
817 // create the cal objects
818 //calibra->RemoveOutliers(1,kTRUE);
819 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
820 //
821 TObjArray object = calibra->GetVectorFit2();
822 AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectExbAlt(&object);
823 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
824 //if(!calDetLorentz) printf("No lorentz created\n");
825 // Put them in the array
826 fCalibObjects->AddAt(calDetLorentz,kExbAlt);
827 fPlots->AddAt(coefLorentzAngle,kExbAlt);
828 //
829 ok = kTRUE;
830 }
831
832 calibra->ResetVectorFit();
833
834 return ok;
835
836}
837//________________________________________________________________________________________________________________
838
b3fcfd96 839Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){
840 //
841 // Analyze PRF - produce the calibration objects
842 //
843
844 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
a2a4ec8e 845 calibra->SetMinEntries(fMinStatsPRF); // If there is less than 1000 entries in the histo: no fit
b3fcfd96 846 calibra->AnalysePRFMarianFit(fPRF2d);
847
848 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
849 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
850 Int_t nbfit = calibra->GetNumberFit();
851 Int_t nbE = calibra->GetNumberEnt();
852
853
854 Bool_t ok = kFALSE;
855 // enough statistics
856 if ((nbtg > 0) &&
857 (nbfit >= 0.95*nbE) && (nbE > 30)) {
858 // create the cal objects
859 TObjArray object = calibra->GetVectorFit();
860 AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object);
861 TH1F *coefPRF = calPadPRF->MakeHisto1D();
862 // Put them in the array
863 fCalibObjects->AddAt(calPadPRF,kPRF);
864 fPlots->AddAt(coefPRF,kPRF);
865 //
866 ok = kTRUE;
867 }
868
869 calibra->ResetVectorFit();
870
871 return ok;
872
873}
a5dcf618 874
875//_____________________________________________________________________________
876Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus()
877{
4c865c34 878 //
a5dcf618 879 // Produce AliTRDCalChamberStatus out of calibration results
4c865c34 880 //
b61b92a0 881
83d0cc79 882 // set up AliTRDCalibChamberStatus
883 AliTRDCalibChamberStatus *ChamberStatus = new AliTRDCalibChamberStatus();
884 ChamberStatus->SetSparseI(fSparse);
885 ChamberStatus->AnalyseHisto(fMinStatsChamberStatus);
886 // get AliTRDCalChamberStatus
887 AliTRDCalChamberStatus *CalChamberStatus = ChamberStatus->GetCalChamberStatus();
01239968 888
a5dcf618 889 // get calibration objects
890 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
891 AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear);
840ec79d 892 AliTRDCalDet *calDetExB = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
a5dcf618 893
894 // Check
83d0cc79 895 if((!calDetGain) || (!calDetVDrift) || (!fCH2d) || (!calDetExB) || (!CalChamberStatus)) return kFALSE;
a5dcf618 896
897 // Gain
83d0cc79 898 Double_t gainmean = calDetGain->GetMean();
a5dcf618 899 Double_t vdriftmean = calDetVDrift->GetMean();
83d0cc79 900 Double_t exbmean = calDetExB->GetMean();
a5dcf618 901
83d0cc79 902 Double_t gainrms = calDetGain->GetRMSRobust();
903 Double_t vdriftrms = calDetVDrift->GetRMSRobust();
904 Double_t exbrms = calDetExB->GetRMSRobust();
a5dcf618 905
906 //printf("Gain mean: %f, rms: %f\n",gainmean,gainrms);
907 //printf("Vdrift mean: %f, rms: %f\n",vdriftmean,vdriftrms);
840ec79d 908 //printf("ExB mean: %f, rms: %f\n",exbmean,exbrms);
909
a5dcf618 910 // Check
840ec79d 911 if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001) || (TMath::Abs(exbrms) < 0.0000001)) return kFALSE;
01239968 912
a5dcf618 913 // mask chambers with empty gain entries
914 //Int_t counter = 0;
915 for (Int_t idet = 0; idet < 540; idet++) {
01239968 916
a5dcf618 917 // ch2d
918 TH1I *projch = (TH1I *) fCH2d->ProjectionX("projch",idet+1,idet+1,(Option_t *)"e");
919 Double_t entries = projch->GetEntries();
83d0cc79 920 //printf("Number of entries %f for det %d\n",entries,idet);
4c865c34 921
a5dcf618 922 // gain
923 Double_t gain = calDetGain->GetValue(idet);
4c865c34 924
a5dcf618 925 // vdrift
926 Double_t vdrift = calDetVDrift->GetValue(idet);
4c865c34 927
840ec79d 928 // exb
929 Double_t exb = calDetExB->GetValue(idet);
930
4c865c34 931
83d0cc79 932 if( (entries<50 && !CalChamberStatus->IsNoData(idet)) ||
933 TMath::Abs(gainmean-gain) > (fRMSBadCalibratedGain*gainrms) ||
934 TMath::Abs(vdriftmean-vdrift) > (fRMSBadCalibratedVdrift*vdriftrms) ||
935 TMath::Abs(exbmean-exb) > (fRMSBadCalibratedExB*exbrms) ) {
a5dcf618 936
937 //printf(" chamber det %03d masked \n",idet);
938 //printf(" gainmean %f and gain %f, gainrms %f \n",gainmean,gain,gainrms);
939 //printf(" vdriftmean %f and vdrift %f, vdriftrms %f \n",vdriftmean,vdrift,vdriftrms);
840ec79d 940 //printf(" exbmean %f and exb %f, exbrms %f \n",exbmean,exb,exbrms);
941
83d0cc79 942 CalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kBadCalibrated);
a5dcf618 943 //counter++;
944 }
4c865c34 945
b61b92a0 946 delete projch;
947
a5dcf618 948 }
b3fcfd96 949
83d0cc79 950 // Security
951 for(Int_t sm=0; sm < 18; sm++) {
952 Int_t smnodata = 0;
953 Int_t smbadcalib = 0;
954 for(Int_t det = 0; det < 30; det++){
955 Int_t detector = sm*30+det;
956 if(CalChamberStatus->IsNoData(detector)) smnodata++;
957 else {
958 if(CalChamberStatus->IsBadCalibrated(detector)) smbadcalib++;
959 }
960 }
961 fNoData[sm] = smnodata;
962 fBadCalib[sm]= smbadcalib;
963 //printf("No Data %d, bad calibrated %d for %d\n",fNoData[sm],fBadCalib[sm],sm);
964 }
965
966 // Security
967 // for(Int_t sm=0; sm < 18; sm++) {
968 // Int_t counter = 0;
969 // for(Int_t det = 0; det < 30; det++){
970 // Int_t detector = sm*30+det;
971 // if(CalChamberStatus->IsBadCalibrated(detector)) counter++;
972 // }
973 // if(counter >= 20) {
974 // for(Int_t det = 0; det < 30; det++){
975 // Int_t detector = sm*30+det;
976 // CalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kGood);
977 // }
978 // }
979 // }
b3fcfd96 980
a5dcf618 981 fCalibObjects->AddAt(CalChamberStatus,kChamberStatus);
982 return kTRUE;
b3fcfd96 983
a5dcf618 984 }
b3fcfd96 985
b3fcfd96 986
a5dcf618 987 //________________________________________________________________________________________________
988 void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() {
989 //
990 // Correct from the gas gain used afterwards
991 //
992 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
993 if(!calDetGain) return;
b3fcfd96 994
a5dcf618 995 // Calculate mean
996 Double_t mean = 0.0;
997 Int_t nbdet = 0;
b3fcfd96 998
a5dcf618 999 for(Int_t det = 0; det < 540; det++) {
00d203b6 1000
a5dcf618 1001 Float_t gaininit = fCalDetGainUsed->GetValue(det);
1002 Float_t gainout = calDetGain->GetValue(det);
00d203b6 1003
00d203b6 1004
a5dcf618 1005 if(TMath::Abs(gainout-1.0) > 0.000001) {
1006 mean += (gaininit*gainout);
1007 nbdet++;
1008 }
1009 }
1010 if(nbdet > 0) mean = mean/nbdet;
00d203b6 1011
a5dcf618 1012 for(Int_t det = 0; det < 540; det++) {
00d203b6 1013
a5dcf618 1014 Float_t gaininit = fCalDetGainUsed->GetValue(det);
1015 Float_t gainout = calDetGain->GetValue(det);
1016
ba1aa7a7 1017 if(TMath::Abs(gainout-1.0) > 0.000001) {
1018 Double_t newgain = gaininit*gainout;
1019 if(newgain < 0.1) newgain = 0.1;
58e2b572 1020 if(newgain > 1.9) newgain = 1.9;
ba1aa7a7 1021 calDetGain->SetValue(det,newgain);
1022 }
1023 else {
1024 Double_t newgain = mean;
1025 if(newgain < 0.1) newgain = 0.1;
58e2b572 1026 if(newgain > 1.9) newgain = 1.9;
ba1aa7a7 1027 calDetGain->SetValue(det,newgain);
1028 }
a5dcf618 1029 }
1030
1031
1032 }
1033 //________________________________________________________________________________________________
1034 void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() {
1035 //
1036 // Correct from the drift velocity
1037 //
1038
1039 //printf("Correct for vdrift\n");
1040
1041 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
1042 if(!calDetGain) return;
1043
1044 Int_t detVdrift = kVdriftPHDet;
1045 if(fMethodSecond) detVdrift = kVdriftLinear;
1046 AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1047 if(!calDetVdrift) return;
1048
1049 // Calculate mean
8dac2af1 1050 if(!fNotEnoughStatisticsForTheVdriftLinear) {
54f2ff1c 1051 for(Int_t det = 0; det < 540; det++) {
1052
1053 Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det);
1054 Float_t vdriftout = calDetVdrift->GetValue(det);
1055
1056 Float_t gain = calDetGain->GetValue(det);
1057 if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout;
1058 if(gain < 0.1) gain = 0.1;
1059 if(gain > 1.9) gain = 1.9;
1060 calDetGain->SetValue(det,gain);
1061 }
a5dcf618 1062 }
54f2ff1c 1063 else {
1064
1065 Float_t vdriftinit = fCalDetVdriftUsed->CalcMean(kFALSE);
1066 Float_t vdriftout = calDetVdrift->CalcMean(kFALSE);
1067 Float_t factorcorrectif = 1.0;
1068 if(vdriftout > 0.0) factorcorrectif = vdriftinit/vdriftout;
1069 for(Int_t det = 0; det < 540; det++) {
1070 Float_t gain = calDetGain->GetValue(det);
1071 gain = gain*factorcorrectif;
1072 if(gain < 0.1) gain = 0.1;
1073 if(gain > 1.9) gain = 1.9;
1074 calDetGain->SetValue(det,gain);
1075 }
1076
1077 }
1078
a5dcf618 1079 }
54f2ff1c 1080//_________________________________________________________________________________________________________________
a5dcf618 1081 void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1082 //
1083 // Update OCDB entry
1084 //
1085
1086 AliCDBMetaData *metaData= new AliCDBMetaData();
1087 metaData->SetObjectClassName("AliTRDCalDet");
1088 metaData->SetResponsible("Raphaelle Bailhache");
58006729 1089 metaData->AddDateToComment();
a5dcf618 1090 metaData->SetBeamPeriod(1);
1091
1092 AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber);
1093 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1094 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
1095 if(calDet) gStorage->Put(calDet, id1, metaData);
1096
1097
eec29d56 1098 }
1099 //___________________________________________________________________________________________________________________
1100 void AliTRDPreprocessorOffline::UpdateOCDBExB(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1101 //
1102 // Update OCDB entry
1103 //
1104
1105 Int_t detExB = kLorentzLinear;
1106 if(!fMethodSecond) return;
1107
1108 //printf("Pass\n");
1109
1110 AliCDBMetaData *metaData= new AliCDBMetaData();
1111 metaData->SetObjectClassName("AliTRDCalDet");
1112 metaData->SetResponsible("Raphaelle Bailhache");
58006729 1113 metaData->AddDateToComment();
eec29d56 1114 metaData->SetBeamPeriod(1);
1115
1116 AliCDBId id1("TRD/Calib/ChamberExB", startRunNumber, endRunNumber);
1117 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1118 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB);
1119 if(calDet) gStorage->Put(calDet, id1, metaData);
1120 //if(!calDet) printf("No caldet\n");
1121
a5dcf618 1122 }
a0bb5615 1123//___________________________________________________________________________________________________________________
1124void AliTRDPreprocessorOffline::UpdateOCDBExBAlt(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1125 //
1126 // Update OCDB entry
1127 //
1128
1129 Int_t detExB = kExbAlt;
1130 if(!fMethodSecond) return;
1131
1132 //printf("Pass\n");
1133
1134 AliCDBMetaData *metaData= new AliCDBMetaData();
1135 metaData->SetObjectClassName("AliTRDCalDet");
58006729 1136 metaData->SetResponsible("Theo Rascanu");
1137 metaData->AddDateToComment();
a0bb5615 1138 metaData->SetBeamPeriod(1);
1139
1140 AliCDBId id1("TRD/Calib/ChamberExBAlt", startRunNumber, endRunNumber);
1141 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1142 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB);
1143 if(calDet) gStorage->Put(calDet, id1, metaData);
1144 //if(!calDet) printf("No caldet\n");
1145
1146}
a5dcf618 1147 //___________________________________________________________________________________________________________________
1148 void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1149 //
1150 // Update OCDB entry
1151 //
1152
1153 Int_t detVdrift = kVdriftPHDet;
1154
1155 if(fMethodSecond) detVdrift = kVdriftLinear;
1156
1157 AliCDBMetaData *metaData= new AliCDBMetaData();
1158 metaData->SetObjectClassName("AliTRDCalDet");
1159 metaData->SetResponsible("Raphaelle Bailhache");
58006729 1160 metaData->AddDateToComment();
a5dcf618 1161 metaData->SetBeamPeriod(1);
1162
1163 AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber);
1164 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1165 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1166 if(calDet) gStorage->Put(calDet, id1, metaData);
1167
1168 //
1169
1170 if(!fMethodSecond) {
1171
1172 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
1173 metaDataPad->SetObjectClassName("AliTRDCalPad");
1174 metaDataPad->SetResponsible("Raphaelle Bailhache");
58006729 1175 metaDataPad->AddDateToComment();
a5dcf618 1176 metaDataPad->SetBeamPeriod(1);
1177
1178 AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber);
1179 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
1180 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
1181
1182 }
1183
1184 }
1185 //________________________________________________________________________________________________________________________
1186 void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1187 //
1188 // Update OCDB entry
1189 //
1190
1191 AliCDBMetaData *metaData= new AliCDBMetaData();
1192 metaData->SetObjectClassName("AliTRDCalDet");
1193 metaData->SetResponsible("Raphaelle Bailhache");
58006729 1194 metaData->AddDateToComment();
a5dcf618 1195 metaData->SetBeamPeriod(1);
1196
1197 AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber);
1198 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1199 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
1200 if(calDet) gStorage->Put(calDet, id1, metaData);
1201
1202 //
1203
1204 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
1205 metaDataPad->SetObjectClassName("AliTRDCalPad");
1206 metaDataPad->SetResponsible("Raphaelle Bailhache");
58006729 1207 metaDataPad->AddDateToComment();
a5dcf618 1208 metaDataPad->SetBeamPeriod(1);
1209
1210 AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber);
1211 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
1212 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
1213
1214
1215
1216 }
1217 //_________________________________________________________________________________________________________________
1218 void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1219 //
1220 // Update OCDB entry
1221 //
1222
1223 AliCDBMetaData *metaData= new AliCDBMetaData();
1224 metaData->SetObjectClassName("AliTRDCalPad");
1225 metaData->SetResponsible("Raphaelle Bailhache");
58006729 1226 metaData->AddDateToComment();
a5dcf618 1227 metaData->SetBeamPeriod(1);
1228
58006729 1229
a5dcf618 1230 AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber);
1231 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1232 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
1233 if(calPad) gStorage->Put(calPad, id1, metaData);
1234
1235
1236 }
1237 //_________________________________________________________________________________________________________________
1238 void AliTRDPreprocessorOffline::UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1239 //
1240 // Update OCDB entry
1241 //
1242
1243 AliCDBMetaData *metaData= new AliCDBMetaData();
1244 metaData->SetObjectClassName("AliTRDCalChamberStatus");
58006729 1245 metaData->SetResponsible("Raphaelle Bailhache and Julian Book");
1246 metaData->AddDateToComment();
a5dcf618 1247 metaData->SetBeamPeriod(1);
1248
1249 AliCDBId id1("TRD/Calib/ChamberStatus", startRunNumber, endRunNumber);
1250 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1251 AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus);
1252 if(calChamberStatus) gStorage->Put(calChamberStatus, id1, metaData);
1253
1254
1255 }
1256 //__________________________________________________________________________________________________________________________
54f2ff1c 1257 Bool_t AliTRDPreprocessorOffline::ValidateGain() {
a5dcf618 1258 //
1259 // Validate OCDB entry
1260 //
1261
1262 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
1263 if(calDet) {
1264 Double_t mean = calDet->GetMean();
1265 Double_t rms = calDet->GetRMSRobust();
1266 if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE;
1267 //if((mean > 0.2) && (mean < 1.4)) return kTRUE;
54f2ff1c 1268 else {
82b413fd 1269 fStatusPos = fStatusPos | kGainErrorRange;
54f2ff1c 1270 return kFALSE;
1271 }
a5dcf618 1272 }
1273 else return kFALSE;
54f2ff1c 1274
a5dcf618 1275
1276
1277 }
1278 //__________________________________________________________________________________________________________________________
1279 Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){
1280 //
1281 // Update OCDB entry
1282 //
1283
1284 Int_t detVdrift = kVdriftPHDet;
1285 Bool_t ok = kTRUE;
1286
1287 if(fMethodSecond) detVdrift = kVdriftLinear;
1288
1289 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1290 if(calDet) {
1291 Double_t mean = calDet->GetMean();
1292 Double_t rms = calDet->GetRMSRobust();
1293 //printf("Vdrift::mean %f, rms %f\n",mean,rms);
54f2ff1c 1294 if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) {
82b413fd 1295 fStatusPos = fStatusPos | kVdriftErrorRange;
54f2ff1c 1296 ok = kFALSE;
1297 }
a5dcf618 1298 }
1299 else return kFALSE;
1300
1301 if(!fMethodSecond) {
1302 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
1303 if(calPad) {
1304 Double_t mean = calPad->GetMean();
1305 Double_t rms = calPad->GetRMS();
1306 //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms);
54f2ff1c 1307 if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) {
82b413fd 1308 fStatusPos = fStatusPos | kVdriftErrorRange;
54f2ff1c 1309 ok = kFALSE;
1310 }
a5dcf618 1311 }
1312 else return kFALSE;
1313 }
1314
1315 return ok;
1316
840ec79d 1317 }
1318 //__________________________________________________________________________________________________________________________
1319 Bool_t AliTRDPreprocessorOffline::ValidateExB(){
1320 //
1321 // Update OCDB entry
1322 //
1323
1324 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
1325 if(calDet) {
1326 Double_t mean = calDet->GetMean();
1327 Double_t rms = calDet->GetRMSRobust();
1328 //printf("Vdrift::mean %f, rms %f\n",mean,rms);
1329 if(!((mean > -1.0) && (mean < 1.0) && (rms < 0.5))) {
1330 fStatusNeg = fStatusNeg | kExBErrorRange;
1331 return kFALSE;
1332 }
1333 else return kTRUE;
1334 }
1335 else return kFALSE;
1336
a5dcf618 1337 }
1338 //__________________________________________________________________________________________________________________________
1339 Bool_t AliTRDPreprocessorOffline::ValidateT0(){
1340 //
1341 // Update OCDB entry
1342 //
1343
1344 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
1345 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
1346 if(calDet && calPad) {
1347 Double_t meandet = calDet->GetMean();
1348 Double_t rmsdet = calDet->GetRMSRobust();
1349 Double_t meanpad = calPad->GetMean();
1350 //Double_t rmspad = calPad->GetRMS();
1351 //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad);
1352 if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE;
54f2ff1c 1353 else {
82b413fd 1354 fStatusPos = fStatusPos | kTimeOffsetErrorRange;
54f2ff1c 1355 return kFALSE;
1356 }
a5dcf618 1357 }
1358 else return kFALSE;
1359
1360 }
1361 //__________________________________________________________________________________________________________________________
1362 Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{
1363 //
1364 // Update OCDB entry
1365 //
1366
1367 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
1368 if(calPad) {
1369 Double_t meanpad = calPad->GetMean();
1370 Double_t rmspad = calPad->GetRMS();
1371 //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad);
1372 if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE;
1373 else return kFALSE;
1374 }
1375 else return kFALSE;
1376
1377
1378 }
1379 //__________________________________________________________________________________________________________________________
82b413fd 1380Bool_t AliTRDPreprocessorOffline::ValidateChamberStatus(){
00d203b6 1381 //
1382 // Update OCDB entry
1383 //
1384
a5dcf618 1385 AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus);
1386 if(calChamberStatus) {
83d0cc79 1387
1388 Int_t detectornodata = 0;
1389 Int_t detectorbadcalib = 0;
1390
1391 for(Int_t sm=0; sm < 18; sm++) {
1392 //printf("%d chambers w/o data in sm %d\n",fNoData[sm],sm);
1393 //printf("%d bad calibrated chambers in sm %d\n",fBadCalib[sm],sm);
1394 if(fNoData[sm] != 30) detectornodata += fNoData[sm];
1395 detectorbadcalib+=fBadCalib[sm];
a5dcf618 1396 }
83d0cc79 1397 //printf("Number of chambers w/o data %d\n",detectornodata);
1398 //printf("Number of chambers bad calibrated %d\n",detectorbadcalib);
1399
1400 if((detectornodata > fNoDataValidate) ||
1401 (detectorbadcalib > fBadCalibValidate)){
82b413fd 1402 fStatusPos = fStatusPos | kChamberStatusErrorRange;
1403 return kFALSE;
1404 }
83d0cc79 1405 return kTRUE;
00d203b6 1406 }
1407 else return kFALSE;
83d0cc79 1408
b3fcfd96 1409}
4c865c34 1410//_____________________________________________________________________________
1411Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const
1412{
1413 //
1414 // Get version from the title
1415 //
1416
1417 // Some patterns
1418 const Char_t *version = "Ver";
1419 if(!strstr(name.Data(),version)) return -1;
f558cb62 1420 const Char_t *after = "Subver";
1421 if(!strstr(name.Data(),after)) return -1;
1422
4c865c34 1423 for(Int_t ver = 0; ver < 999999999; ver++) {
1424
1425 TString vertry(version);
1426 vertry += ver;
f558cb62 1427 vertry += after;
4c865c34 1428
1429 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1430
1431 if(strstr(name.Data(),vertry.Data())) return ver;
1432
1433 }
1434
1435 return -1;
1436
1437}
1438
1439//_____________________________________________________________________________
1440Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const
1441{
1442 //
1443 // Get subversion from the title
1444 //
1445
1446 // Some patterns
1447 const Char_t *subversion = "Subver";
1448 if(!strstr(name.Data(),subversion)) return -1;
f558cb62 1449 const Char_t *after = "FirstRun";
1450 if(!strstr(name.Data(),after)) {
1451 after = "Nz";
1452 }
1453 if(!strstr(name.Data(),after)) return -1;
1454
4c865c34 1455
1456 for(Int_t ver = 0; ver < 999999999; ver++) {
1457
1458 TString vertry(subversion);
1459 vertry += ver;
f558cb62 1460 vertry += after;
ca7e6e64 1461
1462 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1463
1464 if(strstr(name.Data(),vertry.Data())) return ver;
1465
1466 }
1467
1468 return -1;
1469
1470}
1471
1472//_____________________________________________________________________________
1473Int_t AliTRDPreprocessorOffline::GetFirstRun(TString name) const
1474{
1475 //
1476 // Get first run from the title
1477 //
1478
1479 // Some patterns
1480 const Char_t *firstrun = "FirstRun";
1481 if(!strstr(name.Data(),firstrun)) return -1;
f558cb62 1482 const Char_t *after = "Nz";
1483 if(!strstr(name.Data(),after)) return -1;
1484
ca7e6e64 1485
1486 for(Int_t ver = 0; ver < 999999999; ver++) {
1487
1488 TString vertry(firstrun);
1489 vertry += ver;
f558cb62 1490 vertry += after;
4c865c34 1491
1492 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1493
1494 if(strstr(name.Data(),vertry.Data())) return ver;
1495
1496 }
1497
1498 return -1;
1499
1500}
82b413fd 1501//_____________________________________________________________________________
1502Bool_t AliTRDPreprocessorOffline::CheckStatus(Int_t status, Int_t bitMask) const
1503{
1504 //
1505 // Checks the status
1506 //
1507
1508 return (status & bitMask) ? kTRUE : kFALSE;
1509
1510}
1511//_____________________________________________________________________________
1512Int_t AliTRDPreprocessorOffline::GetStatus() const
1513{
1514 //
1515 // Checks the status
1516 // fStatusPos: errors
1517 // fStatusNeg: only info
1518 //
1519
1520 if(fStatusPos > 0) return fStatusPos;
1521 else return (-TMath::Abs(fStatusNeg));
1522
1523}
1524//_____________________________________________________________________________
1525void AliTRDPreprocessorOffline::PrintStatus() const
1526{
1527 //
1528 // Do Summary
1529 //
1530
1531 AliInfo(Form("The error status is %d",fStatusPos));
1532 AliInfo(Form("IsGainErrorOld? %d",(Int_t)IsGainErrorOld()));
1533 AliInfo(Form("IsVdriftErrorOld? %d",(Int_t)IsVdriftErrorOld()));
1534 AliInfo(Form("IsGainErrorRange? %d",(Int_t)IsGainErrorRange()));
1535 AliInfo(Form("IsVdriftErrorRange? %d",(Int_t)IsVdriftErrorRange()));
1536 AliInfo(Form("IsTimeOffsetErrorRange? %d",(Int_t)IsTimeOffsetErrorRange()));
1537 AliInfo(Form("IsChamberStatusErrorRange? %d",(Int_t)IsChamberStatusErrorRange()));
1538
1539
1540 AliInfo(Form("The info status is %d",fStatusNeg));
1541 AliInfo(Form("IsGainNotEnoughStatsButFill? %d",(Int_t)IsGainNotEnoughStatsButFill()));
1542 AliInfo(Form("IsVdriftNotEnoughStatsButFill? %d",(Int_t)IsVdriftNotEnoughStatsButFill()));
1543 AliInfo(Form("IsGainNotEnoughStatsNotFill? %d",(Int_t)IsGainNotEnoughStatsNotFill()));
1544 AliInfo(Form("IsVdriftNotEnoughStatsNotFill? %d",(Int_t)IsVdriftNotEnoughStatsNotFill()));
1545 AliInfo(Form("IsTimeOffsetNotEnoughStatsNotFill? %d",(Int_t)IsTimeOffsetNotEnoughStatsNotFill()));
840ec79d 1546
1547 AliInfo(Form("IsExBErrorRange? %d",(Int_t)IsExBErrorRange()));
1548 AliInfo(Form("IsExBErrorOld? %d",(Int_t)IsExBErrorOld()));
82b413fd 1549
1550}
840ec79d 1551//___________________________________________________________________________________
1552void AliTRDPreprocessorOffline::SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed)
1553{
1554
1555 fCalDetVdriftUsed = calDetVdriftUsed;
1556
1557 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1558 for(Int_t k = 0; k < 540; k++){
1559 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1560 //printf("Set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1561 }
1562
1563};
83d0cc79 1564//___________________________________________________________________________________
1565Bool_t AliTRDPreprocessorOffline::SetCalDetGain(Int_t runNumber, Int_t version, Int_t subversion)
1566{
1567 //
1568 // Set the fCalDetGainUsed
1569 //
1570
1571 if((version == 0) && (subversion == 0)) return kFALSE;
82b413fd 1572
83d0cc79 1573 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",runNumber, version, subversion);
1574 if(!entry) {
1575 AliError("Found no entry\n");
1576 fStatusPos = fStatusPos | kGainErrorOld;
1577 return kFALSE;
1578 }
1579 //const AliCDBId id = entry->GetId();
1580 //version = id.GetVersion();
1581 //subversion = id.GetSubVersion();
1582 //printf("Found version %d and subversion %d for vdrift\n",version,subversion);
1583 AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject();
1584 if(calDet) fCalDetGainUsed = calDet;
1585 else {
1586 fStatusPos = fStatusPos | kGainErrorOld;
1587 return kFALSE;
1588 }
1589
1590 return kTRUE;
1591
1592}
1593//___________________________________________________________________________________
1594Bool_t AliTRDPreprocessorOffline::SetCalDetVdriftExB(Int_t runNumber, Int_t versionv, Int_t subversionv, Int_t versionexb, Int_t subversionexb)
1595{
1596 //
1597 // Set the fCalDetVdriftUsed and fCalDetExBUsed
1598 //
1599
1600 if((versionv == 0) && (subversionv == 0)) return kFALSE;
1601
1602 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberVdrift",runNumber, versionv, subversionv);
1603 if(!entry) {
1604 AliError("Found no entry\n");
1605 fStatusPos = fStatusPos | kVdriftErrorOld;
1606 return kFALSE;
1607 }
1608 AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject();
1609 if(calDet) fCalDetVdriftUsed = calDet;
1610 else {
1611 fStatusPos = fStatusPos | kVdriftErrorOld;
1612 return kFALSE;
1613 }
1614
1615 // ExB object
1616
1617 if((versionexb == 0) && (subversionexb == 0)) {
1618
1619 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1620 for(Int_t k = 0; k < 540; k++){
1621 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1622 //printf("Nothing found: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1623 }
1624 }
1625 else {
1626
1627 entry = 0x0;
1628 entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberExB",runNumber, versionexb, subversionexb);
1629 if(!entry) {
1630 //printf("Found no entry\n");
1631 fStatusPos = fStatusPos | kExBErrorOld;
1632 return kFALSE;
1633 }
1634 AliTRDCalDet* calDetexb = (AliTRDCalDet *)entry->GetObject();
1635 if(!calDetexb) {
1636 fStatusPos = fStatusPos | kExBErrorOld;
1637 return kFALSE;
1638 }
1639
1640 Double_t meanexb = calDetexb->GetMean();
1641 //printf("Mean value %f\n",meanexb);
1642 if((meanexb > 70) || (fNoExBUsedInReco)) {
1643 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1644 for(Int_t k = 0; k < 540; k++){
1645 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1646 //printf("Found but: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1647 }
1648 }
1649 else {
1650 fCalDetExBUsed = calDetexb;
1651 }
1652
1653 }
1654
1655
1656 return kTRUE;
1657
1658}
01239968 1659