- for(Int_t i=0;i<10;i++){
- t0maker->DefineT0("all",fPtCutMin[i],fPtCutMax[i]);
- t0tof[0] = t0maker->GetResult(0);
- t0tof[1] = t0maker->GetResult(1);
- t0tof[2] = t0maker->GetResult(2);
- t0tof[3] = t0maker->GetResult(3);
- fT0pt[i] =-1000*t0tof[0]; // best t0
- fT0ptSigma[i] =1000*t0tof[1]; // sigma best t0
-
- if(fT0ptSigma[i] < sigmaFill && fT0ptSigma[i] < fTimeResolution * 1.2 && TMath::Abs(fT0pt[i] - t0fill) < 500){
- // Ok T0
+ if(fCalculated[7] < 100){
+ for(Int_t i=0;i<fNmomBins;i++){
+ t0maker->DefineT0("all",fPIDesd->GetTOFResponse().GetMinMom(i),fPIDesd->GetTOFResponse().GetMaxMom(i));
+ t0tof[0] = t0maker->GetResult(0);
+ t0tof[1] = t0maker->GetResult(1);
+ t0tof[2] = t0maker->GetResult(2);
+ t0tof[3] = t0maker->GetResult(3);
+
+
+ Float_t t0bin =-1000*t0tof[0]; // best t0
+ Float_t t0binRes =1000*t0tof[1]; // sigma best t0
+
+ if(t0binRes < sigmaFill && t0binRes < fTimeResolution * 1.2 && TMath::Abs(t0bin - t0fill) < 500){
+ // Ok T0
+ if(t0sigma < 1000){
+ Double_t w1 = 1./t0sigma/t0sigma;
+ Double_t w2 = 1./t0binRes/t0binRes;
+
+ Double_t wtot = w1+w2;
+
+ t0bin = (w1*t0time + w2*t0bin) / wtot;
+ t0binRes = TMath::Sqrt(1./wtot);
+ }
+ }
+ else{
+ t0bin = t0fill;
+ t0binRes = sigmaFill;
+ if(t0sigma < 1000){
+ t0bin = t0time;
+ t0binRes= t0sigma;
+ }
+ }
+ fPIDesd->GetTOFResponse().SetT0bin(i,t0bin);
+ fPIDesd->GetTOFResponse().SetT0binRes(i,t0binRes);