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 ///////////////////////////////////////////////////////////////////////////
19 // Class AliCalorimeter
20 // Description of a modular calorimeter system.
21 // A matrix geometry is used in which a module is identified by (row,col).
22 // Note : First module is identified as (1,1).
24 // This is the way to define and enter signals into a calorimeter :
26 // AliCalorimeter cal(10,15); // Calorimeter of 10x15 modules
27 // // All module signals set to 0.
28 // cal.AddSignal(5,7,85.4);
29 // cal.AddSignal(5,7,25.9);
30 // cal.AddSignal(3,5,1000);
31 // cal.SetSignal(5,7,10.3);
32 // cal.Reset(3,5); // Reset module (3,5) as being 'not fired'
33 // // All module data are re-initialised.
34 // cal.SetEdgeOn(1,1); // Declare module (1,1) as an 'edge module'
36 // cal.SetGain(2,8,3.2);
38 // Float_t vec[3]={6,1,20};
39 // cal.SetPosition(2,8,vec,"car");
42 // Float_t loc[3]={-1,12,3};
43 // s.SetPosition(loc,"car");
45 // cal.AddVetoSignal(s); // Associate (extrapolated) signal as a veto
47 // cal.Group(2); // Group 'fired' modules into clusters
48 // // Perform grouping over 2 rings around the center
49 // cal.Reset(); // Reset the complete calorimeter
50 // // Normally to prepare for the next event data
51 // // Note : Module gain, edge and dead flags remain
53 //--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht
54 //- Modified: NvE $Date$ UU-SAP Utrecht
55 ///////////////////////////////////////////////////////////////////////////
57 #include "AliCalorimeter.h"
58 #include "Riostream.h"
60 ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
62 AliCalorimeter::AliCalorimeter() : TObject()
64 // Default constructor, all parameters set to 0
81 ///////////////////////////////////////////////////////////////////////////
82 AliCalorimeter::~AliCalorimeter()
84 // Destructor to delete memory allocated to the various arrays and matrices
111 // Free memory allocated for (internal) module and position matrices.
112 // The modules have already been deleted via the fModules I/O array,
113 // so they shouldn't be deleted here anymore.
114 if (fMatrix || fPositions)
116 for (Int_t i=0; i<fNrows; i++)
118 for (Int_t j=0; j<fNcolumns; j++)
120 if (fPositions[i][j]) delete fPositions[i][j];
122 if (fPositions[i]) delete [] fPositions[i];
123 if (fMatrix[i]) delete [] fMatrix[i];
132 delete [] fPositions;
147 ///////////////////////////////////////////////////////////////////////////
148 AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TObject()
150 // 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;
195 ///////////////////////////////////////////////////////////////////////////
196 AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
216 fNcolumns=c.fNcolumns;
219 if (fNrows && fNcolumns)
223 for (Int_t irow=1; irow<=fNrows; irow++)
225 for (Int_t icol=1; icol<=fNcolumns; icol++)
227 AliPosition* p=c.GetPosition(irow,icol);
228 SetPosition(irow,icol,*p);
233 TMatrix* mat=c.fAttributes;
234 if (mat) fAttributes=new TMatrix(*mat);
237 if (mat) fGains=new TMatrix(*mat);
241 fClusters=new TObjArray();
242 fClusters->SetOwner();
243 for (Int_t icl=1; icl<=c.fNclusters; icl++)
245 AliCalcluster* cl=c.GetCluster(icl);
246 fClusters->Add(new AliCalcluster(*cl));
251 for (Int_t im=1; im<=c.fNsignals; im++)
253 AliCalmodule* m=c.GetModule(im);
254 SetSignal(m->GetRow(),m->GetColumn(),m->GetSignal());
257 for (Int_t iv=1; iv<=c.fNvetos; iv++)
259 AliSignal* s=c.GetVetoSignal(iv);
264 ///////////////////////////////////////////////////////////////////////////
265 Int_t AliCalorimeter::GetNrows()
267 // Provide the number of rows for the calorimeter module matrix
270 ///////////////////////////////////////////////////////////////////////////
271 Int_t AliCalorimeter::GetNcolumns()
273 // Provide the number of columns for the calorimeter module matrix
276 ///////////////////////////////////////////////////////////////////////////
277 void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
279 // Set the signal for a certain calorimeter module
281 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
283 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
285 AliCalmodule* m=fMatrix[row-1][col-1];
286 if (!m) // only count new modules
290 fModules=new TObjArray(); // Default size, expanded automatically
291 fModules->SetOwner();
294 m=new AliCalmodule();
295 AliPosition* r=fPositions[row-1][col-1];
296 if (r) m->SetPosition(*r);
297 m->SetGain(GetGain(row,col));
298 if (GetDeadValue(row,col)) m->SetDead();
300 fMatrix[row-1][col-1]=m;
302 m->SetSignal(row,col,sig);
306 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
307 << " out of range." << endl;
308 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
311 ///////////////////////////////////////////////////////////////////////////
312 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
314 // Add the signal to a certain calorimeter module
316 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
318 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
320 AliCalmodule* m=fMatrix[row-1][col-1];
321 if (!m) // only count new modules
323 SetSignal(row,col,sig);
327 m->AddSignal(row,col,sig);
332 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
333 << " out of range." << endl;
334 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
337 ///////////////////////////////////////////////////////////////////////////
338 void AliCalorimeter::AddSignal(AliCalmodule* mod)
340 // Add the signal of module mod to the current calorimeter data.
341 // This enables mixing of calorimeter data of various events.
343 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
345 Int_t row=mod->GetRow();
346 Int_t col=mod->GetColumn();
347 Float_t sig=mod->GetSignal();
348 AliPosition r=mod->GetPosition();
350 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
352 AliCalmodule* m=fMatrix[row-1][col-1];
353 if (!m) // No module existed yet at this position
357 fModules=new TObjArray(); // Default size, expanded automatically
358 fModules->SetOwner();
363 fMatrix[row-1][col-1]=m;
366 m->AddSignal(row,col,sig);
367 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition(r);
371 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
372 << " out of range." << endl;
373 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
376 ///////////////////////////////////////////////////////////////////////////
377 void AliCalorimeter::Reset(Int_t row,Int_t col)
379 // Reset the signal for a certain calorimeter module
381 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
383 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
385 AliCalmodule* m=fMatrix[row-1][col-1];
390 fModules->Compress();
392 fMatrix[row-1][col-1]=0;
397 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
398 << " out of range." << endl;
399 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
402 ///////////////////////////////////////////////////////////////////////////
403 void AliCalorimeter::Reset(Int_t mode)
405 // Reset the signals for the complete calorimeter.
406 // Normally this is done to prepare for the data of the next event.
408 // mode = 0 : Module positions, gains, edge and dead flags remain unchanged.
409 // 1 : Module positions, gains, edge and dead flags are cleared.
411 // The default is mode=0.
413 // Note : In the case of reading AliCalorimeter objects from a data file,
414 // one has to reset the AliCalorimeter object with mode=1
415 // (or explicitly delete it) before reading-in the next object
416 // in order to prevent memory leaks.
418 if (mode<0 || mode>1)
420 cout << " *AliCalorimeter::Reset* Wrong argument. mode = " << mode << endl;
445 if (fMatrix || fPositions)
447 for (Int_t i=0; i<fNrows; i++)
449 for (Int_t j=0; j<fNcolumns; j++)
457 if (fPositions[i][j]) delete fPositions[i][j];
462 if (fPositions[i]) delete [] fPositions[i];
463 if (fMatrix[i]) delete [] fMatrix[i];
468 // Free memory allocated for various arrays and matrices.
478 delete [] fPositions;
503 ///////////////////////////////////////////////////////////////////////////
504 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
506 // Provide the signal of a certain calorimeter module.
507 // In case the module was marked dead, 0 is returned.
509 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
511 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
514 AliCalmodule* m=fMatrix[row-1][col-1];
517 Int_t dead=m->GetDeadValue();
518 if (!dead) signal=m->GetSignal();
524 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
525 << " out of range." << endl;
526 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
530 ///////////////////////////////////////////////////////////////////////////
531 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
533 // Indicate a certain calorimeter module as 'edge module'
535 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
537 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
539 Float_t word=(*fAttributes)(row-1,col-1);
540 Int_t iword=int(word+0.1);
543 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
547 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
548 << " out of range." << endl;
549 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
552 ///////////////////////////////////////////////////////////////////////////
553 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
555 // Indicate a certain calorimeter module as 'non-edge module'
557 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
559 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
561 Float_t word=(*fAttributes)(row-1,col-1);
562 Int_t iword=int(word+0.1);
565 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
569 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
570 << " out of range." << endl;
571 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
574 ///////////////////////////////////////////////////////////////////////////
575 void AliCalorimeter::SetDead(Int_t row,Int_t col)
577 // Indicate a certain calorimeter module as 'dead module'
579 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
581 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
583 Float_t word=(*fAttributes)(row-1,col-1);
584 Int_t iword=int(word+0.1);
587 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
588 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
590 // Increase the 'edge value' of surrounding modules
596 if (rlow < 1) rlow=row;
597 if (rup > fNrows) rup=fNrows;
598 if (clow < 1) clow=col;
599 if (cup > fNcolumns) cup=fNcolumns;
601 for (Int_t i=rlow; i<=rup; i++)
603 for (Int_t j=clow; j<=cup; j++)
605 if (i!=row || j!=col) // No increase of edge value for the dead module itself
607 word=(*fAttributes)(i-1,j-1);
612 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
619 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
620 << " out of range." << endl;
621 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
624 ///////////////////////////////////////////////////////////////////////////
625 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
627 // Indicate a certain calorimeter module as 'active module'
629 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
631 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
633 Float_t word=(*fAttributes)(row-1,col-1);
634 Int_t iword=int(word+0.1);
637 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
638 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
640 // Decrease the 'edge value' of surrounding modules
646 if (rlow < 1) rlow=row;
647 if (rup > fNrows) rup=fNrows;
648 if (clow < 1) clow=col;
649 if (cup > fNcolumns) cup=fNcolumns;
651 for (Int_t i=rlow; i<=rup; i++)
653 for (Int_t j=clow; j<=cup; j++)
655 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
657 word=(*fAttributes)(i-1,j-1);
662 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
669 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
670 << " out of range." << endl;
671 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
674 ///////////////////////////////////////////////////////////////////////////
675 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
677 // Set the gain value for a certain calorimeter module
679 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
681 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
683 (*fGains)(row-1,col-1)=gain;
684 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
688 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
689 << " out of range." << endl;
690 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
693 ///////////////////////////////////////////////////////////////////////////
694 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
696 // Set the position in user coordinates for a certain calorimeter module
698 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
700 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
702 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
703 (fPositions[row-1][col-1])->SetVector(vec,f);
704 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
708 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
709 << " out of range." << endl;
710 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
713 ///////////////////////////////////////////////////////////////////////////
714 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
716 // Set the position for a certain calorimeter module
718 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
720 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
722 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
723 (fPositions[row-1][col-1])->SetPosition(r);
724 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
728 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
729 << " out of range." << endl;
730 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
733 ///////////////////////////////////////////////////////////////////////////
734 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
736 // Provide the value of the edge flag of a certain module
738 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
740 Float_t word=(*fAttributes)(row-1,col-1);
741 Int_t iword=int(word+0.1);
747 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
748 << " out of range." << endl;
749 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
753 ///////////////////////////////////////////////////////////////////////////
754 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
756 // Provide the value of the dead flag of a certain module
758 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
760 Float_t word=(*fAttributes)(row-1,col-1);
761 Int_t iword=int(word+0.1);
767 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
768 << " out of range." << endl;
769 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
773 ///////////////////////////////////////////////////////////////////////////
774 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
776 // Provide the gain value of a certain module
778 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
780 return (*fGains)(row-1,col-1);
784 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
785 << " out of range." << endl;
786 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
790 ///////////////////////////////////////////////////////////////////////////
791 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
793 // Return the position in user coordinates for a certain calorimeter module
795 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
797 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
799 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
800 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
804 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
805 << " out of range." << endl;
806 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
809 ///////////////////////////////////////////////////////////////////////////
810 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
812 // Access to the position of a certain calorimeter module
814 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
816 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
818 return fPositions[row-1][col-1];
822 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
823 << " out of range." << endl;
824 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
828 ///////////////////////////////////////////////////////////////////////////
829 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
831 // Provide the module signal after clustering
833 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
835 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
837 if (fMatrix[row-1][col-1])
839 return (fMatrix[row-1][col-1])->GetClusteredSignal();
848 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
849 << " out of range." << endl;
850 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
854 ///////////////////////////////////////////////////////////////////////////
855 Int_t AliCalorimeter::GetNsignals()
857 // Provide the number of modules that contain a signal
858 // Note : The number of modules marked 'dead' but which had a signal
862 ///////////////////////////////////////////////////////////////////////////
863 void AliCalorimeter::Group(Int_t n)
865 // Group the individual modules into clusters
866 // Module signals of n rings around the central module will be grouped
868 if (fNsignals > 0) // Directly return if no modules fired
870 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
872 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
874 // Order the modules with decreasing signal
875 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
879 // Clustering of modules. Start with the highest signal.
885 fClusters=new TObjArray();
886 fClusters->SetOwner();
892 for (Int_t i=0; i<nord; i++)
894 row=ordered[i]->GetRow(); // row number of cluster center
895 col=ordered[i]->GetColumn(); // column number of cluster center
896 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
898 m=fMatrix[row-1][col-1];
901 // only use modules not yet used in a cluster
902 if (m->GetClusteredSignal() > 0.)
904 Int_t edge=GetEdgeValue(row,col);
906 if (!edge) c->Start(*m); // module to start the cluster if not on edge
907 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
910 fNclusters++; // update cluster counter
911 AddRing(row,col,n); // add signals of n rings around the center
922 // Delete the temp. array
925 for (Int_t j=0; j<nord; j++)
933 ///////////////////////////////////////////////////////////////////////////
934 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
936 // Order the modules with decreasing signal
939 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
941 for (Int_t ii=0; ii<fNcolumns; ii++)
943 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
945 if (nord == 0) // store the first module with a signal at the first ordered position
948 ordered[nord-1]=fMatrix[i][ii];
952 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
954 if (j == nord) // module has smallest signal seen so far
957 ordered[j]=fMatrix[i][ii]; // add module at the end
958 break; // go for next matrix module
961 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
964 for (Int_t k=nord-1; k>j; k--) // create empty position
966 ordered[k]=ordered[k-1];
968 ordered[j]=fMatrix[i][ii]; // put module at empty position
969 break; // go for next matrix module
974 ///////////////////////////////////////////////////////////////////////////
975 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
977 // Add module signals of 1 ring around (row,col) to current cluster
978 // n denotes the maximum number of rings around cluster center
979 // Note : This function is used recursively
981 if (n >= 1) // Check if any rings left for recursive calls
983 Float_t signal=GetSignal(row,col); // signal of (row,col) module
985 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
986 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
987 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
988 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
990 for (Int_t i=lrow; i<=urow; i++)
992 for (Int_t j=lcol; j<=ucol; j++)
994 // add module(i,j) to cluster if the signal <= signal(row,col)
995 if (GetSignal(i,j) <= signal)
997 AliCalmodule* m=fMatrix[i-1][j-1];
998 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
1000 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
1005 ///////////////////////////////////////////////////////////////////////////
1006 Int_t AliCalorimeter::GetNclusters()
1008 // Provide the number of clusters
1011 ///////////////////////////////////////////////////////////////////////////
1012 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
1014 // Provide cluster number j
1015 // Note : j=1 denotes the first cluster
1016 if ((j >= 1) && (j <= fNclusters))
1018 return (AliCalcluster*)fClusters->At(j-1);
1022 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
1023 << " out of range." << endl;
1024 cout << " -- Cluster number 1 (if any) returned " << endl;
1025 return (AliCalcluster*)fClusters->At(0);
1028 ///////////////////////////////////////////////////////////////////////////
1029 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
1031 // Provide 'fired' module number j
1032 // Note : j=1 denotes the first 'fired' module
1033 if ((j >= 1) && (j <= fNsignals))
1035 return (AliCalmodule*)fModules->At(j-1);
1039 cout << " *AliCalorimeter::GetModule* module number : " << j
1040 << " out of range." << endl;
1041 cout << " -- Fired module number 1 (if any) returned " << endl;
1042 return (AliCalmodule*)fModules->At(0);
1045 ///////////////////////////////////////////////////////////////////////////
1046 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
1048 // Provide access to module (row,col).
1049 // Note : first module is at (1,1).
1051 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1053 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
1055 return fMatrix[row-1][col-1];
1059 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
1060 << " out of range." << endl;
1064 ///////////////////////////////////////////////////////////////////////////
1065 TH2F* AliCalorimeter::DrawModules()
1067 // Provide a lego plot of the module signals
1075 fHmodules=new TH2F("fHmodules","Module signals",
1076 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1078 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
1082 Float_t row,col,signal;
1084 for (Int_t i=0; i<fNsignals; i++)
1086 m=(AliCalmodule*)fModules->At(i);
1089 row=float(m->GetRow());
1090 col=float(m->GetColumn());
1091 dead=m->GetDeadValue();
1093 if (!dead) signal=m->GetSignal();
1094 if (signal>0.) fHmodules->Fill(col,row,signal);
1098 fHmodules->Draw("lego");
1101 ///////////////////////////////////////////////////////////////////////////
1102 TH2F* AliCalorimeter::DrawClusters()
1104 // Provide a lego plot of the cluster signals
1108 fHclusters->Reset();
1112 fHclusters=new TH2F("fHclusters","Cluster signals",
1113 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1115 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
1119 Float_t row,col,signal;
1120 for (Int_t i=0; i<fNclusters; i++)
1122 c=(AliCalcluster*)fClusters->At(i);
1125 row=float(c->GetRow());
1126 col=float(c->GetColumn());
1127 signal=c->GetSignal();
1128 if (signal>0.) fHclusters->Fill(col,row,signal);
1132 fHclusters->Draw("lego");
1135 ///////////////////////////////////////////////////////////////////////////
1136 void AliCalorimeter::LoadMatrix()
1138 // Load the Calorimeter module matrix data back from the TObjArray
1140 // Initialise the module matrix
1143 fMatrix=new AliCalmodule**[fNrows];
1144 for (Int_t i=0; i<fNrows; i++)
1146 fMatrix[i]=new AliCalmodule*[fNcolumns];
1150 // Initialise the position matrix
1153 fPositions=new AliPosition**[fNrows];
1154 for (Int_t j=0; j<fNrows; j++)
1156 fPositions[j]=new AliPosition*[fNcolumns];
1160 for (Int_t jrow=0; jrow<fNrows; jrow++)
1162 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1164 fMatrix[jrow][jcol]=0;
1165 fPositions[jrow][jcol]=0;
1169 // Copy the module pointers back into the matrix
1174 if (fModules) nsig=fModules->GetEntries();
1175 for (Int_t j=0; j<nsig; j++)
1177 m=(AliCalmodule*)fModules->At(j);
1182 AliPosition r=m->GetPosition();
1183 fMatrix[row-1][col-1]=m;
1184 fPositions[row-1][col-1]=new AliPosition(r);
1188 ///////////////////////////////////////////////////////////////////////////
1189 void AliCalorimeter::Ungroup()
1191 // Set the module signals back to the non-clustered situation
1193 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1196 if (fModules) nsig=fModules->GetEntries();
1200 for (Int_t j=0; j<nsig; j++)
1202 m=(AliCalmodule*)fModules->At(j);
1205 signal=m->GetSignal();
1206 m->SetClusteredSignal(signal);
1210 ///////////////////////////////////////////////////////////////////////////
1211 void AliCalorimeter::AddVetoSignal(AliSignal& s)
1213 // Associate an (extrapolated) AliSignal as veto to the calorimeter.
1217 fVetos=new TObjArray();
1221 AliSignal* sx=new AliSignal(s);
1226 ///////////////////////////////////////////////////////////////////////////
1227 Int_t AliCalorimeter::GetNvetos()
1229 // Provide the number of veto signals associated to the calorimeter
1232 ///////////////////////////////////////////////////////////////////////////
1233 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1235 // Provide access to the i-th veto signal of this calorimeter
1236 // Note : The first hit corresponds to i=1
1238 if (i>0 && i<=fNvetos)
1240 return (AliSignal*)fVetos->At(i-1);
1244 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1245 << " out of range." << endl;
1246 cout << " --- First signal (if any) returned." << endl;
1247 return (AliSignal*)fVetos->At(0);
1250 ///////////////////////////////////////////////////////////////////////////
1251 void AliCalorimeter::SetName(TString name)
1253 // Set the name of the calorimeter system.
1256 ///////////////////////////////////////////////////////////////////////////
1257 TString AliCalorimeter::GetName()
1259 // Provide the name of the calorimeter system.
1262 ///////////////////////////////////////////////////////////////////////////