1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.3 1999/11/03 14:23:17 fca
19 New version of RALICE introduced
21 Revision 1.2 1999/09/29 09:24:28 fca
22 Introduction of the Copyright and cvs Log
26 ///////////////////////////////////////////////////////////////////////////
27 // Class AliCalorimeter
28 // Description of a modular calorimeter system.
29 // A matrix geometry is used in which a module is identified by (row,col).
30 // Note : First module is identified as (1,1).
32 // This is the way to define and enter signals into a calorimeter :
34 // AliCalorimeter cal(10,15); // Calorimeter of 10x15 modules
35 // // All module signals set to 0.
36 // cal.AddSignal(5,7,85.4);
37 // cal.AddSignal(5,7,25.9);
38 // cal.AddSignal(3,5,1000);
39 // cal.SetSignal(5,7,10.3);
40 // cal.Reset(3,5); // Reset module (3,5) as being 'not fired'
41 // // All module data are re-initialised.
42 // cal.SetEdgeOn(1,1); // Declare module (1,1) as an 'edge module'
44 // cal.SetGain(2,8,3.2);
46 // Float_t vec[3]={6,1,20};
47 // cal.SetPosition(2,8,vec,"car");
49 // Float_t loc[3]={-1,12,3};
50 // cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto
52 // cal.Group(2); // Group 'fired' modules into clusters
53 // // Perform grouping over 2 rings around the center
54 // cal.Reset(); // Reset the complete calorimeter
55 // // Normally to prepare for the next event data
56 // // Note : Module gain, edge and dead flags remain
58 //--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht
59 //- Modified: NvE 03-mar-2000 UU-SAP Utrecht
60 ///////////////////////////////////////////////////////////////////////////
62 #include "AliCalorimeter.h"
64 ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
66 AliCalorimeter::AliCalorimeter()
68 // Default constructor, all parameters set to 0
84 ///////////////////////////////////////////////////////////////////////////
85 AliCalorimeter::~AliCalorimeter()
87 // Destructor to delete memory allocated to the various arrays and matrix
116 if (fMatrix || fPositions)
118 for (Int_t i=0; i<fNrows; i++)
120 for (Int_t j=0; j<fNcolumns; j++)
123 if (fPositions[i][j]) delete fPositions[i][j];
133 delete [] fPositions;
148 ///////////////////////////////////////////////////////////////////////////
149 AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol)
151 // Create a calorimeter module matrix
157 fAttributes=new TMatrix(nrow,ncol);
158 fGains=new TMatrix(nrow,ncol);
159 fMatrix=new AliCalmodule**[nrow];
160 fPositions=new AliPosition**[nrow];
161 for (Int_t row=0; row<nrow; row++)
163 fMatrix[row]=new AliCalmodule*[ncol];
164 fPositions[row]=new AliPosition*[ncol];
165 // Initialise the various matrices
166 for (Int_t col=0; col<ncol; col++)
169 fPositions[row][col]=0;
170 (*fGains)(row,col)=1;
171 (*fAttributes)(row,col)=0;
175 // Mark the edge modules
176 for (Int_t j=0; j<ncol; j++)
178 (*fAttributes)(0,j)=10;
179 (*fAttributes)(nrow-1,j)=10;
181 for (Int_t i=0; i<nrow; i++)
183 (*fAttributes)(i,0)=10;
184 (*fAttributes)(i,ncol-1)=10;
187 fModules=new TObjArray(); // Default size, expanded automatically
195 ///////////////////////////////////////////////////////////////////////////
196 Int_t AliCalorimeter::GetNrows()
198 // Provide the number of rows for the calorimeter module matrix
201 ///////////////////////////////////////////////////////////////////////////
202 Int_t AliCalorimeter::GetNcolumns()
204 // Provide the number of columns for the calorimeter module matrix
207 ///////////////////////////////////////////////////////////////////////////
208 void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
210 // Set the signal for a certain calorimeter module
212 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
214 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
216 AliCalmodule* m=fMatrix[row-1][col-1];
217 if (!m) // only count new modules
221 AliPosition* r=fPositions[row-1][col-1];
222 if (r) m->SetPosition(*r);
224 fMatrix[row-1][col-1]=m;
226 m->SetSignal(row,col,sig);
230 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
231 << " out of range." << endl;
232 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
235 ///////////////////////////////////////////////////////////////////////////
236 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
238 // Add the signal to a certain calorimeter module
240 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
242 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
244 AliCalmodule* m=fMatrix[row-1][col-1];
245 if (!m) // only count new modules
247 SetSignal(row,col,sig);
251 m->AddSignal(row,col,sig);
256 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
257 << " out of range." << endl;
258 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
261 ///////////////////////////////////////////////////////////////////////////
262 void AliCalorimeter::AddSignal(AliCalmodule* mod)
264 // Add the signal of module mod to the current calorimeter data.
265 // This enables mixing of calorimeter data of various events.
267 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
269 Int_t row=mod->GetRow();
270 Int_t col=mod->GetColumn();
271 Float_t sig=mod->GetSignal();
272 AliPosition r=mod->GetPosition();
274 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
276 AliCalmodule* m=fMatrix[row-1][col-1];
277 if (!m) // No module existed yet at this position
282 fMatrix[row-1][col-1]=m;
285 m->AddSignal(row,col,sig);
286 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition(r);
290 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
291 << " out of range." << endl;
292 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
295 ///////////////////////////////////////////////////////////////////////////
296 void AliCalorimeter::Reset(Int_t row,Int_t col)
298 // Reset the signal for a certain calorimeter module
300 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
302 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
304 AliCalmodule* m=fMatrix[row-1][col-1];
309 fModules->Compress();
311 fMatrix[row-1][col-1]=0;
316 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
317 << " out of range." << endl;
318 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
321 ///////////////////////////////////////////////////////////////////////////
322 void AliCalorimeter::Reset()
324 // Reset the signals for the complete calorimeter
325 // Normally this is done to prepare for the data of the next event
326 // Note : Module gains, edge and dead flags remain unchanged
328 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
331 if (fModules) fModules->Delete();
332 for (Int_t i=0; i<fNrows; i++)
334 for (Int_t j=0; j<fNcolumns; j++)
356 ///////////////////////////////////////////////////////////////////////////
357 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
359 // Provide the signal of a certain calorimeter module.
360 // In case the module was marked dead, 0 is returned.
362 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
364 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
367 AliCalmodule* m=fMatrix[row-1][col-1];
370 Int_t dead=m->GetDeadValue();
371 if (!dead) signal=m->GetSignal();
377 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
378 << " out of range." << endl;
379 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
383 ///////////////////////////////////////////////////////////////////////////
384 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
386 // Indicate a certain calorimeter module as 'edge module'
388 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
390 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
392 Float_t word=(*fAttributes)(row-1,col-1);
393 Int_t iword=int(word+0.1);
396 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
400 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
401 << " out of range." << endl;
402 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
405 ///////////////////////////////////////////////////////////////////////////
406 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
408 // Indicate a certain calorimeter module as 'non-edge module'
410 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
412 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
414 Float_t word=(*fAttributes)(row-1,col-1);
415 Int_t iword=int(word+0.1);
418 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
422 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
423 << " out of range." << endl;
424 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
427 ///////////////////////////////////////////////////////////////////////////
428 void AliCalorimeter::SetDead(Int_t row,Int_t col)
430 // Indicate a certain calorimeter module as 'dead module'
432 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
434 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
436 Float_t word=(*fAttributes)(row-1,col-1);
437 Int_t iword=int(word+0.1);
440 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
441 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
443 // Increase the 'edge value' of surrounding modules
449 if (rlow < 1) rlow=row;
450 if (rup > fNrows) rup=fNrows;
451 if (clow < 1) clow=col;
452 if (cup > fNcolumns) cup=fNcolumns;
454 for (Int_t i=rlow; i<=rup; i++)
456 for (Int_t j=clow; j<=cup; j++)
458 if (i!=row || j!=col) // No increase of edge value for the dead module itself
460 word=(*fAttributes)(i-1,j-1);
465 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
472 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
473 << " out of range." << endl;
474 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
477 ///////////////////////////////////////////////////////////////////////////
478 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
480 // Indicate a certain calorimeter module as 'active module'
482 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
484 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
486 Float_t word=(*fAttributes)(row-1,col-1);
487 Int_t iword=int(word+0.1);
490 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
491 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
493 // Decrease the 'edge value' of surrounding modules
499 if (rlow < 1) rlow=row;
500 if (rup > fNrows) rup=fNrows;
501 if (clow < 1) clow=col;
502 if (cup > fNcolumns) cup=fNcolumns;
504 for (Int_t i=rlow; i<=rup; i++)
506 for (Int_t j=clow; j<=cup; j++)
508 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
510 word=(*fAttributes)(i-1,j-1);
515 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
522 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
523 << " out of range." << endl;
524 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
527 ///////////////////////////////////////////////////////////////////////////
528 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
530 // Set the gain value for a certain calorimeter module
532 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
534 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
536 (*fGains)(row-1,col-1)=gain;
537 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
541 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
542 << " out of range." << endl;
543 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
546 ///////////////////////////////////////////////////////////////////////////
547 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
549 // Set the position in user coordinates for a certain calorimeter module
551 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
553 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
555 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
556 (fPositions[row-1][col-1])->SetVector(vec,f);
557 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
561 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
562 << " out of range." << endl;
563 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
566 ///////////////////////////////////////////////////////////////////////////
567 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
569 // Set the position for a certain calorimeter module
571 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
573 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
575 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
576 (fPositions[row-1][col-1])->SetPosition(r);
577 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
581 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
582 << " out of range." << endl;
583 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
586 ///////////////////////////////////////////////////////////////////////////
587 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
589 // Provide the value of the edge flag of a certain module
591 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
593 Float_t word=(*fAttributes)(row-1,col-1);
594 Int_t iword=int(word+0.1);
600 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
601 << " out of range." << endl;
602 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
606 ///////////////////////////////////////////////////////////////////////////
607 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
609 // Provide the value of the dead flag of a certain module
611 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
613 Float_t word=(*fAttributes)(row-1,col-1);
614 Int_t iword=int(word+0.1);
620 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
621 << " out of range." << endl;
622 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
626 ///////////////////////////////////////////////////////////////////////////
627 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
629 // Provide the gain value of a certain module
631 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
633 return (*fGains)(row-1,col-1);
637 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
638 << " out of range." << endl;
639 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
643 ///////////////////////////////////////////////////////////////////////////
644 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
646 // Return the position in user coordinates for a certain calorimeter module
648 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
650 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
652 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
653 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
657 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
658 << " out of range." << endl;
659 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
662 ///////////////////////////////////////////////////////////////////////////
663 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
665 // Access to the position of a certain calorimeter module
667 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
669 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
671 return fPositions[row-1][col-1];
675 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
676 << " out of range." << endl;
677 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
681 ///////////////////////////////////////////////////////////////////////////
682 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
684 // Provide the module signal after clustering
686 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
688 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
690 if (fMatrix[row-1][col-1])
692 return (fMatrix[row-1][col-1])->GetClusteredSignal();
701 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
702 << " out of range." << endl;
703 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
707 ///////////////////////////////////////////////////////////////////////////
708 Int_t AliCalorimeter::GetNsignals()
710 // Provide the number of modules that contain a signal
711 // Note : The number of modules marked 'dead' but which had a signal
715 ///////////////////////////////////////////////////////////////////////////
716 void AliCalorimeter::Group(Int_t n)
718 // Group the individual modules into clusters
719 // Module signals of n rings around the central module will be grouped
721 if (fNsignals > 0) // Directly return if no modules fired
723 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
725 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
727 // Order the modules with decreasing signal
728 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
732 // Clustering of modules. Start with the highest signal.
739 fClusters=new TObjArray();
745 for (Int_t i=0; i<nord; i++)
747 row=ordered[i]->GetRow(); // row number of cluster center
748 col=ordered[i]->GetColumn(); // column number of cluster center
749 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
751 m=fMatrix[row-1][col-1];
754 // only use modules not yet used in a cluster
755 if (m->GetClusteredSignal() > 0.)
757 Int_t edge=GetEdgeValue(row,col);
759 if (!edge) c->Start(*m); // module to start the cluster if not on edge
760 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
763 fNclusters++; // update cluster counter
764 AddRing(row,col,n); // add signals of n rings around the center
775 // Delete the temp. array
778 for (Int_t j=0; j<nord; j++)
786 ///////////////////////////////////////////////////////////////////////////
787 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
789 // Order the modules with decreasing signal
792 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
794 for (Int_t ii=0; ii<fNcolumns; ii++)
796 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
798 if (nord == 0) // store the first module with a signal at the first ordered position
801 ordered[nord-1]=fMatrix[i][ii];
805 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
807 if (j == nord) // module has smallest signal seen so far
810 ordered[j]=fMatrix[i][ii]; // add module at the end
811 break; // go for next matrix module
814 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
817 for (Int_t k=nord-1; k>j; k--) // create empty position
819 ordered[k]=ordered[k-1];
821 ordered[j]=fMatrix[i][ii]; // put module at empty position
822 break; // go for next matrix module
827 ///////////////////////////////////////////////////////////////////////////
828 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
830 // Add module signals of 1 ring around (row,col) to current cluster
831 // n denotes the maximum number of rings around cluster center
832 // Note : This function is used recursively
834 if (n >= 1) // Check if any rings left for recursive calls
836 Float_t signal=GetSignal(row,col); // signal of (row,col) module
838 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
839 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
840 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
841 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
843 for (Int_t i=lrow; i<=urow; i++)
845 for (Int_t j=lcol; j<=ucol; j++)
847 // add module(i,j) to cluster if the signal <= signal(row,col)
848 if (GetSignal(i,j) <= signal)
850 AliCalmodule* m=fMatrix[i-1][j-1];
851 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
853 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
858 ///////////////////////////////////////////////////////////////////////////
859 Int_t AliCalorimeter::GetNclusters()
861 // Provide the number of clusters
864 ///////////////////////////////////////////////////////////////////////////
865 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
867 // Provide cluster number j
868 // Note : j=1 denotes the first cluster
869 if ((j >= 1) && (j <= fNclusters))
871 return (AliCalcluster*)fClusters->At(j-1);
875 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
876 << " out of range." << endl;
877 cout << " -- Cluster number 1 (if any) returned " << endl;
878 return (AliCalcluster*)fClusters->At(0);
881 ///////////////////////////////////////////////////////////////////////////
882 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
884 // Provide 'fired' module number j
885 // Note : j=1 denotes the first 'fired' module
886 if ((j >= 1) && (j <= fNsignals))
888 return (AliCalmodule*)fModules->At(j-1);
892 cout << " *AliCalorimeter::GetModule* module number : " << j
893 << " out of range." << endl;
894 cout << " -- Fired module number 1 (if any) returned " << endl;
895 return (AliCalmodule*)fModules->At(0);
898 ///////////////////////////////////////////////////////////////////////////
899 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
901 // Provide access to module (row,col).
902 // Note : first module is at (1,1).
904 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
906 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
908 return fMatrix[row-1][col-1];
912 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
913 << " out of range." << endl;
917 ///////////////////////////////////////////////////////////////////////////
918 TH2F* AliCalorimeter::DrawModules()
920 // Provide a lego plot of the module signals
928 fHmodules=new TH2F("fHmodules","Module signals",
929 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
931 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
935 Float_t row,col,signal;
937 for (Int_t i=0; i<fNsignals; i++)
939 m=(AliCalmodule*)fModules->At(i);
942 row=float(m->GetRow());
943 col=float(m->GetColumn());
944 dead=m->GetDeadValue();
946 if (!dead) signal=m->GetSignal();
947 if (signal>0.) fHmodules->Fill(col,row,signal);
951 fHmodules->Draw("lego");
954 ///////////////////////////////////////////////////////////////////////////
955 TH2F* AliCalorimeter::DrawClusters()
957 // Provide a lego plot of the cluster signals
965 fHclusters=new TH2F("fHclusters","Cluster signals",
966 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
968 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
972 Float_t row,col,signal;
973 for (Int_t i=0; i<fNclusters; i++)
975 c=(AliCalcluster*)fClusters->At(i);
978 row=float(c->GetRow());
979 col=float(c->GetColumn());
980 signal=c->GetSignal();
981 if (signal>0.) fHclusters->Fill(col,row,signal);
985 fHclusters->Draw("lego");
988 ///////////////////////////////////////////////////////////////////////////
989 void AliCalorimeter::LoadMatrix()
991 // Load the Calorimeter module matrix data back from the TObjArray
993 // Initialise the module matrix
996 fMatrix=new AliCalmodule**[fNrows];
997 for (Int_t i=0; i<fNrows; i++)
999 fMatrix[i]=new AliCalmodule*[fNcolumns];
1003 // Initialise the position matrix
1006 fPositions=new AliPosition**[fNrows];
1007 for (Int_t j=0; j<fNrows; j++)
1009 fPositions[j]=new AliPosition*[fNcolumns];
1013 for (Int_t jrow=0; jrow<fNrows; jrow++)
1015 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1017 fMatrix[jrow][jcol]=0;
1018 fPositions[jrow][jcol]=0;
1022 // Copy the module pointers back into the matrix
1027 if (fModules) nsig=fModules->GetEntries();
1028 for (Int_t j=0; j<nsig; j++)
1030 m=(AliCalmodule*)fModules->At(j);
1035 AliPosition r=m->GetPosition();
1036 fMatrix[row-1][col-1]=m;
1037 fPositions[row-1][col-1]=new AliPosition(r);
1041 ///////////////////////////////////////////////////////////////////////////
1042 void AliCalorimeter::Ungroup()
1044 // Set the module signals back to the non-clustered situation
1046 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1049 if (fModules) nsig=fModules->GetEntries();
1053 for (Int_t j=0; j<nsig; j++)
1055 m=(AliCalmodule*)fModules->At(j);
1058 signal=m->GetSignal();
1059 m->SetClusteredSignal(signal);
1063 ///////////////////////////////////////////////////////////////////////////
1064 void AliCalorimeter::AddVetoSignal(Float_t* r,TString f,Float_t s)
1066 // Associate an (extrapolated) AliSignal at location r as veto to the cal.
1067 // Note : The default signal value (s) is 0
1071 fVetos=new TObjArray();
1074 fVetos->Add(new AliSignal);
1077 ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
1078 ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
1080 ///////////////////////////////////////////////////////////////////////////
1081 Int_t AliCalorimeter::GetNvetos()
1083 // Provide the number of veto signals associated to the calorimeter
1086 ///////////////////////////////////////////////////////////////////////////
1087 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1089 // Provide access to the i-th veto signal of this calorimeter
1090 // Note : The first hit corresponds to i=1
1092 if (i>0 && i<=fNvetos)
1094 return (AliSignal*)fVetos->At(i-1);
1098 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1099 << " out of range." << endl;
1100 cout << " --- First signal (if any) returned." << endl;
1101 return (AliSignal*)fVetos->At(0);
1104 ///////////////////////////////////////////////////////////////////////////