///////////////////////////////////////////////////////////////////////////////
#include <TObject.h>
-#include <TROOT.h>
#include <TMath.h>
-#include <TStopwatch.h>
#include <TTreeStream.h>
#include "AliLog.h"
-
#include "AliTRDcluster.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDpadPlane.h"
#include "AliTRDchamberTimeBin.h"
#include "AliTRDrecoParam.h"
#include "AliTRDReconstructor.h"
-#include "AliTRDtrackerV1.h"
-
ClassImp(AliTRDchamberTimeBin)
//_____________________________________________________________________________
AliTRDchamberTimeBin::AliTRDchamberTimeBin(Int_t plane, Int_t stack, Int_t sector, Double_t z0, Double_t zLength)
:TObject()
- ,fReconstructor(0x0)
- ,fOwner(kFALSE)
+ ,fkReconstructor(NULL)
,fPlane(plane)
,fStack(stack)
,fSector(sector)
//
// Default constructor (Only provided to use AliTRDchamberTimeBin with arrays)
//
-
+ SetBit(kT0, kFALSE);
+ SetBit(kOwner, kFALSE);
memset(fPositions, 1, kMaxRows*sizeof(UChar_t));
memset(fClusters, 0, kMaxClustersLayer*sizeof(AliTRDcluster*));
memset(fIndex, 1, kMaxClustersLayer*sizeof(UInt_t));
}
-// //_____________________________________________________________________________
-// AliTRDchamberTimeBin::AliTRDchamberTimeBin(const AliTRDpropagationLayer &layer, Double_t
-// z0, Double_t zLength, UChar_t stackNr):
-// TObject()
-// ,fOwner(kFALSE)
-// ,fPlane(0xff)
-// ,fStack(0xff)
-// ,fSector(0xff)
-// ,fNRows(kMaxRows)
-// ,fN(0)
-// ,fX(0.)
-// ,fZ0(z0)
-// ,fZLength(zLength)
-// {
-// // Standard constructor.
-// // Initialize also the underlying AliTRDpropagationLayer using the copy constructor.
-//
-// SetT0(layer.IsT0());
-// for(int i=0; i<kMaxRows; i++) fPositions[i] = 0xff;
-// for(int ic=0; ic<kMaxClustersLayer; ic++){
-// fClusters[ic] = 0x0;
-// fIndex[ic] = 0xffff;
-// }
-// }
-//
-// //_____________________________________________________________________________
-// AliTRDchamberTimeBin::AliTRDchamberTimeBin(const AliTRDpropagationLayer &layer):
-// TObject()
-// ,fOwner(kFALSE)
-// ,fPlane(0xff)
-// ,fStack(0xff)
-// ,fSector(0xff)
-// ,fNRows(kMaxRows)
-// ,fN(0)
-// ,fX(0.)
-// ,fZ0(0)
-// ,fZLength(0)
-// {
-// // Standard constructor using only AliTRDpropagationLayer.
-//
-// SetT0(layer.IsT0());
-// for(int i=0; i<kMaxRows; i++) fPositions[i] = 0xff;
-// for(int ic=0; ic<kMaxClustersLayer; ic++){
-// fClusters[ic] = 0x0;
-// fIndex[ic] = 0xffff;
-// }
-// }
-// //_____________________________________________________________________________
-// AliTRDchamberTimeBin &AliTRDchamberTimeBin::operator=(const AliTRDpropagationLayer &layer)
-// {
-// // Assignment operator from an AliTRDpropagationLayer
-//
-// if (this != &layer) layer.Copy(*this);
-// return *this;
-// }
-//
//_____________________________________________________________________________
AliTRDchamberTimeBin::AliTRDchamberTimeBin(const AliTRDchamberTimeBin &layer):
TObject()
- ,fReconstructor(layer.fReconstructor)
- ,fOwner(layer.fOwner)
+ ,fkReconstructor(layer.fkReconstructor)
,fPlane(layer.fPlane)
,fStack(layer.fStack)
,fSector(layer.fSector)
,fZ0(layer.fZ0)
,fZLength(layer.fZLength)
{
-// Copy Constructor (performs a deep copy)
+// Copy Constructor
- SetT0(layer.IsT0());
+ SetBit(kT0, layer.IsT0());
+ SetBit(kOwner, kFALSE);
for(int i=0; i<kMaxRows; i++) fPositions[i] = layer.fPositions[i];
- memcpy(&fClusters[0], &layer.fClusters[0], kMaxClustersLayer*sizeof(UChar_t));
+ memcpy(&fClusters[0], &layer.fClusters[0], kMaxClustersLayer*sizeof(AliTRDcluster*));
memcpy(&fIndex[0], &layer.fIndex[0], kMaxClustersLayer*sizeof(UInt_t));
//_____________________________________________________________________________
void AliTRDchamberTimeBin::Clear(const Option_t *)
{
- for (Int_t i = 0; i < fN; i++){
- if(!fClusters[i]) continue;
- if(fOwner) delete fClusters[i];
- fClusters[i] = NULL;
- }
+ // Reset the Chamber Timebin
+ if(IsOwner())
+ for(Int_t it = 0; it<kMaxClustersLayer; it++)
+ delete fClusters[it];
+ memset(fClusters,0,kMaxClustersLayer*sizeof(fClusters[0]));
fN = 0;
}
// Copy method. Performs a deep copy of all data from this object to object o.
AliTRDchamberTimeBin &layer = (AliTRDchamberTimeBin &)o;
- layer.fReconstructor = fReconstructor;
- layer.fOwner = kFALSE;
+ layer.fkReconstructor = fkReconstructor;
layer.fPlane = fPlane;
layer.fStack = fStack;
layer.fSector = fSector;
layer.fZ0 = fZ0;
layer.fZLength = fZLength;
layer.SetT0(IsT0());
-
- for(int i = 0; i < kMaxRows; i++) layer.fPositions[i] = 0;
+ layer.SetBit(kOwner, kFALSE);
for(int i=0; i<kMaxRows; i++) layer.fPositions[i] = fPositions[i];
- memcpy(&layer.fClusters[0], &fClusters[0], kMaxClustersLayer*sizeof(UChar_t));
+ memcpy(&layer.fClusters[0], &fClusters[0], kMaxClustersLayer*sizeof(AliTRDcluster*));
memcpy(&layer.fIndex[0], &fIndex[0], kMaxClustersLayer*sizeof(UInt_t));
TObject::Copy(layer); // copies everything into layer
AliTRDchamberTimeBin::~AliTRDchamberTimeBin()
{
// Destructor
- if(fOwner) for(int ic=0; ic<fN; ic++) delete fClusters[ic];
+ if(IsOwner()){
+ for(AliTRDcluster **cit = &fClusters[0]; (*cit); cit++) delete (*cit);
+ }
+}
+
+//_____________________________________________________________________________
+void AliTRDchamberTimeBin::SetOwner(Bool_t copy)
+{
+// Sets the ownership of the clusters to this
+// If option "copy" is kTRUE [default] the clusters
+// are also copied otherwise only the ownership bit
+// is flipped.
+
+ SetBit(kOwner, kTRUE);
+ if(!copy) return;
+ for(AliTRDcluster **cit = &fClusters[0]; (*cit); ++cit){
+ (*cit) = new AliTRDcluster(*(*cit));
+ }
}
//_____________________________________________________________________________
-void AliTRDchamberTimeBin::SetRange(const Float_t z0, const Float_t zLength)
+void AliTRDchamberTimeBin::SetRange(Float_t z0, Float_t zLength)
{
// Sets the range in z-direction
//
fIndex[i] = index;
fClusters[i] = c;
fN++;
+}
-}
-
+//___________________________________________________
+void AliTRDchamberTimeBin::Bootstrap(const AliTRDReconstructor *rec, Int_t det)
+{
+// Reinitialize all data members from the clusters array
+// It has to be used after reading from disk
+
+ fkReconstructor = rec;
+ fPlane = AliTRDgeometry::GetLayer(det);
+ fStack = AliTRDgeometry::GetStack(det);
+ fSector = AliTRDgeometry::GetSector(det);
+ AliTRDgeometry g;
+ fNRows = g.GetPadPlane(fPlane, fStack)->GetNrows();
+ fN = 0;
+ for(AliTRDcluster **cit = &fClusters[0]; (*cit); cit++) fN++;
+ BuildIndices();
+}
//_____________________________________________________________________________
void AliTRDchamberTimeBin::BuildIndices(Int_t iter)
// Select clusters that belong to the Stack
Int_t nClStack = 0; // Internal counter
for(Int_t i = 0; i < fN; i++){
- if(fClusters[i]->IsUsed()){
- 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){
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++;
}
*(hcliter++) = tmpcl;
*(hinditer++) = *finditer;
- tmpcl = 0x0;
+ tmpcl = NULL;
*(finditer++) = 0xffff;
nClStack++;
}
// 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
for(Int_t i = 0; i < fN; i++){
// boundary check
AliTRDcluster *cl = *(cliter++);
fX += cl->GetX();
// Debug Streaming
- if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 3){
- TTreeSRedirector &cstream = *AliTRDtrackerV1::DebugStreamer();
+ 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";
}
}
//_____________________________________________________________________________
-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.
//End_Html
//
- if(!fReconstructor){
+ if(!fkReconstructor){
AliError("Reconstructor not set.");
return;
}
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.
//
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++;
// 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;
}
//_____________________________________________________________________________
-void AliTRDchamberTimeBin::PrintClusters() const
+void AliTRDchamberTimeBin::Print(Option_t *) const
{
// Prints the position of each cluster in the stacklayer on the stdout
//
- printf("\nnRows = %d\n", fNRows);
- printf("Z0 = %f\n", fZ0);
- printf("Z1 = %f\n", fZ0+fZLength);
- printf("clusters in AliTRDchamberTimeBin %d\n", fN);
- for(Int_t i = 0; i < fN; i++){
- printf("AliTRDchamberTimeBin: index=%i, Cluster: X = %3.3f [%d] Y = %3.3f [%d] Z = %3.3f [%d]\n", i, fClusters[i]->GetX(), fClusters[i]->GetLocalTimeBin(), fClusters[i]->GetY(), fClusters[i]->GetPadCol(), fClusters[i]->GetZ(), fClusters[i]->GetPadRow());
- if(fClusters[i]->IsUsed()) printf("cluster allready used. rejected in search algorithm\n");
+ if(!fN) return;
+ AliInfo(Form("Layer[%d] Stack[%d] Sector[%2d] nRows[%2d]", fPlane, fStack, fSector, fNRows));
+ AliInfo(Form("Z0[%7.3f] Z1[%7.3f]", fZ0, fZ0+fZLength));
+ AliTRDcluster* const* icl = &fClusters[0];
+ for(Int_t jcl = 0; jcl < fN; jcl++, icl++){
+ AliInfo(Form("%2d X[%7.3f] Y[%7.3f] Z[%7.3f] tb[%2d] col[%3d] row[%2d] used[%s]", jcl, (*icl)->GetX(), (*icl)->GetY(), (*icl)->GetZ(), (*icl)->GetLocalTimeBin(), (*icl)->GetPadCol(), (*icl)->GetPadRow(),
+ (*icl)->IsUsed() ? "y" : "n"));
+ }
+ Int_t irow = 0;
+ for(UChar_t const* pos = &fPositions[0]; irow<fNRows; pos++, irow++){
+ if((*pos) != 0xff) AliInfo(Form("r[%2d] pos[%d]", irow, (*pos)));
}
}