From 6aafa7ea865a8b7a1ac0b15f6bb21ba9948352dc Mon Sep 17 00:00:00 2001 From: cblume Date: Wed, 9 Dec 2009 10:56:39 +0000 Subject: [PATCH] a/ AliTRDCalibraFillHisto.cxx .h: Trying to fix the DAQ algorithm Improvement for the speed offline/HLT calibration b/ AliTRDCalibraFit.cxx .h Trying to fix the DAQ algorithm c/ AliTRDPreprocessor.cxx .h: Trying to fix the DAQ algorithm --- TRD/AliTRDCalibraFillHisto.cxx | 70 ++++++--- TRD/AliTRDCalibraFillHisto.h | 8 + TRD/AliTRDCalibraFit.cxx | 262 ++++++++++++++++++++++++++++++--- TRD/AliTRDCalibraFit.h | 167 ++++++++++----------- TRD/AliTRDPreprocessor.cxx | 10 +- TRD/TRDVDRIFTda.cxx | 2 +- 6 files changed, 392 insertions(+), 127 deletions(-) diff --git a/TRD/AliTRDCalibraFillHisto.cxx b/TRD/AliTRDCalibraFillHisto.cxx index 48e5dfc916f..82e0f721cb1 100644 --- a/TRD/AliTRDCalibraFillHisto.cxx +++ b/TRD/AliTRDCalibraFillHisto.cxx @@ -142,6 +142,10 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto() ,fROBPrevious(-1) ,fNumberClusters(1) ,fNumberClustersf(30) + ,fNumberClustersProcent(0.5) + ,fThresholdClustersDAQ(120.0) + ,fNumberRowDAQ(2) + ,fNumberColDAQ(4) ,fProcent(6.0) ,fDifference(17) ,fNumberTrack(0) @@ -210,6 +214,10 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c) ,fROBPrevious(c.fROBPrevious) ,fNumberClusters(c.fNumberClusters) ,fNumberClustersf(c.fNumberClustersf) + ,fNumberClustersProcent(c.fNumberClustersProcent) + ,fThresholdClustersDAQ(c.fThresholdClustersDAQ) + ,fNumberRowDAQ(c.fNumberRowDAQ) + ,fNumberColDAQ(c.fNumberColDAQ) ,fProcent(c.fProcent) ,fDifference(c.fDifference) ,fNumberTrack(c.fNumberTrack) @@ -370,7 +378,7 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos(Int_t nboftimebin) if(!fNormalizeNbOfCluster) fRelativeScale = 20.0; else fRelativeScale = 1.18; fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.5*fTimeMax); + fNumberClusters = (Int_t)(fNumberClustersProcent*fTimeMax); // Init linear fitter if(!fLinearFitterTracklet) { @@ -919,6 +927,15 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track //////////////////////////// Int_t nbli = 0; AliTRDcluster *cl = 0x0; + ////////////////////////////// + // Check no shared clusters + ////////////////////////////// + for(int icc=AliTRDseedV1::kNtb; iccGetClusters(icc))) crossrow = 1; + } + ////////////////////////////////// + // Loop clusters + ////////////////////////////////// for(int ic=0; icGetClusters(ic))) continue; if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue; @@ -934,12 +951,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track fLinearFitterTracklet->AddPoint(&timeis,ycluster,1); nbli++; - ////////////////////////////// - // Check no shared clusters - ////////////////////////////// - for(int icc=AliTRDseedV1::kNtb; iccGetClusters(icc))) crossrow = 1; - } + } //////////////////////////////////// @@ -2365,7 +2377,7 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo //baseline = rawStream->GetCommonAdditive(); // common additive baseline fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.6*fTimeMax); + fNumberClusters = (Int_t)(fNumberClustersProcent*fTimeMax); Int_t *signal = rawStream->GetSignals(); // current ADC signal @@ -2431,7 +2443,7 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.6*fTimeMax); + fNumberClusters = (Int_t)(fNumberClustersProcent*fTimeMax); Int_t *signal = rawStream->GetSignals(); // current ADC signal Int_t col = rawStream->GetCol(); Int_t row = rawStream->GetRow(); @@ -2544,9 +2556,9 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){ for (Int_t ic = 2; ic <= 142; ic++) { Double_t integral = 0; - for (Int_t ishiftR = 0; ishiftR < 2; ishiftR++) + for (Int_t ishiftR = 0; ishiftR < fNumberRowDAQ; ishiftR++) { - for (Int_t ishiftC = -2; ishiftC < 2; ishiftC++) + for (Int_t ishiftC = -fNumberColDAQ; ishiftC < fNumberColDAQ; ishiftC++) { if (ir + ishiftR >= 1 && ir + ishiftR <= 16 && ic + ishiftC >= 1 && ic + ishiftC <= 144) @@ -2570,7 +2582,12 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){ //printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax); - if((imaxRow == 0) || (imaxCol == 0)) { + //if((imaxRow == 0) || (imaxRow >= 15) || (imaxCol <= 3) || (imaxCol >= 140)) { + // used=1; + // return used; + // } + + if(((imaxRow + fNumberRowDAQ) > 16) || (imaxRow == 0) || ((imaxCol - fNumberColDAQ) <= 1) || ((imaxCol + fNumberColDAQ) >= 144)) { used=1; return used; } @@ -2582,21 +2599,25 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){ // //////////////////////////////////////////////////// - for (Int_t ir = imaxRow - 1; ir < imaxRow + 1; ir++) + for (Int_t ishiftR = 0; ishiftR < fNumberRowDAQ; ishiftR++) { - for (Int_t ic = imaxCol - 2; ic < imaxCol + 2; ic++) + for (Int_t ishiftC = -fNumberColDAQ; ishiftC < fNumberColDAQ; ishiftC++) { - for(Int_t it = 0; it < fTimeMax; it++){ - sum[it] += phvalue[ir][ic][it]; - } - }//ic - }//ir + if (imaxRow + ishiftR >= 1 && imaxRow + ishiftR <= 16 && + imaxCol + ishiftC >= 1 && imaxCol + ishiftC <= 144) + { + for(Int_t it = 0; it < fTimeMax; it++){ + sum[it] += phvalue[imaxRow + ishiftR-1][imaxCol + ishiftC-1][it]; + } + } + } // col shift + }// row shift Int_t nbcl = 0; Double_t sumcharge = 0.0; for(Int_t it = 0; it < fTimeMax; it++){ sumcharge += sum[it]; - if(sum[it] > 20.0) nbcl++; + if(sum[it] > fThresholdClustersDAQ) nbcl++; } @@ -2629,6 +2650,7 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){ "clustera="< 100.0) used = 1; if(nbcl < fNumberClusters) used = 1; if(nbcl > fNumberClustersf) used = 1; @@ -2648,8 +2671,12 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){ for(Int_t it = 0; it < fTimeMax; it++){ if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); else{ - if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); + if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); } + //if(fFillWithZero) UpdateDAQ(0,0,0,it,sum[it],fTimeMax); + //else{ + // if(sum[it] > 0.0) UpdateDAQ(0,0,0,it,sum[it],fTimeMax); + //} } @@ -3192,4 +3219,3 @@ void AliTRDCalibraFillHisto::AnalyseLinearFitter() } } } - diff --git a/TRD/AliTRDCalibraFillHisto.h b/TRD/AliTRDCalibraFillHisto.h index ba1b32c47f1..4efadda8956 100644 --- a/TRD/AliTRDCalibraFillHisto.h +++ b/TRD/AliTRDCalibraFillHisto.h @@ -135,6 +135,10 @@ class AliTRDCalibraFillHisto : public TObject { void SetDifference(Short_t difference) { fDifference = difference; } void SetNumberClusters(Short_t numberClusters) { if(numberClusters >= 0) fNumberClusters = numberClusters; } void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; } + void SetNumberClustersProcent(Float_t numberClustersProcent) { fNumberClustersProcent = numberClustersProcent; } + void SetThresholdClustersDAQ(Float_t thresholdClustersDAQ) { fThresholdClustersDAQ = thresholdClustersDAQ; } + void SetNumberRowDAQ(Short_t numberRowDAQ) { fNumberRowDAQ = numberRowDAQ; } + void SetNumberColDAQ(Short_t numberColDAQ) { fNumberColDAQ = numberColDAQ; } void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; } void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; } void SetNumberGroupsPRF(Short_t numberGroupsPRF); @@ -202,6 +206,10 @@ AliTRDCalibraVector *GetCalibraVector() const { r Int_t fROBPrevious; // Change of ROB Short_t fNumberClusters; // Minimum number of clusters in the tracklets Short_t fNumberClustersf; // Maximum number of clusters in the tracklets + Float_t fNumberClustersProcent; // Procent of number of time bins for fNumberClusters + Float_t fThresholdClustersDAQ; // Threshold clusters for DAQ algorithm + Short_t fNumberRowDAQ; // Size of the spot for DAQ algorithm + Short_t fNumberColDAQ; // Size of the spot for DAQ algorithm Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH) Int_t fNumberTrack; // How many tracks could be used (Debug for the moment) diff --git a/TRD/AliTRDCalibraFit.cxx b/TRD/AliTRDCalibraFit.cxx index ec1ecd1a374..377b9fbd775 100644 --- a/TRD/AliTRDCalibraFit.cxx +++ b/TRD/AliTRDCalibraFit.cxx @@ -556,23 +556,34 @@ Bool_t AliTRDCalibraFit::AnalysePH(const TProfile2D *ph) const char *name = ph->GetTitle(); if(!SetModeCalibration(name,1)) return kFALSE; + //printf("Mode calibration set\n"); + // Number of Xbins (detectors or groups of pads) Int_t nbins = ph->GetNbinsX();// time Int_t nybins = ph->GetNbinsY();// calibration group if (!InitFit(nybins,1)) { return kFALSE; } + + //printf("Init fit\n"); + if (!InitFitPH()) { return kFALSE; } + + //printf("Init fit PH\n"); + fStatisticMean = 0.0; fNumberFit = 0; fNumberFitSuccess = 0; fNumberEnt = 0; // Init fCountDet and fCount InitfCountDetAndfCount(1); + //printf("Init Count Det and fCount %d, %d\n",fDect1,fDect2); + // Beginning of the loop for (Int_t idect = fDect1; idect < fDect2; idect++) { + //printf("idect = %d\n",idect); // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi....... UpdatefCountDetAndfCount(idect,1); ReconstructFitRowMinRowMax(idect,1); @@ -605,6 +616,7 @@ Bool_t AliTRDCalibraFit::AnalysePH(const TProfile2D *ph) CalculVdriftCoefMean(); CalculT0CoefMean(); //Method choosen + //printf("Method\n"); switch(fMethod) { case 0: FitLagrangePoly((TH1 *) projph); break; @@ -1387,6 +1399,166 @@ Bool_t AliTRDCalibraFit::SetNzFromTObject(const char *name, Int_t i) return kFALSE; } //______________________________________________________________________ +void AliTRDCalibraFit::RemoveOutliers(Int_t type, Bool_t perdetector){ + // + // Remove the results too far from the mean value and rms + // type: 0 gain, 1 vdrift + // perdetector + // + + Int_t loop = (Int_t) fVectorFit.GetEntriesFast(); + if(loop != 540) { + AliInfo("The Vector Fit is not complete!"); + return; + } + Int_t detector = -1; + Int_t sector = -1; + Float_t value = 0.0; + + ///////////////////////////////// + // Calculate the mean values + //////////////////////////////// + // Initialisation + //////////////////////// + Double_t meanAll = 0.0; + Double_t rmsAll = 0.0; + Int_t countAll = 0; + //////////// + // compute + //////////// + for (Int_t k = 0; k < loop; k++) { + detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); + sector = GetSector(detector); + if(perdetector){ + value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0]; + if(value > 0.0) { + rmsAll += value*value; + meanAll += value; + countAll++; + } + } + else { + Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); + Int_t colMax = fGeo->GetColMax(GetLayer(detector)); + for (Int_t row = 0; row < rowMax; row++) { + for (Int_t col = 0; col < colMax; col++) { + value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; + if(value > 0.0) { + rmsAll += value*value; + meanAll += value; + countAll++; + } + + } // Col + } // Row + } + } + if(countAll > 0) { + meanAll = meanAll/countAll; + rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll))); + } + //printf("RemoveOutliers: meanAll %f and rmsAll %f\n",meanAll,rmsAll); + ///////////////////////////////////////////////// + // Remove outliers + //////////////////////////////////////////////// + Double_t defaultvalue = -1.0; + if(type==1) defaultvalue = -1.5; + for (Int_t k = 0; k < loop; k++) { + detector = ((AliTRDFitInfo *) fVectorFit.At(k))->GetDetector(); + sector = GetSector(detector); + Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); + Int_t colMax = fGeo->GetColMax(GetLayer(detector)); + Float_t *coef = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef(); + + // remove the results too far away + for (Int_t row = 0; row < rowMax; row++) { + for (Int_t col = 0; col < colMax; col++) { + value = coef[(Int_t)(col*rowMax+row)]; + if((value > 0.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2*rmsAll))) { + coef[(Int_t)(col*rowMax+row)] = defaultvalue; + } + } // Col + } // Row + } +} +//______________________________________________________________________ +void AliTRDCalibraFit::RemoveOutliers2(Bool_t perdetector){ + // + // Remove the results too far from the mean and rms + // perdetector + // + + Int_t loop = (Int_t) fVectorFit2.GetEntriesFast(); + if(loop != 540) { + AliInfo("The Vector Fit is not complete!"); + return; + } + Int_t detector = -1; + Int_t sector = -1; + Float_t value = 0.0; + + ///////////////////////////////// + // Calculate the mean values + //////////////////////////////// + // Initialisation + //////////////////////// + Double_t meanAll = 0.0; + Double_t rmsAll = 0.0; + Int_t countAll = 0; + ///////////// + // compute + //////////// + for (Int_t k = 0; k < loop; k++) { + detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); + sector = GetSector(detector); + if(perdetector){ + value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0]; + if(value < 70.0) { + meanAll += value; + rmsAll += value*value; + countAll++; + } + } + else { + Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); + Int_t colMax = fGeo->GetColMax(GetLayer(detector)); + for (Int_t row = 0; row < rowMax; row++) { + for (Int_t col = 0; col < colMax; col++) { + value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; + if(value < 70.0) { + rmsAll += value*value; + meanAll += value; + countAll++; + } + } // Col + } // Row + } + } + if(countAll > 0) { + meanAll = meanAll/countAll; + rmsAll = TMath::Sqrt(TMath::Abs(rmsAll/countAll - (meanAll*meanAll))); + } + //printf("Remove outliers 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll); + ///////////////////////////////////////////////// + // Remove outliers + //////////////////////////////////////////////// + for (Int_t k = 0; k < loop; k++) { + detector = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetDetector(); + sector = GetSector(detector); + Int_t rowMax = fGeo->GetRowMax(GetLayer(detector),GetStack(detector),GetSector(detector)); + Int_t colMax = fGeo->GetColMax(GetLayer(detector)); + Float_t *coef = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef(); + + // remove the results too far away + for (Int_t row = 0; row < rowMax; row++) { + for (Int_t col = 0; col < colMax; col++) { + value = coef[(Int_t)(col*rowMax+row)]; + if((value < 70.0) && (rmsAll > 0.0) && (TMath::Abs(value-meanAll) > (2.5*rmsAll))) coef[(Int_t)(col*rowMax+row)] = 100.0; + } // Col + } // Row + } +} +//______________________________________________________________________ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetector){ // // ofwhat is equaled to 0: mean value of all passing detectors @@ -1410,17 +1582,23 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect Double_t meanAll = 0.0; Double_t meanSupermodule[18]; Double_t meanDetector[540]; + Double_t rmsAll = 0.0; + Double_t rmsSupermodule[18]; + Double_t rmsDetector[540]; Int_t countAll = 0; Int_t countSupermodule[18]; Int_t countDetector[540]; for(Int_t sm = 0; sm < 18; sm++){ + rmsSupermodule[sm] = 0.0; meanSupermodule[sm] = 0.0; countSupermodule[sm] = 0; } for(Int_t det = 0; det < 540; det++){ + rmsDetector[det] = 0.0; meanDetector[det] = 0.0; countDetector[det] = 0; } + //////////// // compute //////////// for (Int_t k = 0; k < loop; k++) { @@ -1429,10 +1607,13 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect if(perdetector){ value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[0]; if(value > 0.0) { + rmsDetector[detector] += value*value; meanDetector[detector] += value; countDetector[detector]++; + rmsSupermodule[sector] += value*value; meanSupermodule[sector] += value; countSupermodule[sector]++; + rmsAll += value*value; meanAll += value; countAll++; } @@ -1444,10 +1625,13 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect for (Int_t col = 0; col < colMax; col++) { value = ((AliTRDFitInfo *) fVectorFit.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; if(value > 0.0) { + rmsDetector[detector] += value*value; meanDetector[detector] += value; countDetector[detector]++; + rmsSupermodule[sector] += value*value; meanSupermodule[sector] += value; countSupermodule[sector]++; + rmsAll += value*value; meanAll += value; countAll++; } @@ -1456,13 +1640,24 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect } // Row } } - if(countAll > 0) meanAll = meanAll/countAll; + if(countAll > 0) { + meanAll = meanAll/countAll; + rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll)); + } for(Int_t sm = 0; sm < 18; sm++){ - if(countSupermodule[sm] > 0) meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; + if(countSupermodule[sm] > 0) { + meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; + rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm])); + } } for(Int_t det = 0; det < 540; det++){ - if(countDetector[det] > 0) meanDetector[det] = meanDetector[det]/countDetector[det]; + if(countDetector[det] > 0) { + meanDetector[det] = meanDetector[det]/countDetector[det]; + rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det])); + } } + //printf("Put mean value, meanAll %f, rmsAll %f\n",meanAll,rmsAll); + /////////////////////////////////////////////// // Put the mean value for the no-fitted ///////////////////////////////////////////// for (Int_t k = 0; k < loop; k++) { @@ -1476,11 +1671,11 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect for (Int_t col = 0; col < colMax; col++) { value = coef[(Int_t)(col*rowMax+row)]; if(value < 0.0) { - if((ofwhat == 0) && (meanAll > 0.0)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); + if((ofwhat == 0) && (meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); if(ofwhat == 1){ - if(meanDetector[detector] > 0.0) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanDetector[detector]); - else if(meanSupermodule[sector] > 0.0) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanSupermodule[sector]); - else if(meanAll > 0.0) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); + if((meanDetector[detector] > 0.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanDetector[detector]); + else if((meanSupermodule[sector] > 0.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanSupermodule[sector]); + else if((meanAll > 0.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = -TMath::Abs(meanAll); } } // Debug @@ -1507,7 +1702,6 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit(Int_t ofwhat, Bool_t perdetect } // Col } // Row } - } //______________________________________________________________________ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetector){ @@ -1531,16 +1725,21 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec // Initialisation //////////////////////// Double_t meanAll = 0.0; + Double_t rmsAll = 0.0; Double_t meanSupermodule[18]; + Double_t rmsSupermodule[18]; Double_t meanDetector[540]; + Double_t rmsDetector[540]; Int_t countAll = 0; Int_t countSupermodule[18]; Int_t countDetector[540]; for(Int_t sm = 0; sm < 18; sm++){ + rmsSupermodule[sm] = 0.0; meanSupermodule[sm] = 0.0; countSupermodule[sm] = 0; } for(Int_t det = 0; det < 540; det++){ + rmsDetector[det] = 0.0; meanDetector[det] = 0.0; countDetector[det] = 0; } @@ -1552,11 +1751,14 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec if(perdetector){ value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[0]; if(value < 70.0) { + rmsDetector[detector] += value*value; meanDetector[detector] += value; countDetector[detector]++; + rmsSupermodule[sector] += value*value; meanSupermodule[sector] += value; countSupermodule[sector]++; meanAll += value; + rmsAll += value*value; countAll++; } } @@ -1567,10 +1769,13 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec for (Int_t col = 0; col < colMax; col++) { value = ((AliTRDFitInfo *) fVectorFit2.At(k))->GetCoef()[(Int_t)(col*rowMax+row)]; if(value < 70.0) { + rmsDetector[detector] += value*value; meanDetector[detector] += value; countDetector[detector]++; + rmsSupermodule[sector] += value*value; meanSupermodule[sector] += value; countSupermodule[sector]++; + rmsAll += value*value; meanAll += value; countAll++; } @@ -1579,13 +1784,24 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec } // Row } } - if(countAll > 0) meanAll = meanAll/countAll; + if(countAll > 0) { + meanAll = meanAll/countAll; + rmsAll = TMath::Abs(rmsAll/countAll - (meanAll*meanAll)); + } for(Int_t sm = 0; sm < 18; sm++){ - if(countSupermodule[sm] > 0) meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; + if(countSupermodule[sm] > 0) { + meanSupermodule[sm] = meanSupermodule[sm]/countSupermodule[sm]; + rmsSupermodule[sm] = TMath::Abs(rmsSupermodule[sm]/countSupermodule[sm] - (meanSupermodule[sm]*meanSupermodule[sm])); + } } for(Int_t det = 0; det < 540; det++){ - if(countDetector[det] > 0) meanDetector[det] = meanDetector[det]/countDetector[det]; + if(countDetector[det] > 0) { + meanDetector[det] = meanDetector[det]/countDetector[det]; + rmsDetector[det] = TMath::Abs(rmsDetector[det]/countDetector[det] - (meanDetector[det]*meanDetector[det])); + } } + //printf("Put mean value 2: meanAll %f, rmsAll %f\n",meanAll,rmsAll); + //////////////////////////////////////////// // Put the mean value for the no-fitted ///////////////////////////////////////////// for (Int_t k = 0; k < loop; k++) { @@ -1599,11 +1815,11 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec for (Int_t col = 0; col < colMax; col++) { value = coef[(Int_t)(col*rowMax+row)]; if(value > 70.0) { - if((ofwhat == 0) && (meanAll > -1.5)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; + if((ofwhat == 0) && (meanAll > -1.5) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; if(ofwhat == 1){ - if(meanDetector[detector] > -1.5) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0; - else if(meanSupermodule[sector] > -1.5) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0; - else if(meanAll > -1.5) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; + if((meanDetector[detector] > -1.5) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0; + else if((meanSupermodule[sector] > -1.5) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0; + else if((meanAll > -1.5) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0; } } // Debug @@ -2488,10 +2704,16 @@ void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i) if(fDebugLevel == 1) { fCountDet = 0; fCalibraMode->CalculXBins(fCountDet,i); - while(fCalibraMode->GetXbins(i) <=fFitVoir){ + if((fCalibraMode->GetNz(i)!=100) && (fCalibraMode->GetNrphi(i)!=100)){ + while(fCalibraMode->GetXbins(i) <=fFitVoir){ + fCountDet++; + fCalibraMode->CalculXBins(fCountDet,i); + //printf("GetXBins %d\n",fCalibraMode->GetXbins(i)); + } + } + else { fCountDet++; - fCalibraMode->CalculXBins(fCountDet,i); - } + } fCount = fCalibraMode->GetXbins(i); fCountDet--; // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi @@ -4079,7 +4301,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH) // // Slope methode but with polynomes de Lagrange // - + // Constants const Float_t kDrWidth = AliTRDgeometry::DrThick(); Int_t binmax = 0; @@ -4601,7 +4823,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH) (put)) { fCurrentCoef[0] = (kDrWidth) / (fPhd[2]-fPhd[1]); if(fCurrentCoef[0] > 2.5) fCurrentCoef[0] = -TMath::Abs(fCurrentCoef[1]); - fNumberFitSuccess++; + else fNumberFitSuccess++; if (fPhdt0 >= 0.0) { fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins; if (fCurrentCoef2[0] < -1.0) { diff --git a/TRD/AliTRDCalibraFit.h b/TRD/AliTRDCalibraFit.h index 20c10778bc7..2754f08a952 100644 --- a/TRD/AliTRDCalibraFit.h +++ b/TRD/AliTRDCalibraFit.h @@ -52,90 +52,92 @@ class AliTRDCalibraFit : public TObject { AliTRDCalibraFit(const AliTRDCalibraFit &c); AliTRDCalibraFit &operator=(const AliTRDCalibraFit &) { return *this; } - // Function for integration range of the charge - void RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const; + // Function for integration range of the charge + void RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const; - // Functions fit for CH - Bool_t AnalyseCH(const TH2I *ch); - Bool_t AnalyseCH(AliTRDCalibraVector *calvect); - - // Functions fit for PH - Bool_t AnalysePH(const TProfile2D *ph); - Bool_t AnalysePH(AliTRDCalibraVector *calvect); - - // Functions fit for PRF - Bool_t AnalysePRF(const TProfile2D *prf); - Bool_t AnalysePRF(AliTRDCalibraVector *calvect); - - Bool_t AnalysePRFMarianFit(const TProfile2D *prf); - Bool_t AnalysePRFMarianFit(AliTRDCalibraVector *calvect); - - // Functions fit for vdrift/lorentzangle - Bool_t AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli); - - // Pad Calibration - Bool_t SetModeCalibration(const char *name, Int_t i); - - //Reset Function - void ResetVectorFit(); - - // Some functions - Double_t *CalculPolynomeLagrange2(const Double_t *x, const Double_t *y) const; - Double_t *CalculPolynomeLagrange3(const Double_t *x, const Double_t *y) const; - Double_t *CalculPolynomeLagrange4(const Double_t *x, const Double_t *y) const; - - // Fill the database - void PutMeanValueOtherVectorFit(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); - void PutMeanValueOtherVectorFit2(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); - AliTRDCalDet *CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); - AliTRDCalDet *CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore=kTRUE, Double_t scaleFitFactor = 0.02431, Bool_t perdetector = kTRUE); - AliTRDCalDet *CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); - AliTRDCalDet *CreateDetObjectLorentzAngle(const TObjArray *vectorFit); - - TObject *CreatePadObjectGain(const TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, const AliTRDCalDet *detobject = 0); - TObject *CreatePadObjectVdrift(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); - TObject *CreatePadObjectT0(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); - TObject *CreatePadObjectPRF(const TObjArray *vectorFit); - - // Outliers stats - AliTRDCalDet *MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean); - TObject *MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean); + // Functions fit for CH + Bool_t AnalyseCH(const TH2I *ch); + Bool_t AnalyseCH(AliTRDCalibraVector *calvect); + + // Functions fit for PH + Bool_t AnalysePH(const TProfile2D *ph); + Bool_t AnalysePH(AliTRDCalibraVector *calvect); + + // Functions fit for PRF + Bool_t AnalysePRF(const TProfile2D *prf); + Bool_t AnalysePRF(AliTRDCalibraVector *calvect); + + Bool_t AnalysePRFMarianFit(const TProfile2D *prf); + Bool_t AnalysePRFMarianFit(AliTRDCalibraVector *calvect); + + // Functions fit for vdrift/lorentzangle + Bool_t AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli); + + // Pad Calibration + Bool_t SetModeCalibration(const char *name, Int_t i); + + //Reset Function + void ResetVectorFit(); + + // Some functions + Double_t *CalculPolynomeLagrange2(const Double_t *x, const Double_t *y) const; + Double_t *CalculPolynomeLagrange3(const Double_t *x, const Double_t *y) const; + Double_t *CalculPolynomeLagrange4(const Double_t *x, const Double_t *y) const; + + // Fill the database + void RemoveOutliers(Int_t type, Bool_t perdetector = kFALSE); + void RemoveOutliers2(Bool_t perdetector = kFALSE); + void PutMeanValueOtherVectorFit(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); + void PutMeanValueOtherVectorFit2(Int_t ofwhat = 1, Bool_t perdetector = kFALSE); + AliTRDCalDet *CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); + AliTRDCalDet *CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore=kTRUE, Double_t scaleFitFactor = 0.02431, Bool_t perdetector = kTRUE); + AliTRDCalDet *CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector = kFALSE); + AliTRDCalDet *CreateDetObjectLorentzAngle(const TObjArray *vectorFit); + + TObject *CreatePadObjectGain(const TObjArray *vectorFit = 0, Double_t scaleFitFactor = 1.0, const AliTRDCalDet *detobject = 0); + TObject *CreatePadObjectVdrift(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); + TObject *CreatePadObjectT0(const TObjArray *vectorFit = 0, const AliTRDCalDet *detobject = 0); + TObject *CreatePadObjectPRF(const TObjArray *vectorFit); + + // Outliers stats + AliTRDCalDet *MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean); + TObject *MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean); - // - // Set or Get the variables - // + // + // Set or Get the variables + // + + // Fit + void ChooseMethod(Short_t method) { fMethod = method; } + void SetBeginFitCharge(Float_t beginFitCharge); + void SetPeriodeFitPH(Int_t periodeFitPH); + void SetTakeTheMaxPH() { fTakeTheMaxPH = kTRUE; } + void SetT0Shift0(Float_t t0Shift0); + void SetT0Shift1(Float_t t0Shift1); + void SetRangeFitPRF(Float_t rangeFitPRF); + void SetAccCDB() { fAccCDB = kTRUE; } + void SetMinEntries(Int_t minEntries); + void SetRebin(Short_t rebin); + + Int_t GetPeriodeFitPH() const { return fFitPHPeriode; } + Bool_t GetTakeTheMaxPH() const { return fTakeTheMaxPH; } + Float_t GetT0Shift0() const { return fT0Shift0; } + Float_t GetT0Shift1() const { return fT0Shift1; } + Float_t GetRangeFitPRF() const { return fRangeFitPRF; } + Bool_t GetAccCDB() const { return fAccCDB; } + Int_t GetMinEntries() const { return fMinEntries; } + Short_t GetRebin() const { return fRebin; } + + // Statistics + Int_t GetNumberFit() const { return fNumberFit; } + Int_t GetNumberFitSuccess() const { return fNumberFitSuccess; } + Int_t GetNumberEnt() const { return fNumberEnt; } + Double_t GetStatisticMean() const { return fStatisticMean; } + - // Fit - void ChooseMethod(Short_t method) { fMethod = method; } - void SetBeginFitCharge(Float_t beginFitCharge); - void SetPeriodeFitPH(Int_t periodeFitPH); - void SetTakeTheMaxPH() { fTakeTheMaxPH = kTRUE; } - void SetT0Shift0(Float_t t0Shift0); - void SetT0Shift1(Float_t t0Shift1); - void SetRangeFitPRF(Float_t rangeFitPRF); - void SetAccCDB() { fAccCDB = kTRUE; } - void SetMinEntries(Int_t minEntries); - void SetRebin(Short_t rebin); - - Int_t GetPeriodeFitPH() const { return fFitPHPeriode; } - Bool_t GetTakeTheMaxPH() const { return fTakeTheMaxPH; } - Float_t GetT0Shift0() const { return fT0Shift0; } - Float_t GetT0Shift1() const { return fT0Shift1; } - Float_t GetRangeFitPRF() const { return fRangeFitPRF; } - Bool_t GetAccCDB() const { return fAccCDB; } - Int_t GetMinEntries() const { return fMinEntries; } - Short_t GetRebin() const { return fRebin; } - - // Statistics - Int_t GetNumberFit() const { return fNumberFit; } - Int_t GetNumberFitSuccess() const { return fNumberFitSuccess; } - Int_t GetNumberEnt() const { return fNumberEnt; } - Double_t GetStatisticMean() const { return fStatisticMean; } - - - // Debug - void SetDebugLevel(Short_t level) { fDebugLevel = level; } - void SetDet(Int_t iLayer, Int_t iStack, Int_t iSector) { fDet[0] = iLayer; + // Debug + void SetDebugLevel(Short_t level) { fDebugLevel = level; } + void SetDet(Int_t iLayer, Int_t iStack, Int_t iSector) { fDet[0] = iLayer; fDet[1] = iStack; fDet[2] = iSector; } void SetFitVoir(Int_t fitVoir) { fFitVoir = fitVoir; } @@ -180,6 +182,8 @@ class AliTRDCalibraFit : public TObject { }; + // Fit function + void FitLagrangePoly(TH1* projPH); protected: @@ -313,7 +317,6 @@ class AliTRDCalibraFit : public TObject { Bool_t FitPRFGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins,Float_t xMin,Float_t xMax); Double_t FitGausMI(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nBins, Float_t xMin,Float_t xMax,TVectorD *param, Bool_t kError= kTRUE); void FitPente(TH1 *projPH); - void FitLagrangePoly(TH1* projPH); void FitTnpRange(Double_t *arraye,Double_t *arraym,Double_t *arrayme,Int_t nbg,Int_t nybins); TH1I *ReBin(const TH1I *hist) const; TH1F *ReBin(const TH1F *hist) const; diff --git a/TRD/AliTRDPreprocessor.cxx b/TRD/AliTRDPreprocessor.cxx index caf085b5eb9..0d0fdf607aa 100644 --- a/TRD/AliTRDPreprocessor.cxx +++ b/TRD/AliTRDPreprocessor.cxx @@ -681,13 +681,16 @@ Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); Int_t nbfit = calibra->GetNumberFit(); + Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); Int_t nbE = calibra->GetNumberEnt(); // if enough statistics store the results if ((nbtg > 0) && - (nbfit >= 0.5*nbE) && (nbE > 30)) { + (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { // create the cal objects + calibra->RemoveOutliers(1,kTRUE); calibra->PutMeanValueOtherVectorFit(1,kTRUE); + calibra->RemoveOutliers2(kTRUE); calibra->PutMeanValueOtherVectorFit2(1,kTRUE); TObjArray object = calibra->GetVectorFit(); AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); @@ -834,12 +837,15 @@ Bool_t AliTRDPreprocessor::ExtractHLT() Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); Int_t nbfit = calibra->GetNumberFit(); + Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); Int_t nbE = calibra->GetNumberEnt(); // enough statistics if ((nbtg > 0) && - (nbfit >= 0.5*nbE) && (nbE > 30)) { + (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { // create the cal objects + calibra->RemoveOutliers(1,kTRUE); calibra->PutMeanValueOtherVectorFit(1,kTRUE); + calibra->RemoveOutliers2(kTRUE); calibra->PutMeanValueOtherVectorFit2(1,kTRUE); TObjArray object = calibra->GetVectorFit(); AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); diff --git a/TRD/TRDVDRIFTda.cxx b/TRD/TRDVDRIFTda.cxx index 7c3c6257cfb..03f77de7b70 100644 --- a/TRD/TRDVDRIFTda.cxx +++ b/TRD/TRDVDRIFTda.cxx @@ -109,6 +109,7 @@ int main(int argc, char **argv) { //man->SetRun(0); //Instance of AliTRDCalibraFillHisto AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); + calibra->SetNumberClustersProcent(0.9); // everythings are okey for vdrift Bool_t passvdrift = kTRUE; // if timebin okey Int_t nbvdrift = 0; // number of events with entries for vdrift @@ -157,7 +158,6 @@ int main(int argc, char **argv) { if( ((Int_t)neventstotal)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) neventstotal,(Int_t) neventsphysics); - /* use event - here, just write event id to result file */ eventT=event->eventType; -- 2.43.5