Coding violation fixes.
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
2f614988 1#ifndef AliRICH_h
2#define AliRICH_h
3da30618 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
d3eb6079 6//#include <Riostream.h>
853634d3 7#include <TClonesArray.h>
1c349ae5 8#include <TObjArray.h>
9#include <TVector.h>
d4c94996 10#include <TVector3.h>
1c349ae5 11
3582c1f9 12#include "AliRICHDigitizer.h"
cb8189e7 13#include "AliRICHParam.h"
1c349ae5 14#include <AliDetector.h>
15#include <AliDigit.h>
16#include <AliHit.h>
cb8189e7 17
c021cb15 18//__________________AliRICHhit______________________________________________________________________
853634d3 19class AliRICHhit : public AliHit
e42a7b46 22 AliRICHhit():AliHit(),fChamber(kBad),fEloss(kBad) {fInX3.SetXYZ(0,0,0);fOutX3.SetXYZ(0,0,0);}
d4c94996 23 AliRICHhit(Int_t c,Int_t tid,TVector3 in,TVector3 out,Double_t e):AliHit(0,tid)
24 {fChamber=c;fInX3=in; fOutX3=out;fEloss=e; fX=out.X();fY=out.Y();fZ=out.Z();}
25 virtual ~AliRICHhit() {;}
af3d25a6 26
d4c94996 27 Int_t C() const{return fChamber;} //chamber number
28 Int_t Chamber() const{return fChamber;} //chamber number
29 Float_t Eloss() const{return fEloss;} //energy lost by track inside amplification gap
30 TVector3 InX3() const{return fInX3;} //track position at the faceplane of the gap
31 TVector3 OutX3() const{return fOutX3;} //track position at the backplane of the gap
32 Double_t Length() const{return (fOutX3-fInX3).Mag();} //track length inside the amplification gap
33 void Print(Option_t *option="")const; //virtual
853634d3 34protected:
c021cb15 35 Int_t fChamber; //chamber number
d4c94996 36 Double_t fEloss; //ionisation energy lost in GAP
3582c1f9 37 TVector3 fInX3; //position at the entrance of the GAP
d4c94996 38 TVector3 fOutX3; //position at the exit of the GAP
ed3ceb24 39 ClassDef(AliRICHhit,2) //RICH hit class
853634d3 40};//class AliRICHhit
c021cb15 41
c021cb15 42//__________________AliRICHdigit____________________________________________________________________
853634d3 43class AliRICHdigit :public AliDigit
e42a7b46 46 AliRICHdigit():AliDigit(),fCFM(0),fChamber(0),fPadX(0),fPadY(0),fQdc(kBad){fTracks[0]=fTracks[1]=fTracks[2]=kBad;}
47 AliRICHdigit(Int_t c,TVector pad,Double_t q,Int_t cfm,Int_t tid0,Int_t tid1,Int_t tid2)
48 {fPadX=(Int_t)pad[0];fPadY=(Int_t)pad[1];fQdc=q;fChamber=10*c+AliRICHParam::Pad2Sec(pad);fCFM=cfm;fTracks[0]=tid0;fTracks[1]=tid1;fTracks[2]=tid2;}
853634d3 49 virtual ~AliRICHdigit() {;}
d4c94996 50 Int_t Compare(const TObject *pObj) const
51 {if(Id()==((AliRICHdigit*)pObj)->Id())return 0;else if(Id()>((AliRICHdigit*)pObj)->Id())return 1;else return -1;} //virtual
e42a7b46 52 virtual Bool_t IsSortable() const{return kTRUE;} //sort interface
53 virtual void Print(Option_t *option="") const; //virtual
54 Int_t ChFbMi() const{return fCFM;} //particle mixture for this digit
d4c94996 55 Int_t C() const{return fChamber/10;} //chamber number
56 Int_t S() const{return fChamber-(fChamber/10)*10;} //sector number
57 Int_t X() const{return fPadX;} //x position of the pad
58 Int_t Y() const{return fPadY;} //y postion of the pad
e42a7b46 59 TVector Pad() const{Float_t v[2]={fPadX,fPadY}; return TVector(2,v);}
d4c94996 60 Int_t Id() const{return fChamber*10000000+fPadX*1000+fPadY;} //absolute id of this pad
61 Double_t Q() const{return fQdc;} //charge in terms of ADC channels
89924db8 62 void AddTidOffset(Int_t offset)
63 {for (Int_t i=0; i<3; i++) if (fTracks[i]>0) fTracks[i]+=offset;};
853634d3 64protected:
e42a7b46 65 Int_t fCFM; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
ed3ceb24 66 Int_t fChamber; //10*chamber number+ sector number
c1863e3c 67 Int_t fPadX; //pad number along X
68 Int_t fPadY; //pad number along Y
ed3ceb24 69 Double_t fQdc; //QDC value, fractions are permitted for summable procedure
d4c94996 70 ClassDef(AliRICHdigit,3) //RICH digit class
853634d3 71};//class AliRICHdigit
cbaf35fb 72
ed3ceb24 73//__________________AliRICHcluster__________________________________________________________________
c1863e3c 74class AliRICHcluster :public TObject
a25b3368 77 enum ClusterStatus {kEdge,kShape,kSize,kRaw,kResolved,kEmpty};
e42a7b46 78 AliRICHcluster():TObject(),fCFM(0),fSize(0),fShape(0),fQdc(0),fChamber(0),fX(0),fY(0),fStatus(kEmpty),fDigits(0) {}
998b831f 79 virtual ~AliRICHcluster() {AliDebug(1,"Start");/*Reset();*/}
e42a7b46 80 void Reset() {DeleteDigits();fCFM=fSize=fShape=fQdc=fChamber=0;fX=fY=0;fStatus=kEmpty;} //cleans the cluster
998b831f 81 void DeleteDigits() {if(fDigits) {delete fDigits;} fDigits=0;} //deletes the list of digits
e42a7b46 82 AliRICHcluster& operator=(const AliRICHcluster&) {return *this;}
83 Int_t Nlocals() const{return fSize-10000*(fSize/10000);} //number of local maximums
84 Int_t Size() const{return fSize/10000;} //number of digits in cluster
85 Int_t Fsize() const{return fSize;} //
86 Int_t Shape() const{return fShape;} //cluster shape rectangulare
87 Int_t C() const{return fChamber/10;} //chamber number
88 Int_t S() const{return fChamber-(fChamber/10)*10;} //sector number
89 Int_t Fchamber() const{return fChamber;} //
90 Int_t Q() const{return fQdc;} //cluster charge in QDC channels
91 Double_t X() const{return fX;} //cluster x position in LRS
92 Double_t Y() const{return fY;} //cluster y position in LRS
93 Int_t Status() const{return fStatus;} //
94 void SetStatus(Int_t status) {fStatus=status;} //
95 Int_t Nmips() const{return fCFM-1000000*Ncerenkovs()-1000*Nfeedbacks();} //
96 Int_t Ncerenkovs() const{return fCFM/1000000;} //
97 Int_t Nfeedbacks() const{return (fCFM-1000000*Ncerenkovs())/1000;} //
98 Bool_t IsPureMip() const{return fCFM<1000;} //
99 Bool_t IsPureCerenkov() const{return Nmips()==0&&Nfeedbacks()==0;} //
100 Bool_t IsPureFeedback() const{return Nmips()==0&&Ncerenkovs()==0;} //
101 Bool_t IsSingleMip() const{return Nmips()==1&&Ncerenkovs()==0&&Nfeedbacks()==0;} //
102 Bool_t IsSingleCerenkov() const{return Nmips()==0&&Ncerenkovs()==1&&Nfeedbacks()==0;} //
103 Bool_t IsSingleFeedback() const{return Nmips()==0&&Ncerenkovs()==0&&Nfeedbacks()==1;} //
104 Bool_t IsMip() const{return Nmips()!=0;} //
105 Bool_t IsCerenkov() const{return Ncerenkovs()!=0;} //
106 Bool_t IsFeedback() const{return Nfeedbacks()!=0;} //
107 Int_t CombiPid() const{return fCFM;} //
108 void CFM(Int_t c,Int_t f,Int_t m) {fCFM=1000000*c+1000*f+m;} //cluster contributors
109 TObjArray* Digits() const{return fDigits;} //
998b831f 110 virtual void Print(Option_t *option="")const; //
111 inline void AddDigit(AliRICHdigit *pDig); //
112 inline void CoG(Int_t nLocals); //calculates center of gravity
113 void Fill(AliRICHcluster *pRaw,Double_t x,Double_t y,Double_t q,Int_t cfm) //form new resolved cluster from raw one
114 {fCFM=cfm;fChamber=pRaw->Fchamber();fSize=pRaw->Fsize();fQdc=(Int_t)(q*pRaw->Q());fX=x;fY=y;fStatus=kResolved;}
115 Double_t DistTo(TVector2 x) const{return TMath::Sqrt((x.X()-fX)*(x.X()-fX)+(x.Y()-fY)*(x.Y()-fY));} //distance to given point
1cb5a97c 116 Double_t DistX(TVector2 x) const{return (x.X()-fX);} //distance in x to given point
117 Double_t DistY(TVector2 x) const{return (x.Y()-fY);} //distance to given point
c1863e3c 118protected:
e42a7b46 119 Int_t fCFM; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
6865fb8d 120 Int_t fSize; //10000*(how many digits belong to this cluster) + nLocalMaxima
e42a7b46 121 Int_t fShape; //100*xdim+ydim box containing the cluster
c1863e3c 122 Int_t fQdc; //QDC value
123 Int_t fChamber; //10*module number+sector number
124 Double_t fX; //local x postion
125 Double_t fY; //local y postion
126 Int_t fStatus; //flag to mark the quality of the cluster
127 TObjArray *fDigits; //! list of digits forming this cluster
ed3ceb24 128 ClassDef(AliRICHcluster,2) //RICH cluster class
c1863e3c 129};//class AliRICHcluster
131void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
e42a7b46 132{
133// Adds a given digit to the list of digits belonging to this cluster
134 if(!fDigits) {fQdc=fSize=fCFM=0;fDigits = new TObjArray;}
cbaf35fb 135 fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
cb8189e7 136 fChamber=10*pDig->C()+pDig->S();
6865fb8d 137 fSize+=10000;
e42a7b46 138 fStatus=kRaw;
cbaf35fb 139}
6865fb8d 141void AliRICHcluster::CoG(Int_t nLocals)
e42a7b46 142{
143// Calculates naive cluster position as a center of gravity of its digits.
144 Float_t xmin=999,ymin=999,xmax=0,ymax=0;
cb8189e7 145 fX=fY=0;
146 for(Int_t iDig=0;iDig<Size();iDig++) {
147 AliRICHdigit *pDig=(AliRICHdigit*)fDigits->At(iDig);
e42a7b46 148 TVector pad=pDig->Pad(); Double_t q=pDig->Q();
149 TVector2 x2=AliRICHParam::Pad2Loc(pad);
3582c1f9 150 fX += x2.X()*q;fY +=x2.Y()*q;
e42a7b46 151 if(pad[0]<xmin)xmin=pad[0];if(pad[0]>xmax)xmax=pad[0];if(pad[1]<ymin)ymin=pad[1];if(pad[1]>ymax)ymax=pad[1];
cbaf35fb 152 }
cb8189e7 153 fX/=fQdc;fY/=fQdc;//Center of Gravity
ed83829e 154
155 TVector2 center = AliRICHParam::Pad2Loc(AliRICHParam::Loc2Pad(TVector2(fX,fY)));
bfe16b5f 156 fX += AliRICHParam::CogCorr(fX-center.X());
ed83829e 157
e42a7b46 158 fShape=Int_t(100*(xmax-xmin+1)+ymax-ymin+1);//find box containing cluster
6865fb8d 159 fSize+=nLocals;
cb8189e7 160 fStatus=kRaw;
d4c94996 162
c021cb15 163//__________________AliRICH_________________________________________________________________________
e42a7b46 164class AliESD;
3ea9cb08 165
2f614988 166class AliRICH : public AliDetector
2f614988 168public:
a25b3368 169//ctor & dtor
853634d3 170 AliRICH();
af3d25a6 171 AliRICH(const char *name, const char *title);
d4c94996 172 AliRICH(const AliRICH& RICH):AliDetector(RICH) {;} //copy ctor
853634d3 173 virtual ~AliRICH();
dfb4e77d 174
942194a4 175 AliRICH& operator=(const AliRICH&) {return *this;}
d4c94996 176//framework part
e42a7b46 177 virtual Int_t IsVersion() const =0; //interface from
178 virtual void StepManager() =0; //interface from AliMC
179 virtual void Hits2SDigits(); //interface from AliSimulation
d3eb6079 180 virtual void Digits2Raw(); //interface from AliSimulation
e42a7b46 181 virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* man) const {return new AliRICHDigitizer(man);} //interface from AliSimulation
e42a7b46 182 virtual void SetTreeAddress(); //interface from AliLoader
183 virtual void MakeBranch(Option_t *opt=" "); //interface from AliLoader
184 virtual void CreateMaterials(); //interface from AliMC
185 virtual void CreateGeometry(); //interface from AliMC
d3eb6079 186 void GeomPadPanelFrame()const; //defines PPF geometry
187 void GeomAmpGap() const; //defines gap geometry + anod wires
188 void GeomRadiators() const; //defines radiators geometry
189 void GeomSandBox() const; //defines sandbox geometry
190 void GeomRadioSrc() const; //defines radio source geometry
191 void GeomAerogel() const; //defines aerogel geometry
e42a7b46 192 virtual void BuildGeometry(); //interface
d4c94996 193//private part
a25b3368 194 static Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola); //deals with Fresnel absorption
d4c94996 195 inline void CreateHits(); //create hits container as a simple list
196 inline void CreateSDigits(); //create sdigits container as a simple list
197 inline void CreateDigits(); //create digits container as 7 lists, one per chamber
198 inline void CreateClusters(); //create clusters container as 7 lists, one per chamber
d4c94996 199 void ResetSDigits() {fNsdigits=0; if(fSdigits) fSdigits ->Clear();}
e42a7b46 200 void ResetDigits() {if(fDigitsNew)for(int i=0;i<kNchambers;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}} //virtual
201 void ResetClusters() {if(fClusters) for(int i=0;i<kNchambers;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
c1863e3c 202 TClonesArray* SDigits() const{return fSdigits;}
543d5224 203 TClonesArray* Digits(Int_t iC) const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
c60862bf 204 TClonesArray* Clusters(Int_t iC) const{if(fClusters) return (TClonesArray *)fClusters->At(iC-1);else return 0;}
a25b3368 205 AliRICHChamber* C(Int_t iC) const{return fpParam->C(iC);} //provides pointer to a given chamber
206 AliRICHParam* P() const{return fpParam;} //provides pointer to a RICH params
207 AliRICH* R() {return this;} //provides pointer to RICH main object
208 TVector Counters() const{return fCounters;} //provides a set of counters
209 void ControlPlots(); //creates ~/RCP.root with a set of QA plots
210 virtual void Print(Option_t *option="") const; //prints current RICH status
211 void PrintHits (Int_t iEvent=0); //prints a list of hits for a given event
212 void PrintSDigits (Int_t iEvent=0); //prints a list of sdigits for a given event
213 void PrintDigits (Int_t iEvent=0); //prints a list of digits for a given event
214 void PrintClusters(Int_t iEvent=0); //prints a list of clusters for a given event
215 void PrintTracks (Int_t iEvent=0); //prints a list of tracks for a given event
d3eb6079 216 void CheckPR ()const; //utility-> run staff for stack ??????
217 AliRICHhit* Hit(Int_t tid)const; //returns pointer of the first RICH hit created by a given particle
a25b3368 218 inline void AddHit(Int_t chamber,Int_t tid,TVector3 in3,TVector3 out3,Double_t eloss=0); //add new hit
219 inline void AddSDigit(Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid); //add new sdigit
220 inline void AddDigit(int c,TVector pad,int q,int cfm,int *tid); //add new digit
221// void AddDigit(Int_t c,TVector pad,Int_t q)//for real data digits
222// {TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(0));new(tmp[fNdigitsNew[0]++])AliRICHdigit(c,pad,q,0,-1,-1,-1);}
223 inline void AddCluster(AliRICHcluster &cl); //add new cluster
d3eb6079 224 using AliModule::AddHit; //to get rid of virtual hidden warning
225 using AliModule::AddDigit; //to get rid of virtual hidden warning
226 using AliModule::Digits; //to get rid of virtual hidden warning
c60862bf 227protected:
d3eb6079 228 enum EMedia {kAir=1,kRoha,kSiO2,kC6F14,kCH4,kCsI,kGridCu,kOpSiO2,kGap,kAl,kGlass,kCu,kW,kSteel,kPerpex,kSr90,kMylar,kGel,kReflector};
a25b3368 229 enum ECounters {kStepManager=0,kCerProdTot,kCerProdRad,kCerKillTot,kCerKillRad,kCerKillRef,kEleProdTot};
230 AliRICHParam *fpParam; //main RICH parametrization
231 //fHits and fDigits belong to AliDetector
232 TClonesArray *fSdigits; //! list of sdigits
233 Int_t fNsdigits; //! current number of sdigits
84365c70 234
a25b3368 235 TObjArray *fDigitsNew; //! each chamber holds it's one lists of digits
236 Int_t fNdigitsNew[7]; //! array of current numbers of digits
84365c70 237
a25b3368 238 TObjArray *fClusters; //! each chamber holds it's one lists of clusters
239 Int_t fNclusters[7]; //! array of current numbers of raw clusters
84365c70 240
a25b3368 241 TVector fCounters; //Particle history counters, explanation in StepManager()
243 ClassDef(AliRICH,7) //Main RICH class
c60862bf 244};//class AliRICH
ed3ceb24 245
c1863e3c 246//__________________________________________________________________________________________________
c60862bf 247void AliRICH::CreateHits()
249 if(fHits) return;
998b831f 250 AliDebug(1,"creating hits container.");
c60862bf 251 fHits=new TClonesArray("AliRICHhit",10000); fNhits=0;
543d5224 252}
c60862bf 253//__________________________________________________________________________________________________
c1863e3c 254void AliRICH::CreateSDigits()
c60862bf 255{
256 if(fSdigits) return;
998b831f 257 AliDebug(1,"creating sdigits container.");
c60862bf 258 fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
543d5224 259}
c60862bf 260//__________________________________________________________________________________________________
261void AliRICH::CreateDigits()
263 if(fDigitsNew) return;
998b831f 264 AliDebug(1,"creating digits containers.");
e42a7b46 265 fDigitsNew = new TObjArray(kNchambers);
266 for(Int_t i=0;i<kNchambers;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
543d5224 267}
c60862bf 268//__________________________________________________________________________________________________
269void AliRICH::CreateClusters()
271 if(fClusters) return;
998b831f 272 AliDebug(1,"creating clusters containers.");
e42a7b46 273 fClusters = new TObjArray(kNchambers);
274 for(Int_t i=0;i<kNchambers;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
543d5224 275}
ed3ceb24 276//__________________________________________________________________________________________________
a25b3368 277void AliRICH::AddHit(Int_t c,Int_t tid,TVector3 i3,TVector3 o3,Double_t eloss)
279//add new RICH hit to the list of hits
280 TClonesArray &tmp=*fHits;
281 new(tmp[fNhits++])AliRICHhit(c,tid,i3,o3,eloss);
e42a7b46 284void AliRICH::AddSDigit(Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid)
286 Int_t cfm;
ed3ceb24 287 switch(pid){
e42a7b46 288 case 50000050: cfm=1000000;break;//cerenkov
289 case 50000051: cfm=1000; break;//feedback
290 default: cfm=1; break;//mip
ed3ceb24 291 }
e42a7b46 292 TClonesArray &tmp=*fSdigits; new(tmp[fNsdigits++])AliRICHdigit(c,pad,q,cfm,tid,kBad,kBad);
d4c94996 294//__________________________________________________________________________________________________
a25b3368 295void AliRICH::AddDigit(int c,TVector pad,int q,int cfm,int *tid)
297 TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(c-1));
298 new(tmp[fNdigitsNew[c-1]++])AliRICHdigit(c,pad,q,cfm,tid[0],tid[1],tid[2]);
301void AliRICH::AddCluster(AliRICHcluster &cl)
303 Int_t c=cl.C()-1;TClonesArray &tmp=*((TClonesArray*)fClusters->At(c));
304 new(tmp[fNclusters[c]++])AliRICHcluster(cl);
c60862bf 306#endif//#ifndef AliRICH_h