]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackHits.cxx
Updated VZERO source
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackHits.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 ////////////////////////////////////////////////
17 //                                            //
18 //  Manager class for TRD   hits              //
19 //                                            //
20 ////////////////////////////////////////////////
21
22 #include "AliTRDtrackHits.h"
23 #include "TClonesArray.h"    
24 #include "AliTRDhit.h"    
25
26 #include <iostream.h>
27
28
29 ClassImp(AliTRDtrackHits)
30  
31 void  AliTRDtrackHits::AddHitTRD(Int_t volumeID, Int_t trackID, Double_t x, 
32                     Double_t y, Double_t z,Int_t q, Bool_t inDrift)
33 {
34   //
35   // Add one TRD hit
36   //
37
38   if (inDrift) q=2*q+1;
39   else q=2*q;
40   AddHitKartez(volumeID, trackID,x,y,z,q);
41 }
42
43 Bool_t AliTRDtrackHits::First()
44 {
45   //
46   //set Current hit for the first hit
47   //
48   AliTrackHitsParamV2 *param = (AliTrackHitsParamV2 *)fArray->At(0);
49   if (!fHit) 
50     fHit = new AliTRDhit;
51   if (!(param) ) {
52     fCurrentHit->fStatus = kFALSE;
53     return kFALSE;
54   }
55   //
56   fCurrentHit->fParamIndex = 0;
57   fCurrentHit->fStackIndex = 0;
58   //
59   //
60   ((AliTRDhit*)fHit)->SetDetector(param->fVolumeID);
61   ((AliTRDhit*)fHit)->SetTrack(param->fTrackID);
62   ((AliTRDhit*)fHit)->SetX(param->fR*TMath::Cos(param->fFi));
63   ((AliTRDhit*)fHit)->SetY(param->fR*TMath::Sin(param->fFi));
64   ((AliTRDhit*)fHit)->SetZ(param->fZ); 
65   ((AliTRDhit*)fHit)->SetQ(param->fCharge[0]/2);  
66   if (param->fCharge[0]%2==0) ((AliTRDhit*)fHit)->SetAmplification(); 
67   else ((AliTRDhit*)fHit)->SetDrift();
68   fCurrentHit->fR = param->fR;
69   
70   return fCurrentHit->fStatus = kTRUE;
71 }
72
73 Bool_t AliTRDtrackHits::Next()
74 {
75   //
76   //  
77   if (!(fCurrentHit->fStatus)) 
78     return kFALSE;
79
80   fCurrentHit->fStackIndex++;
81
82   AliTrackHitsParamV2 *param =  (AliTrackHitsParamV2 *)fArray->At(fCurrentHit->fParamIndex);
83   if (fCurrentHit->fStackIndex>=((UInt_t) param->fNHits)){
84     fCurrentHit->fParamIndex++;
85     if (fCurrentHit->fParamIndex>=((UInt_t) fArray->GetEntriesFast())){
86       fCurrentHit->fStatus=kFALSE;
87       return kFALSE;
88     }
89     param =  (AliTrackHitsParamV2 *)fArray->At(fCurrentHit->fParamIndex);
90     fCurrentHit->fStackIndex=0; 
91     fCurrentHit->fR = param->fR;
92   }
93
94
95
96   Double_t ratio;
97   
98   //    Double_t dfi2 = param->fAn+2*param->fAd*(fCurrentHit->fR-param->fR);
99   Double_t dfi2 = param->fAn;
100   dfi2*=dfi2*fCurrentHit->fR*fCurrentHit->fR;
101   //    Double_t ddz2 = param->fTheta+2*param->fThetaD*(fCurrentHit->fR-param->fR);
102   Double_t ddz2 =  param->fTheta;
103   ddz2*=ddz2;
104   ratio = TMath::Sqrt(1.+ dfi2+ ddz2);  
105
106
107   fCurrentHit->fR += fStep*param->fHitDistance[fCurrentHit->fStackIndex]/ratio;
108
109   Double_t dR = fCurrentHit->fR - param->fR;
110   Double_t fi = param->fFi + (param->fAn*dR+param->fAd*dR*dR);
111   Double_t z  = param->fZ + (param->fTheta*dR+param->fThetaD*dR*dR);
112
113   ((AliTRDhit*)fHit)->SetQ(param->fCharge[fCurrentHit->fStackIndex]/2);   
114   if ( param->fCharge[fCurrentHit->fStackIndex]%2==0) ((AliTRDhit*)fHit)->SetAmplification();
115   else ((AliTRDhit*)fHit)->SetDrift();
116   ((AliTRDhit*)fHit)->SetX(fCurrentHit->fR*TMath::Cos(fi));
117   ((AliTRDhit*)fHit)->SetY(fCurrentHit->fR*TMath::Sin(fi));
118   ((AliTRDhit*)fHit)->SetZ(z);   
119   ((AliTRDhit*)fHit)->SetDetector(param->fVolumeID);
120   ((AliTRDhit*)fHit)->SetTrack(param->fTrackID);
121
122   return kTRUE;
123 }
124