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>
14 #include "AliRICHConst.h"
15 #include "AliRICHChamber.h"
17 #include "AliRICHDigit.h"
18 #include "AliRICHSDigit.h"
19 #include "AliRICHRawCluster.h"
21 //__________________AliRICHhit______________________________________________________________________
22 //__________________________________________________________________________________________________
23 //__________________________________________________________________________________________________
24 class AliRICHhit : public AliHit
28 inline AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits);
29 inline AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss);
30 virtual ~AliRICHhit() {;}
32 Int_t C() {return fChamber;}
33 Int_t Chamber() {return fChamber;}
34 Int_t Pid() {return fPid;}
35 Int_t Particle() {return fPid;}
36 Float_t Theta() {return fTheta;}
37 Float_t Phi() {return fPhi;}
38 Float_t Tlength() {return fTlength;}
39 Float_t Eloss() {return fEloss;}
40 Float_t Loss() {return fLoss;}
41 Float_t PHfirst() {return fPHfirst;}
42 Float_t PHlast() {return fPHlast;}
43 Float_t MomX() {return fMomX;}
44 Float_t MomY() {return fMomY;}
45 Float_t MomZ() {return fMomZ;}
46 Float_t CerenkovAngle() {return fCerenkovAngle;}
47 Float_t MomFreoX() {return fMomFreoX;}
48 Float_t MomFreoY() {return fMomFreoY;}
49 Float_t MomFreoZ() {return fMomFreoZ;}
50 void Print(Option_t *option="")const; //virtual
52 Int_t fChamber; //chamber number
53 Int_t fPid; //particle code
54 Float_t fTheta,fPhi ; //incident theta phi angles in degrees
55 Float_t fTlength; //track length inside the chamber
56 Float_t fEloss; //ionisation energy loss in gas
57 Float_t fPHfirst; //first padhit
58 Float_t fPHlast; //last padhit
59 Float_t fLoss; // did it hit the freon?
60 Float_t fMomX,fMomY,fMomZ; //momentum at photochatode entry point
61 Float_t fNPads; // Pads hit
62 Float_t fCerenkovAngle; // Dummy cerenkov angle
63 Float_t fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
64 ClassDef(AliRICHhit,1) //RICH hit class
67 //__________________________________________________________________________________________________
68 AliRICHhit::AliRICHhit()
72 fTheta=fPhi=fTlength=fEloss=fPHfirst=fPHlast=fLoss=kBad;
73 fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
75 //__________________________________________________________________________________________________
76 AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
81 fX=hit[1];fY=hit[2];fZ=hit[3];
82 fTheta=hit[4];fPhi=hit[5];
85 fPHfirst=(Int_t)hit[8];
86 fPHlast=(Int_t)hit[9];
88 fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
90 fCerenkovAngle=hit[18];
91 fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
93 //__________________________________________________________________________________________________
94 AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss):
99 fX=x4.X();fY=x4.Y();fZ=x4.Z();
103 //__________________AliRICHCerenkov_________________________________________________________________
104 //__________________________________________________________________________________________________
105 //__________________________________________________________________________________________________
106 class AliRICHCerenkov: public AliHit
109 inline AliRICHCerenkov();
110 inline AliRICHCerenkov(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *Cerenkovs);
111 virtual ~AliRICHCerenkov() {;}
113 Int_t fChamber; //chamber number
114 Float_t fTheta,fPhi; //incident theta phi angles in degrees
115 Float_t fTlength; //track length inside the chamber
116 Float_t fEloss; //ionisation energy loss in gas
117 Int_t fPHfirst; //first padhit
118 Int_t fPHlast; //last padhit
119 Int_t fCMother; //index of mother particle
120 Float_t fLoss; //nature of particle loss
121 Float_t fIndex; //index of photon
122 Float_t fProduction; //point of production
123 Float_t fMomX,fMomY,fMomZ; //local Momentum
124 Float_t fNPads; // Pads hit
125 Float_t fCerenkovAngle; // Cerenkov Angle
127 ClassDef(AliRICHCerenkov,1) //RICH cerenkov class
128 };//class AliRICHCerenkov
130 //__________________________________________________________________________________________________
131 AliRICHCerenkov::AliRICHCerenkov()
134 fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
135 fPHfirst=fPHlast=fCMother=kBad;
136 fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
138 //__________________________________________________________________________________________________
139 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
140 :AliHit(shunt, track)
143 fX=hits[1];fY=hits[2];fZ=hits[3];
144 fTheta=hits[4];fPhi=hits[5];
147 fPHfirst=(Int_t)hits[8];fPHlast=(Int_t)hits[9];
148 fCMother=Int_t(hits[10]);
150 fProduction = hits[12];
152 fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
154 fCerenkovAngle=hits[18];
157 //__________________AliRICHdigit____________________________________________________________________
158 //__________________________________________________________________________________________________
159 //__________________________________________________________________________________________________
160 class AliRICHdigit :public AliDigit
163 AliRICHdigit() {fPadX=fPadY=fChamber=fTracks[0]=fTracks[1]=fTracks[2]=kBad;fQdc=kBad;}
164 inline AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Double_t iQdc,Int_t iT1,Int_t iT2,Int_t iT3);
165 virtual ~AliRICHdigit() {;}
166 inline Int_t Compare(const TObject *pObj) const; //virtual
167 Bool_t IsSortable() const{return kTRUE;}//virtual
168 Int_t C() const{return fChamber;}
169 Int_t X() const{return fPadX;}
170 Int_t Y() const{return fPadY;}
171 Int_t Id() const{return fChamber*1000000+fPadX*1000+fPadY;}
172 Double_t Q() const{return fQdc;}
173 Int_t T(Int_t i) const{return fTracks[i];}
174 void Print(Option_t *option)const; //virtual
176 Int_t fChamber; //module number
177 Int_t fPadX; //pad number along X
178 Int_t fPadY; //pad number along Y
179 Double_t fQdc; //QDC value, fractions are permitted for summable procedure
180 ClassDef(AliRICHdigit,1) //RICH digit class
181 };//class AliRICHdigit
182 //__________________________________________________________________________________________________
183 AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1,Int_t iT2)
185 fChamber=iC;fPadX=iX;fPadY=iY;fQdc=q;
186 fTracks[0]=iT0;fTracks[1]=iT1;fTracks[2]=iT2;
188 //__________________________________________________________________________________________________
189 Int_t AliRICHdigit::Compare(const TObject *pObj)const
191 if(Id()==((AliRICHdigit*)pObj)->Id())
193 else if(Id()>((AliRICHdigit*)pObj)->Id())
198 //__________________AliRICHcluster__________________________________________________________________
199 //__________________________________________________________________________________________________
200 //__________________________________________________________________________________________________
201 class AliRICHcluster :public TObject
204 enum ClusterStatus {kOK,kEdge,kShape,kSize};
206 AliRICHcluster() {fStatus=fSize=fDimXY=fChamber=fQdc=kBad;fX=fY=kBad;fDigits=0;}
207 virtual ~AliRICHcluster() {delete fDigits;}
208 Int_t Size() const{return fSize;}
209 Int_t DimXY() const{return fDimXY;}
210 Int_t Chamber() const{return fChamber/10;}
211 Int_t Sector() const{return fChamber-(fChamber/10)*10;}
212 Int_t Q() const{return fQdc;}
213 Double_t X() const{return fX;}
214 Double_t Y() const{return fY;}
215 Int_t Status() const{return fStatus;}
216 void Print(Option_t *option)const; //virtual
217 inline void AddDigit(AliRICHdigit *pDig);
219 Int_t fSize; //how many digits belong to this cluster
220 Int_t fDimXY; //100*xdim+ydim box containing the cluster
221 Int_t fQdc; //QDC value
222 Int_t fChamber; //10*module number+sector number
223 Double_t fX; //local x postion
224 Double_t fY; //local y postion
225 Int_t fStatus; //flag to mark the quality of the cluster
226 TObjArray *fDigits; //! list of digits forming this cluster
227 ClassDef(AliRICHcluster,1) //RICH digit class
228 };//class AliRICHcluster
229 //__________________________________________________________________________________________________
230 void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
232 fSize++; fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
234 //__________________AliRICH_________________________________________________________________________
235 //__________________________________________________________________________________________________
236 //__________________________________________________________________________________________________
240 class AliRICH : public AliDetector
244 AliRICH(const char *name, const char *title);
245 AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}
248 AliRICH& operator=(const AliRICH&) {return *this;}
249 virtual Int_t IsVersion() const =0;
250 void Hits2SDigits(); //virtual
251 void SDigits2Digits(); //virtual
252 void Digits2Reco(); //virtual
254 inline void CreateHits();
255 inline void CreateSDigits();
256 inline void CreateDigits();
257 inline void CreateClusters();
258 inline void AddHit(Int_t track, Int_t *vol, Float_t *hits); //virtual
259 inline void AddSDigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);
260 inline void AddDigit (Int_t iC,Int_t iX,Int_t iY,Int_t iQ,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);
261 inline void AddCluster(AliRICHcluster clus);
262 void ResetHits() {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();} //virtual
263 void ResetSDigits() {fNsdigits=0; if(fSdigits) fSdigits ->Clear();}
264 void ResetDigits() {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
265 void ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
266 //Hits provided by AliDetector
267 TClonesArray* SDigits() const{return fSdigits;}
268 TClonesArray* Digits(Int_t iC) const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
269 TClonesArray* Clusters(Int_t iC) const{if(fClusters) return (TClonesArray *)fClusters->At(iC-1);else return 0;}
271 AliRICHChamber* C(Int_t iC) const{return (AliRICHChamber*)fChambers->At(iC-1);}
272 AliRICHParam* Param() const{return fpParam;}
274 // AliRICHhit* FirstHit(Int_t iTrkN) {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);} //virtual
275 // AliRICHhit* NextHit() {return (AliRICHhit*)AliDetector::NextHit();} //virtual
277 void CreateChambers();
278 void CreateMaterials(); //virtual
279 virtual void BuildGeometry(); //virtual
280 virtual void CreateGeometry(); //virtual
281 Float_t AbsoCH4(Float_t x);
282 Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola);
284 virtual void StepManager()=0;
285 void GenerateFeedbacks(Int_t iChamber,Float_t eloss);
286 void Print(Option_t *option)const;//virtual
287 void MakeBranch(Option_t *opt=" ");
288 void SetTreeAddress();//virtual
289 // OLD staff OLD staff
290 inline void AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
291 inline void AddSpecialOld(Int_t *);
292 inline void AddDigitOld(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits);
293 inline void AddClusterOld(Int_t iChamber, const AliRICHRawCluster& cluster);
295 inline void CreateCerenkovsOld();
296 inline void CreateSpecialsOld();
297 inline void CreateDigitsOld();
298 inline void CreateRawClustersOld();
299 void ResetDigitsOld() {if(fDchambers) for(int i=0;i<kNCH;i++){fDchambers->At(i)->Clear();fNdch[i]=0;}} //virtual
300 void ResetSpecialsOld(){fNspecials=0; if(fSpecials) fSpecials->Clear();}
301 void ResetRawClusters(){if(fRawClusters)for(int i=0;i<kNCH;i++){fRawClusters->At(i)->Clear();fNrawch[i]=0;}}
303 TClonesArray* DigitsOld(Int_t iC) const{if(fDchambers) return (TClonesArray *)fDchambers->At(iC-1);else return 0;}
304 TClonesArray* ClustersOld(Int_t iC) const{if(fRawClusters)return (TClonesArray *)fRawClusters->At(iC-1);else return 0;}
305 TClonesArray* Specials() const{return fSpecials;}
306 TClonesArray* Cerenkovs() const{return fCerenkovs;}
310 AliRICHChamber& Chamber(Int_t id) {return *((AliRICHChamber *) (*fChambers)[id]);}
311 TObjArray *Dchambers() const{return fDchambers;}
312 Int_t *Ndch() {return fNdch;}
313 TClonesArray *DigitsAddress(Int_t id) const{return ((TClonesArray *) (*fDchambers)[id]);}
314 TClonesArray *RawClustAddress(Int_t id) const{return ((TClonesArray *) (*fRawClusters)[id]);}
315 // Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) {return 9999;}
318 AliRICHParam *fpParam; //main RICH parametrization
319 TObjArray *fChambers; //list of RICH chambers
320 //fHits and fDigits belong to AliDetector
321 TClonesArray *fSdigits; //! List of sdigits
322 Int_t fNsdigits; //Current number of sdigits
323 TObjArray *fDigitsNew; //! Each chamber holds it's one lists of digits
324 Int_t fNdigitsNew[kNCH]; //Array of current numbers of digits
325 TObjArray *fClusters; //! Each chamber holds it's one lists of clusters
326 Int_t fNclusters[kNCH]; //Array of current numbers of raw clusters
328 TClonesArray *fCerenkovs; //! ??? List of cerenkovs
329 Int_t fNcerenkovs; //??? Current number of cerenkovs
330 TClonesArray *fSpecials; //! ??? List of specials
331 Int_t fNspecials; //??? Current number of specials
332 TObjArray *fDchambers; //! Array of lists of digits
333 Int_t fNdch[kNCH]; //Array of current numbers of digits
334 TObjArray *fRawClusters; //! Array of lists of raw clusters
335 Int_t fNrawch[kNCH]; //Array of current numbers of raw clusters
336 Int_t fCkovNumber; // Number of Cerenkov photons
337 Int_t fFreonProd; // Cerenkovs produced in freon
338 Int_t fFeedbacks; // Number of feedback photons
340 ClassDef(AliRICH,3) //Main RICH class
342 //__________________________________________________________________________________________________
343 void AliRICH::AddHit(Int_t track, Int_t *vol, Float_t *hits)
344 {//Adds the current hit to the RICH hits list
345 TClonesArray &tmp=*fHits;
346 new(tmp[fNhits++])AliRICHhit(fIshunt,track,vol,hits);
348 //__________________________________________________________________________________________________
349 void AliRICH::AddSDigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1,Int_t iT2)
350 {//Adds the current Sdigit to the RICH list of Sdigits
351 TClonesArray &tmp=*fSdigits;
352 new(tmp[fNsdigits++])AliRICHdigit(iC,iX,iY,q,iT0,iT1,iT2);
354 //__________________________________________________________________________________________________
355 void AliRICH::AddDigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
356 {//Adds the current digit to the corresponding RICH list of digits (individual list per chamber)
357 TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(iC-1));
358 new(tmp[fNdigitsNew[iC-1]++]) AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
360 //__________________________________________________________________________________________________
361 void AliRICH::AddCluster(AliRICHcluster clus)
362 {//Adds the current cluster to the corresponding RICH list of clusters (individual list per chamber)
363 TClonesArray &tmp=*((TClonesArray*)fClusters->At(clus.Chamber()-1));
364 new(tmp[fNclusters[clus.Chamber()-1]++]) AliRICHcluster(clus);
366 //__________________________________________________________________________________________________
367 void AliRICH::CreateHits()
370 if(GetDebug())Info("CreateHits","creating hits container.");
371 fHits=new TClonesArray("AliRICHhit",10000); fNhits=0;
373 //__________________________________________________________________________________________________
374 void AliRICH::CreateSDigits()
377 if(GetDebug())Info("CreateSDigits","creating sdigits container.");
378 fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
380 //__________________________________________________________________________________________________
381 void AliRICH::CreateDigits()
383 if(fDigitsNew) return;
384 if(GetDebug())Info("CreateDigits","creating digits containers.");
385 fDigitsNew = new TObjArray(kNCH);
386 for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
388 //__________________________________________________________________________________________________
389 void AliRICH::CreateClusters()
391 if(fClusters) return;
392 if(GetDebug())Info("CreateClusters","creating clusters containers.");
393 fClusters = new TObjArray(kNCH);
394 for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
399 //__________________________________________________________________________________________________
400 void AliRICH::CreateCerenkovsOld()
402 if(fCerenkovs) return;
403 if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
404 fCerenkovs=new TClonesArray("AliRICHCerenkov",10000); fNcerenkovs=0;
406 //__________________________________________________________________________________________________
407 void AliRICH::CreateSpecialsOld()
409 if(fSpecials) return;
410 if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
411 fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
413 //__________________________________________________________________________________________________
414 void AliRICH::CreateDigitsOld()
416 if(fDchambers) return;
417 if(GetDebug())Info("CreateDigitsOld","creating digits containers.");
418 fDchambers = new TObjArray(kNCH);
419 for(Int_t i=0;i<kNCH;i++) fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i);
421 //__________________________________________________________________________________________________
422 void AliRICH::CreateRawClustersOld()
424 if(fRawClusters) return;
425 if(GetDebug())Info("CreateClustersOld","creating clusters containers.");
426 fRawClusters = new TObjArray(kNCH);
427 for(Int_t i=0; i<kNCH ;i++) fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i);
429 //__________________________________________________________________________________________________
430 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
431 {//Adds the current RICH cerenkov hit to the Cerenkovs list
432 TClonesArray &tmp=*fCerenkovs;
433 new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
435 //__________________________________________________________________________________________________
436 void AliRICH::AddSpecialOld(Int_t *aiSDigit)
437 {// Adds the current Sdigit to the RICH list of Specials
438 TClonesArray &lSDigits = *fSpecials;
439 new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
441 //__________________________________________________________________________________________________
442 void AliRICH::AddDigitOld(Int_t iChamber, Int_t *tracks, Int_t *charges, Int_t *digits)
443 {// Adds the current digit to the RICH list of S digits
444 TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(iChamber-1));
445 new(ldigits[fNdch[iChamber-1]++]) AliRICHDigit(tracks,charges,digits);
447 //__________________________________________________________________________________________________
448 void AliRICH::AddClusterOld(Int_t iChamber, const AliRICHRawCluster& c)
449 {// Add a RICH raw cluster to the list
450 TClonesArray &tmp= *((TClonesArray*)fRawClusters->At(iChamber-1));
451 new(tmp[fNrawch[iChamber-1]++]) AliRICHRawCluster(c);
453 //__________________________________________________________________________________________________
454 #endif//#ifndef AliRICH_h