]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliCalorimeter.cxx
Close material file
[u/mrichter/AliRoot.git] / RALICE / AliCalorimeter.cxx
CommitLineData
4c039060 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
16/*
17$Log$
959fbac5 18Revision 1.2 1999/09/29 09:24:28 fca
19Introduction of the Copyright and cvs Log
20
4c039060 21*/
22
959fbac5 23///////////////////////////////////////////////////////////////////////////
24// Class AliCalorimeter
25// Description of a modular calorimeter system.
26// A matrix geometry is used in which a module is identified by (row,col).
27// Note : First module is identified as (1,1).
28//
29// This is the way to define and enter signals into a calorimeter :
30//
31// AliCalorimeter cal(10,15); // Calorimeter of 10x15 modules
32// // All module signals set to 0.
33// cal.AddSignal(5,7,85.4);
34// cal.AddSignal(5,7,25.9);
35// cal.AddSignal(3,5,1000);
36// cal.SetSignal(5,7,10.3);
37// cal.Reset(3,5); // Reset module (3,5) as being 'not fired'
38// // All module data are re-initialised.
39// cal.SetEdgeOn(1,1); // Declare module (1,1) as an 'edge module'
40// cal.SetDead(8,3);
41// cal.SetGain(2,8,3.2);
42//
43// Float_t vec[3]={6,1,20};
44// cal.SetPosition(2,8,vec,"car");
45//
46// Float_t loc[3]={-1,12,3};
47// cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto
48//
49// cal.Group(2); // Group 'fired' modules into clusters
50// // Perform grouping over 2 rings around the center
51// cal.Reset(); // Reset the complete calorimeter
52// // Normally to prepare for the next event data
53// // Note : Module gain, edge and dead flags remain
54//
55//--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht
56//- Modified: NvE 31-oct-1999 UU-SAP Utrecht
57///////////////////////////////////////////////////////////////////////////
58
d88f97cc 59#include "AliCalorimeter.h"
959fbac5 60
d88f97cc 61ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
62
63AliCalorimeter::AliCalorimeter()
64{
65// Default constructor, all parameters set to 0
66 fNrows=0;
67 fNcolumns=0;
68 fNsignals=0;
69 fNclusters=0;
70 fMatrix=0;
71 fClusters=0;
72 fModules=0;
73 fHmodules=0;
74 fHclusters=0;
75 fNvetos=0;
76 fVetos=0;
77}
78///////////////////////////////////////////////////////////////////////////
79AliCalorimeter::~AliCalorimeter()
80{
81// Destructor to delete memory allocated for matrix and cluster array
82 if (fMatrix)
83 {
84 for (Int_t i=0; i<fNrows; i++)
85 {
86 delete [] fMatrix[i];
87 }
88 delete [] fMatrix;
89 }
90 fMatrix=0;
91 if (fModules) delete fModules;
92 fModules=0;
93 if (fClusters)
94 {
95 fClusters->Delete();
96 delete fClusters;
97 fClusters=0;
98 }
99 if (fHmodules) delete fHmodules;
100 fHmodules=0;
101 if (fHclusters) delete fHclusters;
102 fHclusters=0;
103 if (fVetos)
104 {
105 fVetos->Delete();
106 delete fVetos;
107 fVetos=0;
108 }
109}
110///////////////////////////////////////////////////////////////////////////
111AliCalorimeter::AliCalorimeter(Int_t nrow, Int_t ncol)
112{
113// Create a calorimeter module matrix
114 fNrows=nrow;
115 fNcolumns=ncol;
116 fNsignals=0;
117 fNclusters=0;
118 fClusters=0;
119 fMatrix=new AliCalmodule*[nrow];
120 for (Int_t i=0; i<nrow; i++)
121 {
122 fMatrix[i]=new AliCalmodule[ncol];
123 }
124 // Mark the edge modules
125 for (Int_t j=0; j<ncol; j++)
126 {
127 fMatrix[0][j].SetEdgeOn();
128 fMatrix[nrow-1][j].SetEdgeOn();
129 }
130 for (Int_t k=0; k<nrow; k++)
131 {
132 fMatrix[k][0].SetEdgeOn();
133 fMatrix[k][ncol-1].SetEdgeOn();
134 }
135
136 fModules=new TObjArray(); // Default size, expanded automatically
137
138 fHmodules=0;
139 fHclusters=0;
140
141 fNvetos=0;
142 fVetos=0;
143}
144///////////////////////////////////////////////////////////////////////////
145Int_t AliCalorimeter::GetNrows()
146{
147// Provide the number of rows for the calorimeter module matrix
148 return fNrows;
149}
150///////////////////////////////////////////////////////////////////////////
151Int_t AliCalorimeter::GetNcolumns()
152{
153// Provide the number of columns for the calorimeter module matrix
154 return fNcolumns;
155}
156///////////////////////////////////////////////////////////////////////////
157void AliCalorimeter::SetSignal(Int_t row, Int_t col, Float_t sig)
158{
159// Set the signal for a certain calorimeter module
160
161 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
162
163 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
164 {
165 if (fMatrix[row-1][col-1].GetSignal() <= 0.) // only count new modules
166 {
167 fNsignals++;
168 fModules->Add(&(fMatrix[row-1][col-1]));
169 }
170 fMatrix[row-1][col-1].SetSignal(row,col,sig);
171 }
172 else
173 {
174 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
175 << " out of range." << endl;
176 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
177 }
178}
179///////////////////////////////////////////////////////////////////////////
180void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
181{
182// Add the signal to a certain calorimeter module
183
184 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
185
186 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
187 {
188 if (fMatrix[row-1][col-1].GetSignal() <= 0.) // only count new modules
189 {
190 fNsignals++;
191 fModules->Add(&(fMatrix[row-1][col-1]));
192 }
193 fMatrix[row-1][col-1].AddSignal(row,col,sig);
194 }
195 else
196 {
197 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
198 << " out of range." << endl;
199 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
200 }
201}
202///////////////////////////////////////////////////////////////////////////
203void AliCalorimeter::Reset(Int_t row, Int_t col)
204{
205// Reset the signal for a certain calorimeter module
206
207 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
208
209 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
210 {
211 fMatrix[row-1][col-1].SetSignal(row,col,0);
959fbac5 212 AliCalmodule* m=(AliCalmodule*)fModules->Remove(&(fMatrix[row-1][col-1]));
213 if (m)
214 {
215 fNsignals--;
216 fModules->Compress();
217 }
d88f97cc 218 }
219 else
220 {
221 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
222 << " out of range." << endl;
223 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
224 }
225}
226///////////////////////////////////////////////////////////////////////////
227void AliCalorimeter::Reset()
228{
229// Reset the signals for the complete calorimeter
230// Normally this is done to prepare for the data of the next event
231// Note : Module gains, edge and dead flags remain unchanged
232
233 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
234
235 fNsignals=0;
236 for (Int_t i=0; i<fNrows; i++)
237 {
238 for (Int_t j=0; j<fNcolumns; j++)
239 {
240 fMatrix[i][j].SetSignal(i+1,j+1,0);
241 }
242 }
243 if (fModules) fModules->Clear();
244
245 fNclusters=0;
246 if (fClusters)
247 {
248 fClusters->Delete();
249 delete fClusters;
250 fClusters=0;
251 }
252
253 fNvetos=0;
254 if (fVetos)
255 {
256 fVetos->Delete();
257 delete fVetos;
258 fVetos=0;
259 }
260}
261///////////////////////////////////////////////////////////////////////////
262Float_t AliCalorimeter::GetSignal(Int_t row, Int_t col)
263{
959fbac5 264// Provide the signal of a certain calorimeter module.
265// In case the module was marked dead, 0 is returned.
d88f97cc 266
267 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
268
269 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
270 {
959fbac5 271 Int_t dead=fMatrix[row-1][col-1].GetDeadValue();
272 Float_t signal=0;
273 if (!dead) signal=fMatrix[row-1][col-1].GetSignal();
274 return signal;
d88f97cc 275 }
276 else
277 {
278 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
279 << " out of range." << endl;
280 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
281 return 0;
282 }
283}
284///////////////////////////////////////////////////////////////////////////
285void AliCalorimeter::SetEdgeOn(Int_t row, Int_t col)
286{
287// Indicate a certain calorimeter module as 'edge module'
288
289 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
290
291 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
292 {
293 fMatrix[row-1][col-1].SetEdgeOn();
294 }
295 else
296 {
297 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
298 << " out of range." << endl;
299 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
300 }
301}
302///////////////////////////////////////////////////////////////////////////
303void AliCalorimeter::SetEdgeOff(Int_t row, Int_t col)
304{
305// Indicate a certain calorimeter module as 'non-edge module'
306
307 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
308
309 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
310 {
311 fMatrix[row-1][col-1].SetEdgeOff();
312 }
313 else
314 {
315 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
316 << " out of range." << endl;
317 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
318 }
319}
320///////////////////////////////////////////////////////////////////////////
321void AliCalorimeter::SetDead(Int_t row, Int_t col)
322{
323// Indicate a certain calorimeter module as 'dead module'
324
325 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
326
327 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
328 {
329 fMatrix[row-1][col-1].SetDead();
330
331 // Increase the 'edge value' of surrounding modules
332 Int_t rlow=row-1;
333 Int_t rup=row+1;
334 Int_t clow=col-1;
335 Int_t cup=col+1;
336
337 if (rlow < 1) rlow=row;
338 if (rup > fNrows) rup=fNrows;
339 if (clow < 1) clow=col;
340 if (cup > fNcolumns) cup=fNcolumns;
341
342 for (Int_t i=rlow; i<=rup; i++)
343 {
344 for (Int_t j=clow; j<=cup; j++)
345 {
346 fMatrix[i-1][j-1].EdgeUp();
347 }
348 }
349
350 // Correct the 'edge value' for the dead module itself
351 fMatrix[row-1][col-1].EdgeDown();
352 }
353 else
354 {
355 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
356 << " out of range." << endl;
357 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
358 }
359}
360///////////////////////////////////////////////////////////////////////////
361void AliCalorimeter::SetAlive(Int_t row, Int_t col)
362{
363// Indicate a certain calorimeter module as 'active module'
364
365 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
366
367 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
368 {
369 fMatrix[row-1][col-1].SetAlive();
370
371 // Decrease the 'edge value' of surrounding modules
372 Int_t rlow=row-1;
373 Int_t rup=row+1;
374 Int_t clow=col-1;
375 Int_t cup=col+1;
376
377 if (rlow < 1) rlow=row;
378 if (rup > fNrows) rup=fNrows;
379 if (clow < 1) clow=col;
380 if (cup > fNcolumns) cup=fNcolumns;
381
382 for (Int_t i=rlow; i<=rup; i++)
383 {
384 for (Int_t j=clow; j<=cup; j++)
385 {
386 fMatrix[i-1][j-1].EdgeDown();
387 }
388 }
389
390 // Correct the 'edge value' for the dead module itself
391 fMatrix[row-1][col-1].EdgeUp();
392 }
393 else
394 {
395 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
396 << " out of range." << endl;
397 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
398 }
399}
400///////////////////////////////////////////////////////////////////////////
401void AliCalorimeter::SetGain(Int_t row, Int_t col, Float_t gain)
402{
403// Set the gain value for a certain calorimeter module
404
405 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
406
407 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
408 {
409 fMatrix[row-1][col-1].SetGain(gain);
410 }
411 else
412 {
413 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
414 << " out of range." << endl;
415 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
416 }
417}
418///////////////////////////////////////////////////////////////////////////
419void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
420{
421// Set the position in user coordinates for a certain calorimeter module
422
423 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
424
425 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
426 {
427 fMatrix[row-1][col-1].SetPosition(vec,f);
428 }
429 else
430 {
431 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
432 << " out of range." << endl;
433 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
434 }
435}
436///////////////////////////////////////////////////////////////////////////
437Int_t AliCalorimeter::GetEdgeValue(Int_t row, Int_t col)
438{
439// Provide the value of the edge flag of a certain module
440
441 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
442
443 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
444 {
445 return fMatrix[row-1][col-1].GetEdgeValue();
446 }
447 else
448 {
449 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
450 << " out of range." << endl;
451 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
452 return 0;
453 }
454}
455///////////////////////////////////////////////////////////////////////////
456Int_t AliCalorimeter::GetDeadValue(Int_t row, Int_t col)
457{
458// Provide the value of the dead flag of a certain module
459
460 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
461
462 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
463 {
464 return fMatrix[row-1][col-1].GetDeadValue();
465 }
466 else
467 {
468 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
469 << " out of range." << endl;
470 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
471 return 0;
472 }
473}
474///////////////////////////////////////////////////////////////////////////
475Float_t AliCalorimeter::GetGain(Int_t row, Int_t col)
476{
477// Provide the gain value of a certain module
478
479 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
480
481 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
482 {
483 return fMatrix[row-1][col-1].GetGain();
484 }
485 else
486 {
487 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
488 << " out of range." << endl;
489 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
490 return 0;
491 }
492}
493///////////////////////////////////////////////////////////////////////////
494void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
495{
496// Return the position in user coordinates for a certain calorimeter module
497
498 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
499
500 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
501 {
502 fMatrix[row-1][col-1].GetPosition(vec,f);
503 }
504 else
505 {
506 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
507 << " out of range." << endl;
508 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
509 }
510}
511///////////////////////////////////////////////////////////////////////////
512Float_t AliCalorimeter::GetClusteredSignal(Int_t row, Int_t col)
513{
514// Provide the module signal after clustering
515
516 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
517
518 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
519 {
520 return fMatrix[row-1][col-1].GetClusteredSignal();
521 }
522 else
523 {
524 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
525 << " out of range." << endl;
526 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
527 return 0;
528 }
529}
530///////////////////////////////////////////////////////////////////////////
531Int_t AliCalorimeter::GetNsignals()
532{
533// Provide the number of modules that contain a signal
534// Note : The number of modules marked 'dead' but which had a signal
535// are included.
536 return fNsignals;
537}
538///////////////////////////////////////////////////////////////////////////
539void AliCalorimeter::Group(Int_t n)
540{
541// Group the individual modules into clusters
542// Module signals of n rings around the central module will be grouped
543
544 if (fNsignals > 0) // Directly return if no modules fired
545 {
546 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
547
548 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
549
550 // Order the modules with decreasing signal
959fbac5 551 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
552 Int_t nord=0;
553 Sortm(ordered,nord);
d88f97cc 554
555 // Clustering of modules. Start with the highest signal.
556 if (fClusters)
557 {
558 fClusters->Delete();
559 delete fClusters;
560 fClusters=0;
561 }
562 fClusters=new TObjArray();
563 fNclusters=0;
564 Int_t row=0;
565 Int_t col=0;
566 AliCalcluster* c=0;
959fbac5 567 for (Int_t i=0; i<nord; i++)
d88f97cc 568 {
959fbac5 569 row=ordered[i]->GetRow(); // row number of cluster center
570 col=ordered[i]->GetColumn(); // column number of cluster center
d88f97cc 571 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
572 {
573 // only use modules not yet used in a cluster
574 if (fMatrix[row-1][col-1].GetClusteredSignal() > 0.)
575 {
576 c=new AliCalcluster;
577 c->Start(fMatrix[row-1][col-1]); // module to start the cluster
578 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
579 {
580 fClusters->Add(c);
581 fNclusters++; // update cluster counter
582 AddRing(row,col,n); // add signals of n rings around the center
583 }
584 else
585 {
586 if (c) delete c;
587 c=0;
588 }
589 }
590 }
591 }
592
593 // Delete the temp. array
959fbac5 594 if (ordered)
595 {
596 for (Int_t j=0; j<nord; j++)
597 {
598 ordered[j]=0;
599 }
600 delete [] ordered;
601 }
d88f97cc 602 }
603}
604///////////////////////////////////////////////////////////////////////////
959fbac5 605void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
d88f97cc 606{
607// Order the modules with decreasing signal
608
959fbac5 609 nord=0;
d88f97cc 610 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
611 {
612 for (Int_t ii=0; ii<fNcolumns; ii++)
613 {
959fbac5 614 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
d88f97cc 615
616 if (nord == 0) // store the first module with a signal at the first ordered position
617 {
618 nord++;
959fbac5 619 ordered[nord-1]=&(fMatrix[i][ii]);
d88f97cc 620 continue;
621 }
622
623 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
624 {
625 if (j == nord) // module has smallest signal seen so far
626 {
627 nord++;
959fbac5 628 ordered[j]=&(fMatrix[i][ii]); // add module at the end
d88f97cc 629 break; // go for next matrix module
630 }
631
959fbac5 632 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
d88f97cc 633
634 nord++;
959fbac5 635 for (Int_t k=nord-1; k>j; k--) // create empty position
636 {
637 ordered[k]=ordered[k-1];
638 }
639 ordered[j]=&(fMatrix[i][ii]); // put module at empty position
d88f97cc 640 break; // go for next matrix module
641 }
642 }
643 }
644}
645///////////////////////////////////////////////////////////////////////////
646void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
647{
648// Add module signals of 1 ring around (row,col) to current cluster
649// n denotes the maximum number of rings around cluster center
650// Note : This function is used recursively
651
652 if (n >= 1) // Check if any rings left for recursive calls
653 {
654 Float_t signal=GetSignal(row,col); // signal of (row,col) module
655
656 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
657 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
658 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
659 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
660
661 for (Int_t i=lrow; i<=urow; i++)
662 {
663 for (Int_t j=lcol; j<=ucol; j++)
664 {
665 // add module(i,j) to cluster if the signal <= signal(row,col)
959fbac5 666 if (GetSignal(i,j) <= signal)
d88f97cc 667 {
668 ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(fMatrix[i-1][j-1]);
669 }
670 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
671 }
672 }
673 }
674}
675///////////////////////////////////////////////////////////////////////////
676Int_t AliCalorimeter::GetNclusters()
677{
678// Provide the number of clusters
679 return fNclusters;
680}
681///////////////////////////////////////////////////////////////////////////
682AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
683{
684// Provide cluster number j
685// Note : j=1 denotes the first cluster
686 if ((j >= 1) && (j <= fNclusters))
687 {
688 return (AliCalcluster*)fClusters->At(j-1);
689 }
690 else
691 {
692 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
693 << " out of range." << endl;
694 cout << " -- Cluster number 1 (if any) returned " << endl;
695 return (AliCalcluster*)fClusters->At(0);
696 }
697}
698///////////////////////////////////////////////////////////////////////////
699AliCalmodule* AliCalorimeter::GetModule(Int_t j)
700{
701// Provide 'fired' module number j
702// Note : j=1 denotes the first 'fired' module
703 if ((j >= 1) && (j <= fNsignals))
704 {
705 return (AliCalmodule*)fModules->At(j-1);
706 }
707 else
708 {
709 cout << " *AliCalorimeter::GetModule* module number : " << j
710 << " out of range." << endl;
711 cout << " -- Fired module number 1 (if any) returned " << endl;
712 return (AliCalmodule*)fModules->At(0);
713 }
714}
715///////////////////////////////////////////////////////////////////////////
959fbac5 716AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
717{
718// Provide access to module (row,col).
719// Note : first module is at (1,1).
720
721 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
722
723 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
724 {
725 return &(fMatrix[row-1][col-1]);
726 }
727 else
728 {
729 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
730 << " out of range." << endl;
731 return 0;
732 }
733}
734///////////////////////////////////////////////////////////////////////////
d88f97cc 735TH2F* AliCalorimeter::DrawModules()
736{
737// Provide a lego plot of the module signals
738
739 if (fHmodules)
740 {
741 fHmodules->Reset();
742 }
743 else
744 {
745 fHmodules=new TH2F("fHmodules","Module signals",
746 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
747
748 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
749 }
750
751 AliCalmodule* m;
752 Float_t row,col,signal;
959fbac5 753 Int_t dead;
d88f97cc 754 for (Int_t i=0; i<fNsignals; i++)
755 {
756 m=(AliCalmodule*)fModules->At(i);
757 if (m)
758 {
759 row=float(m->GetRow());
760 col=float(m->GetColumn());
959fbac5 761 dead=m->GetDeadValue();
762 signal=0;
763 if (!dead) signal=m->GetSignal();
d88f97cc 764 if (signal>0.) fHmodules->Fill(col,row,signal);
765 }
766 }
767
768 fHmodules->Draw("lego");
769 return fHmodules;
770}
771///////////////////////////////////////////////////////////////////////////
772TH2F* AliCalorimeter::DrawClusters()
773{
774// Provide a lego plot of the cluster signals
775
776 if (fHclusters)
777 {
778 fHclusters->Reset();
779 }
780 else
781 {
782 fHclusters=new TH2F("fHclusters","Cluster signals",
783 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
784
785 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
786 }
787
788 AliCalcluster* c;
789 Float_t row,col,signal;
790 for (Int_t i=0; i<fNclusters; i++)
791 {
792 c=(AliCalcluster*)fClusters->At(i);
793 if (c)
794 {
795 row=float(c->GetRow());
796 col=float(c->GetColumn());
797 signal=c->GetSignal();
798 if (signal>0.) fHclusters->Fill(col,row,signal);
799 }
800 }
801
802 fHclusters->Draw("lego");
803 return fHclusters;
804}
805///////////////////////////////////////////////////////////////////////////
806void AliCalorimeter::LoadMatrix()
807{
808// Load the Calorimeter module matrix data back from the TObjArray
959fbac5 809
d88f97cc 810 // Create the module matrix space
811 if (fMatrix)
812 {
813 for (Int_t k=0; k<fNrows; k++)
814 {
815 delete [] fMatrix[k];
816 }
817 delete [] fMatrix;
818 }
819 fMatrix=new AliCalmodule*[fNrows];
820 for (Int_t i=0; i<fNrows; i++)
821 {
822 fMatrix[i]=new AliCalmodule[fNcolumns];
823 }
824
825 // Copy the module data back into the matrix
959fbac5 826 AliCalmodule* m=0;
827 Int_t row=0;
828 Int_t col=0;
829 Int_t nsig=0;
830 if (fModules) nsig=fModules->GetSize();
831 for (Int_t j=0; j<nsig; j++)
d88f97cc 832 {
833 m=(AliCalmodule*)fModules->At(j);
959fbac5 834 if (m)
835 {
836 row=m->GetRow();
837 col=m->GetColumn();
838 fMatrix[row-1][col-1]=*m;
839 fModules->AddAt(&(fMatrix[row-1][col-1]),j); // Store new pointer
840 }
d88f97cc 841 }
959fbac5 842
d88f97cc 843}
844///////////////////////////////////////////////////////////////////////////
845void AliCalorimeter::Ungroup()
846{
847// Set the module signals back to the non-clustered situation
848
849 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
850
851 Float_t signal=0;
852 for (Int_t i=0; i<fNrows; i++)
853 {
854 for (Int_t j=0; j<fNcolumns; j++)
855 {
856 signal=fMatrix[i][j].GetSignal();
857 fMatrix[i][j].SetClusteredSignal(signal);
858 }
859 }
860}
861///////////////////////////////////////////////////////////////////////////
862void AliCalorimeter::AddVetoSignal(Float_t* r,TString f,Float_t s)
863{
864// Associate an (extrapolated) AliSignal at location r as veto to the cal.
865// Note : The default signal value (s) is 0
866 if (!fVetos)
867 {
868 fNvetos=0;
869 fVetos=new TObjArray();
870 }
871
872 fVetos->Add(new AliSignal);
873 fNvetos++;
874
875 ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
876 ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
877}
878///////////////////////////////////////////////////////////////////////////
879Int_t AliCalorimeter::GetNvetos()
880{
881// Provide the number of veto signals associated to the calorimeter
882 return fNvetos;
883}
884///////////////////////////////////////////////////////////////////////////
885AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
886{
887// Provide access to the i-th veto signal of this calorimeter
888// Note : The first hit corresponds to i=1
889
890 if (i>0 && i<=fNvetos)
891 {
892 return (AliSignal*)fVetos->At(i-1);
893 }
894 else
895 {
896 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
897 << " out of range." << endl;
898 cout << " --- First signal (if any) returned." << endl;
899 return (AliSignal*)fVetos->At(0);
900 }
901}
902///////////////////////////////////////////////////////////////////////////