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