]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibViewer.h
Changes for bug #70680: AliROOT Coverity DELETE_ARRAY checker fix
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewer.h
1 #ifndef ALITPCCALIBVIEWER_H
2 #define ALITPCCALIBVIEWER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id: AliTPCCalibViewer.h,v */
7
8 ///////////////////////////////////////////////////
9 //                                               //
10 //  TPC calibration viewer/visualization class   //
11 //  use Tree for visualization                   //
12 ///////////////////////////////////////////////////
13
14 class TFile;
15 class TLegend;
16 class TGraph;
17 #include <TTree.h>
18 #include <TMatrixDfwd.h>
19
20 class AliTPCCalPad;
21 class AliTPCCalROC;
22 class TFriendElement;
23
24
25 class AliTPCCalibViewer : public TObject {
26 public:
27    AliTPCCalibViewer();
28    AliTPCCalibViewer(const AliTPCCalibViewer &c);
29    AliTPCCalibViewer(TTree *const tree);
30    AliTPCCalibViewer(const char* fileName, const char* treeName = "calPads");
31    AliTPCCalibViewer &operator = (const AliTPCCalibViewer & param);
32    virtual ~AliTPCCalibViewer();
33    virtual void Delete(Option_t* option = "");
34    
35    TString& GetAbbreviation()  { return fAbbreviation;  }
36    TString& GetAppendString()  { return fAppendString; }
37    void SetAbbreviation(const Char_t *abr) { fAbbreviation = abr; }
38    void SetAppendString(const Char_t *str) { fAppendString = str; }
39    
40    virtual void     Draw(Option_t* opt="") { fTree->Draw(opt); }
41    virtual Long64_t Draw(const char* varexp, const TCut& selection, Option_t* option = "", Long64_t nentries = 1000000000, Long64_t firstentry = 0) { return fTree->Draw(varexp, selection, option, nentries, firstentry); };
42    virtual Long64_t Draw(const char* varexp, const char* selection, Option_t* option = "", Long64_t nentries = 1000000000, Long64_t firstentry = 0) { return fTree->Draw(varexp, selection, option, nentries, firstentry); };
43
44    const char* AddAbbreviations(const Char_t *c, Bool_t printDrawCommand = kFALSE);
45    Int_t EasyDraw(const char* drawCommand, const char* sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const;   // easy drawing of data, use '~' for abbreviation of '.fElements'
46    Int_t EasyDraw(const char* drawCommand, Int_t sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const;   // easy drawing of data, use '~' for abbreviation of '.fElements'
47    Int_t EasyDraw1D(const char* drawCommand, const char* sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const;   // easy drawing of data, use '~' for abbreviation of '.fElements'
48    Int_t EasyDraw1D(const char* drawCommand, Int_t sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const;   // easy drawing of data, use '~' for abbreviation of '.fElements'
49    void FormatHistoLabels(TH1 *histo) const; // formats title and axis labels of histo, removes '.fElements'
50    
51    Int_t  DrawHisto1D(const char* drawCommand,       Int_t sector, const char* cuts = 0, const char *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts
52    Int_t  DrawHisto1D(const char* drawCommand, const char* sector, const char* cuts = 0, const char *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts
53    Int_t     SigmaCut(const char* drawCommand,       Int_t sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws fraction of used pads over different sigma cuts
54    Int_t  SigmaCutNew(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws fraction of used pads over different sigma cuts
55    Int_t     SigmaCut(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws fraction of used pads over different sigma cuts
56    Int_t    Integrate(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws an integrated histogram
57    Int_t    Integrate(const char* drawCommand,       Int_t sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws an integrated histogram
58    Int_t IntegrateOld(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, const char *sigmas = "", Float_t sigmaStep = -1) const;    // draws an integrated histogram
59    
60    AliTPCCalPad* GetCalPadOld(const char* desiredData, const char* cuts = "", const char* calPadName = "NoName") const;     // returns an AliTPCCalPad object containing the specified data with cuts applied
61    AliTPCCalPad* GetCalPad(const char* desiredData, const char* cuts = "", const char* calPadName = "NoName") const;     // returns an AliTPCCalPad object containing the specified data with cuts applied
62
63    AliTPCCalROC* GetCalROC(const char* desiredData, UInt_t sector, const char* cuts = "") const;  // returns an AliTPCCalROC object containing the specified data for sector with cuts applied
64    
65    TObjArray* GetArrayOfCalPads();
66    TObjArray* GetListOfVariables(Bool_t printList = kFALSE);
67    TObjArray* GetListOfNormalizationVariables(Bool_t printList = kFALSE) const;
68    
69    static void MakeTreeWithObjects(const char * fileName, const TObjArray *const array, const char * mapFileName = 0);
70    static void MakeTree(const char * fileName, TObjArray * array, const char * mapFileName = 0, AliTPCCalPad *const outlierPad = 0, Float_t ltmFraction = 0.9);
71    static void MakeTree(const char *outPutFileName, const Char_t *inputFileName, AliTPCCalPad *outlierPad = 0, Float_t ltmFraction = 0.9, const char *mapFileName = "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
72    static void CreateObjectList(const Char_t *filename, TObjArray *calibObjects);
73    
74    TFriendElement* AddReferenceTree(const char* filename, const char* treename = "calPads", const char* refname = "R");
75    TFriendElement* AddFriend(const char* treename, const char* filename) {return fTree->AddFriend(treename, filename);};
76    TFriendElement* AddFriend(TTree* tree, const char* alias, Bool_t warn=kFALSE) {return fTree->AddFriend(tree, alias, warn);};
77    TFriendElement* AddFriend(const char* treename, TFile* file) {return fTree->AddFriend(treename, file);};
78    TTree * GetTree() const { return fTree;}
79
80    TString* Fit(const char* drawCommand, const char* formula, const char* cuts, Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix);
81
82   // 
83   // Array tools
84   // 
85   static Double_t GetLTM(Int_t n, const Double_t *const array, Double_t *const sigma = 0, Double_t fraction = 0.9);
86   static Int_t GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp);
87   static TH1F* SigmaCut(Int_t n, const Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE);
88   static TH1F* SigmaCut(TH1F *const histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE);
89   static TH1F* Integrate(TH1F *const histogram, Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1);
90   static TH1F* Integrate(Int_t n, const Float_t *const array, Int_t nbins, Float_t binLow, Float_t binUp, Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1);
91   
92   static TH1F* SigmaCut(Int_t n, const Double_t *array, Double_t mean, Double_t sigma, Int_t nbins, const Double_t *xbins, Double_t sigmaMax);
93    
94    
95          
96 protected:
97    TTree* fTree;     // tree containing visualization data (e.g. written by AliTPCCalPad::MakeTree(...)
98    TFile* fFile;     // file that contains a calPads tree (e.g. written by AliTPCCalPad::MakeTree(...)
99    TObjArray* fListOfObjectsToBeDeleted;  //Objects, that will be deleted when the destructor ist called
100    Bool_t fTreeMustBeDeleted;  // decides weather the tree must be deleted in destructor or not 
101    TString fAbbreviation;       // the abreviation for '.fElements'
102    TString fAppendString;      // '.fElements', stored in a TStrig
103    
104    void DrawLines(TH1F *cutHistoMean, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
105    void DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
106   
107    
108    ClassDef(AliTPCCalibViewer,1)    //  TPC calibration viewer class
109 };
110
111 #endif
112
113
114