X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=T0%2FAliT0CalibTimeEq.cxx;h=dbfb086ac3dc2217fed8fbecb90608173abf4fad;hb=220e801918a771088710682f67f894875afb81a3;hp=98d3807dd4687790b38770b1c62d77a9cdfde02d;hpb=593a6aab21d2df13316a190e01f71c3137e89cd9;p=u%2Fmrichter%2FAliRoot.git diff --git a/T0/AliT0CalibTimeEq.cxx b/T0/AliT0CalibTimeEq.cxx index 98d3807dd46..dbfb086ac3d 100644 --- a/T0/AliT0CalibTimeEq.cxx +++ b/T0/AliT0CalibTimeEq.cxx @@ -1,3 +1,4 @@ + /************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * @@ -39,7 +40,11 @@ ClassImp(AliT0CalibTimeEq) fRmsVertex(0) { // - + for(Int_t i=0; i<24; i++) { + fTimeEq[i] = 0; // Time Equalized for OCDB + fTimeEqRms[i] = -1; // RMS of Time Equalized for OCDB + for (Int_t ih=0; ih<5; ih++) fCFDvalue[i][ih] = 0; + } } //________________________________________________________________ @@ -53,6 +58,11 @@ AliT0CalibTimeEq::AliT0CalibTimeEq(const char* name):TNamed(), namst += name; SetName(namst.Data()); SetTitle(namst.Data()); + for(Int_t i=0; i<24; i++) { + fTimeEq[i] = 0; // Time Equalized for OCDB + fTimeEqRms[i] = -1; // RMS of Time Equalized for OCDB + for (Int_t ih=0; ih<5; ih++) fCFDvalue[i][ih] = 0; + } } //________________________________________________________________ @@ -63,7 +73,7 @@ AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calib // copy constructor SetName(calibda.GetName()); SetTitle(calibda.GetName()); - + ((AliT0CalibTimeEq &) calibda).Copy(*this); } @@ -74,6 +84,7 @@ AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda) SetName(calibda.GetName()); SetTitle(calibda.GetName()); + if (this != &calibda) (( AliT0CalibTimeEq &) calibda).Copy(*this); return *this; } @@ -100,8 +111,8 @@ void AliT0CalibTimeEq::Print(Option_t*) const printf("\n ---- PM Arrays ----\n\n"); printf(" Time delay CFD \n"); - for (Int_t i=0; i<24; i++) printf(" CFD %f ",fTimeEq[i]); - printf("\n Mean Vertex %f \n", fMeanVertex); + for (Int_t i=0; i<24; i++) + printf(" CFD %f diff %f \n",fCFDvalue[i][0],fTimeEq[i]); } @@ -113,7 +124,10 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys) meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0; Double_t rmsver=0; Int_t nent=0; + Int_t okdiff=0; + Int_t oktime=0; Bool_t ok=false; + // gFile = TFile::Open(filePhys); if(!gFile) { AliError("No input PHYS data found "); @@ -124,13 +138,46 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys) for (Int_t i=0; i<24; i++) { meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0; - TH1F *cfd = (TH1F*) gFile->Get(Form("CFD1minCFD%d",i+1)); + TH1F *cfd = (TH1F*) gFile->Get(Form("CFD1minCFD%d",i+1)); TH1F *cfdtime = (TH1F*) gFile->Get(Form("CFD%d",i+1)); - if(!cfd) AliWarning(Form("no Diff histograms collected by PHYS DA for channel %i", i)); - if(!cfdtime) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i)); + if(!cfd) { + AliWarning(Form("no Diff histograms collected by PHYS DA for channel %i", i)); + okdiff++; + if(okdiff<4) { + meandiff = 0; + sigmadiff = 0; + } + else + ok = false; + } + if(!cfdtime) { + AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i)); + oktime++; + if(oktime<4) { + meancfdtime = 0; + } + else + ok = false; + } if(cfd) { nent = Int_t(cfd->GetEntries()); - if(nent>500) { + if( nent<=50) { + okdiff++; + // printf(" pmt %i nent %i cfd->GetRMS() %f cfd->GetMean() %f \n", + // i, nent, cfd->GetRMS(), cfd->GetMean() ); + if(okdiff<4) { + meandiff = 0; + sigmadiff = 0; + } + else + { + // printf(" OK fsle:: pmt %i nent %i cfd->GetRMS() %f cfd->GetMean() %f \n", + // i, nent, cfd->GetRMS(), cfd->GetMean() ); + AliWarning(Form(" Not enouph data in PMT %i- PMT1: %i ", i, nent)); + ok = false; + } + } + if(nent>50) { if(cfd->GetRMS()>1.5 ) GetMeanAndSigma(cfd, meandiff, sigmadiff); if(cfd->GetRMS()<=1.5) @@ -138,164 +185,232 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys) meandiff = cfd->GetMean(); sigmadiff=cfd->GetRMS(); } - if(TMath::Abs(cfd->GetMean() - meandiff) >10 ) meandiff = cfd->GetMean(); + Int_t maxBin = cfd->GetMaximumBin(); + Double_t meanEstimate = cfd->GetBinCenter( maxBin); + if(TMath::Abs(meanEstimate - meandiff) > 20 ) meandiff = meanEstimate; } - else - { - ok=false; - AliWarning(Form(" Not enouph data in PMT %i- PMT1: %i ", i, nent)); - } - if(!cfd) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i)); } - // printf(" i = %d buf1 = %s\n", i, buf1); + if(cfdtime) { nent = Int_t(cfdtime->GetEntries()); - if(nent > 500 ) { //!!!!!!!!!! + if( nent<=50 ) { + oktime++; + if(oktime<4) { + meancfdtime = 0; + } + else + { + AliWarning(Form(" Not enouph data in PMT %i: %i ", i, nent)); + ok = false; + } + } + if(nent > 50 ) { //!!!!!!!!!! if(cfdtime->GetRMS()>1.5 ) GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime); if(cfdtime->GetRMS()<=1.5) { + if(cfdtime->GetRMS()==0 ||cfdtime->GetMean()==0 ) { + ok = false; + } meancfdtime = cfdtime->GetMean(); sigmacfdtime = cfdtime->GetRMS(); } - if(TMath::Abs(cfdtime->GetMean() - meancfdtime) >20 ) meancfdtime = cfdtime->GetMean(); + Int_t maxBin = cfdtime->GetMaximumBin(); + Double_t meanEstimate = cfdtime->GetBinCenter( maxBin); + if(TMath::Abs(meanEstimate - meancfdtime) > 20 ) meancfdtime = meanEstimate; } } - else - { - ok=false; - AliWarning(Form(" Not enouph data in PMT in CFD peak %i - %i ", i, nent)); - } - printf(" %i %f %f %f %f \n",i, meandiff, sigmadiff, meancfdtime, sigmacfdtime); SetTimeEq(i,meandiff); SetTimeEqRms(i,sigmadiff); SetCFDvalue(i,0,meancfdtime); if (cfd) delete cfd; if (cfdtime) delete cfdtime; - } - TH1F *ver = (TH1F*) gFile->Get("hVertex"); - if(!ver) AliWarning("no T0 histogram collected by PHYS DA "); + TH1F *ver = (TH1F*) gFile->Get("hVertex") ; if(ver) { meanver = ver->GetMean(); rmsver = ver->GetRMS(); } SetMeanVertex(meanver); SetRmsVertex(rmsver); - gFile->Close(); delete gFile; - } return ok; } //________________________________________________________________ -Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *timecdb, Float_t *cfdvalue, Int_t badpmt) +Int_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *timecdb, Float_t *cfdvalue, Int_t badpmt) { - // compute online equalized time + // fStatus implementation: + //ok means + // 1000 - can not open file + // for timediff + // 20 >3 histos are empty + // -11 low statistics oe empty histos in few channels; for these channels OCDB value will be written back WARNING + // for cfd + // 20 >2 histos are empty or with low statistic + // -11 if less 3 channels are empty or low statistics in few channels ;for these channels OCDB value will be written back WARNING + // + // compute offline equalized time Float_t meandiff, sigmadiff, meanver, meancfdtime, sigmacfdtime; meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0; - Double_t rmsver=0; Int_t nent=0; - Bool_t ok=false; + Int_t ok = 0; + Int_t okcfd=0; + TH1F *cfddiff = NULL; + TH1F *cfdtime = NULL; + TObjArray * tzeroObj = NULL; + gFile = TFile::Open(filePhys); if(!gFile) { AliError("No input PHYS data found "); + ok = 1000; return ok; } else { - meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0; - ok=true; - TDirectory *dr = (TDirectory*) gFile->Get("T0Calib"); - if (!dr ) { AliError("No input T0calib found "); - return ok; - } - TObjArray * TzeroObj = (TObjArray*) dr->Get("fTzeroObject"); + // TDirectory *dr = (TDirectory*) gFile->Get("T0Calib"); + tzeroObj = dynamic_cast(gFile->Get("T0Calib")); for (Int_t i=0; i<24; i++) { - printf("@@@ were in OCDB before %f \n", timecdb[i]); - if (i != badpmt) { - TH1F *cfddiff = (TH1F*)TzeroObj->At(i); - TH1F *cfdtime = (TH1F*)TzeroObj->At(i+24); - if(!cfddiff) AliWarning(Form("no Diff histograms collected by PHYS DA for channel %i", i)); - // printf(" i = %d buf1 = %s\n", i, buf1); - if(!cfdtime) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i)); - if(cfddiff) { - nent = Int_t(cfddiff->GetEntries()); - if(nent>500 ) { //!!!!! - if(cfddiff->GetRMS()>1.5 ) - GetMeanAndSigma(cfddiff, meandiff, sigmadiff); - if(cfddiff->GetRMS()<=1.5) - { - meandiff = cfddiff->GetMean(); - sigmadiff = cfddiff->GetRMS(); - } - if(TMath::Abs(cfddiff->GetMean() - meandiff) >10 ) meandiff = cfddiff->GetMean(); - + if (i != badpmt) { + if(tzeroObj) { + cfddiff = (TH1F*) tzeroObj->FindObject(Form("CFD1minCFD%d",i+1)); + cfdtime = (TH1F*)tzeroObj->FindObject(Form("CFD%d",i+1)); } - else + else { - ok=false; - AliWarning(Form(" Not enouph data in PMT %i- PMT1: %i ", i, nent)); + cfddiff = (TH1F*)gFile->Get(Form("CFD1minCFD%d",i+1)); + cfdtime = (TH1F*)gFile->Get(Form("CFD%d",i+1)); + } - } - if(cfdtime) { - nent = Int_t(cfdtime->GetEntries()); - if(nent>500 ) { //!!!!! - if(cfdtime->GetRMS()>1.5 ) - GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime); - if(cfdtime->GetRMS()<=1.5) + if(!cfddiff ) { + AliWarning(Form("no histograms collected by pass0 for diff channel %i\n", i)); + meandiff = timecdb[i]; + sigmadiff = 0; + } + if(cfddiff) { + nent = Int_t(cfddiff->GetEntries()); + if ( nent == 0 ) { + AliWarning(Form("no entries in histogram for diff channel %i\n", i)); + meandiff = timecdb[i]; + sigmadiff = 0; + } + if(nent<=100 && nent>0) { //!!!!! + AliWarning(Form(" Not enouph data in PMT %i- PMT1: %i \n", i, nent)); + meandiff = timecdb[i]; + sigmadiff = 0; + } + if(nent>=100 ) { //!!!!! { - meancfdtime = cfdtime->GetMean(); - sigmacfdtime=cfdtime->GetRMS(); + if(cfddiff->GetRMS()>1.5 ) + GetMeanAndSigma(cfddiff, meandiff, sigmadiff); + if(cfddiff->GetRMS()<=1.5) + { + meandiff = cfddiff->GetMean(); + sigmadiff = cfddiff->GetRMS(); + } + Int_t maxBin = cfddiff->GetMaximumBin(); + Double_t meanEstimate = cfddiff->GetBinCenter( maxBin); + if(TMath::Abs(meanEstimate - meandiff) > 20 ) meandiff = meanEstimate; } - if(TMath::Abs(cfdtime->GetMean() - meancfdtime) >20 ) meancfdtime = cfdtime->GetMean(); + } } - else - { - ok=false; - AliWarning(Form(" Not enouph data in PMT in CFD peak %i - %i ", i, nent)); + if(!cfdtime ) { + AliWarning(Form("no histograms collected by pass0 for time channel %i", i)); + meancfdtime = cfdvalue[i]; + okcfd++; + if(okcfd<2) { + meancfdtime = cfdvalue[i]; + // ok = -11; + } + else { + AliError(Form("no histograms collected by pass0 for time %i channels ", okcfd)); + if (tzeroObj) delete tzeroObj; + return 20; } + } + if(cfdtime) { + nent = Int_t(cfdtime->GetEntries()); + if (nent == 0 || + (cfdtime->GetRMS() == 0 || cfdtime->GetMean() ==0 ) ) + { + okcfd++; + if(okcfd<2) { + meancfdtime = cfdvalue[i]; + // ok = -11; + printf("!!!!bad data:: pmt %i nent%i RMS %f mean %f cdbtime %f \n", + i, nent, cfdtime->GetRMS(), cfdtime->GetMean(), cfdvalue[i] ); + } + else + { + printf("!!!!fatal data:: pmt %i nent%i RMS %f mean %f cdbtime %f \n", + i, nent, cfdtime->GetRMS(), cfdtime->GetMean(), cfdvalue[i]); + AliError(Form(" histograms collected by pass0 for time %i channels are empty", okcfd)); + if (tzeroObj) delete tzeroObj; + return 20; + } + } + + + if(nent<=100 && nent>0 ) + { + okcfd++; + AliWarning(Form(" Not enouph data in PMT in CFD peak %i - %i ", i, nent)); + meancfdtime = cfdvalue[i]; + // ok = -11; + printf("!!!!low statstics:: pmt %i nent%i RMS %f mean %f cdbtime %f \n", + i, nent, cfdtime->GetRMS(), cfdtime->GetMean(), cfdvalue[i]); + if (okcfd>2) { + ok = -11; + if (tzeroObj) delete tzeroObj; + return ok; + } + } + + if( nent>100 ) { //!!!!! + if(cfdtime->GetRMS()>1.5 ) + GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime); + if(cfdtime->GetRMS()<=1.5) + { + meancfdtime = cfdtime->GetMean(); + sigmacfdtime=cfdtime->GetRMS(); + } + Int_t maxBin = cfdtime->GetMaximumBin(); + Double_t meanEstimate = cfdtime->GetBinCenter( maxBin); + if(TMath::Abs(meanEstimate - meancfdtime) > 20 ) meancfdtime = meanEstimate; + } } - SetTimeEq(i,timecdb[i] + meandiff); + + SetTimeEq(i,meandiff); SetTimeEqRms(i,sigmadiff); - SetCFDvalue(i,0,cfdvalue[i] ); - if (cfddiff) delete cfddiff; - if (cfdtime) delete cfdtime; + SetCFDvalue(i,0, meancfdtime ); + if (cfddiff) cfddiff->Reset(); + if (cfdtime) cfdtime->Reset(); } //bad pmt - } - TH1F *ver = (TH1F*) gFile->Get("hVertex"); - if(!ver) AliWarning("no T0 histogram collected by PHYS DA "); - if(ver) { - meanver = ver->GetMean(); - rmsver = ver->GetRMS(); - } - SetMeanVertex(meanver); - SetRmsVertex(rmsver); - + } gFile->Close(); delete gFile; - } - return ok; - } + if (tzeroObj) delete tzeroObj; + return ok; +} //________________________________________________________________________ void AliT0CalibTimeEq::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma) { - const double window = 2.; //fit window - + const double window = 5.; //fit window double meanEstimate, sigmaEstimate; int maxBin; maxBin = hist->GetMaximumBin(); //position of maximum meanEstimate = hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum sigmaEstimate = hist->GetRMS(); + // sigmaEstimate = 10; TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate); fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate); - hist->Fit("fit","RQ","Q"); + hist->Fit("fit","QR",""); mean = (Float_t) fit->GetParameter(1); sigma = (Float_t) fit->GetParameter(2);