/*
$Log$
+Revision 1.52 2002/02/18 09:26:09 kowal2
+Removed compiler warning
+
Revision 1.51 2002/01/21 17:13:21 kowal2
New track hits using root containers. Setting active sectors added.
ClassImp(AliTPC)
+//_____________________________________________________________________________
+// helper class for fast matrix and vector manipulation - no range checking
+// origin - Marian Ivanov
+
+class AliTPCFastMatrix : public TMatrix {
+public :
+ AliTPCFastMatrix(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb);
+ inline Float_t & UncheckedAt(Int_t rown, Int_t coln) const {return (fIndex[coln])[rown];} //fast acces
+ inline Float_t UncheckedAtFast(Int_t rown, Int_t coln) const {return (fIndex[coln])[rown];} //fast acces
+};
+
+AliTPCFastMatrix::AliTPCFastMatrix(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb):
+ TMatrix(row_lwb, row_upb,col_lwb,col_upb)
+ {
+ };
+//_____________________________________________________________________________
+class AliTPCFastVector : public TVector {
+public :
+ AliTPCFastVector(Int_t size);
+ inline Float_t & UncheckedAt(Int_t index) const {return fElements[index];} //fast acces
+};
+
+AliTPCFastVector::AliTPCFastVector(Int_t size):TVector(size){
+};
+
//_____________________________________________________________________________
AliTPC::AliTPC()
{
// Int_t sector,nhits;
Int_t ipart;
const Int_t kcmaxhits=30000;
- TVector * xxxx = new TVector(kcmaxhits*4);
- TVector & xxx = *xxxx;
+ AliTPCFastVector * xxxx = new AliTPCFastVector(kcmaxhits*4);
+ AliTPCFastVector & xxx = *xxxx;
Int_t maxhits = kcmaxhits;
//construct array for each padrow
for (Int_t i=0; i<fTPCParam->GetNRow(isec);i++)
//--------------------------------------------------------
// Digitize this sector, row by row
- // row[i] is the pointer to the TObjArray of TVectors,
+ // row[i] is the pointer to the TObjArray of AliTPCFastVectors,
// each one containing electrons accepted on this
// row, assigned into tracks
//--------------------------------------------------------
// Integrated signal for this row
// and a single track signal
//
- TMatrix *m1 = new TMatrix(0,nofPads,0,nofTbins); // integrated
- TMatrix *m2 = new TMatrix(0,nofPads,0,nofTbins); // single
+
+ AliTPCFastMatrix *m1 = new AliTPCFastMatrix(0,nofPads,0,nofTbins); // integrated
+ AliTPCFastMatrix *m2 = new AliTPCFastMatrix(0,nofPads,0,nofTbins); // single
//
- TMatrix &total = *m1;
+ AliTPCFastMatrix &total = *m1;
// Array of pointers to the label-signal list
Int_t tracks[3];
AliDigits *dig = fDigitsArray->GetRow(isec,irow);
- for(Int_t ip=0;ip<nofPads;ip++){
- for(Int_t it=0;it<nofTbins;it++){
-
- Float_t q = total(ip,it);
-
- Int_t gi =it*nofPads+ip; // global index
-
+ Int_t gi=-1;
+ Float_t fzerosup = zerosup+0.5;
+ for(Int_t it=0;it<nofTbins;it++){
+ Float_t *pq = &(total.UncheckedAt(0,it));
+ for(Int_t ip=0;ip<nofPads;ip++){
+ gi++;
+ Float_t q=*pq;
+ pq++;
if(fDigitsSwitch == 0){
-
- // q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac());
q+=GetNoise();
+ if(q <=fzerosup) continue; // do not fill zeros
q = TMath::Nint(q);
-
- if(q <=zerosup) continue; // do not fill zeros
if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); // saturation
}
//_____________________________________________________________________________
-Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, TMatrix *m1, TMatrix *m2,
- Int_t *indexRange)
+Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr,
+ AliTPCFastMatrix *m1, AliTPCFastMatrix *m2,Int_t *indexRange)
{
//---------------------------------------------------------------
// Modified: Marian Ivanov
//-----------------------------------------------------------------
- TVector *tv;
-
- tv = (TVector*)p1->At(ntr); // pointer to a track
- TVector &v = *tv;
+ AliTPCFastVector *tv;
+
+ tv = (AliTPCFastVector*)p1->At(ntr); // pointer to a track
+ AliTPCFastVector &v = *tv;
Float_t label = v(0);
Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3])-1)/2;
indexRange[2]=9999; //min time
indexRange[3]=-1; // max time
- // Float_t IneffFactor = 0.5; // inefficiency in the gain close to the edge, as above
-
- TMatrix &signal = *m1;
- TMatrix &total = *m2;
+ AliTPCFastMatrix &signal = *m1;
+ AliTPCFastMatrix &total = *m2;
//
// Loop over all electrons
//
Float_t aval = v(idx+4);
Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac();
Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)};
- Int_t n = fTPCParam->CalcResponse(xyz,fCurrentIndex,fCurrentIndex[3]);
-
- if (n>0) for (Int_t i =0; i<n; i++){
- Int_t *index = fTPCParam->GetResBin(i);
+ Int_t n = ((AliTPCParamSR*)fTPCParam)->CalcResponseFast(xyz,fCurrentIndex,fCurrentIndex[3]);
+
+ Int_t *index = fTPCParam->GetResBin(0);
+ Float_t *weight = & (fTPCParam->GetResWeight(0));
+
+ if (n>0) for (Int_t i =0; i<n; i++){
Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0
- if ( ( pad<(fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]))) && (pad>=0)) {
+
+ if (pad>=0){
Int_t time=index[2];
- Float_t weight = fTPCParam->GetResWeight(i); //we normalise response to ADC channel
- weight *= eltoadcfac;
+ Float_t qweight = *(weight)*eltoadcfac;
- if (m1!=0) signal(pad,time)+=weight;
- total(pad,time)+=weight;
- indexRange[0]=TMath::Min(indexRange[0],pad);
- indexRange[1]=TMath::Max(indexRange[1],pad);
- indexRange[2]=TMath::Min(indexRange[2],time);
- indexRange[3]=TMath::Max(indexRange[3],time);
+ if (m1!=0) signal.UncheckedAt(pad,time)+=qweight;
+ total.UncheckedAt(pad,time)+=qweight;
+ if (indexRange[0]>pad) indexRange[0]=pad;
+ if (indexRange[1]<pad) indexRange[1]=pad;
+ if (indexRange[2]>time) indexRange[2]=time;
+ if (indexRange[3]<time) indexRange[3]=time;
+
+ index+=3;
+ weight++;
+
}
}
} // end of loop over electrons
}
//_____________________________________________________________________________
-void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,Int_t *indexRange,
- Float_t **pList)
+void AliTPC::GetList(Float_t label,Int_t np,AliTPCFastMatrix *m,
+ Int_t *indexRange, Float_t **pList)
{
//----------------------------------------------------------------------
// Updates the list of tracks contributing to digits for a given row
// Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
//-----------------------------------------------------------------
- TMatrix &signal = *m;
+ AliTPCFastMatrix &signal = *m;
// lop over nonzero digits
//----------------------------------------------
// Create TObjArray-s, one for each row,
- // each TObjArray will store the TVectors
- // of electrons, one TVector per each track.
+ // each TObjArray will store the AliTPCFastVectors
+ // of electrons, one AliTPCFastVectors per each track.
//----------------------------------------------
Int_t *nofElectrons = new Int_t [nrows]; // electron counter for each row
- TVector **tracks = new TVector* [nrows]; //pointers to the track vectors
+ AliTPCFastVector **tracks = new AliTPCFastVector* [nrows]; //pointers to the track vectors
+
for(i=0; i<nrows; i++){
row[i] = new TObjArray;
nofElectrons[i]=0;
for(i=0;i<nrows;i++){
if(previousTrack != -1){
if(nofElectrons[i]>0){
- TVector &v = *tracks[i];
+ AliTPCFastVector &v = *tracks[i];
v(0) = previousTrack;
tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
row[i]->Add(tracks[i]);
}
else{
- delete tracks[i]; // delete empty TVector
+ delete tracks[i]; // delete empty AliTPCFastVector
tracks[i]=0;
}
}
nofElectrons[i]=0;
- tracks[i] = new TVector(481); // TVectors for the next fTrack
+ tracks[i] = new AliTPCFastVector(481); // AliTPCFastVectors for the next fTrack
} // end of loop over rows
}
}
- TVector &v = *tracks[rowNumber];
+ AliTPCFastVector &v = *tracks[rowNumber];
Int_t idx = 4*nofElectrons[rowNumber]-3;
-
- v(idx)= xyz[0]; // X - pad row coordinate
- v(idx+1)=xyz[1]; // Y - pad coordinate (along the pad-row)
- v(idx+2)=xyz[2]; // Z - time bin coordinate
- v(idx+3)=xyz[3]; // avalanche size
+ Real_t * position = &(((AliTPCFastVector&)v).UncheckedAt(idx)); //make code faster
+ memcpy(position,xyz,4*sizeof(Float_t));
+
} // end of loop over electrons
tpcHit = (AliTPChit*)NextHit();
for(i=0;i<nrows;i++){
if(nofElectrons[i]>0){
- TVector &v = *tracks[i];
+ AliTPCFastVector &v = *tracks[i];
v(0) = previousTrack;
tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
row[i]->Add(tracks[i]);
Int_t ipart;
const Int_t kcmaxhits=30000;
- TVector * xxxx = new TVector(kcmaxhits*4);
- TVector & xxx = *xxxx;
+ AliTPCFastVector * xxxx = new AliTPCFastVector(kcmaxhits*4);
+ AliTPCFastVector & xxx = *xxxx;
Int_t maxhits = kcmaxhits;
//
/*
$Log$
+Revision 1.5 2001/12/06 07:49:30 kowal2
+corrected number of pads calculation
+
Revision 1.4 2000/11/02 07:33:15 kowal2
Improvements of the code.
#include <AliTPCParamSR.h>
#include "AliTPCPRF2D.h"
#include "AliTPCRF1D.h"
-
+#include "TH1.h"
ClassImp(AliTPCParamSR)
Int_t lpad = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19); //last pad
Int_t ltime = TMath::Min(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()+sftime),ftime+19); // last time
ltime = TMath::Min(ltime,GetMaxTBin()-1);
-
+ //
+ Int_t npads = GetNPads(index[1],row);
+ if (fpad<-npads/2)
+ fpad = -npads/2;
+ if (lpad>npads/2)
+ lpad= npads/2;
+ if (ftime<0) ftime=0;
+ //
if (row>=0) { //if we are interesting about given pad row
if (fpadrow<=row) fpadrow =row;
else
AliTPCParam::Streamer(R__b);
}
}
+Int_t AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
+{
+ //
+ //calculate bin response as function of the input position -x
+ //return number of valid response bin
+ //
+ //we suppose that coordinate is expressed in float digits
+ // it's mean coordinate system 8
+ //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
+ if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){
+ Error("AliTPCParamSR", "response function was not adjusted");
+ return -1;
+ }
+
+ const Int_t padn = 500;
+ const Float_t fpadn = 500.;
+ const Int_t timen = 500;
+ const Float_t ftimen = 500.;
+ const Int_t padrn = 500;
+ const Float_t fpadrn = 500.;
+
+
+ static Float_t prfinner[2*padrn][5*padn]; //pad divided by 50
+ static Float_t prfouter[2*padrn][5*padn]; //prfouter division
+
+ static Float_t rftime[5*timen]; //time division
+ static Int_t blabla=0;
+ static Float_t zoffset=0;
+ static Float_t zwidth=0;
+ static Float_t zoffset2=0;
+ static TH1F * hdiff=0;
+ static TH1F * hdiff1=0;
+ static TH1F * hdiff2=0;
+
+ if (blabla==0) { //calculate Response function - only at the begginning
+ hdiff =new TH1F("prf_diff","prf_diff",10000,-1,1);
+ hdiff1 =new TH1F("no_repsonse1","no_response1",10000,-1,1);
+ hdiff2 =new TH1F("no_response2","no_response2",10000,-1,1);
+
+ blabla=1;
+ zoffset = GetZOffset();
+ zwidth = fZWidth;
+ zoffset2 = zoffset/zwidth;
+ for (Int_t i=0;i<5*timen;i++){
+ rftime[i] = fTimeRF->GetRF(((i-2.5*ftimen)/ftimen)*zwidth+zoffset);
+ }
+ for (Int_t i=0;i<5*padn;i++){
+ for (Int_t j=0;j<2*padrn;j++){
+ prfinner[j][i] =
+ fInnerPRF->GetPRF((i-2.5*fpadn)/fpadn
+ *fInnerPadPitchWidth,(j-fpadrn)/fpadrn*fInnerPadPitchLength);
+ prfouter[j][i] =
+ fOuterPRF->GetPRF((i-2.5*fpadn)/fpadn
+ *fOuterPadPitchWidth,(j-fpadrn)/fpadrn*fOuterPadPitchLength);
+ }
+ }
+ }
+ // calculate central padrow, pad, time
+ Int_t npads = GetNPads(index[1],index[2]);
+ Int_t cpadrow = index[2];
+ Int_t cpad = TMath::Nint(xyz[1]);
+ Int_t ctime = TMath::Nint(xyz[2]+zoffset2);
+ //calulate deviation
+ Float_t dpadrow = xyz[0];
+ Float_t dpad = xyz[1]-cpad;
+ Float_t dtime = xyz[2]+zoffset2-ctime;
+ Int_t cindex =0;
+ Int_t cindex3 =0;
+ Int_t maxt =GetMaxTBin();
+
+ Int_t fpadrow;
+ Int_t lpadrow;
+
+ if (row>=0) { //if we are interesting about given pad row
+ fpadrow = row-cpadrow;
+ lpadrow = row-cpadrow;
+ }else{
+ fpadrow = (index[2]>1) ? -1 :0;
+ lpadrow = (index[2]<GetNRow(index[1])-1) ? 1:0;
+ }
+ Int_t fpad = (cpad > -npads/2+1) ? -2: -npads/2-cpad;
+ Int_t lpad = (cpad < npads/2-1) ? 2: npads/2-cpad;
+ Int_t ftime = (ctime>1) ? -2: -ctime;
+ Int_t ltime = (ctime<maxt-2) ? 2: maxt-ctime-1;
+
+ Int_t apadrow= TMath::Nint((dpadrow-fpadrow)*fpadrn+fpadrn);
+ //Int_t apadrow= TMath::Nint((-dpadrow-fpadrow)*fpadrn+fpadrn);
+
+ for (Int_t ipadrow = fpadrow; ipadrow<=lpadrow;ipadrow++){
+ if ( (apadrow<0) || (apadrow>=2*padrn))
+ continue;
+ Int_t apad= TMath::Nint((dpad-fpad)*fpadn+2.5*fpadn);
+ for (Int_t ipad = fpad; ipad<=lpad;ipad++){
+ Float_t cweight;
+ if (index[1]<fNInnerSector)
+ cweight=prfinner[apadrow][apad];
+ else
+ cweight=prfouter[apadrow][apad];
+ // if (cweight<fResponseThreshold) continue;
+ Int_t atime = TMath::Nint((dtime-ftime)*ftimen+2.5*ftimen);
+ for (Int_t itime = ftime;itime<=ltime;itime++){
+ Float_t cweight2 = cweight*rftime[atime];
+ if (cweight2>fResponseThreshold) {
+ fResponseBin[cindex3++]=cpadrow+ipadrow;
+ fResponseBin[cindex3++]=cpad+ipad;
+ fResponseBin[cindex3++]=ctime+itime;
+ fResponseWeight[cindex++]=cweight2;
+
+ if (cweight2>100)
+ {
+ printf("Pici pici %d %f %d\n",ipad,dpad,apad);
+ }
+
+ }
+ atime-=timen;
+ }
+ apad-= padn;
+ }
+ apadrow-=padrn;
+ }
+ fCurrentMax=cindex;
+ return fCurrentMax;
+
+}