]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICH.h
9a3cb061609de45dd9a953ff843209ed8963dc7d
[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 "AliRICHConst.h"
15 #include "AliRICHChamber.h"
16
17 #include "AliRICHDigit.h"
18 #include "AliRICHSDigit.h"
19 #include "AliRICHRawCluster.h"
20 class AliRICHRecHit1D;
21
22 //__________________AliRICHhit______________________________________________________________________
23 //__________________________________________________________________________________________________
24 //__________________________________________________________________________________________________
25 class AliRICHhit : public AliHit
26 {
27 public:
28   inline   AliRICHhit();
29   inline   AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits);
30   inline   AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss);
31   virtual ~AliRICHhit()         {;}
32     
33   Int_t   C()                   {return fChamber;}
34   Int_t   Chamber()             {return fChamber;}
35   Int_t   Pid()                 {return fPid;}    
36   Int_t   Particle()            {return fPid;}
37   Float_t Theta()               {return fTheta;}
38   Float_t Phi()                 {return fPhi;}
39   Float_t Tlength()             {return fTlength;}
40   Float_t Eloss()               {return fEloss;}
41   Float_t Loss()                {return fLoss;}
42   Float_t PHfirst()             {return fPHfirst;}
43   Float_t PHlast()              {return fPHlast;}
44   Float_t MomX()                {return fMomX;}
45   Float_t MomY()                {return fMomY;}
46   Float_t MomZ()                {return fMomZ;}
47   Float_t CerenkovAngle()       {return fMomX;}
48   Float_t MomFreoX()            {return fMomX;}
49   Float_t MomFreoY()            {return fMomY;}
50   Float_t MomFreoZ()            {return fMomZ;}
51   void    Print(Option_t *option="")const;      //virtual
52 protected:
53   Int_t     fChamber;                      //chamber number
54   Int_t     fPid;                          //particle code
55   Float_t   fTheta,fPhi ;                  //incident theta phi angles in degrees      
56   Float_t   fTlength;                      //track length inside the chamber
57   Float_t   fEloss;                        //ionisation energy loss in gas   
58   Float_t   fPHfirst;                      //first padhit
59   Float_t   fPHlast;                       //last padhit
60   Float_t   fLoss;                         // did it hit the freon?
61   Float_t   fMomX,fMomY,fMomZ;             //momentum at photochatode entry point
62   Float_t   fNPads;                        // Pads hit
63   Float_t   fCerenkovAngle;                // Dummy cerenkov angle
64   Float_t   fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
65   ClassDef(AliRICHhit,1)                   //RICH hit class
66 };//class AliRICHhit
67
68   //__________________________________________________________________________________________________
69 AliRICHhit::AliRICHhit()
70            :AliHit() 
71 {//default ctor  
72   fChamber=fPid=kBad;
73   fTheta=fPhi=fTlength=fEloss=fPHfirst=fPHlast=fLoss=kBad;
74   fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
75 }
76 //__________________________________________________________________________________________________
77 AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
78             AliHit(shunt, track)
79 {//ctor
80   fChamber=vol[0];
81   fPid=(Int_t)hit[0];
82   fX=hit[1];fY=hit[2];fZ=hit[3];
83   fTheta=hit[4];fPhi=hit[5];
84   fTlength=hit[6];
85   fEloss=hit[7];
86   fPHfirst=(Int_t)hit[8];
87   fPHlast=(Int_t)hit[9];
88   fLoss=hit[13];
89   fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
90   fNPads=hit[17];
91   fCerenkovAngle=hit[18];
92   fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
93 }
94 //__________________________________________________________________________________________________
95 AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss):
96             AliHit(0, track)
97 {//ctor
98   fChamber=iChamber;
99   fPid=iPID;
100   fX=x4.X();fY=x4.Y();fZ=x4.Z();
101   fEloss=eloss;
102 }
103
104 //__________________AliRICHCerenkov_________________________________________________________________
105 //__________________________________________________________________________________________________
106 //__________________________________________________________________________________________________
107 class AliRICHCerenkov: public AliHit 
108 {
109 public:
110   inline   AliRICHCerenkov();
111   inline   AliRICHCerenkov(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *Cerenkovs);
112   virtual ~AliRICHCerenkov() {;}
113 public:
114   Int_t     fChamber;          //chamber number
115   Float_t   fTheta,fPhi;       //incident theta phi angles in degrees      
116   Float_t   fTlength;          //track length inside the chamber
117   Float_t   fEloss;            //ionisation energy loss in gas
118   Int_t     fPHfirst;          //first padhit
119   Int_t     fPHlast;           //last padhit
120   Int_t     fCMother;          //index of mother particle
121   Float_t   fLoss;             //nature of particle loss
122   Float_t   fIndex;            //index of photon
123   Float_t   fProduction;       //point of production
124   Float_t   fMomX,fMomY,fMomZ; //local Momentum
125   Float_t   fNPads;           // Pads hit
126   Float_t   fCerenkovAngle;   // Cerenkov Angle
127     
128   ClassDef(AliRICHCerenkov,1)  //RICH cerenkov class
129 };//class AliRICHCerenkov
130
131 //__________________________________________________________________________________________________
132 AliRICHCerenkov::AliRICHCerenkov()
133 {//ctor
134     fChamber=kBad;
135     fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
136     fPHfirst=fPHlast=fCMother=kBad;
137     fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
138 }
139 //__________________________________________________________________________________________________
140 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
141                 :AliHit(shunt, track)
142 {//ctor
143     fChamber=vol[0];
144     fX=hits[1];fY=hits[2];fZ=hits[3];
145     fTheta=hits[4];fPhi=hits[5];
146     fTlength=hits[6];
147     fEloss=hits[7];
148     fPHfirst=(Int_t)hits[8];fPHlast=(Int_t)hits[9];
149     fCMother=Int_t(hits[10]);
150     fIndex = hits[11];
151     fProduction = hits[12];  
152     fLoss=hits[13];
153     fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
154     fNPads=hits[17];
155     fCerenkovAngle=hits[18];
156 }
157
158 //__________________AliRICHdigit____________________________________________________________________
159 //__________________________________________________________________________________________________
160 //__________________________________________________________________________________________________
161 class AliRICHdigit :public AliDigit
162 {
163 public:
164            AliRICHdigit() {fPadX=fPadY=fChamber=fQdc=fTracks[0]=fTracks[1]=fTracks[2]=kBad;}
165   inline   AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iQdc,Int_t iT1,Int_t iT2,Int_t iT3);
166   virtual ~AliRICHdigit() {;}  
167   inline   Int_t Compare(const TObject *pObj) const;//virtual
168            Bool_t IsSortable()                                 const{return kTRUE;}//virtual
169            Int_t C()                                           const{return fChamber;}
170            Int_t X()                                           const{return fPadX;}
171            Int_t Y()                                           const{return fPadY;}
172            Int_t Id()                                          const{return fChamber*1000000+fPadX*1000+fPadY;}
173            Int_t Qdc()                                         const{return fQdc;}
174            Int_t T(Int_t i)                                    const{return fTracks[i];}
175            void  Print(Option_t *option)const;      //virtual
176 protected:
177   Int_t fChamber;  //module number 
178   Int_t fPadX;     //pad number along X
179   Int_t fPadY;     //pad number along Y
180   Int_t fQdc;      //ADC value
181   ClassDef(AliRICHdigit,1) //RICH digit class       
182 };//class AliRICHdigit
183 //__________________________________________________________________________________________________
184 AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iQdc,Int_t iT0,Int_t iT1,Int_t iT2)
185 {
186   fChamber=iC;fPadX=iX;fPadY=iY;fQdc=iQdc;
187   fTracks[0]=iT0;fTracks[1]=iT1;fTracks[2]=iT2;
188 }
189 //__________________________________________________________________________________________________
190 Int_t AliRICHdigit::Compare(const TObject *pObj)const
191 {
192   if(Id()==((AliRICHdigit*)pObj)->Id()) 
193     return 0;
194   else if(Id()>((AliRICHdigit*)pObj)->Id()) 
195     return 1;
196   else
197     return -1;
198
199 //__________________AliRICH_________________________________________________________________________
200 //__________________________________________________________________________________________________
201 //__________________________________________________________________________________________________
202 class AliRICHParam;
203 class AliRICHSDigit;
204
205 class AliRICH : public AliDetector 
206 {
207 public:
208             AliRICH();                                            
209             AliRICH(const char *name, const char *title);         
210             AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}   
211   virtual  ~AliRICH();                                            
212           
213   AliRICH&  operator=(const AliRICH&)                 {return *this;}
214   virtual Int_t   IsVersion()                                            const =0;            
215           void    Hits2SDigits();                                                                                 //virtual
216           void    SDigits2Digits();                                                                               //virtual
217           void    Digits2Reco();                                                                                  //virtual
218   
219   inline  void    CreateHits();    
220   inline  void    CreateSdigits();  
221   inline  void    CreateDigits();  
222   inline  void    CreateClusters();  
223   inline  void    AddHit(Int_t track, Int_t *vol, Float_t *hits);                                                 //virtual
224   inline  void    AddSdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);
225   inline  void    AddDigit (Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);     
226           void    AddCluster()                                                                                {;}     
227           void    ResetHits()     {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();}  //virtual
228           void    ResetSdigits()  {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();}                                 
229           void    ResetDigits()   {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
230           void    ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
231                   //Hits provided by AliDetector
232   TClonesArray*   Sdigits()             const{return fSdigits;}
233   TClonesArray*   Digits(Int_t iC)      const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
234   TClonesArray*   Clusters(Int_t iC)    const{if(fClusters)  return (TClonesArray *)fClusters->At(iC-1);else return 0;}
235           
236   AliRICHChamber* C(Int_t iC)           const{return (AliRICHChamber*)fChambers->At(iC-1);}
237   AliRICHParam*   Param()               const{return fpParam;}
238   
239   AliRICHhit*     FirstHit(Int_t iTrkN)      {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);}                   //virtual
240   AliRICHhit*     NextHit()                  {return (AliRICHhit*)AliDetector::NextHit();}                         //virtual 
241   
242           void    CreateChambers();         
243           void    CreateMaterials(); //virtual
244   virtual void    BuildGeometry();   //virtual
245   virtual void    CreateGeometry();  //virtual
246           Float_t AbsoCH4(Float_t x);
247           Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola);
248   
249   virtual void    StepManager()=0;
250           void    GenerateFeedbacks(Int_t iChamber,Float_t eloss);
251           void    Print(Option_t *option)const;//virtual
252           void    MakeBranch(Option_t *opt=" ");
253           void    SetTreeAddress();//virtual
254 // OLD staff OLD staff    
255   inline  void    AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
256   inline  void    AddSpecialOld(Int_t *);      
257   inline  void    AddDigitOld(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits);          
258   inline  void    AddClusterOld(Int_t iChamber, const AliRICHRawCluster& cluster);
259           void    AddRecHit1D(Int_t id, Float_t* rechit, Float_t* photons, Int_t* padsx, Int_t* padsy);
260           
261   inline  void    CreateCerenkovsOld();  
262   inline  void    CreateSpecialsOld();   
263   inline  void    CreateDigitsOld();    
264   inline  void    CreateRawClustersOld();  
265   inline  void    CreateRecos1Old();  
266   inline  void    CreateRecos3Old();  
267           void    ResetDigitsOld()  {if(fDchambers)  for(int i=0;i<kNCH;i++){fDchambers->At(i)->Clear();fNdch[i]=0;}}   //virtual
268           void    ResetSpecialsOld(){fNspecials=0; if(fSpecials) fSpecials->Clear();}   
269           void    ResetRawClusters(){if(fRawClusters)for(int i=0;i<kNCH;i++){fRawClusters->At(i)->Clear();fNrawch[i]=0;}}
270           void    ResetRecHits1D()  {if(fRecHits1D)  for(int i=0;i<kNCH;i++){fRecHits1D  ->At(i)->Clear();fNrechits1D[i]=0;}}
271   
272   TClonesArray*   DigitsOld(Int_t iC)   const{if(fDchambers) return (TClonesArray *)fDchambers->At(iC-1);else return 0;}
273   TClonesArray*   ClustersOld(Int_t iC) const{if(fRawClusters)return (TClonesArray *)fRawClusters->At(iC-1);else return 0;}
274   TClonesArray*   Specials()            const{return fSpecials;}
275   TClonesArray*   Cerenkovs()           const{return fCerenkovs;}
276   
277   
278             
279   AliRICHChamber& Chamber(Int_t id)      {return *((AliRICHChamber *) (*fChambers)[id]);}  
280   TObjArray     *Dchambers()                const{return fDchambers;}
281   TObjArray     *RecHits1D()                const{return fRecHits1D;}
282   Int_t         *Ndch()                          {return fNdch;}
283   Int_t         *Nrechits1D()                    {return fNrechits1D;} 
284   TClonesArray  *DigitsAddress(Int_t id)    const{return ((TClonesArray *) (*fDchambers)[id]);}
285   TClonesArray  *RecHitsAddress1D(Int_t id) const{return ((TClonesArray *) (*fRecHits1D)[id]);}
286   TClonesArray  *RawClustAddress(Int_t id)  const{return ((TClonesArray *) (*fRawClusters)[id]);}    
287 //          Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)      {return 9999;}
288     
289 protected:  
290   AliRICHParam         *fpParam;             //main RICH parametrization     
291   TObjArray            *fChambers;           //list of RICH chambers
292                 //fHits and fDigits belong to AliDetector
293   TClonesArray         *fSdigits;            //! List of sdigits  
294   Int_t                 fNsdigits;           //Current number of sdigits
295   TObjArray            *fDigitsNew;          //! Each chamber holds it's one lists of digits
296   Int_t                 fNdigitsNew[kNCH];   //Array of current numbers of digits
297   TObjArray            *fClusters;           //! Each chamber holds it's one lists of clusters 
298   Int_t                 fNclusters[kNCH];    //Array of current numbers of raw clusters
299
300   TClonesArray         *fCerenkovs;          //! ??? List of cerenkovs
301   Int_t                 fNcerenkovs;         //??? Current number of cerenkovs
302   TClonesArray         *fSpecials;           //! ??? List of specials
303   Int_t                 fNspecials;          //??? Current number of specials  
304   TObjArray            *fDchambers;          //! Array of lists of digits  
305   Int_t                 fNdch[kNCH];         //Array of current numbers of digits
306   TObjArray            *fRawClusters;        //! Array of lists of raw clusters 
307   Int_t                 fNrawch[kNCH];       //Array of current numbers of raw clusters
308   TObjArray            *fRecHits1D;          //!List of rec. hits
309   Int_t                 fNrechits1D[kNCH];   //Array of current numbers of rec hits 1D
310   Int_t fCkovNumber;                         // Number of Cerenkov photons
311   Int_t fFreonProd;                          // Cerenkovs produced in freon
312   Int_t fFeedbacks;                          // Number of feedback photons
313     
314   ClassDef(AliRICH,3)                        //Main RICH class 
315 };//class AliRICH  
316 //__________________________________________________________________________________________________
317 void AliRICH::AddHit(Int_t track, Int_t *vol, Float_t *hits)
318 {//Adds the current hit to the RICH hits list
319   TClonesArray &tmp=*fHits;
320   new(tmp[fNhits++])AliRICHhit(fIshunt,track,vol,hits);
321 }
322 //__________________________________________________________________________________________________
323 void AliRICH::AddSdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
324 {//Adds the current Sdigit to the RICH list of Sdigits   
325   TClonesArray &tmp=*fSdigits;
326   new(tmp[fNsdigits++])AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
327
328 //__________________________________________________________________________________________________
329 void AliRICH::AddDigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
330 {//Adds the current digit to the corresponding RICH list of digits (individual list per chamber)
331   TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(iC-1));
332   new(tmp[fNdigitsNew[iC-1]++]) AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
333 }
334 //__________________________________________________________________________________________________
335 void AliRICH::CreateHits()
336 {
337   if(fHits) return;
338   if(GetDebug())Info("CreateHits","creating hits container.");
339   fHits=new TClonesArray("AliRICHhit",10000);   fNhits=0;
340 }
341 //__________________________________________________________________________________________________
342 void AliRICH::CreateSdigits()
343 {
344   if(fSdigits) return;
345   if(GetDebug())Info("CreateSdigits","creating sdigits container.");
346   fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
347 }
348 //__________________________________________________________________________________________________
349 void AliRICH::CreateDigits()
350 {
351   if(fDigitsNew) return;
352   if(GetDebug())Info("CreateDigits","creating digits containers.");
353   fDigitsNew = new TObjArray(kNCH);  
354   for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
355 }
356 //__________________________________________________________________________________________________
357 void AliRICH::CreateClusters()
358 {
359   if(fClusters) return;
360   if(GetDebug())Info("CreateClusters","creating clusters containers.");
361   fClusters = new TObjArray(kNCH);  
362   for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
363 }
364
365
366
367 //__________________________________________________________________________________________________
368 void AliRICH::CreateCerenkovsOld()
369 {
370   if(fCerenkovs) return;
371   if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
372   fCerenkovs=new TClonesArray("AliRICHCerenkov",10000);   fNcerenkovs=0;
373 }
374 //__________________________________________________________________________________________________
375 void AliRICH::CreateSpecialsOld()
376 {
377   if(fSpecials) return;
378   if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
379   fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
380 }
381 //__________________________________________________________________________________________________
382 void AliRICH::CreateDigitsOld()
383 {
384   if(fDchambers) return;
385   if(GetDebug())Info("CreateDigitsOld","creating digits containers.");
386   fDchambers = new TObjArray(kNCH);  
387   for(Int_t i=0;i<kNCH;i++) fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
388 }
389 //__________________________________________________________________________________________________
390 void AliRICH::CreateRawClustersOld()
391 {
392   if(fRawClusters) return;
393   if(GetDebug())Info("CreateClustersOld","creating clusters containers.");
394   fRawClusters = new TObjArray(kNCH);
395   for(Int_t i=0; i<kNCH ;i++) fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
396 }
397 //__________________________________________________________________________________________________
398 void AliRICH::CreateRecos1Old()
399 {
400   if(fRecHits1D) return;
401   if(GetDebug())Info("CreateRecos1DOld","creating recos 1 containers.");
402   fRecHits1D = new TObjArray(kNCH);
403   for(Int_t i=0; i<kNCH ;i++)  fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
404 }
405 //__________________________________________________________________________________________________
406 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
407 {//Adds the current RICH cerenkov hit to the Cerenkovs list   
408   TClonesArray &tmp=*fCerenkovs;
409   new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
410 }
411 //__________________________________________________________________________________________________
412 void AliRICH::AddSpecialOld(Int_t *aiSDigit)
413 {// Adds the current Sdigit to the RICH list of Specials
414   TClonesArray &lSDigits = *fSpecials;
415   new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
416 }
417 //__________________________________________________________________________________________________
418 void AliRICH::AddDigitOld(Int_t iChamber, Int_t *tracks, Int_t *charges, Int_t *digits)
419 {// Adds the current digit to the RICH list of S digits
420    TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(iChamber-1));
421    new(ldigits[fNdch[iChamber-1]++]) AliRICHDigit(tracks,charges,digits);
422 }
423 //__________________________________________________________________________________________________
424 void AliRICH::AddClusterOld(Int_t iChamber, const AliRICHRawCluster& c)
425 {// Add a RICH raw cluster to the list   
426   TClonesArray &tmp= *((TClonesArray*)fRawClusters->At(iChamber-1));
427   new(tmp[fNrawch[iChamber-1]++]) AliRICHRawCluster(c);
428 }
429 //__________________________________________________________________________________________________
430 #endif//#ifndef AliRICH_h