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