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.20 2007/10/26 15:13:50 zampolli
19 Using a TChain instead of a TTree
21 Revision 1.19 2007/10/23 15:27:38 zampolli
22 Rearrangement of Calibration objects for simulation
24 Revision 1.16 2007/10/08 10:13:26 zampolli
25 First Run and Last Run members added, infinite validity of calib obj implemented.
27 Revision 1.15 2007/10/04 13:23:28 zampolli
28 Updates to handle functionalities in TOF online/offline calibration according to the latest schema
30 Revision 1.14 2007/06/06 16:26:30 arcelli
31 remove fall-back call to local CDB storage
33 Revision 1.13 2007/04/20 13:59:40 arcelli
34 make protections agains failed retrieval of the CDB object in a proper way
36 Revision 1.12 2007/03/23 11:31:16 arcelli
37 CDB Entry for TOF Reconstruction Parameters
39 Revision 1.11 2007/02/28 18:08:26 arcelli
40 Add protection against failed retrieval of the CDB cal object
42 Revision 1.10 2006/08/22 13:30:49 arcelli
43 removal of effective c++ warnings (C.Zampolli)
45 Revision 1.9 2006/04/20 22:30:50 hristov
46 Coding conventions (Annalisa)
48 Revision 1.8 2006/04/16 22:29:05 hristov
49 Coding conventions (Annalisa)
51 Revision 1.7 2006/04/16 20:12:46 hristov
52 Removing memory leak in case of cached CDB entries
54 Revision 1.6 2006/04/11 15:28:32 hristov
55 Checks on cache status before deleting calibration objects (A.Colla)
57 Revision 1.5 2006/04/05 08:35:38 hristov
58 Coding conventions (S.Arcelli, C.Zampolli)
60 Revision 1.4 2006/03/31 11:26:46 arcelli
61 changing CDB Ids according to standard convention
63 Revision 1.3 2006/03/28 14:57:02 arcelli
64 updates to handle new V5 geometry & some re-arrangements
66 Revision 1.2 2006/02/13 17:22:26 arcelli
69 Revision 1.1 2006/02/13 16:10:48 arcelli
70 Add classes for TOF Calibration (C.Zampolli)
72 author: Chiara Zampolli, zampolli@bo.infn.it
75 ///////////////////////////////////////////////////////////////////////////////
77 // class for TOF calibration //
79 ///////////////////////////////////////////////////////////////////////////////
93 #include "AliCDBEntry.h"
94 #include "AliCDBRunRange.h"
96 #include "AliCDBManager.h"
97 #include "AliCDBStorage.h"
98 #include "AliCDBMetaData.h"
99 #include "AliESDtrack.h"
103 #include "AliTOFcalib.h"
104 #include "AliTOFChannelOnline.h"
105 #include "AliTOFChannelOffline.h"
106 #include "AliTOFGeometry.h"
107 #include "AliTOFRecoParam.h"
110 extern TStyle *gStyle;
112 ClassImp(AliTOFcalib)
114 //_______________________________________________________________________
115 AliTOFcalib::AliTOFcalib():
116 TTask("AliTOFcalib",""),
126 fLastRun(AliCDBRunRange::Infinity())
128 //TOF Calibration Class ctor
129 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
131 //____________________________________________________________________________
133 AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
134 TTask("AliTOFcalib",""),
135 fNChannels(calib.fNChannels),
138 fTOFSimToT(calib.fTOFSimToT),
139 fkValidity(calib.fkValidity),
141 fChain(calib.fChain),
142 fNruns(calib.fNruns),
143 fFirstRun(calib.fFirstRun),
144 fLastRun(calib.fLastRun)
146 //TOF Calibration Class copy ctor
147 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
148 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
149 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
150 fTOFCalOnline->AddAt(calChOnline,iarray);
151 fTOFCalOffline->AddAt(calChOffline,iarray);
156 //____________________________________________________________________________
158 AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
160 //TOF Calibration Class assignment operator
161 this->fNChannels = calib.fNChannels;
162 this->fTOFSimToT = calib.fTOFSimToT;
163 this->fkValidity = calib.fkValidity;
164 this->fTree = calib.fTree;
165 this->fChain = calib.fChain;
166 this->fNruns = calib.fNruns;
167 this->fFirstRun = calib.fFirstRun;
168 this->fLastRun = calib.fLastRun;
169 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
170 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
171 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
172 this->fTOFCalOnline->AddAt(calChOnline,iarray);
173 this->fTOFCalOffline->AddAt(calChOffline,iarray);
178 //____________________________________________________________________________
180 AliTOFcalib::~AliTOFcalib()
182 //TOF Calibration Class dtor
183 if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
185 delete fTOFCalOnline;
188 delete fTOFCalOffline;
191 if (fTree!=0x0) delete fTree;
192 if (fChain!=0x0) delete fChain;
194 //_____________________________________________________________________________
195 void AliTOFcalib::CreateCalArrays(){
197 // creating arrays for online/offline calibration objs
199 fTOFCalOnline = new TObjArray(fNChannels);
200 fTOFCalOffline = new TObjArray(fNChannels);
201 fTOFCalOnline->SetOwner();
202 fTOFCalOffline->SetOwner();
203 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
204 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
205 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
206 fTOFCalOnline->AddAt(calChOnline,iarray);
207 fTOFCalOffline->AddAt(calChOffline,iarray);
210 //_____________________________________________________________________________
211 void AliTOFcalib::WriteParOnlineOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
213 //Write calibration parameters to the CDB
216 AliCDBManager *man = AliCDBManager::Instance();
217 Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
219 sprintf(out,"%s/%s",sel,sel1);
220 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
221 AliCDBId id(out,fFirstRun,fLastRun);
222 AliCDBMetaData *md = new AliCDBMetaData();
223 md->SetResponsible("Chiara Zampolli");
224 if (!fTOFCalOnline) {
227 man->Put(fTOFCalOnline,id,md);
230 //_____________________________________________________________________________
232 void AliTOFcalib::WriteParOnlineOnCDB(Char_t *sel)
234 //Write calibration parameters to the CDB with infinite validity
235 AliCDBManager *man = AliCDBManager::Instance();
236 Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor
238 sprintf(out,"%s/%s",sel,sel1);
239 AliCDBRunRange runrange(fFirstRun,fLastRun);
240 AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
241 AliCDBId id(out,runrange);
242 AliCDBMetaData *md = new AliCDBMetaData();
243 md->SetResponsible("Chiara Zampolli");
244 if (!fTOFCalOnline) {
247 man->Put(fTOFCalOnline,id,md);
250 //_____________________________________________________________________________
252 void AliTOFcalib::WriteParOfflineOnCDB(Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun)
254 //Write calibration parameters to the CDB
257 AliCDBManager *man = AliCDBManager::Instance();
258 Char_t *sel1 = "ParOffline" ;
260 sprintf(out,"%s/%s",sel,sel1);
261 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun));
262 AliCDBId id(out,fFirstRun,fLastRun);
263 AliCDBMetaData *md = new AliCDBMetaData();
264 md->SetResponsible("Chiara Zampolli");
265 md->SetComment(validity);
266 man->Put(fTOFCalOffline,id,md);
269 //_____________________________________________________________________________
271 void AliTOFcalib::WriteParOfflineOnCDB(Char_t *sel, const Char_t *validity)
273 //Write calibration parameters to the CDB with infinite validity
274 AliCDBManager *man = AliCDBManager::Instance();
275 Char_t *sel1 = "ParOffline" ;
277 sprintf(out,"%s/%s",sel,sel1);
278 AliCDBRunRange runrange(fFirstRun,fLastRun);
279 AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun()));
280 AliCDBId id(out,runrange);
281 AliCDBMetaData *md = new AliCDBMetaData();
282 md->SetResponsible("Chiara Zampolli");
283 md->SetComment(validity);
284 man->Put(fTOFCalOffline,id,md);
287 //_____________________________________________________________________________
289 Bool_t AliTOFcalib::ReadParOnlineFromCDB(Char_t *sel, Int_t nrun)
291 //Read calibration parameters from the CDB
292 AliCDBManager *man = AliCDBManager::Instance();
293 Char_t *sel1 = "ParOnline" ;
295 sprintf(out,"%s/%s",sel,sel1);
296 if (!man->Get(out,nrun)) {
299 AliCDBEntry *entry = man->Get(out,nrun);
300 if(!entry->GetObject()){
304 fTOFCalOnline =(TObjArray*)entry->GetObject();
309 //_____________________________________________________________________________
311 Bool_t AliTOFcalib::ReadParOfflineFromCDB(Char_t *sel, Int_t nrun)
313 //Read calibration parameters from the CDB
314 AliCDBManager *man = AliCDBManager::Instance();
315 Char_t *sel1 = "ParOffline" ;
317 sprintf(out,"%s/%s",sel,sel1);
318 if (!man->Get(out,nrun)) {
321 AliCDBEntry *entry = man->Get(out,nrun);
322 if(!entry->GetObject()){
325 AliCDBMetaData * md = entry->GetMetaData();
326 fkValidity = md->GetComment();
327 fTOFCalOffline =(TObjArray*)entry->GetObject();
332 //_____________________________________________________________________________
333 void AliTOFcalib::WriteSimHistoOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo){
334 //Write Sim miscalibration parameters to the CDB
337 AliCDBManager *man = AliCDBManager::Instance();
338 Char_t *sel1 = "SimHisto" ;
340 sprintf(out,"%s/%s",sel,sel1);
341 AliCDBMetaData *mdhisto = new AliCDBMetaData();
342 mdhisto->SetResponsible("Chiara Zampolli");
343 AliCDBId id(out,minrun,maxrun);
344 man->Put(fTOFSimToT,id,mdhisto);
347 //_____________________________________________________________________________
348 Bool_t AliTOFcalib::ReadSimHistoFromCDB(Char_t *sel, Int_t nrun)
350 //Read miscalibration parameters from the CDB
351 AliCDBManager *man = AliCDBManager::Instance();
355 Char_t *sel1 = "SimHisto" ;
357 sprintf(out,"%s/%s",sel,sel1);
358 if (!man->Get(out,nrun)) {
359 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
362 AliCDBEntry *entry = man->Get(out,nrun);
363 if(!entry->GetObject()){
364 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
367 TH1F *histo =(TH1F*)entry->GetObject();
371 //_____________________________________________________________________________
372 void AliTOFcalib::WriteRecParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){
373 //Write reconstruction parameters to the CDB
375 AliCDBManager *man = AliCDBManager::Instance();
376 AliCDBMetaData *md = new AliCDBMetaData();
377 md->SetResponsible("Silvia Arcelli");
378 Char_t *sel1 = "RecPar" ;
380 sprintf(out,"%s/%s",sel,sel1);
381 AliCDBId id(out,minrun,maxrun);
382 man->Put(param,id,md);
385 //_____________________________________________________________________________
386 AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(Char_t *sel, Int_t nrun)
388 //Read reconstruction parameters from the CDB
389 AliCDBManager *man = AliCDBManager::Instance();
390 Char_t *sel1 = "RecPar" ;
392 sprintf(out,"%s/%s",sel,sel1);
393 if (!man->Get(out,nrun)) {
394 AliFatal("Exiting, no CDB object (RecPar) found!!!");
397 AliCDBEntry *entry = man->Get(out,nrun);
398 if(!entry->GetObject()){
399 AliFatal("Exiting, no CDB object (RecPar) found!!!");
403 AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject();
406 //-----------------------------------------------------------------------------
407 // Calibration methods
408 //-----------------------------------------------------------------------------
409 void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){
411 // creating the chain with the trees for calibration
412 // collecting them from reference data
413 // from minrun to maxrun
415 Float_t p[CHENTRIESSMALL];
417 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
418 fTree->Branch("nentries",&nentries,"nentries/I");
419 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
420 AliCDBManager *man = AliCDBManager::Instance();
421 AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT");
422 for (Int_t irun = minrun;irun<=maxrun;irun++){
423 AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun);
425 AliInfo(Form("No entry found for run %i",irun));
428 TTree *tree = new TTree();
429 tree = (TTree*)entry->GetObject();
430 tree->SetBranchAddress("nentries",&nentries);
431 tree->SetBranchAddress("TOFentries",p);
432 fTree->CopyEntries(tree);
437 AliInfo(Form("Number of runs being analyzed %i",fNruns));
439 //-----------------------------------------------------------------------------
440 void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
442 // creating the chain with the trees for calibration
443 // collecting them from the Grid
444 // from minrun to maxrun
446 Float_t p[CHENTRIESSMALL];
448 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
449 fTree->SetDirectory(0);
450 fTree->Branch("nentries",&nentries,"nentries/I");
451 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
452 AliInfo("connected to alien");
453 TGrid::Connect("alien://");
455 Char_t filename[100];
456 for (Int_t irun = minrun;irun<=maxrun;irun++){
457 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
458 TFile *filegrid = TFile::Open(filename,"READ");
459 TTree *tree = (TTree*)filegrid->Get("T");
460 tree->SetBranchAddress("nentries",&nentries);
461 tree->SetBranchAddress("TOFentries",p);
462 fTree->CopyEntries(tree);
467 AliInfo(Form("Number of runs being analyzed %i",fNruns));
469 //-----------------------------------------------------------------------------
470 void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){
472 // creating the tree with the trees for calibration
473 // collecting them from reference data (from file)
474 // from minrun to maxrun
476 Float_t p[CHENTRIESSMALL];
478 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
479 fTree->SetDirectory(0);
480 fTree->Branch("nentries",&nentries,"nentries/I");
481 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
482 Char_t filename[100];
483 for (Int_t irun = minrun;irun<=maxrun;irun++){
484 sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun);
485 TFile *file = new TFile(filename,"READ");
486 TTree *tree = (TTree*)file->Get("T");
487 tree->SetBranchAddress("nentries",&nentries);
488 tree->SetBranchAddress("TOFentries",p);
489 fTree->CopyEntries(tree);
496 AliInfo(Form("Number of runs being analyzed %i",fNruns));
498 //-----------------------------------------------------------------------------
499 void AliTOFcalib::CreateChainFromGrid(Int_t minrun, Int_t maxrun){
501 // creating the chain with the trees for calibration
502 // collecting them from the Grid
503 // from minrun to maxrun
505 fChain = new TChain("T");
506 AliInfo("connected to alien");
507 TGrid::Connect("alien://");
509 Char_t filename[100];
510 for (Int_t irun = minrun;irun<=maxrun;irun++){
511 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
512 fChain->Add(filename);
516 AliInfo(Form("Number of runs being analyzed %i",fNruns));
518 //-----------------------------------------------------------------------------
519 Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){
521 // calibrating summing more than one channels
522 // computing calibration parameters
524 // 0 -> everything was ok
525 // 1 -> no tree for calibration found
526 // 2 -> not enough statistics to perform calibration
527 // 3 -> problems with arrays
529 TH1::AddDirectory(0);
531 AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ;
532 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
533 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
535 Float_t p[CHENTRIESSMALL];
537 //fTree->SetBranchAddress("nentries",&nentries);
538 //fTree->SetBranchAddress("TOFentries",p);
539 fChain->SetBranchAddress("nentries",&nentries);
540 fChain->SetBranchAddress("TOFentries",p);
542 Float_t ntracksTotalmean =0;
543 for (Int_t i=ichmin; i<ichmax; i++){
545 for (Int_t irun=0;irun<fNruns;irun++){
546 ientry = i+irun*fNChannels;
547 //fTree->GetEntry(ientry);
548 fChain->GetEntry(ientry);
549 Int_t ntracksRun=nentries/3;
550 ntracksTotalmean+=ntracksRun;
554 if (ntracksTotalmean < MEANENTRIES) {
555 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
559 //filling ToT and Time arrays
561 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
562 Float_t minToT = 0; // ns
563 Float_t maxToT = 4.88; // ns
565 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
566 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
567 Int_t ntracksTotal = 0;
568 Int_t ntracksRun = 0;
569 Double_t binsProfile[101]; // sized larger than necessary, the correct
570 // dim being set in the booking of the profile
573 for (Int_t i = ichmin;i<ichmax;i++){
575 for (Int_t irun=0;irun<fNruns;irun++){
576 ientry = i+irun*fNChannels;
577 //fTree->GetEntry(ientry);
578 fChain->GetEntry(ientry);
579 ntracksTotal+=nentries/3;
580 ntracksRun=nentries/3;
581 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun));
582 for (Int_t j=0;j<ntracksRun;j++){
583 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
584 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
585 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
586 Float_t tot = p[idxexToT];
587 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
588 meantime+=p[idxexTime]-p[idxexExTime];
593 nusefulbins = FindBins(hToT,&binsProfile[0]);
594 meantime/=ntracksTotal;
595 AliDebug(2, Form("meantime = %f",meantime));
597 for (Int_t j=1;j<=nusefulbins;j++) {
598 AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j]));
601 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
602 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
604 for (Int_t irun=0;irun<fNruns;irun++){
606 for (Int_t i=ichmin; i<ichmax; i++){
607 ientry = i+irun*fNChannels;
608 //fTree->GetEntry(ientry);
609 fChain->GetEntry(ientry);
610 ntracksRun=nentries/3;
611 for (Int_t j=0;j<ntracksRun;j++){
612 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
613 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
614 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
615 Float_t tot = p[idxexToT];
616 Float_t time = p[idxexTime]-p[idxexExTime];
617 AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
618 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
619 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
624 hSlewingProf->Fit("pol5",optionFit,"",0,4);
625 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
627 for(Int_t kk=0;kk<6;kk++){
628 par[kk]=calibfunc->GetParameter(kk);
629 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
632 if(strstr(optionSave,"save")){
633 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
635 TString profName=Form("Profile%06i_%06i",ichmin,ichmax);
636 TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax);
637 TString totName=Form("Tot%06i_%06i",ichmin,ichmax);
638 TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax);
639 hSlewingProf->Write(profName);
640 htimetot->Write(timeTotName);
641 hToT->Write(totName);
642 hdeltaTime->Write(deltaName);
657 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin);
658 calChannel->SetSlewPar(par);
659 WriteParOfflineOnCDB("TOF/Calib","valid");
662 //----------------------------------------------------------------------------
663 Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){
665 // computing calibration parameters for channel i
667 // 0 -> everything was ok
668 // 1 -> no tree for calibration found
669 // 2 -> not enough statistics to perform calibration
670 // 3 -> problems with arrays
672 TH1::AddDirectory(0);
674 AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ;
675 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
676 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
678 Float_t p[MAXCHENTRIESSMALL];
680 //fTree->SetBranchAddress("nentries",&nentries);
681 //fTree->SetBranchAddress("TOFentries",p);
682 fChain->SetBranchAddress("nentries",&nentries);
683 fChain->SetBranchAddress("TOFentries",p);
685 Float_t ntracksTotal =0;
686 for (Int_t irun=0;irun<fNruns;irun++){
688 ientry = i+irun*fNChannels;
689 //fTree->GetEntry(ientry);
690 fChain->GetEntry(ientry);
691 ntracksTotal+=nentries/3;
694 if (ntracksTotal < MEANENTRIES) {
695 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
699 //filling ToT and Time arrays
701 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
702 Float_t minToT = 0; // ns
703 Float_t maxToT = 4.88; // ns
705 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
706 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
707 Int_t ntracksRun = 0;
708 Double_t binsProfile[101]; // sized larger than necessary, the correct
709 // dim being set in the booking of the profile
712 for (Int_t irun=0;irun<fNruns;irun++){
714 ientry = i+irun*fNChannels;
715 //fTree->GetEntry(ientry);
716 fChain->GetEntry(ientry);
717 ntracksRun=nentries/3;
718 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun));
719 for (Int_t j=0;j<ntracksRun;j++){
720 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
721 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
722 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
723 Float_t tot = p[idxexToT];
724 meantime+=p[idxexTime]-p[idxexExTime];
725 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
730 nusefulbins = FindBins(hToT,&binsProfile[0]);
731 meantime/=ntracksTotal;
732 AliDebug(2,Form("meantime = %f",meantime));
734 for (Int_t j=1;j<=nusefulbins;j++) {
735 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
738 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
739 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
740 for (Int_t irun=0;irun<fNruns;irun++){
742 ientry = i+irun*fNChannels;
743 //fTree->GetEntry(ientry);
744 fChain->GetEntry(ientry);
745 ntracksRun=nentries/3;
746 for (Int_t j=0;j<ntracksRun;j++){
747 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
748 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
749 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
750 Float_t tot = p[idxexToT];
751 Float_t time = p[idxexTime]-p[idxexExTime];
752 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
753 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
754 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
758 hSlewingProf->Fit("pol5",optionFit,"",0,4);
759 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
761 for(Int_t kk=0;kk<6;kk++){
762 par[kk]=calibfunc->GetParameter(kk);
763 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
767 if(strstr(optionSave,"save")){
768 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
770 TString profName=Form("Profile%06i",i);
771 TString timeTotName=Form("TimeTot%06i",i);
772 TString totName=Form("Tot%06i",i);
773 TString deltaName=Form("Delta%06i",i);
774 hSlewingProf->Write(profName);
775 htimetot->Write(timeTotName);
776 hToT->Write(totName);
777 hdeltaTime->Write(deltaName);
792 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
793 calChannel->SetSlewPar(par);
794 WriteParOfflineOnCDB("TOF/Calib","valid");
797 //----------------------------------------------------------------------------
798 Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){
800 // calibrating an array of channels
801 // computing calibration parameters
803 // 0 -> everything was ok
804 // 1 -> no tree for calibration found
805 // 2 -> not enough statistics to perform calibration
806 // 3 -> problems with arrays
808 TH1::AddDirectory(0);
810 AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ;
811 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
812 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
813 for (Int_t ich=0; ich<nch; ich++){
815 AliInfo(Form("Calibrating channel = %i",i )) ;
817 Float_t p[MAXCHENTRIESSMALL];
819 //fTree->SetBranchAddress("nentries",&nentries);
820 //fTree->SetBranchAddress("TOFentries",p);
821 fChain->SetBranchAddress("nentries",&nentries);
822 fChain->SetBranchAddress("TOFentries",p);
824 Float_t ntracksTotalmean =0;
825 for (Int_t ich=0; ich<nch; ich++){
828 for (Int_t irun=0;irun<fNruns;irun++){
829 ientry = i+irun*fNChannels;
830 //fTree->GetEntry(ientry);
831 fChain->GetEntry(ientry);
832 ntracksTotalmean+=nentries/3;
836 ntracksTotalmean/=nch;
837 if (ntracksTotalmean < MEANENTRIES) {
838 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
842 //filling ToT and Time arrays
844 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
845 Float_t minToT = 0; // ns
846 Float_t maxToT = 4.88; // ns
847 TFile * fileProf=0x0;
848 if(strstr(optionSave,"save")){
849 fileProf = new TFile("TOFCalibSave.root","recreate");
851 for (Int_t ich=0; ich<nch; ich++) {
852 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
853 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
854 Double_t binsProfile[101]; // sized larger than necessary, the correct
855 // dim being set in the booking of the profile
856 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
857 Int_t ntracksTotal = 0;
858 Int_t ntracksRun = 0;
862 for (Int_t irun=0;irun<fNruns;irun++){
863 i = ch[ich]+irun*fNChannels;
864 AliDebug(2,Form("Calibrating channel %i",i));
865 //fTree->GetEntry(i);
867 ntracksTotal+=nentries/3;
869 if (ntracksTotal < MEANENTRIES) {
870 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal));
874 for (Int_t irun=0;irun<fNruns;irun++){
875 Int_t i = ch[ich]+irun*fNChannels;
876 //fTree->GetEntry(i);
878 ntracksRun=nentries/3;
879 for (Int_t j=0;j<ntracksRun;j++){
880 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
881 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
882 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
883 Float_t tot = p[idxexToT];
884 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
885 meantime+=p[idxexTime]-p[idxexExTime];
890 nusefulbins = FindBins(hToT,&binsProfile[0]);
891 meantime/=ntracksTotal;
892 for (Int_t j=1;j<=nusefulbins;j++) {
893 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
896 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
897 for (Int_t irun=0;irun<fNruns;irun++){
898 Int_t i = ch[ich]+irun*fNChannels;
899 //fTree->GetEntry(i);
901 ntracksRun=nentries/3;
902 for (Int_t j=0;j<ntracksRun;j++){
903 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
904 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
905 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
906 Float_t tot = p[idxexToT];
907 Float_t time = p[idxexTime]-p[idxexExTime];
908 AliDebug(2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
909 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
910 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
914 hSlewingProf->Fit("pol5",optionFit,"",1,4);
915 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
917 for(Int_t kk=0;kk<6;kk++){
918 par[kk]=calibfunc->GetParameter(kk);
919 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
922 if(strstr(optionSave,"save") && fileProf){
923 TString profName=Form("Profile%06i",i);
924 TString timeTotName=Form("TimeTot%06i",i);
925 TString totName=Form("Tot%06i",i);
926 TString deltaName=Form("Delta%06i",i);
928 hSlewingProf->Write(profName);
929 htimetot->Write(timeTotName);
930 hToT->Write(totName);
931 hdeltaTime->Write(deltaName);
934 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
935 calChannel->SetSlewPar(par);
946 if(strstr(optionSave,"save") && fileProf){
951 WriteParOfflineOnCDB("TOF/Calib","valid");
955 //----------------------------------------------------------------------------
956 Int_t AliTOFcalib::CalibrateFromProfile(Int_t ich, Option_t *optionSave, Option_t *optionFit){
958 // computing calibration parameters using the old profiling algo
960 // 0 -> everything was ok
961 // 1 -> no tree for calibration found
962 // 2 -> not enough statistics to perform calibration
963 // 3 -> problems with arrays
965 TH1::AddDirectory(0);
967 AliInfo(Form("*** Calibrating Histograms From Profile %s", GetName())) ;
968 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
969 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
970 Float_t p[MAXCHENTRIESSMALL];
972 Int_t ntracksTotal=0;
973 //fTree->SetBranchAddress("nentries",&nentries);
974 //fTree->SetBranchAddress("TOFentries",p);
975 fChain->SetBranchAddress("nentries",&nentries);
976 fChain->SetBranchAddress("TOFentries",p);
978 for (Int_t irun=0;irun<fNruns;irun++){
979 Int_t i = ich+irun*fNChannels;
980 //fTree->GetEntry(i);
982 ntracksTotal+=nentries/3;
985 if (ntracksTotal < MEANENTRIES) {
986 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
990 TH1F * hProf = new TH1F();
991 hProf = Profile(ich);
992 hProf->Fit("pol5",optionFit,"",0,4);
993 TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5");
995 for(Int_t kk=0;kk<6;kk++){
996 par[kk]=calibfunc->GetParameter(kk);
997 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1000 if(strstr(optionSave,"save")){
1001 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1003 TString profName=Form("Profile%06i",ich);
1004 hProf->Write(profName);
1012 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich);
1013 calChannel->SetSlewPar(par);
1014 WriteParOfflineOnCDB("TOF/Calib","valid");
1017 //----------------------------------------------------------------------------
1018 Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){
1020 // calibrating the whole TOF
1021 // computing calibration parameters
1023 // 0 -> everything was ok
1024 // 1 -> no tree for calibration found
1025 // 2 -> not enough statistics to perform calibration
1026 // 3 -> problems with arrays
1028 TH1::AddDirectory(0);
1030 AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ;
1031 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1032 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1034 TFile * fileProf=0x0;
1035 if(strstr(optionSave,"save")){
1036 fileProf = new TFile("TOFCalibSave.root","recreate");
1039 Float_t p[MAXCHENTRIESSMALL];
1041 //fTree->SetBranchAddress("nentries",&nentries);
1042 //fTree->SetBranchAddress("TOFentries",p);
1043 fChain->SetBranchAddress("nentries",&nentries);
1044 fChain->SetBranchAddress("TOFentries",p);
1046 Float_t ntracksTotalmean =0;
1047 for (Int_t ii=0; ii<fNChannels; ii++){
1048 for (Int_t irun=0;irun<fNruns;irun++){
1049 Int_t i = ii+irun*fNChannels;
1050 //fTree->GetEntry(i);
1051 fChain->GetEntry(i);
1052 ntracksTotalmean+=nentries/3;
1056 ntracksTotalmean/=fNChannels;
1057 if (ntracksTotalmean < MEANENTRIES) {
1058 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1062 //filling ToT and Time arrays
1064 Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps
1065 Float_t minToT = 0; // ns
1066 Float_t maxToT = 4.88;// ns
1067 for (Int_t ii=0; ii<fNChannels; ii++) {
1068 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1069 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1070 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1071 if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii));
1073 Int_t nusefulbins=0;
1074 Double_t binsProfile[101]; // sized larger than necessary, the correct
1075 // dim being set in the booking of the profile
1076 Int_t ntracksRun = 0;
1077 Int_t ntracksTotal = 0;
1078 for (Int_t irun=0;irun<fNruns;irun++){
1079 Int_t i = ii+irun*fNChannels;
1080 //fTree->GetEntry(i);
1081 fChain->GetEntry(i);
1082 ntracksTotal+=nentries/3;
1084 if (ntracksTotal < MEANENTRIES) {
1085 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal));
1089 for (Int_t irun=0;irun<fNruns;irun++){
1090 Int_t i = ii+irun*fNChannels;
1091 //fTree->GetEntry(i);
1092 fChain->GetEntry(i);
1093 ntracksRun=nentries/3;
1094 for (Int_t j=0;j<ntracksRun;j++){
1095 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1096 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1097 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1098 Float_t tot = p[idxexToT];
1099 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1100 meantime+=p[idxexTime]-p[idxexExTime];
1104 nusefulbins = FindBins(hToT,&binsProfile[0]);
1105 meantime/=ntracksTotal;
1106 for (Int_t j=0;j<nusefulbins;j++) {
1107 AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j]));
1109 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1110 for (Int_t irun=0;irun<fNruns;irun++){
1111 Int_t i = ii+irun*fNChannels;
1112 //fTree->GetEntry(i);
1113 fChain->GetEntry(i);
1114 ntracksRun=nentries/3;
1115 for (Int_t j=0;j<ntracksRun;j++){
1116 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1117 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1118 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1119 Float_t tot = p[idxexToT];
1120 Float_t time = p[idxexTime]-p[idxexExTime];
1121 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1122 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1123 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1126 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1127 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1129 for(Int_t kk=0;kk<6;kk++){
1130 par[kk]=calibfunc->GetParameter(kk);
1131 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1134 if(strstr(optionSave,"save") && fileProf){
1135 TString profName=Form("Profile%06i",ii);
1136 TString timeTotName=Form("TimeTot%06i",ii);
1137 TString totName=Form("Tot%06i",ii);
1138 TString deltaName=Form("Delta%06i",ii);
1140 hSlewingProf->Write(profName);
1141 htimetot->Write(timeTotName);
1142 hToT->Write(totName);
1143 hdeltaTime->Write(deltaName);
1145 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii);
1146 calChannel->SetSlewPar(par);
1150 delete hSlewingProf;
1158 if(strstr(optionSave,"save")){
1163 WriteParOfflineOnCDB("TOF/Calib","valid");
1167 //-----------------------------------------------------------------------
1168 TH1F* AliTOFcalib::Profile(Int_t ich)
1172 Float_t p[MAXCHENTRIESSMALL];
1174 //fTree->SetBranchAddress("nentries",&nentries);
1175 //fTree->SetBranchAddress("TOFentries",p);
1176 fChain->SetBranchAddress("nentries",&nentries);
1177 fChain->SetBranchAddress("TOFentries",p);
1179 //Prepare histograms for Slewing Correction
1180 const Int_t knbinToT = 100;
1181 Int_t nbinTime = 200;
1182 Float_t minTime = -5.5; //ns
1183 Float_t maxTime = 5.5; //ns
1184 Float_t minToT = 0; //ns
1185 Float_t maxToT = 5.; //ns
1186 Float_t deltaToT = (maxToT-minToT)/knbinToT;
1187 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];
1188 Int_t n[knbinToT+1], nentrx[knbinToT+1];
1189 Double_t sigmaToT[knbinToT+1];
1190 for (Int_t i = 0; i < knbinToT+1 ; i++){
1208 TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
1209 Int_t ntracksRun = 0;
1210 TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT);
1211 for (Int_t irun=0;irun<fNruns;irun++){
1212 Int_t i = ich+irun*fNChannels;
1213 //fTree->GetEntry(i);
1214 fChain->GetEntry(i);
1215 ntracksRun=nentries/3;
1216 for (Int_t j=0;j<ntracksRun;j++){
1217 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1218 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1219 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1220 Float_t tot = p[idxexToT];
1221 Float_t time = p[idxexTime]-p[idxexExTime];
1222 Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1;
1223 if ((tot != 0) && ( time!= 0)){
1225 vTime2[nx]+=time*time;
1229 hSlewing->Fill(tot,time);
1233 Int_t nbinsToT=hSlewing->GetNbinsX();
1234 if (nbinsToT != knbinToT) {
1235 AliError("Profile :: incompatible numbers of bins");
1240 for (Int_t i=1;i<=nbinsToT;i++){
1242 n[usefulBins]+=nentrx[i];
1243 if (n[usefulBins]==0 && i == nbinsToT) {
1246 meanTime[usefulBins]+=vTime[i];
1247 meanTime2[usefulBins]+=vTime2[i];
1248 meanToT[usefulBins]+=vToT[i];
1249 meanToT2[usefulBins]+=vToT2[i];
1250 if (n[usefulBins]<10 && i!=nbinsToT) continue;
1251 mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
1252 mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
1253 sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1254 *(meanTime2[usefulBins]-meanTime[usefulBins]
1255 *meanTime[usefulBins]/n[usefulBins]));
1256 if ((1./n[usefulBins]/n[usefulBins]
1257 *(meanToT2[usefulBins]-meanToT[usefulBins]
1258 *meanToT[usefulBins]/n[usefulBins]))< 0) {
1259 AliError(" too small radical" );
1260 sigmaToT[usefulBins]=0;
1263 sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1264 *(meanToT2[usefulBins]-meanToT[usefulBins]
1265 *meanToT[usefulBins]/n[usefulBins]));
1270 for (Int_t i=0;i<usefulBins;i++){
1271 Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
1272 histo->Fill(mToT[i],mTime[i]);
1273 histo->SetBinError(binN,sigmaTime[i]);
1280 //----------------------------------------------------------------------------
1281 Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{
1283 // to determine the bins for ToT histo
1287 Int_t nbin = h->GetNbinsX();
1288 Int_t nentries = (Int_t)h->GetEntries();
1289 Float_t max = h->GetBinLowEdge(nbin);
1290 Int_t nusefulbins=0;
1292 // setting maxvalue of entries per bin
1293 if (nentries <= 60) maxcont = 2;
1294 else if (nentries <= 100) maxcont = 5;
1295 else if (nentries <= 500) maxcont = 10;
1297 for (Int_t j=1;j<=nbin;j++) {
1298 cont += (Int_t)h->GetBinContent(j);
1302 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1311 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1312 binsProfile[nusefulbins]=max;
1315 binsProfile[nusefulbins]=h->GetBinLowEdge(startBin);