4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
8 #include <TClonesArray.h>
9 #include <TLorentzVector.h>
10 #include <AliDetector.h>
13 #include "AliRICHDigitizer.h"
14 #include "AliRICHParam.h"
16 #include "AliRICHSDigit.h"
18 //__________________AliRICHhit______________________________________________________________________
19 class AliRICHhit : public AliHit
22 AliRICHhit():AliHit() {fChamber=fPid=kBad; fEloss=kBad; fInX3.SetXYZ(0,0,0);fOutX3.SetXYZ(0,0,0);
23 fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;}
24 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;
25 fX=out.X();fY=out.Y();fZ=out.Z();
26 fPid=kBad;fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;}
27 inline AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits); //old version 3 ?????
28 virtual ~AliRICHhit() {;}
30 Int_t C() const{return fChamber;}
31 Int_t Chamber() const{return fChamber;}
32 Int_t Pid() const{return fPid;}
33 Int_t Particle() const{return fPid;}
34 Float_t Eloss() const{return fEloss;}
35 Float_t MomX() const{return fMomX;}
36 Float_t MomY() const{return fMomY;}
37 Float_t MomZ() const{return fMomZ;}
38 Float_t CerenkovAngle() const{return fCerenkovAngle;}
39 Float_t MomFreoX() const{return fMomFreoX;}
40 Float_t MomFreoY() const{return fMomFreoY;}
41 Float_t MomFreoZ() const{return fMomFreoZ;}
42 TVector3 InX3() const{return fInX3;}
43 TVector3 OutX3() const{return fOutX3;}
44 Double_t Length() const{return (fOutX3-fInX3).Mag();}
45 void Print(Option_t *option="")const; //virtual
47 Int_t fChamber; //chamber number
48 Int_t fPid; //particle code
49 Double_t fEloss; //ionisation energy loss in GAP
50 Float_t fMomX,fMomY,fMomZ; //momentum at photochatode entry point
51 Float_t fNPads; //Pads hit
52 Float_t fCerenkovAngle; //Dummy cerenkov angle
53 Float_t fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
54 TVector3 fInX3; //position at the entrance of the GAP
55 TVector3 fOutX3; //position at exit of the GAP
56 ClassDef(AliRICHhit,2) //RICH hit class
58 //__________________________________________________________________________________________________
59 AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit)
62 // old ctor to be deleted
65 fX=hit[1];fY=hit[2];fZ=hit[3];
67 fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
68 fCerenkovAngle=hit[18];
69 fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
72 //__________________AliRICHCerenkov_________________________________________________________________
73 class AliRICHCerenkov: public AliHit
76 inline AliRICHCerenkov();
77 inline AliRICHCerenkov(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *Cerenkovs);
78 virtual ~AliRICHCerenkov() {;}
80 Int_t fChamber; //chamber number
81 Float_t fTheta,fPhi; //incident theta phi angles in degrees
82 Float_t fTlength; //track length inside the chamber
83 Float_t fEloss; //ionisation energy loss in gas
84 Int_t fPHfirst; //first padhit
85 Int_t fPHlast; //last padhit
86 Int_t fCMother; //index of mother particle
87 Float_t fLoss; //nature of particle loss
88 Float_t fIndex; //index of photon
89 Float_t fProduction; //point of production
90 Float_t fMomX,fMomY,fMomZ; //local Momentum
91 Float_t fNPads; // Pads hit
92 Float_t fCerenkovAngle; // Cerenkov Angle
94 ClassDef(AliRICHCerenkov,1) //RICH cerenkov class
95 };//class AliRICHCerenkov
97 //__________________________________________________________________________________________________
98 AliRICHCerenkov::AliRICHCerenkov()
101 fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
102 fPHfirst=fPHlast=fCMother=kBad;
103 fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
105 //__________________________________________________________________________________________________
106 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
107 :AliHit(shunt, track)
110 fX=hits[1];fY=hits[2];fZ=hits[3];
111 fTheta=hits[4];fPhi=hits[5];
114 fPHfirst=(Int_t)hits[8];fPHlast=(Int_t)hits[9];
115 fCMother=Int_t(hits[10]);
117 fProduction = hits[12];
119 fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
121 fCerenkovAngle=hits[18];
124 //__________________AliRICHdigit____________________________________________________________________
125 class AliRICHdigit :public AliDigit
128 AliRICHdigit() {fCombiPid=fChamber=fPadX=fPadY=fTracks[0]=fTracks[1]=fTracks[2]=kBad;fQdc=kBad;}
129 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)
130 {fPadX=x;fPadY=y;fQdc=q;fChamber=10*c+AliRICHParam::Sector(x,y);fCombiPid=cpid;fTracks[0]=tid0;fTracks[1]=tid1;fTracks[2]=tid2;}
131 virtual ~AliRICHdigit() {;}
132 Int_t Compare(const TObject *pObj) const //virtual
133 {if(Id()==((AliRICHdigit*)pObj)->Id()) return 0; else if(Id()>((AliRICHdigit*)pObj)->Id()) return 1; else return -1;}
135 Bool_t IsSortable() const{return kTRUE;}//virtual
136 Int_t CombiPid() const{return fCombiPid;}
137 Int_t C() const{return fChamber/10;}
138 Int_t S() const{return fChamber-(fChamber/10)*10;}
139 Int_t Chamber() const{return C();}
140 Int_t Sector() const{return S();}
141 Int_t X() const{return fPadX;}
142 Int_t Y() const{return fPadY;}
143 Int_t Id() const{return fChamber*10000000+fPadX*1000+fPadY;}
144 Double_t Q() const{return fQdc;}
145 Int_t Tid(Int_t i) const{return fTracks[i];}
146 void Print(Option_t *option="")const; //virtual
148 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
149 Int_t fChamber; //10*chamber number+ sector number
150 Int_t fPadX; //pad number along X
151 Int_t fPadY; //pad number along Y
152 Double_t fQdc; //QDC value, fractions are permitted for summable procedure
153 ClassDef(AliRICHdigit,2) //RICH digit class
154 };//class AliRICHdigit
156 //__________________AliRICHcluster__________________________________________________________________
157 class AliRICHcluster :public TObject
160 enum ClusterStatus {kEdge,kShape,kSize,kRaw,kResolved};
161 AliRICHcluster() {fSize=fQdc=fStatus=fChamber=fDimXY=0;fX=fY=kBad;fDigits=0;}
162 virtual ~AliRICHcluster() {delete fDigits;}
163 AliRICHcluster& operator=(const AliRICHcluster&) {return *this;}
164 Int_t Nlocals() const{return fSize - 10000*(fSize/10000);} //
165 Int_t Size() const{return fSize/10000;} //
166 Int_t Fsize() const{return fSize;} //
167 Int_t DimXY() const{return fDimXY;} //
168 Int_t C() const{return fChamber/10;} //
169 Int_t S() const{return fChamber-(fChamber/10)*10;} //
170 Int_t Fchamber() const{return fChamber;} //
171 Int_t Chamber() const{return C();} //
172 Int_t Sector() const{return S();} //
173 Int_t Q() const{return fQdc;} //
174 Double_t X() const{return fX;} //
175 Double_t Y() const{return fY;} //
176 Int_t Status() const{return fStatus;} //
177 void SetStatus(Int_t status) {fStatus=status;} //
178 Int_t Nmips() const{return fCombiPid-1000000*Ncerenkovs()-1000*Nfeedbacks();} //
179 Int_t Ncerenkovs() const{return fCombiPid/1000000;} //
180 Int_t Nfeedbacks() const{return (fCombiPid-1000000*Ncerenkovs())/1000;} //
181 Bool_t IsPureMip() const{return fCombiPid<1000;}
182 Bool_t IsPureCerenkov() const{return Nmips()==0&&Nfeedbacks()==0;} //
183 Bool_t IsPureFeedback() const{return Nmips()==0&&Ncerenkovs()==0;} //
184 Int_t CombiPid() const{return fCombiPid;} //
185 void SetCombiPid(Int_t ckov,Int_t feeds,Int_t mips) {fCombiPid=1000000*ckov+1000*feeds+mips;} //
186 void Fill(AliRICHcluster *pRaw,Double_t x,Double_t y, Double_t q, Int_t combipid)
187 {fCombiPid=combipid;fChamber=pRaw->Fchamber();fSize=pRaw->Fsize();
188 fQdc=(Int_t)(q*pRaw->Q());fX=x;fY=y;fStatus=kResolved;} //
189 TObjArray* Digits() const{return fDigits;} //
190 void Print(Option_t *option="")const; //virtual
191 inline void AddDigit(AliRICHdigit *pDig); //
192 inline void CoG(Int_t nLocals); //
193 void Reset() {fSize=fQdc=fStatus=fChamber=fDimXY=kBad;fX=fY=kBad;delete fDigits;fDigits=0;} //
195 Int_t fCombiPid; //1000000*Ncerenkovs+1000*Nfeedbacks+Nmips
196 Int_t fSize; //10000*(how many digits belong to this cluster) + nLocalMaxima
197 Int_t fDimXY; //100*xdim+ydim box containing the cluster
198 Int_t fQdc; //QDC value
199 Int_t fChamber; //10*module number+sector number
200 Double_t fX; //local x postion
201 Double_t fY; //local y postion
202 Int_t fStatus; //flag to mark the quality of the cluster
203 TObjArray *fDigits; //! list of digits forming this cluster
204 ClassDef(AliRICHcluster,2) //RICH cluster class
205 };//class AliRICHcluster
206 //__________________________________________________________________________________________________
207 void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
209 if(!fDigits) {fQdc=fSize=fCombiPid=0;fDigits = new TObjArray;}
210 fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
211 fChamber=10*pDig->C()+pDig->S();
214 //__________________________________________________________________________________________________
215 void AliRICHcluster::CoG(Int_t nLocals)
217 Int_t xmin=999,ymin=999,xmax=0,ymax=0;
219 for(Int_t iDig=0;iDig<Size();iDig++) {
220 AliRICHdigit *pDig=(AliRICHdigit*)fDigits->At(iDig);
221 Int_t padX = pDig->X();Int_t padY = pDig->Y();Double_t q=pDig->Q();
222 TVector2 x2=AliRICHParam::Pad2Loc(padX,padY);
223 fX += x2.X()*q;fY +=x2.Y()*q;
224 if(padX<xmin)xmin=padX;if(padX>xmax)xmax=padX;if(padY<ymin)ymin=padY;if(padY>ymax)ymax=padY;
226 fX/=fQdc;fY/=fQdc;//Center of Gravity
227 fDimXY = 100*(xmax-xmin+1)+ymax-ymin+1;//find box containing cluster
231 //__________________________________________________________________________________________________
232 class AliRICHreco: public TObject
235 AliRICHreco() {fTid=fNphotons=kBad; fThetaCherenkov=kBad;}
236 AliRICHreco(Int_t tid,Double_t thetaCherenkov,Int_t nPhotons) {fTid=tid;fThetaCherenkov=thetaCherenkov;fNphotons=nPhotons;}
238 virtual ~AliRICHreco() {;}
240 void Print(Option_t *option="")const; //virtual print
243 Int_t fTid; // track Id reference
244 Int_t fNphotons; // number of photons contributed to the recontruction
245 Double_t fThetaCherenkov; // reconstructed Theta Cerenkov for a given charged track
247 ClassDef(AliRICHreco,1) //RICH reco class
249 };//class AliRICHreco
250 //__________________AliRICH_________________________________________________________________________
252 class AliRICHChamber;
255 class AliRICH : public AliDetector
259 AliRICH(const char *name, const char *title);
260 AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}
263 AliRICH& operator=(const AliRICH&) {return *this;}
264 virtual Int_t IsVersion() const =0;
265 void Hits2SDigits(); //virtual
266 AliDigitizer* CreateDigitizer(AliRunDigitizer* man) const {return new AliRICHDigitizer(man);} //virtual
267 void SDigits2Digits(); //virtual
269 inline void CreateHits();
270 inline void CreateSDigits();
271 inline void CreateDigits();
272 inline void CreateClusters();
273 inline void CreateRecos();
274 void AddHit(Int_t track, Int_t *vol, Float_t *hits) {TClonesArray &tmp=*fHits; new(tmp[fNhits++])AliRICHhit(fIshunt,track,vol,hits);}//virtual
275 void AddHit(Int_t chamber,Int_t tid,TVector3 iX3,TVector3 oX3,Double_t eloss=0)
276 {TClonesArray &tmp=*fHits;new(tmp[fNhits++])AliRICHhit(chamber,tid,iX3,oX3,eloss);}
277 inline void AddSDigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t pid,Int_t tid);
278 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]);}
279 void AddCluster(AliRICHcluster &cl) {TClonesArray &tmp=*((TClonesArray*)fClusters->At(cl.C()-1));new(tmp[fNclusters[cl.C()-1]++])AliRICHcluster(cl);}
280 void AddReco(Int_t tid,Double_t thetaCherenkov,Int_t nPhotons) {TClonesArray &tmp=*(TClonesArray*)fRecos;new(tmp[fNrecos++])AliRICHreco(tid,thetaCherenkov,nPhotons);}
281 void ResetHits() {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();} //virtual
282 void ResetSDigits() {fNsdigits=0; if(fSdigits) fSdigits ->Clear();}
283 void ResetDigits() {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
284 void ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
285 void ResetRecos() {if(fRecos) fRecos->Clear();fNrecos=0;}
286 //Hits provided by AliDetector
287 TClonesArray* SDigits() const{return fSdigits;}
288 TClonesArray* Digits(Int_t iC) const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
289 TClonesArray* Clusters(Int_t iC) const{if(fClusters) return (TClonesArray *)fClusters->At(iC-1);else return 0;}
290 TClonesArray* Recos() const{return fRecos;}
292 AliRICHChamber* C(Int_t iC) const{return (AliRICHChamber*)fChambers->At(iC-1);}
293 AliRICHParam* Param() const{return fpParam;}
294 AliRICHParam* P() const{return fpParam;}
295 void CreateChambers();
296 void CreateMaterials(); //virtual
297 virtual void BuildGeometry(); //virtual
298 virtual void CreateGeometry(); //virtual
299 Float_t AbsoCH4(Float_t x)const;
300 Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)const;
302 virtual void StepManager()=0;
303 void GenerateFeedbacks(Int_t iChamber,Float_t eloss=0);//eloss=0 for photon
304 void Print(Option_t *option)const;//virtual
305 void MakeBranch(Option_t *opt=" ");
306 void SetTreeAddress();//virtual
307 // OLD staff OLD staff
308 inline void AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
309 inline void AddSpecialOld(Int_t *array);
311 inline void CreateCerenkovsOld();
312 inline void CreateSpecialsOld();
313 void ResetSpecialsOld(){fNspecials=0; if(fSpecials) fSpecials->Clear();}
314 TClonesArray* Specials() const{return fSpecials;}
315 TClonesArray* Cerenkovs() const{return fCerenkovs;}
319 AliRICHChamber& Chamber(Int_t id) {return *((AliRICHChamber *) (*fChambers)[id]);}
320 // Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) {return 9999;}
323 enum {kCSI=6,kGAP=9};
324 AliRICHParam *fpParam; //main RICH parametrization
325 TObjArray *fChambers; //list of RICH chambers
326 //fHits and fDigits belong to AliDetector
327 TClonesArray *fSdigits; //! List of sdigits
328 Int_t fNsdigits; //! Current number of sdigits
329 TObjArray *fDigitsNew; //! Each chamber holds it's one lists of digits
330 Int_t fNdigitsNew[kNCH]; //! Array of current numbers of digits
331 TObjArray *fClusters; //! Each chamber holds it's one lists of clusters
332 Int_t fNclusters[kNCH]; //! Array of current numbers of raw clusters
333 TClonesArray *fRecos; //! pointer to the list of recos
334 Int_t fNrecos; //! number of recos
336 TClonesArray *fCerenkovs; //! ??? List of cerenkovs
337 Int_t fNcerenkovs; //! ??? Current number of cerenkovs
338 TClonesArray *fSpecials; //! ??? List of specials
339 Int_t fNspecials; //! ??? Current number of specials
340 Int_t fCkovNumber; // Number of Cerenkov photons
341 Int_t fFreonProd; // Cerenkovs produced in freon
342 Int_t fFeedbacks; // Number of feedback photons
344 ClassDef(AliRICH,4) //Main RICH class
347 //__________________________________________________________________________________________________
348 void AliRICH::CreateHits()
351 if(GetDebug())Info("CreateHits","creating hits container.");
352 fHits=new TClonesArray("AliRICHhit",10000); fNhits=0;
354 //__________________________________________________________________________________________________
355 void AliRICH::CreateSDigits()
358 if(GetDebug())Info("CreateSDigits","creating sdigits container.");
359 fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
361 //__________________________________________________________________________________________________
362 void AliRICH::CreateDigits()
364 if(fDigitsNew) return;
365 if(GetDebug())Info("CreateDigits","creating digits containers.");
366 fDigitsNew = new TObjArray(kNCH);
367 for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
369 //__________________________________________________________________________________________________
370 void AliRICH::CreateClusters()
372 if(fClusters) return;
373 if(GetDebug())Info("CreateClusters","creating clusters containers.");
374 fClusters = new TObjArray(kNCH);
375 for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
377 //__________________________________________________________________________________________________
378 void AliRICH::CreateRecos()
381 if(GetDebug())Info("CreateRecos","creating recos containers.");
382 fRecos = new TClonesArray("AliRICHreco",1000);fNrecos=0;
384 //__________________________________________________________________________________________________
385 void AliRICH::AddSDigit(Int_t c,Int_t x,Int_t y,Double_t q,Int_t pid,Int_t tid)
388 case 50000050: pid=1000000;break;//cerenkov
389 case 50000051: pid=1000; break;//feedback
390 default: pid=1; break;//mip
392 TClonesArray &tmp=*fSdigits;
393 new(tmp[fNsdigits++])AliRICHdigit(c,x,y,q,pid,tid,kBad,kBad);
397 //______OLD OLD OLD OLD_____________________________________________________________________________
398 void AliRICH::CreateCerenkovsOld()
400 if(fCerenkovs) return;
401 if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
402 fCerenkovs=new TClonesArray("AliRICHCerenkov",10000); fNcerenkovs=0;
404 //__________________________________________________________________________________________________
405 void AliRICH::CreateSpecialsOld()
407 if(fSpecials) return;
408 if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
409 fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
411 //__________________________________________________________________________________________________
412 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
413 {//Adds the current RICH cerenkov hit to the Cerenkovs list
414 TClonesArray &tmp=*fCerenkovs;
415 new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
417 //__________________________________________________________________________________________________
418 void AliRICH::AddSpecialOld(Int_t *aiSDigit)
419 {// Adds the current Sdigit to the RICH list of Specials
420 TClonesArray &lSDigits = *fSpecials;
421 new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
423 #endif//#ifndef AliRICH_h