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