]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCParamCR.cxx
Add tmevsin and mevsim libraries.
[u/mrichter/AliRoot.git] / TPC / AliTPCParamCR.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 $Log$
18 Revision 1.4  2000/11/02 07:33:15  kowal2
19 Improvements of the code.
20
21 Revision 1.3  2000/06/30 12:07:50  kowal2
22 Updated from the TPC-PreRelease branch
23
24 Revision 1.2.4.1  2000/06/14 16:48:24  kowal2
25 Parameter setting improved. Removed compiler warnings
26
27 Revision 1.2  2000/04/17 09:37:33  kowal2
28 removed obsolete AliTPCDigitsDisplay.C
29
30 Revision 1.1.4.2  2000/04/10 11:36:13  kowal2
31
32 New Detector parameters handling class
33
34 */
35
36 ///////////////////////////////////////////////////////////////////////
37 //  Manager and of geomety  classes for set: TPC                     //
38 //                                                                   //
39 //  !sectors are numbered from  0                                     //
40 //  !pad rows are numbered from 0                                     //
41 //  
42 //  27.7.   - AliTPCPaaramSr object for TPC 
43 //            TPC with straight pad rows 
44 //  Origin:  Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk // 
45 //                                                                   //  
46 ///////////////////////////////////////////////////////////////////////
47
48
49 #include <iostream.h>
50 #include <TMath.h>
51 #include <TClass.h>
52 #include <AliTPCParamCR.h>
53 #include "AliTPCPRF2D.h"
54 #include "AliTPCRF1D.h"
55
56
57
58 ClassImp(AliTPCParamCR)
59 const static  Int_t kMaxRows=600;
60 const static  Float_t  kEdgeSectorSpace = 2.5;
61
62 AliTPCParamCR::AliTPCParamCR()
63 {   
64   //
65   //constructor set the default parameters
66   fInnerPRF=0;
67   fOuterPRF=0;
68   fTimeRF = 0;
69   fFacSigma = Float_t(2.);
70   SetDefault();
71   Update();
72 }
73
74 AliTPCParamCR::~AliTPCParamCR()
75 {
76   //
77   //destructor destroy some dynmicaly alocated variables
78   if (fInnerPRF != 0) delete fInnerPRF;
79   if (fOuterPRF != 0) delete fOuterPRF;
80   if (fTimeRF != 0) delete fTimeRF;
81 }
82
83 void AliTPCParamCR::SetDefault()
84 {
85   //set default TPC param   
86   fbStatus = kFALSE;
87   AliTPCParam::SetDefault();  
88 }  
89
90 Int_t  AliTPCParamCR::CalcResponse(Float_t* xyz, Int_t * index, Int_t dummy)
91 {
92   //
93   //calculate bin response as function of the input position -x 
94   //return number of valid response bin
95   //
96   //we suppose that coordinata is expressed in float digits 
97   // it's mean coordinate system 8
98   //xyz[0] - float padrow xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
99   if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){ 
100     Error("AliTPCParamCR", "response function were not adjusted");
101     return -1;
102   }
103   
104   Float_t sfpadrow;   // sigma of response function
105   Float_t sfpad;      // sigma  of 
106   Float_t sftime= fFacSigma*fTimeRF->GetSigma()/fZWidth;     //3 sigma of time response
107   if (index[1]<fNInnerSector){
108     sfpadrow =fFacSigma*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
109     sfpad    =fFacSigma*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
110   }else{
111     sfpadrow =fFacSigma*fOuterPRF->GetSigmaY()/fOuterPadPitchLength;
112     sfpad    =fFacSigma*fOuterPRF->GetSigmaX()/fOuterPadPitchWidth;
113   }
114
115   Int_t fpadrow = TMath::Nint(xyz[0]-sfpadrow);  //"first" padrow
116   Int_t fpad    = TMath::Nint(xyz[1]-sfpad);     //first pad
117   Int_t ftime   = TMath::Nint(xyz[2]+fTimeRF->GetOffset()-sftime);    // first time
118   Int_t lpadrow = TMath::Min(TMath::Nint(xyz[0]+sfpadrow),fpadrow+19);  //"last" padrow
119   Int_t lpad    = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19);     //last pad
120   Int_t ltime   = TMath::Min(TMath::Nint(xyz[2]+fTimeRF->GetOffset()+sftime),ftime+19);    // last time
121    
122   Float_t  padres[20][20];  //I don't expect bigger number of bins
123   Float_t  timeres[20];     
124   //calculate padresponse function 
125   Int_t padrow; 
126   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
127     for (Int_t pad = fpad;pad<=lpad;pad++){
128       Float_t dy = (xyz[0]-Float_t(padrow));
129       Float_t dx = (xyz[1]-Float_t(pad));
130       if (index[1]<fNInnerSector)
131         padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
132       else
133         padres[padrow-fpadrow][pad-fpad]=fOuterPRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuterPadPitchLength);      
134     }
135   //calculate time response function
136
137   Int_t time;
138   for (time = ftime;time<=ltime;time++) timeres[time-ftime]= fTimeRF->GetRF((xyz[2]-Float_t(time))*fZWidth); 
139     
140   //write over threshold values to stack
141   Int_t cindex3=-1;
142   Int_t cindex=0;
143   Float_t cweight = 0;
144   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
145     for (Int_t pad = fpad;pad<=lpad;pad++)
146       for (time = ftime;time<=ltime;time++){
147         cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
148         if (cweight>fResponseThreshold) {
149           fResponseBin[++cindex3]=padrow;
150           fResponseBin[++cindex3]=pad;
151           fResponseBin[++cindex3]=time;
152           fResponseWeight[++cindex]=cweight;
153         }
154       }
155   fCurrentMax=cindex;   
156   return fCurrentMax;
157 }
158
159 void AliTPCParamCR::CRXYZtoXYZ(Float_t *xyz,
160                const Int_t &sector, const Int_t & padrow, Int_t option) const  
161 {  
162   //transform relative coordinates to absolute
163   Bool_t rel = ( (option&2)!=0);
164   Int_t index[2]={sector,padrow};
165   if (rel==kTRUE)      Transform4to3(xyz,index);//if the position is relative to pad row  
166   Transform2to1(xyz,index);
167 }
168
169 void AliTPCParamCR::XYZtoCRXYZ(Float_t *xyz,
170                              Int_t &sector, Int_t & padrow, Int_t option) const
171 {
172    //transform global position to the position relative to the sector padrow
173   //if option=0  X calculate absolute            calculate sector
174   //if option=1  X           absolute            use input sector
175   //if option=2  X           relative to pad row calculate sector
176   //if option=3  X           relative            use input sector
177   //!!!!!!!!! WE start to calculate rows from row = 0
178   Int_t index[2];
179   Bool_t rel = ( (option&2)!=0);  
180
181   //option 0 and 2  means that we don't have information about sector
182   if ((option&1)==0)   Transform0to1(xyz,index);  //we calculate sector number 
183   else
184     index[0]=sector;
185   Transform1to2(xyz,index);
186   Transform2to3(xyz,index);
187   //if we store relative position calculate position relative to pad row
188   if (rel==kTRUE) Transform3to4(xyz,index);
189   sector = index[0];
190   padrow = index[1];
191 }
192
193
194          
195 Bool_t AliTPCParamCR::Update()
196 {
197   
198   //
199   // update some calculated parameter which must be updated after changing "base"
200   // parameters 
201   // for example we can change size of pads and according this recalculate number
202   // of pad rows, number of of pads in given row ....
203   Int_t i;
204   if (AliTPCParam::Update()==kFALSE) return kFALSE;
205   fbStatus = kFALSE;
206
207   // adjust lower sectors pad row positions and pad numbers 
208   fNRowLow   =  (Int_t(1.0001*(fRInnerLastWire-fRInnerFirstWire)/fInnerWWPitch)
209                -2*fInnerDummyWire)/fNInnerWiresPerPad;  
210   if ( kMaxRows<fNRowLow) fNRowUp = kMaxRows;
211   if (1>fNRowLow) return kFALSE;
212   Float_t firstpad = fRInnerFirstWire+(fInnerDummyWire-0.5)*fInnerWWPitch
213     +fInnerPadPitchLength/2.;
214       
215   for (i = 0;i<fNRowLow;i++) 
216     {
217        Float_t x  = firstpad +fInnerPadPitchLength*(Float_t)i;       
218        Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerFrameSpace-
219                     fInnerPadPitchWidth/2.;
220        fPadRowLow[i] = x;
221        fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
222        }
223
224   // adjust upper sectors pad row positions and pad numbers
225   fNRowUp   = (Int_t((fROuterLastWire-fROuterFirstWire+0.001)/fOuterWWPitch)
226                -2*fOuterDummyWire)/fNOuterWiresPerPad; 
227   if ( kMaxRows<fNRowUp) fNRowUp = kMaxRows;
228   if (1>fNRowUp) return kFALSE;
229   firstpad = fROuterFirstWire+(fOuterDummyWire-0.5)*fOuterWWPitch
230     +fOuterPadPitchLength/2.;
231  
232   for (i = 0;i<fNRowUp;i++) 
233     {
234        Float_t x  = firstpad + fOuterPadPitchLength*(Float_t)i;      
235        Float_t y = (x-0.5*fOuterPadPitchLength)*tan(fOuterAngle/2.)-fOuterFrameSpace-
236                     fInnerPadPitchWidth/2.;
237        fPadRowUp[i] = x;
238        fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
239     }
240   fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
241   fbStatus = kTRUE;
242   return kTRUE;
243 }
244
245
246
247 void AliTPCParamCR::Streamer(TBuffer &R__b)
248 {
249    // Stream an object of class AliTPC.
250
251    if (R__b.IsReading()) {
252       AliTPCParamCR::Class()->ReadBuffer(R__b, this);
253       Update();
254    } else {
255       AliTPCParamCR::Class()->WriteBuffer(R__b, this);
256    }
257 }
258
259
260
261
262
263
264
265
266
267