1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 $Log: AliTOFcalib.cxx,v $
18 Revision 1.21 2007/11/02 15:41:49 hristov
19 Provide return value if the function is not void
21 Revision 1.20 2007/10/26 15:13:50 zampolli
22 Using a TChain instead of a TTree
24 Revision 1.19 2007/10/23 15:27:38 zampolli
25 Rearrangement of Calibration objects for simulation
27 Revision 1.16 2007/10/08 10:13:26 zampolli
28 First Run and Last Run members added, infinite validity of calib obj implemented.
30 Revision 1.15 2007/10/04 13:23:28 zampolli
31 Updates to handle functionalities in TOF online/offline calibration according to the latest schema
33 Revision 1.14 2007/06/06 16:26:30 arcelli
34 remove fall-back call to local CDB storage
36 Revision 1.13 2007/04/20 13:59:40 arcelli
37 make protections agains failed retrieval of the CDB object in a proper way
39 Revision 1.12 2007/03/23 11:31:16 arcelli
40 CDB Entry for TOF Reconstruction Parameters
42 Revision 1.11 2007/02/28 18:08:26 arcelli
43 Add protection against failed retrieval of the CDB cal object
45 Revision 1.10 2006/08/22 13:30:49 arcelli
46 removal of effective c++ warnings (C.Zampolli)
48 Revision 1.9 2006/04/20 22:30:50 hristov
49 Coding conventions (Annalisa)
51 Revision 1.8 2006/04/16 22:29:05 hristov
52 Coding conventions (Annalisa)
54 Revision 1.7 2006/04/16 20:12:46 hristov
55 Removing memory leak in case of cached CDB entries
57 Revision 1.6 2006/04/11 15:28:32 hristov
58 Checks on cache status before deleting calibration objects (A.Colla)
60 Revision 1.5 2006/04/05 08:35:38 hristov
61 Coding conventions (S.Arcelli, C.Zampolli)
63 Revision 1.4 2006/03/31 11:26:46 arcelli
64 changing CDB Ids according to standard convention
66 Revision 1.3 2006/03/28 14:57:02 arcelli
67 updates to handle new V5 geometry & some re-arrangements
69 Revision 1.2 2006/02/13 17:22:26 arcelli
72 Revision 1.1 2006/02/13 16:10:48 arcelli
73 Add classes for TOF Calibration (C.Zampolli)
75 author: Chiara Zampolli, zampolli@bo.infn.it
78 ///////////////////////////////////////////////////////////////////////////////
80 // class for TOF calibration //
82 ///////////////////////////////////////////////////////////////////////////////
98 #include "AliCDBEntry.h"
99 #include "AliCDBRunRange.h"
100 #include "AliCDBId.h"
101 #include "AliCDBManager.h"
102 #include "AliCDBStorage.h"
103 #include "AliCDBMetaData.h"
104 //#include "AliESDtrack.h"
105 //#include "AliESD.h"
108 #include "AliTOFcalib.h"
109 #include "AliTOFChannelOnlineArray.h"
110 #include "AliTOFChannelOnline.h"
111 #include "AliTOFChannelOnlineStatus.h"
112 #include "AliTOFChannelOnlineStatusArray.h"
113 #include "AliTOFChannelOffline.h"
114 #include "AliTOFGeometry.h"
115 #include "AliTOFRecoParam.h"
116 #include "AliTOFDeltaBCOffset.h"
117 #include "AliTOFCTPLatency.h"
118 #include "AliTOFT0Fill.h"
119 #include "AliTOFRunParams.h"
125 extern TStyle *gStyle;
127 ClassImp(AliTOFcalib)
129 //_______________________________________________________________________
130 AliTOFcalib::AliTOFcalib():
131 TTask("AliTOFcalib",""),
134 fTOFCalOnlinePulser(0x0),
135 fTOFCalOnlineNoise(0x0),
136 fTOFCalOnlineHW(0x0),
146 fLastRun(AliCDBRunRange::Infinity()),
147 fConfigMap(new TMap),
148 fDeltaBCOffset(NULL),
153 //TOF Calibration Class ctor
154 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
156 //____________________________________________________________________________
158 AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
160 fNChannels(calib.fNChannels),
162 fTOFCalOnlinePulser(0x0),
163 fTOFCalOnlineNoise(0x0),
164 fTOFCalOnlineHW(0x0),
167 fStatus(calib.fStatus),
168 fTOFSimToT(calib.fTOFSimToT),
169 fkValidity(calib.fkValidity),
171 fChain(calib.fChain),
172 fNruns(calib.fNruns),
173 fFirstRun(calib.fFirstRun),
174 fLastRun(calib.fLastRun),
175 fConfigMap(calib.fConfigMap),
176 fDeltaBCOffset(NULL),
181 //TOF Calibration Class copy ctor
182 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
183 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
184 AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray);
185 AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray);
186 AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray);
187 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
188 fTOFCalOnline->AddAt(calChOnline,iarray);
189 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
190 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
191 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
192 fTOFCalOffline->AddAt(calChOffline,iarray);
195 if (calib.fDeltaBCOffset) fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset);
196 if (calib.fCTPLatency) fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency);
197 if (calib.fT0Fill) fT0Fill = new AliTOFT0Fill(*calib.fT0Fill);
198 if (calib.fRunParams) fRunParams = new AliTOFRunParams(*calib.fRunParams);
201 //____________________________________________________________________________
203 AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
205 //TOF Calibration Class assignment operator
210 TTask::operator=(calib);
211 fNChannels = calib.fNChannels;
213 fStatus = calib.fStatus;
214 fTOFSimToT = calib.fTOFSimToT;
215 fkValidity = calib.fkValidity;
217 fChain = calib.fChain;
218 fNruns = calib.fNruns;
219 fFirstRun = calib.fFirstRun;
220 fLastRun = calib.fLastRun;
221 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
222 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
223 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
224 AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray);
225 AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray);
226 AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray);
227 fTOFCalOnline->AddAt(calChOnline,iarray);
228 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
229 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
230 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
231 fTOFCalOffline->AddAt(calChOffline,iarray);
234 if (calib.fDeltaBCOffset) {
235 if (fDeltaBCOffset) *fDeltaBCOffset = *calib.fDeltaBCOffset;
236 else fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset);
239 if (calib.fCTPLatency) {
240 if (fCTPLatency) *fCTPLatency = *calib.fCTPLatency;
241 else fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency);
245 if (fT0Fill) *fT0Fill = *calib.fT0Fill;
246 else fT0Fill = new AliTOFT0Fill(*calib.fT0Fill);
248 if (calib.fRunParams) {
249 if (fRunParams) *fRunParams = *calib.fRunParams;
250 else fRunParams = new AliTOFRunParams(*calib.fRunParams);
256 //____________________________________________________________________________
258 AliTOFcalib::~AliTOFcalib()
260 //TOF Calibration Class dtor
261 if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
263 delete fTOFCalOnline;
265 if (fTOFCalOnlinePulser){
266 delete fTOFCalOnlinePulser;
268 if (fTOFCalOnlineNoise){
269 delete fTOFCalOnlineNoise;
271 if (fTOFCalOnlineHW){
272 delete fTOFCalOnlineHW;
275 delete fTOFCalOffline;
286 if (fDeltaBCOffset) delete fDeltaBCOffset;
287 if (fCTPLatency) delete fCTPLatency;
288 if (fT0Fill) delete fT0Fill;
289 if (fRunParams) delete fRunParams;
291 if (fTree!=0x0) delete fTree;
292 if (fChain!=0x0) delete fChain;
295 //_____________________________________________________________________________
296 void AliTOFcalib::CreateCalArrays(){
298 // creating arrays for online/offline calibration objs
300 fTOFCalOnline = new TObjArray(fNChannels);
301 fTOFCalOnlinePulser = new TObjArray(fNChannels);
302 fTOFCalOnlineNoise = new TObjArray(fNChannels);
303 fTOFCalOnlineHW = new TObjArray(fNChannels);
304 fTOFCalOffline = new TObjArray(fNChannels);
305 fTOFCalOnline->SetOwner();
306 fTOFCalOnlinePulser->SetOwner();
307 fTOFCalOnlineNoise->SetOwner();
308 fTOFCalOnlineHW->SetOwner();
309 fTOFCalOffline->SetOwner();
310 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
311 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
312 AliTOFChannelOnlineStatus * calChOnlineStPulser = new AliTOFChannelOnlineStatus();
313 AliTOFChannelOnlineStatus * calChOnlineStNoise = new AliTOFChannelOnlineStatus();
314 AliTOFChannelOnlineStatus * calChOnlineStHW = new AliTOFChannelOnlineStatus();
315 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
316 fTOFCalOnline->AddAt(calChOnline,iarray);
317 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
318 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
319 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
320 fTOFCalOffline->AddAt(calChOffline,iarray);
322 fCal = new AliTOFChannelOnlineArray(fNChannels);
323 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
325 //_____________________________________________________________________________
326 void AliTOFcalib::CreateCalObjects(){
328 // creating arrays for online/offline calibration objs
330 fTOFCalOffline = new TObjArray(fNChannels);
331 fTOFCalOffline->SetOwner();
332 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
333 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
334 fTOFCalOffline->AddAt(calChOffline,iarray);
336 fCal = new AliTOFChannelOnlineArray(fNChannels);
337 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
339 //_____________________________________________________________________________
340 void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
342 //Write calibration parameters to the CDB
345 AliCDBManager *man = AliCDBManager::Instance();
346 const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor
348 sprintf(out,"%s/%s",sel,sel1);
349 AliDebug(2,Form("Writing TOF configuration map for online calib on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
350 AliCDBId id(out,fFirstRun,fLastRun);
351 AliCDBMetaData *md = new AliCDBMetaData();
352 md->SetResponsible("Chiara Zampolli");
356 man->Put(fConfigMap,id,md);
359 //_____________________________________________________________________________
361 void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel)
363 //Write calibration parameters to the CDB with infinite validity
364 AliCDBManager *man = AliCDBManager::Instance();
365 const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor
367 sprintf(out,"%s/%s",sel,sel1);
368 AliCDBRunRange runrange(fFirstRun,fLastRun);
369 AliDebug(2,Form("Writing TOF config map for online calib on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
370 AliCDBId id(out,runrange);
371 AliCDBMetaData *md = new AliCDBMetaData();
372 md->SetResponsible("Chiara Zampolli");
376 man->Put(fConfigMap,id,md);
379 //_____________________________________________________________________________
380 void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
382 //Write calibration parameters to the CDB -------> new calib objs!!!!!
385 AliCDBManager *man = AliCDBManager::Instance();
386 const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor
388 sprintf(out,"%s/%s",sel,sel1);
389 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
390 AliCDBId id(out,fFirstRun,fLastRun);
391 AliCDBMetaData *md = new AliCDBMetaData();
392 md->SetResponsible("Chiara Zampolli");
396 man->Put(fCal,id,md);
399 //_____________________________________________________________________________
400 void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
402 //Write calibration parameters to the CDB -------> new calib objs!!!!!
405 AliCDBManager *man = AliCDBManager::Instance();
406 const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor
408 sprintf(out,"%s/%s",sel,sel1);
409 AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
410 AliCDBId id(out,fFirstRun,fLastRun);
411 AliCDBMetaData *md = new AliCDBMetaData();
412 md->SetResponsible("Chiara Zampolli");
416 man->Put(fStatus,id,md);
419 //_____________________________________________________________________________
421 void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel)
423 //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!!
424 AliCDBManager *man = AliCDBManager::Instance();
425 const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor
427 sprintf(out,"%s/%s",sel,sel1);
428 AliCDBRunRange runrange(fFirstRun,fLastRun);
429 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
430 AliCDBId id(out,runrange);
431 AliCDBMetaData *md = new AliCDBMetaData();
432 md->SetResponsible("Chiara Zampolli");
436 man->Put(fCal,id,md);
439 //_____________________________________________________________________________
441 void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel)
443 //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!!
444 AliCDBManager *man = AliCDBManager::Instance();
445 const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor
447 sprintf(out,"%s/%s",sel,sel1);
448 AliCDBRunRange runrange(fFirstRun,fLastRun);
449 AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
450 AliCDBId id(out,runrange);
451 AliCDBMetaData *md = new AliCDBMetaData();
452 md->SetResponsible("Chiara Zampolli");
456 man->Put(fStatus,id,md);
459 //_____________________________________________________________________________
460 void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
462 //Write calibration parameters to the CDB
465 AliCDBManager *man = AliCDBManager::Instance();
466 const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
468 sprintf(out,"%s/%s",sel,sel1);
469 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
470 AliCDBId id(out,fFirstRun,fLastRun);
471 AliCDBMetaData *md = new AliCDBMetaData();
472 md->SetResponsible("Chiara Zampolli");
473 if (!fTOFCalOnline) {
476 man->Put(fTOFCalOnline,id,md);
479 //_____________________________________________________________________________
480 void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
482 //Write calibration parameters from pulser to the CDB
485 AliCDBManager *man = AliCDBManager::Instance();
486 const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor
488 sprintf(out,"%s/%s",sel,sel1);
489 AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
490 AliCDBId id(out,fFirstRun,fLastRun);
491 AliCDBMetaData *md = new AliCDBMetaData();
492 md->SetResponsible("Chiara Zampolli");
493 if (!fTOFCalOnlinePulser) {
496 man->Put(fTOFCalOnlinePulser,id,md);
499 //_____________________________________________________________________________
500 void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
502 //Write calibration parameters from noise to the CDB
505 AliCDBManager *man = AliCDBManager::Instance();
506 const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor
508 sprintf(out,"%s/%s",sel,sel1);
509 AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
510 AliCDBId id(out,fFirstRun,fLastRun);
511 AliCDBMetaData *md = new AliCDBMetaData();
512 md->SetResponsible("Chiara Zampolli");
513 if (!fTOFCalOnlineNoise) {
516 man->Put(fTOFCalOnlineNoise,id,md);
519 //_____________________________________________________________________________
520 void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
522 //Write calibration parameters from hardware to the CDB
525 AliCDBManager *man = AliCDBManager::Instance();
526 const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor
528 sprintf(out,"%s/%s",sel,sel1);
529 AliDebug(2,Form("Writing TOF online calib obj from hardware on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
530 AliCDBId id(out,fFirstRun,fLastRun);
531 AliCDBMetaData *md = new AliCDBMetaData();
532 md->SetResponsible("Chiara Zampolli");
533 if (!fTOFCalOnlineHW) {
536 man->Put(fTOFCalOnlineHW,id,md);
539 //_____________________________________________________________________________
541 void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel)
543 //Write calibration parameters to the CDB with infinite validity
544 AliCDBManager *man = AliCDBManager::Instance();
545 const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
547 sprintf(out,"%s/%s",sel,sel1);
548 AliCDBRunRange runrange(fFirstRun,fLastRun);
549 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
550 AliCDBId id(out,runrange);
551 AliCDBMetaData *md = new AliCDBMetaData();
552 md->SetResponsible("Chiara Zampolli");
553 if (!fTOFCalOnline) {
556 man->Put(fTOFCalOnline,id,md);
559 //_____________________________________________________________________________
561 void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel)
563 //Write calibration parameters from pulser to the CDB with infinite validity
564 AliCDBManager *man = AliCDBManager::Instance();
565 const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor
567 sprintf(out,"%s/%s",sel,sel1);
568 AliCDBRunRange runrange(fFirstRun,fLastRun);
569 AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
570 AliCDBId id(out,runrange);
571 AliCDBMetaData *md = new AliCDBMetaData();
572 md->SetResponsible("Chiara Zampolli");
573 if (!fTOFCalOnlinePulser) {
576 man->Put(fTOFCalOnlinePulser,id,md);
579 //_____________________________________________________________________________
581 void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel)
583 //Write calibration parameters from noise to the CDB with infinite validity
584 AliCDBManager *man = AliCDBManager::Instance();
585 const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor
587 sprintf(out,"%s/%s",sel,sel1);
588 AliCDBRunRange runrange(fFirstRun,fLastRun);
589 AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
590 AliCDBId id(out,runrange);
591 AliCDBMetaData *md = new AliCDBMetaData();
592 md->SetResponsible("Chiara Zampolli");
593 if (!fTOFCalOnlineNoise) {
596 man->Put(fTOFCalOnlineNoise,id,md);
599 //_____________________________________________________________________________
601 void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel)
603 //Write calibration parameters from hardware to the CDB with infinite validity
604 AliCDBManager *man = AliCDBManager::Instance();
605 const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor
607 sprintf(out,"%s/%s",sel,sel1);
608 AliCDBRunRange runrange(fFirstRun,fLastRun);
609 AliDebug(2,Form("Writing TOF online calib obj from harware on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
610 AliCDBId id(out,runrange);
611 AliCDBMetaData *md = new AliCDBMetaData();
612 md->SetResponsible("Chiara Zampolli");
613 if (!fTOFCalOnlineHW) {
616 man->Put(fTOFCalOnlineHW,id,md);
619 //_____________________________________________________________________________
621 void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun)
623 //Write calibration parameters to the CDB
626 AliCDBManager *man = AliCDBManager::Instance();
627 const Char_t *sel1 = "ParOffline" ;
629 sprintf(out,"%s/%s",sel,sel1);
630 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
631 AliCDBId id(out,fFirstRun,fLastRun);
632 AliCDBMetaData *md = new AliCDBMetaData();
633 md->SetResponsible("Chiara Zampolli");
634 md->SetComment(validity);
635 man->Put(fTOFCalOffline,id,md);
638 //_____________________________________________________________________________
640 void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity)
642 //Write calibration parameters to the CDB with infinite validity
643 AliCDBManager *man = AliCDBManager::Instance();
644 const Char_t *sel1 = "ParOffline" ;
646 sprintf(out,"%s/%s",sel,sel1);
647 AliCDBRunRange runrange(fFirstRun,fLastRun);
648 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
649 AliCDBId id(out,runrange);
650 AliCDBMetaData *md = new AliCDBMetaData();
651 md->SetResponsible("Chiara Zampolli");
652 md->SetComment(validity);
653 man->Put(fTOFCalOffline,id,md);
656 //_____________________________________________________________________________
658 Bool_t AliTOFcalib::ReadConfigMapFromCDB(const Char_t *sel, Int_t nrun)
660 //Read calibration parameters from the CDB
661 AliCDBManager *man = AliCDBManager::Instance();
662 const Char_t *sel1 = "Config" ;
664 sprintf(out,"%s/%s",sel,sel1);
665 AliCDBEntry *entry = man->Get(out,nrun);
667 AliFatal("Exiting, no CDB object (ConfigMap) found!!!");
670 if(!entry->GetObject()){
671 AliFatal("Exiting, no CDB object (ConfigMap) found!!!");
675 fConfigMap =(TMap*)entry->GetObject();
680 //_____________________________________________________________________________
682 Bool_t AliTOFcalib::ReadParOnlineDelayFromCDB(const Char_t *sel, Int_t nrun)
684 //Read calibration parameters from the CDB -------> new calib objs!!!!!
685 AliCDBManager *man = AliCDBManager::Instance();
686 const Char_t *sel1 = "ParOnlineDelay" ;
688 sprintf(out,"%s/%s",sel,sel1);
689 AliCDBEntry *entry = man->Get(out,nrun);
691 AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!");
694 if(!entry->GetObject()){
695 AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!");
699 fCal =(AliTOFChannelOnlineArray*)entry->GetObject();
704 //_____________________________________________________________________________
706 Bool_t AliTOFcalib::ReadParOnlineStatusFromCDB(const Char_t *sel, Int_t nrun)
708 //Read calibration parameters from the CDB -------> new calib objs!!!!!
709 AliCDBManager *man = AliCDBManager::Instance();
710 const Char_t *sel1 = "Status" ;
712 sprintf(out,"%s/%s",sel,sel1);
713 AliCDBEntry *entry = man->Get(out,nrun);
715 AliFatal("Exiting, no CDB object (Status) found!!!");
718 if(!entry->GetObject()){
719 AliFatal("Exiting, no CDB object (Status) found!!!");
723 fStatus =(AliTOFChannelOnlineStatusArray*)entry->GetObject();
728 //_____________________________________________________________________________
730 Bool_t AliTOFcalib::ReadParOnlineFromCDB(const Char_t *sel, Int_t nrun)
732 //Read calibration parameters from the CDB
733 AliCDBManager *man = AliCDBManager::Instance();
734 const Char_t *sel1 = "ParOnline" ;
736 sprintf(out,"%s/%s",sel,sel1);
737 AliCDBEntry *entry = man->Get(out,nrun);
739 AliFatal("Exiting, no CDB object (ParOnline) found!!!");
742 if(!entry->GetObject()){
743 AliFatal("Exiting, no CDB object (ParOnline) found!!!");
747 fTOFCalOnline =(TObjArray*)entry->GetObject();
752 //_____________________________________________________________________________
754 Bool_t AliTOFcalib::ReadParOnlinePulserFromCDB(const Char_t *sel, Int_t nrun)
756 //Read calibration parameters from pulser from the CDB
757 AliCDBManager *man = AliCDBManager::Instance();
758 const Char_t *sel1 = "Pulser" ;
760 sprintf(out,"%s/%s",sel,sel1);
761 AliCDBEntry *entry = man->Get(out,nrun);
763 AliFatal("Exiting, no CDB object (Pulser) found!!!");
766 if(!entry->GetObject()){
767 AliFatal("Exiting, no CDB object (Pulser) found!!!");
771 fTOFCalOnlinePulser =(TObjArray*)entry->GetObject();
776 //_____________________________________________________________________________
778 Bool_t AliTOFcalib::ReadParOnlineNoiseFromCDB(const Char_t *sel, Int_t nrun)
780 //Read calibration parameters from noise from the CDB
781 AliCDBManager *man = AliCDBManager::Instance();
782 const Char_t *sel1 = "Noise" ;
784 sprintf(out,"%s/%s",sel,sel1);
785 AliCDBEntry *entry = man->Get(out,nrun);
787 AliFatal("Exiting, no CDB object (Noise) found!!!");
790 if(!entry->GetObject()){
791 AliFatal("Exiting, no CDB object (Noise) found!!!");
795 fTOFCalOnlineNoise =(TObjArray*)entry->GetObject();
800 //_____________________________________________________________________________
802 Bool_t AliTOFcalib::ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun)
804 //Read calibration parameters from hardware from the CDB
805 AliCDBManager *man = AliCDBManager::Instance();
806 const Char_t *sel1 = "HW" ;
808 sprintf(out,"%s/%s",sel,sel1);
809 AliCDBEntry *entry = man->Get(out,nrun);
811 AliFatal("Exiting, no CDB object (HW map) found!!!");
814 if(!entry->GetObject()){
815 AliFatal("Exiting, no CDB object (HW map) found!!!");
819 fTOFCalOnlineHW =(TObjArray*)entry->GetObject();
824 //_____________________________________________________________________________
826 Bool_t AliTOFcalib::ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun)
828 //Read calibration parameters from the CDB
829 AliCDBManager *man = AliCDBManager::Instance();
830 const Char_t *sel1 = "ParOffline" ;
832 sprintf(out,"%s/%s",sel,sel1);
833 AliCDBEntry *entry = man->Get(out,nrun);
835 AliFatal("Exiting, no CDB object (ParOffline) found!!!");
838 if(!entry->GetObject()){
839 AliFatal("Exiting, no CDB object (ParOffline) found!!!");
842 AliCDBMetaData * md = entry->GetMetaData();
843 fkValidity = md->GetComment();
844 fTOFCalOffline =(TObjArray*)entry->GetObject();
849 //_____________________________________________________________________________
850 void AliTOFcalib::WriteSimHistoOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo){
851 //Write Sim miscalibration parameters to the CDB
854 AliCDBManager *man = AliCDBManager::Instance();
855 const Char_t *sel1 = "SimHisto" ;
857 sprintf(out,"%s/%s",sel,sel1);
858 AliCDBMetaData *mdhisto = new AliCDBMetaData();
859 mdhisto->SetResponsible("Chiara Zampolli");
860 AliCDBId id(out,minrun,maxrun);
861 man->Put(fTOFSimToT,id,mdhisto);
864 //_____________________________________________________________________________
865 Bool_t AliTOFcalib::ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun)
867 //Read miscalibration parameters from the CDB
868 AliCDBManager *man = AliCDBManager::Instance();
872 const Char_t *sel1 = "SimHisto" ;
874 sprintf(out,"%s/%s",sel,sel1);
875 AliCDBEntry *entry = man->Get(out,nrun);
877 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
880 if(!entry->GetObject()){
881 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
884 TH1F *histo =(TH1F*)entry->GetObject();
888 //_____________________________________________________________________________
889 void AliTOFcalib::WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){
890 //Write reconstruction parameters to the CDB
892 AliCDBManager *man = AliCDBManager::Instance();
893 AliCDBMetaData *md = new AliCDBMetaData();
894 md->SetResponsible("Silvia Arcelli");
895 const Char_t *sel1 = "RecoParam" ;
897 sprintf(out,"%s/%s",sel,sel1);
898 AliCDBId id(out,minrun,maxrun);
899 man->Put(param,id,md);
902 //_____________________________________________________________________________
903 AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(const Char_t *sel, Int_t nrun)
905 //Read reconstruction parameters from the CDB
906 AliCDBManager *man = AliCDBManager::Instance();
907 const Char_t *sel1 = "RecoParam" ;
909 sprintf(out,"%s/%s",sel,sel1);
910 AliCDBEntry *entry = man->Get(out,nrun);
912 AliFatal("Exiting, no CDB object (RecoParam) found!!!");
915 if(!entry->GetObject()){
916 AliFatal("Exiting, no CDB object (RecoParam) found!!!");
920 AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject();
923 //-----------------------------------------------------------------------------
924 // Calibration methods
925 //-----------------------------------------------------------------------------
926 void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){
928 // creating the chain with the trees for calibration
929 // collecting them from reference data
930 // from minrun to maxrun
932 Float_t p[CHENTRIESSMALL];
934 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
935 fTree->Branch("nentries",&nentries,"nentries/I");
936 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
937 AliCDBManager *man = AliCDBManager::Instance();
938 AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT/OCDB");
939 for (Int_t irun = minrun;irun<=maxrun;irun++){
940 AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun);
942 AliInfo(Form("No entry found for run %i",irun));
945 TTree *tree = new TTree();
946 tree = (TTree*)entry->GetObject();
947 tree->SetBranchAddress("nentries",&nentries);
948 tree->SetBranchAddress("TOFentries",p);
949 fTree->CopyEntries(tree);
954 AliInfo(Form("Number of runs being analyzed %i",fNruns));
956 //-----------------------------------------------------------------------------
957 void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
959 // creating the chain with the trees for calibration
960 // collecting them from the Grid
961 // from minrun to maxrun
963 Float_t p[CHENTRIESSMALL];
965 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
966 fTree->SetDirectory(0);
967 fTree->Branch("nentries",&nentries,"nentries/I");
968 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
969 AliInfo("connected to alien");
970 TGrid::Connect("alien://");
972 Char_t filename[100];
973 for (Int_t irun = minrun;irun<=maxrun;irun++){
974 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
975 TFile *filegrid = TFile::Open(filename,"READ");
976 TTree *tree = (TTree*)filegrid->Get("T");
977 tree->SetBranchAddress("nentries",&nentries);
978 tree->SetBranchAddress("TOFentries",p);
979 fTree->CopyEntries(tree);
984 AliInfo(Form("Number of runs being analyzed %i",fNruns));
986 //-----------------------------------------------------------------------------
987 void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){
989 // creating the tree with the trees for calibration
990 // collecting them from reference data (from file)
991 // from minrun to maxrun
993 Float_t p[CHENTRIESSMALL];
995 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
996 fTree->SetDirectory(0);
997 fTree->Branch("nentries",&nentries,"nentries/I");
998 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
999 Char_t filename[100];
1000 for (Int_t irun = minrun;irun<=maxrun;irun++){
1001 sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun);
1002 TFile *file = new TFile(filename,"READ");
1003 TTree *tree = (TTree*)file->Get("T");
1004 tree->SetBranchAddress("nentries",&nentries);
1005 tree->SetBranchAddress("TOFentries",p);
1006 fTree->CopyEntries(tree);
1013 AliInfo(Form("Number of runs being analyzed %i",fNruns));
1015 //-----------------------------------------------------------------------------
1016 void AliTOFcalib::CreateChainFromGrid(Int_t minrun, Int_t maxrun){
1018 // creating the chain with the trees for calibration
1019 // collecting them from the Grid
1020 // from minrun to maxrun
1022 fChain = new TChain("T");
1023 AliInfo("connected to alien");
1024 TGrid::Connect("alien://");
1026 Char_t filename[100];
1027 for (Int_t irun = minrun;irun<=maxrun;irun++){
1028 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
1029 fChain->Add(filename);
1033 AliInfo(Form("Number of runs being analyzed %i",fNruns));
1035 //-----------------------------------------------------------------------------
1036 Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){
1038 // calibrating summing more than one channels
1039 // computing calibration parameters
1041 // 0 -> everything was ok
1042 // 1 -> no tree for calibration found
1043 // 2 -> not enough statistics to perform calibration
1044 // 3 -> problems with arrays
1046 TH1::AddDirectory(0);
1048 AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ;
1049 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1050 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1052 Float_t p[CHENTRIESSMALL];
1054 //fTree->SetBranchAddress("nentries",&nentries);
1055 //fTree->SetBranchAddress("TOFentries",p);
1056 fChain->SetBranchAddress("nentries",&nentries);
1057 fChain->SetBranchAddress("TOFentries",p);
1059 Float_t ntracksTotalmean =0;
1060 for (Int_t i=ichmin; i<ichmax; i++){
1062 for (Int_t irun=0;irun<fNruns;irun++){
1063 ientry = i+irun*fNChannels;
1064 //fTree->GetEntry(ientry);
1065 fChain->GetEntry(ientry);
1066 Int_t ntracksRun=nentries/3;
1067 ntracksTotalmean+=ntracksRun;
1071 if (ntracksTotalmean < MEANENTRIES) {
1072 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1076 //filling ToT and Time arrays
1078 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1079 Float_t minToT = 0; // ns
1080 Float_t maxToT = 4.88; // ns
1082 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1083 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1084 Int_t ntracksTotal = 0;
1085 Int_t ntracksRun = 0;
1086 Double_t binsProfile[101]; // sized larger than necessary, the correct
1087 // dim being set in the booking of the profile
1088 Int_t nusefulbins=0;
1090 for (Int_t i = ichmin;i<ichmax;i++){
1092 for (Int_t irun=0;irun<fNruns;irun++){
1093 ientry = i+irun*fNChannels;
1094 //fTree->GetEntry(ientry);
1095 fChain->GetEntry(ientry);
1096 ntracksTotal+=nentries/3;
1097 ntracksRun=nentries/3;
1098 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun));
1099 for (Int_t j=0;j<ntracksRun;j++){
1100 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1101 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1102 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1103 Float_t tot = p[idxexToT];
1104 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1105 meantime+=p[idxexTime]-p[idxexExTime];
1110 nusefulbins = FindBins(hToT,&binsProfile[0]);
1111 meantime/=ntracksTotal;
1112 AliDebug(2, Form("meantime = %f",meantime));
1114 for (Int_t j=1;j<=nusefulbins;j++) {
1115 AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j]));
1118 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1119 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1121 for (Int_t irun=0;irun<fNruns;irun++){
1123 for (Int_t i=ichmin; i<ichmax; i++){
1124 ientry = i+irun*fNChannels;
1125 //fTree->GetEntry(ientry);
1126 fChain->GetEntry(ientry);
1127 ntracksRun=nentries/3;
1128 for (Int_t j=0;j<ntracksRun;j++){
1129 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1130 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1131 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1132 Float_t tot = p[idxexToT];
1133 Float_t time = p[idxexTime]-p[idxexExTime];
1134 AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1135 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1136 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1141 hSlewingProf->Fit("pol5",optionFit,"",0,4);
1142 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1144 for(Int_t kk=0;kk<6;kk++){
1145 par[kk]=calibfunc->GetParameter(kk);
1146 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1149 if(strstr(optionSave,"save")){
1150 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1152 TString profName=Form("Profile%06i_%06i",ichmin,ichmax);
1153 TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax);
1154 TString totName=Form("Tot%06i_%06i",ichmin,ichmax);
1155 TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax);
1156 hSlewingProf->Write(profName);
1157 htimetot->Write(timeTotName);
1158 hToT->Write(totName);
1159 hdeltaTime->Write(deltaName);
1167 delete hSlewingProf;
1174 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin);
1175 calChannel->SetSlewPar(par);
1176 WriteParOfflineOnCDB("TOF/Calib","valid");
1179 //----------------------------------------------------------------------------
1180 Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){
1182 // computing calibration parameters for channel i
1184 // 0 -> everything was ok
1185 // 1 -> no tree for calibration found
1186 // 2 -> not enough statistics to perform calibration
1187 // 3 -> problems with arrays
1189 TH1::AddDirectory(0);
1191 AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ;
1192 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1193 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1195 Float_t p[MAXCHENTRIESSMALL];
1197 //fTree->SetBranchAddress("nentries",&nentries);
1198 //fTree->SetBranchAddress("TOFentries",p);
1199 fChain->SetBranchAddress("nentries",&nentries);
1200 fChain->SetBranchAddress("TOFentries",p);
1202 Float_t ntracksTotal =0;
1203 for (Int_t irun=0;irun<fNruns;irun++){
1205 ientry = i+irun*fNChannels;
1206 //fTree->GetEntry(ientry);
1207 fChain->GetEntry(ientry);
1208 ntracksTotal+=nentries/3;
1211 if (ntracksTotal < MEANENTRIES) {
1212 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
1216 //filling ToT and Time arrays
1218 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1219 Float_t minToT = 0; // ns
1220 Float_t maxToT = 4.88; // ns
1222 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1223 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1224 Int_t ntracksRun = 0;
1225 Double_t binsProfile[101]; // sized larger than necessary, the correct
1226 // dim being set in the booking of the profile
1227 Int_t nusefulbins=0;
1229 for (Int_t irun=0;irun<fNruns;irun++){
1231 ientry = i+irun*fNChannels;
1232 //fTree->GetEntry(ientry);
1233 fChain->GetEntry(ientry);
1234 ntracksRun=nentries/3;
1235 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun));
1236 for (Int_t j=0;j<ntracksRun;j++){
1237 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1238 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1239 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1240 Float_t tot = p[idxexToT];
1241 meantime+=p[idxexTime]-p[idxexExTime];
1242 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1247 nusefulbins = FindBins(hToT,&binsProfile[0]);
1248 meantime/=ntracksTotal;
1249 AliDebug(2,Form("meantime = %f",meantime));
1251 for (Int_t j=1;j<=nusefulbins;j++) {
1252 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
1255 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1256 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1257 for (Int_t irun=0;irun<fNruns;irun++){
1259 ientry = i+irun*fNChannels;
1260 //fTree->GetEntry(ientry);
1261 fChain->GetEntry(ientry);
1262 ntracksRun=nentries/3;
1263 for (Int_t j=0;j<ntracksRun;j++){
1264 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1265 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1266 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1267 Float_t tot = p[idxexToT];
1268 Float_t time = p[idxexTime]-p[idxexExTime];
1269 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1270 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1271 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1275 hSlewingProf->Fit("pol5",optionFit,"",0,4);
1276 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1278 for(Int_t kk=0;kk<6;kk++){
1279 par[kk]=calibfunc->GetParameter(kk);
1280 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1284 if(strstr(optionSave,"save")){
1285 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1287 TString profName=Form("Profile%06i",i);
1288 TString timeTotName=Form("TimeTot%06i",i);
1289 TString totName=Form("Tot%06i",i);
1290 TString deltaName=Form("Delta%06i",i);
1291 hSlewingProf->Write(profName);
1292 htimetot->Write(timeTotName);
1293 hToT->Write(totName);
1294 hdeltaTime->Write(deltaName);
1302 delete hSlewingProf;
1309 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
1310 calChannel->SetSlewPar(par);
1311 WriteParOfflineOnCDB("TOF/Calib","valid");
1314 //----------------------------------------------------------------------------
1315 Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){
1317 // calibrating an array of channels
1318 // computing calibration parameters
1320 // 0 -> everything was ok
1321 // 1 -> no tree for calibration found
1322 // 2 -> not enough statistics to perform calibration
1323 // 3 -> problems with arrays
1325 TH1::AddDirectory(0);
1327 AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ;
1328 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1329 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1330 for (Int_t ich=0; ich<nch; ich++){
1332 AliInfo(Form("Calibrating channel = %i",i )) ;
1334 Float_t p[MAXCHENTRIESSMALL];
1336 //fTree->SetBranchAddress("nentries",&nentries);
1337 //fTree->SetBranchAddress("TOFentries",p);
1338 fChain->SetBranchAddress("nentries",&nentries);
1339 fChain->SetBranchAddress("TOFentries",p);
1341 Float_t ntracksTotalmean =0;
1342 for (Int_t ich=0; ich<nch; ich++){
1345 for (Int_t irun=0;irun<fNruns;irun++){
1346 ientry = i+irun*fNChannels;
1347 //fTree->GetEntry(ientry);
1348 fChain->GetEntry(ientry);
1349 ntracksTotalmean+=nentries/3;
1353 ntracksTotalmean/=nch;
1354 if (ntracksTotalmean < MEANENTRIES) {
1355 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1359 //filling ToT and Time arrays
1361 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1362 Float_t minToT = 0; // ns
1363 Float_t maxToT = 4.88; // ns
1364 TFile * fileProf=0x0;
1365 if(strstr(optionSave,"save")){
1366 fileProf = new TFile("TOFCalibSave.root","recreate");
1368 for (Int_t ich=0; ich<nch; ich++) {
1369 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1370 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1371 Double_t binsProfile[101]; // sized larger than necessary, the correct
1372 // dim being set in the booking of the profile
1373 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1374 Int_t ntracksTotal = 0;
1375 Int_t ntracksRun = 0;
1376 Int_t nusefulbins=0;
1379 for (Int_t irun=0;irun<fNruns;irun++){
1380 i = ch[ich]+irun*fNChannels;
1381 AliDebug(2,Form("Calibrating channel %i",i));
1382 //fTree->GetEntry(i);
1383 fChain->GetEntry(i);
1384 ntracksTotal+=nentries/3;
1386 if (ntracksTotal < MEANENTRIES) {
1387 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal));
1391 for (Int_t irun=0;irun<fNruns;irun++){
1392 i = ch[ich]+irun*fNChannels;
1393 //fTree->GetEntry(i);
1394 fChain->GetEntry(i);
1395 ntracksRun=nentries/3;
1396 for (Int_t j=0;j<ntracksRun;j++){
1397 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1398 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1399 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1400 Float_t tot = p[idxexToT];
1401 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1402 meantime+=p[idxexTime]-p[idxexExTime];
1407 nusefulbins = FindBins(hToT,&binsProfile[0]);
1408 meantime/=ntracksTotal;
1409 for (Int_t j=1;j<=nusefulbins;j++) {
1410 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
1413 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1414 for (Int_t irun=0;irun<fNruns;irun++){
1415 i = ch[ich]+irun*fNChannels;
1416 //fTree->GetEntry(i);
1417 fChain->GetEntry(i);
1418 ntracksRun=nentries/3;
1419 for (Int_t j=0;j<ntracksRun;j++){
1420 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1421 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1422 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1423 Float_t tot = p[idxexToT];
1424 Float_t time = p[idxexTime]-p[idxexExTime];
1425 AliDebug(2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1426 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1427 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1431 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1432 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1434 for(Int_t kk=0;kk<6;kk++){
1435 par[kk]=calibfunc->GetParameter(kk);
1436 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1439 if(strstr(optionSave,"save") && fileProf){
1440 TString profName=Form("Profile%06i",i);
1441 TString timeTotName=Form("TimeTot%06i",i);
1442 TString totName=Form("Tot%06i",i);
1443 TString deltaName=Form("Delta%06i",i);
1445 hSlewingProf->Write(profName);
1446 htimetot->Write(timeTotName);
1447 hToT->Write(totName);
1448 hdeltaTime->Write(deltaName);
1451 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
1452 calChannel->SetSlewPar(par);
1455 delete hSlewingProf;
1463 if(strstr(optionSave,"save") && fileProf){
1468 WriteParOfflineOnCDB("TOF/Calib","valid");
1472 //----------------------------------------------------------------------------
1473 Int_t AliTOFcalib::CalibrateFromProfile(Int_t ich, Option_t *optionSave, Option_t *optionFit){
1475 // computing calibration parameters using the old profiling algo
1477 // 0 -> everything was ok
1478 // 1 -> no tree for calibration found
1479 // 2 -> not enough statistics to perform calibration
1480 // 3 -> problems with arrays
1482 TH1::AddDirectory(0);
1484 AliInfo(Form("*** Calibrating Histograms From Profile %s", GetName())) ;
1485 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1486 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1487 Float_t p[MAXCHENTRIESSMALL];
1489 Int_t ntracksTotal=0;
1490 //fTree->SetBranchAddress("nentries",&nentries);
1491 //fTree->SetBranchAddress("TOFentries",p);
1492 fChain->SetBranchAddress("nentries",&nentries);
1493 fChain->SetBranchAddress("TOFentries",p);
1495 for (Int_t irun=0;irun<fNruns;irun++){
1496 Int_t i = ich+irun*fNChannels;
1497 //fTree->GetEntry(i);
1498 fChain->GetEntry(i);
1499 ntracksTotal+=nentries/3;
1502 if (ntracksTotal < MEANENTRIES) {
1503 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
1507 TH1F * hProf = new TH1F();
1508 hProf = Profile(ich);
1509 hProf->Fit("pol5",optionFit,"",0,4);
1510 TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5");
1512 for(Int_t kk=0;kk<6;kk++){
1513 par[kk]=calibfunc->GetParameter(kk);
1514 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1517 if(strstr(optionSave,"save")){
1518 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1520 TString profName=Form("Profile%06i",ich);
1521 hProf->Write(profName);
1529 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich);
1530 calChannel->SetSlewPar(par);
1531 WriteParOfflineOnCDB("TOF/Calib","valid");
1534 //----------------------------------------------------------------------------
1535 Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){
1537 // calibrating the whole TOF
1538 // computing calibration parameters
1540 // 0 -> everything was ok
1541 // 1 -> no tree for calibration found
1542 // 2 -> not enough statistics to perform calibration
1543 // 3 -> problems with arrays
1545 TH1::AddDirectory(0);
1547 AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ;
1548 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1549 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1551 TFile * fileProf=0x0;
1552 if(strstr(optionSave,"save")){
1553 fileProf = new TFile("TOFCalibSave.root","recreate");
1556 Float_t p[MAXCHENTRIESSMALL];
1558 //fTree->SetBranchAddress("nentries",&nentries);
1559 //fTree->SetBranchAddress("TOFentries",p);
1560 fChain->SetBranchAddress("nentries",&nentries);
1561 fChain->SetBranchAddress("TOFentries",p);
1563 Float_t ntracksTotalmean =0;
1564 for (Int_t ii=0; ii<fNChannels; ii++){
1565 for (Int_t irun=0;irun<fNruns;irun++){
1566 Int_t i = ii+irun*fNChannels;
1567 //fTree->GetEntry(i);
1568 fChain->GetEntry(i);
1569 ntracksTotalmean+=nentries/3;
1573 ntracksTotalmean/=fNChannels;
1574 if (ntracksTotalmean < MEANENTRIES) {
1575 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1579 //filling ToT and Time arrays
1581 Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps
1582 Float_t minToT = 0; // ns
1583 Float_t maxToT = 4.88;// ns
1584 for (Int_t ii=0; ii<fNChannels; ii++) {
1585 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1586 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1587 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1588 if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii));
1590 Int_t nusefulbins=0;
1591 Double_t binsProfile[101]; // sized larger than necessary, the correct
1592 // dim being set in the booking of the profile
1593 Int_t ntracksRun = 0;
1594 Int_t ntracksTotal = 0;
1595 for (Int_t irun=0;irun<fNruns;irun++){
1596 Int_t i = ii+irun*fNChannels;
1597 //fTree->GetEntry(i);
1598 fChain->GetEntry(i);
1599 ntracksTotal+=nentries/3;
1601 if (ntracksTotal < MEANENTRIES) {
1602 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal));
1606 for (Int_t irun=0;irun<fNruns;irun++){
1607 Int_t i = ii+irun*fNChannels;
1608 //fTree->GetEntry(i);
1609 fChain->GetEntry(i);
1610 ntracksRun=nentries/3;
1611 for (Int_t j=0;j<ntracksRun;j++){
1612 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1613 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1614 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1615 Float_t tot = p[idxexToT];
1616 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1617 meantime+=p[idxexTime]-p[idxexExTime];
1621 nusefulbins = FindBins(hToT,&binsProfile[0]);
1622 meantime/=ntracksTotal;
1623 for (Int_t j=0;j<nusefulbins;j++) {
1624 AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j]));
1626 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1627 for (Int_t irun=0;irun<fNruns;irun++){
1628 Int_t i = ii+irun*fNChannels;
1629 //fTree->GetEntry(i);
1630 fChain->GetEntry(i);
1631 ntracksRun=nentries/3;
1632 for (Int_t j=0;j<ntracksRun;j++){
1633 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1634 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1635 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1636 Float_t tot = p[idxexToT];
1637 Float_t time = p[idxexTime]-p[idxexExTime];
1638 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1639 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1640 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1643 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1644 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1646 for(Int_t kk=0;kk<6;kk++){
1647 par[kk]=calibfunc->GetParameter(kk);
1648 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1651 if(strstr(optionSave,"save") && fileProf){
1652 TString profName=Form("Profile%06i",ii);
1653 TString timeTotName=Form("TimeTot%06i",ii);
1654 TString totName=Form("Tot%06i",ii);
1655 TString deltaName=Form("Delta%06i",ii);
1657 hSlewingProf->Write(profName);
1658 htimetot->Write(timeTotName);
1659 hToT->Write(totName);
1660 hdeltaTime->Write(deltaName);
1662 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii);
1663 calChannel->SetSlewPar(par);
1667 delete hSlewingProf;
1675 if(strstr(optionSave,"save")){
1680 WriteParOfflineOnCDB("TOF/Calib","valid");
1684 //-----------------------------------------------------------------------
1685 TH1F* AliTOFcalib::Profile(Int_t ich)
1689 Float_t p[MAXCHENTRIESSMALL];
1691 //fTree->SetBranchAddress("nentries",&nentries);
1692 //fTree->SetBranchAddress("TOFentries",p);
1693 fChain->SetBranchAddress("nentries",&nentries);
1694 fChain->SetBranchAddress("TOFentries",p);
1696 //Prepare histograms for Slewing Correction
1697 const Int_t knbinToT = 100;
1698 Int_t nbinTime = 200;
1699 Float_t minTime = -5.5; //ns
1700 Float_t maxTime = 5.5; //ns
1701 Float_t minToT = 0; //ns
1702 Float_t maxToT = 5.; //ns
1703 Float_t deltaToT = (maxToT-minToT)/knbinToT;
1704 Double_t mTime[knbinToT+1],mToT[knbinToT+1],meanTime[knbinToT+1], meanTime2[knbinToT+1],vToT[knbinToT+1], vToT2[knbinToT+1],meanToT[knbinToT+1],meanToT2[knbinToT+1],vTime[knbinToT+1],vTime2[knbinToT+1],xlow[knbinToT+1],sigmaTime[knbinToT+1];
1705 Int_t n[knbinToT+1], nentrx[knbinToT+1];
1706 Double_t sigmaToT[knbinToT+1];
1707 for (Int_t i = 0; i < knbinToT+1 ; i++){
1725 TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
1726 Int_t ntracksRun = 0;
1727 TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT);
1728 for (Int_t irun=0;irun<fNruns;irun++){
1729 Int_t i = ich+irun*fNChannels;
1730 //fTree->GetEntry(i);
1731 fChain->GetEntry(i);
1732 ntracksRun=nentries/3;
1733 for (Int_t j=0;j<ntracksRun;j++){
1734 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1735 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1736 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1737 Float_t tot = p[idxexToT];
1738 Float_t time = p[idxexTime]-p[idxexExTime];
1739 Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1;
1740 if ((tot != 0) && ( time!= 0)){
1742 vTime2[nx]+=time*time;
1746 hSlewing->Fill(tot,time);
1750 Int_t nbinsToT=hSlewing->GetNbinsX();
1751 if (nbinsToT != knbinToT) {
1752 AliError("Profile :: incompatible numbers of bins");
1757 for (Int_t i=1;i<=nbinsToT;i++){
1759 n[usefulBins]+=nentrx[i];
1760 if (n[usefulBins]==0 && i == nbinsToT) {
1763 meanTime[usefulBins]+=vTime[i];
1764 meanTime2[usefulBins]+=vTime2[i];
1765 meanToT[usefulBins]+=vToT[i];
1766 meanToT2[usefulBins]+=vToT2[i];
1767 if (n[usefulBins]<10 && i!=nbinsToT) continue;
1768 mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
1769 mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
1770 sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1771 *(meanTime2[usefulBins]-meanTime[usefulBins]
1772 *meanTime[usefulBins]/n[usefulBins]));
1773 if ((1./n[usefulBins]/n[usefulBins]
1774 *(meanToT2[usefulBins]-meanToT[usefulBins]
1775 *meanToT[usefulBins]/n[usefulBins]))< 0) {
1776 AliError(" too small radical" );
1777 sigmaToT[usefulBins]=0;
1780 sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1781 *(meanToT2[usefulBins]-meanToT[usefulBins]
1782 *meanToT[usefulBins]/n[usefulBins]));
1787 for (Int_t i=0;i<usefulBins;i++){
1788 Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
1789 histo->Fill(mToT[i],mTime[i]);
1790 histo->SetBinError(binN,sigmaTime[i]);
1797 //----------------------------------------------------------------------------
1798 Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{
1800 // to determine the bins for ToT histo
1804 Int_t nbin = h->GetNbinsX();
1805 Int_t nentries = (Int_t)h->GetEntries();
1806 Float_t max = h->GetBinLowEdge(nbin);
1807 Int_t nusefulbins=0;
1809 // setting maxvalue of entries per bin
1810 if (nentries <= 60) maxcont = 2;
1811 else if (nentries <= 100) maxcont = 5;
1812 else if (nentries <= 500) maxcont = 10;
1814 for (Int_t j=1;j<=nbin;j++) {
1815 cont += (Int_t)h->GetBinContent(j);
1819 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1828 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1829 binsProfile[nusefulbins]=max;
1832 binsProfile[nusefulbins]=h->GetBinLowEdge(startBin);
1840 //----------------------------------------------------------------------------
1843 AliTOFcalib::CreateDeltaBCOffset()
1846 * create deltaBC offset
1849 if (fDeltaBCOffset) {
1850 AliWarning("DeltaBCOffset object already defined, cannot create a new one");
1853 fDeltaBCOffset = new AliTOFDeltaBCOffset();
1856 //----------------------------------------------------------------------------
1859 AliTOFcalib::CreateCTPLatency()
1862 * create CTP latency
1866 AliWarning("CTPLatency object already defined, cannot create a new one");
1869 fCTPLatency = new AliTOFCTPLatency();
1872 //----------------------------------------------------------------------------
1875 AliTOFcalib::CreateT0Fill()
1882 AliWarning("T0Fill object already defined, cannot create a new one");
1885 fT0Fill = new AliTOFT0Fill();
1888 //----------------------------------------------------------------------------
1891 AliTOFcalib::CreateRunParams()
1898 AliWarning("RunParams object already defined, cannot create a new one");
1901 fRunParams = new AliTOFRunParams();
1904 //----------------------------------------------------------------------------
1907 AliTOFcalib::WriteDeltaBCOffsetOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1910 * deltaBC offset on CDB
1913 if (!fDeltaBCOffset) return;
1914 AliCDBId id(Form("%s/DeltaBCOffset", sel), minrun, maxrun);
1915 AliCDBMetaData *md = new AliCDBMetaData();
1916 md->SetResponsible("Roberto Preghenella");
1917 AliCDBManager *man = AliCDBManager::Instance();
1918 man->Put(fDeltaBCOffset, id, md);
1919 AliDebug(2,Form("DeltaBCOffset written on CDB with run range [%i, %i] ",minrun ,maxrun));
1923 //----------------------------------------------------------------------------
1926 AliTOFcalib::WriteCTPLatencyOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1929 * write CTP latency on CDB
1932 if (!fCTPLatency) return;
1933 AliCDBId id(Form("%s/CTPLatency", sel), minrun, maxrun);
1934 AliCDBMetaData *md = new AliCDBMetaData();
1935 md->SetResponsible("Roberto Preghenella");
1936 AliCDBManager *man = AliCDBManager::Instance();
1937 man->Put(fCTPLatency, id, md);
1938 AliDebug(2,Form("CTPLatency written on CDB with run range [%i, %i] ",minrun ,maxrun));
1942 //----------------------------------------------------------------------------
1945 AliTOFcalib::WriteT0FillOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1948 * write event-time on CDB
1951 if (!fT0Fill) return;
1952 AliCDBId id(Form("%s/T0Fill", sel), minrun, maxrun);
1953 AliCDBMetaData *md = new AliCDBMetaData();
1954 md->SetResponsible("Roberto Preghenella");
1955 AliCDBManager *man = AliCDBManager::Instance();
1956 man->Put(fT0Fill, id, md);
1957 AliDebug(2,Form("T0Fill written on CDB with run range [%i, %i] ",minrun ,maxrun));
1961 //----------------------------------------------------------------------------
1964 AliTOFcalib::WriteRunParamsOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1967 * write run params on CDB
1970 if (!fRunParams) return;
1971 AliCDBId id(Form("%s/RunParams", sel), minrun, maxrun);
1972 AliCDBMetaData *md = new AliCDBMetaData();
1973 md->SetResponsible("Roberto Preghenella");
1974 AliCDBManager *man = AliCDBManager::Instance();
1975 man->Put(fRunParams, id, md);
1976 AliDebug(2,Form("RunParams written on CDB with run range [%i, %i] ",minrun ,maxrun));
1980 //----------------------------------------------------------------------------
1983 AliTOFcalib::ReadDeltaBCOffsetFromCDB(const Char_t *sel , Int_t nrun)
1986 * read deltaBC offset from CDB
1989 AliCDBManager *man = AliCDBManager::Instance();
1990 AliCDBEntry *entry = man->Get(Form("%s/DeltaBCOffset", sel),nrun);
1992 AliFatal("No DeltaBCOffset entry found in CDB");
1995 fDeltaBCOffset =(AliTOFDeltaBCOffset *)entry->GetObject();
1996 if(!fDeltaBCOffset){
1997 AliFatal("No DeltaBCOffset object found in CDB entry");
2003 //----------------------------------------------------------------------------
2006 AliTOFcalib::ReadCTPLatencyFromCDB(const Char_t *sel , Int_t nrun)
2009 * read CTP latency from CDB
2012 AliCDBManager *man = AliCDBManager::Instance();
2013 AliCDBEntry *entry = man->Get(Form("%s/CTPLatency", sel),nrun);
2015 AliFatal("No CTPLatency entry found in CDB");
2018 fCTPLatency =(AliTOFCTPLatency *)entry->GetObject();
2020 AliFatal("No CTPLatency object found in CDB entry");
2026 //----------------------------------------------------------------------------
2029 AliTOFcalib::ReadT0FillFromCDB(const Char_t *sel , Int_t nrun)
2032 * read event-time from CDB
2035 AliCDBManager *man = AliCDBManager::Instance();
2036 AliCDBEntry *entry = man->Get(Form("%s/T0Fill", sel),nrun);
2038 AliFatal("No T0Fill entry found in CDB");
2041 fT0Fill =(AliTOFT0Fill *)entry->GetObject();
2043 AliFatal("No T0Fill object found in CDB entry");
2049 //----------------------------------------------------------------------------
2052 AliTOFcalib::ReadRunParamsFromCDB(const Char_t *sel , Int_t nrun)
2055 * read run params from CDB
2058 AliCDBManager *man = AliCDBManager::Instance();
2059 AliCDBEntry *entry = man->Get(Form("%s/RunParams", sel),nrun);
2061 AliFatal("No RunParams entry found in CDB");
2064 fRunParams =(AliTOFRunParams *)entry->GetObject();
2066 AliFatal("No RunParams object found in CDB entry");