]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/Cal/AliTRDCalDet.cxx
a/ AliTRDCalibTask.cxx .h: one histo more to quantify the event selection if any...
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDCalDet.cxx
index a3b098743cf8216605f98a317d1c7f895b38e612..37058dffbad7fb4ca5ad8fad6a1ec176cbc67458 100644 (file)
@@ -108,7 +108,7 @@ void AliTRDCalDet::Copy(TObject &c) const
 }
 
 //___________________________________________________________________________________
-Double_t AliTRDCalDet::GetMean(AliTRDCalDet* outlierDet) 
+Double_t AliTRDCalDet::GetMean(AliTRDCalDet * const outlierDet) const
 {
   //
   // Calculate the mean
@@ -116,20 +116,20 @@ Double_t AliTRDCalDet::GetMean(AliTRDCalDet* outlierDet)
 
   if (!outlierDet) return TMath::Mean(kNdet,fData);
   Double_t *ddata = new Double_t[kNdet];
-  Int_t NPoints = 0;
+  Int_t nPoints = 0;
   for (Int_t i=0;i<kNdet;i++) {
     if (!(outlierDet->GetValue(i))) {
-      ddata[NPoints]= fData[NPoints];
-      NPoints++;
+      ddata[nPoints]= fData[nPoints];
+      nPoints++;
     }
   }
-  Double_t mean = TMath::Mean(NPoints,ddata);
+  Double_t mean = TMath::Mean(nPoints,ddata);
   delete [] ddata;
   return mean;
 }
 
 //_______________________________________________________________________________________
-Double_t AliTRDCalDet::GetMedian(AliTRDCalDet* outlierDet) 
+Double_t AliTRDCalDet::GetMedian(AliTRDCalDet * const outlierDet) const
 {
   //
   // Calculate the median
@@ -137,21 +137,21 @@ Double_t AliTRDCalDet::GetMedian(AliTRDCalDet* outlierDet)
 
   if (!outlierDet) return (Double_t) TMath::Median(kNdet,fData);
   Double_t *ddata = new Double_t[kNdet];
-  Int_t NPoints = 0;
+  Int_t nPoints = 0;
   for (Int_t i=0;i<kNdet;i++) {
     if (!(outlierDet->GetValue(i))) {
-      ddata[NPoints]= fData[NPoints];
-      NPoints++;
+      ddata[nPoints]= fData[nPoints];
+      nPoints++;
     }
   }
-  Double_t mean = TMath::Median(NPoints,ddata);
+  Double_t mean = TMath::Median(nPoints,ddata);
   delete [] ddata;
   return mean;
 
 }
 
 //____________________________________________________________________________________________
-Double_t AliTRDCalDet::GetRMS(AliTRDCalDet* outlierDet) 
+Double_t AliTRDCalDet::GetRMS(AliTRDCalDet * const outlierDet) const
 {
   //
   // Calculate the RMS
@@ -159,20 +159,59 @@ Double_t AliTRDCalDet::GetRMS(AliTRDCalDet* outlierDet)
 
   if (!outlierDet) return TMath::RMS(kNdet,fData);
   Double_t *ddata = new Double_t[kNdet];
-  Int_t NPoints = 0;
+  Int_t nPoints = 0;
   for (Int_t i=0;i<kNdet;i++) {
     if (!(outlierDet->GetValue(i))) {
-      ddata[NPoints]= fData[NPoints];
-      NPoints++;
+      ddata[nPoints]= fData[nPoints];
+      nPoints++;
     }
   }
-  Double_t mean = TMath::RMS(NPoints,ddata);
+  Double_t mean = TMath::RMS(nPoints,ddata);
   delete [] ddata;
   return mean;
 }
 
+//____________________________________________________________________________________________
+Double_t AliTRDCalDet::GetRMSRobust(Double_t robust) const
+{
+  //
+  // Calculate the robust RMS
+  //
+
+  // sorted
+  Int_t *index = new Int_t[kNdet];
+  TMath::Sort((Int_t)kNdet,fData,index);
+  // reject
+  Double_t reject = (Int_t) (kNdet*(1-robust)/2.0);
+  if(reject <= 0.0) reject = 0.0;
+  if(reject >= kNdet) reject = 0.0;
+  //printf("Rejecter %f\n",reject);
+
+  Double_t *ddata = new Double_t[kNdet];
+  Int_t nPoints = 0;
+  for (Int_t i=0;i<kNdet;i++) {
+    Bool_t rej = kFALSE;
+    for(Int_t k = 0; k < reject; k++){
+      if(i==index[k]) rej = kTRUE;
+      if(i==index[kNdet-(k+1)]) rej  = kTRUE;
+    }
+    if(!rej){
+      ddata[nPoints]= fData[i];
+      nPoints++;
+    }
+  }
+  //printf("Number of points %d\n",nPoints);
+  Double_t mean = TMath::RMS(nPoints,ddata);
+  delete [] ddata;
+  delete [] index;
+  return mean;
+}
+
 //______________________________________________________________________________________________
-Double_t AliTRDCalDet::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalDet* outlierDet)
+Double_t AliTRDCalDet::GetLTM(Double_t *sigma
+                            , Double_t fraction
+                            , AliTRDCalDet * const outlierDet)
 {
   //
   //  Calculate LTM mean and sigma
@@ -180,15 +219,15 @@ Double_t AliTRDCalDet::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalDet*
 
   Double_t *ddata = new Double_t[kNdet];
   Double_t mean=0, lsigma=0;
-  UInt_t NPoints = 0;
+  UInt_t nPoints = 0;
   for (Int_t i=0;i<kNdet;i++) {
      if (!outlierDet || !(outlierDet->GetValue(i))) {
-        ddata[NPoints]= fData[NPoints];
-        NPoints++;
+        ddata[nPoints]= fData[nPoints];
+        nPoints++;
      }
   }
-  Int_t hh = TMath::Min(TMath::Nint(fraction *NPoints), Int_t(NPoints));
-  AliMathBase::EvaluateUni(NPoints,ddata, mean, lsigma, hh);
+  Int_t hh = TMath::Min(TMath::Nint(fraction *nPoints), Int_t(nPoints));
+  AliMathBase::EvaluateUni(nPoints,ddata, mean, lsigma, hh);
   if (sigma) *sigma=lsigma;
   delete [] ddata;
   return mean;
@@ -232,7 +271,7 @@ TH1F * AliTRDCalDet::MakeHisto1Distribution(Float_t min, Float_t max,Int_t type)
     }
   }
   char  name[1000];
-  sprintf(name,"%s CalDet 1Distribution",GetTitle());
+  snprintf(name,1000,"%s CalDet 1Distribution",GetTitle());
   TH1F * his = new TH1F(name,name,100, min,max);
   for (Int_t idet=0; idet<kNdet; idet++){
     his->Fill(GetValue(idet));
@@ -277,7 +316,7 @@ TH1F * AliTRDCalDet::MakeHisto1DAsFunctionOfDet(Float_t min, Float_t max,Int_t t
   }
  
   char  name[1000];
-  sprintf(name,"%s CalDet as function of det",GetTitle());
+  snprintf(name,1000,"%s CalDet as function of det",GetTitle());
   TH1F * his = new TH1F(name,name,kNdet, 0, kNdet);
   for(Int_t det = 0; det< kNdet; det++){
     his->Fill(det+0.5,GetValue(det));
@@ -332,7 +371,7 @@ TH2F *AliTRDCalDet::MakeHisto2DCh(Int_t ch, Float_t min, Float_t max, Int_t type
   Double_t posglobal[3] = {0.0,0.0,0.0};
   
   char  name[1000];
-  sprintf(name,"%s CalDet 2D ch %d",GetTitle(),ch);
+  snprintf(name,1000,"%s CalDet 2D ch %d",GetTitle(),ch);
   TH2F * his = new TH2F(name, name, 400,-400.0,400.0,400,-400.0,400.0);
 
   // Where we begin
@@ -408,7 +447,7 @@ TH2F *AliTRDCalDet::MakeHisto2DSmPl(Int_t sm, Int_t pl, Float_t min, Float_t max
   Double_t col0    = padPlane0->GetCol0();
 
   char  name[1000];
-  sprintf(name,"%s CalDet 2D sm %d and pl %d",GetTitle(),sm,pl);
+  snprintf(name,1000,"%s CalDet 2D sm %d and pl %d",GetTitle(),sm,pl);
   TH2F * his = new TH2F( name, name, 5,  -TMath::Abs(row0),  TMath::Abs(row0)
                                    , 4,-2*TMath::Abs(col0),2*TMath::Abs(col0));
 
@@ -489,3 +528,5 @@ void AliTRDCalDet::Divide(const AliTRDCalDet * calDet)
        }
     }
 }
+
+