10cc58420292adb9eaaac46fb88cd90a65487666
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
1 #ifndef AliRICH_h
2 #define AliRICH_h
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 #include <AliDetector.h>  //inheritance
7 #include <TClonesArray.h> 
8 #include <TObjArray.h>
9 #include <TVector.h>
10 #include <TVector3.h>
11
12 #include "AliRICHParam.h"
13 #include "AliRICHCluster.h"
14 #include "AliRICHHit.h"
15
16 //__________________AliRICH_________________________________________________________________________
17 class AliESD;
18
19 class AliRICH : public AliDetector 
20 {
21 public:
22 //ctor & dtor    
23             AliRICH();                                            
24             AliRICH(const char *name, const char *title);
25             AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}  //copy ctor 
26   virtual  ~AliRICH();                                            
27           
28   AliRICH&  operator=(const AliRICH&)                 {return *this;}
29 //framework part  
30   virtual Int_t         IsVersion()                           const =0;                                  //interface from         
31   virtual void          StepManager()                               =0;                                  //interface from AliMC
32   virtual void          SetTreeAddress();                                                                //interface from AliLoader
33   virtual void          MakeBranch(Option_t *opt=" ");                                                   //interface from AliLoader
34   virtual void          CreateMaterials();                                                               //interface from AliMC
35   virtual void          CreateGeometry();                                                                //interface from AliMC
36   virtual void          BuildGeometry();                                                                 //interface 
37   virtual void          Print(Option_t *option="")               const;       //prints current RICH status
38 //private part  
39           void          GeomPadPanelFrame()const;                                                        //defines PPF geometry
40           void          GeomAmpGap()       const;                                                        //defines gap geometry + anod wires
41           void          GeomRadiators()    const;                                                        //defines radiators geometry
42           void          GeomSandBox()      const;                                                        //defines sandbox geometry
43           void          GeomRadioSrc()     const;                                                        //defines radio source geometry
44           void          GeomAerogel()      const;                                                        //defines aerogel geometry
45   static  Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola);       //deals with Fresnel absorption
46   
47          AliRICHHit*   Hit           (Int_t tid                                              )const;                                                 //first hit of given TID 
48   inline void          HitAdd        (Int_t c,Int_t tid,TVector3 in,TVector3 out,Double_t e=0);                                                      //add new hit
49   inline void          HitsCreate    (                                                       );                                                      //create hits container
50          void          HitsPrint     (Int_t iEvent=0                                         )const;                                                 //prints hits
51          void          HitsQA        (Double_t cut=0,Double_t cutele=0,Double_t cutR=999);
52             
53          TClonesArray* SDigits       (                                                       )const{return fSdigits;}                                //pointer to sdigits list 
54   inline void          SDigitAdd     (Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid     )     ;                                                 //add new sdigit
55   inline void          SDigitsCreate (                                                       )     ;                                                 //create sdigits container
56          void          SDigitsReset  (                                                       )     {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();} //clean a list of sdigits                                
57          void          SDigitsPrint  (Int_t iEvent=0                                         )const;                                                 //prints sdigits 
58          
59     using AliDetector::Digits;  
60          TClonesArray* Digits        (Int_t iC                                               )const{return fDigs ? (TClonesArray *)fDigs->At(iC-1):0;}
61   inline void          DigitAdd      (Int_t c,TVector pad,int q,int cfm,int *tid             )     ;                                                 //add new digit
62   inline void          DigitAdd      (AliRICHDigit &dif                                      )     ;                                                 //add new digit
63   inline void          DigitsCreate  (                                                       )     ;                                                 //create digits
64          void          DigitsReset   (                                                       )     {if(fDigs)for(int i=0;i<kNchambers;i++){fDigs->At(i)->Clear();fNdigs[i]=0;}} //virtual
65          void          DigitsPrint   (Int_t iEvent=0                                         )const;                                                 //prints digits
66           
67          TClonesArray* Clusters      (Int_t iC                                               )const{if(fClus)  return (TClonesArray *)fClus->At(iC-1);else return 0;}
68   inline void          ClusterAdd    (AliRICHCluster &cl                                     )     ;                                                  //add new cluster                        
69   inline void          ClustersCreate(                                                       )     ;                                                  //create clusters container
70          void          ClustersReset (                                                       )     {if(fClus)for(int i=0;i<kNchambers;i++){fClus ->At(i)->Clear();fNclus[i]=0;}}
71          void          ClustersPrint (Int_t iEvent=0                                         )const;                        //prints a list of clusters for a given event
72
73          void          OccupancyPrint(Int_t iEvent=-1                                        )const;
74          void          SummaryOfEvent(Int_t iEvent=0                                         )const;
75          
76   AliRICHChamber* C(Int_t iC)           const{return fParam->C(iC);}   //provides pointer to a given chamber
77   AliRICHParam*   P()                   const{return fParam;}          //provides pointer to a RICH params
78   AliRICH*        R()                        {return this;}             //provides pointer to RICH main object
79   TVector         Counters()            const{return fCounters;}        //provides a set of counters
80   void            ControlPlots();                                       //creates ~/RCP.root with a set of QA plots
81   void            Display()const; //Display event
82   void            DisplayEvent(Int_t,Int_t)const; //Display event
83   static Int_t     Nparticles(Int_t iPid,Int_t iEventN,AliRunLoader *pRunLoader); //counts total number of particle with iPid
84   void            PrintTracks  (Int_t iEvent=0);                        //prints a list of tracks for a given event
85   void            CheckPR      ()const;                                 //utility-> run staff for stack ??????     
86   void            ReadESD(Int_t iEventN, Int_t iChamber)const;
87   void            DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const;
88
89 protected:  
90   enum                  EMedia {kAir=1,kRoha,kSiO2,kC6F14,kCH4,kCsI,kGridCu,kOpSiO2,kGap,kAl,kGlass,kCu,kW,kSteel,kPerpex,kSr90,kMylar,kGel,kReflector};
91   enum                  ECounters {kStepManager=0,kCerProdTot,kCerProdRad,kCerKillTot,kCerKillRad,kCerKillRef,kEleProdTot};
92   AliRICHParam         *fParam;                    //main RICH parametrization     
93                                                    //fHits and fDigits belong to AliDetector
94   TClonesArray         *fSdigits;                  //! list of sdigits  
95   Int_t                 fNsdigits;                 //! current number of sdigits
96   
97   TObjArray            *fDigs;                     //! each chamber holds it's one lists of digits
98   Int_t                 fNdigs[7];                 //! array of current numbers of digits
99   
100   TObjArray            *fClus;                     //! each chamber holds it's one lists of clusters 
101   Int_t                 fNclus[7];                 //! array of current numbers of raw clusters
102   
103   TVector               fCounters;                 //Particle history counters, explanation in StepManager() 
104   
105   ClassDef(AliRICH,9)                              //Main RICH class 
106 };//class AliRICH  
107
108 //__________________________________________________________________________________________________
109 void AliRICH::HitsCreate()
110 {
111   if(fHits) return;
112   AliDebug(1,"creating hits container.");
113   fHits=new TClonesArray("AliRICHHit",10000);   fNhits=0;
114 }
115 //__________________________________________________________________________________________________
116 void AliRICH::HitAdd(Int_t c,Int_t tid,TVector3 i3,TVector3 o3,Double_t eloss)
117 {
118 //add new RICH hit to the list of hits  
119   TClonesArray &tmp=*fHits;
120   new(tmp[fNhits++])AliRICHHit(c,tid,i3,o3,eloss);
121 }//AddHit()
122 //__________________________________________________________________________________________________
123 void AliRICH::SDigitsCreate()
124 {
125   if(fSdigits) return;
126   AliDebug(1,"creating sdigits container.");
127   fSdigits=new TClonesArray("AliRICHDigit",10000); fNsdigits=0;
128 }
129 //__________________________________________________________________________________________________
130 void AliRICH::SDigitAdd(Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid) 
131
132   Int_t cfm;  
133   switch(pid){
134     case 50000050: cfm=1000000;break;//cerenkov
135     case 50000051: cfm=1000;   break;//feedback
136     default:       cfm=1;      break;//mip
137   }   
138   TClonesArray &tmp=*fSdigits; new(tmp[fNsdigits++])AliRICHDigit(c,pad,q,cfm,tid,-1,-1);
139 }
140 //__________________________________________________________________________________________________
141 void AliRICH::DigitsCreate()
142 {
143   if(fDigs) return;
144   AliDebug(1,"creating digits containers.");
145   fDigs = new TObjArray(kNchambers);  
146   for(Int_t i=0;i<kNchambers;i++) {fDigs->AddAt(new TClonesArray("AliRICHDigit",10000), i); fNdigs[i]=0;}
147 }
148 //__________________________________________________________________________________________________
149 void AliRICH::DigitAdd(AliRICHDigit &dig)
150 {
151 //special for digit formed from raw  
152   TClonesArray &tmp=*((TClonesArray*)fDigs->At(dig.Chamber()-1));
153   new(tmp[fNdigs[dig.Chamber()-1]++])AliRICHDigit(dig);
154 }    
155 //__________________________________________________________________________________________________
156 void AliRICH::DigitAdd(int c,TVector pad,int q,int cfm,int *tid)
157 {
158   TClonesArray &tmp=*((TClonesArray*)fDigs->At(c-1));
159   new(tmp[fNdigs[c-1]++])AliRICHDigit(c,pad,q,cfm,tid[0],tid[1],tid[2]);
160 }    
161 //__________________________________________________________________________________________________
162 void AliRICH::ClustersCreate()
163 {
164   if(fClus) return;
165   AliDebug(1,"creating clusters containers.");
166   fClus = new TObjArray(kNchambers);  
167   for(Int_t i=0;i<kNchambers;i++) {fClus->AddAt(new TClonesArray("AliRICHCluster",10000), i); fNclus[i]=0;}
168 }
169 //__________________________________________________________________________________________________
170 void AliRICH::ClusterAdd(AliRICHCluster &cl)                     
171 {
172   Int_t c=cl.C()-1;TClonesArray &tmp=*((TClonesArray*)fClus->At(c));
173   new(tmp[fNclus[c]++])AliRICHCluster(cl);
174 }
175 //__________________________________________________________________________________________________
176 #endif//#ifndef AliRICH_h