]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICH.h
Method to count the physical contribution to a cluster added.
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
1 #ifndef AliRICH_h
2 #define AliRICH_h
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 #include <TObjArray.h>
8 #include <TClonesArray.h>
9 #include <TLorentzVector.h>
10 #include <AliDetector.h>
11 #include <AliHit.h>
12 #include <AliDigit.h>
13
14 #include "AliRICHParam.h"
15
16 #include "AliRICHSDigit.h"
17
18 //__________________AliRICHhit______________________________________________________________________
19 class AliRICHhit : public AliHit
20 {
21 public:
22   inline   AliRICHhit();
23   inline   AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits);
24   inline   AliRICHhit(Int_t tid,TVector3 x3,Double_t eloss);
25   virtual ~AliRICHhit()         {;}
26     
27   Int_t   C()                   const{return fChamber;}
28   Int_t   Chamber()             const{return fChamber;}
29   Int_t   Pid()                 const{return fPid;}    
30   Int_t   Particle()            const{return fPid;}
31   Float_t Eloss()               const{return fEloss;}
32   Float_t MomX()                const{return fMomX;}
33   Float_t MomY()                const{return fMomY;}
34   Float_t MomZ()                const{return fMomZ;}
35   Float_t CerenkovAngle()       const{return fCerenkovAngle;}
36   Float_t MomFreoX()            const{return fMomFreoX;}
37   Float_t MomFreoY()            const{return fMomFreoY;}
38   Float_t MomFreoZ()            const{return fMomFreoZ;}
39   void    Print(Option_t *option="")const;      //virtual
40 protected:
41   Int_t     fChamber;                      //chamber number
42   Int_t     fPid;                          //particle code
43   Double_t  fEloss;                        //ionisation energy loss in gas
44   Float_t   fMomX,fMomY,fMomZ;             //momentum at photochatode entry point
45   Float_t   fNPads;                        // Pads hit
46   Float_t   fCerenkovAngle;                // Dummy cerenkov angle
47   Float_t   fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
48   ClassDef(AliRICHhit,2)                   //RICH hit class
49 };//class AliRICHhit
50
51   //__________________________________________________________________________________________________
52 AliRICHhit::AliRICHhit()
53            :AliHit() 
54 {//default ctor  
55   fChamber=fPid=kBad;
56   fEloss=kBad;
57   fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
58 }
59 //__________________________________________________________________________________________________
60 AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit)
61            :AliHit(shunt, track)
62 {//ctor
63   fChamber=vol[0];
64   fPid=(Int_t)hit[0];
65   fX=hit[1];fY=hit[2];fZ=hit[3];
66   fEloss=hit[7];
67   fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
68   fCerenkovAngle=hit[18];
69   fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
70 }
71 //__________________________________________________________________________________________________
72 AliRICHhit::AliRICHhit(Int_t tid,TVector3 x3,Double_t eloss)
73            :AliHit(0,tid)
74 {//ctor
75   fX=x3.X();fY=x3.Y();fZ=x3.Z();
76   fEloss=eloss;
77 }
78
79 //__________________AliRICHCerenkov_________________________________________________________________
80 class AliRICHCerenkov: public AliHit 
81 {
82 public:
83   inline   AliRICHCerenkov();
84   inline   AliRICHCerenkov(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *Cerenkovs);
85   virtual ~AliRICHCerenkov() {;}
86 protected:
87   Int_t     fChamber;          //chamber number
88   Float_t   fTheta,fPhi;       //incident theta phi angles in degrees      
89   Float_t   fTlength;          //track length inside the chamber
90   Float_t   fEloss;            //ionisation energy loss in gas
91   Int_t     fPHfirst;          //first padhit
92   Int_t     fPHlast;           //last padhit
93   Int_t     fCMother;          //index of mother particle
94   Float_t   fLoss;             //nature of particle loss
95   Float_t   fIndex;            //index of photon
96   Float_t   fProduction;       //point of production
97   Float_t   fMomX,fMomY,fMomZ; //local Momentum
98   Float_t   fNPads;           // Pads hit
99   Float_t   fCerenkovAngle;   // Cerenkov Angle
100     
101   ClassDef(AliRICHCerenkov,1)  //RICH cerenkov class
102 };//class AliRICHCerenkov
103
104 //__________________________________________________________________________________________________
105 AliRICHCerenkov::AliRICHCerenkov()
106 {//ctor
107     fChamber=kBad;
108     fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
109     fPHfirst=fPHlast=fCMother=kBad;
110     fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
111 }
112 //__________________________________________________________________________________________________
113 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
114                 :AliHit(shunt, track)
115 {//ctor
116     fChamber=vol[0];
117     fX=hits[1];fY=hits[2];fZ=hits[3];
118     fTheta=hits[4];fPhi=hits[5];
119     fTlength=hits[6];
120     fEloss=hits[7];
121     fPHfirst=(Int_t)hits[8];fPHlast=(Int_t)hits[9];
122     fCMother=Int_t(hits[10]);
123     fIndex = hits[11];
124     fProduction = hits[12];  
125     fLoss=hits[13];
126     fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
127     fNPads=hits[17];
128     fCerenkovAngle=hits[18];
129 }
130
131 //__________________AliRICHdigit____________________________________________________________________
132 class AliRICHdigit :public AliDigit
133 {
134 public:
135            AliRICHdigit() {fCombiPid=fChamber=fPadX=fPadY=fTracks[0]=fTracks[1]=fTracks[2]=kBad;fQdc=kBad;}
136            AliRICHdigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t cpid,Int_t tid0,Int_t tid1,Int_t tid2)
137            {fPadX=x;fPadY=y;fQdc=q;fChamber=10*c+AliRICHParam::Pad2Sec(x,y);fCombiPid=cpid;fTracks[0]=tid0;fTracks[1]=tid1;fTracks[2]=tid2;}        
138   virtual ~AliRICHdigit() {;}  
139   Int_t    Compare(const TObject *pObj) const                                         //virtual
140            {if(Id()==((AliRICHdigit*)pObj)->Id()) return 0; else if(Id()>((AliRICHdigit*)pObj)->Id()) return 1;  else return -1;} 
141            
142            Bool_t   IsSortable()                                  const{return kTRUE;}//virtual
143            Int_t    CombiPid()                                    const{return fCombiPid;}
144            Int_t    C()                                           const{return fChamber/10;}
145            Int_t    S()                                           const{return fChamber-(fChamber/10)*10;} 
146            Int_t    Chamber()                                     const{return C();}
147            Int_t    Sector()                                      const{return S();}
148            Int_t    X()                                           const{return fPadX;}
149            Int_t    Y()                                           const{return fPadY;}
150            Int_t    Id()                                          const{return fChamber*10000000+fPadX*1000+fPadY;}
151            Double_t Q()                                           const{return fQdc;}
152            Int_t    Tid(Int_t i)                                  const{return fTracks[i];}
153            void  Print(Option_t *option="")const;                 //virtual
154 protected:
155   Int_t    fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips  
156   Int_t    fChamber;  //10*chamber number+ sector number 
157   Int_t    fPadX;     //pad number along X
158   Int_t    fPadY;     //pad number along Y
159   Double_t fQdc;      //QDC value, fractions are permitted for summable procedure  
160   ClassDef(AliRICHdigit,2) //RICH digit class       
161 };//class AliRICHdigit
162
163 //__________________AliRICHcluster__________________________________________________________________
164 class AliRICHcluster :public TObject
165 {
166 public:
167   enum ClusterStatus {kOK,kEdge,kShape,kSize,kRaw};
168                     AliRICHcluster()                                 {fSize=fQdc=fStatus=fChamber=fDimXY=kBad;fX=fY=kBad;fDigits=0;}
169   virtual          ~AliRICHcluster()                                 {delete fDigits;}  
170   AliRICHcluster&   operator=(const AliRICHcluster&)                 {return *this;}
171          Int_t      Size()                                      const{return fSize;}                       //
172          Int_t      DimXY()                                     const{return fDimXY;}                      //
173          Int_t      C()                                         const{return fChamber/10;}                 //
174          Int_t      S()                                         const{return fChamber-(fChamber/10)*10;}   //
175          Int_t      Chamber()                                   const{return C();}                         //
176          Int_t      Sector()                                    const{return S();}                         //
177          Int_t      Q()                                         const{return fQdc;}                        // 
178          Double_t   X()                                         const{return fX;}                          //
179          Double_t   Y()                                         const{return fY;}                          // 
180          Int_t      Status()                                    const{return fStatus;}                     //
181          void       SetStatus(Int_t status)                          {fStatus=status;}                     //
182          Int_t      Nmips()                                     const{return fCombiPid-1000000*Ncerenkovs()-1000*Nfeedbacks();}  //
183          Int_t      Ncerenkovs()                                const{return fCombiPid/1000000;}           //
184          Int_t      Nfeedbacks()                                const{return (fCombiPid-1000000*Ncerenkovs())/1000;}      //
185          Bool_t     IsPureMip()                                 const{return fCombiPid<1000;}   
186          Bool_t     IsPureCerenkov()                            const{return Nmips()==0&&Nfeedbacks()==0;} //
187          Bool_t     IsPureFeedback()                            const{return Nmips()==0&&Ncerenkovs()==0;} //
188          void       SetCombiPid(Int_t ckov,Int_t feeds,Int_t mips)   {fCombiPid=1000000*ckov+1000*feeds+mips;}            //
189          TObjArray* Digits()                                    const{return fDigits;}                     //  
190          void       Print(Option_t *option="")const;                                                       //virtual
191   inline void       AddDigit(AliRICHdigit *pDig);                                                          //
192   inline void       CoG();                                                                                 // 
193          void       Reset() {fSize=fQdc=fStatus=fChamber=fDimXY=kBad;fX=fY=kBad;delete fDigits;fDigits=0;} //
194 protected:
195   Int_t         fCombiPid;    //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips  
196   Int_t         fSize;        //how many digits belong to this cluster    
197   Int_t         fDimXY;       //100*xdim+ydim box containing the cluster
198   Int_t         fQdc;         //QDC value
199   Int_t         fChamber;     //10*module number+sector number 
200   Double_t      fX;           //local x postion 
201   Double_t      fY;           //local y postion  
202   Int_t         fStatus;      //flag to mark the quality of the cluster   
203   TObjArray    *fDigits;      //! list of digits forming this cluster
204   ClassDef(AliRICHcluster,2)  //RICH cluster class       
205 };//class AliRICHcluster
206 //__________________________________________________________________________________________________
207 void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
208 {//    
209   if(!fDigits) {fQdc=fSize=fCombiPid=0;fDigits = new TObjArray;}
210   fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
211   fChamber=10*pDig->C()+pDig->S();
212   fSize++;
213 }
214 //__________________________________________________________________________________________________
215 void AliRICHcluster::CoG()
216 {//
217   Int_t xmin=999,ymin=999,xmax=0,ymax=0;   
218   Double_t x,y;        
219   fX=fY=0;
220   for(Int_t iDig=0;iDig<Size();iDig++) {
221     AliRICHdigit *pDig=(AliRICHdigit*)fDigits->At(iDig);
222     Int_t padX = pDig->X();Int_t padY = pDig->Y();Double_t q=pDig->Q();
223     AliRICHParam::Pad2Loc(padX,padY,x,y);
224     fX += x*q;fY +=y*q;
225     if(padX<xmin)xmin=padX;if(padX>xmax)xmax=padX;if(padY<ymin)ymin=padY;if(padY>ymax)ymax=padY;
226    }
227    fX/=fQdc;fY/=fQdc;//Center of Gravity
228    fDimXY = 100*(xmax-xmin+1)+ymax-ymin+1;//find box containing cluster
229    fStatus=kRaw;
230 }//CoG()
231
232 //__________________AliRICH_________________________________________________________________________
233 class AliRICHParam;
234 class AliRICHChamber;
235 class AliRICHSDigit;
236
237 class AliRICH : public AliDetector 
238 {
239 public:
240             AliRICH();                                            
241             AliRICH(const char *name, const char *title);         
242             AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}   
243   virtual  ~AliRICH();                                            
244           
245   AliRICH&  operator=(const AliRICH&)                 {return *this;}
246   virtual Int_t   IsVersion()                                            const =0;            
247           void    Hits2SDigits();                                                                                 //virtual
248           void    SDigits2Digits();                                                                               //virtual
249   
250   inline  void    CreateHits();    
251   inline  void    CreateSDigits();  
252   inline  void    CreateDigits();  
253   inline  void    CreateClusters();  
254   void AddHit(Int_t track, Int_t *vol, Float_t *hits)     {TClonesArray &tmp=*fHits; new(tmp[fNhits++])AliRICHhit(fIshunt,track,vol,hits);}//virtual
255   void AddHit(Int_t tid,TVector3 x3,Double_t eloss=0)     {TClonesArray &tmp=*fHits;new(tmp[fNhits++])AliRICHhit(tid,x3,eloss);} 
256   inline void AddSDigit(int c,int x,int y,int q,int pid,int tid); 
257   void AddDigit(int c,int x,int y,int q,int cpid,int *tid){TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(c-1));new(tmp[fNdigitsNew[c-1]++])AliRICHdigit(c,x,y,q,cpid,tid[0],tid[1],tid[2]);}  
258   void AddCluster(AliRICHcluster &cl)                     {TClonesArray &tmp=*((TClonesArray*)fClusters->At(cl.C()-1));new(tmp[fNclusters[cl.C()-1]++])AliRICHcluster(cl);}
259   
260   void ResetHits()     {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();}  //virtual  
261   void ResetSDigits()  {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();}                                 
262   void ResetDigits()   {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
263   void ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
264                   //Hits provided by AliDetector
265   TClonesArray*   SDigits()             const{return fSdigits;}
266   TClonesArray*   Digits(Int_t iC)      const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
267   TClonesArray*   Clusters(Int_t iC)    const{if(fClusters)  return (TClonesArray *)fClusters->At(iC-1);else return 0;}
268           
269   AliRICHChamber* C(Int_t iC)           const{return (AliRICHChamber*)fChambers->At(iC-1);}
270   AliRICHParam*   Param()               const{return fpParam;}
271   AliRICHParam*   P()                   const{return fpParam;}
272           void    CreateChambers();         
273           void    CreateMaterials(); //virtual
274   virtual void    BuildGeometry();   //virtual
275   virtual void    CreateGeometry();  //virtual
276           Float_t AbsoCH4(Float_t x)const;
277           Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)const;
278   
279   virtual void    StepManager()=0;
280           void    GenerateFeedbacks(Int_t iChamber,Float_t eloss);
281           void    Print(Option_t *option)const;//virtual
282           void    MakeBranch(Option_t *opt=" ");
283           void    SetTreeAddress();//virtual
284 // OLD staff OLD staff    
285   inline  void    AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
286   inline  void    AddSpecialOld(Int_t *array);      
287           
288   inline  void    CreateCerenkovsOld();  
289   inline  void    CreateSpecialsOld();   
290           void    ResetSpecialsOld(){fNspecials=0; if(fSpecials) fSpecials->Clear();}   
291   TClonesArray*   Specials()            const{return fSpecials;}
292   TClonesArray*   Cerenkovs()           const{return fCerenkovs;}
293   
294   
295             
296   AliRICHChamber& Chamber(Int_t id)      {return *((AliRICHChamber *) (*fChambers)[id]);}  
297 //          Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)      {return 9999;}
298     
299 protected:  
300   enum       {kCSI=6,kGAP=9};
301   AliRICHParam         *fpParam;             //main RICH parametrization     
302   TObjArray            *fChambers;           //list of RICH chambers
303                 //fHits and fDigits belong to AliDetector
304   TClonesArray         *fSdigits;            //! List of sdigits  
305   Int_t                 fNsdigits;           //! Current number of sdigits
306   TObjArray            *fDigitsNew;          //! Each chamber holds it's one lists of digits
307   Int_t                 fNdigitsNew[kNCH];   //! Array of current numbers of digits
308   TObjArray            *fClusters;           //! Each chamber holds it's one lists of clusters 
309   Int_t                 fNclusters[kNCH];    //! Array of current numbers of raw clusters
310
311   TClonesArray         *fCerenkovs;          //! ??? List of cerenkovs
312   Int_t                 fNcerenkovs;         //! ??? Current number of cerenkovs
313   TClonesArray         *fSpecials;           //! ??? List of specials
314   Int_t                 fNspecials;          //! ??? Current number of specials  
315   Int_t fCkovNumber;                         // Number of Cerenkov photons
316   Int_t fFreonProd;                          // Cerenkovs produced in freon
317   Int_t fFeedbacks;                          // Number of feedback photons
318     
319   ClassDef(AliRICH,4)                        //Main RICH class 
320 };//class AliRICH  
321
322 //__________________________________________________________________________________________________
323 void AliRICH::CreateHits()
324 {
325   if(fHits) return;
326   if(GetDebug())Info("CreateHits","creating hits container.");
327   fHits=new TClonesArray("AliRICHhit",10000);   fNhits=0;
328 }
329 //__________________________________________________________________________________________________
330 void AliRICH::CreateSDigits()
331 {
332   if(fSdigits) return;
333   if(GetDebug())Info("CreateSDigits","creating sdigits container.");
334   fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
335 }
336 //__________________________________________________________________________________________________
337 void AliRICH::CreateDigits()
338 {
339   if(fDigitsNew) return;
340   if(GetDebug())Info("CreateDigits","creating digits containers.");
341   fDigitsNew = new TObjArray(kNCH);  
342   for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
343 }
344 //__________________________________________________________________________________________________
345 void AliRICH::CreateClusters()
346 {
347   if(fClusters) return;
348   if(GetDebug())Info("CreateClusters","creating clusters containers.");
349   fClusters = new TObjArray(kNCH);  
350   for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
351 }
352 //__________________________________________________________________________________________________
353 void AliRICH::AddSDigit(int c,int x,int y,int q,int pid,int tid) 
354 {   
355   switch(pid){
356     case 50000048: pid=1000000;break;
357     case 50000052: pid=1000;   break;
358     default:       pid=1;      break;
359   }   
360   TClonesArray &tmp=*fSdigits;
361   new(tmp[fNsdigits++])AliRICHdigit(c,x,y,q,pid,tid,kBad,kBad);
362 }//AddSDigit()   
363
364
365 //______OLD OLD OLD OLD_____________________________________________________________________________
366 void AliRICH::CreateCerenkovsOld()
367 {
368   if(fCerenkovs) return;
369   if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
370   fCerenkovs=new TClonesArray("AliRICHCerenkov",10000);   fNcerenkovs=0;
371 }
372 //__________________________________________________________________________________________________
373 void AliRICH::CreateSpecialsOld()
374 {
375   if(fSpecials) return;
376   if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
377   fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
378 }
379 //__________________________________________________________________________________________________
380 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
381 {//Adds the current RICH cerenkov hit to the Cerenkovs list   
382   TClonesArray &tmp=*fCerenkovs;
383   new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
384 }
385 //__________________________________________________________________________________________________
386 void AliRICH::AddSpecialOld(Int_t *aiSDigit)
387 {// Adds the current Sdigit to the RICH list of Specials
388   TClonesArray &lSDigits = *fSpecials;
389   new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
390 }
391 #endif//#ifndef AliRICH_h