#include "AliTPCCalPad.h"
#include "AliTPCCalROC.h"
-
+#include <TObjArray.h>
+#include <TAxis.h>
+#include <TGraph.h>
ClassImp(AliTPCCalPad)
//_____________________________________________________________________________
}
+//_____________________________________________________________________________
+AliTPCCalPad::AliTPCCalPad(TObjArray * array):TNamed()
+{
+ //
+ // AliTPCCalPad default constructor
+ //
+
+ for (Int_t isec = 0; isec < kNsec; isec++) {
+ fROC[isec] = (AliTPCCalROC *)array->At(isec);
+ }
+
+}
+
+
///_____________________________________________________________________________
AliTPCCalPad::~AliTPCCalPad()
{
}
TObject::Copy(c);
}
+
+TGraph * AliTPCCalPad::MakeGraph(Int_t type, Float_t ratio){
+ //
+ // type=1 - mean
+ // 2 - median
+ // 3 - LTM
+ Int_t npoints = 0;
+ for (Int_t i=0;i<72;i++) if (fROC[i]) npoints++;
+ TGraph * graph = new TGraph(npoints);
+ npoints=0;
+ for (Int_t isec=0;isec<72;isec++){
+ if (!fROC[isec]) continue;
+ if (type==0) graph->SetPoint(npoints,isec,fROC[isec]->GetMean());
+ if (type==1) graph->SetPoint(npoints,isec,fROC[isec]->GetMedian());
+ if (type==2) graph->SetPoint(npoints,isec,fROC[isec]->GetLTM(0,ratio));
+ npoints++;
+ }
+
+ graph->GetXaxis()->SetTitle("Sector");
+ if (type==0) {
+ graph->GetYaxis()->SetTitle("Mean");
+ graph->SetMarkerStyle(22);
+ }
+ if (type==1) {
+ graph->GetYaxis()->SetTitle("Median");
+ graph->SetMarkerStyle(22);
+ }
+ if (type==2) {
+ graph->GetYaxis()->SetTitle(Form("Mean%f",ratio));
+ graph->SetMarkerStyle(24);
+ }
+
+ return graph;
+}
#include "TMath.h"
#include "TClass.h"
#include "TFile.h"
+#include "TH1F.h"
#include "TH2F.h"
+#include "AliMathBase.h"
ClassImp(AliTPCCalROC)
}
+Double_t AliTPCCalROC::GetLTM(Double_t *sigma, Double_t fraction){
+ //
+ // Calculate LTM mean and sigma
+ //
+ Double_t *ddata = new Double_t[fNChannels];
+ Double_t mean=0, lsigma=0;
+ Int_t hh = TMath::Min(TMath::Nint(fraction *fNChannels), Int_t(fNChannels));
+ for (UInt_t i=0;i<fNChannels;i++) ddata[i]= fData[i];
+ AliMathBase::EvaluateUni(UInt_t(fNChannels),ddata, mean, lsigma, hh);
+ if (sigma) *sigma=lsigma;
+ delete [] ddata;
+ return mean;
+}
-void AliTPCCalROC::Draw(Option_t* option){
+TH1F * AliTPCCalROC::MakeHisto1D(Float_t min, Float_t max,Int_t type){
//
- // create histogram with values and draw it
+ // make 1D histo
+ // type -1 = user defined range
+ // 0 = nsigma cut nsigma=min
+ // 1 = delta cut around median delta=min
+ if (type>=0){
+ if (type==0){
+ // nsigma range
+ Float_t mean = GetMean();
+ Float_t sigma = GetRMS();
+ Float_t nsigma = TMath::Abs(min);
+ min = mean-nsigma*sigma;
+ max = mean+nsigma*sigma;
+ }
+ if (type==1){
+ // fixed range
+ Float_t mean = GetMedian();
+ Float_t delta = min;
+ min = mean-delta;
+ max = mean+delta;
+ }
+ if (type==2){
+ //
+ // LTM mean +- nsigma
+ //
+ Double_t sigma;
+ Float_t mean = GetLTM(&sigma,max);
+ sigma*=min;
+ min = mean-sigma;
+ max = mean+sigma;
+ }
+ }
+ char name[1000];
+ sprintf(name,"%s ROC 1D%d",GetTitle(),fSector);
+ TH1F * his = new TH1F(name,name,100, min,max);
+ for (UInt_t irow=0; irow<fNRows; irow++){
+ UInt_t npads = (Int_t)GetNPads(irow);
+ for (UInt_t ipad=0; ipad<=npads; ipad++){
+ his->Fill(GetValue(irow,ipad));
+ }
+ }
+ return his;
+}
+
+
+
+TH2F * AliTPCCalROC::MakeHisto2D(Float_t min, Float_t max,Int_t type){
//
+ // make 2D histo
+ // type -1 = user defined range
+ // 0 = nsigma cut nsigma=min
+ // 1 = delta cut around median delta=min
+ if (type>=0){
+ if (type==0){
+ // nsigma range
+ Float_t mean = GetMean();
+ Float_t sigma = GetRMS();
+ Float_t nsigma = TMath::Abs(min);
+ min = mean-nsigma*sigma;
+ max = mean+nsigma*sigma;
+ }
+ if (type==1){
+ // fixed range
+ Float_t mean = GetMedian();
+ Float_t delta = min;
+ min = mean-delta;
+ max = mean+delta;
+ }
+ if (type==2){
+ Double_t sigma;
+ Float_t mean = GetLTM(&sigma,max);
+ sigma*=min;
+ min = mean-sigma;
+ max = mean+sigma;
+
+ }
+ }
UInt_t maxPad = 0;
for (UInt_t irow=0; irow<fNRows; irow++){
if (GetNPads(irow)>maxPad) maxPad = GetNPads(irow);
his->Fill(irow+0.5,Int_t(ipad)-Int_t(npads/2)+0.5,GetValue(irow,ipad));
}
}
+ his->SetMaximum(max);
+ his->SetMinimum(min);
+ return his;
+}
+
+TH2F * AliTPCCalROC::MakeHistoOutliers(Float_t delta, Float_t fraction, Int_t type){
+ //
+ // Make Histogram with outliers
+ // mode = 0 - sigma cut used
+ // mode = 1 - absolute cut used
+ // fraction - fraction of values used to define sigma
+ // delta - in mode 0 - nsigma cut
+ // mode 1 - delta cut
+ Double_t sigma;
+ Float_t mean = GetLTM(&sigma,fraction);
+ if (type==0) delta*=sigma;
+ UInt_t maxPad = 0;
+ for (UInt_t irow=0; irow<fNRows; irow++){
+ if (GetNPads(irow)>maxPad) maxPad = GetNPads(irow);
+ }
+
+ char name[1000];
+ sprintf(name,"%s ROC Outliers%d",GetTitle(),fSector);
+ TH2F * his = new TH2F(name,name,fNRows+10,-5, fNRows+5, maxPad+10, -(Int_t(maxPad/2))-5, maxPad/2+5);
+ for (UInt_t irow=0; irow<fNRows; irow++){
+ UInt_t npads = (Int_t)GetNPads(irow);
+ for (UInt_t ipad=0; ipad<=npads; ipad++){
+ if (TMath::Abs(GetValue(irow,ipad)-mean)>delta)
+ his->Fill(irow+0.5,Int_t(ipad)-Int_t(npads/2)+0.5,1);
+ }
+ }
+ return his;
+}
+
+
+
+void AliTPCCalROC::Draw(Option_t* opt){
+ //
+ // create histogram with values and draw it
+ //
+ TH1 * his=0;
+ TString option=opt;
+ option.ToUpper();
+ if (option.Contains("1D")){
+ his = MakeHisto1D();
+ }
+ else{
+ his = MakeHisto2D();
+ }
his->Draw(option);
}
+
+
+
void AliTPCCalROC::Test(){
//
// example function to show functionality and tes AliTPCCalROC
//////////////////////////////////////////////////
#include <TObject.h>
+#include <TMath.h>
#include <AliTPCROC.h>
-
+class TH1F;
+class TH2F;
//_____________________________________________________________________________
class AliTPCCalROC : public TObject {
void SetValue(UInt_t row, UInt_t pad, Float_t vd) { if ( row<fNRows && (fIndexes[row]+pad)<fNChannels)fData[fIndexes[row]+pad]= vd; };
void SetValue(UInt_t channel, Float_t vd) {fData[channel]= vd; };
virtual void Draw(Option_t* option = "");
+ //
+ Double_t GetMean(){return TMath::Mean(fNChannels, fData);}
+ Double_t GetRMS() {return TMath::RMS(fNChannels, fData);}
+ Double_t GetMedian() {return TMath::Median(fNChannels, fData);}
+ Double_t GetLTM(Double_t *sigma=0, Double_t fraction=0.9);
+ TH1F * MakeHisto1D(Float_t min=4, Float_t max=-4, Int_t type=0);
+ TH2F * MakeHisto2D(Float_t min=4, Float_t max=-4, Int_t type=0);
+ TH2F * MakeHistoOutliers(Float_t delta=4, Float_t fraction=0.7, Int_t mode=0);
static void Test();
protected:
UInt_t fSector; // sector number