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