X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSClusterFinder.cxx;h=107adbc9787201f9edc2b5c7f9ab4387794cc777;hb=909eee575ce9f77645113230cc0acd685d40bc71;hp=82155b7674ab5deb94fd78f9d4ac4fc43c4d3e28;hpb=9355b256f4236cc608310e428e01f6134cd6dc70;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSClusterFinder.cxx b/ITS/AliITSClusterFinder.cxx index 82155b7674a..107adbc9787 100644 --- a/ITS/AliITSClusterFinder.cxx +++ b/ITS/AliITSClusterFinder.cxx @@ -12,118 +12,453 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ +//////////////////////////////////////////////////////////////////////////// +// // +// Base Class used to find // +// the reconstructed points for ITS // +// See also AliITSClusterFinderSPD, AliITSClusterFinderSDD, // +// AliITSClusterFinderSDD AliITSClusterFinderV2 // +//////////////////////////////////////////////////////////////////////////// -#include "AliITSClusterFinder.h" #include "AliRun.h" -#include "AliITS.h" +#include "AliITSClusterFinder.h" +#include "AliITSRecPoint.h" +#include "AliITSdigit.h" +#include "AliITSDetTypeRec.h" +#include "AliITSMap.h" +#include "AliITSgeomTGeo.h" +#include +#include "AliMC.h" + +ClassImp(AliITSClusterFinder) -//---------------------------------------------------------- +extern AliRun *gAlice; -//---------------------------------------------------------- +//---------------------------------------------------------------------- +AliITSClusterFinder::AliITSClusterFinder(): +TObject(), +fModule(0), +fDigits(0), +fNdigits(0), +fDetTypeRec(0), +fClusters(0), +fMap(0), +fNPeaks(-1), +fNModules(AliITSgeomTGeo::GetNModules()), +fEvent(0){ + // default cluster finder + // Input: + // none. + // Output: + // none. + // Return: + // A default constructed AliITSCulsterFinder +} +//---------------------------------------------------------------------- +AliITSClusterFinder::AliITSClusterFinder(AliITSDetTypeRec* dettyp): +TObject(), +fModule(0), +fDigits(0), +fNdigits(0), +fDetTypeRec(dettyp), +fClusters(0), +fMap(0), +fNPeaks(-1), +fNModules(AliITSgeomTGeo::GetNModules()), +fEvent(0){ + // default cluster finder + // Standard constructor for cluster finder + // Input: + // AliITSsegmentation *seg The segmentation class to be used + // AliITSresponse *res The response class to be used + // Output: + // none. + // Return: + // A Standard constructed AliITSCulsterFinder -ClassImp(AliITSClusterFinder) +} +//---------------------------------------------------------------------- +AliITSClusterFinder::AliITSClusterFinder(AliITSDetTypeRec* dettyp, + TClonesArray *digits): +TObject(), +fModule(0), +fDigits(digits), +fNdigits(0), +fDetTypeRec(dettyp), +fClusters(0), +fMap(0), +fNPeaks(-1), +fNModules(AliITSgeomTGeo::GetNModules()), +fEvent(0){ + // default cluster finder + // Standard + cluster finder constructor + // Input: + // AliITSsegmentation *seg The segmentation class to be used + // AliITSresponse *res The response class to be used + // TClonesArray *digits Array of digits to be used + // Output: + // none. + // Return: + // A Standard constructed AliITSCulsterFinder -AliITSClusterFinder::AliITSClusterFinder -(AliITSsegmentation *seg, AliITSresponse *response, TClonesArray *digits) -{ - // cluster finder - fSegmentation=seg; - fResponse=response; - fMap = 0; - - fDigits=digits; fNdigits = fDigits->GetEntriesFast(); +} + +//______________________________________________________________________ +AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : TObject(source), +fModule(source.fModule), +fDigits(), +fNdigits(source.fNdigits), +fDetTypeRec(), +fClusters(), +fMap(), +fNPeaks(source.fNPeaks), +fNModules(source.fNModules), +fEvent(source.fEvent) { + // Copy constructor + // Copies are not allowed. The method is protected to avoid misuse. + AliError("Copy constructor not allowed\n"); +} + + +//______________________________________________________________________ +//AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder& /* source */){ + // Assignment operator + // Assignment is not allowed. The method is protected to avoid misuse. +// Fatal("= operator","Assignment operator not allowed\n"); +// return *this; +//} - fNRawClusters=0; +//---------------------------------------------------------------------- +AliITSClusterFinder::~AliITSClusterFinder(){ + // destructor cluster finder + // Input: + // none. + // Output: + // none. + // Return: + // none. - SetNperMax(); - SetClusterSize(); - SetDeclusterFlag(); + if(fMap) {delete fMap;} + // Zero local pointers. Other classes own these pointers. + fMap = 0; + fDigits = 0; + fNdigits = 0; + fNPeaks = 0; + fDetTypeRec = 0; - fNPeaks=-1; } +//__________________________________________________________________________ +void AliITSClusterFinder::InitGeometry(){ + // + // Initialisation of ITS geometry + // + Int_t mmax=AliITSgeomTGeo::GetNModules(); + for (Int_t m=0; mGetEntriesFast()<=0) return kFALSE; + // can not be a digit with first element or elements out or range + if(i<=0 || i>=digs->GetEntriesFast()) return kFALSE; - fNPeaks=-1; + for(j=0;j<4;j++){n[j] = -1;nei[j]=kFALSE;} + ix = ((AliITSdigit*)(digs->At(i)))->GetCoord1(); + iz = ((AliITSdigit*)(digs->At(i)))->GetCoord2(); + for(j=0;jAt(j)))->GetCoord1(); + jz = ((AliITSdigit*)(digs->At(j)))->GetCoord2(); + if(jx+1==ix && jz ==iz){n[0] = j;nei[0] = kTRUE;} + if(jx ==ix && jz+1==iz){n[1] = j;nei[1] = kTRUE;} + if(jx+1==ix && jz+1==iz){n[2] = j;nei[2] = kTRUE;} + if(jx+1==ix && jz-1==iz){n[3] = j;nei[3] = kTRUE;} + } // end for k + if(nei[0]||nei[1]) return kTRUE; + if(kdiagonal&&(nei[2]||nei[3])) return kTRUE; + // no Neighbors found. + return kFALSE; } - -//__________________________________________________________________________ -AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source){ - // Copy Constructor - if(&source == this) return; - this->fDigits = source.fDigits; - this->fNdigits = source.fNdigits; - this->fResponse = source.fResponse; - this->fSegmentation = source.fSegmentation; - this->fNRawClusters = source.fNRawClusters; - this->fMap = source.fMap; - this->fNperMax = source.fNperMax; - this->fDeclusterFlag = source.fDeclusterFlag; - this->fClusterSize = source.fClusterSize; - this->fNPeaks = source.fNPeaks; - return; -} - -//_________________________________________________________________________ -AliITSClusterFinder& - AliITSClusterFinder::operator=(const AliITSClusterFinder &source) { - // Assignment operator - if(&source == this) return *this; - this->fDigits = source.fDigits; - this->fNdigits = source.fNdigits; - this->fResponse = source.fResponse; - this->fSegmentation = source.fSegmentation; - this->fNRawClusters = source.fNRawClusters; - this->fMap = source.fMap; - this->fNperMax = source.fNperMax; - this->fDeclusterFlag = source.fDeclusterFlag; - this->fClusterSize = source.fClusterSize; - this->fNPeaks = source.fNPeaks; - return *this; -} - -//---------------------------------------------------------- -void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c) -{ - // - // Add a raw cluster copy to the list - // - AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); - iTS->AddCluster(branch,c); - fNRawClusters++; - -} - - -//---------------------------------------------------------- -void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c, AliITSRecPoint &rp) -{ - // - // Add a raw cluster copy to the list - // - AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); - iTS->AddCluster(branch,c); - fNRawClusters++; - iTS->AddRecPoint(rp); + +//______________________________________________________________________ +void AliITSClusterFinder::Print(ostream *os) const{ + //Standard output format for this class + // Inputs: + // ostream *os Output stream + // Output: + // ostream *os Output stream + // Return: + // none. + + *os << fModule<<","; + *os << fNdigits<<","; + *os << fNPeaks<> fModule; + *is >> fNdigits; + *is >> fNPeaks; +} +//______________________________________________________________________ +ostream &operator<<(ostream &os,AliITSClusterFinder &source){ + // Standard output streaming function. + // Inputs: + // ostream *os Output stream + // AliITSClusterFinder &source Class to be printed + // Output: + // ostream *os Output stream + // Return: + // none. + + source.Print(&os); + return os; +} +//______________________________________________________________________ +istream &operator>>(istream &is,AliITSClusterFinder &source){ + // Standard output streaming function. + // Inputs: + // istream *is Input stream + // AliITSClusterFinder &source Class to be read in. + // Output: + // istream *is Input stream + // Return: + // none. + + source.Read(&is); + return is; +} +//______________________________________________________________________ +void AliITSClusterFinder::CheckLabels2(Int_t lab[10]) { + //------------------------------------------------------------ + // Tries to find mother's labels + //------------------------------------------------------------ + AliRunLoader *rl = AliRunLoader::Instance(); + TTree *trK=(TTree*)rl->TreeK(); + if(trK){ + Int_t nlabels =0; + for (Int_t i=0;i<10;i++) if (lab[i]>=0) nlabels++; + if(nlabels == 0) return; // In case of no labels just exit + Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); + for (Int_t i=0;i<10;i++){ + Int_t label = lab[i]; + if (label>=0 && labelGetMCApp()->Particle(label); + + if (part->P() < 0.02) { + Int_t m=part->GetFirstMother(); + if (m<0) { + continue; + } + if (part->GetStatusCode()>0) { + continue; + } + lab[i]=m; + } + else + if (part->P() < 0.12 && nlabels>3) { + lab[i]=-2; + nlabels--; + } + } + else{ + if ( (label>ntracks||label <0) && nlabels>3) { + lab[i]=-2; + nlabels--; + } + } + } + if (nlabels>3){ + for (Int_t i=0;i<10;i++){ + if (nlabels>3){ + Int_t label = lab[i]; + if (label>=0 && labelGetMCApp()->Particle(label); + if (part->P() < 0.1) { + lab[i]=-2; + nlabels--; + } + } + } + } + } + + //compress labels -- if multi-times the same + Int_t lab2[10]; + for (Int_t i=0;i<10;i++) lab2[i]=-2; + for (Int_t i=0;i<10 ;i++){ + if (lab[i]<0) continue; + for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){ + if (lab2[j]<0) { + lab2[j]= lab[i]; + break; + } + } + } + for (Int_t j=0;j<10;j++) lab[j]=lab2[j]; + + } +} + +//______________________________________________________________________ +void AliITSClusterFinder::AddLabel(Int_t lab[10], Int_t label) { + //add label to the cluster + AliRunLoader *rl = AliRunLoader::Instance(); + TTree *trK=(TTree*)rl->TreeK(); + if(trK){ + if(label<0) return; // In case of no label just exit + + Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); + if (label>ntracks) return; + for (Int_t i=0;i<10;i++){ + // if (label<0) break; + if (lab[i]==label) break; + if (lab[i]<0) { + lab[i]= label; + break; + } + } + } +} + + +//______________________________________________________________________ +void AliITSClusterFinder:: +FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) { + //------------------------------------------------------------ + // returns an array of indices of digits belonging to the cluster + // (needed when the segmentation is not regular) + //------------------------------------------------------------ + if (n<200) idx[n++]=bins[k].GetIndex(); + bins[k].Use(); + + if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx); + if (bins[k-1 ].IsNotUsed()) FindCluster(k-1 ,maxz,bins,n,idx); + if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx); + if (bins[k+1 ].IsNotUsed()) FindCluster(k+1 ,maxz,bins,n,idx); + /* + if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx); + if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx); + if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx); + if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx); + */ +} + +//______________________________________________________________________ +Bool_t AliITSClusterFinder::IsMaximum(Int_t k,Int_t max,const AliBin *bins) { + //------------------------------------------------------------ + //is this a local maximum ? + //------------------------------------------------------------ + UShort_t q=bins[k].GetQ(); + if (q==1023) return kFALSE; + if (bins[k-max].GetQ() > q) return kFALSE; + if (bins[k-1 ].GetQ() > q) return kFALSE; + if (bins[k+max].GetQ() > q) return kFALSE; + if (bins[k+1 ].GetQ() > q) return kFALSE; + if (bins[k-max-1].GetQ() > q) return kFALSE; + if (bins[k+max-1].GetQ() > q) return kFALSE; + if (bins[k+max+1].GetQ() > q) return kFALSE; + if (bins[k-max+1].GetQ() > q) return kFALSE; + return kTRUE; +} + +//______________________________________________________________________ +void AliITSClusterFinder:: +FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) { + //------------------------------------------------------------ + //find local maxima + //------------------------------------------------------------ + if (n<31) + if (IsMaximum(k,max,b)) { + idx[n]=k; msk[n]=(2<