]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICH.h
No need to filter out libNew
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
CommitLineData
2f614988 1#ifndef AliRICH_h
2#define AliRICH_h
2e5f0f7b 3
3da30618 4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
c11ee6f0 7#include <TObjArray.h>
853634d3 8#include <TClonesArray.h>
c021cb15 9#include <TLorentzVector.h>
c11ee6f0 10#include <AliDetector.h>
853634d3 11#include <AliHit.h>
12#include <AliDigit.h>
3582c1f9 13#include "AliRICHDigitizer.h"
cb8189e7 14#include "AliRICHParam.h"
09c52ebc 15#include <Riostream.h>
cb8189e7 16
c021cb15 17//__________________AliRICHhit______________________________________________________________________
853634d3 18class AliRICHhit : public AliHit
19{
20public:
3582c1f9 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 ?????
853634d3 27 virtual ~AliRICHhit() {;}
af3d25a6 28
53fd478b 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;}
53fd478b 33 Float_t Eloss() const{return fEloss;}
53fd478b 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;}
6865fb8d 41 TVector3 InX3() const{return fInX3;}
42 TVector3 OutX3() const{return fOutX3;}
3582c1f9 43 Double_t Length() const{return (fOutX3-fInX3).Mag();}
543d5224 44 void Print(Option_t *option="")const; //virtual
853634d3 45protected:
c021cb15 46 Int_t fChamber; //chamber number
c60862bf 47 Int_t fPid; //particle code
3582c1f9 48 Double_t fEloss; //ionisation energy loss in GAP
c021cb15 49 Float_t fMomX,fMomY,fMomZ; //momentum at photochatode entry point
af3d25a6 50 Float_t fNPads; //Pads hit
51 Float_t fCerenkovAngle; //Dummy cerenkov angle
c021cb15 52 Float_t fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
3582c1f9 53 TVector3 fInX3; //position at the entrance of the GAP
54 TVector3 fOutX3; //position at exit of the GAP
ed3ceb24 55 ClassDef(AliRICHhit,2) //RICH hit class
853634d3 56};//class AliRICHhit
c021cb15 57//__________________________________________________________________________________________________
ed3ceb24 58AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit)
59 :AliHit(shunt, track)
3582c1f9 60{
61// old ctor to be deleted
853634d3 62 fChamber=vol[0];
c60862bf 63 fPid=(Int_t)hit[0];
c021cb15 64 fX=hit[1];fY=hit[2];fZ=hit[3];
c021cb15 65 fEloss=hit[7];
c021cb15 66 fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
c021cb15 67 fCerenkovAngle=hit[18];
68 fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
bc3c4bbf 69}
c021cb15 70
c021cb15 71//__________________AliRICHdigit____________________________________________________________________
853634d3 72class AliRICHdigit :public AliDigit
73{
74public:
ed3ceb24 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)
3582c1f9 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;}
853634d3 78 virtual ~AliRICHdigit() {;}
ed3ceb24 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
c1863e3c 82 Bool_t IsSortable() const{return kTRUE;}//virtual
ed3ceb24 83 Int_t CombiPid() const{return fCombiPid;}
cb8189e7 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();}
c1863e3c 88 Int_t X() const{return fPadX;}
89 Int_t Y() const{return fPadY;}
cb8189e7 90 Int_t Id() const{return fChamber*10000000+fPadX*1000+fPadY;}
c1863e3c 91 Double_t Q() const{return fQdc;}
ed3ceb24 92 Int_t Tid(Int_t i) const{return fTracks[i];}
cb8189e7 93 void Print(Option_t *option="")const; //virtual
853634d3 94protected:
ed3ceb24 95 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
96 Int_t fChamber; //10*chamber number+ sector number
c1863e3c 97 Int_t fPadX; //pad number along X
98 Int_t fPadY; //pad number along Y
ed3ceb24 99 Double_t fQdc; //QDC value, fractions are permitted for summable procedure
100 ClassDef(AliRICHdigit,2) //RICH digit class
853634d3 101};//class AliRICHdigit
cbaf35fb 102
ed3ceb24 103//__________________AliRICHcluster__________________________________________________________________
c1863e3c 104class AliRICHcluster :public TObject
105{
106public:
6865fb8d 107 enum ClusterStatus {kEdge,kShape,kSize,kRaw,kResolved};
108 AliRICHcluster() {fSize=fQdc=fStatus=fChamber=fDimXY=0;fX=fY=kBad;fDigits=0;}
53fd478b 109 virtual ~AliRICHcluster() {delete fDigits;}
110 AliRICHcluster& operator=(const AliRICHcluster&) {return *this;}
6865fb8d 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;} //
cb8189e7 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;} //
6865fb8d 117 Int_t Fchamber() const{return fChamber;} //
cb8189e7 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;} //
ed3ceb24 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;} //
6865fb8d 131 Int_t CombiPid() const{return fCombiPid;} //
ed3ceb24 132 void SetCombiPid(Int_t ckov,Int_t feeds,Int_t mips) {fCombiPid=1000000*ckov+1000*feeds+mips;} //
6865fb8d 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;} //
cb8189e7 136 TObjArray* Digits() const{return fDigits;} //
137 void Print(Option_t *option="")const; //virtual
138 inline void AddDigit(AliRICHdigit *pDig); //
6865fb8d 139 inline void CoG(Int_t nLocals); //
ed3ceb24 140 void Reset() {fSize=fQdc=fStatus=fChamber=fDimXY=kBad;fX=fY=kBad;delete fDigits;fDigits=0;} //
c1863e3c 141protected:
ed3ceb24 142 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
6865fb8d 143 Int_t fSize; //10000*(how many digits belong to this cluster) + nLocalMaxima
c1863e3c 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
ed3ceb24 151 ClassDef(AliRICHcluster,2) //RICH cluster class
c1863e3c 152};//class AliRICHcluster
153//__________________________________________________________________________________________________
154void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
cb8189e7 155{//
ed3ceb24 156 if(!fDigits) {fQdc=fSize=fCombiPid=0;fDigits = new TObjArray;}
cbaf35fb 157 fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
cb8189e7 158 fChamber=10*pDig->C()+pDig->S();
6865fb8d 159 fSize+=10000;
cbaf35fb 160}
161//__________________________________________________________________________________________________
6865fb8d 162void AliRICHcluster::CoG(Int_t nLocals)
cb8189e7 163{//
164 Int_t xmin=999,ymin=999,xmax=0,ymax=0;
cb8189e7 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();
3582c1f9 169 TVector2 x2=AliRICHParam::Pad2Loc(padX,padY);
170 fX += x2.X()*q;fY +=x2.Y()*q;
cb8189e7 171 if(padX<xmin)xmin=padX;if(padX>xmax)xmax=padX;if(padY<ymin)ymin=padY;if(padY>ymax)ymax=padY;
cbaf35fb 172 }
cb8189e7 173 fX/=fQdc;fY/=fQdc;//Center of Gravity
174 fDimXY = 100*(xmax-xmin+1)+ymax-ymin+1;//find box containing cluster
6865fb8d 175 fSize+=nLocals;
cb8189e7 176 fStatus=kRaw;
177}//CoG()
3582c1f9 178//__________________________________________________________________________________________________
af3d25a6 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;}
ed3ceb24 184
af3d25a6 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
c021cb15 197//__________________AliRICH_________________________________________________________________________
3ea9cb08 198class AliRICHParam;
ed3ceb24 199class AliRICHChamber;
3ea9cb08 200
2f614988 201class AliRICH : public AliDetector
202{
2f614988 203public:
853634d3 204 AliRICH();
af3d25a6 205 AliRICH(const char *name, const char *title);
942194a4 206 AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}
853634d3 207 virtual ~AliRICH();
dfb4e77d 208
942194a4 209 AliRICH& operator=(const AliRICH&) {return *this;}
c60862bf 210 virtual Int_t IsVersion() const =0;
211 void Hits2SDigits(); //virtual
3582c1f9 212 AliDigitizer* CreateDigitizer(AliRunDigitizer* man) const {return new AliRICHDigitizer(man);} //virtual
c021cb15 213
c60862bf 214 inline void CreateHits();
c1863e3c 215 inline void CreateSDigits();
c60862bf 216 inline void CreateDigits();
217 inline void CreateClusters();
af3d25a6 218 inline void CreateRecos();
3582c1f9 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);
ed3ceb24 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]);}
09c52ebc 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);}
af3d25a6 224 void AddReco(Int_t tid,Double_t thetaCherenkov,Int_t nPhotons) {TClonesArray &tmp=*(TClonesArray*)fRecos;new(tmp[fNrecos++])AliRICHreco(tid,thetaCherenkov,nPhotons);}
84365c70 225// void ResetHits() {AliDetector::ResetHits();} //virtual
ed3ceb24 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;}}
af3d25a6 229 void ResetRecos() {if(fRecos) fRecos->Clear();fNrecos=0;}
c60862bf 230 //Hits provided by AliDetector
c1863e3c 231 TClonesArray* SDigits() const{return fSdigits;}
543d5224 232 TClonesArray* Digits(Int_t iC) const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
c60862bf 233 TClonesArray* Clusters(Int_t iC) const{if(fClusters) return (TClonesArray *)fClusters->At(iC-1);else return 0;}
af3d25a6 234 TClonesArray* Recos() const{return fRecos;}
c60862bf 235
236 AliRICHChamber* C(Int_t iC) const{return (AliRICHChamber*)fChambers->At(iC-1);}
237 AliRICHParam* Param() const{return fpParam;}
ed3ceb24 238 AliRICHParam* P() const{return fpParam;}
3ea9cb08 239 void CreateChambers();
c60862bf 240 void CreateMaterials(); //virtual
241 virtual void BuildGeometry(); //virtual
242 virtual void CreateGeometry(); //virtual
53fd478b 243 Float_t AbsoCH4(Float_t x)const;
244 Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)const;
3ea9cb08 245
c021cb15 246 virtual void StepManager()=0;
3582c1f9 247 void GenerateFeedbacks(Int_t iChamber,Float_t eloss=0);//eloss=0 for photon
c60862bf 248 void Print(Option_t *option)const;//virtual
249 void MakeBranch(Option_t *opt=" ");
250 void SetTreeAddress();//virtual
c60862bf 251
c60862bf 252// Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) {return 9999;}
2f614988 253
c60862bf 254protected:
53fd478b 255 enum {kCSI=6,kGAP=9};
c021cb15 256 AliRICHParam *fpParam; //main RICH parametrization
257 TObjArray *fChambers; //list of RICH chambers
84365c70 258 //fHits and fDigits belong to AliDetector
c60862bf 259 TClonesArray *fSdigits; //! List of sdigits
aed240d4 260 Int_t fNsdigits; //! Current number of sdigits
84365c70 261
c60862bf 262 TObjArray *fDigitsNew; //! Each chamber holds it's one lists of digits
aed240d4 263 Int_t fNdigitsNew[kNCH]; //! Array of current numbers of digits
84365c70 264
c60862bf 265 TObjArray *fClusters; //! Each chamber holds it's one lists of clusters
aed240d4 266 Int_t fNclusters[kNCH]; //! Array of current numbers of raw clusters
84365c70 267
af3d25a6 268 TClonesArray *fRecos; //! pointer to the list of recos
269 Int_t fNrecos; //! number of recos
c60862bf 270
84365c70 271 ClassDef(AliRICH,5) //Main RICH class
c60862bf 272};//class AliRICH
ed3ceb24 273
c1863e3c 274//__________________________________________________________________________________________________
c60862bf 275void AliRICH::CreateHits()
276{
277 if(fHits) return;
278 if(GetDebug())Info("CreateHits","creating hits container.");
279 fHits=new TClonesArray("AliRICHhit",10000); fNhits=0;
543d5224 280}
c60862bf 281//__________________________________________________________________________________________________
c1863e3c 282void AliRICH::CreateSDigits()
c60862bf 283{
284 if(fSdigits) return;
c1863e3c 285 if(GetDebug())Info("CreateSDigits","creating sdigits container.");
c60862bf 286 fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
543d5224 287}
c60862bf 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;}
543d5224 295}
c60862bf 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;}
543d5224 303}
ed3ceb24 304//__________________________________________________________________________________________________
af3d25a6 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//__________________________________________________________________________________________________
3582c1f9 312void AliRICH::AddSDigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t pid,Int_t tid)
ed3ceb24 313{
314 switch(pid){
3582c1f9 315 case 50000050: pid=1000000;break;//cerenkov
316 case 50000051: pid=1000; break;//feedback
317 default: pid=1; break;//mip
ed3ceb24 318 }
319 TClonesArray &tmp=*fSdigits;
320 new(tmp[fNsdigits++])AliRICHdigit(c,x,y,q,pid,tid,kBad,kBad);
321}//AddSDigit()
c60862bf 322
c60862bf 323#endif//#ifndef AliRICH_h