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"
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),
152 //TOF Calibration Class ctor
153 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
155 //____________________________________________________________________________
157 AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
159 fNChannels(calib.fNChannels),
161 fTOFCalOnlinePulser(0x0),
162 fTOFCalOnlineNoise(0x0),
163 fTOFCalOnlineHW(0x0),
166 fStatus(calib.fStatus),
167 fTOFSimToT(calib.fTOFSimToT),
168 fkValidity(calib.fkValidity),
170 fChain(calib.fChain),
171 fNruns(calib.fNruns),
172 fFirstRun(calib.fFirstRun),
173 fLastRun(calib.fLastRun),
174 fConfigMap(calib.fConfigMap),
175 fDeltaBCOffset(NULL),
179 //TOF Calibration Class copy ctor
180 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
181 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
182 AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray);
183 AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray);
184 AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray);
185 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
186 fTOFCalOnline->AddAt(calChOnline,iarray);
187 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
188 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
189 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
190 fTOFCalOffline->AddAt(calChOffline,iarray);
193 if (calib.fDeltaBCOffset) fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset);
194 if (calib.fCTPLatency) fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency);
195 if (calib.fT0Fill) fT0Fill = new AliTOFT0Fill(*calib.fT0Fill);
198 //____________________________________________________________________________
200 AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
202 //TOF Calibration Class assignment operator
207 TTask::operator=(calib);
208 fNChannels = calib.fNChannels;
210 fStatus = calib.fStatus;
211 fTOFSimToT = calib.fTOFSimToT;
212 fkValidity = calib.fkValidity;
214 fChain = calib.fChain;
215 fNruns = calib.fNruns;
216 fFirstRun = calib.fFirstRun;
217 fLastRun = calib.fLastRun;
218 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
219 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
220 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
221 AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray);
222 AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray);
223 AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray);
224 fTOFCalOnline->AddAt(calChOnline,iarray);
225 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
226 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
227 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
228 fTOFCalOffline->AddAt(calChOffline,iarray);
231 if (calib.fDeltaBCOffset) {
232 if (fDeltaBCOffset) *fDeltaBCOffset = *calib.fDeltaBCOffset;
233 else fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset);
236 if (calib.fCTPLatency) {
237 if (fCTPLatency) *fCTPLatency = *calib.fCTPLatency;
238 else fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency);
242 if (fT0Fill) *fT0Fill = *calib.fT0Fill;
243 else fT0Fill = new AliTOFT0Fill(*calib.fT0Fill);
249 //____________________________________________________________________________
251 AliTOFcalib::~AliTOFcalib()
253 //TOF Calibration Class dtor
254 if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
256 delete fTOFCalOnline;
258 if (fTOFCalOnlinePulser){
259 delete fTOFCalOnlinePulser;
261 if (fTOFCalOnlineNoise){
262 delete fTOFCalOnlineNoise;
264 if (fTOFCalOnlineHW){
265 delete fTOFCalOnlineHW;
268 delete fTOFCalOffline;
279 if (fDeltaBCOffset) delete fDeltaBCOffset;
280 if (fCTPLatency) delete fCTPLatency;
281 if (fT0Fill) delete fT0Fill;
283 if (fTree!=0x0) delete fTree;
284 if (fChain!=0x0) delete fChain;
287 //_____________________________________________________________________________
288 void AliTOFcalib::CreateCalArrays(){
290 // creating arrays for online/offline calibration objs
292 fTOFCalOnline = new TObjArray(fNChannels);
293 fTOFCalOnlinePulser = new TObjArray(fNChannels);
294 fTOFCalOnlineNoise = new TObjArray(fNChannels);
295 fTOFCalOnlineHW = new TObjArray(fNChannels);
296 fTOFCalOffline = new TObjArray(fNChannels);
297 fTOFCalOnline->SetOwner();
298 fTOFCalOnlinePulser->SetOwner();
299 fTOFCalOnlineNoise->SetOwner();
300 fTOFCalOnlineHW->SetOwner();
301 fTOFCalOffline->SetOwner();
302 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
303 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
304 AliTOFChannelOnlineStatus * calChOnlineStPulser = new AliTOFChannelOnlineStatus();
305 AliTOFChannelOnlineStatus * calChOnlineStNoise = new AliTOFChannelOnlineStatus();
306 AliTOFChannelOnlineStatus * calChOnlineStHW = new AliTOFChannelOnlineStatus();
307 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
308 fTOFCalOnline->AddAt(calChOnline,iarray);
309 fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray);
310 fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray);
311 fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray);
312 fTOFCalOffline->AddAt(calChOffline,iarray);
314 fCal = new AliTOFChannelOnlineArray(fNChannels);
315 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
317 //_____________________________________________________________________________
318 void AliTOFcalib::CreateCalObjects(){
320 // creating arrays for online/offline calibration objs
322 fTOFCalOffline = new TObjArray(fNChannels);
323 fTOFCalOffline->SetOwner();
324 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
325 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
326 fTOFCalOffline->AddAt(calChOffline,iarray);
328 fCal = new AliTOFChannelOnlineArray(fNChannels);
329 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
331 //_____________________________________________________________________________
332 void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
334 //Write calibration parameters to the CDB
337 AliCDBManager *man = AliCDBManager::Instance();
338 const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor
340 sprintf(out,"%s/%s",sel,sel1);
341 AliDebug(2,Form("Writing TOF configuration map for online calib on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
342 AliCDBId id(out,fFirstRun,fLastRun);
343 AliCDBMetaData *md = new AliCDBMetaData();
344 md->SetResponsible("Chiara Zampolli");
348 man->Put(fConfigMap,id,md);
351 //_____________________________________________________________________________
353 void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel)
355 //Write calibration parameters to the CDB with infinite validity
356 AliCDBManager *man = AliCDBManager::Instance();
357 const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor
359 sprintf(out,"%s/%s",sel,sel1);
360 AliCDBRunRange runrange(fFirstRun,fLastRun);
361 AliDebug(2,Form("Writing TOF config map for online calib on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
362 AliCDBId id(out,runrange);
363 AliCDBMetaData *md = new AliCDBMetaData();
364 md->SetResponsible("Chiara Zampolli");
368 man->Put(fConfigMap,id,md);
371 //_____________________________________________________________________________
372 void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
374 //Write calibration parameters to the CDB -------> new calib objs!!!!!
377 AliCDBManager *man = AliCDBManager::Instance();
378 const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor
380 sprintf(out,"%s/%s",sel,sel1);
381 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
382 AliCDBId id(out,fFirstRun,fLastRun);
383 AliCDBMetaData *md = new AliCDBMetaData();
384 md->SetResponsible("Chiara Zampolli");
388 man->Put(fCal,id,md);
391 //_____________________________________________________________________________
392 void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
394 //Write calibration parameters to the CDB -------> new calib objs!!!!!
397 AliCDBManager *man = AliCDBManager::Instance();
398 const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor
400 sprintf(out,"%s/%s",sel,sel1);
401 AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
402 AliCDBId id(out,fFirstRun,fLastRun);
403 AliCDBMetaData *md = new AliCDBMetaData();
404 md->SetResponsible("Chiara Zampolli");
408 man->Put(fStatus,id,md);
411 //_____________________________________________________________________________
413 void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel)
415 //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!!
416 AliCDBManager *man = AliCDBManager::Instance();
417 const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor
419 sprintf(out,"%s/%s",sel,sel1);
420 AliCDBRunRange runrange(fFirstRun,fLastRun);
421 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
422 AliCDBId id(out,runrange);
423 AliCDBMetaData *md = new AliCDBMetaData();
424 md->SetResponsible("Chiara Zampolli");
428 man->Put(fCal,id,md);
431 //_____________________________________________________________________________
433 void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel)
435 //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!!
436 AliCDBManager *man = AliCDBManager::Instance();
437 const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor
439 sprintf(out,"%s/%s",sel,sel1);
440 AliCDBRunRange runrange(fFirstRun,fLastRun);
441 AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
442 AliCDBId id(out,runrange);
443 AliCDBMetaData *md = new AliCDBMetaData();
444 md->SetResponsible("Chiara Zampolli");
448 man->Put(fStatus,id,md);
451 //_____________________________________________________________________________
452 void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
454 //Write calibration parameters to the CDB
457 AliCDBManager *man = AliCDBManager::Instance();
458 const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
460 sprintf(out,"%s/%s",sel,sel1);
461 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
462 AliCDBId id(out,fFirstRun,fLastRun);
463 AliCDBMetaData *md = new AliCDBMetaData();
464 md->SetResponsible("Chiara Zampolli");
465 if (!fTOFCalOnline) {
468 man->Put(fTOFCalOnline,id,md);
471 //_____________________________________________________________________________
472 void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
474 //Write calibration parameters from pulser to the CDB
477 AliCDBManager *man = AliCDBManager::Instance();
478 const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor
480 sprintf(out,"%s/%s",sel,sel1);
481 AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
482 AliCDBId id(out,fFirstRun,fLastRun);
483 AliCDBMetaData *md = new AliCDBMetaData();
484 md->SetResponsible("Chiara Zampolli");
485 if (!fTOFCalOnlinePulser) {
488 man->Put(fTOFCalOnlinePulser,id,md);
491 //_____________________________________________________________________________
492 void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
494 //Write calibration parameters from noise to the CDB
497 AliCDBManager *man = AliCDBManager::Instance();
498 const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor
500 sprintf(out,"%s/%s",sel,sel1);
501 AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
502 AliCDBId id(out,fFirstRun,fLastRun);
503 AliCDBMetaData *md = new AliCDBMetaData();
504 md->SetResponsible("Chiara Zampolli");
505 if (!fTOFCalOnlineNoise) {
508 man->Put(fTOFCalOnlineNoise,id,md);
511 //_____________________________________________________________________________
512 void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun)
514 //Write calibration parameters from hardware to the CDB
517 AliCDBManager *man = AliCDBManager::Instance();
518 const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor
520 sprintf(out,"%s/%s",sel,sel1);
521 AliDebug(2,Form("Writing TOF online calib obj from hardware on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
522 AliCDBId id(out,fFirstRun,fLastRun);
523 AliCDBMetaData *md = new AliCDBMetaData();
524 md->SetResponsible("Chiara Zampolli");
525 if (!fTOFCalOnlineHW) {
528 man->Put(fTOFCalOnlineHW,id,md);
531 //_____________________________________________________________________________
533 void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel)
535 //Write calibration parameters to the CDB with infinite validity
536 AliCDBManager *man = AliCDBManager::Instance();
537 const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
539 sprintf(out,"%s/%s",sel,sel1);
540 AliCDBRunRange runrange(fFirstRun,fLastRun);
541 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
542 AliCDBId id(out,runrange);
543 AliCDBMetaData *md = new AliCDBMetaData();
544 md->SetResponsible("Chiara Zampolli");
545 if (!fTOFCalOnline) {
548 man->Put(fTOFCalOnline,id,md);
551 //_____________________________________________________________________________
553 void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel)
555 //Write calibration parameters from pulser to the CDB with infinite validity
556 AliCDBManager *man = AliCDBManager::Instance();
557 const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor
559 sprintf(out,"%s/%s",sel,sel1);
560 AliCDBRunRange runrange(fFirstRun,fLastRun);
561 AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
562 AliCDBId id(out,runrange);
563 AliCDBMetaData *md = new AliCDBMetaData();
564 md->SetResponsible("Chiara Zampolli");
565 if (!fTOFCalOnlinePulser) {
568 man->Put(fTOFCalOnlinePulser,id,md);
571 //_____________________________________________________________________________
573 void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel)
575 //Write calibration parameters from noise to the CDB with infinite validity
576 AliCDBManager *man = AliCDBManager::Instance();
577 const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor
579 sprintf(out,"%s/%s",sel,sel1);
580 AliCDBRunRange runrange(fFirstRun,fLastRun);
581 AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
582 AliCDBId id(out,runrange);
583 AliCDBMetaData *md = new AliCDBMetaData();
584 md->SetResponsible("Chiara Zampolli");
585 if (!fTOFCalOnlineNoise) {
588 man->Put(fTOFCalOnlineNoise,id,md);
591 //_____________________________________________________________________________
593 void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel)
595 //Write calibration parameters from hardware to the CDB with infinite validity
596 AliCDBManager *man = AliCDBManager::Instance();
597 const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor
599 sprintf(out,"%s/%s",sel,sel1);
600 AliCDBRunRange runrange(fFirstRun,fLastRun);
601 AliDebug(2,Form("Writing TOF online calib obj from harware on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
602 AliCDBId id(out,runrange);
603 AliCDBMetaData *md = new AliCDBMetaData();
604 md->SetResponsible("Chiara Zampolli");
605 if (!fTOFCalOnlineHW) {
608 man->Put(fTOFCalOnlineHW,id,md);
611 //_____________________________________________________________________________
613 void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun)
615 //Write calibration parameters to the CDB
618 AliCDBManager *man = AliCDBManager::Instance();
619 const Char_t *sel1 = "ParOffline" ;
621 sprintf(out,"%s/%s",sel,sel1);
622 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
623 AliCDBId id(out,fFirstRun,fLastRun);
624 AliCDBMetaData *md = new AliCDBMetaData();
625 md->SetResponsible("Chiara Zampolli");
626 md->SetComment(validity);
627 man->Put(fTOFCalOffline,id,md);
630 //_____________________________________________________________________________
632 void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity)
634 //Write calibration parameters to the CDB with infinite validity
635 AliCDBManager *man = AliCDBManager::Instance();
636 const Char_t *sel1 = "ParOffline" ;
638 sprintf(out,"%s/%s",sel,sel1);
639 AliCDBRunRange runrange(fFirstRun,fLastRun);
640 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
641 AliCDBId id(out,runrange);
642 AliCDBMetaData *md = new AliCDBMetaData();
643 md->SetResponsible("Chiara Zampolli");
644 md->SetComment(validity);
645 man->Put(fTOFCalOffline,id,md);
648 //_____________________________________________________________________________
650 Bool_t AliTOFcalib::ReadConfigMapFromCDB(const Char_t *sel, Int_t nrun)
652 //Read calibration parameters from the CDB
653 AliCDBManager *man = AliCDBManager::Instance();
654 const Char_t *sel1 = "Config" ;
656 sprintf(out,"%s/%s",sel,sel1);
657 AliCDBEntry *entry = man->Get(out,nrun);
659 AliFatal("Exiting, no CDB object (ConfigMap) found!!!");
662 if(!entry->GetObject()){
663 AliFatal("Exiting, no CDB object (ConfigMap) found!!!");
667 fConfigMap =(TMap*)entry->GetObject();
672 //_____________________________________________________________________________
674 Bool_t AliTOFcalib::ReadParOnlineDelayFromCDB(const Char_t *sel, Int_t nrun)
676 //Read calibration parameters from the CDB -------> new calib objs!!!!!
677 AliCDBManager *man = AliCDBManager::Instance();
678 const Char_t *sel1 = "ParOnlineDelay" ;
680 sprintf(out,"%s/%s",sel,sel1);
681 AliCDBEntry *entry = man->Get(out,nrun);
683 AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!");
686 if(!entry->GetObject()){
687 AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!");
691 fCal =(AliTOFChannelOnlineArray*)entry->GetObject();
696 //_____________________________________________________________________________
698 Bool_t AliTOFcalib::ReadParOnlineStatusFromCDB(const Char_t *sel, Int_t nrun)
700 //Read calibration parameters from the CDB -------> new calib objs!!!!!
701 AliCDBManager *man = AliCDBManager::Instance();
702 const Char_t *sel1 = "Status" ;
704 sprintf(out,"%s/%s",sel,sel1);
705 AliCDBEntry *entry = man->Get(out,nrun);
707 AliFatal("Exiting, no CDB object (Status) found!!!");
710 if(!entry->GetObject()){
711 AliFatal("Exiting, no CDB object (Status) found!!!");
715 fStatus =(AliTOFChannelOnlineStatusArray*)entry->GetObject();
720 //_____________________________________________________________________________
722 Bool_t AliTOFcalib::ReadParOnlineFromCDB(const Char_t *sel, Int_t nrun)
724 //Read calibration parameters from the CDB
725 AliCDBManager *man = AliCDBManager::Instance();
726 const Char_t *sel1 = "ParOnline" ;
728 sprintf(out,"%s/%s",sel,sel1);
729 AliCDBEntry *entry = man->Get(out,nrun);
731 AliFatal("Exiting, no CDB object (ParOnline) found!!!");
734 if(!entry->GetObject()){
735 AliFatal("Exiting, no CDB object (ParOnline) found!!!");
739 fTOFCalOnline =(TObjArray*)entry->GetObject();
744 //_____________________________________________________________________________
746 Bool_t AliTOFcalib::ReadParOnlinePulserFromCDB(const Char_t *sel, Int_t nrun)
748 //Read calibration parameters from pulser from the CDB
749 AliCDBManager *man = AliCDBManager::Instance();
750 const Char_t *sel1 = "Pulser" ;
752 sprintf(out,"%s/%s",sel,sel1);
753 AliCDBEntry *entry = man->Get(out,nrun);
755 AliFatal("Exiting, no CDB object (Pulser) found!!!");
758 if(!entry->GetObject()){
759 AliFatal("Exiting, no CDB object (Pulser) found!!!");
763 fTOFCalOnlinePulser =(TObjArray*)entry->GetObject();
768 //_____________________________________________________________________________
770 Bool_t AliTOFcalib::ReadParOnlineNoiseFromCDB(const Char_t *sel, Int_t nrun)
772 //Read calibration parameters from noise from the CDB
773 AliCDBManager *man = AliCDBManager::Instance();
774 const Char_t *sel1 = "Noise" ;
776 sprintf(out,"%s/%s",sel,sel1);
777 AliCDBEntry *entry = man->Get(out,nrun);
779 AliFatal("Exiting, no CDB object (Noise) found!!!");
782 if(!entry->GetObject()){
783 AliFatal("Exiting, no CDB object (Noise) found!!!");
787 fTOFCalOnlineNoise =(TObjArray*)entry->GetObject();
792 //_____________________________________________________________________________
794 Bool_t AliTOFcalib::ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun)
796 //Read calibration parameters from hardware from the CDB
797 AliCDBManager *man = AliCDBManager::Instance();
798 const Char_t *sel1 = "HW" ;
800 sprintf(out,"%s/%s",sel,sel1);
801 AliCDBEntry *entry = man->Get(out,nrun);
803 AliFatal("Exiting, no CDB object (HW map) found!!!");
806 if(!entry->GetObject()){
807 AliFatal("Exiting, no CDB object (HW map) found!!!");
811 fTOFCalOnlineHW =(TObjArray*)entry->GetObject();
816 //_____________________________________________________________________________
818 Bool_t AliTOFcalib::ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun)
820 //Read calibration parameters from the CDB
821 AliCDBManager *man = AliCDBManager::Instance();
822 const Char_t *sel1 = "ParOffline" ;
824 sprintf(out,"%s/%s",sel,sel1);
825 AliCDBEntry *entry = man->Get(out,nrun);
827 AliFatal("Exiting, no CDB object (ParOffline) found!!!");
830 if(!entry->GetObject()){
831 AliFatal("Exiting, no CDB object (ParOffline) found!!!");
834 AliCDBMetaData * md = entry->GetMetaData();
835 fkValidity = md->GetComment();
836 fTOFCalOffline =(TObjArray*)entry->GetObject();
841 //_____________________________________________________________________________
842 void AliTOFcalib::WriteSimHistoOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo){
843 //Write Sim miscalibration parameters to the CDB
846 AliCDBManager *man = AliCDBManager::Instance();
847 const Char_t *sel1 = "SimHisto" ;
849 sprintf(out,"%s/%s",sel,sel1);
850 AliCDBMetaData *mdhisto = new AliCDBMetaData();
851 mdhisto->SetResponsible("Chiara Zampolli");
852 AliCDBId id(out,minrun,maxrun);
853 man->Put(fTOFSimToT,id,mdhisto);
856 //_____________________________________________________________________________
857 Bool_t AliTOFcalib::ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun)
859 //Read miscalibration parameters from the CDB
860 AliCDBManager *man = AliCDBManager::Instance();
864 const Char_t *sel1 = "SimHisto" ;
866 sprintf(out,"%s/%s",sel,sel1);
867 AliCDBEntry *entry = man->Get(out,nrun);
869 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
872 if(!entry->GetObject()){
873 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
876 TH1F *histo =(TH1F*)entry->GetObject();
880 //_____________________________________________________________________________
881 void AliTOFcalib::WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){
882 //Write reconstruction parameters to the CDB
884 AliCDBManager *man = AliCDBManager::Instance();
885 AliCDBMetaData *md = new AliCDBMetaData();
886 md->SetResponsible("Silvia Arcelli");
887 const Char_t *sel1 = "RecoParam" ;
889 sprintf(out,"%s/%s",sel,sel1);
890 AliCDBId id(out,minrun,maxrun);
891 man->Put(param,id,md);
894 //_____________________________________________________________________________
895 AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(const Char_t *sel, Int_t nrun)
897 //Read reconstruction parameters from the CDB
898 AliCDBManager *man = AliCDBManager::Instance();
899 const Char_t *sel1 = "RecoParam" ;
901 sprintf(out,"%s/%s",sel,sel1);
902 AliCDBEntry *entry = man->Get(out,nrun);
904 AliFatal("Exiting, no CDB object (RecoParam) found!!!");
907 if(!entry->GetObject()){
908 AliFatal("Exiting, no CDB object (RecoParam) found!!!");
912 AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject();
915 //-----------------------------------------------------------------------------
916 // Calibration methods
917 //-----------------------------------------------------------------------------
918 void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){
920 // creating the chain with the trees for calibration
921 // collecting them from reference data
922 // from minrun to maxrun
924 Float_t p[CHENTRIESSMALL];
926 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
927 fTree->Branch("nentries",&nentries,"nentries/I");
928 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
929 AliCDBManager *man = AliCDBManager::Instance();
930 AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT/OCDB");
931 for (Int_t irun = minrun;irun<=maxrun;irun++){
932 AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun);
934 AliInfo(Form("No entry found for run %i",irun));
937 TTree *tree = new TTree();
938 tree = (TTree*)entry->GetObject();
939 tree->SetBranchAddress("nentries",&nentries);
940 tree->SetBranchAddress("TOFentries",p);
941 fTree->CopyEntries(tree);
946 AliInfo(Form("Number of runs being analyzed %i",fNruns));
948 //-----------------------------------------------------------------------------
949 void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
951 // creating the chain with the trees for calibration
952 // collecting them from the Grid
953 // from minrun to maxrun
955 Float_t p[CHENTRIESSMALL];
957 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
958 fTree->SetDirectory(0);
959 fTree->Branch("nentries",&nentries,"nentries/I");
960 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
961 AliInfo("connected to alien");
962 TGrid::Connect("alien://");
964 Char_t filename[100];
965 for (Int_t irun = minrun;irun<=maxrun;irun++){
966 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
967 TFile *filegrid = TFile::Open(filename,"READ");
968 TTree *tree = (TTree*)filegrid->Get("T");
969 tree->SetBranchAddress("nentries",&nentries);
970 tree->SetBranchAddress("TOFentries",p);
971 fTree->CopyEntries(tree);
976 AliInfo(Form("Number of runs being analyzed %i",fNruns));
978 //-----------------------------------------------------------------------------
979 void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){
981 // creating the tree with the trees for calibration
982 // collecting them from reference data (from file)
983 // from minrun to maxrun
985 Float_t p[CHENTRIESSMALL];
987 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
988 fTree->SetDirectory(0);
989 fTree->Branch("nentries",&nentries,"nentries/I");
990 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
991 Char_t filename[100];
992 for (Int_t irun = minrun;irun<=maxrun;irun++){
993 sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun);
994 TFile *file = new TFile(filename,"READ");
995 TTree *tree = (TTree*)file->Get("T");
996 tree->SetBranchAddress("nentries",&nentries);
997 tree->SetBranchAddress("TOFentries",p);
998 fTree->CopyEntries(tree);
1005 AliInfo(Form("Number of runs being analyzed %i",fNruns));
1007 //-----------------------------------------------------------------------------
1008 void AliTOFcalib::CreateChainFromGrid(Int_t minrun, Int_t maxrun){
1010 // creating the chain with the trees for calibration
1011 // collecting them from the Grid
1012 // from minrun to maxrun
1014 fChain = new TChain("T");
1015 AliInfo("connected to alien");
1016 TGrid::Connect("alien://");
1018 Char_t filename[100];
1019 for (Int_t irun = minrun;irun<=maxrun;irun++){
1020 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
1021 fChain->Add(filename);
1025 AliInfo(Form("Number of runs being analyzed %i",fNruns));
1027 //-----------------------------------------------------------------------------
1028 Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){
1030 // calibrating summing more than one channels
1031 // computing calibration parameters
1033 // 0 -> everything was ok
1034 // 1 -> no tree for calibration found
1035 // 2 -> not enough statistics to perform calibration
1036 // 3 -> problems with arrays
1038 TH1::AddDirectory(0);
1040 AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ;
1041 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1042 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1044 Float_t p[CHENTRIESSMALL];
1046 //fTree->SetBranchAddress("nentries",&nentries);
1047 //fTree->SetBranchAddress("TOFentries",p);
1048 fChain->SetBranchAddress("nentries",&nentries);
1049 fChain->SetBranchAddress("TOFentries",p);
1051 Float_t ntracksTotalmean =0;
1052 for (Int_t i=ichmin; i<ichmax; i++){
1054 for (Int_t irun=0;irun<fNruns;irun++){
1055 ientry = i+irun*fNChannels;
1056 //fTree->GetEntry(ientry);
1057 fChain->GetEntry(ientry);
1058 Int_t ntracksRun=nentries/3;
1059 ntracksTotalmean+=ntracksRun;
1063 if (ntracksTotalmean < MEANENTRIES) {
1064 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1068 //filling ToT and Time arrays
1070 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1071 Float_t minToT = 0; // ns
1072 Float_t maxToT = 4.88; // ns
1074 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1075 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1076 Int_t ntracksTotal = 0;
1077 Int_t ntracksRun = 0;
1078 Double_t binsProfile[101]; // sized larger than necessary, the correct
1079 // dim being set in the booking of the profile
1080 Int_t nusefulbins=0;
1082 for (Int_t i = ichmin;i<ichmax;i++){
1084 for (Int_t irun=0;irun<fNruns;irun++){
1085 ientry = i+irun*fNChannels;
1086 //fTree->GetEntry(ientry);
1087 fChain->GetEntry(ientry);
1088 ntracksTotal+=nentries/3;
1089 ntracksRun=nentries/3;
1090 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun));
1091 for (Int_t j=0;j<ntracksRun;j++){
1092 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1093 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1094 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1095 Float_t tot = p[idxexToT];
1096 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1097 meantime+=p[idxexTime]-p[idxexExTime];
1102 nusefulbins = FindBins(hToT,&binsProfile[0]);
1103 meantime/=ntracksTotal;
1104 AliDebug(2, Form("meantime = %f",meantime));
1106 for (Int_t j=1;j<=nusefulbins;j++) {
1107 AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j]));
1110 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1111 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1113 for (Int_t irun=0;irun<fNruns;irun++){
1115 for (Int_t i=ichmin; i<ichmax; i++){
1116 ientry = i+irun*fNChannels;
1117 //fTree->GetEntry(ientry);
1118 fChain->GetEntry(ientry);
1119 ntracksRun=nentries/3;
1120 for (Int_t j=0;j<ntracksRun;j++){
1121 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1122 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1123 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1124 Float_t tot = p[idxexToT];
1125 Float_t time = p[idxexTime]-p[idxexExTime];
1126 AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1127 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1128 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1133 hSlewingProf->Fit("pol5",optionFit,"",0,4);
1134 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1136 for(Int_t kk=0;kk<6;kk++){
1137 par[kk]=calibfunc->GetParameter(kk);
1138 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1141 if(strstr(optionSave,"save")){
1142 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1144 TString profName=Form("Profile%06i_%06i",ichmin,ichmax);
1145 TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax);
1146 TString totName=Form("Tot%06i_%06i",ichmin,ichmax);
1147 TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax);
1148 hSlewingProf->Write(profName);
1149 htimetot->Write(timeTotName);
1150 hToT->Write(totName);
1151 hdeltaTime->Write(deltaName);
1159 delete hSlewingProf;
1166 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin);
1167 calChannel->SetSlewPar(par);
1168 WriteParOfflineOnCDB("TOF/Calib","valid");
1171 //----------------------------------------------------------------------------
1172 Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){
1174 // computing calibration parameters for channel i
1176 // 0 -> everything was ok
1177 // 1 -> no tree for calibration found
1178 // 2 -> not enough statistics to perform calibration
1179 // 3 -> problems with arrays
1181 TH1::AddDirectory(0);
1183 AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ;
1184 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1185 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1187 Float_t p[MAXCHENTRIESSMALL];
1189 //fTree->SetBranchAddress("nentries",&nentries);
1190 //fTree->SetBranchAddress("TOFentries",p);
1191 fChain->SetBranchAddress("nentries",&nentries);
1192 fChain->SetBranchAddress("TOFentries",p);
1194 Float_t ntracksTotal =0;
1195 for (Int_t irun=0;irun<fNruns;irun++){
1197 ientry = i+irun*fNChannels;
1198 //fTree->GetEntry(ientry);
1199 fChain->GetEntry(ientry);
1200 ntracksTotal+=nentries/3;
1203 if (ntracksTotal < MEANENTRIES) {
1204 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
1208 //filling ToT and Time arrays
1210 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1211 Float_t minToT = 0; // ns
1212 Float_t maxToT = 4.88; // ns
1214 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1215 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1216 Int_t ntracksRun = 0;
1217 Double_t binsProfile[101]; // sized larger than necessary, the correct
1218 // dim being set in the booking of the profile
1219 Int_t nusefulbins=0;
1221 for (Int_t irun=0;irun<fNruns;irun++){
1223 ientry = i+irun*fNChannels;
1224 //fTree->GetEntry(ientry);
1225 fChain->GetEntry(ientry);
1226 ntracksRun=nentries/3;
1227 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun));
1228 for (Int_t j=0;j<ntracksRun;j++){
1229 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1230 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1231 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1232 Float_t tot = p[idxexToT];
1233 meantime+=p[idxexTime]-p[idxexExTime];
1234 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1239 nusefulbins = FindBins(hToT,&binsProfile[0]);
1240 meantime/=ntracksTotal;
1241 AliDebug(2,Form("meantime = %f",meantime));
1243 for (Int_t j=1;j<=nusefulbins;j++) {
1244 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
1247 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1248 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1249 for (Int_t irun=0;irun<fNruns;irun++){
1251 ientry = i+irun*fNChannels;
1252 //fTree->GetEntry(ientry);
1253 fChain->GetEntry(ientry);
1254 ntracksRun=nentries/3;
1255 for (Int_t j=0;j<ntracksRun;j++){
1256 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1257 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1258 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1259 Float_t tot = p[idxexToT];
1260 Float_t time = p[idxexTime]-p[idxexExTime];
1261 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1262 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1263 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1267 hSlewingProf->Fit("pol5",optionFit,"",0,4);
1268 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1270 for(Int_t kk=0;kk<6;kk++){
1271 par[kk]=calibfunc->GetParameter(kk);
1272 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1276 if(strstr(optionSave,"save")){
1277 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1279 TString profName=Form("Profile%06i",i);
1280 TString timeTotName=Form("TimeTot%06i",i);
1281 TString totName=Form("Tot%06i",i);
1282 TString deltaName=Form("Delta%06i",i);
1283 hSlewingProf->Write(profName);
1284 htimetot->Write(timeTotName);
1285 hToT->Write(totName);
1286 hdeltaTime->Write(deltaName);
1294 delete hSlewingProf;
1301 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
1302 calChannel->SetSlewPar(par);
1303 WriteParOfflineOnCDB("TOF/Calib","valid");
1306 //----------------------------------------------------------------------------
1307 Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){
1309 // calibrating an array of channels
1310 // computing calibration parameters
1312 // 0 -> everything was ok
1313 // 1 -> no tree for calibration found
1314 // 2 -> not enough statistics to perform calibration
1315 // 3 -> problems with arrays
1317 TH1::AddDirectory(0);
1319 AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ;
1320 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1321 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1322 for (Int_t ich=0; ich<nch; ich++){
1324 AliInfo(Form("Calibrating channel = %i",i )) ;
1326 Float_t p[MAXCHENTRIESSMALL];
1328 //fTree->SetBranchAddress("nentries",&nentries);
1329 //fTree->SetBranchAddress("TOFentries",p);
1330 fChain->SetBranchAddress("nentries",&nentries);
1331 fChain->SetBranchAddress("TOFentries",p);
1333 Float_t ntracksTotalmean =0;
1334 for (Int_t ich=0; ich<nch; ich++){
1337 for (Int_t irun=0;irun<fNruns;irun++){
1338 ientry = i+irun*fNChannels;
1339 //fTree->GetEntry(ientry);
1340 fChain->GetEntry(ientry);
1341 ntracksTotalmean+=nentries/3;
1345 ntracksTotalmean/=nch;
1346 if (ntracksTotalmean < MEANENTRIES) {
1347 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1351 //filling ToT and Time arrays
1353 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
1354 Float_t minToT = 0; // ns
1355 Float_t maxToT = 4.88; // ns
1356 TFile * fileProf=0x0;
1357 if(strstr(optionSave,"save")){
1358 fileProf = new TFile("TOFCalibSave.root","recreate");
1360 for (Int_t ich=0; ich<nch; ich++) {
1361 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1362 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1363 Double_t binsProfile[101]; // sized larger than necessary, the correct
1364 // dim being set in the booking of the profile
1365 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1366 Int_t ntracksTotal = 0;
1367 Int_t ntracksRun = 0;
1368 Int_t nusefulbins=0;
1371 for (Int_t irun=0;irun<fNruns;irun++){
1372 i = ch[ich]+irun*fNChannels;
1373 AliDebug(2,Form("Calibrating channel %i",i));
1374 //fTree->GetEntry(i);
1375 fChain->GetEntry(i);
1376 ntracksTotal+=nentries/3;
1378 if (ntracksTotal < MEANENTRIES) {
1379 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal));
1383 for (Int_t irun=0;irun<fNruns;irun++){
1384 i = ch[ich]+irun*fNChannels;
1385 //fTree->GetEntry(i);
1386 fChain->GetEntry(i);
1387 ntracksRun=nentries/3;
1388 for (Int_t j=0;j<ntracksRun;j++){
1389 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1390 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1391 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1392 Float_t tot = p[idxexToT];
1393 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1394 meantime+=p[idxexTime]-p[idxexExTime];
1399 nusefulbins = FindBins(hToT,&binsProfile[0]);
1400 meantime/=ntracksTotal;
1401 for (Int_t j=1;j<=nusefulbins;j++) {
1402 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
1405 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1406 for (Int_t irun=0;irun<fNruns;irun++){
1407 i = ch[ich]+irun*fNChannels;
1408 //fTree->GetEntry(i);
1409 fChain->GetEntry(i);
1410 ntracksRun=nentries/3;
1411 for (Int_t j=0;j<ntracksRun;j++){
1412 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1413 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1414 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1415 Float_t tot = p[idxexToT];
1416 Float_t time = p[idxexTime]-p[idxexExTime];
1417 AliDebug(2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1418 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1419 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1423 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1424 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1426 for(Int_t kk=0;kk<6;kk++){
1427 par[kk]=calibfunc->GetParameter(kk);
1428 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1431 if(strstr(optionSave,"save") && fileProf){
1432 TString profName=Form("Profile%06i",i);
1433 TString timeTotName=Form("TimeTot%06i",i);
1434 TString totName=Form("Tot%06i",i);
1435 TString deltaName=Form("Delta%06i",i);
1437 hSlewingProf->Write(profName);
1438 htimetot->Write(timeTotName);
1439 hToT->Write(totName);
1440 hdeltaTime->Write(deltaName);
1443 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
1444 calChannel->SetSlewPar(par);
1447 delete hSlewingProf;
1455 if(strstr(optionSave,"save") && fileProf){
1460 WriteParOfflineOnCDB("TOF/Calib","valid");
1464 //----------------------------------------------------------------------------
1465 Int_t AliTOFcalib::CalibrateFromProfile(Int_t ich, Option_t *optionSave, Option_t *optionFit){
1467 // computing calibration parameters using the old profiling algo
1469 // 0 -> everything was ok
1470 // 1 -> no tree for calibration found
1471 // 2 -> not enough statistics to perform calibration
1472 // 3 -> problems with arrays
1474 TH1::AddDirectory(0);
1476 AliInfo(Form("*** Calibrating Histograms From Profile %s", GetName())) ;
1477 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1478 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1479 Float_t p[MAXCHENTRIESSMALL];
1481 Int_t ntracksTotal=0;
1482 //fTree->SetBranchAddress("nentries",&nentries);
1483 //fTree->SetBranchAddress("TOFentries",p);
1484 fChain->SetBranchAddress("nentries",&nentries);
1485 fChain->SetBranchAddress("TOFentries",p);
1487 for (Int_t irun=0;irun<fNruns;irun++){
1488 Int_t i = ich+irun*fNChannels;
1489 //fTree->GetEntry(i);
1490 fChain->GetEntry(i);
1491 ntracksTotal+=nentries/3;
1494 if (ntracksTotal < MEANENTRIES) {
1495 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
1499 TH1F * hProf = new TH1F();
1500 hProf = Profile(ich);
1501 hProf->Fit("pol5",optionFit,"",0,4);
1502 TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5");
1504 for(Int_t kk=0;kk<6;kk++){
1505 par[kk]=calibfunc->GetParameter(kk);
1506 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1509 if(strstr(optionSave,"save")){
1510 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1512 TString profName=Form("Profile%06i",ich);
1513 hProf->Write(profName);
1521 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich);
1522 calChannel->SetSlewPar(par);
1523 WriteParOfflineOnCDB("TOF/Calib","valid");
1526 //----------------------------------------------------------------------------
1527 Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){
1529 // calibrating the whole TOF
1530 // computing calibration parameters
1532 // 0 -> everything was ok
1533 // 1 -> no tree for calibration found
1534 // 2 -> not enough statistics to perform calibration
1535 // 3 -> problems with arrays
1537 TH1::AddDirectory(0);
1539 AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ;
1540 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1541 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1543 TFile * fileProf=0x0;
1544 if(strstr(optionSave,"save")){
1545 fileProf = new TFile("TOFCalibSave.root","recreate");
1548 Float_t p[MAXCHENTRIESSMALL];
1550 //fTree->SetBranchAddress("nentries",&nentries);
1551 //fTree->SetBranchAddress("TOFentries",p);
1552 fChain->SetBranchAddress("nentries",&nentries);
1553 fChain->SetBranchAddress("TOFentries",p);
1555 Float_t ntracksTotalmean =0;
1556 for (Int_t ii=0; ii<fNChannels; ii++){
1557 for (Int_t irun=0;irun<fNruns;irun++){
1558 Int_t i = ii+irun*fNChannels;
1559 //fTree->GetEntry(i);
1560 fChain->GetEntry(i);
1561 ntracksTotalmean+=nentries/3;
1565 ntracksTotalmean/=fNChannels;
1566 if (ntracksTotalmean < MEANENTRIES) {
1567 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1571 //filling ToT and Time arrays
1573 Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps
1574 Float_t minToT = 0; // ns
1575 Float_t maxToT = 4.88;// ns
1576 for (Int_t ii=0; ii<fNChannels; ii++) {
1577 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1578 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1579 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1580 if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii));
1582 Int_t nusefulbins=0;
1583 Double_t binsProfile[101]; // sized larger than necessary, the correct
1584 // dim being set in the booking of the profile
1585 Int_t ntracksRun = 0;
1586 Int_t ntracksTotal = 0;
1587 for (Int_t irun=0;irun<fNruns;irun++){
1588 Int_t i = ii+irun*fNChannels;
1589 //fTree->GetEntry(i);
1590 fChain->GetEntry(i);
1591 ntracksTotal+=nentries/3;
1593 if (ntracksTotal < MEANENTRIES) {
1594 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal));
1598 for (Int_t irun=0;irun<fNruns;irun++){
1599 Int_t i = ii+irun*fNChannels;
1600 //fTree->GetEntry(i);
1601 fChain->GetEntry(i);
1602 ntracksRun=nentries/3;
1603 for (Int_t j=0;j<ntracksRun;j++){
1604 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1605 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1606 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1607 Float_t tot = p[idxexToT];
1608 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1609 meantime+=p[idxexTime]-p[idxexExTime];
1613 nusefulbins = FindBins(hToT,&binsProfile[0]);
1614 meantime/=ntracksTotal;
1615 for (Int_t j=0;j<nusefulbins;j++) {
1616 AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j]));
1618 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1619 for (Int_t irun=0;irun<fNruns;irun++){
1620 Int_t i = ii+irun*fNChannels;
1621 //fTree->GetEntry(i);
1622 fChain->GetEntry(i);
1623 ntracksRun=nentries/3;
1624 for (Int_t j=0;j<ntracksRun;j++){
1625 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1626 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1627 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1628 Float_t tot = p[idxexToT];
1629 Float_t time = p[idxexTime]-p[idxexExTime];
1630 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1631 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1632 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1635 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1636 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1638 for(Int_t kk=0;kk<6;kk++){
1639 par[kk]=calibfunc->GetParameter(kk);
1640 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1643 if(strstr(optionSave,"save") && fileProf){
1644 TString profName=Form("Profile%06i",ii);
1645 TString timeTotName=Form("TimeTot%06i",ii);
1646 TString totName=Form("Tot%06i",ii);
1647 TString deltaName=Form("Delta%06i",ii);
1649 hSlewingProf->Write(profName);
1650 htimetot->Write(timeTotName);
1651 hToT->Write(totName);
1652 hdeltaTime->Write(deltaName);
1654 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii);
1655 calChannel->SetSlewPar(par);
1659 delete hSlewingProf;
1667 if(strstr(optionSave,"save")){
1672 WriteParOfflineOnCDB("TOF/Calib","valid");
1676 //-----------------------------------------------------------------------
1677 TH1F* AliTOFcalib::Profile(Int_t ich)
1681 Float_t p[MAXCHENTRIESSMALL];
1683 //fTree->SetBranchAddress("nentries",&nentries);
1684 //fTree->SetBranchAddress("TOFentries",p);
1685 fChain->SetBranchAddress("nentries",&nentries);
1686 fChain->SetBranchAddress("TOFentries",p);
1688 //Prepare histograms for Slewing Correction
1689 const Int_t knbinToT = 100;
1690 Int_t nbinTime = 200;
1691 Float_t minTime = -5.5; //ns
1692 Float_t maxTime = 5.5; //ns
1693 Float_t minToT = 0; //ns
1694 Float_t maxToT = 5.; //ns
1695 Float_t deltaToT = (maxToT-minToT)/knbinToT;
1696 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];
1697 Int_t n[knbinToT+1], nentrx[knbinToT+1];
1698 Double_t sigmaToT[knbinToT+1];
1699 for (Int_t i = 0; i < knbinToT+1 ; i++){
1717 TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
1718 Int_t ntracksRun = 0;
1719 TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT);
1720 for (Int_t irun=0;irun<fNruns;irun++){
1721 Int_t i = ich+irun*fNChannels;
1722 //fTree->GetEntry(i);
1723 fChain->GetEntry(i);
1724 ntracksRun=nentries/3;
1725 for (Int_t j=0;j<ntracksRun;j++){
1726 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1727 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1728 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1729 Float_t tot = p[idxexToT];
1730 Float_t time = p[idxexTime]-p[idxexExTime];
1731 Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1;
1732 if ((tot != 0) && ( time!= 0)){
1734 vTime2[nx]+=time*time;
1738 hSlewing->Fill(tot,time);
1742 Int_t nbinsToT=hSlewing->GetNbinsX();
1743 if (nbinsToT != knbinToT) {
1744 AliError("Profile :: incompatible numbers of bins");
1749 for (Int_t i=1;i<=nbinsToT;i++){
1751 n[usefulBins]+=nentrx[i];
1752 if (n[usefulBins]==0 && i == nbinsToT) {
1755 meanTime[usefulBins]+=vTime[i];
1756 meanTime2[usefulBins]+=vTime2[i];
1757 meanToT[usefulBins]+=vToT[i];
1758 meanToT2[usefulBins]+=vToT2[i];
1759 if (n[usefulBins]<10 && i!=nbinsToT) continue;
1760 mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
1761 mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
1762 sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1763 *(meanTime2[usefulBins]-meanTime[usefulBins]
1764 *meanTime[usefulBins]/n[usefulBins]));
1765 if ((1./n[usefulBins]/n[usefulBins]
1766 *(meanToT2[usefulBins]-meanToT[usefulBins]
1767 *meanToT[usefulBins]/n[usefulBins]))< 0) {
1768 AliError(" too small radical" );
1769 sigmaToT[usefulBins]=0;
1772 sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1773 *(meanToT2[usefulBins]-meanToT[usefulBins]
1774 *meanToT[usefulBins]/n[usefulBins]));
1779 for (Int_t i=0;i<usefulBins;i++){
1780 Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
1781 histo->Fill(mToT[i],mTime[i]);
1782 histo->SetBinError(binN,sigmaTime[i]);
1789 //----------------------------------------------------------------------------
1790 Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{
1792 // to determine the bins for ToT histo
1796 Int_t nbin = h->GetNbinsX();
1797 Int_t nentries = (Int_t)h->GetEntries();
1798 Float_t max = h->GetBinLowEdge(nbin);
1799 Int_t nusefulbins=0;
1801 // setting maxvalue of entries per bin
1802 if (nentries <= 60) maxcont = 2;
1803 else if (nentries <= 100) maxcont = 5;
1804 else if (nentries <= 500) maxcont = 10;
1806 for (Int_t j=1;j<=nbin;j++) {
1807 cont += (Int_t)h->GetBinContent(j);
1811 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1820 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1821 binsProfile[nusefulbins]=max;
1824 binsProfile[nusefulbins]=h->GetBinLowEdge(startBin);
1832 //----------------------------------------------------------------------------
1835 AliTOFcalib::CreateDeltaBCOffset()
1838 * create deltaBC offset
1841 if (fDeltaBCOffset) {
1842 AliWarning("DeltaBCOffset object already defined, cannot create a new one");
1845 fDeltaBCOffset = new AliTOFDeltaBCOffset();
1848 //----------------------------------------------------------------------------
1851 AliTOFcalib::CreateCTPLatency()
1854 * create CTP latency
1858 AliWarning("CTPLatency object already defined, cannot create a new one");
1861 fCTPLatency = new AliTOFCTPLatency();
1864 //----------------------------------------------------------------------------
1867 AliTOFcalib::CreateT0Fill()
1874 AliWarning("T0Fill object already defined, cannot create a new one");
1877 fT0Fill = new AliTOFT0Fill();
1880 //----------------------------------------------------------------------------
1883 AliTOFcalib::WriteDeltaBCOffsetOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1886 * deltaBC offset on CDB
1889 if (!fDeltaBCOffset) return;
1890 AliCDBId id(Form("%s/DeltaBCOffset", sel), minrun, maxrun);
1891 AliCDBMetaData *md = new AliCDBMetaData();
1892 md->SetResponsible("Roberto Preghenella");
1893 AliCDBManager *man = AliCDBManager::Instance();
1894 man->Put(fDeltaBCOffset, id, md);
1895 AliDebug(2,Form("DeltaBCOffset written on CDB with run range [%i, %i] ",minrun ,maxrun));
1899 //----------------------------------------------------------------------------
1902 AliTOFcalib::WriteCTPLatencyOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1905 * write CTP latency on CDB
1908 if (!fCTPLatency) return;
1909 AliCDBId id(Form("%s/CTPLatency", sel), minrun, maxrun);
1910 AliCDBMetaData *md = new AliCDBMetaData();
1911 md->SetResponsible("Roberto Preghenella");
1912 AliCDBManager *man = AliCDBManager::Instance();
1913 man->Put(fCTPLatency, id, md);
1914 AliDebug(2,Form("CTPLatency written on CDB with run range [%i, %i] ",minrun ,maxrun));
1918 //----------------------------------------------------------------------------
1921 AliTOFcalib::WriteT0FillOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun)
1924 * write event-time on CDB
1927 if (!fT0Fill) return;
1928 AliCDBId id(Form("%s/T0Fill", sel), minrun, maxrun);
1929 AliCDBMetaData *md = new AliCDBMetaData();
1930 md->SetResponsible("Roberto Preghenella");
1931 AliCDBManager *man = AliCDBManager::Instance();
1932 man->Put(fT0Fill, id, md);
1933 AliDebug(2,Form("T0Fill written on CDB with run range [%i, %i] ",minrun ,maxrun));
1937 //----------------------------------------------------------------------------
1940 AliTOFcalib::ReadDeltaBCOffsetFromCDB(const Char_t *sel , Int_t nrun)
1943 * read deltaBC offset from CDB
1946 AliCDBManager *man = AliCDBManager::Instance();
1947 AliCDBEntry *entry = man->Get(Form("%s/DeltaBCOffset", sel),nrun);
1949 AliFatal("No DeltaBCOffset entry found in CDB");
1952 fDeltaBCOffset =(AliTOFDeltaBCOffset *)entry->GetObject();
1953 if(!fDeltaBCOffset){
1954 AliFatal("No DeltaBCOffset object found in CDB entry");
1960 //----------------------------------------------------------------------------
1963 AliTOFcalib::ReadCTPLatencyFromCDB(const Char_t *sel , Int_t nrun)
1966 * read CTP latency from CDB
1969 AliCDBManager *man = AliCDBManager::Instance();
1970 AliCDBEntry *entry = man->Get(Form("%s/CTPLatency", sel),nrun);
1972 AliFatal("No CTPLatency entry found in CDB");
1975 fCTPLatency =(AliTOFCTPLatency *)entry->GetObject();
1977 AliFatal("No CTPLatency object found in CDB entry");
1983 //----------------------------------------------------------------------------
1986 AliTOFcalib::ReadT0FillFromCDB(const Char_t *sel , Int_t nrun)
1989 * read event-time from CDB
1992 AliCDBManager *man = AliCDBManager::Instance();
1993 AliCDBEntry *entry = man->Get(Form("%s/T0Fill", sel),nrun);
1995 AliFatal("No T0Fill entry found in CDB");
1998 fT0Fill =(AliTOFT0Fill *)entry->GetObject();
2000 AliFatal("No T0Fill object found in CDB entry");