]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackHits.cxx
Try to fix Delete problem in trigger code
[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 <Riostream.h>
23
24 #include <TClonesArray.h>
25
26 #include "AliTRDtrackHits.h"
27 #include "AliTRDhit.h"    
28
29 ClassImp(AliTRDtrackHits)
30  
31 //_____________________________________________________________________________
32 void  AliTRDtrackHits::AddHitTRD(Int_t volumeID, Int_t trackID, Double_t x
33                                , Double_t y, Double_t z, Int_t q, Bool_t inDrift)
34 {
35   //
36   // Add one TRD hit
37   //
38
39   if (inDrift) {
40     q = 2 * q + 1;
41   }
42   else {
43     q = 2 * q;
44   }
45
46   AddHitKartez(volumeID,trackID,x,y,z,q,0);
47
48 }
49
50 //_____________________________________________________________________________
51 Bool_t AliTRDtrackHits::First()
52 {
53   //
54   // Set Current hit for the first hit
55   //
56
57   if (fArray->GetSize() <= 0) {
58     fCurrentHit->fStatus = kFALSE;
59     return kFALSE;
60   }
61
62   AliTrackHitsParamV2 *param = (AliTrackHitsParamV2 *) fArray->At(0);
63   if (!fHit) {
64     fHit = new AliTRDhit;
65   }
66   if (!(param)) {
67     fCurrentHit->fStatus = kFALSE;
68     return kFALSE;
69   }
70
71   fCurrentHit->fParamIndex = 0;
72   fCurrentHit->fStackIndex = 0;
73
74   ((AliTRDhit *) fHit)->SetDetector(param->fVolumeID);
75   ((AliTRDhit *) fHit)->SetTrack(param->fTrackID);
76   ((AliTRDhit *) fHit)->SetX(param->fR * TMath::Cos(param->fFi));
77   ((AliTRDhit *) fHit)->SetY(param->fR * TMath::Sin(param->fFi));
78   ((AliTRDhit *) fHit)->SetZ(param->fZ); 
79   ((AliTRDhit *) fHit)->SetQ(param->fCharge[0] / 2);  
80   if ((param->fCharge[0] % 2) == 0) {
81     ((AliTRDhit *) fHit)->SetAmplification(); 
82   }
83   else {
84     ((AliTRDhit *) fHit)->SetDrift();
85   }
86   fCurrentHit->fR = param->fR;
87   
88   return fCurrentHit->fStatus = kTRUE;
89
90 }
91 //set current hit to next
92 //_____________________________________________________________________________
93 Bool_t AliTRDtrackHits::Next()
94 {
95   //
96   // Set current hit to next
97   //
98
99   if (!(fCurrentHit->fStatus)) { 
100     return kFALSE;
101   }
102   fCurrentHit->fStackIndex++;
103
104   AliTrackHitsParamV2 *param = (AliTrackHitsParamV2 *) 
105                                  fArray->At(fCurrentHit->fParamIndex);
106
107   if (fCurrentHit->fStackIndex >= param->fNHits) {
108     fCurrentHit->fParamIndex++;
109     if (fCurrentHit->fParamIndex >= fArray->GetEntriesFast()) {
110       fCurrentHit->fStatus = kFALSE;
111       return kFALSE;
112     }
113     param = (AliTrackHitsParamV2 *) fArray->At(fCurrentHit->fParamIndex);
114     fCurrentHit->fStackIndex = 0; 
115     fCurrentHit->fR          = param->fR;
116   }
117
118   Double_t ratio;
119   Double_t dfi2 = param->fAn;
120   dfi2 *= dfi2 * fCurrentHit->fR * fCurrentHit->fR;
121   Double_t ddz2 = param->fTheta;
122   ddz2 *= ddz2;
123   ratio = TMath::Sqrt(1.0 + dfi2 + ddz2);  
124
125   fCurrentHit->fR += fStep * param->fHitDistance[fCurrentHit->fStackIndex] / ratio;
126
127   Double_t dR = fCurrentHit->fR - param->fR;
128   Double_t fi = param->fFi + (param->fAn    * dR + param->fAd     * dR*dR);
129   Double_t z  = param->fZ  + (param->fTheta * dR + param->fThetaD * dR*dR);
130
131   ((AliTRDhit *) fHit)->SetQ(param->fCharge[fCurrentHit->fStackIndex] / 2);   
132   if ((param->fCharge[fCurrentHit->fStackIndex] % 2) ==0) {
133     ((AliTRDhit *) fHit)->SetAmplification();
134   }
135   else {
136     ((AliTRDhit *) fHit)->SetDrift();
137   }
138   ((AliTRDhit *) fHit)->SetX(fCurrentHit->fR * TMath::Cos(fi));
139   ((AliTRDhit *) fHit)->SetY(fCurrentHit->fR * TMath::Sin(fi));
140   ((AliTRDhit *) fHit)->SetZ(z);   
141   ((AliTRDhit *) fHit)->SetDetector(param->fVolumeID);
142   ((AliTRDhit *) fHit)->SetTrack(param->fTrackID);
143
144   return kTRUE;
145
146 }
147