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.14 2007/06/06 16:26:30 arcelli
19 remove fall-back call to local CDB storage
21 Revision 1.13 2007/04/20 13:59:40 arcelli
22 make protections agains failed retrieval of the CDB object in a proper way
24 Revision 1.12 2007/03/23 11:31:16 arcelli
25 CDB Entry for TOF Reconstruction Parameters
27 Revision 1.11 2007/02/28 18:08:26 arcelli
28 Add protection against failed retrieval of the CDB cal object
30 Revision 1.10 2006/08/22 13:30:49 arcelli
31 removal of effective c++ warnings (C.Zampolli)
33 Revision 1.9 2006/04/20 22:30:50 hristov
34 Coding conventions (Annalisa)
36 Revision 1.8 2006/04/16 22:29:05 hristov
37 Coding conventions (Annalisa)
39 Revision 1.7 2006/04/16 20:12:46 hristov
40 Removing memory leak in case of cached CDB entries
42 Revision 1.6 2006/04/11 15:28:32 hristov
43 Checks on cache status before deleting calibration objects (A.Colla)
45 Revision 1.5 2006/04/05 08:35:38 hristov
46 Coding conventions (S.Arcelli, C.Zampolli)
48 Revision 1.4 2006/03/31 11:26:46 arcelli
49 changing CDB Ids according to standard convention
51 Revision 1.3 2006/03/28 14:57:02 arcelli
52 updates to handle new V5 geometry & some re-arrangements
54 Revision 1.2 2006/02/13 17:22:26 arcelli
57 Revision 1.1 2006/02/13 16:10:48 arcelli
58 Add classes for TOF Calibration (C.Zampolli)
60 author: Chiara Zampolli, zampolli@bo.infn.it
63 ///////////////////////////////////////////////////////////////////////////////
65 // class for TOF calibration //
67 ///////////////////////////////////////////////////////////////////////////////
80 #include "AliCDBEntry.h"
82 #include "AliCDBManager.h"
83 #include "AliCDBStorage.h"
84 #include "AliCDBMetaData.h"
85 #include "AliESDtrack.h"
89 #include "AliTOFcalib.h"
90 #include "AliTOFChannelOnline.h"
91 #include "AliTOFChannelOffline.h"
92 #include "AliTOFGeometry.h"
93 #include "AliTOFRecoParam.h"
96 extern TStyle *gStyle;
100 //_______________________________________________________________________
101 AliTOFcalib::AliTOFcalib():
102 TTask("AliTOFcalib",""),
106 fTOFSimCalOnline(0x0),
107 fTOFSimCalOffline(0x0),
113 //TOF Calibration Class ctor
114 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
116 //____________________________________________________________________________
118 AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
119 TTask("AliTOFcalib",""),
120 fNChannels(calib.fNChannels),
123 fTOFSimCalOnline(0x0),
124 fTOFSimCalOffline(0x0),
125 fTOFSimToT(calib.fTOFSimToT),
126 fkValidity(calib.fkValidity),
130 //TOF Calibration Class copy ctor
131 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
132 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
133 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
134 fTOFCalOnline->AddAt(calChOnline,iarray);
135 fTOFCalOffline->AddAt(calChOffline,iarray);
137 AliTOFChannelOnline * simCalChOnline = (AliTOFChannelOnline*)calib.fTOFSimCalOnline->At(iarray);
138 AliTOFChannelOffline * simCalChOffline = (AliTOFChannelOffline*)calib.fTOFSimCalOffline->At(iarray);
139 fTOFSimCalOnline->AddAt(simCalChOnline,iarray);
140 fTOFSimCalOffline->AddAt(simCalChOffline,iarray);
144 //____________________________________________________________________________
146 AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
148 //TOF Calibration Class assignment operator
149 this->fNChannels = calib.fNChannels;
150 this->fTOFSimToT = calib.fTOFSimToT;
151 this->fkValidity = calib.fkValidity;
152 this->fTree = calib.fTree;
153 this->fNruns = calib.fNruns;
154 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
155 AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray);
156 AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray);
157 this->fTOFCalOnline->AddAt(calChOnline,iarray);
158 this->fTOFCalOffline->AddAt(calChOffline,iarray);
159 AliTOFChannelOnline * simCalChOnline = (AliTOFChannelOnline*)calib.fTOFSimCalOnline->At(iarray);
160 AliTOFChannelOffline * simCalChOffline = (AliTOFChannelOffline*)calib.fTOFSimCalOffline->At(iarray);
161 this->fTOFSimCalOnline->AddAt(simCalChOnline,iarray);
162 this->fTOFSimCalOffline->AddAt(simCalChOffline,iarray);
167 //____________________________________________________________________________
169 AliTOFcalib::~AliTOFcalib()
171 //TOF Calibration Class dtor
172 if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
174 fTOFCalOnline->Clear();
175 delete fTOFCalOnline;
178 fTOFCalOffline->Clear();
179 delete fTOFCalOffline;
181 if (fTOFSimCalOnline){
182 fTOFSimCalOnline->Clear();
183 delete fTOFSimCalOnline;
185 if (fTOFSimCalOffline){
186 fTOFSimCalOffline->Clear();
187 delete fTOFSimCalOffline;
190 if (fTree!=0x0) delete fTree;
192 //_____________________________________________________________________________
193 void AliTOFcalib::CreateCalArrays(){
195 // creating arrays for online/offline calibration objs
197 fTOFCalOnline = new TObjArray(fNChannels);
198 fTOFCalOffline = new TObjArray(fNChannels);
199 fTOFCalOnline->SetOwner();
200 fTOFCalOffline->SetOwner();
201 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
202 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
203 AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline();
204 fTOFCalOnline->AddAt(calChOnline,iarray);
205 fTOFCalOffline->AddAt(calChOffline,iarray);
208 //_____________________________________________________________________________
209 void AliTOFcalib::CreateSimCalArrays(){
211 // creating arrays for simulation online/offline calibration objs
213 fTOFSimCalOnline = new TObjArray(fNChannels);
214 fTOFSimCalOffline = new TObjArray(fNChannels);
215 fTOFSimCalOnline->SetOwner();
216 fTOFSimCalOffline->SetOwner();
217 for (Int_t iarray = 0; iarray<fNChannels; iarray++){
218 AliTOFChannelOnline * simCalChOnline = new AliTOFChannelOnline();
219 AliTOFChannelOffline * simCalChOffline = new AliTOFChannelOffline();
220 fTOFSimCalOnline->AddAt(simCalChOnline,iarray);
221 fTOFSimCalOffline->AddAt(simCalChOffline,iarray);
224 //_____________________________________________________________________________
226 void AliTOFcalib::WriteParOnlineOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
228 //Write calibration parameters to the CDB
229 AliCDBManager *man = AliCDBManager::Instance();
230 Char_t *sel1 = "OnlineDelay" ; // to be consistent with TOFPreprocessor
232 sprintf(out,"%s/%s",sel,sel1);
233 AliCDBId id(out,minrun,maxrun);
234 AliCDBMetaData *md = new AliCDBMetaData();
235 md->SetResponsible("Chiara Zampolli");
236 if (!fTOFCalOnline) {
239 man->Put(fTOFCalOnline,id,md);
242 //_____________________________________________________________________________
244 void AliTOFcalib::WriteParOfflineOnCDB(Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun)
246 //Write calibration parameters to the CDB
247 AliCDBManager *man = AliCDBManager::Instance();
248 Char_t *sel1 = "ParOffline" ;
250 sprintf(out,"%s/%s",sel,sel1);
251 AliCDBId id(out,minrun,maxrun);
252 AliCDBMetaData *md = new AliCDBMetaData();
253 md->SetResponsible("Chiara Zampolli");
254 md->SetComment(validity);
255 man->Put(fTOFCalOffline,id,md);
258 //_____________________________________________________________________________
260 Bool_t AliTOFcalib::ReadParOnlineFromCDB(Char_t *sel, Int_t nrun)
262 //Read calibration parameters from the CDB
263 AliCDBManager *man = AliCDBManager::Instance();
264 Char_t *sel1 = "OnlineDelay" ;
266 sprintf(out,"%s/%s",sel,sel1);
267 if (!man->Get(out,nrun)) {
270 AliCDBEntry *entry = man->Get(out,nrun);
271 if(!entry->GetObject()){
275 fTOFCalOnline =(TObjArray*)entry->GetObject();
280 //_____________________________________________________________________________
282 Bool_t AliTOFcalib::ReadParOfflineFromCDB(Char_t *sel, Int_t nrun)
284 //Read calibration parameters from the CDB
285 AliCDBManager *man = AliCDBManager::Instance();
286 Char_t *sel1 = "ParOffline" ;
288 sprintf(out,"%s/%s",sel,sel1);
289 if (!man->Get(out,nrun)) {
292 AliCDBEntry *entry = man->Get(out,nrun);
293 if(!entry->GetObject()){
296 AliCDBMetaData * md = entry->GetMetaData();
297 fkValidity = md->GetComment();
298 fTOFCalOffline =(TObjArray*)entry->GetObject();
303 //_____________________________________________________________________________
304 void AliTOFcalib::WriteSimParOnlineOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, TObjArray *calOnline){
305 //Write Sim miscalibration parameters to the CDB
307 fTOFSimCalOnline=calOnline;
308 AliCDBManager *man = AliCDBManager::Instance();
309 AliCDBMetaData *md = new AliCDBMetaData();
310 md->SetResponsible("Chiara Zampolli");
311 Char_t *sel1 = "SimParOnline" ;
313 sprintf(out,"%s/%s",sel,sel1);
314 AliCDBId id1(out,minrun,maxrun);
315 man->Put(fTOFSimCalOnline,id1,md);
318 //_____________________________________________________________________________
319 void AliTOFcalib::WriteSimParOfflineOnCDB(Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun, TObjArray *calOffline, TH1F *histo){
320 //Write Sim miscalibration parameters to the CDB
323 fTOFSimCalOffline=calOffline;
324 AliCDBManager *man = AliCDBManager::Instance();
325 AliCDBMetaData *md = new AliCDBMetaData();
326 md->SetResponsible("Chiara Zampolli");
327 md->SetComment(validity);
328 Char_t *sel1 = "SimParOffline" ;
330 sprintf(out,"%s/%s",sel,sel1);
331 AliCDBId id1(out,minrun,maxrun);
332 man->Put(fTOFSimCalOffline,id1,md);
333 Char_t *sel2 = "SimHisto" ;
334 sprintf(out,"%s/%s",sel,sel2);
335 AliCDBMetaData *mdhisto = new AliCDBMetaData();
336 mdhisto->SetResponsible("Chiara Zampolli");
337 AliCDBId id2(out,minrun,maxrun);
338 man->Put(fTOFSimToT,id2,mdhisto);
342 //_____________________________________________________________________________
343 void AliTOFcalib::ReadSimParOnlineFromCDB(Char_t *sel, Int_t nrun)
345 //Read miscalibration parameters from the CDB
346 AliCDBManager *man = AliCDBManager::Instance();
350 Char_t *sel1 = "SimParOnline" ;
352 sprintf(out,"%s/%s",sel,sel1);
353 if (!man->Get(out,nrun)) {
354 AliFatal("Exiting, no CDB object (SimPar) found!!!");
357 AliCDBEntry *entry1 = man->Get(out,nrun);
358 if(!entry1->GetObject()){
359 AliFatal("Exiting, no CDB object (SimPar) found!!!");
362 TObjArray *cal =(TObjArray*)entry1->GetObject();
363 fTOFSimCalOnline=cal;
366 //_____________________________________________________________________________
367 void AliTOFcalib::ReadSimParOfflineFromCDB(Char_t *sel, Int_t nrun)
369 //Read miscalibration parameters from the CDB
370 AliCDBManager *man = AliCDBManager::Instance();
374 Char_t *sel1 = "SimParOffline" ;
376 sprintf(out,"%s/%s",sel,sel1);
377 if (!man->Get(out,nrun)) {
378 AliFatal("Exiting, no CDB object (SimPar) found!!!");
381 AliCDBEntry *entry1 = man->Get(out,nrun);
382 if(!entry1->GetObject()){
383 AliFatal("Exiting, no CDB object (SimPar) found!!!");
386 TObjArray *cal =(TObjArray*)entry1->GetObject();
387 AliCDBMetaData *md = (AliCDBMetaData*)entry1->GetMetaData();
388 fkValidity = md->GetComment();
389 fTOFSimCalOffline=cal;
393 Char_t *sel2 = "SimHisto" ;
394 sprintf(out,"%s/%s",sel,sel2);
395 if (!man->Get(out,nrun)) {
396 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
399 AliCDBEntry *entry2 = man->Get(out,nrun);
400 if(!entry2->GetObject()){
401 AliFatal("Exiting, no CDB object (SimHisto) found!!!");
404 TH1F *histo =(TH1F*)entry2->GetObject();
407 //_____________________________________________________________________________
408 void AliTOFcalib::WriteRecParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){
409 //Write reconstruction parameters to the CDB
411 AliCDBManager *man = AliCDBManager::Instance();
412 AliCDBMetaData *md = new AliCDBMetaData();
413 md->SetResponsible("Silvia Arcelli");
414 Char_t *sel1 = "RecPar" ;
416 sprintf(out,"%s/%s",sel,sel1);
417 AliCDBId id(out,minrun,maxrun);
418 man->Put(param,id,md);
421 //_____________________________________________________________________________
422 AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(Char_t *sel, Int_t nrun)
424 //Read reconstruction parameters from the CDB
425 AliCDBManager *man = AliCDBManager::Instance();
426 Char_t *sel1 = "RecPar" ;
428 sprintf(out,"%s/%s",sel,sel1);
429 if (!man->Get(out,nrun)) {
430 AliFatal("Exiting, no CDB object (RecPar) found!!!");
433 AliCDBEntry *entry = man->Get(out,nrun);
434 if(!entry->GetObject()){
435 AliFatal("Exiting, no CDB object (RecPar) found!!!");
439 AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject();
442 //-----------------------------------------------------------------------------
443 // Calibration methods
444 //-----------------------------------------------------------------------------
445 void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){
447 // creating the chain with the trees for calibration
448 // collecting them from reference data
449 // from minrun to maxrun
451 Float_t p[CHENTRIESSMALL];
453 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
454 fTree->Branch("nentries",&nentries,"nentries/I");
455 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
456 AliCDBManager *man = AliCDBManager::Instance();
457 AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT");
458 for (Int_t irun = minrun;irun<=maxrun;irun++){
459 AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun);
461 AliInfo(Form("No entry found for run %i",irun));
464 TTree *tree = new TTree();
465 tree = (TTree*)entry->GetObject();
466 tree->SetBranchAddress("nentries",&nentries);
467 tree->SetBranchAddress("TOFentries",p);
468 fTree->CopyEntries(tree);
473 AliInfo(Form("Number of runs being analyzed %i",fNruns));
475 //-----------------------------------------------------------------------------
476 void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
478 // creating the chain with the trees for calibration
479 // collecting them from the Grid
480 // from minrun to maxrun
482 Float_t p[CHENTRIESSMALL];
484 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
485 fTree->SetDirectory(0);
486 fTree->Branch("nentries",&nentries,"nentries/I");
487 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
488 AliInfo("connected to alien");
489 TGrid::Connect("alien://");
491 Char_t filename[100];
492 for (Int_t irun = minrun;irun<=maxrun;irun++){
493 sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
494 TFile *filegrid = TFile::Open(filename,"READ");
495 TTree *tree = (TTree*)filegrid->Get("T");
496 tree->SetBranchAddress("nentries",&nentries);
497 tree->SetBranchAddress("TOFentries",p);
498 fTree->CopyEntries(tree);
503 AliInfo(Form("Number of runs being analyzed %i",fNruns));
505 //-----------------------------------------------------------------------------
506 void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){
508 // creating the tree with the trees for calibration
509 // collecting them from reference data (from file)
510 // from minrun to maxrun
512 Float_t p[CHENTRIESSMALL];
514 fTree = new TTree("TOFCalib","Tree for TOF Calibration");
515 fTree->SetDirectory(0);
516 fTree->Branch("nentries",&nentries,"nentries/I");
517 fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
518 Char_t filename[100];
519 for (Int_t irun = minrun;irun<=maxrun;irun++){
520 sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun);
521 TFile *file = new TFile(filename,"READ");
522 TTree *tree = (TTree*)file->Get("T");
523 tree->SetBranchAddress("nentries",&nentries);
524 tree->SetBranchAddress("TOFentries",p);
525 fTree->CopyEntries(tree);
532 AliInfo(Form("Number of runs being analyzed %i",fNruns));
534 //-----------------------------------------------------------------------------
535 Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){
537 // calibrating summing more than one channels
538 // computing calibration parameters
540 // 0 -> everything was ok
541 // 1 -> no tree for calibration found
542 // 2 -> not enough statistics to perform calibration
543 // 3 -> problems with arrays
545 TH1::AddDirectory(0);
547 AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ;
548 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
549 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
551 Float_t p[CHENTRIESSMALL];
553 fTree->SetBranchAddress("nentries",&nentries);
554 fTree->SetBranchAddress("TOFentries",p);
556 Float_t ntracksTotalmean =0;
557 for (Int_t i=ichmin; i<ichmax; i++){
559 for (Int_t irun=0;irun<fNruns;irun++){
560 ientry = i+irun*fNChannels;
561 fTree->GetEntry(ientry);
562 Int_t ntracksRun=nentries/3;
563 ntracksTotalmean+=ntracksRun;
567 if (ntracksTotalmean < MEANENTRIES) {
568 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
572 //filling ToT and Time arrays
574 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
575 Float_t minToT = 0; // ns
576 Float_t maxToT = 4.88; // ns
578 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
579 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
580 Int_t ntracksTotal = 0;
581 Int_t ntracksRun = 0;
582 Double_t binsProfile[101]; // sized larger than necessary, the correct
583 // dim being set in the booking of the profile
586 for (Int_t i = ichmin;i<ichmax;i++){
588 for (Int_t irun=0;irun<fNruns;irun++){
589 ientry = i+irun*fNChannels;
590 fTree->GetEntry(ientry);
591 ntracksTotal+=nentries/3;
592 ntracksRun=nentries/3;
593 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun));
594 for (Int_t j=0;j<ntracksRun;j++){
595 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
596 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
597 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
598 Float_t tot = p[idxexToT];
599 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
600 meantime+=p[idxexTime]-p[idxexExTime];
605 nusefulbins = FindBins(hToT,&binsProfile[0]);
606 meantime/=ntracksTotal;
607 AliDebug(2, Form("meantime = %f",meantime));
609 for (Int_t j=1;j<=nusefulbins;j++) {
610 AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j]));
613 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
614 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
616 for (Int_t irun=0;irun<fNruns;irun++){
618 for (Int_t i=ichmin; i<ichmax; i++){
619 ientry = i+irun*fNChannels;
620 fTree->GetEntry(ientry);
621 ntracksRun=nentries/3;
622 for (Int_t j=0;j<ntracksRun;j++){
623 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
624 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
625 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
626 Float_t tot = p[idxexToT];
627 Float_t time = p[idxexTime]-p[idxexExTime];
628 AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
629 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
630 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
635 hSlewingProf->Fit("pol5",optionFit,"",0,4);
636 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
638 for(Int_t kk=0;kk<6;kk++){
639 par[kk]=calibfunc->GetParameter(kk);
640 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
643 if(strstr(optionSave,"save")){
644 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
646 TString profName=Form("Profile%06i_%06i",ichmin,ichmax);
647 TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax);
648 TString totName=Form("Tot%06i_%06i",ichmin,ichmax);
649 TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax);
650 hSlewingProf->Write(profName);
651 htimetot->Write(timeTotName);
652 hToT->Write(totName);
653 hdeltaTime->Write(deltaName);
668 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin);
669 calChannel->SetSlewPar(par);
670 WriteParOfflineOnCDB("TOF/Calib","valid",0,0);
673 //----------------------------------------------------------------------------
674 Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){
676 // computing calibration parameters for channel i
678 // 0 -> everything was ok
679 // 1 -> no tree for calibration found
680 // 2 -> not enough statistics to perform calibration
681 // 3 -> problems with arrays
683 TH1::AddDirectory(0);
685 AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ;
686 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
687 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
689 Float_t p[MAXCHENTRIESSMALL];
691 fTree->SetBranchAddress("nentries",&nentries);
692 fTree->SetBranchAddress("TOFentries",p);
694 Float_t ntracksTotal =0;
695 for (Int_t irun=0;irun<fNruns;irun++){
697 ientry = i+irun*fNChannels;
698 fTree->GetEntry(ientry);
699 ntracksTotal+=nentries/3;
702 if (ntracksTotal < MEANENTRIES) {
703 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
707 //filling ToT and Time arrays
709 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
710 Float_t minToT = 0; // ns
711 Float_t maxToT = 4.88; // ns
713 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
714 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
715 Int_t ntracksRun = 0;
716 Double_t binsProfile[101]; // sized larger than necessary, the correct
717 // dim being set in the booking of the profile
720 for (Int_t irun=0;irun<fNruns;irun++){
722 ientry = i+irun*fNChannels;
723 fTree->GetEntry(ientry);
724 ntracksRun=nentries/3;
725 AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun));
726 for (Int_t j=0;j<ntracksRun;j++){
727 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
728 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
729 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
730 Float_t tot = p[idxexToT];
731 meantime+=p[idxexTime]-p[idxexExTime];
732 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
737 nusefulbins = FindBins(hToT,&binsProfile[0]);
738 meantime/=ntracksTotal;
739 AliDebug(2,Form("meantime = %f",meantime));
741 for (Int_t j=1;j<=nusefulbins;j++) {
742 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
745 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
746 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
747 for (Int_t irun=0;irun<fNruns;irun++){
749 ientry = i+irun*fNChannels;
750 fTree->GetEntry(ientry);
751 ntracksRun=nentries/3;
752 for (Int_t j=0;j<ntracksRun;j++){
753 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
754 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
755 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
756 Float_t tot = p[idxexToT];
757 Float_t time = p[idxexTime]-p[idxexExTime];
758 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
759 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
760 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
764 hSlewingProf->Fit("pol5",optionFit,"",0,4);
765 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
767 for(Int_t kk=0;kk<6;kk++){
768 par[kk]=calibfunc->GetParameter(kk);
769 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
773 if(strstr(optionSave,"save")){
774 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
776 TString profName=Form("Profile%06i",i);
777 TString timeTotName=Form("TimeTot%06i",i);
778 TString totName=Form("Tot%06i",i);
779 TString deltaName=Form("Delta%06i",i);
780 hSlewingProf->Write(profName);
781 htimetot->Write(timeTotName);
782 hToT->Write(totName);
783 hdeltaTime->Write(deltaName);
798 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i);
799 calChannel->SetSlewPar(par);
800 WriteParOfflineOnCDB("TOF/Calib","valid",0,0);
803 //----------------------------------------------------------------------------
804 Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){
806 // calibrating an array of channels
807 // computing calibration parameters
809 // 0 -> everything was ok
810 // 1 -> no tree for calibration found
811 // 2 -> not enough statistics to perform calibration
812 // 3 -> problems with arrays
814 TH1::AddDirectory(0);
816 AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ;
817 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
818 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
819 for (Int_t ich=0; ich<nch; ich++){
821 AliInfo(Form("Calibrating channel = %i",i )) ;
823 Float_t p[MAXCHENTRIESSMALL];
825 fTree->SetBranchAddress("nentries",&nentries);
826 fTree->SetBranchAddress("TOFentries",p);
828 Float_t ntracksTotalmean =0;
829 for (Int_t ich=0; ich<nch; ich++){
832 for (Int_t irun=0;irun<fNruns;irun++){
833 ientry = i+irun*fNChannels;
834 fTree->GetEntry(ientry);
835 ntracksTotalmean+=nentries/3;
839 ntracksTotalmean/=nch;
840 if (ntracksTotalmean < MEANENTRIES) {
841 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
845 //filling ToT and Time arrays
847 Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps
848 Float_t minToT = 0; // ns
849 Float_t maxToT = 4.88; // ns
850 TFile * fileProf=0x0;
851 if(strstr(optionSave,"save")){
852 fileProf = new TFile("TOFCalibSave.root","recreate");
854 for (Int_t ich=0; ich<nch; ich++) {
855 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
856 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
857 Double_t binsProfile[101]; // sized larger than necessary, the correct
858 // dim being set in the booking of the profile
859 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
860 Int_t ntracksTotal = 0;
861 Int_t ntracksRun = 0;
865 for (Int_t irun=0;irun<fNruns;irun++){
866 i = ch[ich]+irun*fNChannels;
867 AliDebug(2,Form("Calibrating channel %i",i));
869 ntracksTotal+=nentries/3;
871 if (ntracksTotal < MEANENTRIES) {
872 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal));
876 for (Int_t irun=0;irun<fNruns;irun++){
877 Int_t i = ch[ich]+irun*fNChannels;
879 ntracksRun=nentries/3;
880 for (Int_t j=0;j<ntracksRun;j++){
881 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
882 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
883 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
884 Float_t tot = p[idxexToT];
885 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
886 meantime+=p[idxexTime]-p[idxexExTime];
891 nusefulbins = FindBins(hToT,&binsProfile[0]);
892 meantime/=ntracksTotal;
893 for (Int_t j=1;j<=nusefulbins;j++) {
894 AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j]));
897 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
898 for (Int_t irun=0;irun<fNruns;irun++){
899 Int_t i = ch[ich]+irun*fNChannels;
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",0,0);
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);
976 for (Int_t irun=0;irun<fNruns;irun++){
977 Int_t i = ich+irun*fNChannels;
979 ntracksTotal+=nentries/3;
982 if (ntracksTotal < MEANENTRIES) {
983 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal));
987 TH1F * hProf = new TH1F();
988 hProf = Profile(ich);
989 hProf->Fit("pol5",optionFit,"",0,4);
990 TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5");
992 for(Int_t kk=0;kk<6;kk++){
993 par[kk]=calibfunc->GetParameter(kk);
994 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
997 if(strstr(optionSave,"save")){
998 TFile * fileProf = new TFile("TOFCalibSave.root","recreate");
1000 TString profName=Form("Profile%06i",ich);
1001 hProf->Write(profName);
1009 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich);
1010 calChannel->SetSlewPar(par);
1011 WriteParOfflineOnCDB("TOF/Calib","valid",0,0);
1014 //----------------------------------------------------------------------------
1015 Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){
1017 // calibrating the whole TOF
1018 // computing calibration parameters
1020 // 0 -> everything was ok
1021 // 1 -> no tree for calibration found
1022 // 2 -> not enough statistics to perform calibration
1023 // 3 -> problems with arrays
1025 TH1::AddDirectory(0);
1027 AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ;
1028 AliInfo(Form("Option for Saving histos = %s",optionSave )) ;
1029 AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ;
1031 TFile * fileProf=0x0;
1032 if(strstr(optionSave,"save")){
1033 fileProf = new TFile("TOFCalibSave.root","recreate");
1036 Float_t p[MAXCHENTRIESSMALL];
1038 fTree->SetBranchAddress("nentries",&nentries);
1039 fTree->SetBranchAddress("TOFentries",p);
1041 Float_t ntracksTotalmean =0;
1042 for (Int_t ii=0; ii<fNChannels; ii++){
1043 for (Int_t irun=0;irun<fNruns;irun++){
1044 Int_t i = ii+irun*fNChannels;
1046 ntracksTotalmean+=nentries/3;
1050 ntracksTotalmean/=fNChannels;
1051 if (ntracksTotalmean < MEANENTRIES) {
1052 AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean));
1056 //filling ToT and Time arrays
1058 Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps
1059 Float_t minToT = 0; // ns
1060 Float_t maxToT = 4.88;// ns
1061 for (Int_t ii=0; ii<fNChannels; ii++) {
1062 TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT);
1063 TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4);
1064 TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10);
1065 if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii));
1067 Int_t nusefulbins=0;
1068 Double_t binsProfile[101]; // sized larger than necessary, the correct
1069 // dim being set in the booking of the profile
1070 Int_t ntracksRun = 0;
1071 Int_t ntracksTotal = 0;
1072 for (Int_t irun=0;irun<fNruns;irun++){
1073 Int_t i = ii+irun*fNChannels;
1075 ntracksTotal+=nentries/3;
1077 if (ntracksTotal < MEANENTRIES) {
1078 AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal));
1082 for (Int_t irun=0;irun<fNruns;irun++){
1083 Int_t i = ii+irun*fNChannels;
1085 ntracksRun=nentries/3;
1086 for (Int_t j=0;j<ntracksRun;j++){
1087 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1088 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1089 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1090 Float_t tot = p[idxexToT];
1091 hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]);
1092 meantime+=p[idxexTime]-p[idxexExTime];
1096 nusefulbins = FindBins(hToT,&binsProfile[0]);
1097 meantime/=ntracksTotal;
1098 for (Int_t j=0;j<nusefulbins;j++) {
1099 AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j]));
1101 TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!!
1102 for (Int_t irun=0;irun<fNruns;irun++){
1103 Int_t i = ii+irun*fNChannels;
1105 ntracksRun=nentries/3;
1106 for (Int_t j=0;j<ntracksRun;j++){
1107 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1108 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1109 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1110 Float_t tot = p[idxexToT];
1111 Float_t time = p[idxexTime]-p[idxexExTime];
1112 AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime));
1113 hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above
1114 htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above
1117 hSlewingProf->Fit("pol5",optionFit,"",1,4);
1118 TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5");
1120 for(Int_t kk=0;kk<6;kk++){
1121 par[kk]=calibfunc->GetParameter(kk);
1122 AliDebug(2,Form("parameter %i = %f",kk,par[kk]));
1125 if(strstr(optionSave,"save") && fileProf){
1126 TString profName=Form("Profile%06i",ii);
1127 TString timeTotName=Form("TimeTot%06i",ii);
1128 TString totName=Form("Tot%06i",ii);
1129 TString deltaName=Form("Delta%06i",ii);
1131 hSlewingProf->Write(profName);
1132 htimetot->Write(timeTotName);
1133 hToT->Write(totName);
1134 hdeltaTime->Write(deltaName);
1136 AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii);
1137 calChannel->SetSlewPar(par);
1141 delete hSlewingProf;
1149 if(strstr(optionSave,"save")){
1154 WriteParOfflineOnCDB("TOF/Calib","valid",0,0);
1158 //-----------------------------------------------------------------------
1159 TH1F* AliTOFcalib::Profile(Int_t ich)
1163 Float_t p[MAXCHENTRIESSMALL];
1165 fTree->SetBranchAddress("nentries",&nentries);
1166 fTree->SetBranchAddress("TOFentries",p);
1168 //Prepare histograms for Slewing Correction
1169 const Int_t knbinToT = 100;
1170 Int_t nbinTime = 200;
1171 Float_t minTime = -5.5; //ns
1172 Float_t maxTime = 5.5; //ns
1173 Float_t minToT = 0; //ns
1174 Float_t maxToT = 5.; //ns
1175 Float_t deltaToT = (maxToT-minToT)/knbinToT;
1176 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];
1177 Int_t n[knbinToT+1], nentrx[knbinToT+1];
1178 Double_t sigmaToT[knbinToT+1];
1179 for (Int_t i = 0; i < knbinToT+1 ; i++){
1197 TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
1198 Int_t ntracksRun = 0;
1199 TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT);
1200 for (Int_t irun=0;irun<fNruns;irun++){
1201 Int_t i = ich+irun*fNChannels;
1203 ntracksRun=nentries/3;
1204 for (Int_t j=0;j<ntracksRun;j++){
1205 Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT;
1206 Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME;
1207 Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID;
1208 Float_t tot = p[idxexToT];
1209 Float_t time = p[idxexTime]-p[idxexExTime];
1210 Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1;
1211 if ((tot != 0) && ( time!= 0)){
1213 vTime2[nx]+=time*time;
1217 hSlewing->Fill(tot,time);
1221 Int_t nbinsToT=hSlewing->GetNbinsX();
1222 if (nbinsToT != knbinToT) {
1223 AliError("Profile :: incompatible numbers of bins");
1228 for (Int_t i=1;i<=nbinsToT;i++){
1230 n[usefulBins]+=nentrx[i];
1231 if (n[usefulBins]==0 && i == nbinsToT) {
1234 meanTime[usefulBins]+=vTime[i];
1235 meanTime2[usefulBins]+=vTime2[i];
1236 meanToT[usefulBins]+=vToT[i];
1237 meanToT2[usefulBins]+=vToT2[i];
1238 if (n[usefulBins]<10 && i!=nbinsToT) continue;
1239 mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
1240 mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
1241 sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1242 *(meanTime2[usefulBins]-meanTime[usefulBins]
1243 *meanTime[usefulBins]/n[usefulBins]));
1244 if ((1./n[usefulBins]/n[usefulBins]
1245 *(meanToT2[usefulBins]-meanToT[usefulBins]
1246 *meanToT[usefulBins]/n[usefulBins]))< 0) {
1247 AliError(" too small radical" );
1248 sigmaToT[usefulBins]=0;
1251 sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
1252 *(meanToT2[usefulBins]-meanToT[usefulBins]
1253 *meanToT[usefulBins]/n[usefulBins]));
1258 for (Int_t i=0;i<usefulBins;i++){
1259 Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
1260 histo->Fill(mToT[i],mTime[i]);
1261 histo->SetBinError(binN,sigmaTime[i]);
1268 //----------------------------------------------------------------------------
1269 Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{
1271 // to determine the bins for ToT histo
1275 Int_t nbin = h->GetNbinsX();
1276 Int_t nentries = (Int_t)h->GetEntries();
1277 Float_t max = h->GetBinLowEdge(nbin);
1278 Int_t nusefulbins=0;
1280 // setting maxvalue of entries per bin
1281 if (nentries <= 60) maxcont = 2;
1282 else if (nentries <= 100) maxcont = 5;
1283 else if (nentries <= 500) maxcont = 10;
1285 for (Int_t j=1;j<=nbin;j++) {
1286 cont += (Int_t)h->GetBinContent(j);
1290 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1299 binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin);
1300 binsProfile[nusefulbins]=max;
1303 binsProfile[nusefulbins]=h->GetBinLowEdge(startBin);