]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHClusterFinder.cxx
d0f0fdacbdee49d4111a0176c485786f300cbb86
[u/mrichter/AliRoot.git] / RICH / AliRICHClusterFinder.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 #include "AliRICHClusterFinder.h"
18 #include "AliRICH.h"
19 #include "AliRICHMap.h"
20 #include "AliRICHParam.h"
21 #include <AliLoader.h>
22 #include <AliRun.h>
23
24
25 ClassImp(AliRICHClusterFinder)
26 //__________________________________________________________________________________________________
27 AliRICHClusterFinder::AliRICHClusterFinder(AliRICH *pRICH)   
28 {//main ctor
29   Info("main ctor","Start.");
30   
31   fRICH = pRICH;
32   
33   fHitMap = 0;  
34   
35 }//main ctor
36 //__________________________________________________________________________________________________
37 void AliRICHClusterFinder::FindLocalMaxima(AliRICHcluster *pRawCluster)
38 {// Split the cluster according to the number of maxima inside
39   Info("SplitbyLocalMaxima","Start.");
40   Int_t Nlocal = 0;
41   Int_t localX[100],localY[100];
42   for(Int_t iDig1=0;iDig1<pRawCluster->Size();iDig1++) {
43     Int_t iNotMax = 0;
44     AliRICHdigit *pDig1 = (AliRICHdigit *)pRawCluster->Digits()->At(iDig1);
45     Int_t padX1 = pDig1->X();
46     Int_t padY1 = pDig1->Y();
47     Double_t padQ1 = pDig1->Q();
48     for(Int_t iDig2=0;iDig2<pRawCluster->Size();iDig2++) {
49       AliRICHdigit *pDig2 = (AliRICHdigit *)pRawCluster->Digits()->At(iDig2);
50       Int_t padX2 = pDig2->X();
51       Int_t padY2 = pDig2->Y();
52       Double_t padQ2 = pDig2->Q();
53       if(iDig1==iDig2) continue;
54       Int_t diffx = TMath::Sign(padX1-padX2,1);
55       Int_t diffy = TMath::Sign(padY1-padY2,1);
56       if((diffx+diffy)<=1) {
57          if(padQ2>padQ1) iNotMax++;
58       }
59     }
60     if(iNotMax==0) {
61     localX[Nlocal] = padX1;
62     localY[Nlocal] = padY1;
63     Nlocal++;
64     }
65   }   
66 }//FindLocalMaxima()
67 //__________________________________________________________________________________________________
68 void AliRICHClusterFinder::Exec()
69 {
70   Info("Exec","Start.");
71   
72   
73   Rich()->GetLoader()->LoadDigits(); 
74   
75   for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
76     gAlice->GetRunLoader()->GetEvent(iEventN);
77     
78     Rich()->GetLoader()->MakeTree("R");  Rich()->MakeBranch("R");
79     Rich()->ResetDigits();  Rich()->ResetClusters();
80     
81     Rich()->GetLoader()->TreeD()->GetEntry(0);
82     for(Int_t iChamber=1;iChamber<=kNCH;iChamber++){//chambers loop
83      FindRawClusters(iChamber);
84         
85     }//chambers loop
86     
87     Rich()->GetLoader()->TreeR()->Fill();
88     Rich()->GetLoader()->WriteRecPoints("OVERWRITE");
89   }//events loop  
90   Rich()->GetLoader()->UnloadDigits(); Rich()->GetLoader()->UnloadRecPoints();  
91   Rich()->ResetDigits();  Rich()->ResetClusters();
92   Info("Exec","Stop.");      
93 }//Exec()
94 //__________________________________________________________________________________________________
95 void AliRICHClusterFinder::FindRawClusters(Int_t iChamber)
96 {//finds neighbours and fill the tree with raw clusters
97   Int_t nDigits=Rich()->Digits(iChamber)->GetEntriesFast();
98   Info("FindRawClusters","Start for Chamber %i with %i digits.",iChamber,nDigits);  
99   if(nDigits==0)return;
100
101   fHitMap=new AliRICHMap(Rich()->Digits(iChamber));
102
103   AliRICHcluster *pRawCluster;
104     
105   for(Int_t iDig=0;iDig<nDigits;iDig++){    
106     AliRICHdigit *dig=(AliRICHdigit*)Rich()->Digits(iChamber)->At(iDig);
107     Int_t i=dig->X();   Int_t j=dig->Y();
108     if(fHitMap->TestHit(i,j)==kUsed) continue;
109         
110     pRawCluster = new AliRICHcluster;
111     FormRawCluster(i,j,pRawCluster);
112         
113     if(AliRICHParam::IsResolveClusters()) {
114       ResolveCluster(pRawCluster); // ResolveCluster serialization will happen inside
115     } else {
116       WriteRawCluster(pRawCluster); // simply output of the RawCluster found without deconvolution
117     }    
118     delete pRawCluster;
119     
120   }//digits loop
121
122   delete fHitMap;
123   Info("FindRawClusters","Stop.");
124   
125 }//FindRawClusters()
126 //__________________________________________________________________________________________________
127 void  AliRICHClusterFinder::FormRawCluster(Int_t i, Int_t j, AliRICHcluster *pCluster)
128 {// Builder of the final Raw Cluster (before deconvolution)  
129   Info("FormRawCluster","Start with digit(%i,%i)",i,j);
130   
131 //  Int_t idx = fHitMap->GetHitIndex(i,j);
132   AliRICHdigit* pDigit = (AliRICHdigit*) fHitMap->GetHit(i,j);
133   pCluster->AddDigit(pDigit);
134   
135   fHitMap->FlagHit(i,j);// Flag hit as taken  
136
137   Int_t listX[4], listY[4];    //  Now look recursively for all neighbours
138   for (Int_t iNeighbour=0;iNeighbour<Rich()->Param()->PadNeighbours(i,j,listX,listY);iNeighbour++)
139     if(fHitMap->TestHit(listX[iNeighbour],listY[iNeighbour])==kUnused) 
140                       FormRawCluster(listX[iNeighbour],listY[iNeighbour],pCluster);    
141 }//AddDigit2Cluster()
142 //__________________________________________________________________________________________________
143 void AliRICHClusterFinder::ResolveCluster(AliRICHcluster *pRawCluster)
144 {// Decluster algorithm
145   Info("ResolveCluster","Start.");    
146   
147   pRawCluster->SetStatus(kRaw);// just dummy to compile...
148      
149 }//ResolveCluster()
150 //__________________________________________________________________________________________________
151 void AliRICHClusterFinder::WriteRawCluster(AliRICHcluster *pRawCluster)
152 {// out the current RawCluster
153   Info("ResolveCluster","Start.");
154   
155   pRawCluster->SetStatus(kRaw);
156   
157   
158 }//WriteRawCluster()
159 //__________________________________________________________________________________________________