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