]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSPlaneEffSDD.h
Remove lgamma and replace by TMath::LnGamma which should work across platforms.
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSDD.h
1 #ifndef ALIITSPLANEEFFSDD_H
2 #define ALIITSPLANEEFFSDD_H
3 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 #include <TH2I.h>
7 #include <TProfile.h>
8 #include "AliITSPlaneEff.h"
9 #include "AliCDBId.h"
10
11 ///////////////////////////////////////////
12 //                                       //
13 // ITS Plane Efficiency class            //
14 //       for SDD                         //
15 // Origin: Giuseppe.Bruno@ba.infn.it     //
16 ///////////////////////////////////////////
17
18 /* $Id$ */
19   
20 class AliITSPlaneEffSDD :  public AliITSPlaneEff {
21  public:
22     AliITSPlaneEffSDD(); // default constructor
23     virtual ~AliITSPlaneEffSDD(); // destructror
24     // copy constructor
25     AliITSPlaneEffSDD(const AliITSPlaneEffSDD &source);
26     // ass. operator
27     AliITSPlaneEffSDD& operator=(const AliITSPlaneEffSDD &s);
28     // Simple way to add another class (i.e. statistics). 
29     AliITSPlaneEffSDD& operator +=( const AliITSPlaneEffSDD &add);
30     // Getters for average Plane efficiency (icluding dead/noisy)
31     Double_t PlaneEff(const UInt_t mod, const UInt_t chip, 
32                       const UInt_t wing, const UInt_t subw=0) const;
33     Double_t ErrPlaneEff(const UInt_t mod, const UInt_t chip,
34                          const UInt_t wing, const UInt_t subw=0) const;
35     Double_t PlaneEff(const UInt_t key) const 
36        {return PlaneEff(GetModFromKey(key),GetChipFromKey(key),
37                         GetWingFromKey(key),GetSubWingFromKey(key));};
38     Double_t ErrPlaneEff(const UInt_t key) const 
39        {return ErrPlaneEff(GetModFromKey(key),GetChipFromKey(key),
40                            GetWingFromKey(key),GetSubWingFromKey(key));};
41     // Getters for fFound[] and fTried[]
42     Int_t GetFound(const UInt_t key) const;
43     Int_t GetTried(const UInt_t key) const;
44     // Methods to update the Plane efficiency (specific of the SDD segmentation) 
45     Bool_t UpDatePlaneEff(const Bool_t Kfound, const UInt_t mod, 
46                           const UInt_t chip, const UInt_t wing, const UInt_t subw=0);
47     Bool_t UpDatePlaneEff(const Bool_t Kfound, const UInt_t key)
48       {return UpDatePlaneEff(Kfound,GetModFromKey(key),GetChipFromKey(key),
49                              GetWingFromKey(key),GetSubWingFromKey(key));};
50     //
51     enum {kNModule = 260}; // The number of modules (i.e. detector 7.25*7.53 cm^2)
52     enum {kNChip = 4}; // The number of chips per half module (i.e. per wing, in total 4+4 chips)
53     enum {kNWing = 2}; // The number of wings (this is hardware division of the module) 
54     enum {kNSubWing = 1}; // Eventually sub-divide each wing (by 2 ?) to account for different 
55                           // efficiencies due to different drift times.  
56     enum {kNAnode = 64};   // Number of channels/chip (i.e. anodes per chip)
57     //enum {kNTimeBin = 174};   // granularity along drift direction (i.e. segmentation in r-phi)
58
59 //
60 //  Plane efficiency for active  detector (excluding dead/noisy channels)
61 //  access to DB is needed
62     virtual Double_t LivePlaneEff(UInt_t key) const;
63     Double_t LivePlaneEff(const UInt_t mod, const UInt_t chip, 
64                           const UInt_t wing, const UInt_t subw=0) const
65        {return LivePlaneEff(GetKey(mod,chip,wing,subw));};
66     virtual Double_t ErrLivePlaneEff(UInt_t key) const;
67     Double_t ErrLivePlaneEff(const UInt_t mod, const UInt_t chip,
68                              const UInt_t wing, const UInt_t subw=0) const
69        {return ErrLivePlaneEff(GetKey(mod,chip,wing,subw));};
70     // Compute the fraction of Live area (of the CHIP/SubWing for the SDD)
71     virtual Double_t GetFracLive(const UInt_t key) const;
72     // Compute the fraction of bad (i.e. dead and noisy) area (of the CHIP/SubWing for the SDD)
73     virtual Double_t GetFracBad(const UInt_t key) const;
74     virtual Bool_t WriteIntoCDB() const;
75     virtual Bool_t ReadFromCDB(); // this method reads Data Members (statistics) from DataBase
76     Bool_t AddFromCDB(AliCDBId *cdbId);   // this method updates Data Members (statistics) from DataBase
77     virtual Bool_t AddFromCDB()  {AliCDBId *cdbId=0; return  AddFromCDB(cdbId);}
78     // method to locate a basic block from Detector Local coordinate (to be used in tracking)
79     // see file cxx for numbering convention.
80     // here idet runs from 0 to 83 for layer 2 and from 0 to 175 for layer 3
81     UInt_t GetKeyFromDetLocCoord(Int_t ilay,Int_t idet, Float_t locx, Float_t locz) const;
82     UInt_t Nblock() const; // return the number of basic blocks
83     // compute the geometrical limit of a basic block in detector local coordinate system
84     Bool_t GetBlockBoundaries(const UInt_t key,Float_t& xmn,Float_t& xmx,Float_t& zmn,Float_t& zmx) const;
85   // Methods for dealing with auxiliary histograms
86     // method to set on/off the creation/updates of histograms (Histos are created/destroyed)
87     void   SetCreateHistos(Bool_t his=kFALSE)
88          {fHis=his; if(fHis) {DeleteHistos(); InitHistos();} else DeleteHistos(); return; }
89     virtual Bool_t FillHistos(UInt_t key, Bool_t found, Float_t *track, Float_t *cluster, Int_t *ctype, Float_t *);
90     virtual Bool_t WriteHistosToFile(TString filename="PlaneEffSDDHistos.root",Option_t* option = "RECREATE");
91     virtual Bool_t ReadHistosFromFile(TString filename="PlaneEffSDDHistos.root"); // histos must exist already !
92                                                                           // This method increases the
93                                                                           // statistics of histos by adding
94                                                                           // those of the input file.
95     UInt_t GetKey(const UInt_t mod, const UInt_t chip,           // unique key to locate the
96                   const UInt_t wing, const UInt_t subw=0) const; // basic block of the SDD
97     // return chip [0,3] and wing [0,1] from the "absolute" chip number [0,7] as defined in AliITSsegmentationSDD
98     void ChipAndWingFromChip07(const Int_t chip07, UInt_t& chip,  UInt_t& wing) const;
99  protected:
100     virtual void Copy(TObject &obj) const;
101     Int_t GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, 
102                                       UInt_t im, UInt_t ic, UInt_t iw,  UInt_t isw=0) const;
103     UInt_t GetModFromKey(const UInt_t key) const;
104     UInt_t GetChipFromKey(const UInt_t key) const;
105     UInt_t GetWingFromKey(const UInt_t key) const;
106     UInt_t GetSubWingFromKey(const UInt_t key) const;
107     // getters for chip and wing numbers, given the anode number [0,511]
108     UInt_t ChipFromAnode(const UInt_t anode) const; // return the chip number (from 0 to kNChip-1)
109     UInt_t WingFromAnode(const UInt_t anode) const; // return the wing number (from 0 to kNWing-1)
110     void   ChipAndWingFromAnode(const UInt_t anode,UInt_t& chip,UInt_t& wing) const;
111     // return the Subwing  (from 0 to kNSubWing-1) from the cell time bin in the range
112     // [0,ntb] and from the number of time bins
113     UInt_t SubWingFromTimeBin(const Int_t tb, const Int_t ntb) const;
114
115     void   ChipAndWingAndSubWingFromLocCoor(Float_t locx, Float_t locz,
116                                  UInt_t& chip, UInt_t& wing, UInt_t& subw) const;
117     //
118     void GetAllFromKey(const UInt_t key, UInt_t& mod, UInt_t& chip,
119                        UInt_t& wing, UInt_t& subw) const;
120     void GetBadInBlock(const UInt_t key, UInt_t& bad) const;
121 // 
122     Int_t fFound[kNModule*kNChip*kNWing*kNSubWing]; // number of associated clusters in a given block
123     Int_t fTried[kNModule*kNChip*kNWing*kNSubWing]; // number of tracks used for efficiency evaluation
124
125  private:
126     enum {kNHisto = kNModule}; // The number of histograms: module by module.
127     enum {kNclu = 3};          // Build specific histos of residuals up to cluster size kNclu.
128                                // If you change them, then you must change implementation of
129                                // the method FillHistos.
130
131     virtual void InitHistos();     // create histos by allocating memory for them
132     virtual void DeleteHistos();   // deletete histos (memory is freed)
133     virtual void CopyHistos(AliITSPlaneEffSDD& target) const; // copy only histograms to target
134
135     TH1F **fHisResX; //! histos with residual distribution (track-cluster) along local X (r-phi)
136     TH1F **fHisResZ; //! histos with residual distribution (track-cluster) along local Z
137     TH2F **fHisResXZ; //! 2-d histos with residual distribution (track-cluster) along local X and Z
138     TH2I **fHisClusterSize; //! histos with cluster-size distribution
139     //TH1F ***fHisResXclu; //! histos with residual distribution along local X (r-phi) for cluster type
140     TProfile **fProfResXvsCluSizeX; //! TProfile of X Residuals vs. cluster size in X 
141     TH1F ***fHisResZclu; //! histos with residual distribution along local Z for cluster type
142     TProfile **fProfResXvsX; //! TProfile of X Residuals vs. X (of the cluster)
143     TProfile **fProfResZvsX; //! TProfile of Z Residuals vs. X (of the cluster)
144     TProfile **fProfClustSizeXvsX; //! TProfile of cluster_size_X vs. X (of the cluster)
145     TProfile **fProfClustSizeZvsX; //! TProfile of cluster_size_X vs. X (of the cluster)
146     TH1F **fHisTrackErrX; //! histos with track prediction error on Local X
147     TH1F **fHisTrackErrZ; //! histos with track prediction error on Local Z
148     TH1F **fHisClusErrX; //! histos with Local_X cluster error
149     TH1F **fHisClusErrZ; //! histos with Local_Z cluster error
150
151     ClassDef(AliITSPlaneEffSDD,2) // SDD Plane Efficiency class
152 };
153 //
154 inline UInt_t AliITSPlaneEffSDD::Nblock() const {return kNModule*kNChip*kNWing*kNSubWing;}
155
156 inline Int_t AliITSPlaneEffSDD::GetFound(const UInt_t key) const {
157  if(key>=kNModule*kNChip*kNWing*kNSubWing) {AliWarning("GetFound: you asked for a non existing key"); return -1;}
158  return fFound[key];
159 }
160 inline Int_t AliITSPlaneEffSDD::GetTried(const UInt_t key) const {
161  if(key>=kNModule*kNChip*kNWing*kNSubWing) {AliWarning("GetTried: you asked for a non existing key"); return -1;}
162  return fTried[key];
163 }
164 inline void AliITSPlaneEffSDD::ChipAndWingFromChip07(const Int_t chip07, UInt_t& chip, 
165                                                            UInt_t& wing) const {
166 if(chip07<0 || chip07>7) 
167   {AliWarning("ChipAndWingFromChip07:  you asked for a non existing chip"); return;}
168 else if(chip07<=3) { chip=chip07; wing=0;}
169 else {chip=chip07-kNChip; wing=1;} 
170 return;
171 }
172 //
173 #endif