Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSDD.h
CommitLineData
6344adcc 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
3ebe30ad 6#include <TH2I.h>
7#include <TProfile.h>
6344adcc 8#include "AliITSPlaneEff.h"
1cc5cedc 9#include "AliCDBId.h"
6344adcc 10
11///////////////////////////////////////////
12// //
13// ITS Plane Efficiency class //
14// for SDD //
15// Origin: Giuseppe.Bruno@ba.infn.it //
16///////////////////////////////////////////
17
162637e4 18/* $Id$ */
6344adcc 19
20class 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);
6344adcc 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));};
41d18cd2 41 // Getters for fFound[] and fTried[]
42 Int_t GetFound(const UInt_t key) const;
43 Int_t GetTried(const UInt_t key) const;
6344adcc 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);
1cc5cedc 47 Bool_t UpDatePlaneEff(const Bool_t Kfound, const UInt_t key)
6344adcc 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)
7167ae53 57 //enum {kNTimeBin = 174}; // granularity along drift direction (i.e. segmentation in r-phi)
3ebe30ad 58
6344adcc 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
1cc5cedc 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);}
7167ae53 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
aa0de373 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;
3ebe30ad 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; }
1cc5cedc 89 //Bool_t FillHistos(UInt_t key, Bool_t found, Float_t trackXZ[2], Float_t clusterXZ[2], Int_t ctXZ[2]);
90 virtual Bool_t FillHistos(UInt_t key, Bool_t found, Float_t *track, Float_t *cluster, Int_t *ctype);
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 !
3ebe30ad 93 // This method increases the
94 // statistics of histos by adding
95 // those of the input file.
1cc5cedc 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
41d18cd2 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;
6344adcc 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;
1cc5cedc 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;
6344adcc 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
1cc5cedc 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
3ebe30ad 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
41d18cd2 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
3ebe30ad 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)
41d18cd2 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
6344adcc 151
3ebe30ad 152 ClassDef(AliITSPlaneEffSDD,2) // SDD Plane Efficiency class
6344adcc 153};
7167ae53 154//
155inline UInt_t AliITSPlaneEffSDD::Nblock() const {return kNModule*kNChip*kNWing*kNSubWing;}
41d18cd2 156
157inline 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}
161inline 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}
165inline void AliITSPlaneEffSDD::ChipAndWingFromChip07(const Int_t chip07, UInt_t& chip,
166 UInt_t& wing) const {
167if(chip07<0 || chip07>7)
168 {AliWarning("ChipAndWingFromChip07: you asked for a non existing chip"); return;}
169else if(chip07<=3) { chip=chip07; wing=0;}
170else {chip=chip07-kNChip; wing=1;}
171return;
172}
7167ae53 173//
6344adcc 174#endif