Skip to content

Commit

Permalink
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
FriederikeBock committed Jun 27, 2014
2 parents d285838 + 50672ff commit 258b2b8
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 93 deletions.
96 changes: 96 additions & 0 deletions ITS/UPGRADE/AliITSUClusterPix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ AliITSUClusterPix::AliITSUClusterPix()
: fCharge(0)
, fRecoInfo(0)
, fNxNzN(0)
#ifdef _ClusterTopology_
,fPatternNRows(0)
,fPatternNCols(0)
,fPatternMinRow(0)
,fPatternMinCol(0)
#endif
{
// default constructor
#ifdef _ClusterTopology_
memset(fPattern,0,kMaxPatternBytes*sizeof(UChar_t));
#endif

}

//_____________________________________________________
Expand All @@ -32,8 +42,17 @@ AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
,fCharge(cluster.fCharge)
,fRecoInfo(cluster.fRecoInfo)
,fNxNzN(cluster.fNxNzN)
#ifdef _ClusterTopology_
,fPatternNRows(cluster.fPatternNRows)
,fPatternNCols(cluster.fPatternNCols)
,fPatternMinRow(cluster.fPatternMinRow)
,fPatternMinCol(cluster.fPatternMinCol)
#endif
{
// copy constructor
#ifdef _ClusterTopology_
memcpy(fPattern,cluster.fPattern,kMaxPatternBytes*sizeof(UChar_t));
#endif
}

//______________________________________________________________________________
Expand All @@ -44,6 +63,15 @@ AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster
fNxNzN = cluster.fNxNzN;
fCharge = cluster.fCharge;
fRecoInfo = cluster.fRecoInfo;
//
#ifdef _ClusterTopology_
memcpy(fPattern,cluster.fPattern,kMaxPatternBytes*sizeof(UChar_t));
fPatternNRows = cluster.fPatternNRows;
fPatternNCols = cluster.fPatternNCols;
fPatternMinRow = cluster.fPatternMinRow;
fPatternMinCol = cluster.fPatternMinCol;
#endif
//
TObject::operator=(cluster);
AliCluster::operator=(cluster);
return *this;
Expand Down Expand Up @@ -85,8 +113,76 @@ void AliITSUClusterPix::Print(Option_t* option) const
if (TestBit(kSplit)) printf(" Spl");
printf("\n");
//
#ifdef _ClusterTopology_
if (str.Contains("p")) { // print pattern
int nr = GetPatternRowSpan();
int nc = GetPatternColSpan();
printf("Pattern: %d rows from %d",nr,fPatternMinRow);
if (IsPatternRowsTruncated()) printf("(truncated)");
printf(", %d columns from %d",nc,fPatternMinCol);
if (IsPatternColsTruncated()) printf("(truncated)");
printf("\n");
for (int ir=0;ir<nr;ir++) {
for (int ic=0;ic<nc;ic++) printf("%c",TestPixel(ir,ic) ? '+':'-');
printf("\n");
}
}
#endif
//
}

#ifdef _ClusterTopology_
//______________________________________________________________________________
void AliITSUClusterPix::ResetPattern()
{
// reset pixels pattern
memset(fPattern,0,kMaxPatternBytes*sizeof(UChar_t));
}

//______________________________________________________________________________
Bool_t AliITSUClusterPix::TestPixel(UShort_t row,UShort_t col) const
{
// test if pixel at relative row,col is fired
int nbits = row*GetPatternColSpan()+col;
if (nbits>=kMaxPatternBits) return kFALSE;
int bytn = nbits>>3; // 1/8
int bitn = nbits%8;
return (fPattern[bytn]&(0x1<<bitn))!=0;
//
}

//______________________________________________________________________________
void AliITSUClusterPix::SetPixel(UShort_t row,UShort_t col, Bool_t fired)
{
// test if pixel at relative row,col is fired
int nbits = row*GetPatternColSpan()+col;
if (nbits>=kMaxPatternBits) return;
int bytn = nbits>>3; // 1/8
int bitn = nbits%8;
if (nbits>=kMaxPatternBits) exit(1);
if (fired) fPattern[bytn] |= (0x1<<bitn);
else fPattern[bytn] &= (0xff ^ (0x1<<bitn));
//
}

//______________________________________________________________________________
void AliITSUClusterPix::SetPatternRowSpan(UShort_t nr, Bool_t truncated)
{
// set pattern span in rows, flag if truncated
fPatternNRows = kSpanMask&nr;
if (truncated) fPatternNRows |= kTruncateMask;
}

//______________________________________________________________________________
void AliITSUClusterPix::SetPatternColSpan(UShort_t nc, Bool_t truncated)
{
// set pattern span in columns, flag if truncated
fPatternNCols = kSpanMask&nc;
if (truncated) fPatternNCols |= kTruncateMask;
}

#endif

//______________________________________________________________________________
Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
{
Expand Down
38 changes: 36 additions & 2 deletions ITS/UPGRADE/AliITSUClusterPix.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
#include "AliCluster.h"
#include <TMath.h>

// uncomment this to have cluster topology in stored
//#define _ClusterTopology_

#define CLUSTER_VERSION 2

class TGeoHMatrix;
class AliITSUGeomTGeo;



class AliITSUClusterPix : public AliCluster
{
public:
Expand All @@ -24,7 +30,10 @@ class AliITSUClusterPix : public AliCluster
,kSortIdTrkYZ = BIT(1) // sort according to ID, then Y,Z of tracking frame
,kSortBits = kSortIdLocXZ|kSortIdTrkYZ
};

#ifdef _ClusterTopology_
enum {kMaxPatternBits=32*16, kMaxPatternBytes=kMaxPatternBits/8,
kSpanMask=0x7fff,kTruncateMask=0x8000};
#endif
public:
AliITSUClusterPix();
AliITSUClusterPix(const AliITSUClusterPix& cluster);
Expand Down Expand Up @@ -86,6 +95,21 @@ class AliITSUClusterPix : public AliCluster
static SortMode_t SortModeIdTrkYZ() {return kSortIdTrkYZ;}
static SortMode_t SortModeIdLocXZ() {return kSortIdLocXZ;}
//
#ifdef _ClusterTopology_
Int_t GetPatternRowSpan() const {return fPatternNRows&kSpanMask;}
Int_t GetPatternColSpan() const {return fPatternNCols&kSpanMask;}
Bool_t IsPatternRowsTruncated() const {return fPatternNRows&kTruncateMask;}
Bool_t IsPatternColsTruncated() const {return fPatternNRows&kTruncateMask;}
Bool_t IsPatternTruncated() const {return IsPatternRowsTruncated()||IsPatternColsTruncated();}
void SetPatternRowSpan(UShort_t nr, Bool_t truncated);
void SetPatternColSpan(UShort_t nc, Bool_t truncated);
void SetPatternMinRow(UShort_t row) {fPatternMinRow = row;}
void SetPatternMinCol(UShort_t col) {fPatternMinCol = col;}
void ResetPattern();
Bool_t TestPixel(UShort_t row,UShort_t col) const;
void SetPixel(UShort_t row,UShort_t col, Bool_t fired=kTRUE);
#endif
//
protected:
//
UShort_t fCharge; // charge (for MC studies only)
Expand All @@ -95,7 +119,17 @@ class AliITSUClusterPix : public AliCluster
static UInt_t fgMode; //! general mode (sorting mode etc)
static AliITSUGeomTGeo* fgGeom; //! pointer on the geometry data

ClassDef(AliITSUClusterPix,2)
#ifdef _ClusterTopology_
UShort_t fPatternNRows; // pattern span in rows
UShort_t fPatternNCols; // pattern span in columns
UShort_t fPatternMinRow; // pattern start row
UShort_t fPatternMinCol; // pattern start column
UChar_t fPattern[kMaxPatternBytes]; // cluster topology
//
ClassDef(AliITSUClusterPix,CLUSTER_VERSION+1)
#else
ClassDef(AliITSUClusterPix,CLUSTER_VERSION)
#endif
};

//______________________________________________________
Expand Down
107 changes: 47 additions & 60 deletions ITS/UPGRADE/AliITSUClusterizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <TParticle.h>
#include <TMath.h>
#include "AliRun.h"
#include "AliLog.h"
#include "AliMC.h"
#include <AliITSUSegmentationPix.h>
#include "AliITSUClusterizer.h"
#include "AliITSUClusterPix.h"
#include "AliITSUGeomTGeo.h"
#include "AliITSUSegmentationPix.h"
#include "AliITSdigit.h"
Expand Down Expand Up @@ -39,8 +39,6 @@ AliITSUClusterizer::AliITSUClusterizer(Int_t initNRow)
,fPartFreelistBptr(0)
,fCandFreelistBptr(0)
#ifdef _ClusterTopology_
,fTreeTopology(0)
,fFileTopology(0)
,fTopology(0)
,fMinCol(0)
,fMinRow(0)
Expand All @@ -49,6 +47,14 @@ AliITSUClusterizer::AliITSUClusterizer(Int_t initNRow)
SetUniqueID(0);
// c-tor
SetNRow(initNRow);
//
#ifdef _ClusterTopology_
AliInfo("*********************************************************************");
AliInfo("ATTENTION: YOU ARE RUNNING IN SPECIAL MODE OF STORING CLUSTER PATTERN");
AliInfo("*********************************************************************");
#endif //_ClusterTopology_

//
}

//______________________________________________________________________________
Expand Down Expand Up @@ -95,9 +101,6 @@ AliITSUClusterizer::~AliITSUClusterizer()
delete[] fPartFreelistBptr;
delete[] fCandFreelistBptr;
//
#ifdef _ClusterTopology_
SaveTopologyTree();
#endif //_ClusterTopology_
}

//______________________________________________________________________________
Expand Down Expand Up @@ -235,7 +238,7 @@ void AliITSUClusterizer::Transform(AliITSUClusterPix *cluster,AliITSUClusterizer
// printf("mod %d: (%.4lf,%.4lf)cm\n",fVolID,x,z);
//
#ifdef _ClusterTopology_
FillClusterTopology(cand);
FillClusterTopology(cand,cluster);
#endif //_ClusterTopology_
//
}
Expand Down Expand Up @@ -418,68 +421,52 @@ void AliITSUClusterizer::CheckLabels()
#ifdef _ClusterTopology_
//
//______________________________________________________________________
void AliITSUClusterizer::FillClusterTopology(AliITSUClusterizerClusterCand *cand)
void AliITSUClusterizer::FillClusterTopology(const AliITSUClusterizerClusterCand *cand, AliITSUClusterPix* cl) const
{
// fill special tree with cluster topology bit pattern
// fill cluster topology bit pattern
//
enum {kMaxColSpan=30,kMaxRowSpan=30};
//
Int_t mnCol=999999,mxCol=0,mnRow=999999,mxRow=0;
UShort_t mnCol=0xffff,mxCol=0,mnRow=0xffff,mxRow=0;
for (AliITSUClusterizerClusterDigit *idigit=cand->fFirstDigit;idigit;idigit=idigit->fNext) {
AliITSdigit* dig = idigit->fDigit;
if (mnCol>dig->GetCoord1()) mnCol = dig->GetCoord1();
if (mxCol<dig->GetCoord1()) mxCol = dig->GetCoord1();
if (mnRow>dig->GetCoord2()) mnRow = dig->GetCoord2();
if (mxRow<dig->GetCoord2()) mxRow = dig->GetCoord2();
if (mnCol>dig->GetCoord1()) mnCol = (UShort_t)dig->GetCoord1();
if (mxCol<dig->GetCoord1()) mxCol = (UShort_t)dig->GetCoord1();
if (mnRow>dig->GetCoord2()) mnRow = (UShort_t)dig->GetCoord2();
if (mxRow<dig->GetCoord2()) mxRow = (UShort_t)dig->GetCoord2();
}
int nColSpan = mxCol-mnCol+1;
int nRowSpan = mxRow-mnRow+1;
if (nColSpan<kMaxColSpan && nRowSpan<kMaxRowSpan) {
fTopology.Clear();
fTopology.SetBitNumber(nColSpan*nRowSpan-1,kFALSE); // set the size
fTopology.SetUniqueID( (nRowSpan<<8) + nColSpan );
for (AliITSUClusterizerClusterDigit *idigit=cand->fFirstDigit;idigit;idigit=idigit->fNext) {
AliITSdigit* dig = idigit->fDigit;
fTopology.SetBitNumber( (dig->GetCoord2()-mnRow)*nColSpan + (dig->GetCoord1()-mnCol) );
UShort_t nColSpan = UShort_t(mxCol-mnCol+1);
UShort_t nRowSpan = UShort_t(mxRow-mnRow+1);
UShort_t nColSpanW = nColSpan;
UShort_t nRowSpanW = nRowSpan;
if (nColSpan*nRowSpan>AliITSUClusterPix::kMaxPatternBits) { // need to store partial info
// will crtail largest dimension
if (nColSpan>nRowSpan) {
if ( (nColSpanW=AliITSUClusterPix::kMaxPatternBits/nRowSpan)==0 ) {
nColSpanW = 1;
nRowSpanW = AliITSUClusterPix::kMaxPatternBits;
}
}
else {
if ( (nRowSpanW=AliITSUClusterPix::kMaxPatternBits/nColSpan)==0 ) {
nRowSpanW = 1;
nColSpanW = AliITSUClusterPix::kMaxPatternBits;
}
}
if (!fTreeTopology) InitTopologyTree();
AliInfo(Form("Fill Topology, lr %d",fLayerID));
fMinCol = mnCol;
fMinRow = mnRow;
fTreeTopology->Fill();
}
cl->ResetPattern();
//
cl->SetPatternRowSpan(nRowSpanW,nRowSpanW<nRowSpan);
cl->SetPatternColSpan(nColSpanW,nColSpanW<nColSpan);
cl->SetPatternMinRow(mnRow);
cl->SetPatternMinCol(mnCol);
//
for (AliITSUClusterizerClusterDigit *idigit=cand->fFirstDigit;idigit;idigit=idigit->fNext) {
AliITSdigit* dig = idigit->fDigit;
UInt_t ir = dig->GetCoord2()-mnRow;
UInt_t ic = dig->GetCoord1()-mnCol;
if (ir<nRowSpanW && ic<nColSpanW) cl->SetPixel(ir,ic);
}
//
}

//______________________________________________________________________
void AliITSUClusterizer::InitTopologyTree()
{
// create output tree for the topology stydy
if (fFileTopology || fTreeTopology) AliFatal("Topology structures are already created");
TDirectory* cdr = gDirectory;
fFileTopology = TFile::Open("clusterTopology.root","recreate");
fFileTopology->cd();
fTreeTopology = new TTree("clTop","ClusterTopology");
fTreeTopology->Branch("tp","TBits",&fTopology);
fTreeTopology->Branch("volID",&fVolID);
fTreeTopology->Branch("mnCol",&fMinCol);
fTreeTopology->Branch("mnRow",&fMinRow);
cdr->cd();
}

//______________________________________________________________________
void AliITSUClusterizer::SaveTopologyTree()
{
// write output tree for the topology stydy
AliInfo("Storing cluster topology tree");
if (!fFileTopology || !fTreeTopology) {AliError("Topology structures are not created"); return;}
fFileTopology->cd();
fTreeTopology->Write();
delete fTreeTopology;
fFileTopology->Close();
delete fFileTopology;
fTreeTopology = 0;
fFileTopology = 0;
}

#endif //_ClusterTopology_
Loading

0 comments on commit 258b2b8

Please sign in to comment.