]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSPlaneEffSPD.h
Bug fix
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSPD.h
1 #ifndef ALIITSPLANEEFFSPD_H
2 #define ALIITSPLANEEFFSPD_H
3 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 #include <TH1F.h>
7 #include <TH2I.h>
8 #include "AliITSPlaneEff.h"
9
10 ///////////////////////////////////////////
11 //                                       //
12 // ITS Plane Efficiency class            //
13 //       for SPD                         //
14 // Origin: Giuseppe.Bruno@ba.infn.it     //
15 ///////////////////////////////////////////
16
17 /* $Id$ */
18   
19 class AliITSPlaneEffSPD :  public AliITSPlaneEff {
20  public:
21     AliITSPlaneEffSPD(); // default constructor
22     virtual ~AliITSPlaneEffSPD(); // destructror
23     // copy constructor
24     AliITSPlaneEffSPD(const AliITSPlaneEffSPD &source);
25     // ass. operator
26     AliITSPlaneEffSPD& operator=(const AliITSPlaneEffSPD &s);
27     AliITSPlaneEff& operator=(const AliITSPlaneEff &source);
28     //AliPlaneEff& operator=(const AliPlaneEff &source);
29     // Simple way to add another class (i.e. statistics). 
30     AliITSPlaneEffSPD& operator +=( const AliITSPlaneEffSPD &add);
31     // Getters for average Plane efficiency (icluding dead/noisy)
32     Double_t PlaneEff(const UInt_t mod, const UInt_t chip) const;
33     Double_t ErrPlaneEff(const UInt_t mod, const UInt_t chip) const;
34     Double_t PlaneEff(const UInt_t key) const 
35         {return PlaneEff(GetModFromKey(key),GetChipFromKey(key));};
36     Double_t ErrPlaneEff(const UInt_t key) const 
37         {return ErrPlaneEff(GetModFromKey(key),GetChipFromKey(key));};
38     // Methods to update the Plane efficiency (specific of the SPD segmentation) 
39     Bool_t UpDatePlaneEff(const Bool_t Kfound, const UInt_t mod, const UInt_t chip);
40     virtual Bool_t UpDatePlaneEff(const Bool_t Kfound, const UInt_t key)
41         {return UpDatePlaneEff(Kfound,GetModFromKey(key),GetChipFromKey(key));};
42     //
43     enum {kNModule = 240}; // The number of modules
44     enum {kNChip = 5};     // The number of chips per module
45     enum {kNCol = 32};     // The number of columns per chip
46     enum {kNRow = 256};    // The number of rows per chip (and per module)
47
48     enum {kNHisto = kNModule}; // The number of histograms: module by module.  
49     enum {kNclu = 3};          // Build specific histos of residuals up to cluster size kNclu.
50                                // If you change them, then you must change implementation of 
51                                // the method FillHistos.
52 //
53 //  UInt_t GetChip(const UInt_t col) const; // get the chip number (from 0 to kNChip)
54 //  Plane efficiency for active  detector (excluding dead/noisy channels)
55 //  access to DB is needed
56     virtual Double_t LivePlaneEff(UInt_t key) const;
57     Double_t LivePlaneEff(const UInt_t mod, const UInt_t chip) const
58        {return LivePlaneEff(GetKey(mod,chip));};
59     virtual Double_t ErrLivePlaneEff(UInt_t key) const;
60     Double_t ErrLivePlaneEff(const UInt_t mod, const UInt_t chip) const
61        {return ErrLivePlaneEff(GetKey(mod,chip));};
62     // Compute the fraction of Live area (of the CHIP for the SPD)
63     virtual Double_t GetFracLive(const UInt_t key) const;
64     // Compute the fraction of bad (i.e. dead and noisy) area (of the CHIP for the SPD)
65     virtual Double_t GetFracBad(const UInt_t key) const;
66     virtual Bool_t WriteIntoCDB() const;
67     virtual Bool_t ReadFromCDB(); // this method reads Data Members (statistics) from DataBase
68     virtual Bool_t AddFromCDB()   // this method updates Data Members (statistics) from DataBase
69       {AliError("AddFromCDB: Still To be implemented"); return kFALSE;}
70    // method to locate a basic block from Detector Local coordinate (to be used in tracking)
71    // see file cxx for numbering convention.
72    // here idet runs from 0 to 79 for layer 0 and from 0 to 159 for layer 1
73     UInt_t GetKey(const UInt_t mod, const UInt_t chip) const; // unique key to locate the basic
74                                                               // block of the SPD
75     UInt_t GetKeyFromDetLocCoord(Int_t ilay,Int_t idet, Float_t, Float_t locz) const;
76     UInt_t Nblock() const; // return the number of basic blocks
77     // compute the geometrical limit of a basic block (chip) in detector local coordinate system 
78     Bool_t GetBlockBoundaries(const UInt_t key,Float_t& xmn,Float_t& xmx,Float_t& zmn,Float_t& zmx) const;
79   // Methods for dealing with auxiliary histograms
80     // method to set on/off the creation/updates of histograms (Histos are created/destroyed)
81     void   SetCreateHistos(Bool_t his=kFALSE) 
82          //{fHis=his; if(fHis) InitHistos(); else DeleteHistos(); return; }
83          {fHis=his; if(fHis) {DeleteHistos(); InitHistos();} else DeleteHistos(); return; }
84     Bool_t FillHistos(UInt_t key, Bool_t found, Float_t trackXZ[2], Float_t clusterXZ[2], Int_t ctXZ[2]);
85     Bool_t WriteHistosToFile(TString filename="PlaneEffSPDHistos.root",Option_t* option = "RECREATE");
86     Bool_t ReadHistosFromFile(TString filename="PlaneEffSPDHistos.root"); // histos must exist already !
87                                                                           // This method increases the
88                                                                           // statistics of histos by adding 
89                                                                           // those of the input file. 
90  protected:
91     virtual void Copy(TObject &obj) const;           // copy ALL data members to obj 
92                                                      // iboth statistics ad histograms)
93     void CopyHistos(AliITSPlaneEffSPD& target) const; // copy only histograms to target
94     Int_t GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, UInt_t im, UInt_t ic) const;
95
96 // 
97     Int_t fFound[kNModule*kNChip];  // number of associated clusters in a given chip
98     Int_t fTried[kNModule*kNChip];  // number of tracks used for chip efficiency evaluation
99     TH1F **fHisResX; //! histos with residual distribution (track-cluster) along local X (r-phi)
100     TH1F **fHisResZ; //! histos with residual distribution (track-cluster) along local Z
101     TH2F **fHisResXZ; //! 2-d histos with residual distribution (track-cluster) along local X and Z
102     TH2I **fHisClusterSize; //! histos with cluster-size distribution
103     TH1F ***fHisResXclu; //! histos with residual distribution along local X (r-phi) for cluster type 
104     TH1F ***fHisResZclu; //! histos with residual distribution along local Z for cluster type  
105  private:
106     //UInt_t GetKey(const UInt_t mod, const UInt_t chip) const; // unique key to locate the basic 
107                                                               // block of the SPD 
108     UInt_t GetModFromKey(const UInt_t key) const;
109     UInt_t GetChipFromKey(const UInt_t key) const;
110     UInt_t GetChipFromCol(const UInt_t col) const;  // get the chip number (from 0 to kNChip)
111     UInt_t GetColFromLocZ(Float_t zloc) const;      // get the Column from the local z
112     Float_t GetLocZFromCol(const UInt_t col) const; // get the local Z from the column number,  
113                                                     // the latter in the range [0,kNChip*kNCol]
114     Float_t GetLocXFromRow(const UInt_t row) const; // get the local X from the row number  
115                                                     // the latter in the range [0,kNRow]
116     void GetModAndChipFromKey(const UInt_t key, UInt_t& mod, UInt_t& chip) const;
117     void GetDeadAndNoisyInChip(const UInt_t key, UInt_t& dead, UInt_t& noisy) const;
118     void InitHistos();
119     void DeleteHistos();
120
121     ClassDef(AliITSPlaneEffSPD,2) // SPD Plane Efficiency class
122 };
123 //
124 inline UInt_t AliITSPlaneEffSPD::Nblock() const {return kNModule*kNChip;}
125 //
126 #endif
127