X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDchamberTimeBin.cxx;h=51c0eb1dbca806c7208d074eac205fc2572ca862;hb=b4b977f70edde287e24f18a09a8e9e70129edda4;hp=ccc024285bc2c4d29df635917ea5a91620abb348;hpb=29f95561a03f8e7f4baa77b63395b5d092cfd353;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDchamberTimeBin.cxx b/TRD/AliTRDchamberTimeBin.cxx index ccc024285bc..51c0eb1dbca 100644 --- a/TRD/AliTRDchamberTimeBin.cxx +++ b/TRD/AliTRDchamberTimeBin.cxx @@ -31,13 +31,11 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include #include -#include #include #include "AliLog.h" - +#include "AliTRDcluster.h" #include "AliTRDgeometry.h" #include "AliTRDpadPlane.h" #include "AliTRDchamberTimeBin.h" @@ -49,7 +47,7 @@ ClassImp(AliTRDchamberTimeBin) //_____________________________________________________________________________ AliTRDchamberTimeBin::AliTRDchamberTimeBin(Int_t plane, Int_t stack, Int_t sector, Double_t z0, Double_t zLength) :TObject() - ,fReconstructor(0x0) + ,fkReconstructor(NULL) ,fPlane(plane) ,fStack(stack) ,fSector(sector) @@ -73,7 +71,7 @@ AliTRDchamberTimeBin::AliTRDchamberTimeBin(Int_t plane, Int_t stack, Int_t secto //_____________________________________________________________________________ AliTRDchamberTimeBin::AliTRDchamberTimeBin(const AliTRDchamberTimeBin &layer): TObject() - ,fReconstructor(layer.fReconstructor) + ,fkReconstructor(layer.fkReconstructor) ,fPlane(layer.fPlane) ,fStack(layer.fStack) ,fSector(layer.fSector) @@ -107,10 +105,11 @@ AliTRDchamberTimeBin &AliTRDchamberTimeBin::operator=(const AliTRDchamberTimeBin //_____________________________________________________________________________ void AliTRDchamberTimeBin::Clear(const Option_t *) { - for(AliTRDcluster **cit = &fClusters[0]; (*cit); cit++){ - if(IsOwner()) delete (*cit); - (*cit) = NULL; - } + // Reset the Chamber Timebin + if(IsOwner()) + for(Int_t it = 0; itIsUsed()){ - fClusters[i] = 0x0; + if(fClusters[i]->IsUsed() || fClusters[i]->IsShared()){ + fClusters[i] = NULL; fIndex[i] = 0xffff; } else nClStack++; } - if(nClStack > kMaxClustersLayer) AliWarning(Form("Number of clusters in stack %d exceed buffer size %d. Truncating.", nClStack, kMaxClustersLayer)); + if(nClStack > kMaxClustersLayer) AliInfo(Form("Number of clusters in stack %d exceed buffer size %d. Truncating.", nClStack, kMaxClustersLayer)); // Nothing in this time bin. Reset indexes if(!nClStack){ fN = 0; - memset(&fPositions[0], 0xff, sizeof(UChar_t) * kMaxRows); - memset(&fClusters[0], 0x0, sizeof(AliTRDcluster*) * kMaxClustersLayer); - memset(&fIndex[0], 0xffff, sizeof(UInt_t) * kMaxClustersLayer); + memset(&fPositions[0], 0, sizeof(UChar_t) * kMaxRows); + memset(&fClusters[0], 0, sizeof(AliTRDcluster*) * kMaxClustersLayer); + memset(&fIndex[0], 0, sizeof(UInt_t) * kMaxClustersLayer); return; } @@ -268,7 +267,7 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter) nClStack = 0; // Defining iterators AliTRDcluster **fcliter = &fClusters[0], **hcliter = &helpCL[0]; UInt_t *finditer = &fIndex[0], *hinditer = &helpInd[0]; - AliTRDcluster *tmpcl = 0x0; + AliTRDcluster *tmpcl = NULL; for(Int_t i = 0; i < TMath::Min(fN, kMaxClustersLayer); i++){ if(!(tmpcl = *(fcliter++))){ finditer++; @@ -276,7 +275,7 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter) } *(hcliter++) = tmpcl; *(hinditer++) = *finditer; - tmpcl = 0x0; + tmpcl = NULL; *(finditer++) = 0xffff; nClStack++; } @@ -288,13 +287,17 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter) // Reset Positions array memset(fPositions, 0, sizeof(UChar_t)*kMaxRows); AliTRDcluster **cliter = &helpCL[0]; // Declare iterator running over the whole array + const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam(); //the dynamic cast in GetRecoParam is slow, so caching the pointer to it + Int_t tb(-1); for(Int_t i = 0; i < fN; i++){ // boundary check AliTRDcluster *cl = *(cliter++); UChar_t rowIndex = cl->GetPadRow(); + if(tb<0) tb=cl->GetLocalTimeBin(); // Insert Leaf - Int_t pos = FindYPosition(cl->GetY(), rowIndex, i); - if(pos == -1){ // zbin is empty; + Int_t pos = FindYPosition(cl->GetY(), rowIndex, nClStack); + if(pos == -2) continue; // zbin error; + else if(pos == -1) { // zbin is empty; Int_t upper = (rowIndex == fNRows - 1) ? nClStack : fPositions[rowIndex + 1]; memmove(fClusters + upper + 1, fClusters + upper, (sizeof(AliTRDcluster *))*(nClStack-upper)); memmove(fIndex + upper + 1, fIndex + upper, (sizeof(UInt_t))*(nClStack-upper)); @@ -317,14 +320,15 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter) fX += cl->GetX(); // Debug Streaming - if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 3){ - TTreeSRedirector &cstream = *fReconstructor->GetDebugStream(AliTRDReconstructor::kTracker); + if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 3){ + AliTRDcluster dcl(*cl); + TTreeSRedirector &cstream = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); cstream << "BuildIndices" << "Plane=" << fPlane << "Stack=" << fStack << "Sector=" << fSector << "Iter=" << iter - << "C.=" << cl + << "C.=" << &dcl << "rowIndex=" << rowIndex << "\n"; } @@ -332,8 +336,17 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter) // AliInfo("Positions"); // for(int ir=0; ir=fNRows){ // check pad row of cluster + AliDebug(1, Form("Row[%2d] outside range [0 %2d] in %02d_%d_%d.", z, fNRows, fSector, fStack, fPlane)); + return -2; + } Int_t start = fPositions[z]; // starting Position of the bin Int_t upper = (Int_t)((z != fNRows - 1) ? fPositions[z+1] : nClusters); // ending Position of the bin Int_t end = upper - 1; // ending Position of the bin @@ -411,7 +428,7 @@ Int_t AliTRDchamberTimeBin::FindNearestYCluster(Double_t y, UChar_t z) const // Int_t position = FindYPosition(y, z, fN); - if(position == -1) return position; // bin empty + if(position == -2 || position == -1) return position; // bin empty // FindYPosition always returns the left Neighbor. We don't know if the left or the right Neighbor is nearest // to the Reference y-position, so test both Int_t upper = (Int_t)((z < fNRows-1) ? fPositions[z+1] : fN); // ending Position of the bin @@ -512,7 +529,7 @@ Int_t AliTRDchamberTimeBin::SearchNearestCluster(Double_t y, Double_t z, Double_ } //_____________________________________________________________________________ -void AliTRDchamberTimeBin::BuildCond(AliTRDcluster *cl, Double_t *cond, UChar_t Layer, Double_t theta, Double_t phi) +void AliTRDchamberTimeBin::BuildCond(AliTRDcluster * const cl, Double_t *cond, UChar_t Layer, Double_t theta, Double_t phi) { // Helper function to calculate the area where to expect a cluster in THIS // layer. @@ -536,7 +553,7 @@ void AliTRDchamberTimeBin::BuildCond(AliTRDcluster *cl, Double_t *cond, UChar_t //End_Html // - if(!fReconstructor){ + if(!fkReconstructor){ AliError("Reconstructor not set."); return; } @@ -544,18 +561,18 @@ void AliTRDchamberTimeBin::BuildCond(AliTRDcluster *cl, Double_t *cond, UChar_t if(Layer == 0){ cond[0] = cl->GetY(); // center: y-Direction cond[1] = cl->GetZ(); // center: z-Direction - cond[2] = fReconstructor->GetRecoParam()->GetMaxPhi() * (cl->GetX() - GetX()) + 1.0; // deviation: y-Direction - cond[3] = fReconstructor->GetRecoParam()->GetMaxTheta() * (cl->GetX() - GetX()) + 1.0; // deviation: z-Direction + cond[2] = fkReconstructor->GetRecoParam()->GetMaxPhi() * (cl->GetX() - GetX()) + 1.0; // deviation: y-Direction + cond[3] = fkReconstructor->GetRecoParam()->GetMaxTheta() * (cl->GetX() - GetX()) + 1.0; // deviation: z-Direction } else { cond[0] = cl->GetY() + phi * (GetX() - cl->GetX()); cond[1] = cl->GetZ() + theta * (GetX() - cl->GetX()); - cond[2] = fReconstructor->GetRecoParam()->GetRoad0y() + phi; - cond[3] = fReconstructor->GetRecoParam()->GetRoad0z(); + cond[2] = fkReconstructor->GetRecoParam()->GetRoad0y() + phi; + cond[3] = fkReconstructor->GetRecoParam()->GetRoad0z(); } } //_____________________________________________________________________________ -void AliTRDchamberTimeBin::GetClusters(Double_t *cond, Int_t *index, Int_t& ncl, Int_t BufferSize) +void AliTRDchamberTimeBin::GetClusters(const Double_t * const cond, Int_t *index, Int_t& ncl, Int_t BufferSize) { // Finds all clusters situated in this layer inside a rectangle given by the center an ranges. // @@ -589,19 +606,22 @@ void AliTRDchamberTimeBin::GetClusters(Double_t *cond, Int_t *index, Int_t& ncl, PrintClusters(); AliInfo(Form("zlo[%f] zhi[%f]", zvals[0], zvals[1])); AliInfo(Form("zlo[%d] zhi[%d]", zlo, zhi));*/ - + + Double_t ylo = cond[0] - cond[2], + yhi = cond[0] + cond[2]; + //printf("CTB : ylo[%f] yhi[%f]\n", ylo, yhi); //Preordering in Direction z saves a lot of loops (boundary checked) for(UChar_t z = zlo; z <= zhi; z++){ UInt_t upper = (z < fNRows-1) ? fPositions[z+1] : fN; //AliInfo(Form("z[%d] y [%d %d]", z, fPositions[z], upper)); for(Int_t y = fPositions[z]; y < (Int_t)upper; y++){ if(ncl == BufferSize){ - AliWarning("Buffer size riched. Some clusters may be lost."); + AliDebug(1, Form("Buffer size [%d] riched. Some clusters may be lost.", BufferSize)); return; //Buffer filled } - if(fClusters[y]->GetY() > (cond[0] + cond[2])) break; // Abbortion conditions!!! - if(fClusters[y]->GetY() < (cond[0] - cond[2])) continue; // Too small + if(fClusters[y]->GetY() > yhi) break; // Abbortion conditions!!! + if(fClusters[y]->GetY() < ylo) continue; // Too small if(((Int_t)((fClusters[y]->GetZ())*1000) < (Int_t)(zvals[0]*1000)) || ((Int_t)((fClusters[y]->GetZ())*1000) > (Int_t)(zvals[1]*1000))){/*printf("exit z\n"); TODO*/ continue;} index[ncl] = y; ncl++; @@ -627,11 +647,11 @@ AliTRDcluster *AliTRDchamberTimeBin::GetNearestCluster(Double_t *cond) // successfull) by the help of the method FindNearestCluster - Double_t maxroad = fReconstructor->GetRecoParam()->GetRoad2y(); - Double_t maxroadz = fReconstructor->GetRecoParam()->GetRoad2z(); + Double_t maxroad = fkReconstructor->GetRecoParam()->GetRoad2y(); + Double_t maxroadz = fkReconstructor->GetRecoParam()->GetRoad2z(); Int_t index = SearchNearestCluster(cond[0],cond[1],maxroad,maxroadz); - AliTRDcluster *returnCluster = 0x0; + AliTRDcluster *returnCluster = NULL; if(index != -1) returnCluster = (AliTRDcluster *) fClusters[index]; return returnCluster; }