]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSClusterizerv2.cxx
coding conventions corrections
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv2.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 /* $Id:  */
16
17 /* $Log:
18  */
19 //*-- Author: Boris Polichtchouk, IHEP
20 //////////////////////////////////////////////////////////////////////////////
21 //  Clusterization class for IHEP reconstruction.
22 // Performs clusterization (collects neighbouring active cells)
23 // It differs from AliPHOSClusterizerv1 in neighbour definition only
24
25 // --- ROOT system ---
26 #include "TBenchmark.h"
27 #include "TROOT.h"
28
29 // --- Standard library ---
30
31 // --- AliRoot header files ---
32 #include "AliPHOSClusterizerv2.h"
33 #include "AliPHOSGetter.h"
34 #include "TFolder.h"
35 #include "AliPHOSEvalRecPoint.h"
36 #include "AliPHOSRecCpvManager.h"
37 #include "AliPHOSRecEmcManager.h"
38
39 ClassImp(AliPHOSClusterizerv2)
40
41 AliPHOSClusterizerv2::AliPHOSClusterizerv2() : AliPHOSClusterizerv1() 
42 {}
43
44 AliPHOSClusterizerv2::AliPHOSClusterizerv2(const char * headerFile, const char * name, const Bool_t toSplit):
45 AliPHOSClusterizerv1(headerFile,name,toSplit)
46 {}
47
48 void AliPHOSClusterizerv2::GetNumberOfClustersFound(int* numb) const
49 {
50   // Returns the number of found EMC and CPV rec.points
51
52   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;   
53   numb[0] = gime->EmcRecPoints()->GetEntries();  
54   numb[1] = gime->CpvRecPoints()->GetEntries();  
55 }
56
57 void AliPHOSClusterizerv2::Exec(Option_t* option)
58 {
59   // Steering method
60
61   if(strstr(option,"tim"))
62     gBenchmark->Start("PHOSClusterizer"); 
63   
64   if(strstr(option,"print"))
65     Print("") ; 
66
67   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
68
69   TFolder* storage = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData/RecPoints/PHOS")); 
70   TFolder* wPoolF =  storage->AddFolder("SmP","SmartRecPoints for PHOS");
71   
72   TObjArray* wPool = new TObjArray(400);
73   wPool->SetName("SmartPoints");
74   wPoolF->Add(wPool);
75   wPoolF->Add(this);
76
77   Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
78   Int_t ievent ;
79
80   for(ievent = 0; ievent<nevents; ievent++) {
81     
82     gAlice->GetEvent(ievent) ;
83     gAlice->SetEvent(ievent) ;
84     
85     gime->Event(ievent,"D") ;
86 //      if(!ReadDigits(ievent))  //reads digits for event fEvent
87 //        continue;
88     
89     Info("Exec", "MakeClusters invoked..") ;
90     MakeClusters() ;
91     Info("Exec", "MakeClusters done.") ;
92
93
94     //SmartRecPoints will communicate with wPool.
95
96     AliPHOSEvalRecPoint* rp=0;
97
98     // CPV reconstruction
99
100     AliPHOSRecCpvManager* recCpv = new AliPHOSRecCpvManager();
101     wPoolF->Add(recCpv);
102
103     Int_t iPoint; //loop variable
104
105     for(iPoint=0; iPoint<gime->CpvRecPoints()->GetEntriesFast(); iPoint++) {
106       rp = new AliPHOSEvalRecPoint(iPoint,AliPHOSEvalRecPoint::kCpv);
107       rp->MakeJob();
108     }
109
110     AliPHOSEvalRecPoint pt;
111     pt.UpdateWorkingPool();
112
113     TObjArray * cpvRecPoints = gime->CpvRecPoints() ; 
114     Int_t nOldCpv = cpvRecPoints->GetEntries();
115     cpvRecPoints->Delete();
116     cpvRecPoints->Compress();
117
118     Int_t i; //loop variable
119
120     for(i=0; i<wPool->GetEntries(); i++)
121       cpvRecPoints->Add(wPool->At(i));
122
123     wPool->Clear();
124     wPool->Compress();
125
126     wPoolF->Remove(recCpv);
127     delete recCpv;
128
129     Info("Exec", "       %d", gime->CpvRecPoints()->GetEntries() ) ;
130     Info("Exec", "       %d cpvRecPoints", cpvRecPoints->GetEntries() ) ;
131
132
133     // Now Emc reconstruction
134
135     AliPHOSRecEmcManager* recEmc = new AliPHOSRecEmcManager();
136     wPoolF->Add(recEmc);
137
138     for(iPoint=0; iPoint<gime->EmcRecPoints()->GetEntriesFast(); iPoint++) {
139       rp = new AliPHOSEvalRecPoint(iPoint,(Bool_t)AliPHOSEvalRecPoint::kEmc);
140       rp->MakeJob();
141     }
142
143     pt.UpdateWorkingPool();
144
145     TObjArray * emcRecPoints = gime->EmcRecPoints() ; 
146     Int_t nOldEmc = emcRecPoints->GetEntries();
147     emcRecPoints->Delete();
148     emcRecPoints->Compress();
149
150     for(i=0; i<wPool->GetEntries(); i++)
151       emcRecPoints->Add(wPool->At(i));
152
153     wPool->Clear();
154     wPool->Compress();
155
156     wPoolF->Remove(recEmc);
157     delete recEmc;
158
159     TString message ; 
160     message  = "       %d  OLD cpvRecPoints\n" ; 
161     message += "       %d\n" ; 
162     message += "       %d cpvRecPoints\n" ; 
163
164     message += "       %d OLD emcRecPoints " ; 
165     message += "       %d\n" ;
166     message += "       %d emcRecPoints\n" ;
167
168     Info("Exec", message.Data(), 
169          nOldCpv, 
170          gime->CpvRecPoints()->GetEntries(),cpvRecPoints->GetEntries(), 
171          nOldEmc, 
172          gime->EmcRecPoints()->GetEntries(), emcRecPoints->GetEntries() ) ; 
173
174     WriteRecPoints(ievent);
175
176
177   } // loop over events
178
179   if(strstr(option,"tim")) {
180     gBenchmark->Stop("PHOSClusterizer");
181     Info("Exec","took %f seconds for Clusterizing", gBenchmark->GetCpuTime("PHOSClusterizer") ) ;
182   }
183 }
184 //---------------------------------------------------------------------------------
185 Int_t AliPHOSClusterizerv2::AreNeighbours(AliPHOSDigit* d1, AliPHOSDigit* d2) const
186 {
187   // Points are neighbours if they have common edge.
188   // Points with common vertex are NOT neighbours.
189   // This treatment of neighbourship is the part of 
190   // IHEP algorithm of clusterization.
191
192   // Gives the neighbourness of two digits = 0 are not neighbour but continue searching 
193   //                                       = 1 are neighbour
194   //                                       = 2 are not neighbour but do not continue searching
195   // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster 
196   // which is compared to a digit (d2)  not yet in a cluster  
197
198   const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry();
199
200   Int_t rv = 0 ; 
201
202   Int_t relid1[4] ; 
203   geom->AbsToRelNumbering(d1->GetId(), relid1) ; 
204
205   Int_t relid2[4] ; 
206   geom->AbsToRelNumbering(d2->GetId(), relid2) ; 
207  
208   if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module 
209     Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;  
210     Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;  
211     
212     if ( ( (coldiff < 1) && (rowdiff <= 1) ) || ( ( coldiff <= 1 )  && ( rowdiff < 1 ) ) ){
213       rv = 1 ; 
214     }
215     else {
216       if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1)) 
217         rv = 2; //  Difference in row numbers is too large to look further 
218     }
219
220   } 
221   else {
222     
223     if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )  
224       rv=2 ;
225
226   }
227
228   return rv ; 
229
230 }