]>
Commit | Line | Data |
---|---|---|
d15a28e7 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
17 | ||
9a1398dd | 18 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute) |
d15a28e7 | 19 | ////////////////////////////////////////////////////////////////////////////// |
9a1398dd | 20 | // Clusterization class. Performs clusterization (collects neighbouring active cells) and |
a4e98857 | 21 | // unfolds the clusters having several local maxima. |
22 | // Results are stored in TreeR#, branches PHOSEmcRP (EMC recPoints), | |
9a1398dd | 23 | // PHOSCpvRP (CPV RecPoints) and AliPHOSClusterizer (Clusterizer with all |
f035f6ce | 24 | // parameters including input digits branch title, thresholds etc.) |
a4e98857 | 25 | // This TTask is normally called from Reconstructioner, but can as well be used in |
26 | // standalone mode. | |
27 | // Use Case: | |
fc12304f | 28 | // root [0] AliPHOSClusterizerv1 * cl = new AliPHOSClusterizerv1("galice.root", "recpointsname", "digitsname") |
a4e98857 | 29 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
fc12304f | 30 | // // reads gAlice from header file "galice.root", uses digits stored in the branch names "digitsname" (default = "Default") |
31 | // // and saves recpoints in branch named "recpointsname" (default = "digitsname") | |
a4e98857 | 32 | // root [1] cl->ExecuteTask() |
9a1398dd | 33 | // //finds RecPoints in all events stored in galice.root |
a4e98857 | 34 | // root [2] cl->SetDigitsBranch("digits2") |
f035f6ce | 35 | // //sets another title for Digitis (input) branch |
a4e98857 | 36 | // root [3] cl->SetRecPointsBranch("recp2") |
f035f6ce | 37 | // //sets another title four output branches |
a4e98857 | 38 | // root [4] cl->SetEmcLocalMaxCut(0.03) |
9a1398dd | 39 | // //set clusterization parameters |
a4e98857 | 40 | // root [5] cl->ExecuteTask("deb all time") |
9a1398dd | 41 | // //once more finds RecPoints options are |
42 | // // deb - print number of found rec points | |
43 | // // deb all - print number of found RecPoints and some their characteristics | |
44 | // // time - print benchmarking results | |
ed4205d8 | 45 | |
d15a28e7 | 46 | // --- ROOT system --- |
47 | ||
48 | #include "TMath.h" | |
9a1398dd | 49 | #include "TMinuit.h" |
50 | #include "TTree.h" | |
9a1398dd | 51 | #include "TBenchmark.h" |
d15a28e7 | 52 | |
53 | // --- Standard library --- | |
54 | ||
d15a28e7 | 55 | // --- AliRoot header files --- |
351dd634 | 56 | #include "AliLog.h" |
88cb7938 | 57 | #include "AliPHOSGetter.h" |
e957fea8 | 58 | #include "AliPHOSGeometry.h" |
d15a28e7 | 59 | #include "AliPHOSClusterizerv1.h" |
88cb7938 | 60 | #include "AliPHOSEmcRecPoint.h" |
9a1398dd | 61 | #include "AliPHOSCpvRecPoint.h" |
d15a28e7 | 62 | #include "AliPHOSDigit.h" |
9a1398dd | 63 | #include "AliPHOSDigitizer.h" |
ba898748 | 64 | #include "AliPHOSCalibrationDB.h" |
d15a28e7 | 65 | |
66 | ClassImp(AliPHOSClusterizerv1) | |
f035f6ce | 67 | |
d15a28e7 | 68 | //____________________________________________________________________________ |
7b7c1533 | 69 | AliPHOSClusterizerv1::AliPHOSClusterizerv1() : AliPHOSClusterizer() |
d15a28e7 | 70 | { |
f035f6ce | 71 | // default ctor (to be used mainly by Streamer) |
f035f6ce | 72 | |
8d0f3f77 | 73 | InitParameters() ; |
92f521a9 | 74 | fDefaultInit = kTRUE ; |
9a1398dd | 75 | } |
7b7c1533 | 76 | |
9a1398dd | 77 | //____________________________________________________________________________ |
88cb7938 | 78 | AliPHOSClusterizerv1::AliPHOSClusterizerv1(const TString alirunFileName, const TString eventFolderName) |
79 | :AliPHOSClusterizer(alirunFileName, eventFolderName) | |
9a1398dd | 80 | { |
a4e98857 | 81 | // ctor with the indication of the file where header Tree and digits Tree are stored |
9a1398dd | 82 | |
8d0f3f77 | 83 | InitParameters() ; |
2bd5457f | 84 | Init() ; |
92f521a9 | 85 | fDefaultInit = kFALSE ; |
9a1398dd | 86 | } |
fc12304f | 87 | |
9688c1dd | 88 | //____________________________________________________________________________ |
89 | AliPHOSClusterizerv1::~AliPHOSClusterizerv1() | |
90 | { | |
0bc3b8ed | 91 | // dtor |
92 | ||
9688c1dd | 93 | } |
fc12304f | 94 | //____________________________________________________________________________ |
95 | const TString AliPHOSClusterizerv1::BranchName() const | |
96 | { | |
88cb7938 | 97 | return GetName(); |
fc12304f | 98 | } |
99 | ||
9a1398dd | 100 | //____________________________________________________________________________ |
3758d9fc | 101 | Float_t AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId) const |
88cb7938 | 102 | { |
103 | //To be replaced later by the method, reading individual parameters from the database | |
ba898748 | 104 | if(fCalibrationDB){ |
105 | return fCalibrationDB->Calibrate(amp,absId) ; | |
106 | } | |
107 | else{ //simulation | |
108 | if(absId <= fEmcCrystals) //calibrate as EMC | |
109 | return fADCpedestalEmc + amp*fADCchanelEmc ; | |
110 | else //calibrate as CPV | |
111 | return fADCpedestalCpv+ amp*fADCchanelCpv ; | |
112 | } | |
3758d9fc | 113 | } |
548f0134 | 114 | |
3758d9fc | 115 | //____________________________________________________________________________ |
eabde521 | 116 | void AliPHOSClusterizerv1::Exec(Option_t *option) |
a4e98857 | 117 | { |
eabde521 | 118 | // Steering method to perform clusterization for events |
119 | // in the range from fFirstEvent to fLastEvent. | |
120 | // This range is optionally set by SetEventRange(). | |
121 | // if fLastEvent=-1 (by default), then process events until the end. | |
9a1398dd | 122 | |
123 | if(strstr(option,"tim")) | |
7d493c2c | 124 | gBenchmark->Start("PHOSClusterizer"); |
9a1398dd | 125 | |
eabde521 | 126 | if(strstr(option,"print")) { |
88cb7938 | 127 | Print() ; |
eabde521 | 128 | return ; |
129 | } | |
bed9e3fb | 130 | |
ba898748 | 131 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
132 | GetCalibrationParameters() ; | |
88cb7938 | 133 | |
9cae45af | 134 | if (fLastEvent == -1) |
135 | fLastEvent = gime->MaxEvent() - 1 ; | |
136 | else | |
fb43ada4 | 137 | fLastEvent = TMath::Min(fFirstEvent, gime->MaxEvent()); // one event at the time |
eabde521 | 138 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
ba898748 | 139 | |
9cae45af | 140 | Int_t ievent ; |
9cae45af | 141 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
88cb7938 | 142 | gime->Event(ievent, "D"); |
04f0bda3 | 143 | |
548f0134 | 144 | fNumberOfEmcClusters = fNumberOfCpvClusters = 0 ; |
9a1398dd | 145 | |
88cb7938 | 146 | MakeClusters() ; |
147 | ||
fc12304f | 148 | if(fToUnfold) |
149 | MakeUnfolding() ; | |
7b7c1533 | 150 | |
88cb7938 | 151 | WriteRecPoints(); |
7b7c1533 | 152 | |
94de8339 | 153 | if(strstr(option,"deb")) |
154 | PrintRecPoints(option) ; | |
155 | ||
88cb7938 | 156 | //increment the total number of recpoints per run |
fbf811ec | 157 | fRecPointsInRun += gime->EmcRecPoints()->GetEntriesFast() ; |
158 | fRecPointsInRun += gime->CpvRecPoints()->GetEntriesFast() ; | |
88cb7938 | 159 | } |
160 | ||
ba898748 | 161 | if(fWrite) //do not unload in "on flight" mode |
162 | Unload(); | |
9a1398dd | 163 | |
164 | if(strstr(option,"tim")){ | |
165 | gBenchmark->Stop("PHOSClusterizer"); | |
351dd634 | 166 | AliInfo(Form("took %f seconds for Clusterizing %f seconds per event \n", |
21cd0c07 | 167 | gBenchmark->GetCpuTime("PHOSClusterizer"), |
351dd634 | 168 | gBenchmark->GetCpuTime("PHOSClusterizer")/nEvents )) ; |
88cb7938 | 169 | } |
9a1398dd | 170 | } |
171 | ||
172 | //____________________________________________________________________________ | |
a0636361 | 173 | Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, AliPHOSDigit ** maxAt, Float_t * maxAtEnergy, |
d1de15f5 | 174 | Int_t nPar, Float_t * fitparameters) const |
9a1398dd | 175 | { |
176 | // Calls TMinuit to fit the energy distribution of a cluster with several maxima | |
a4e98857 | 177 | // The initial values for fitting procedure are set equal to the positions of local maxima. |
f035f6ce | 178 | // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers |
9a1398dd | 179 | |
88cb7938 | 180 | |
181 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
182 | TClonesArray * digits = gime->Digits(); | |
7b7c1533 | 183 | |
184 | ||
9a1398dd | 185 | gMinuit->mncler(); // Reset Minuit's list of paramters |
186 | gMinuit->SetPrintLevel(-1) ; // No Printout | |
187 | gMinuit->SetFCN(AliPHOSClusterizerv1::UnfoldingChiSquare) ; | |
188 | // To set the address of the minimization function | |
189 | ||
190 | TList * toMinuit = new TList(); | |
191 | toMinuit->AddAt(emcRP,0) ; | |
7b7c1533 | 192 | toMinuit->AddAt(digits,1) ; |
9a1398dd | 193 | |
194 | gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare | |
195 | ||
196 | // filling initial values for fit parameters | |
197 | AliPHOSDigit * digit ; | |
198 | ||
199 | Int_t ierflg = 0; | |
200 | Int_t index = 0 ; | |
201 | Int_t nDigits = (Int_t) nPar / 3 ; | |
202 | ||
203 | Int_t iDigit ; | |
204 | ||
7b7c1533 | 205 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
9a1398dd | 206 | |
207 | for(iDigit = 0; iDigit < nDigits; iDigit++){ | |
a0636361 | 208 | digit = maxAt[iDigit]; |
9a1398dd | 209 | |
210 | Int_t relid[4] ; | |
7b7c1533 | 211 | Float_t x = 0.; |
212 | Float_t z = 0.; | |
213 | geom->AbsToRelNumbering(digit->GetId(), relid) ; | |
214 | geom->RelPosInModule(relid, x, z) ; | |
9a1398dd | 215 | |
216 | Float_t energy = maxAtEnergy[iDigit] ; | |
217 | ||
218 | gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ; | |
219 | index++ ; | |
220 | if(ierflg != 0){ | |
21cd0c07 | 221 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : x = %f\n", x ) ; |
9a1398dd | 222 | return kFALSE; |
223 | } | |
224 | gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ; | |
225 | index++ ; | |
226 | if(ierflg != 0){ | |
21cd0c07 | 227 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : z =%f\n", z ) ; |
9a1398dd | 228 | return kFALSE; |
229 | } | |
230 | gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ; | |
231 | index++ ; | |
232 | if(ierflg != 0){ | |
21cd0c07 | 233 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : energy = %f\n", energy ) ; |
9a1398dd | 234 | return kFALSE; |
235 | } | |
236 | } | |
237 | ||
238 | Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly | |
239 | // depends on it. | |
240 | Double_t p1 = 1.0 ; | |
241 | Double_t p2 = 0.0 ; | |
242 | ||
243 | gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls | |
244 | gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient | |
245 | gMinuit->SetMaxIterations(5); | |
246 | gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings | |
247 | ||
248 | gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize | |
249 | ||
250 | if(ierflg == 4){ // Minimum not found | |
21cd0c07 | 251 | Warning("FindFit", "PHOS Unfolding fit not converged, cluster abandoned\n" ); |
9a1398dd | 252 | return kFALSE ; |
253 | } | |
254 | for(index = 0; index < nPar; index++){ | |
255 | Double_t err ; | |
256 | Double_t val ; | |
257 | gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index | |
258 | fitparameters[index] = val ; | |
259 | } | |
260 | ||
261 | delete toMinuit ; | |
262 | return kTRUE; | |
c3c187e5 | 263 | |
d15a28e7 | 264 | } |
265 | ||
3758d9fc | 266 | //____________________________________________________________________________ |
267 | void AliPHOSClusterizerv1::GetCalibrationParameters() | |
268 | { | |
fbf811ec | 269 | |
88cb7938 | 270 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
ba898748 | 271 | if(gime->IsRawDigits()){ |
272 | fCalibrationDB = gime->CalibrationDB(); | |
273 | } | |
274 | else{ | |
275 | if ( !gime->Digitizer() ) | |
276 | gime->LoadDigitizer(); | |
277 | AliPHOSDigitizer * dig = gime->Digitizer(); | |
278 | fADCchanelEmc = dig->GetEMCchannel() ; | |
279 | fADCpedestalEmc = dig->GetEMCpedestal(); | |
280 | ||
281 | fADCchanelCpv = dig->GetCPVchannel() ; | |
282 | fADCpedestalCpv = dig->GetCPVpedestal() ; | |
283 | } | |
3758d9fc | 284 | } |
548f0134 | 285 | |
d15a28e7 | 286 | //____________________________________________________________________________ |
a4e98857 | 287 | void AliPHOSClusterizerv1::Init() |
288 | { | |
2bd5457f | 289 | // Make all memory allocations which can not be done in default constructor. |
290 | // Attach the Clusterizer task to the list of PHOS tasks | |
ba898748 | 291 | |
292 | AliPHOSGetter* gime = AliPHOSGetter::Instance() ; | |
293 | if(!gime) | |
294 | gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
fbf811ec | 295 | |
88cb7938 | 296 | AliPHOSGeometry * geom = gime->PHOSGeometry(); |
ba898748 | 297 | |
3758d9fc | 298 | fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ; |
299 | ||
7b7c1533 | 300 | if(!gMinuit) |
88cb7938 | 301 | gMinuit = new TMinuit(100); |
fbf811ec | 302 | |
ba898748 | 303 | if ( !gime->Clusterizer() ) { |
88cb7938 | 304 | gime->PostClusterizer(this); |
ba898748 | 305 | } |
9a1398dd | 306 | } |
7b7c1533 | 307 | |
8d0f3f77 | 308 | //____________________________________________________________________________ |
309 | void AliPHOSClusterizerv1::InitParameters() | |
310 | { | |
311 | ||
312 | fNumberOfCpvClusters = 0 ; | |
313 | fNumberOfEmcClusters = 0 ; | |
314 | ||
315 | fCpvClusteringThreshold = 0.0; | |
316 | fEmcClusteringThreshold = 0.2; | |
317 | ||
318 | fEmcLocMaxCut = 0.03 ; | |
319 | fCpvLocMaxCut = 0.03 ; | |
ba898748 | 320 | |
321 | fEmcMinE = 0.01 ; | |
322 | fCpvMinE = 0.0 ; | |
323 | ||
8d0f3f77 | 324 | fW0 = 4.5 ; |
325 | fW0CPV = 4.0 ; | |
326 | ||
327 | fEmcTimeGate = 1.e-8 ; | |
328 | ||
329 | fToUnfold = kTRUE ; | |
88cb7938 | 330 | |
8d0f3f77 | 331 | fRecPointsInRun = 0 ; |
c2cd5471 | 332 | |
ba898748 | 333 | fWrite = kTRUE ; |
334 | ||
ae911977 | 335 | fCalibrationDB = 0 ; |
336 | ||
eabde521 | 337 | SetEventRange(0,-1) ; |
8d0f3f77 | 338 | } |
339 | ||
9a1398dd | 340 | //____________________________________________________________________________ |
341 | Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)const | |
d15a28e7 | 342 | { |
b2a60966 | 343 | // Gives the neighbourness of two digits = 0 are not neighbour but continue searching |
344 | // = 1 are neighbour | |
345 | // = 2 are not neighbour but do not continue searching | |
a4e98857 | 346 | // neighbours are defined as digits having at least a common vertex |
b2a60966 | 347 | // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster |
348 | // which is compared to a digit (d2) not yet in a cluster | |
349 | ||
88cb7938 | 350 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; |
7b7c1533 | 351 | |
d15a28e7 | 352 | Int_t rv = 0 ; |
353 | ||
d15a28e7 | 354 | Int_t relid1[4] ; |
7b7c1533 | 355 | geom->AbsToRelNumbering(d1->GetId(), relid1) ; |
d15a28e7 | 356 | |
357 | Int_t relid2[4] ; | |
7b7c1533 | 358 | geom->AbsToRelNumbering(d2->GetId(), relid2) ; |
d15a28e7 | 359 | |
9688c1dd | 360 | if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module |
92862013 | 361 | Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ; |
362 | Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ; | |
d15a28e7 | 363 | |
92862013 | 364 | if (( coldiff <= 1 ) && ( rowdiff <= 1 )){ |
9688c1dd | 365 | if((relid1[1] != 0) || (TMath::Abs(d1->GetTime() - d2->GetTime() ) < fEmcTimeGate)) |
d15a28e7 | 366 | rv = 1 ; |
367 | } | |
368 | else { | |
369 | if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1)) | |
88cb7938 | 370 | rv = 2; // Difference in row numbers is too large to look further |
d15a28e7 | 371 | } |
372 | ||
373 | } | |
374 | else { | |
375 | ||
9688c1dd | 376 | if( (relid1[0] < relid2[0]) || (relid1[1] != relid2[1]) ) |
d15a28e7 | 377 | rv=2 ; |
378 | ||
379 | } | |
d72dfbc3 | 380 | |
d15a28e7 | 381 | return rv ; |
382 | } | |
ba898748 | 383 | //____________________________________________________________________________ |
384 | void AliPHOSClusterizerv1::CleanDigits(TClonesArray * digits){ | |
385 | for(Int_t i=0; i<digits->GetEntriesFast(); i++){ | |
386 | AliPHOSDigit * digit = static_cast<AliPHOSDigit*>(digits->At(i)) ; | |
387 | Float_t cut = IsInEmc(digit) ? fEmcMinE : fCpvMinE ; | |
388 | if(Calibrate(digit->GetAmp(),digit->GetId()) < cut) | |
389 | digits->RemoveAt(i) ; | |
390 | } | |
391 | digits->Compress() ; | |
392 | for (Int_t i = 0 ; i < digits->GetEntriesFast() ; i++) { | |
393 | AliPHOSDigit *digit = static_cast<AliPHOSDigit*>( digits->At(i) ) ; | |
394 | digit->SetIndexInList(i) ; | |
395 | } | |
d15a28e7 | 396 | |
ba898748 | 397 | } |
d15a28e7 | 398 | //____________________________________________________________________________ |
9a1398dd | 399 | Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit) const |
d15a28e7 | 400 | { |
b2a60966 | 401 | // Tells if (true) or not (false) the digit is in a PHOS-EMC module |
402 | ||
9f616d61 | 403 | Bool_t rv = kFALSE ; |
88cb7938 | 404 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; |
d15a28e7 | 405 | |
2b629790 | 406 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); |
d15a28e7 | 407 | |
2b629790 | 408 | if(digit->GetId() <= nEMC ) rv = kTRUE; |
ed4205d8 | 409 | |
410 | return rv ; | |
411 | } | |
412 | ||
ed4205d8 | 413 | //____________________________________________________________________________ |
9a1398dd | 414 | Bool_t AliPHOSClusterizerv1::IsInCpv(AliPHOSDigit * digit) const |
ed4205d8 | 415 | { |
fad3e5b9 | 416 | // Tells if (true) or not (false) the digit is in a PHOS-CPV module |
ed4205d8 | 417 | |
418 | Bool_t rv = kFALSE ; | |
88cb7938 | 419 | |
420 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; | |
ed4205d8 | 421 | |
2b629790 | 422 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); |
ed4205d8 | 423 | |
2b629790 | 424 | if(digit->GetId() > nEMC ) rv = kTRUE; |
d15a28e7 | 425 | |
426 | return rv ; | |
427 | } | |
9a1398dd | 428 | |
429 | //____________________________________________________________________________ | |
88cb7938 | 430 | void AliPHOSClusterizerv1::Unload() |
431 | { | |
432 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
433 | gime->PhosLoader()->UnloadDigits() ; | |
434 | gime->PhosLoader()->UnloadRecPoints() ; | |
435 | } | |
436 | ||
437 | //____________________________________________________________________________ | |
438 | void AliPHOSClusterizerv1::WriteRecPoints() | |
a4e98857 | 439 | { |
7b7c1533 | 440 | |
441 | // Creates new branches with given title | |
a4e98857 | 442 | // fills and writes into TreeR. |
88cb7938 | 443 | |
444 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
445 | ||
fbf811ec | 446 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
447 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
448 | TClonesArray * digits = gime->Digits() ; | |
ba898748 | 449 | |
450 | ||
9a1398dd | 451 | Int_t index ; |
ba898748 | 452 | //Evaluate position, dispersion and other RecPoint properties.. |
453 | Int_t nEmc = emcRecPoints->GetEntriesFast(); | |
454 | for(index = 0; index < nEmc; index++){ | |
455 | AliPHOSEmcRecPoint * rp = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) ); | |
456 | rp->Purify(fEmcMinE) ; | |
457 | if(rp->GetMultiplicity()>0.) //If this RP is not empty | |
458 | rp->EvalAll(fW0,digits) ; | |
459 | else{ | |
460 | emcRecPoints->RemoveAt(index) ; | |
461 | delete rp ; | |
462 | } | |
463 | } | |
464 | emcRecPoints->Compress() ; | |
7b7c1533 | 465 | emcRecPoints->Sort() ; |
ba898748 | 466 | // emcRecPoints->Expand(emcRecPoints->GetEntriesFast()) ; |
467 | for(index = 0; index < emcRecPoints->GetEntries(); index++){ | |
88cb7938 | 468 | dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) )->SetIndexInList(index) ; |
ba898748 | 469 | } |
fbf811ec | 470 | |
9a1398dd | 471 | //Now the same for CPV |
ba898748 | 472 | for(index = 0; index < cpvRecPoints->GetEntries(); index++){ |
473 | AliPHOSCpvRecPoint * rp = dynamic_cast<AliPHOSCpvRecPoint *>( cpvRecPoints->At(index) ); | |
474 | rp->EvalAll(fW0CPV,digits) ; | |
475 | } | |
7b7c1533 | 476 | cpvRecPoints->Sort() ; |
fbf811ec | 477 | |
7b7c1533 | 478 | for(index = 0; index < cpvRecPoints->GetEntries(); index++) |
2bb500e5 | 479 | dynamic_cast<AliPHOSCpvRecPoint *>( cpvRecPoints->At(index) )->SetIndexInList(index) ; |
fbf811ec | 480 | |
7b7c1533 | 481 | cpvRecPoints->Expand(cpvRecPoints->GetEntriesFast()) ; |
9a1398dd | 482 | |
ba898748 | 483 | if(fWrite){ //We write TreeR |
484 | TTree * treeR = gime->TreeR(); | |
9a1398dd | 485 | |
ba898748 | 486 | Int_t bufferSize = 32000 ; |
487 | Int_t splitlevel = 0 ; | |
9a1398dd | 488 | |
ba898748 | 489 | //First EMC |
490 | TBranch * emcBranch = treeR->Branch("PHOSEmcRP","TObjArray",&emcRecPoints,bufferSize,splitlevel); | |
491 | emcBranch->SetTitle(BranchName()); | |
492 | ||
493 | //Now CPV branch | |
494 | TBranch * cpvBranch = treeR->Branch("PHOSCpvRP","TObjArray",&cpvRecPoints,bufferSize,splitlevel); | |
495 | cpvBranch->SetTitle(BranchName()); | |
496 | ||
497 | emcBranch ->Fill() ; | |
498 | cpvBranch ->Fill() ; | |
499 | ||
500 | gime->WriteRecPoints("OVERWRITE"); | |
501 | gime->WriteClusterizer("OVERWRITE"); | |
502 | } | |
9a1398dd | 503 | } |
504 | ||
505 | //____________________________________________________________________________ | |
506 | void AliPHOSClusterizerv1::MakeClusters() | |
507 | { | |
508 | // Steering method to construct the clusters stored in a list of Reconstructed Points | |
509 | // A cluster is defined as a list of neighbour digits | |
d15a28e7 | 510 | |
88cb7938 | 511 | |
512 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
513 | ||
514 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
515 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 516 | |
7d493c2c | 517 | emcRecPoints->Delete() ; |
518 | cpvRecPoints->Delete() ; | |
7b7c1533 | 519 | |
fbf811ec | 520 | TClonesArray * digits = gime->Digits() ; |
88cb7938 | 521 | |
ba898748 | 522 | //Remove digits below threshold |
523 | CleanDigits(digits) ; | |
524 | ||
525 | ||
88cb7938 | 526 | TClonesArray * digitsC = static_cast<TClonesArray*>( digits->Clone() ) ; |
7b7c1533 | 527 | |
528 | ||
d15a28e7 | 529 | // Clusterization starts |
9a1398dd | 530 | |
7b7c1533 | 531 | TIter nextdigit(digitsC) ; |
d15a28e7 | 532 | AliPHOSDigit * digit ; |
92862013 | 533 | Bool_t notremoved = kTRUE ; |
6ad0bfa0 | 534 | |
88cb7938 | 535 | while ( (digit = dynamic_cast<AliPHOSDigit *>( nextdigit()) ) ) { // scan over the list of digitsC |
536 | ||
537 | ||
9a1398dd | 538 | AliPHOSRecPoint * clu = 0 ; |
c161df70 | 539 | |
d1de15f5 | 540 | TArrayI clusterdigitslist(1500) ; |
d15a28e7 | 541 | Int_t index ; |
f2bc1b87 | 542 | |
3758d9fc | 543 | if (( IsInEmc (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fEmcClusteringThreshold ) || |
544 | ( IsInCpv (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fCpvClusteringThreshold ) ) { | |
d15a28e7 | 545 | Int_t iDigitInCluster = 0 ; |
7b7c1533 | 546 | |
6ad0bfa0 | 547 | if ( IsInEmc(digit) ) { |
88cb7938 | 548 | // start a new EMC RecPoint |
549 | if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) | |
550 | emcRecPoints->Expand(2*fNumberOfEmcClusters+1) ; | |
551 | ||
552 | emcRecPoints->AddAt(new AliPHOSEmcRecPoint(""), fNumberOfEmcClusters) ; | |
553 | clu = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(fNumberOfEmcClusters) ) ; | |
554 | fNumberOfEmcClusters++ ; | |
555 | clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->GetId())) ; | |
556 | clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; | |
557 | iDigitInCluster++ ; | |
558 | digitsC->Remove(digit) ; | |
ca77b032 | 559 | |
d72dfbc3 | 560 | } else { |
88cb7938 | 561 | |
562 | // start a new CPV cluster | |
563 | if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) | |
564 | cpvRecPoints->Expand(2*fNumberOfCpvClusters+1); | |
565 | ||
566 | cpvRecPoints->AddAt(new AliPHOSCpvRecPoint(""), fNumberOfCpvClusters) ; | |
567 | ||
568 | clu = dynamic_cast<AliPHOSCpvRecPoint *>( cpvRecPoints->At(fNumberOfCpvClusters) ) ; | |
569 | fNumberOfCpvClusters++ ; | |
570 | clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->GetId()) ) ; | |
571 | clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; | |
572 | iDigitInCluster++ ; | |
573 | digitsC->Remove(digit) ; | |
d15a28e7 | 574 | nextdigit.Reset() ; |
88cb7938 | 575 | |
576 | // Here we remove remaining EMC digits, which cannot make a cluster | |
577 | ||
92862013 | 578 | if( notremoved ) { |
88cb7938 | 579 | while( ( digit = dynamic_cast<AliPHOSDigit *>( nextdigit() ) ) ) { |
9f616d61 | 580 | if( IsInEmc(digit) ) |
88cb7938 | 581 | digitsC->Remove(digit) ; |
d15a28e7 | 582 | else |
88cb7938 | 583 | break ; |
584 | } | |
585 | notremoved = kFALSE ; | |
586 | } | |
587 | ||
d15a28e7 | 588 | } // else |
589 | ||
590 | nextdigit.Reset() ; | |
fad3e5b9 | 591 | |
d15a28e7 | 592 | AliPHOSDigit * digitN ; |
593 | index = 0 ; | |
9f616d61 | 594 | while (index < iDigitInCluster){ // scan over digits already in cluster |
88cb7938 | 595 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(clusterdigitslist[index]) ) ; |
596 | index++ ; | |
597 | while ( (digitN = dynamic_cast<AliPHOSDigit *>( nextdigit() ) ) ) { // scan over the reduced list of digits | |
598 | Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!! | |
d15a28e7 | 599 | switch (ineb ) { |
9f616d61 | 600 | case 0 : // not a neighbour |
88cb7938 | 601 | break ; |
602 | case 1 : // are neighbours | |
603 | clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), digitN->GetId() ) ) ; | |
604 | clusterdigitslist[iDigitInCluster] = digitN->GetIndexInList() ; | |
605 | iDigitInCluster++ ; | |
606 | digitsC->Remove(digitN) ; | |
607 | break ; | |
9f616d61 | 608 | case 2 : // too far from each other |
88cb7938 | 609 | goto endofloop; |
610 | } // switch | |
611 | ||
612 | } // while digitN | |
613 | ||
d15a28e7 | 614 | endofloop: ; |
88cb7938 | 615 | nextdigit.Reset() ; |
616 | ||
d15a28e7 | 617 | } // loop over cluster |
ad8cfaf4 | 618 | |
ad8cfaf4 | 619 | } // energy theshold |
ad8cfaf4 | 620 | |
31aa6d6c | 621 | |
d15a28e7 | 622 | } // while digit |
623 | ||
7b7c1533 | 624 | delete digitsC ; |
9688c1dd | 625 | |
9a1398dd | 626 | } |
627 | ||
628 | //____________________________________________________________________________ | |
a4e98857 | 629 | void AliPHOSClusterizerv1::MakeUnfolding() |
630 | { | |
631 | // Unfolds clusters using the shape of an ElectroMagnetic shower | |
9688c1dd | 632 | // Performs unfolding of all EMC/CPV clusters |
9a1398dd | 633 | |
88cb7938 | 634 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
fc12304f | 635 | |
7b7c1533 | 636 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
88cb7938 | 637 | |
638 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
639 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
fbf811ec | 640 | TClonesArray * digits = gime->Digits() ; |
7b7c1533 | 641 | |
a4e98857 | 642 | // Unfold first EMC clusters |
9a1398dd | 643 | if(fNumberOfEmcClusters > 0){ |
644 | ||
7b7c1533 | 645 | Int_t nModulesToUnfold = geom->GetNModules() ; |
9a1398dd | 646 | |
647 | Int_t numberofNotUnfolded = fNumberOfEmcClusters ; | |
648 | Int_t index ; | |
649 | for(index = 0 ; index < numberofNotUnfolded ; index++){ | |
650 | ||
88cb7938 | 651 | AliPHOSEmcRecPoint * emcRecPoint = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) ) ; |
9a1398dd | 652 | if(emcRecPoint->GetPHOSMod()> nModulesToUnfold) |
88cb7938 | 653 | break ; |
9a1398dd | 654 | |
655 | Int_t nMultipl = emcRecPoint->GetMultiplicity() ; | |
a0636361 | 656 | AliPHOSDigit ** maxAt = new AliPHOSDigit*[nMultipl] ; |
9a1398dd | 657 | Float_t * maxAtEnergy = new Float_t[nMultipl] ; |
7b7c1533 | 658 | Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fEmcLocMaxCut,digits) ; |
9a1398dd | 659 | |
660 | if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 | |
88cb7938 | 661 | UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; |
662 | emcRecPoints->Remove(emcRecPoint); | |
663 | emcRecPoints->Compress() ; | |
664 | index-- ; | |
665 | fNumberOfEmcClusters -- ; | |
666 | numberofNotUnfolded-- ; | |
9a1398dd | 667 | } |
c6bf27f2 | 668 | else{ |
669 | emcRecPoint->SetNExMax(1) ; //Only one local maximum | |
670 | } | |
9a1398dd | 671 | |
672 | delete[] maxAt ; | |
673 | delete[] maxAtEnergy ; | |
674 | } | |
675 | } | |
a4e98857 | 676 | // Unfolding of EMC clusters finished |
9a1398dd | 677 | |
678 | ||
a4e98857 | 679 | // Unfold now CPV clusters |
9a1398dd | 680 | if(fNumberOfCpvClusters > 0){ |
681 | ||
9688c1dd | 682 | Int_t nModulesToUnfold = geom->GetNModules() ; |
9a1398dd | 683 | |
684 | Int_t numberofCpvNotUnfolded = fNumberOfCpvClusters ; | |
685 | Int_t index ; | |
686 | for(index = 0 ; index < numberofCpvNotUnfolded ; index++){ | |
687 | ||
88cb7938 | 688 | AliPHOSRecPoint * recPoint = dynamic_cast<AliPHOSRecPoint *>( cpvRecPoints->At(index) ) ; |
9a1398dd | 689 | |
690 | if(recPoint->GetPHOSMod()> nModulesToUnfold) | |
88cb7938 | 691 | break ; |
9a1398dd | 692 | |
88cb7938 | 693 | AliPHOSEmcRecPoint * emcRecPoint = dynamic_cast<AliPHOSEmcRecPoint*>(recPoint) ; |
9a1398dd | 694 | |
695 | Int_t nMultipl = emcRecPoint->GetMultiplicity() ; | |
a0636361 | 696 | AliPHOSDigit ** maxAt = new AliPHOSDigit*[nMultipl] ; |
9a1398dd | 697 | Float_t * maxAtEnergy = new Float_t[nMultipl] ; |
7b7c1533 | 698 | Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fCpvLocMaxCut,digits) ; |
9a1398dd | 699 | |
700 | if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 | |
88cb7938 | 701 | UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; |
702 | cpvRecPoints->Remove(emcRecPoint); | |
703 | cpvRecPoints->Compress() ; | |
704 | index-- ; | |
705 | numberofCpvNotUnfolded-- ; | |
706 | fNumberOfCpvClusters-- ; | |
9a1398dd | 707 | } |
708 | ||
709 | delete[] maxAt ; | |
710 | delete[] maxAtEnergy ; | |
711 | } | |
712 | } | |
713 | //Unfolding of Cpv clusters finished | |
714 | ||
715 | } | |
716 | ||
9a1398dd | 717 | //____________________________________________________________________________ |
718 | Double_t AliPHOSClusterizerv1::ShowerShape(Double_t r) | |
719 | { | |
720 | // Shape of the shower (see PHOS TDR) | |
a4e98857 | 721 | // If you change this function, change also the gradient evaluation in ChiSquare() |
9a1398dd | 722 | |
723 | Double_t r4 = r*r*r*r ; | |
724 | Double_t r295 = TMath::Power(r, 2.95) ; | |
725 | Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ; | |
726 | return shape ; | |
727 | } | |
728 | ||
729 | //____________________________________________________________________________ | |
730 | void AliPHOSClusterizerv1::UnfoldCluster(AliPHOSEmcRecPoint * iniEmc, | |
88cb7938 | 731 | Int_t nMax, |
732 | AliPHOSDigit ** maxAt, | |
733 | Float_t * maxAtEnergy) | |
9a1398dd | 734 | { |
735 | // Performs the unfolding of a cluster with nMax overlapping showers | |
736 | ||
88cb7938 | 737 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
fc12304f | 738 | |
7b7c1533 | 739 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
88cb7938 | 740 | |
fbf811ec | 741 | const TClonesArray * digits = gime->Digits() ; |
742 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
743 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 744 | |
9a1398dd | 745 | Int_t nPar = 3 * nMax ; |
746 | Float_t * fitparameters = new Float_t[nPar] ; | |
747 | ||
748 | Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ; | |
749 | if( !rv ) { | |
88cb7938 | 750 | // Fit failed, return and remove cluster |
c6bf27f2 | 751 | iniEmc->SetNExMax(-1) ; |
9a1398dd | 752 | delete[] fitparameters ; |
753 | return ; | |
754 | } | |
755 | ||
756 | // create ufolded rec points and fill them with new energy lists | |
757 | // First calculate energy deposited in each sell in accordance with fit (without fluctuations): efit[] | |
758 | // and later correct this number in acordance with actual energy deposition | |
759 | ||
760 | Int_t nDigits = iniEmc->GetMultiplicity() ; | |
761 | Float_t * efit = new Float_t[nDigits] ; | |
7b7c1533 | 762 | Float_t xDigit=0.,zDigit=0.,distance=0. ; |
763 | Float_t xpar=0.,zpar=0.,epar=0. ; | |
9a1398dd | 764 | Int_t relid[4] ; |
7b7c1533 | 765 | AliPHOSDigit * digit = 0 ; |
9a1398dd | 766 | Int_t * emcDigits = iniEmc->GetDigitsList() ; |
767 | ||
768 | Int_t iparam ; | |
769 | Int_t iDigit ; | |
770 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ | |
88cb7938 | 771 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(emcDigits[iDigit] ) ) ; |
7b7c1533 | 772 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
773 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
9a1398dd | 774 | efit[iDigit] = 0; |
775 | ||
776 | iparam = 0 ; | |
777 | while(iparam < nPar ){ | |
778 | xpar = fitparameters[iparam] ; | |
779 | zpar = fitparameters[iparam+1] ; | |
780 | epar = fitparameters[iparam+2] ; | |
781 | iparam += 3 ; | |
782 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; | |
783 | distance = TMath::Sqrt(distance) ; | |
784 | efit[iDigit] += epar * ShowerShape(distance) ; | |
785 | } | |
786 | } | |
787 | ||
788 | ||
789 | // Now create new RecPoints and fill energy lists with efit corrected to fluctuations | |
790 | // so that energy deposited in each cell is distributed betwin new clusters proportionally | |
791 | // to its contribution to efit | |
792 | ||
793 | Float_t * emcEnergies = iniEmc->GetEnergiesList() ; | |
794 | Float_t ratio ; | |
795 | ||
796 | iparam = 0 ; | |
797 | while(iparam < nPar ){ | |
798 | xpar = fitparameters[iparam] ; | |
799 | zpar = fitparameters[iparam+1] ; | |
800 | epar = fitparameters[iparam+2] ; | |
801 | iparam += 3 ; | |
802 | ||
7b7c1533 | 803 | AliPHOSEmcRecPoint * emcRP = 0 ; |
9a1398dd | 804 | |
805 | if(iniEmc->IsEmc()){ //create new entries in fEmcRecPoints... | |
806 | ||
7b7c1533 | 807 | if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) |
88cb7938 | 808 | emcRecPoints->Expand(2*fNumberOfEmcClusters) ; |
9a1398dd | 809 | |
73a68ccb | 810 | (*emcRecPoints)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint("") ; |
88cb7938 | 811 | emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(fNumberOfEmcClusters) ) ; |
9a1398dd | 812 | fNumberOfEmcClusters++ ; |
c6bf27f2 | 813 | emcRP->SetNExMax((Int_t)nPar/3) ; |
9a1398dd | 814 | } |
815 | else{//create new entries in fCpvRecPoints | |
7b7c1533 | 816 | if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) |
88cb7938 | 817 | cpvRecPoints->Expand(2*fNumberOfCpvClusters) ; |
9a1398dd | 818 | |
73a68ccb | 819 | (*cpvRecPoints)[fNumberOfCpvClusters] = new AliPHOSCpvRecPoint("") ; |
88cb7938 | 820 | emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( cpvRecPoints->At(fNumberOfCpvClusters) ) ; |
9a1398dd | 821 | fNumberOfCpvClusters++ ; |
822 | } | |
823 | ||
824 | Float_t eDigit ; | |
825 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ | |
88cb7938 | 826 | digit = dynamic_cast<AliPHOSDigit*>( digits->At( emcDigits[iDigit] ) ) ; |
7b7c1533 | 827 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
828 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
9a1398dd | 829 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; |
830 | distance = TMath::Sqrt(distance) ; | |
831 | ratio = epar * ShowerShape(distance) / efit[iDigit] ; | |
832 | eDigit = emcEnergies[iDigit] * ratio ; | |
833 | emcRP->AddDigit( *digit, eDigit ) ; | |
88cb7938 | 834 | } |
9a1398dd | 835 | } |
836 | ||
837 | delete[] fitparameters ; | |
838 | delete[] efit ; | |
839 | ||
840 | } | |
841 | ||
842 | //_____________________________________________________________________________ | |
843 | void AliPHOSClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag) | |
844 | { | |
a4e98857 | 845 | // Calculates the Chi square for the cluster unfolding minimization |
9a1398dd | 846 | // Number of parameters, Gradient, Chi squared, parameters, what to do |
847 | ||
88cb7938 | 848 | TList * toMinuit = dynamic_cast<TList*>( gMinuit->GetObjectFit() ) ; |
9a1398dd | 849 | |
88cb7938 | 850 | AliPHOSEmcRecPoint * emcRP = dynamic_cast<AliPHOSEmcRecPoint*>( toMinuit->At(0) ) ; |
851 | TClonesArray * digits = dynamic_cast<TClonesArray*>( toMinuit->At(1) ) ; | |
9a1398dd | 852 | |
853 | ||
854 | ||
88cb7938 | 855 | // AliPHOSEmcRecPoint * emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( gMinuit->GetObjectFit() ) ; // EmcRecPoint to fit |
9a1398dd | 856 | |
857 | Int_t * emcDigits = emcRP->GetDigitsList() ; | |
858 | ||
7b7c1533 | 859 | Int_t nOdigits = emcRP->GetDigitsMultiplicity() ; |
9a1398dd | 860 | |
861 | Float_t * emcEnergies = emcRP->GetEnergiesList() ; | |
88cb7938 | 862 | |
863 | const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; | |
9a1398dd | 864 | fret = 0. ; |
865 | Int_t iparam ; | |
866 | ||
867 | if(iflag == 2) | |
868 | for(iparam = 0 ; iparam < nPar ; iparam++) | |
869 | Grad[iparam] = 0 ; // Will evaluate gradient | |
870 | ||
871 | Double_t efit ; | |
872 | ||
873 | AliPHOSDigit * digit ; | |
874 | Int_t iDigit ; | |
875 | ||
7b7c1533 | 876 | for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) { |
9a1398dd | 877 | |
88cb7938 | 878 | digit = dynamic_cast<AliPHOSDigit*>( digits->At( emcDigits[iDigit] ) ); |
9a1398dd | 879 | |
880 | Int_t relid[4] ; | |
881 | Float_t xDigit ; | |
882 | Float_t zDigit ; | |
883 | ||
884 | geom->AbsToRelNumbering(digit->GetId(), relid) ; | |
885 | ||
886 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
887 | ||
888 | if(iflag == 2){ // calculate gradient | |
889 | Int_t iParam = 0 ; | |
890 | efit = 0 ; | |
891 | while(iParam < nPar ){ | |
88cb7938 | 892 | Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ; |
893 | iParam++ ; | |
894 | distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ; | |
895 | distance = TMath::Sqrt( distance ) ; | |
896 | iParam++ ; | |
897 | efit += x[iParam] * ShowerShape(distance) ; | |
898 | iParam++ ; | |
9a1398dd | 899 | } |
88cb7938 | 900 | Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E) |
9a1398dd | 901 | iParam = 0 ; |
902 | while(iParam < nPar ){ | |
88cb7938 | 903 | Double_t xpar = x[iParam] ; |
904 | Double_t zpar = x[iParam+1] ; | |
905 | Double_t epar = x[iParam+2] ; | |
906 | Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ); | |
907 | Double_t shape = sum * ShowerShape(dr) ; | |
908 | Double_t r4 = dr*dr*dr*dr ; | |
909 | Double_t r295 = TMath::Power(dr,2.95) ; | |
910 | Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) + | |
911 | 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ; | |
912 | ||
913 | Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x | |
914 | iParam++ ; | |
915 | Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z | |
916 | iParam++ ; | |
917 | Grad[iParam] += shape ; // Derivative over energy | |
918 | iParam++ ; | |
9a1398dd | 919 | } |
920 | } | |
921 | efit = 0; | |
922 | iparam = 0 ; | |
923 | ||
924 | while(iparam < nPar ){ | |
925 | Double_t xpar = x[iparam] ; | |
926 | Double_t zpar = x[iparam+1] ; | |
927 | Double_t epar = x[iparam+2] ; | |
928 | iparam += 3 ; | |
929 | Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; | |
930 | distance = TMath::Sqrt(distance) ; | |
931 | efit += epar * ShowerShape(distance) ; | |
932 | } | |
933 | ||
88cb7938 | 934 | fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ; |
9a1398dd | 935 | // Here we assume, that sigma = sqrt(E) |
936 | } | |
83974468 | 937 | |
d15a28e7 | 938 | } |
939 | ||
940 | //____________________________________________________________________________ | |
88cb7938 | 941 | void AliPHOSClusterizerv1::Print()const |
d15a28e7 | 942 | { |
d1de15f5 | 943 | // Print clusterizer parameters |
944 | ||
21cd0c07 | 945 | TString message ; |
946 | TString taskName(GetName()) ; | |
947 | taskName.ReplaceAll(Version(), "") ; | |
948 | ||
949 | if( strcmp(GetName(), "") !=0 ) { | |
9a1398dd | 950 | // Print parameters |
21cd0c07 | 951 | message = "\n--------------- %s %s -----------\n" ; |
952 | message += "Clusterizing digits from the file: %s\n" ; | |
953 | message += " Branch: %s\n" ; | |
954 | message += " EMC Clustering threshold = %f\n" ; | |
955 | message += " EMC Local Maximum cut = %f\n" ; | |
956 | message += " EMC Logarothmic weight = %f\n" ; | |
957 | message += " CPV Clustering threshold = %f\n" ; | |
958 | message += " CPV Local Maximum cut = %f\n" ; | |
959 | message += " CPV Logarothmic weight = %f\n" ; | |
9a1398dd | 960 | if(fToUnfold) |
21cd0c07 | 961 | message += " Unfolding on\n" ; |
9a1398dd | 962 | else |
21cd0c07 | 963 | message += " Unfolding off\n" ; |
9a1398dd | 964 | |
21cd0c07 | 965 | message += "------------------------------------------------------------------" ; |
9a1398dd | 966 | } |
21cd0c07 | 967 | else |
968 | message = " AliPHOSClusterizerv1 not initialized " ; | |
969 | ||
351dd634 | 970 | AliInfo(Form("%s, %s %s %s %s %s %s %s %s %s %s", message.Data(), |
21cd0c07 | 971 | taskName.Data(), |
972 | GetTitle(), | |
973 | taskName.Data(), | |
974 | GetName(), | |
975 | fEmcClusteringThreshold, | |
976 | fEmcLocMaxCut, | |
977 | fW0, | |
978 | fCpvClusteringThreshold, | |
979 | fCpvLocMaxCut, | |
351dd634 | 980 | fW0CPV )) ; |
9a1398dd | 981 | } |
21cd0c07 | 982 | |
983 | ||
9a1398dd | 984 | //____________________________________________________________________________ |
a4e98857 | 985 | void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) |
986 | { | |
987 | // Prints list of RecPoints produced at the current pass of AliPHOSClusterizer | |
9a1398dd | 988 | |
88cb7938 | 989 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
990 | ||
991 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
992 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 993 | |
351dd634 | 994 | AliInfo(Form("\nevent %d \n Found %d EMC RecPoints and %d CPV RecPoints", |
995 | gAlice->GetEvNumber(), | |
996 | emcRecPoints->GetEntriesFast(), | |
997 | cpvRecPoints->GetEntriesFast() )) ; | |
88cb7938 | 998 | |
999 | fRecPointsInRun += emcRecPoints->GetEntriesFast() ; | |
1000 | fRecPointsInRun += cpvRecPoints->GetEntriesFast() ; | |
1001 | ||
11f9c5ff | 1002 | |
9a1398dd | 1003 | if(strstr(option,"all")) { |
709e117a | 1004 | printf("\n EMC clusters \n") ; |
1005 | printf("Index Ene(MeV) Multi Module X Y Z Lambdas_1 Lambda_2 # of prim Primaries list\n") ; | |
9a1398dd | 1006 | Int_t index ; |
7b7c1533 | 1007 | for (index = 0 ; index < emcRecPoints->GetEntries() ; index++) { |
1008 | AliPHOSEmcRecPoint * rp = (AliPHOSEmcRecPoint * )emcRecPoints->At(index) ; | |
9a1398dd | 1009 | TVector3 locpos; |
1010 | rp->GetLocalPosition(locpos); | |
9a1398dd | 1011 | Float_t lambda[2]; |
1012 | rp->GetElipsAxis(lambda); | |
9a1398dd | 1013 | Int_t * primaries; |
1014 | Int_t nprimaries; | |
1015 | primaries = rp->GetPrimaries(nprimaries); | |
709e117a | 1016 | printf("\n%6d %8.2f %3d %2d %4.1f %4.1f %4.1f %4f %4f %2d : ", |
11f9c5ff | 1017 | rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(), rp->GetPHOSMod(), |
1018 | locpos.X(), locpos.Y(), locpos.Z(), lambda[0], lambda[1], nprimaries) ; | |
3bf72d32 | 1019 | |
21cd0c07 | 1020 | for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) { |
709e117a | 1021 | printf("%d ", primaries[iprimary] ) ; |
21cd0c07 | 1022 | } |
709e117a | 1023 | printf("\n") ; |
1024 | } | |
1025 | ||
1026 | //Now plot CPV recPoints | |
1027 | printf("\n CPV clusters \n") ; | |
1028 | printf("Index Ene(MeV) Module X Y Z \n") ; | |
1029 | for (index = 0 ; index < cpvRecPoints->GetEntries() ; index++) { | |
2bb500e5 | 1030 | AliPHOSCpvRecPoint * rp = (AliPHOSCpvRecPoint * )cpvRecPoints->At(index) ; |
1031 | ||
1032 | TVector3 locpos; | |
1033 | rp->GetLocalPosition(locpos); | |
1034 | ||
1035 | printf("\n%6d %8.2f %2d %4.1f %4.1f %4.1f \n", | |
1036 | rp->GetIndexInList(), rp->GetEnergy(), rp->GetPHOSMod(), | |
1037 | locpos.X(), locpos.Y(), locpos.Z()) ; | |
88cb7938 | 1038 | } |
9a1398dd | 1039 | } |
d15a28e7 | 1040 | } |
9a1398dd | 1041 |