Corrected protection.
[u/mrichter/AliRoot.git] / STEER / AliBaseCalibViewer.h
CommitLineData
11a2ac51 1#ifndef ALIBASECALIBVIEWER_H
2#define ALIBASECALIBVIEWER_H
3
4///////////////////////////////////////////////////////////////////////////////
5// //
6// Base class for the AliTPCCalibViewer and AliTRDCalibViewer //
7// used for the calibration monitor //
8// //
9///////////////////////////////////////////////////////////////////////////////
10
11#include <TObject.h>
12#include <TTree.h>
13#include <TFile.h>
14#include "TFriendElement.h"
15
16#include "AliMathBase.h"
17
18class TLegend;
19
20class AliBaseCalibViewer : public TObject {
21 public:
22 AliBaseCalibViewer();
23 AliBaseCalibViewer(const AliBaseCalibViewer &c);
24 AliBaseCalibViewer(TTree* tree);
25 AliBaseCalibViewer(const Char_t* fileName, const Char_t* treeName = "tree");
26 AliBaseCalibViewer &operator = (const AliBaseCalibViewer & param);
27 virtual ~AliBaseCalibViewer();
28 virtual void Delete(Option_t* option = "");
29
30 TString& GetAbbreviation() { return fAbbreviation; }
31 TString& GetAppendString() { return fAppendString; }
32 void SetAbbreviation(const Char_t* abr) { fAbbreviation = abr; }
33 void SetAppendString(const Char_t* str) { fAppendString = str; }
34
35 //virtual void GetTimeInfoOCDB(const Char_t* runList, const Char_t* outFile,
36 //Int_t firstRun, Int_t lastRun, UInt_t infoFlags,
37 //const Char_t* ocdbStorage) = 0;
38
39 virtual void Draw(Option_t* opt="") { fTree->Draw(opt); }
40 virtual Long64_t Draw(const Char_t* varexp, const TCut& selection, Option_t* option = "",
41 Long64_t nentries = 1000000000, Long64_t firstentry = 0) {
42 return fTree->Draw(varexp, selection, option, nentries, firstentry);
43 };
44 virtual Long64_t Draw(const Char_t* varexp, const Char_t* selection, Option_t* option = "",
45 Long64_t nentries = 1000000000, Long64_t firstentry = 0) {
46 return fTree->Draw(varexp, selection, option, nentries, firstentry);
47 };
48
49 virtual const char* AddAbbreviations(Char_t* c, Bool_t printDrawCommand = kFALSE) = 0;
50 // easy drawing of data, use '~' for abbreviation of '.fElements'
51 virtual Int_t EasyDraw(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0,
52 const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;
53 // easy drawing of data, use '~' for abbreviation of '.fElements'
54 virtual Int_t EasyDraw(const Char_t* drawCommand, Int_t sector, const Char_t* cuts = 0,
55 const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;
56 // easy drawing of data, use '~' for abbreviation of '.fElements'
57 virtual Int_t EasyDraw1D(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0,
58 const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;
59 // easy drawing of data, use '~' for abbreviation of '.fElements'
60 virtual Int_t EasyDraw1D(const Char_t* drawCommand, Int_t sector, const Char_t* cuts = 0,
61 const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;
62 // formats title and axis labels of histo, removes '.fElements'
63 void FormatHistoLabels(TH1 *histo) const;
64 // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts
65 Int_t DrawHisto1D(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0,
66 const Char_t *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE,
67 Bool_t plotLTM = kTRUE) const;
68 // draws fraction of used pads over different sigma cuts
69 Int_t SigmaCut(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0,
70 Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE,
71 Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const Char_t *sigmas = "",
72 Float_t sigmaStep = -1) const;
73 // draws an integrated histogram
74 Int_t Integrate(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0,
75 Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE,
76 Bool_t plotLTM = kTRUE, const Char_t *sigmas = "", Float_t sigmaStep = -1) const;
77
78 virtual TObjArray* GetListOfVariables(Bool_t printList = kFALSE) = 0;
79 virtual TObjArray* GetListOfNormalizationVariables(Bool_t printList = kFALSE) const = 0;
80
81 TFriendElement* AddReferenceTree(const Char_t* filename, const Char_t* treename = "tree", const Char_t* refname = "R");
82 TFriendElement* AddFriend(const Char_t* treename, const Char_t* filename)
83 {return fTree->AddFriend(treename, filename);};
84 TFriendElement* AddFriend(TTree* tree, const Char_t* alias, Bool_t warn=kFALSE)
85 {return fTree->AddFriend(tree, alias, warn);};
86 TFriendElement* AddFriend(const Char_t* treename, TFile* file)
87 {return fTree->AddFriend(treename, file);};
88 TTree * GetTree() const { return fTree;}
89
90 TString* Fit(const Char_t* drawCommand, const Char_t* formula, const Char_t* cuts,
91 Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix);
92 static Double_t GetLTM(Int_t n, Double_t *array, Double_t *sigma = 0, Double_t fraction = 0.9);
93 static Int_t GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp);
94 static TH1F* SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t sigma, Int_t nbins,
95 Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE);
96 static TH1F* SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax,
97 Float_t sigmaStep = -1, Bool_t pm = kFALSE);
98 static TH1F* Integrate(TH1F *histogram, Float_t mean = 0, Float_t sigma = 0,
99 Float_t sigmaMax = 0, Float_t sigmaStep = -1);
100 static TH1F* Integrate(Int_t n, Float_t *array, Int_t nbins, Float_t binLow, Float_t binUp,
101 Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1);
102 static TH1F* SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma,
103 Int_t nbins, Double_t *xbins, Double_t sigmaMax);
104
105 protected:
106 TTree* fTree; // tree containing visualization data (e.g. written by AliTPCCalPad::MakeTree(...)
107 TFile* fFile; // file that contains a calPads tree (e.g. written by AliTPCCalPad::MakeTree(...)
108 TObjArray* fListOfObjectsToBeDeleted; //Objects, that will be deleted when the destructor ist called
109 Bool_t fTreeMustBeDeleted; // decides weather the tree must be deleted in destructor or not
110 TString fAbbreviation; // the abreviation for '.fElements'
111 TString fAppendString; // '.fElements', stored in a TStrig
112
113 void DrawLines(TH1F *cutHistoMean, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
114 void DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
115
116
117 ClassDef(AliBaseCalibViewer,1) // Base calibration viewer class
118};
119
120#endif