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