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