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 **************************************************************************/
18 Revision 1.19 2007/10/23 15:27:38 zampolli
19 Rearrangement of Calibration objects for simulation
21 Revision 1.16 2007/10/08 10:13:26 zampolli
22 First Run and Last Run members added, infinite validity of calib obj implemented.
24 Revision 1.15 2007/10/04 13:23:28 zampolli
25 Updates to handle functionalities in TOF online/offline calibration according to the latest schema
27 Revision 1.14 2007/06/06 16:26:30 arcelli
28 remove fall-back call to local CDB storage
30 Revision 1.13 2007/04/20 13:59:40 arcelli
31 make protections agains failed retrieval of the CDB object in a proper way
33 Revision 1.12 2007/03/23 11:31:16 arcelli
34 CDB Entry for TOF Reconstruction Parameters
36 Revision 1.11 2007/02/28 18:08:26 arcelli
37 Add protection against failed retrieval of the CDB cal object
39 Revision 1.10 2006/08/22 13:30:49 arcelli
40 removal of effective c++ warnings (C.Zampolli)
42 Revision 1.9 2006/04/20 22:30:50 hristov
43 Coding conventions (Annalisa)
45 Revision 1.8 2006/04/16 22:29:05 hristov
46 Coding conventions (Annalisa)
48 Revision 1.7 2006/04/16 20:12:46 hristov
49 Removing memory leak in case of cached CDB entries
51 Revision 1.6 2006/04/11 15:28:32 hristov
52 Checks on cache status before deleting calibration objects (A.Colla)
54 Revision 1.5 2006/04/05 08:35:38 hristov
55 Coding conventions (S.Arcelli, C.Zampolli)
57 Revision 1.4 2006/03/31 11:26:46 arcelli
58 changing CDB Ids according to standard convention
60 Revision 1.3 2006/03/28 14:57:02 arcelli
61 updates to handle new V5 geometry & some re-arrangements
63 Revision 1.2 2006/02/13 17:22:26 arcelli
66 Revision 1.1 2006/02/13 16:10:48 arcelli
67 Add classes for TOF Calibration (C.Zampolli)
69 author: Chiara Zampolli, zampolli@bo.infn.it
72 ///////////////////////////////////////////////////////////////////////////////
74 // class for TOF calibration //
76 ///////////////////////////////////////////////////////////////////////////////
90 #include "AliCDBEntry.h"
91 #include "AliCDBRunRange.h"
93 #include "AliCDBManager.h"
94 #include "AliCDBStorage.h"
95 #include "AliCDBMetaData.h"
96 #include "AliESDtrack.h"
100 #include "AliTOFcalib.h"
101 #include "AliTOFChannelOnline.h"
102 #include "AliTOFChannelOffline.h"
103 #include "AliTOFGeometry.h"
104 #include "AliTOFRecoParam.h"
107 extern TStyle *gStyle;
109 ClassImp(AliTOFcalib)
111 //_______________________________________________________________________
112 AliTOFcalib::AliTOFcalib():
113 TTask("AliTOFcalib",""),
123 fLastRun(AliCDBRunRange::Infinity())
125 //TOF Calibration Class ctor
126 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
128 //____________________________________________________________________________
130 AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
131 TTask("AliTOFcalib",""),
132 fNChannels(calib.fNChannels),
135 fTOFSimToT(calib.fTOFSimToT),
136 fkValidity(calib.fkValidity),
138 fChain(calib.fChain),
139 fNruns(calib.fNruns),
140 fFirstRun(calib.fFirstRun),
141 fLastRun(calib.fLastRun)
143 //TOF Calibration Class copy ctor
144 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
145 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
146 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
147 fTOFCalOnline->AddAt(calChOnline,iarray);
148 fTOFCalOffline->AddAt(calChOffline,iarray);
153 //____________________________________________________________________________
155 AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
157 //TOF Calibration Class assignment operator
158 this->fNChannels = calib.fNChannels;
159 this->fTOFSimToT = calib.fTOFSimToT;
160 this->fkValidity = calib.fkValidity;
161 this->fTree = calib.fTree;
162 this->fChain = calib.fChain;
163 this->fNruns = calib.fNruns;
164 this->fFirstRun = calib.fFirstRun;
165 this->fLastRun = calib.fLastRun;
166 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
167 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
168 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
169 this->fTOFCalOnline->AddAt(calChOnline,iarray);
170 this->fTOFCalOffline->AddAt(calChOffline,iarray);
175 //____________________________________________________________________________
177 AliTOFcalib::~AliTOFcalib()
179 //TOF Calibration Class dtor
180 if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
182 delete fTOFCalOnline;
185 delete fTOFCalOffline;
188 if (fTree!=0x0) delete fTree;
189 if (fChain!=0x0) delete fChain;
191 //_____________________________________________________________________________
192 void AliTOFcalib::CreateCalArrays(){
194 // creating arrays for online/offline calibration objs
196 fTOFCalOnline = new TObjArray(fNChannels);
197 fTOFCalOffline = new TObjArray(fNChannels);
198 fTOFCalOnline->SetOwner();
199 fTOFCalOffline->SetOwner();
200 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
201 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
202 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
203 fTOFCalOnline->AddAt(calChOnline,iarray);
204 fTOFCalOffline->AddAt(calChOffline,iarray);
207 //_____________________________________________________________________________
208 void AliTOFcalib::WriteParOnlineOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
210 //Write calibration parameters to the CDB
213 AliCDBManager *man = AliCDBManager::Instance();
214 Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
216 sprintf(out,"%s/%s",sel,sel1);
217 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
218 AliCDBId id(out,fFirstRun,fLastRun);
219 AliCDBMetaData *md = new AliCDBMetaData();
220 md->SetResponsible("Chiara Zampolli");
221 if (!fTOFCalOnline) {
224 man->Put(fTOFCalOnline,id,md);
227 //_____________________________________________________________________________
229 void AliTOFcalib::WriteParOnlineOnCDB(Char_t *sel)
231 //Write calibration parameters to the CDB with infinite validity
232 AliCDBManager *man = AliCDBManager::Instance();
233 Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
235 sprintf(out,"%s/%s",sel,sel1);
236 AliCDBRunRange runrange(fFirstRun,fLastRun);
237 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
238 AliCDBId id(out,runrange);
239 AliCDBMetaData *md = new AliCDBMetaData();
240 md->SetResponsible("Chiara Zampolli");
241 if (!fTOFCalOnline) {
244 man->Put(fTOFCalOnline,id,md);
247 //_____________________________________________________________________________
249 void AliTOFcalib::WriteParOfflineOnCDB(Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun)
251 //Write calibration parameters to the CDB
254 AliCDBManager *man = AliCDBManager::Instance();
255 Char_t *sel1 = "ParOffline" ;
257 sprintf(out,"%s/%s",sel,sel1);
258 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
259 AliCDBId id(out,fFirstRun,fLastRun);
260 AliCDBMetaData *md = new AliCDBMetaData();
261 md->SetResponsible("Chiara Zampolli");
262 md->SetComment(validity);
263 man->Put(fTOFCalOffline,id,md);
266 //_____________________________________________________________________________
268 void AliTOFcalib::WriteParOfflineOnCDB(Char_t *sel, const Char_t *validity)
270 //Write calibration parameters to the CDB with infinite validity
271 AliCDBManager *man = AliCDBManager::Instance();
272 Char_t *sel1 = "ParOffline" ;
274 sprintf(out,"%s/%s",sel,sel1);
275 AliCDBRunRange runrange(fFirstRun,fLastRun);
276 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
277 AliCDBId id(out,runrange);
278 AliCDBMetaData *md = new AliCDBMetaData();
279 md->SetResponsible("Chiara Zampolli");
280 md->SetComment(validity);
281 man->Put(fTOFCalOffline,id,md);
284 //_____________________________________________________________________________
286 Bool_t AliTOFcalib::ReadParOnlineFromCDB(Char_t *sel, Int_t nrun)
288 //Read calibration parameters from the CDB
289 AliCDBManager *man = AliCDBManager::Instance();
290 Char_t *sel1 = "ParOnline" ;
292 sprintf(out,"%s/%s",sel,sel1);
293 if (!man->Get(out,nrun)) {
296 AliCDBEntry *entry = man->Get(out,nrun);
297 if(!entry->GetObject()){
301 fTOFCalOnline =(TObjArray*)entry->GetObject();
306 //_____________________________________________________________________________
308 Bool_t AliTOFcalib::ReadParOfflineFromCDB(Char_t *sel, Int_t nrun)
310 //Read calibration parameters from the CDB
311 AliCDBManager *man = AliCDBManager::Instance();
312 Char_t *sel1 = "ParOffline" ;
314 sprintf(out,"%s/%s",sel,sel1);
315 if (!man->Get(out,nrun)) {
318 AliCDBEntry *entry = man->Get(out,nrun);
319 if(!entry->GetObject()){
322 AliCDBMetaData * md = entry->GetMetaData();
323 fkValidity = md->GetComment();
324 fTOFCalOffline =(TObjArray*)entry->GetObject();
329 //_____________________________________________________________________________
330 void AliTOFcalib::WriteSimHistoOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo){
331 //Write Sim miscalibration parameters to the CDB
334 AliCDBManager *man = AliCDBManager::Instance();
335 Char_t *sel1 = "SimHisto" ;
337 sprintf(out,"%s/%s",sel,sel1);
338 AliCDBMetaData *mdhisto = new AliCDBMetaData();
339 mdhisto->SetResponsible("Chiara Zampolli");
340 AliCDBId id(out,minrun,maxrun);
341 man->Put(fTOFSimToT,id,mdhisto);
344 //_____________________________________________________________________________
345 Bool_t AliTOFcalib::ReadSimHistoFromCDB(Char_t *sel, Int_t nrun)
347 //Read miscalibration parameters from the CDB
348 AliCDBManager *man = AliCDBManager::Instance();
352 Char_t *sel1 = "SimHisto" ;
354 sprintf(out,"%s/%s",sel,sel1);
355 if (!man->Get(out,nrun)) {
356 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
359 AliCDBEntry *entry = man->Get(out,nrun);
360 if(!entry->GetObject()){
361 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
364 TH1F *histo =(TH1F*)entry->GetObject();
367 //_____________________________________________________________________________
368 void AliTOFcalib::WriteRecParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){
369 //Write reconstruction parameters to the CDB
371 AliCDBManager *man = AliCDBManager::Instance();
372 AliCDBMetaData *md = new AliCDBMetaData();
373 md->SetResponsible("Silvia Arcelli");
374 Char_t *sel1 = "RecPar" ;
376 sprintf(out,"%s/%s",sel,sel1);
377 AliCDBId id(out,minrun,maxrun);
378 man->Put(param,id,md);
381 //_____________________________________________________________________________
382 AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(Char_t *sel, Int_t nrun)
384 //Read reconstruction parameters from the CDB
385 AliCDBManager *man = AliCDBManager::Instance();
386 Char_t *sel1 = "RecPar" ;
388 sprintf(out,"%s/%s",sel,sel1);
389 if (!man->Get(out,nrun)) {
390 AliFatal("Exiting, no CDB object (RecPar) found!!!");
393 AliCDBEntry *entry = man->Get(out,nrun);
394 if(!entry->GetObject()){
395 AliFatal("Exiting, no CDB object (RecPar) found!!!");
399 AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject();
402 //-----------------------------------------------------------------------------
403 // Calibration methods
404 //-----------------------------------------------------------------------------
405 void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){
407 // creating the chain with the trees for calibration
408 // collecting them from reference data
409 // from minrun to maxrun
411 Float_t p[CHENTRIESSMALL];
413 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
414 fTree->Branch("nentries",&nentries,"nentries/I");
415 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
416 AliCDBManager *man = AliCDBManager::Instance();
417 AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT");
418 for (Int_t irun = minrun;irun<=maxrun;irun++){
419 AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun);
421 AliInfo(Form("No entry found for run %i",irun));
424 TTree *tree = new TTree();
425 tree = (TTree*)entry->GetObject();
426 tree->SetBranchAddress("nentries",&nentries);
427 tree->SetBranchAddress("TOFentries",p);
428 fTree->CopyEntries(tree);
433 AliInfo(Form("Number of runs being analyzed %i",fNruns));
435 //-----------------------------------------------------------------------------
436 void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
438 // creating the chain with the trees for calibration
439 // collecting them from the Grid
440 // from minrun to maxrun
442 Float_t p[CHENTRIESSMALL];
444 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
445 fTree->SetDirectory(0);
446 fTree->Branch("nentries",&nentries,"nentries/I");
447 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
448 AliInfo("connected to alien");
449 TGrid::Connect("alien://");
451 Char_t filename[100];
452 for (Int_t irun = minrun;irun<=maxrun;irun++){
453 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
454 TFile *filegrid = TFile::Open(filename,"READ");
455 TTree *tree = (TTree*)filegrid->Get("T");
456 tree->SetBranchAddress("nentries",&nentries);
457 tree->SetBranchAddress("TOFentries",p);
458 fTree->CopyEntries(tree);
463 AliInfo(Form("Number of runs being analyzed %i",fNruns));
465 //-----------------------------------------------------------------------------
466 void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){
468 // creating the tree with the trees for calibration
469 // collecting them from reference data (from file)
470 // from minrun to maxrun
472 Float_t p[CHENTRIESSMALL];
474 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
475 fTree->SetDirectory(0);
476 fTree->Branch("nentries",&nentries,"nentries/I");
477 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
478 Char_t filename[100];
479 for (Int_t irun = minrun;irun<=maxrun;irun++){
480 sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun);
481 TFile *file = new TFile(filename,"READ");
482 TTree *tree = (TTree*)file->Get("T");
483 tree->SetBranchAddress("nentries",&nentries);
484 tree->SetBranchAddress("TOFentries",p);
485 fTree->CopyEntries(tree);
492 AliInfo(Form("Number of runs being analyzed %i",fNruns));
494 //-----------------------------------------------------------------------------
495 void AliTOFcalib::CreateChainFromGrid(Int_t minrun, Int_t maxrun){
497 // creating the chain with the trees for calibration
498 // collecting them from the Grid
499 // from minrun to maxrun
501 fChain = new TChain("T");
502 AliInfo("connected to alien");
503 TGrid::Connect("alien://");
505 Char_t filename[100];
506 for (Int_t irun = minrun;irun<=maxrun;irun++){
507 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
508 fChain->Add(filename);
512 AliInfo(Form("Number of runs being analyzed %i",fNruns));
514 //-----------------------------------------------------------------------------
515 Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){
517 // calibrating summing more than one channels
518 // computing calibration parameters
520 // 0 -> everything was ok
521 // 1 -> no tree for calibration found
522 // 2 -> not enough statistics to perform calibration
523 // 3 -> problems with arrays
525 TH1::AddDirectory(0);
527 AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ;
528 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
529 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
531 Float_t p[CHENTRIESSMALL];
533 //fTree->SetBranchAddress("nentries",&nentries);
534 //fTree->SetBranchAddress("TOFentries",p);
535 fChain->SetBranchAddress("nentries",&nentries);
536 fChain->SetBranchAddress("TOFentries",p);
538 Float_t ntracksTotalmean =0;
539 for (Int_t i=ichmin; i<ichmax; i++){
541 for (Int_t irun=0;irun<fNruns;irun++){
542 ientry = i+irun*fNChannels;
543 //fTree->GetEntry(ientry);
544 fChain->GetEntry(ientry);
545 Int_t ntracksRun=nentries/3;
546 ntracksTotalmean+=ntracksRun;
550 if (ntracksTotalmean < MEANENTRIES) {
551 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
555 //filling ToT and Time arrays
557 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
558 Float_t minToT = 0; // ns
559 Float_t maxToT = 4.88; // ns
561 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
562 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
563 Int_t ntracksTotal = 0;
564 Int_t ntracksRun = 0;
565 Double_t binsProfile[101]; // sized larger than necessary, the correct
566 // dim being set in the booking of the profile
569 for (Int_t i = ichmin;i<ichmax;i++){
571 for (Int_t irun=0;irun<fNruns;irun++){
572 ientry = i+irun*fNChannels;
573 //fTree->GetEntry(ientry);
574 fChain->GetEntry(ientry);
575 ntracksTotal+=nentries/3;
576 ntracksRun=nentries/3;
577 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun));
578 for (Int_t j=0;j<ntracksRun;j++){
579 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
580 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
581 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
582 Float_t tot = p[idxexToT];
583 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
584 meantime+=p[idxexTime]-p[idxexExTime];
589 nusefulbins = FindBins(hToT,&binsProfile[0]);
590 meantime/=ntracksTotal;
591 AliDebug(2, Form("meantime = %f",meantime));
593 for (Int_t j=1;j<=nusefulbins;j++) {
594 AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j]));
597 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
598 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
600 for (Int_t irun=0;irun<fNruns;irun++){
602 for (Int_t i=ichmin; i<ichmax; i++){
603 ientry = i+irun*fNChannels;
604 //fTree->GetEntry(ientry);
605 fChain->GetEntry(ientry);
606 ntracksRun=nentries/3;
607 for (Int_t j=0;j<ntracksRun;j++){
608 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
609 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
610 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
611 Float_t tot = p[idxexToT];
612 Float_t time = p[idxexTime]-p[idxexExTime];
613 AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
614 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
615 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
620 hSlewingProf->Fit("pol5",optionFit,"",0,4);
621 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
623 for(Int_t kk=0;kk<6;kk++){
624 par[kk]=calibfunc->GetParameter(kk);
625 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
628 if(strstr(optionSave,"save")){
629 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
631 TString profName=Form("Profile%06i_%06i",ichmin,ichmax);
632 TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax);
633 TString totName=Form("Tot%06i_%06i",ichmin,ichmax);
634 TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax);
635 hSlewingProf->Write(profName);
636 htimetot->Write(timeTotName);
637 hToT->Write(totName);
638 hdeltaTime->Write(deltaName);
653 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin);
654 calChannel->SetSlewPar(par);
655 WriteParOfflineOnCDB("TOF/Calib","valid");
658 //----------------------------------------------------------------------------
659 Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){
661 // computing calibration parameters for channel i
663 // 0 -> everything was ok
664 // 1 -> no tree for calibration found
665 // 2 -> not enough statistics to perform calibration
666 // 3 -> problems with arrays
668 TH1::AddDirectory(0);
670 AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ;
671 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
672 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
674 Float_t p[MAXCHENTRIESSMALL];
676 //fTree->SetBranchAddress("nentries",&nentries);
677 //fTree->SetBranchAddress("TOFentries",p);
678 fChain->SetBranchAddress("nentries",&nentries);
679 fChain->SetBranchAddress("TOFentries",p);
681 Float_t ntracksTotal =0;
682 for (Int_t irun=0;irun<fNruns;irun++){
684 ientry = i+irun*fNChannels;
685 //fTree->GetEntry(ientry);
686 fChain->GetEntry(ientry);
687 ntracksTotal+=nentries/3;
690 if (ntracksTotal < MEANENTRIES) {
691 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
695 //filling ToT and Time arrays
697 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
698 Float_t minToT = 0; // ns
699 Float_t maxToT = 4.88; // ns
701 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
702 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
703 Int_t ntracksRun = 0;
704 Double_t binsProfile[101]; // sized larger than necessary, the correct
705 // dim being set in the booking of the profile
708 for (Int_t irun=0;irun<fNruns;irun++){
710 ientry = i+irun*fNChannels;
711 //fTree->GetEntry(ientry);
712 fChain->GetEntry(ientry);
713 ntracksRun=nentries/3;
714 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun));
715 for (Int_t j=0;j<ntracksRun;j++){
716 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
717 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
718 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
719 Float_t tot = p[idxexToT];
720 meantime+=p[idxexTime]-p[idxexExTime];
721 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
726 nusefulbins = FindBins(hToT,&binsProfile[0]);
727 meantime/=ntracksTotal;
728 AliDebug(2,Form("meantime = %f",meantime));
730 for (Int_t j=1;j<=nusefulbins;j++) {
731 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
734 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
735 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
736 for (Int_t irun=0;irun<fNruns;irun++){
738 ientry = i+irun*fNChannels;
739 //fTree->GetEntry(ientry);
740 fChain->GetEntry(ientry);
741 ntracksRun=nentries/3;
742 for (Int_t j=0;j<ntracksRun;j++){
743 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
744 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
745 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
746 Float_t tot = p[idxexToT];
747 Float_t time = p[idxexTime]-p[idxexExTime];
748 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
749 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
750 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
754 hSlewingProf->Fit("pol5",optionFit,"",0,4);
755 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
757 for(Int_t kk=0;kk<6;kk++){
758 par[kk]=calibfunc->GetParameter(kk);
759 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
763 if(strstr(optionSave,"save")){
764 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
766 TString profName=Form("Profile%06i",i);
767 TString timeTotName=Form("TimeTot%06i",i);
768 TString totName=Form("Tot%06i",i);
769 TString deltaName=Form("Delta%06i",i);
770 hSlewingProf->Write(profName);
771 htimetot->Write(timeTotName);
772 hToT->Write(totName);
773 hdeltaTime->Write(deltaName);
788 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
789 calChannel->SetSlewPar(par);
790 WriteParOfflineOnCDB("TOF/Calib","valid");
793 //----------------------------------------------------------------------------
794 Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){
796 // calibrating an array of channels
797 // computing calibration parameters
799 // 0 -> everything was ok
800 // 1 -> no tree for calibration found
801 // 2 -> not enough statistics to perform calibration
802 // 3 -> problems with arrays
804 TH1::AddDirectory(0);
806 AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ;
807 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
808 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
809 for (Int_t ich=0; ich<nch; ich++){
811 AliInfo(Form("Calibrating channel = %i",i )) ;
813 Float_t p[MAXCHENTRIESSMALL];
815 //fTree->SetBranchAddress("nentries",&nentries);
816 //fTree->SetBranchAddress("TOFentries",p);
817 fChain->SetBranchAddress("nentries",&nentries);
818 fChain->SetBranchAddress("TOFentries",p);
820 Float_t ntracksTotalmean =0;
821 for (Int_t ich=0; ich<nch; ich++){
824 for (Int_t irun=0;irun<fNruns;irun++){
825 ientry = i+irun*fNChannels;
826 //fTree->GetEntry(ientry);
827 fChain->GetEntry(ientry);
828 ntracksTotalmean+=nentries/3;
832 ntracksTotalmean/=nch;
833 if (ntracksTotalmean < MEANENTRIES) {
834 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
838 //filling ToT and Time arrays
840 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
841 Float_t minToT = 0; // ns
842 Float_t maxToT = 4.88; // ns
843 TFile * fileProf=0x0;
844 if(strstr(optionSave,"save")){
845 fileProf = new TFile("TOFCalibSave.root","recreate");
847 for (Int_t ich=0; ich<nch; ich++) {
848 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
849 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
850 Double_t binsProfile[101]; // sized larger than necessary, the correct
851 // dim being set in the booking of the profile
852 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
853 Int_t ntracksTotal = 0;
854 Int_t ntracksRun = 0;
858 for (Int_t irun=0;irun<fNruns;irun++){
859 i = ch[ich]+irun*fNChannels;
860 AliDebug(2,Form("Calibrating channel %i",i));
861 //fTree->GetEntry(i);
863 ntracksTotal+=nentries/3;
865 if (ntracksTotal < MEANENTRIES) {
866 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal));
870 for (Int_t irun=0;irun<fNruns;irun++){
871 Int_t i = ch[ich]+irun*fNChannels;
872 //fTree->GetEntry(i);
874 ntracksRun=nentries/3;
875 for (Int_t j=0;j<ntracksRun;j++){
876 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
877 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
878 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
879 Float_t tot = p[idxexToT];
880 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
881 meantime+=p[idxexTime]-p[idxexExTime];
886 nusefulbins = FindBins(hToT,&binsProfile[0]);
887 meantime/=ntracksTotal;
888 for (Int_t j=1;j<=nusefulbins;j++) {
889 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
892 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
893 for (Int_t irun=0;irun<fNruns;irun++){
894 Int_t i = ch[ich]+irun*fNChannels;
895 //fTree->GetEntry(i);
897 ntracksRun=nentries/3;
898 for (Int_t j=0;j<ntracksRun;j++){
899 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
900 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
901 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
902 Float_t tot = p[idxexToT];
903 Float_t time = p[idxexTime]-p[idxexExTime];
904 AliDebug(2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
905 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
906 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
910 hSlewingProf->Fit("pol5",optionFit,"",1,4);
911 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
913 for(Int_t kk=0;kk<6;kk++){
914 par[kk]=calibfunc->GetParameter(kk);
915 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
918 if(strstr(optionSave,"save") && fileProf){
919 TString profName=Form("Profile%06i",i);
920 TString timeTotName=Form("TimeTot%06i",i);
921 TString totName=Form("Tot%06i",i);
922 TString deltaName=Form("Delta%06i",i);
924 hSlewingProf->Write(profName);
925 htimetot->Write(timeTotName);
926 hToT->Write(totName);
927 hdeltaTime->Write(deltaName);
930 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
931 calChannel->SetSlewPar(par);
942 if(strstr(optionSave,"save") && fileProf){
947 WriteParOfflineOnCDB("TOF/Calib","valid");
951 //----------------------------------------------------------------------------
952 Int_t AliTOFcalib::CalibrateFromProfile(Int_t ich, Option_t *optionSave, Option_t *optionFit){
954 // computing calibration parameters using the old profiling algo
956 // 0 -> everything was ok
957 // 1 -> no tree for calibration found
958 // 2 -> not enough statistics to perform calibration
959 // 3 -> problems with arrays
961 TH1::AddDirectory(0);
963 AliInfo(Form("*** Calibrating Histograms From Profile %s", GetName())) ;
964 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
965 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
966 Float_t p[MAXCHENTRIESSMALL];
968 Int_t ntracksTotal=0;
969 //fTree->SetBranchAddress("nentries",&nentries);
970 //fTree->SetBranchAddress("TOFentries",p);
971 fChain->SetBranchAddress("nentries",&nentries);
972 fChain->SetBranchAddress("TOFentries",p);
974 for (Int_t irun=0;irun<fNruns;irun++){
975 Int_t i = ich+irun*fNChannels;
976 //fTree->GetEntry(i);
978 ntracksTotal+=nentries/3;
981 if (ntracksTotal < MEANENTRIES) {
982 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
986 TH1F * hProf = new TH1F();
987 hProf = Profile(ich);
988 hProf->Fit("pol5",optionFit,"",0,4);
989 TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5");
991 for(Int_t kk=0;kk<6;kk++){
992 par[kk]=calibfunc->GetParameter(kk);
993 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
996 if(strstr(optionSave,"save")){
997 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
999 TString profName=Form("Profile%06i",ich);
1000 hProf->Write(profName);
1008 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich);
1009 calChannel->SetSlewPar(par);
1010 WriteParOfflineOnCDB("TOF/Calib","valid");
1013 //----------------------------------------------------------------------------
1014 Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){
1016 // calibrating the whole TOF
1017 // computing calibration parameters
1019 // 0 -> everything was ok
1020 // 1 -> no tree for calibration found
1021 // 2 -> not enough statistics to perform calibration
1022 // 3 -> problems with arrays
1024 TH1::AddDirectory(0);
1026 AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ;
1027 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1028 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1030 TFile * fileProf=0x0;
1031 if(strstr(optionSave,"save")){
1032 fileProf = new TFile("TOFCalibSave.root","recreate");
1035 Float_t p[MAXCHENTRIESSMALL];
1037 //fTree->SetBranchAddress("nentries",&nentries);
1038 //fTree->SetBranchAddress("TOFentries",p);
1039 fChain->SetBranchAddress("nentries",&nentries);
1040 fChain->SetBranchAddress("TOFentries",p);
1042 Float_t ntracksTotalmean =0;
1043 for (Int_t ii=0; ii<fNChannels; ii++){
1044 for (Int_t irun=0;irun<fNruns;irun++){
1045 Int_t i = ii+irun*fNChannels;
1046 //fTree->GetEntry(i);
1047 fChain->GetEntry(i);
1048 ntracksTotalmean+=nentries/3;
1052 ntracksTotalmean/=fNChannels;
1053 if (ntracksTotalmean < MEANENTRIES) {
1054 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1058 //filling ToT and Time arrays
1060 Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps
1061 Float_t minToT = 0; // ns
1062 Float_t maxToT = 4.88;// ns
1063 for (Int_t ii=0; ii<fNChannels; ii++) {
1064 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1065 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1066 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1067 if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii));
1069 Int_t nusefulbins=0;
1070 Double_t binsProfile[101]; // sized larger than necessary, the correct
1071 // dim being set in the booking of the profile
1072 Int_t ntracksRun = 0;
1073 Int_t ntracksTotal = 0;
1074 for (Int_t irun=0;irun<fNruns;irun++){
1075 Int_t i = ii+irun*fNChannels;
1076 //fTree->GetEntry(i);
1077 fChain->GetEntry(i);
1078 ntracksTotal+=nentries/3;
1080 if (ntracksTotal < MEANENTRIES) {
1081 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal));
1085 for (Int_t irun=0;irun<fNruns;irun++){
1086 Int_t i = ii+irun*fNChannels;
1087 //fTree->GetEntry(i);
1088 fChain->GetEntry(i);
1089 ntracksRun=nentries/3;
1090 for (Int_t j=0;j<ntracksRun;j++){
1091 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1092 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1093 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1094 Float_t tot = p[idxexToT];
1095 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1096 meantime+=p[idxexTime]-p[idxexExTime];
1100 nusefulbins = FindBins(hToT,&binsProfile[0]);
1101 meantime/=ntracksTotal;
1102 for (Int_t j=0;j<nusefulbins;j++) {
1103 AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j]));
1105 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1106 for (Int_t irun=0;irun<fNruns;irun++){
1107 Int_t i = ii+irun*fNChannels;
1108 //fTree->GetEntry(i);
1109 fChain->GetEntry(i);
1110 ntracksRun=nentries/3;
1111 for (Int_t j=0;j<ntracksRun;j++){
1112 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1113 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1114 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1115 Float_t tot = p[idxexToT];
1116 Float_t time = p[idxexTime]-p[idxexExTime];
1117 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1118 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1119 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1122 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1123 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1125 for(Int_t kk=0;kk<6;kk++){
1126 par[kk]=calibfunc->GetParameter(kk);
1127 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1130 if(strstr(optionSave,"save") && fileProf){
1131 TString profName=Form("Profile%06i",ii);
1132 TString timeTotName=Form("TimeTot%06i",ii);
1133 TString totName=Form("Tot%06i",ii);
1134 TString deltaName=Form("Delta%06i",ii);
1136 hSlewingProf->Write(profName);
1137 htimetot->Write(timeTotName);
1138 hToT->Write(totName);
1139 hdeltaTime->Write(deltaName);
1141 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii);
1142 calChannel->SetSlewPar(par);
1146 delete hSlewingProf;
1154 if(strstr(optionSave,"save")){
1159 WriteParOfflineOnCDB("TOF/Calib","valid");
1163 //-----------------------------------------------------------------------
1164 TH1F* AliTOFcalib::Profile(Int_t ich)
1168 Float_t p[MAXCHENTRIESSMALL];
1170 //fTree->SetBranchAddress("nentries",&nentries);
1171 //fTree->SetBranchAddress("TOFentries",p);
1172 fChain->SetBranchAddress("nentries",&nentries);
1173 fChain->SetBranchAddress("TOFentries",p);
1175 //Prepare histograms for Slewing Correction
1176 const Int_t knbinToT = 100;
1177 Int_t nbinTime = 200;
1178 Float_t minTime = -5.5; //ns
1179 Float_t maxTime = 5.5; //ns
1180 Float_t minToT = 0; //ns
1181 Float_t maxToT = 5.; //ns
1182 Float_t deltaToT = (maxToT-minToT)/knbinToT;
1183 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];
1184 Int_t n[knbinToT+1], nentrx[knbinToT+1];
1185 Double_t sigmaToT[knbinToT+1];
1186 for (Int_t i = 0; i < knbinToT+1 ; i++){
1204 TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
1205 Int_t ntracksRun = 0;
1206 TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT);
1207 for (Int_t irun=0;irun<fNruns;irun++){
1208 Int_t i = ich+irun*fNChannels;
1209 //fTree->GetEntry(i);
1210 fChain->GetEntry(i);
1211 ntracksRun=nentries/3;
1212 for (Int_t j=0;j<ntracksRun;j++){
1213 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1214 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1215 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1216 Float_t tot = p[idxexToT];
1217 Float_t time = p[idxexTime]-p[idxexExTime];
1218 Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1;
1219 if ((tot != 0) && ( time!= 0)){
1221 vTime2[nx]+=time*time;
1225 hSlewing->Fill(tot,time);
1229 Int_t nbinsToT=hSlewing->GetNbinsX();
1230 if (nbinsToT != knbinToT) {
1231 AliError("Profile :: incompatible numbers of bins");
1236 for (Int_t i=1;i<=nbinsToT;i++){
1238 n[usefulBins]+=nentrx[i];
1239 if (n[usefulBins]==0 && i == nbinsToT) {
1242 meanTime[usefulBins]+=vTime[i];
1243 meanTime2[usefulBins]+=vTime2[i];
1244 meanToT[usefulBins]+=vToT[i];
1245 meanToT2[usefulBins]+=vToT2[i];
1246 if (n[usefulBins]<10 && i!=nbinsToT) continue;
1247 mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
1248 mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
1249 sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1250 *(meanTime2[usefulBins]-meanTime[usefulBins]
1251 *meanTime[usefulBins]/n[usefulBins]));
1252 if ((1./n[usefulBins]/n[usefulBins]
1253 *(meanToT2[usefulBins]-meanToT[usefulBins]
1254 *meanToT[usefulBins]/n[usefulBins]))< 0) {
1255 AliError(" too small radical" );
1256 sigmaToT[usefulBins]=0;
1259 sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1260 *(meanToT2[usefulBins]-meanToT[usefulBins]
1261 *meanToT[usefulBins]/n[usefulBins]));
1266 for (Int_t i=0;i<usefulBins;i++){
1267 Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
1268 histo->Fill(mToT[i],mTime[i]);
1269 histo->SetBinError(binN,sigmaTime[i]);
1276 //----------------------------------------------------------------------------
1277 Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{
1279 // to determine the bins for ToT histo
1283 Int_t nbin = h->GetNbinsX();
1284 Int_t nentries = (Int_t)h->GetEntries();
1285 Float_t max = h->GetBinLowEdge(nbin);
1286 Int_t nusefulbins=0;
1288 // setting maxvalue of entries per bin
1289 if (nentries <= 60) maxcont = 2;
1290 else if (nentries <= 100) maxcont = 5;
1291 else if (nentries <= 500) maxcont = 10;
1293 for (Int_t j=1;j<=nbin;j++) {
1294 cont += (Int_t)h->GetBinContent(j);
1298 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1307 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1308 binsProfile[nusefulbins]=max;
1311 binsProfile[nusefulbins]=h->GetBinLowEdge(startBin);