]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - RICH/AliRICH.h
version 3 and all the old provision for that deleted. New default is version 1
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
... / ...
CommitLineData
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#include "AliRICHDigitizer.h"
14#include "AliRICHParam.h"
15
16//__________________AliRICHhit______________________________________________________________________
17class AliRICHhit : public AliHit
18{
19public:
20 AliRICHhit():AliHit() {fChamber=fPid=kBad; fEloss=kBad; fInX3.SetXYZ(0,0,0);fOutX3.SetXYZ(0,0,0);
21 fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;}
22 AliRICHhit(Int_t c,Int_t tid,TVector3 in,TVector3 out,Double_t e):AliHit(0,tid) {fInX3=in; fOutX3=out; fChamber=c; fEloss=e;
23 fX=out.X();fY=out.Y();fZ=out.Z();
24 fPid=kBad;fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;}
25 inline AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits); //old version 3 ?????
26 virtual ~AliRICHhit() {;}
27
28 Int_t C() const{return fChamber;}
29 Int_t Chamber() const{return fChamber;}
30 Int_t Pid() const{return fPid;}
31 Int_t Particle() const{return fPid;}
32 Float_t Eloss() const{return fEloss;}
33 Float_t MomX() const{return fMomX;}
34 Float_t MomY() const{return fMomY;}
35 Float_t MomZ() const{return fMomZ;}
36 Float_t CerenkovAngle() const{return fCerenkovAngle;}
37 Float_t MomFreoX() const{return fMomFreoX;}
38 Float_t MomFreoY() const{return fMomFreoY;}
39 Float_t MomFreoZ() const{return fMomFreoZ;}
40 TVector3 InX3() const{return fInX3;}
41 TVector3 OutX3() const{return fOutX3;}
42 Double_t Length() const{return (fOutX3-fInX3).Mag();}
43 void Print(Option_t *option="")const; //virtual
44protected:
45 Int_t fChamber; //chamber number
46 Int_t fPid; //particle code
47 Double_t fEloss; //ionisation energy loss in GAP
48 Float_t fMomX,fMomY,fMomZ; //momentum at photochatode entry point
49 Float_t fNPads; //Pads hit
50 Float_t fCerenkovAngle; //Dummy cerenkov angle
51 Float_t fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
52 TVector3 fInX3; //position at the entrance of the GAP
53 TVector3 fOutX3; //position at exit of the GAP
54 ClassDef(AliRICHhit,2) //RICH hit class
55};//class AliRICHhit
56//__________________________________________________________________________________________________
57AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit)
58 :AliHit(shunt, track)
59{
60// old ctor to be deleted
61 fChamber=vol[0];
62 fPid=(Int_t)hit[0];
63 fX=hit[1];fY=hit[2];fZ=hit[3];
64 fEloss=hit[7];
65 fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
66 fCerenkovAngle=hit[18];
67 fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
68}
69
70//__________________AliRICHdigit____________________________________________________________________
71class AliRICHdigit :public AliDigit
72{
73public:
74 AliRICHdigit() {fCombiPid=fChamber=fPadX=fPadY=fTracks[0]=fTracks[1]=fTracks[2]=kBad;fQdc=kBad;}
75 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)
76 {fPadX=x;fPadY=y;fQdc=q;fChamber=10*c+AliRICHParam::Sector(x,y);fCombiPid=cpid;fTracks[0]=tid0;fTracks[1]=tid1;fTracks[2]=tid2;}
77 virtual ~AliRICHdigit() {;}
78 Int_t Compare(const TObject *pObj) const //virtual
79 {if(Id()==((AliRICHdigit*)pObj)->Id()) return 0; else if(Id()>((AliRICHdigit*)pObj)->Id()) return 1; else return -1;}
80
81 Bool_t IsSortable() const{return kTRUE;}//virtual
82 Int_t CombiPid() const{return fCombiPid;}
83 Int_t C() const{return fChamber/10;}
84 Int_t S() const{return fChamber-(fChamber/10)*10;}
85 Int_t Chamber() const{return C();}
86 Int_t Sector() const{return S();}
87 Int_t X() const{return fPadX;}
88 Int_t Y() const{return fPadY;}
89 Int_t Id() const{return fChamber*10000000+fPadX*1000+fPadY;}
90 Double_t Q() const{return fQdc;}
91 Int_t Tid(Int_t i) const{return fTracks[i];}
92 void Print(Option_t *option="")const; //virtual
93protected:
94 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
95 Int_t fChamber; //10*chamber number+ sector number
96 Int_t fPadX; //pad number along X
97 Int_t fPadY; //pad number along Y
98 Double_t fQdc; //QDC value, fractions are permitted for summable procedure
99 ClassDef(AliRICHdigit,2) //RICH digit class
100};//class AliRICHdigit
101
102//__________________AliRICHcluster__________________________________________________________________
103class AliRICHcluster :public TObject
104{
105public:
106 enum ClusterStatus {kEdge,kShape,kSize,kRaw,kResolved};
107 AliRICHcluster() {fSize=fQdc=fStatus=fChamber=fDimXY=0;fX=fY=kBad;fDigits=0;}
108 virtual ~AliRICHcluster() {delete fDigits;}
109 AliRICHcluster& operator=(const AliRICHcluster&) {return *this;}
110 Int_t Nlocals() const{return fSize - 10000*(fSize/10000);} //
111 Int_t Size() const{return fSize/10000;} //
112 Int_t Fsize() const{return fSize;} //
113 Int_t DimXY() const{return fDimXY;} //
114 Int_t C() const{return fChamber/10;} //
115 Int_t S() const{return fChamber-(fChamber/10)*10;} //
116 Int_t Fchamber() const{return fChamber;} //
117 Int_t Chamber() const{return C();} //
118 Int_t Sector() const{return S();} //
119 Int_t Q() const{return fQdc;} //
120 Double_t X() const{return fX;} //
121 Double_t Y() const{return fY;} //
122 Int_t Status() const{return fStatus;} //
123 void SetStatus(Int_t status) {fStatus=status;} //
124 Int_t Nmips() const{return fCombiPid-1000000*Ncerenkovs()-1000*Nfeedbacks();} //
125 Int_t Ncerenkovs() const{return fCombiPid/1000000;} //
126 Int_t Nfeedbacks() const{return (fCombiPid-1000000*Ncerenkovs())/1000;} //
127 Bool_t IsPureMip() const{return fCombiPid<1000;}
128 Bool_t IsPureCerenkov() const{return Nmips()==0&&Nfeedbacks()==0;} //
129 Bool_t IsPureFeedback() const{return Nmips()==0&&Ncerenkovs()==0;} //
130 Int_t CombiPid() const{return fCombiPid;} //
131 void SetCombiPid(Int_t ckov,Int_t feeds,Int_t mips) {fCombiPid=1000000*ckov+1000*feeds+mips;} //
132 void Fill(AliRICHcluster *pRaw,Double_t x,Double_t y, Double_t q, Int_t combipid)
133 {fCombiPid=combipid;fChamber=pRaw->Fchamber();fSize=pRaw->Fsize();
134 fQdc=(Int_t)(q*pRaw->Q());fX=x;fY=y;fStatus=kResolved;} //
135 TObjArray* Digits() const{return fDigits;} //
136 void Print(Option_t *option="")const; //virtual
137 inline void AddDigit(AliRICHdigit *pDig); //
138 inline void CoG(Int_t nLocals); //
139 void Reset() {fSize=fQdc=fStatus=fChamber=fDimXY=kBad;fX=fY=kBad;delete fDigits;fDigits=0;} //
140protected:
141 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
142 Int_t fSize; //10000*(how many digits belong to this cluster) + nLocalMaxima
143 Int_t fDimXY; //100*xdim+ydim box containing the cluster
144 Int_t fQdc; //QDC value
145 Int_t fChamber; //10*module number+sector number
146 Double_t fX; //local x postion
147 Double_t fY; //local y postion
148 Int_t fStatus; //flag to mark the quality of the cluster
149 TObjArray *fDigits; //! list of digits forming this cluster
150 ClassDef(AliRICHcluster,2) //RICH cluster class
151};//class AliRICHcluster
152//__________________________________________________________________________________________________
153void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
154{//
155 if(!fDigits) {fQdc=fSize=fCombiPid=0;fDigits = new TObjArray;}
156 fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
157 fChamber=10*pDig->C()+pDig->S();
158 fSize+=10000;
159}
160//__________________________________________________________________________________________________
161void AliRICHcluster::CoG(Int_t nLocals)
162{//
163 Int_t xmin=999,ymin=999,xmax=0,ymax=0;
164 fX=fY=0;
165 for(Int_t iDig=0;iDig<Size();iDig++) {
166 AliRICHdigit *pDig=(AliRICHdigit*)fDigits->At(iDig);
167 Int_t padX = pDig->X();Int_t padY = pDig->Y();Double_t q=pDig->Q();
168 TVector2 x2=AliRICHParam::Pad2Loc(padX,padY);
169 fX += x2.X()*q;fY +=x2.Y()*q;
170 if(padX<xmin)xmin=padX;if(padX>xmax)xmax=padX;if(padY<ymin)ymin=padY;if(padY>ymax)ymax=padY;
171 }
172 fX/=fQdc;fY/=fQdc;//Center of Gravity
173 fDimXY = 100*(xmax-xmin+1)+ymax-ymin+1;//find box containing cluster
174 fSize+=nLocals;
175 fStatus=kRaw;
176}//CoG()
177//__________________________________________________________________________________________________
178class AliRICHreco: public TObject
179{
180public:
181 AliRICHreco() {fTid=fNphotons=kBad; fThetaCherenkov=kBad;}
182 AliRICHreco(Int_t tid,Double_t thetaCherenkov,Int_t nPhotons) {fTid=tid;fThetaCherenkov=thetaCherenkov;fNphotons=nPhotons;}
183
184 virtual ~AliRICHreco() {;}
185
186 void Print(Option_t *option="")const; //virtual print
187
188protected:
189 Int_t fTid; // track Id reference
190 Int_t fNphotons; // number of photons contributed to the recontruction
191 Double_t fThetaCherenkov; // reconstructed Theta Cerenkov for a given charged track
192
193 ClassDef(AliRICHreco,1) //RICH reco class
194
195};//class AliRICHreco
196//__________________AliRICH_________________________________________________________________________
197class AliRICHParam;
198class AliRICHChamber;
199
200class AliRICH : public AliDetector
201{
202public:
203 AliRICH();
204 AliRICH(const char *name, const char *title);
205 AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}
206 virtual ~AliRICH();
207
208 AliRICH& operator=(const AliRICH&) {return *this;}
209 virtual Int_t IsVersion() const =0;
210 void Hits2SDigits(); //virtual
211 AliDigitizer* CreateDigitizer(AliRunDigitizer* man) const {return new AliRICHDigitizer(man);} //virtual
212
213 inline void CreateHits();
214 inline void CreateSDigits();
215 inline void CreateDigits();
216 inline void CreateClusters();
217 inline void CreateRecos();
218 void AddHit(Int_t chamber,Int_t tid,TVector3 iX3,TVector3 oX3,Double_t eloss=0)
219 {TClonesArray &tmp=*fHits;new(tmp[fNhits++])AliRICHhit(chamber,tid,iX3,oX3,eloss);}
220 inline void AddSDigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t pid,Int_t tid);
221 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]);}
222 void AddCluster(AliRICHcluster &cl) {TClonesArray &tmp=*((TClonesArray*)fClusters->At(cl.C()-1));new(tmp[fNclusters[cl.C()-1]++])AliRICHcluster(cl);}
223 void AddReco(Int_t tid,Double_t thetaCherenkov,Int_t nPhotons) {TClonesArray &tmp=*(TClonesArray*)fRecos;new(tmp[fNrecos++])AliRICHreco(tid,thetaCherenkov,nPhotons);}
224// void ResetHits() {AliDetector::ResetHits();} //virtual
225 void ResetSDigits() {fNsdigits=0; if(fSdigits) fSdigits ->Clear();}
226 void ResetDigits() {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
227 void ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
228 void ResetRecos() {if(fRecos) fRecos->Clear();fNrecos=0;}
229 //Hits provided by AliDetector
230 TClonesArray* SDigits() const{return fSdigits;}
231 TClonesArray* Digits(Int_t iC) const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
232 TClonesArray* Clusters(Int_t iC) const{if(fClusters) return (TClonesArray *)fClusters->At(iC-1);else return 0;}
233 TClonesArray* Recos() const{return fRecos;}
234
235 AliRICHChamber* C(Int_t iC) const{return (AliRICHChamber*)fChambers->At(iC-1);}
236 AliRICHParam* Param() const{return fpParam;}
237 AliRICHParam* P() const{return fpParam;}
238 void CreateChambers();
239 void CreateMaterials(); //virtual
240 virtual void BuildGeometry(); //virtual
241 virtual void CreateGeometry(); //virtual
242 Float_t AbsoCH4(Float_t x)const;
243 Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)const;
244
245 virtual void StepManager()=0;
246 void GenerateFeedbacks(Int_t iChamber,Float_t eloss=0);//eloss=0 for photon
247 void Print(Option_t *option)const;//virtual
248 void MakeBranch(Option_t *opt=" ");
249 void SetTreeAddress();//virtual
250
251// Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) {return 9999;}
252
253protected:
254 enum {kCSI=6,kGAP=9};
255 AliRICHParam *fpParam; //main RICH parametrization
256 TObjArray *fChambers; //list of RICH chambers
257 //fHits and fDigits belong to AliDetector
258 TClonesArray *fSdigits; //! List of sdigits
259 Int_t fNsdigits; //! Current number of sdigits
260
261 TObjArray *fDigitsNew; //! Each chamber holds it's one lists of digits
262 Int_t fNdigitsNew[kNCH]; //! Array of current numbers of digits
263
264 TObjArray *fClusters; //! Each chamber holds it's one lists of clusters
265 Int_t fNclusters[kNCH]; //! Array of current numbers of raw clusters
266
267 TClonesArray *fRecos; //! pointer to the list of recos
268 Int_t fNrecos; //! number of recos
269
270 ClassDef(AliRICH,5) //Main RICH class
271};//class AliRICH
272
273//__________________________________________________________________________________________________
274void AliRICH::CreateHits()
275{
276 if(fHits) return;
277 if(GetDebug())Info("CreateHits","creating hits container.");
278 fHits=new TClonesArray("AliRICHhit",10000); fNhits=0;
279}
280//__________________________________________________________________________________________________
281void AliRICH::CreateSDigits()
282{
283 if(fSdigits) return;
284 if(GetDebug())Info("CreateSDigits","creating sdigits container.");
285 fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
286}
287//__________________________________________________________________________________________________
288void AliRICH::CreateDigits()
289{
290 if(fDigitsNew) return;
291 if(GetDebug())Info("CreateDigits","creating digits containers.");
292 fDigitsNew = new TObjArray(kNCH);
293 for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
294}
295//__________________________________________________________________________________________________
296void AliRICH::CreateClusters()
297{
298 if(fClusters) return;
299 if(GetDebug())Info("CreateClusters","creating clusters containers.");
300 fClusters = new TObjArray(kNCH);
301 for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
302}
303//__________________________________________________________________________________________________
304void AliRICH::CreateRecos()
305{
306 if(fRecos) return;
307 if(GetDebug())Info("CreateRecos","creating recos containers.");
308 fRecos = new TClonesArray("AliRICHreco",1000);fNrecos=0;
309}
310//__________________________________________________________________________________________________
311void AliRICH::AddSDigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t pid,Int_t tid)
312{
313 switch(pid){
314 case 50000050: pid=1000000;break;//cerenkov
315 case 50000051: pid=1000; break;//feedback
316 default: pid=1; break;//mip
317 }
318 TClonesArray &tmp=*fSdigits;
319 new(tmp[fNsdigits++])AliRICHdigit(c,x,y,q,pid,tid,kBad,kBad);
320}//AddSDigit()
321
322#endif//#ifndef AliRICH_h