#include "AliLog.h"
-#include "AliTRDcluster.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDpadPlane.h"
#include "AliTRDchamberTimeBin.h"
#include "AliTRDrecoParam.h"
#include "AliTRDReconstructor.h"
AliTRDchamberTimeBin::AliTRDchamberTimeBin(Int_t plane, Int_t stack, Int_t sector, Double_t z0, Double_t zLength)
:TObject()
,fReconstructor(0x0)
- ,fOwner(kFALSE)
,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)
,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;
- }
+ for(AliTRDcluster **cit = &fClusters[0]; (*cit); cit++){
+ if(IsOwner()) delete (*cit);
+ (*cit) = NULL;
+ }
fN = 0;
}
AliTRDchamberTimeBin &layer = (AliTRDchamberTimeBin &)o;
layer.fReconstructor = fReconstructor;
- layer.fOwner = kFALSE;
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));
+ }
}
//_____________________________________________________________________________
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
+
+ fReconstructor = 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)
// Prints the position of each cluster in the stacklayer on the stdout
//
if(!fN) return;
- AliInfo(Form("nRows[%d] nClusters[%d]", fNRows, fN));
+ 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)));
+ }
}
class AliTRDchamberTimeBin : public TObject
{
public:
+ enum AliTRDchamberTimeBinStatus {
+ kT0 = BIT(14) // is the T0 time bin
+ ,kOwner = BIT(15) // is owner of the clusters
+ };
enum{
- kMaxClustersLayer = 150
+ kMaxClustersLayer = 150
,kMaxRows = 16
};
//AliTRDchamberTimeBin(const AliTRDpropagationLayer &layer);
AliTRDchamberTimeBin(const AliTRDchamberTimeBin &layer);
~AliTRDchamberTimeBin();
- //AliTRDchamberTimeBin &operator=(const AliTRDpropagationLayer &myLayer);
- operator Int_t() const { return fN; }
- AliTRDchamberTimeBin &operator=(const AliTRDchamberTimeBin &myLayer);
- AliTRDcluster *operator[](const Int_t i) const {
+ operator Int_t() const { return fN; }
+ AliTRDchamberTimeBin&
+ operator=(const AliTRDchamberTimeBin &myLayer);
+ AliTRDcluster* operator[](const Int_t i) const {
return ((i < fN) && (i >= 0)) ? fClusters[i] : 0x0;
}
+ void Bootstrap(const AliTRDReconstructor *rec, Int_t det);
void BuildIndices(Int_t iter = 0);
void BuildCond(AliTRDcluster *cl, Double_t *cond, UChar_t Layer, Double_t theta=0., Double_t phi=0.);
void Clear(const Option_t *opt = 0x0);
Int_t GetSector() const { return fSector; }
void InsertCluster(AliTRDcluster *c, UInt_t index);
- Bool_t IsT0() const {return TestBit(1);}
-
+ Bool_t IsT0() const {return TestBit(kT0);}
+ Bool_t IsOwner() const {return TestBit(kOwner);}
+
void Print(Option_t *opt=0x0) const;
Int_t SearchNearestCluster(Double_t y, Double_t z, Double_t Roady, Double_t Roadz) const;
void SetRange(Float_t z0, Float_t zLength);
void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
void SetStack(Int_t stack){ fStack = stack; }
void SetSector(Int_t sector){ fSector = sector; }
- void SetOwner(Bool_t own = kTRUE) {fOwner = own;}
- void SetT0(Bool_t set=kTRUE) {SetBit(1, set);}
+ void SetOwner(Bool_t copy=kTRUE);
+ void SetT0(Bool_t set=kTRUE) {SetBit(kT0, set);}
void SetX(Double_t x) {fX = x;}
private:
void Copy(TObject &o) const;
Int_t FindNearestYCluster(Double_t y, UChar_t z) const;
private:
- const AliTRDReconstructor *fReconstructor; //
- Bool_t fOwner; // owner of the clusters
- Char_t fPlane; // Plane number
- Char_t fStack; // stack number in supermodule
- Char_t fSector; // Sector mumber
- Char_t fNRows; // number of pad rows in the chamber
- UChar_t fPositions[kMaxRows]; // starting index of clusters in pad row
- Int_t fN; // number of clusters
+ const AliTRDReconstructor *fReconstructor; //!
+ Char_t fPlane; //! Plane number
+ Char_t fStack; //! stack number in supermodule
+ Char_t fSector; //! Sector mumber
+ Char_t fNRows; //! number of pad rows in the chamber
+ UChar_t fPositions[kMaxRows]; //! starting index of clusters in pad row
+ Int_t fN; //! number of clusters
AliTRDcluster *fClusters[kMaxClustersLayer]; //Array of pointers to clusters
- UInt_t fIndex[kMaxClustersLayer]; //Array of cluster indexes
- Double_t fX; // radial position of tb
+ UInt_t fIndex[kMaxClustersLayer]; //!Array of cluster indexes
+ Double_t fX; //! radial position of tb
// obsolete !!
Double_t fZ0; // starting position of the layer in Z direction
};
-
#endif // ALITRDCHAMBERTIMEBIN_H
//_______________________________________________________
Int_t AliTRDtrackingChamber::GetNClusters() const
{
+// Basic loop method
// Returns number of clusters in chamber
//
Int_t n = 0;
return n;
}
+//_______________________________________________________
+void AliTRDtrackingChamber::Bootstrap(const AliTRDReconstructor *rec)
+{
+// Basic loop method
+// Bootstrap each time bin
+//
+ AliTRDchamberTimeBin *jtb = &fTB[0];
+ for(Int_t itb=0; itb<kNTimeBins; itb++, ++jtb){
+ (*jtb).Bootstrap(rec, fDetector);
+ }
+}
+
+//_______________________________________________________
+void AliTRDtrackingChamber::SetOwner()
+{
+// Basic loop method
+// Set ownership in time bins
+//
+ AliTRDchamberTimeBin *jtb = &fTB[0];
+ for(Int_t itb=0; itb<kNTimeBins; itb++, ++jtb){
+ if(!(Int_t(*jtb))) continue;
+ (*jtb).SetOwner();
+ }
+}
+
//_______________________________________________________
Double_t AliTRDtrackingChamber::GetQuality()
{
new(fakeLayer) AliTRDchamberTimeBin(layer, stack, sector, z0, zl);
fakeLayer->SetReconstructor(rec);
- AliTRDcluster *cluster = 0x0;
+ fakeLayer->SetNRows(nRows);
+ fakeLayer->SetOwner(kFALSE);
if(nCandidates){
UInt_t fakeIndex = 0;
for(Int_t ican = 0; ican < nCandidates; ican++){
pos[2] = z/n;
sig[0] = .02;
sig[1] = sigcands[ican];
- cluster = new AliTRDcluster(fDetector, 0., pos, sig, 0x0, 3, signal, col, row, 0, 0, 0., 0);
- fakeLayer->InsertCluster(cluster, fakeIndex++);
+ fakeLayer->InsertCluster(new AliTRDcluster(fDetector, 0., pos, sig, 0x0, 3, signal, col, row, 0, 0, 0., 0), fakeIndex++);
}
}
- fakeLayer->SetNRows(nRows);
- fakeLayer->SetOwner();
fakeLayer->BuildIndices();
- //fakeLayer->PrintClusters();
+ //fakeLayer->Print();
if(rec->GetStreamLevel(AliTRDReconstructor::kTracker) >= 3){
//TMatrixD hist(nRows, nCols);
AliTRDtrackingChamber();
virtual ~AliTRDtrackingChamber(){}
+ void Bootstrap(const AliTRDReconstructor *rec);
Bool_t Build(AliTRDgeometry *geo, const AliTRDCalDet *cal, Bool_t hlt = kFALSE);
void Clear(const Option_t *opt = 0x0);
Int_t GetDetector() const {return fDetector;}
void Print(Option_t *opt = 0x0) const;
void SetDetector(Int_t det) { fDetector = det;}
+ void SetOwner();
private:
Int_t fDetector; // detector number