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