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