+}
+//______________________________________________________________________________________
+Bool_t AliTRDCalibraFit::AnalyseExbAltFit(AliTRDCalibraExbAltFit *calivdli)
+{
+ //
+ // The linear method
+ //
+
+ fStatisticMean = 0.0;
+ fNumberFit = 0;
+ fNumberFitSuccess = 0;
+ fNumberEnt = 0;
+ if(!InitFitExbAlt()) return kFALSE;
+
+
+ for(Int_t idet = 0; idet < 540; idet++){
+
+
+ //printf("detector number %d\n",idet);
+
+ // Take the result
+ TVectorD param(3);
+ TVectorD error(3);
+ fEntriesCurrent = 0;
+ fCountDet = idet;
+ Bool_t here = calivdli->GetParam(idet,¶m);
+ Bool_t heree = calivdli->GetError(idet,&error);
+ //printf("here %d and heree %d\n",here, heree);
+ if(heree) {
+ fEntriesCurrent = (Int_t) error[2];
+ fNumberEnt++;
+ }
+ //printf("Number of entries %d\n",fEntriesCurrent);
+ // Nothing found or not enough statistic
+ if((!heree) || (!here) || (fEntriesCurrent <= fMinEntries)) {
+ NotEnoughStatisticExbAlt();
+ continue;
+ }
+ //param.Print();
+ //error.Print();
+ //Statistics
+ fNumberFit++;
+ fStatisticMean += fEntriesCurrent;
+
+ // Statistics
+ fNumberFitSuccess ++;
+
+ // Put the fCurrentCoef
+ if(TMath::Abs(param[2])>0.0001){
+ fCurrentCoef2[0] = -param[1]/2/param[2];
+ fCurrentCoefE2 = 0;//error[1];
+ }else{
+ fCurrentCoef2[0] = 100;
+ fCurrentCoefE2 = 0;//error[1];
+ }
+
+ // Fill
+ FillInfosFitExbAlt();
+
+ }
+ // Mean Statistics
+ if (fNumberFit > 0) {
+ AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
+ }
+ else {
+ AliInfo(Form("There are %d with at least one entries. There is no fit!",fNumberEnt));
+ }
+ delete fDebugStreamer;
+ fDebugStreamer = 0x0;
+ return kTRUE;
+
+}
+//____________Functions fit Online CH2d________________________________________
+void AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall)
+{
+ //
+ // The linear method
+ //
+
+ // Get the mean vdrift and exb used
+ Double_t meanvdriftused = 0.0;
+ Double_t meanexbused = 0.0;
+ Double_t counterdet = 0.0;
+ if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) {
+ vdriftoverall = -100.0;
+ exboverall = 100.0;
+ return;
+ }
+
+ // Add histos
+
+ TH2S *linearfitterhisto = 0x0;
+
+ for(Int_t idet = 0; idet < 540; idet++){
+
+ TH2S * u = calivdli->GetLinearFitterHistoForce(idet);
+ Double_t detectorentries = u->Integral();
+ meanvdriftused += fCalDetVdriftUsed->GetValue(idet)*detectorentries;
+ meanexbused += fCalDetExBUsed->GetValue(idet)*detectorentries;
+ counterdet += detectorentries;
+
+ //printf("detectorentries %f\n",detectorentries);
+
+ //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether detector %d, vdrift %f and exB %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCalDetExBUsed->GetValue(idet));
+
+ if(idet == 0) linearfitterhisto = u;
+ else linearfitterhisto->Add(u);
+
+ }
+ if(counterdet > 0.0){
+ meanvdriftused = meanvdriftused/counterdet;
+ meanexbused = meanexbused/counterdet;
+ }
+ else {
+ vdriftoverall = -100.0;
+ exboverall = 100.0;
+ return;
+ }
+
+
+ //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether MEAN vdrift %f and exB %f\n",meanvdriftused,meanexbused);
+
+ // Fit
+
+ Int_t entries = 0;
+ TAxis *xaxis = linearfitterhisto->GetXaxis();
+ TAxis *yaxis = linearfitterhisto->GetYaxis();
+ TLinearFitter linearfitter = TLinearFitter(2,"pol1");
+ //printf("test\n");
+ Double_t integral = linearfitterhisto->Integral();
+ //printf("Integral is %f\n",integral);
+ Bool_t securitybreaking = kFALSE;
+ if(TMath::Abs(integral-1199) < 0.00001) securitybreaking = kTRUE;
+ for(Int_t ibinx = 0; ibinx < linearfitterhisto->GetNbinsX(); ibinx++){
+ for(Int_t ibiny = 0; ibiny < linearfitterhisto->GetNbinsY(); ibiny++){
+ if(linearfitterhisto->GetBinContent(ibinx+1,ibiny+1)>0){
+ Double_t x = xaxis->GetBinCenter(ibinx+1);
+ Double_t y = yaxis->GetBinCenter(ibiny+1);
+
+ for(Int_t k = 0; k < (Int_t)linearfitterhisto->GetBinContent(ibinx+1,ibiny+1); k++){
+ if(!securitybreaking){
+ linearfitter.AddPoint(&x,y);
+ entries++;
+ }
+ else {
+ if(entries< 1198){
+ linearfitter.AddPoint(&x,y);
+ entries++;
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+ //printf("AnalyseLinearFittersAllTogether::Find %d entries\n",entries);
+ //printf("Minstats %d\n",fMinEntries);
+
+
+
+ // Eval the linear fitter
+ if(entries > fMinEntries){
+ TVectorD par = TVectorD(2);
+ //printf("Fit\n");
+ if((linearfitter.EvalRobust(0.8)==0)) {
+ //printf("Take the param\n");
+ linearfitter.GetParameters(par);
+ //printf("Done\n");
+ //par.Print();
+ //printf("Finish\n");
+ // Put the fCurrentCoef
+ fCurrentCoef[0] = -par[1];
+ // here the database must be the one of the reconstruction for the lorentz angle....
+ if(fCurrentCoef[0] > 0.0) fCurrentCoef2[0] = (par[0]+meanvdriftused*meanexbused)/fCurrentCoef[0];
+ else fCurrentCoef2[0] = 100.0;
+
+ }
+ else {
+
+ fCurrentCoef[0] = -100.0;
+ fCurrentCoef2[0] = 100.0;
+
+ }
+
+
+ }
+ else {
+
+ fCurrentCoef[0] = -100.0;
+ fCurrentCoef2[0] = 100.0;
+
+ }
+
+ vdriftoverall = fCurrentCoef[0];
+ exboverall = fCurrentCoef2[0];
+
+
+ delete linearfitterhisto;
+ delete fDebugStreamer;
+ fDebugStreamer = 0x0;
+