X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=ITS%2FAliITSClusterFinder.cxx;h=4d5cfb55c3a38ed9bc382dd86d9681753f397547;hp=6c1bd7ffec0912eca3f8e77e71b0959b751863f7;hb=7b61cd9c9d60f8fde660333037130db4e7f7e74e;hpb=e869281d3588960aaa0dea0cc1c3b92704931a00 diff --git a/ITS/AliITSClusterFinder.cxx b/ITS/AliITSClusterFinder.cxx index 6c1bd7ffec0..4d5cfb55c3a 100644 --- a/ITS/AliITSClusterFinder.cxx +++ b/ITS/AliITSClusterFinder.cxx @@ -12,61 +12,136 @@ * 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 -// +//////////////////////////////////////////////////////////////////////////// +// // +// Base Class used to find // +// the reconstructed points for ITS // +// See also AliITSClusterFinderSPD, AliITSClusterFinderSDD, // +// AliITSClusterFinderSDD AliITSClusterFinderV2 // +//////////////////////////////////////////////////////////////////////////// #include "AliITSClusterFinder.h" -#include "AliITSdigitSPD.h" -#include "AliITSdigitSDD.h" -#include "AliITSdigitSSD.h" -#include "AliRun.h" -#include "AliITS.h" +#include "AliITSRecPoint.h" +#include "AliITSdigit.h" +#include "AliITSDetTypeRec.h" +#include "AliITSgeom.h" +#include "AliITSMap.h" ClassImp(AliITSClusterFinder) //---------------------------------------------------------------------- -AliITSClusterFinder::AliITSClusterFinder(){ +AliITSClusterFinder::AliITSClusterFinder(): +TObject(), +fDebug(0), +fModule(0), +fDigits(0), +fNdigits(0), +fResponse(0), +fSegmentation(0), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ // default cluster finder - - fSegmentation = 0; - fResponse = 0; - fMap = 0; - fDigits = 0; - fNdigits = 0; - fNRawClusters = 0; - fNperMax = 0; - fDeclusterFlag= 0; - fClusterSize = 0; - fNPeaks = 0; + // Input: + // none. + // Output: + // none. + // Return: + // A default constructed AliITSCulsterFinder } //---------------------------------------------------------------------- AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, - AliITSresponse *response, - TClonesArray *digits){ - // cluster finder - fSegmentation=seg; - fResponse=response; - fMap = 0; - - fDigits=digits; - fNdigits = fDigits->GetEntriesFast(); + AliITSresponse *res): +TObject(), +fDebug(0), +fModule(0), +fDigits(0), +fNdigits(0), +fResponse(res), +fSegmentation(seg), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ + // 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 - fNRawClusters=0; + SetNperMax(); + SetClusterSize(); + SetDeclusterFlag(); +} +//---------------------------------------------------------------------- +AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, + AliITSresponse *response, + TClonesArray *digits): +TObject(), +fDebug(0), +fModule(0), +fDigits(digits), +fNdigits(0), +fResponse(response), +fSegmentation(seg), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ + // 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 + fNdigits = fDigits->GetEntriesFast(); SetNperMax(); SetClusterSize(); SetDeclusterFlag(); +} +//______________________________________________________________________ +AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : TObject(source) { + // Copy constructor + // Copies are not allowed. The method is protected to avoid misuse. + Fatal("AliITSClusterFinder","Copy constructor not allowed\n"); +} - fNPeaks=-1; +//______________________________________________________________________ +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; } + //---------------------------------------------------------------------- AliITSClusterFinder::~AliITSClusterFinder(){ // destructor cluster finder + // Input: + // none. + // Output: + // none. + // Return: + // none. + if(fMap) {delete fMap;} // Zero local pointers. Other classes own these pointers. fSegmentation = 0; fResponse = 0; @@ -78,59 +153,112 @@ AliITSClusterFinder::~AliITSClusterFinder(){ fDeclusterFlag= 0; fClusterSize = 0; fNPeaks = 0; + // fITS = 0; + fDetTypeRec = 0; + fITSgeom = 0; + } //__________________________________________________________________________ -AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : - TObject(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; +void AliITSClusterFinder::InitGeometry(){ + + + //Initialisation of ITS geometry + if(!fITSgeom) { + Error("InitGeometry","ITS geom is null!"); return; + } + Int_t mmax=fITSgeom->GetIndexMax(); + if (mmax>2200) { + Fatal("AliITSClusterFinder","Too many ITS subdetectors !"); + } + Int_t m; + for (m=0; mGetModuleId(m,lay,lad,det); + Float_t x,y,z; fITSgeom->GetTrans(lay,lad,det,x,y,z); + Double_t rot[9]; fITSgeom->GetRotMatrix(lay,lad,det,rot); + Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); + Double_t ca=TMath::Cos(alpha), sa=TMath::Sin(alpha); + fYshift[m] = x*ca + y*sa; + fZshift[m] = (Double_t)z; + fNdet[m] = (lad-1)*fITSgeom->GetNdetectors(lay) + (det-1); + fNlayer[m] = lay-1; + } } -//______________________________________________________________________ -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 + // Input: + // Int_t branch The branch to which the cluster is to be added to + // AliITSRawCluster *c The cluster to be added to the array of clusters + // Output: + // none. + // Return: + // none. - AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); - iTS->AddCluster(branch,c); - fNRawClusters++; + if(!fDetTypeRec) { + Error("AddCluster","fDetTypeRec is null!"); + return; + } + fDetTypeRec->AddCluster(branch,c); + fNRawClusters++; } //---------------------------------------------------------------------- void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c, AliITSRecPoint &rp){ - // Add a raw cluster copy to the list + // Add a raw cluster copy to the list and the RecPoint + // Input: + // Int_t branch The branch to which the cluster is to be added to + // AliITSRawCluster *c The cluster to be added to the array of clusters + // AliITSRecPoint &rp The RecPoint to be added to the array of RecPoints + // Output: + // none. + // Return: + // none. + if(!fDetTypeRec) { + Error("AddCluster","fDetTypeRec is null!"); + return; + } + + fDetTypeRec->AddCluster(branch,c); + fNRawClusters++; + fDetTypeRec->AddRecPoint(rp); + +} +/* +//______________________________________________________________________ +void AliITSClusterFinder::CheckLabels(Int_t lab[3]) { + //------------------------------------------------------------ + // Tries to find mother's labels + //------------------------------------------------------------ + + if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit + // Check if simulation + AliMC* mc = gAlice->GetMCApp(); + if(!mc)return; - AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); - iTS->AddCluster(branch,c); - fNRawClusters++; - iTS->AddRecPoint(rp); + Int_t ntracks = mc->GetNtrack(); + for (Int_t i=0;i<3;i++){ + Int_t label = lab[i]; + if (label>=0 && labelParticle(label); + if (part->P() < 0.005) { + Int_t m=part->GetFirstMother(); + if (m<0) { + continue; + } + if (part->GetStatusCode()>0) { + continue; + } + lab[i]=m; + } + } + } + } +*/ //______________________________________________________________________ void AliITSClusterFinder::FindRawClusters(Int_t module){ // Default Cluster finder. @@ -150,7 +278,7 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ Int_t i=0,nc=0,j[4],k,k2=0; // Copy all digits for this module into a local TObjArray. - for(i=0;iAddAt(new AliITSdigit(*((AliITSdigit*)(fDigits->At(i)))),i); + for(i=0;iAddAt(new AliITSdigit(*(GetDigit(i))),i); digs->Sort(); // First digit is a cluster. i = 0; @@ -160,51 +288,53 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ clust0->AddAtFree(digs->At(i)); // move owner ship from digs to clusts nc++; for(i=1;iAt(j[0])); - // Add to existing cluster. Find which cluster this digis - for(k=0;kAt(k))); - if(clust0->IndexOf(dig)>=0) break; - } // end for k - if(k>=nc){ - Fatal("FindRawClusters","Digit not found as expected"); - } // end if - if(j[1]>=0){ - dig = (AliITSdigit*)(digs->At(j[1])); - // Add to existing cluster. Find which cluster this digis - for(k2=0;k2At(k2))); - if(clust1->IndexOf(dig)>=0) break; - } // end for k2 - if(k2>=nc){ - Fatal("FindRawClusters","Digit not found as expected"); - } // end if - } // end if j[1]>=0 - // Found cluster with neighboring digits add this one to it. - if(clust0==clust1){ // same cluster - clust0->AddAtFree(digs->At(i)); - clust0 = 0; // finished with cluster. zero for safty - clust1 = 0; // finished wit hcluster. zero for safty - }else{ // two different clusters which need to be merged. - clust0->AddAtFree(digs->At(i)); // Add digit to this cluster. - for(k=0;kGetEntriesFast();k++){ - // move clust1 into clust0 - clust0->AddAtFree(clust1->At(k));//move digit to this cluster - clust1->AddAt(0,k); // zero this one - } // end for k - delete clust1; - clusts->AddAt(0,k2); // zero array of clusters element clust1 - clust0 = 0; // finished with cluster. zero for safty - clust1 = 0; // finished wit hcluster. zero for safty - } // end if clust0==clust1 - }else{// New cluster - clusts->AddAt(new TObjArray(kelms),nc); - clust0 = ((TObjArray*)(clusts->At(nc))); - clust0->AddAtFree(digs->At(i));// move owner ship from digs to clusts - clust0 = 0; // finished with cluster. zero for safty - nc++; - } // End if IsNeighbor + if(IsNeighbor(digs,i,j)){ + dig = (AliITSdigit*)(digs->At(j[0])); + // Add to existing cluster. Find which cluster this digis + for(k=0;kAt(k))); + if(clust0->IndexOf(dig)>=0) break; + } // end for k + if(k>=nc){ + Fatal("FindRawClusters","Digit not found as expected"); + } // end if + if(j[1]>=0){ + dig = (AliITSdigit*)(digs->At(j[1])); + // Add to existing cluster. Find which cluster this digis + for(k2=0;k2At(k2))); + if(clust1->IndexOf(dig)>=0) break; + } // end for k2 + if(k2>=nc){ + Fatal("FindRawClusters","Digit not found as expected"); + } // end if + } // end if j[1]>=0 + // Found cluster with neighboring digits add this one to it. + if(clust0==clust1){ // same cluster + clust0->AddAtFree(digs->At(i)); + clust0 = 0; // finished with cluster. zero for safty + clust1 = 0; // finished wit hcluster. zero for safty + }else{ // two different clusters which need to be merged. + clust0->AddAtFree(digs->At(i)); // Add digit to this cluster. + for(k=0;kGetEntriesFast();k++){ + // move clust1 into clust0 + //move digit to this cluster + clust0->AddAtFree(clust1->At(k)); + clust1->AddAt(0,k); // zero this one + } // end for k + delete clust1; + clusts->AddAt(0,k2); // zero array of clusters element clust1 + clust0 = 0; // finished with cluster. zero for safty + clust1 = 0; // finished wit hcluster. zero for safty + } // end if clust0==clust1 + }else{// New cluster + clusts->AddAt(new TObjArray(kelms),nc); + clust0 = ((TObjArray*)(clusts->At(nc))); + // move owner ship from digs to clusts + clust0->AddAtFree(digs->At(i)); + clust0 = 0; // finished with cluster. zero for safty + nc++; + } // End if IsNeighbor } // end for i // There are now nc clusters in clusts. Each element of clust is an // array of digits which are clustered together. @@ -214,11 +344,11 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ // clean up at the end. for(i=0;iAt(i)); - // Digits deleted below, so zero this TObjArray - for(k=0;kGetEntriesFast();k++) clust0->AddAt(0,k); - delete clust0; // Delete this TObjArray - clusts->AddAt(0,i); // Contents deleted above, so zero it. + clust0 =(TObjArray*)(clusts->At(i)); + // Digits deleted below, so zero this TObjArray + for(k=0;kGetEntriesFast();k++) clust0->AddAt(0,k); + delete clust0; // Delete this TObjArray + clusts->AddAt(0,i); // Contents deleted above, so zero it. } // end for i delete clusts; // Delete this TObjArray/ // Delete the digits then the TObjArray which containted them. @@ -226,7 +356,7 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ delete digs; } //______________________________________________________________________ -Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[]) const{ +Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[])const{ // Locagical function which checks to see if digit i has a neighbor. // If so, then it returns kTRUE and its neighbor index j. // This routine checks if the digits are side by side or one before the @@ -256,15 +386,140 @@ Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[]) const{ 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;} + jx = ((AliITSdigit*)(digs->At(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; } + +//______________________________________________________________________ +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 << fDebug<<","; + *os << fModule<<","; + *os << fNdigits<<","; + *os << fNRawClusters<<","; + *os << fNperMax<<","; + *os << fDeclusterFlag<<","; + *os << fClusterSize<<","; + *os << fNPeaks< AliITSclusterV2 for the ITS + // subdetector indexed by idx + //------------------------------------------------------------ + if(!fITSgeom) { + Error("RecPoints2Clusters","ITS geom is null!"); + return; + } + Int_t lastSPD1=fITSgeom->GetModuleIndex(2,1,1)-1; + TClonesArray &cl=*clusters; + Int_t ncl=points->GetEntriesFast(); + for (Int_t i=0; iUncheckedAt(i); + Float_t lp[5]; + lp[0]=-(-p->GetX()+fYshift[idx]); if (idx<=lastSPD1) lp[0]*=-1; //SPD1 + lp[1]= -p->GetZ()+fZshift[idx]; + lp[2]=p->GetSigmaX2(); + lp[3]=p->GetSigmaZ2(); + lp[4]=p->GetQ()*36./23333.; //electrons -> ADC + Int_t lab[4]; + lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2); + lab[3]=fNdet[idx]; + CheckLabels(lab); + Int_t dummy[3]={0,0,0}; + new (cl[i]) AliITSclusterV2(lab,lp, dummy); + } +} +*/ +//______________________________________________________________________ +void AliITSClusterFinder::Read(istream *is) { + //Standard input for this class + // Inputs: + // istream *is Input stream + // Output: + // istream *is Input stream + // Return: + // none. + + *is >> fDebug; + *is >> fModule; + *is >> fNdigits; + *is >> fNRawClusters; + *is >> fNperMax; + *is >> fDeclusterFlag; + *is >> fClusterSize; + *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::RecPoints2Clusters +(const TClonesArray *points, Int_t idx, TClonesArray *clusters) { + //------------------------------------------------------------ + // Conversion AliITSRecPoint -> AliITSclusterV2 for the ITS + // subdetector indexed by idx + //------------------------------------------------------------ + TClonesArray &cl=*clusters; + Int_t ncl=points->GetEntriesFast(); + for (Int_t i=0; iUncheckedAt(i); + Float_t lp[5]; + lp[0]=-(-p->GetX()+fYshift[idx]); if (idx<=fLastSPD1) lp[0]*=-1; //SPD1 + lp[1]= -p->GetZ()+fZshift[idx]; + lp[2]=p->GetSigmaX2(); + lp[3]=p->GetSigmaZ2(); + lp[4]=p->GetQ()*36./23333.; //electrons -> ADC + Int_t lab[4]; + lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2); + lab[3]=fNdet[idx]; + CheckLabels(lab); + Int_t dummy[3]={0,0,0}; + new (cl[i]) AliITSclusterV2(lab,lp, dummy); + } +} +*/