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"
59 ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
61 AliCalorimeter::AliCalorimeter()
63 // Default constructor, all parameters set to 0
80 ///////////////////////////////////////////////////////////////////////////
81 AliCalorimeter::~AliCalorimeter()
83 // Destructor to delete memory allocated to the various arrays and matrices
110 // Free memory allocated for (internal) module and position matrices.
111 // The modules have already been deleted via the fModules I/O array,
112 // so they shouldn't be deleted here anymore.
113 if (fMatrix || fPositions)
115 for (Int_t i=0; i<fNrows; i++)
117 for (Int_t j=0; j<fNcolumns; j++)
119 if (fPositions[i][j]) delete fPositions[i][j];
121 if (fPositions[i]) delete [] fPositions[i];
122 if (fMatrix[i]) delete [] fMatrix[i];
131 delete [] fPositions;
146 ///////////////////////////////////////////////////////////////////////////
147 AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol)
149 // Create a calorimeter module matrix
156 fAttributes=new TMatrix(nrow,ncol);
157 fGains=new TMatrix(nrow,ncol);
158 fMatrix=new AliCalmodule**[nrow];
159 fPositions=new AliPosition**[nrow];
160 for (Int_t row=0; row<nrow; row++)
162 fMatrix[row]=new AliCalmodule*[ncol];
163 fPositions[row]=new AliPosition*[ncol];
164 // Initialise the various matrices
165 for (Int_t col=0; col<ncol; col++)
168 fPositions[row][col]=0;
169 (*fGains)(row,col)=1;
170 (*fAttributes)(row,col)=0;
174 // Mark the edge modules
175 for (Int_t j=0; j<ncol; j++)
177 (*fAttributes)(0,j)=10;
178 (*fAttributes)(nrow-1,j)=10;
180 for (Int_t i=0; i<nrow; i++)
182 (*fAttributes)(i,0)=10;
183 (*fAttributes)(i,ncol-1)=10;
194 ///////////////////////////////////////////////////////////////////////////
195 Int_t AliCalorimeter::GetNrows()
197 // Provide the number of rows for the calorimeter module matrix
200 ///////////////////////////////////////////////////////////////////////////
201 Int_t AliCalorimeter::GetNcolumns()
203 // Provide the number of columns for the calorimeter module matrix
206 ///////////////////////////////////////////////////////////////////////////
207 void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
209 // Set the signal for a certain calorimeter module
211 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
213 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
215 AliCalmodule* m=fMatrix[row-1][col-1];
216 if (!m) // only count new modules
220 fModules=new TObjArray(); // Default size, expanded automatically
221 fModules->SetOwner();
224 m=new AliCalmodule();
225 AliPosition* r=fPositions[row-1][col-1];
226 if (r) m->SetPosition(*r);
228 fMatrix[row-1][col-1]=m;
230 m->SetSignal(row,col,sig);
234 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
235 << " out of range." << endl;
236 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
239 ///////////////////////////////////////////////////////////////////////////
240 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
242 // Add the signal to a certain calorimeter module
244 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
246 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
248 AliCalmodule* m=fMatrix[row-1][col-1];
249 if (!m) // only count new modules
251 SetSignal(row,col,sig);
255 m->AddSignal(row,col,sig);
260 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
261 << " out of range." << endl;
262 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
265 ///////////////////////////////////////////////////////////////////////////
266 void AliCalorimeter::AddSignal(AliCalmodule* mod)
268 // Add the signal of module mod to the current calorimeter data.
269 // This enables mixing of calorimeter data of various events.
271 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
273 Int_t row=mod->GetRow();
274 Int_t col=mod->GetColumn();
275 Float_t sig=mod->GetSignal();
276 AliPosition r=mod->GetPosition();
278 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
280 AliCalmodule* m=fMatrix[row-1][col-1];
281 if (!m) // No module existed yet at this position
285 fModules=new TObjArray(); // Default size, expanded automatically
286 fModules->SetOwner();
291 fMatrix[row-1][col-1]=m;
294 m->AddSignal(row,col,sig);
295 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition(r);
299 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
300 << " out of range." << endl;
301 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
304 ///////////////////////////////////////////////////////////////////////////
305 void AliCalorimeter::Reset(Int_t row,Int_t col)
307 // Reset the signal for a certain calorimeter module
309 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
311 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
313 AliCalmodule* m=fMatrix[row-1][col-1];
318 fModules->Compress();
320 fMatrix[row-1][col-1]=0;
325 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
326 << " out of range." << endl;
327 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
330 ///////////////////////////////////////////////////////////////////////////
331 void AliCalorimeter::Reset(Int_t mode)
333 // Reset the signals for the complete calorimeter.
334 // Normally this is done to prepare for the data of the next event.
336 // mode = 0 : Module positions, gains, edge and dead flags remain unchanged.
337 // 1 : Module positions, gains, edge and dead flags are cleared.
339 // The default is mode=0.
341 // Note : In the case of reading AliCalorimeter objects from a data file,
342 // one has to reset the AliCalorimeter object with mode=1
343 // (or explicitly delete it) before reading-in the next object
344 // in order to prevent memory leaks.
346 if (mode<0 || mode>1)
348 cout << " *AliCalorimeter::Reset* Wrong argument. mode = " << mode << endl;
358 for (Int_t i=0; i<fNrows; i++)
360 for (Int_t j=0; j<fNcolumns; j++)
380 if (fMatrix || fPositions)
382 for (Int_t i=0; i<fNrows; i++)
384 for (Int_t j=0; j<fNcolumns; j++)
392 if (fPositions[i][j]) delete fPositions[i][j];
397 if (fPositions[i]) delete [] fPositions[i];
398 if (fMatrix[i]) delete [] fMatrix[i];
403 // Free memory allocated for various arrays and matrices.
413 delete [] fPositions;
438 ///////////////////////////////////////////////////////////////////////////
439 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
441 // Provide the signal of a certain calorimeter module.
442 // In case the module was marked dead, 0 is returned.
444 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
446 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
449 AliCalmodule* m=fMatrix[row-1][col-1];
452 Int_t dead=m->GetDeadValue();
453 if (!dead) signal=m->GetSignal();
459 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
460 << " out of range." << endl;
461 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
465 ///////////////////////////////////////////////////////////////////////////
466 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
468 // Indicate a certain calorimeter module as 'edge module'
470 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
472 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
474 Float_t word=(*fAttributes)(row-1,col-1);
475 Int_t iword=int(word+0.1);
478 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
482 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
483 << " out of range." << endl;
484 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
487 ///////////////////////////////////////////////////////////////////////////
488 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
490 // Indicate a certain calorimeter module as 'non-edge module'
492 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
494 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
496 Float_t word=(*fAttributes)(row-1,col-1);
497 Int_t iword=int(word+0.1);
500 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
504 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
505 << " out of range." << endl;
506 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
509 ///////////////////////////////////////////////////////////////////////////
510 void AliCalorimeter::SetDead(Int_t row,Int_t col)
512 // Indicate a certain calorimeter module as 'dead module'
514 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
516 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
518 Float_t word=(*fAttributes)(row-1,col-1);
519 Int_t iword=int(word+0.1);
522 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
523 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
525 // Increase the 'edge value' of surrounding modules
531 if (rlow < 1) rlow=row;
532 if (rup > fNrows) rup=fNrows;
533 if (clow < 1) clow=col;
534 if (cup > fNcolumns) cup=fNcolumns;
536 for (Int_t i=rlow; i<=rup; i++)
538 for (Int_t j=clow; j<=cup; j++)
540 if (i!=row || j!=col) // No increase of edge value for the dead module itself
542 word=(*fAttributes)(i-1,j-1);
547 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
554 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
555 << " out of range." << endl;
556 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
559 ///////////////////////////////////////////////////////////////////////////
560 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
562 // Indicate a certain calorimeter module as 'active module'
564 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
566 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
568 Float_t word=(*fAttributes)(row-1,col-1);
569 Int_t iword=int(word+0.1);
572 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
573 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
575 // Decrease the 'edge value' of surrounding modules
581 if (rlow < 1) rlow=row;
582 if (rup > fNrows) rup=fNrows;
583 if (clow < 1) clow=col;
584 if (cup > fNcolumns) cup=fNcolumns;
586 for (Int_t i=rlow; i<=rup; i++)
588 for (Int_t j=clow; j<=cup; j++)
590 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
592 word=(*fAttributes)(i-1,j-1);
597 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
604 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
605 << " out of range." << endl;
606 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
609 ///////////////////////////////////////////////////////////////////////////
610 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
612 // Set the gain value for a certain calorimeter module
614 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
616 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
618 (*fGains)(row-1,col-1)=gain;
619 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
623 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
624 << " out of range." << endl;
625 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
628 ///////////////////////////////////////////////////////////////////////////
629 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
631 // Set the position in user coordinates for a certain calorimeter module
633 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
635 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
637 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
638 (fPositions[row-1][col-1])->SetVector(vec,f);
639 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
643 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
644 << " out of range." << endl;
645 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
648 ///////////////////////////////////////////////////////////////////////////
649 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
651 // Set the position for a certain calorimeter module
653 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
655 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
657 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
658 (fPositions[row-1][col-1])->SetPosition(r);
659 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
663 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
664 << " out of range." << endl;
665 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
668 ///////////////////////////////////////////////////////////////////////////
669 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
671 // Provide the value of the edge flag of a certain module
673 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
675 Float_t word=(*fAttributes)(row-1,col-1);
676 Int_t iword=int(word+0.1);
682 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
683 << " out of range." << endl;
684 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
688 ///////////////////////////////////////////////////////////////////////////
689 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
691 // Provide the value of the dead flag of a certain module
693 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
695 Float_t word=(*fAttributes)(row-1,col-1);
696 Int_t iword=int(word+0.1);
702 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
703 << " out of range." << endl;
704 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
708 ///////////////////////////////////////////////////////////////////////////
709 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
711 // Provide the gain value of a certain module
713 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
715 return (*fGains)(row-1,col-1);
719 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
720 << " out of range." << endl;
721 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
725 ///////////////////////////////////////////////////////////////////////////
726 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
728 // Return the position in user coordinates for a certain calorimeter module
730 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
732 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
734 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
735 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
739 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
740 << " out of range." << endl;
741 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
744 ///////////////////////////////////////////////////////////////////////////
745 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
747 // Access to the position of a certain calorimeter module
749 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
751 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
753 return fPositions[row-1][col-1];
757 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
758 << " out of range." << endl;
759 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
763 ///////////////////////////////////////////////////////////////////////////
764 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
766 // Provide the module signal after clustering
768 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
770 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
772 if (fMatrix[row-1][col-1])
774 return (fMatrix[row-1][col-1])->GetClusteredSignal();
783 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
784 << " out of range." << endl;
785 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
789 ///////////////////////////////////////////////////////////////////////////
790 Int_t AliCalorimeter::GetNsignals()
792 // Provide the number of modules that contain a signal
793 // Note : The number of modules marked 'dead' but which had a signal
797 ///////////////////////////////////////////////////////////////////////////
798 void AliCalorimeter::Group(Int_t n)
800 // Group the individual modules into clusters
801 // Module signals of n rings around the central module will be grouped
803 if (fNsignals > 0) // Directly return if no modules fired
805 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
807 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
809 // Order the modules with decreasing signal
810 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
814 // Clustering of modules. Start with the highest signal.
820 fClusters=new TObjArray();
821 fClusters->SetOwner();
827 for (Int_t i=0; i<nord; i++)
829 row=ordered[i]->GetRow(); // row number of cluster center
830 col=ordered[i]->GetColumn(); // column number of cluster center
831 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
833 m=fMatrix[row-1][col-1];
836 // only use modules not yet used in a cluster
837 if (m->GetClusteredSignal() > 0.)
839 Int_t edge=GetEdgeValue(row,col);
841 if (!edge) c->Start(*m); // module to start the cluster if not on edge
842 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
845 fNclusters++; // update cluster counter
846 AddRing(row,col,n); // add signals of n rings around the center
857 // Delete the temp. array
860 for (Int_t j=0; j<nord; j++)
868 ///////////////////////////////////////////////////////////////////////////
869 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
871 // Order the modules with decreasing signal
874 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
876 for (Int_t ii=0; ii<fNcolumns; ii++)
878 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
880 if (nord == 0) // store the first module with a signal at the first ordered position
883 ordered[nord-1]=fMatrix[i][ii];
887 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
889 if (j == nord) // module has smallest signal seen so far
892 ordered[j]=fMatrix[i][ii]; // add module at the end
893 break; // go for next matrix module
896 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
899 for (Int_t k=nord-1; k>j; k--) // create empty position
901 ordered[k]=ordered[k-1];
903 ordered[j]=fMatrix[i][ii]; // put module at empty position
904 break; // go for next matrix module
909 ///////////////////////////////////////////////////////////////////////////
910 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
912 // Add module signals of 1 ring around (row,col) to current cluster
913 // n denotes the maximum number of rings around cluster center
914 // Note : This function is used recursively
916 if (n >= 1) // Check if any rings left for recursive calls
918 Float_t signal=GetSignal(row,col); // signal of (row,col) module
920 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
921 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
922 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
923 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
925 for (Int_t i=lrow; i<=urow; i++)
927 for (Int_t j=lcol; j<=ucol; j++)
929 // add module(i,j) to cluster if the signal <= signal(row,col)
930 if (GetSignal(i,j) <= signal)
932 AliCalmodule* m=fMatrix[i-1][j-1];
933 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
935 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
940 ///////////////////////////////////////////////////////////////////////////
941 Int_t AliCalorimeter::GetNclusters()
943 // Provide the number of clusters
946 ///////////////////////////////////////////////////////////////////////////
947 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
949 // Provide cluster number j
950 // Note : j=1 denotes the first cluster
951 if ((j >= 1) && (j <= fNclusters))
953 return (AliCalcluster*)fClusters->At(j-1);
957 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
958 << " out of range." << endl;
959 cout << " -- Cluster number 1 (if any) returned " << endl;
960 return (AliCalcluster*)fClusters->At(0);
963 ///////////////////////////////////////////////////////////////////////////
964 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
966 // Provide 'fired' module number j
967 // Note : j=1 denotes the first 'fired' module
968 if ((j >= 1) && (j <= fNsignals))
970 return (AliCalmodule*)fModules->At(j-1);
974 cout << " *AliCalorimeter::GetModule* module number : " << j
975 << " out of range." << endl;
976 cout << " -- Fired module number 1 (if any) returned " << endl;
977 return (AliCalmodule*)fModules->At(0);
980 ///////////////////////////////////////////////////////////////////////////
981 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
983 // Provide access to module (row,col).
984 // Note : first module is at (1,1).
986 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
988 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
990 return fMatrix[row-1][col-1];
994 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
995 << " out of range." << endl;
999 ///////////////////////////////////////////////////////////////////////////
1000 TH2F* AliCalorimeter::DrawModules()
1002 // Provide a lego plot of the module signals
1010 fHmodules=new TH2F("fHmodules","Module signals",
1011 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1013 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
1017 Float_t row,col,signal;
1019 for (Int_t i=0; i<fNsignals; i++)
1021 m=(AliCalmodule*)fModules->At(i);
1024 row=float(m->GetRow());
1025 col=float(m->GetColumn());
1026 dead=m->GetDeadValue();
1028 if (!dead) signal=m->GetSignal();
1029 if (signal>0.) fHmodules->Fill(col,row,signal);
1033 fHmodules->Draw("lego");
1036 ///////////////////////////////////////////////////////////////////////////
1037 TH2F* AliCalorimeter::DrawClusters()
1039 // Provide a lego plot of the cluster signals
1043 fHclusters->Reset();
1047 fHclusters=new TH2F("fHclusters","Cluster signals",
1048 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1050 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
1054 Float_t row,col,signal;
1055 for (Int_t i=0; i<fNclusters; i++)
1057 c=(AliCalcluster*)fClusters->At(i);
1060 row=float(c->GetRow());
1061 col=float(c->GetColumn());
1062 signal=c->GetSignal();
1063 if (signal>0.) fHclusters->Fill(col,row,signal);
1067 fHclusters->Draw("lego");
1070 ///////////////////////////////////////////////////////////////////////////
1071 void AliCalorimeter::LoadMatrix()
1073 // Load the Calorimeter module matrix data back from the TObjArray
1075 // Initialise the module matrix
1078 fMatrix=new AliCalmodule**[fNrows];
1079 for (Int_t i=0; i<fNrows; i++)
1081 fMatrix[i]=new AliCalmodule*[fNcolumns];
1085 // Initialise the position matrix
1088 fPositions=new AliPosition**[fNrows];
1089 for (Int_t j=0; j<fNrows; j++)
1091 fPositions[j]=new AliPosition*[fNcolumns];
1095 for (Int_t jrow=0; jrow<fNrows; jrow++)
1097 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1099 fMatrix[jrow][jcol]=0;
1100 fPositions[jrow][jcol]=0;
1104 // Copy the module pointers back into the matrix
1109 if (fModules) nsig=fModules->GetEntries();
1110 for (Int_t j=0; j<nsig; j++)
1112 m=(AliCalmodule*)fModules->At(j);
1117 AliPosition r=m->GetPosition();
1118 fMatrix[row-1][col-1]=m;
1119 fPositions[row-1][col-1]=new AliPosition(r);
1123 ///////////////////////////////////////////////////////////////////////////
1124 void AliCalorimeter::Ungroup()
1126 // Set the module signals back to the non-clustered situation
1128 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1131 if (fModules) nsig=fModules->GetEntries();
1135 for (Int_t j=0; j<nsig; j++)
1137 m=(AliCalmodule*)fModules->At(j);
1140 signal=m->GetSignal();
1141 m->SetClusteredSignal(signal);
1145 ///////////////////////////////////////////////////////////////////////////
1146 void AliCalorimeter::AddVetoSignal(AliSignal& s)
1148 // Associate an (extrapolated) AliSignal as veto to the calorimeter.
1152 fVetos=new TObjArray();
1156 Int_t nvalues=s.GetNvalues();
1157 AliSignal* sx=new AliSignal(nvalues);
1158 sx->SetName(s.GetName());
1160 sx->SetPosition((Ali3Vector&)s);
1163 for (Int_t i=1; i<=nvalues; i++)
1166 err=s.GetSignalError(i);
1167 sx->SetSignal(sig,i);
1168 sx->SetSignalError(err,i);
1174 ///////////////////////////////////////////////////////////////////////////
1175 Int_t AliCalorimeter::GetNvetos()
1177 // Provide the number of veto signals associated to the calorimeter
1180 ///////////////////////////////////////////////////////////////////////////
1181 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1183 // Provide access to the i-th veto signal of this calorimeter
1184 // Note : The first hit corresponds to i=1
1186 if (i>0 && i<=fNvetos)
1188 return (AliSignal*)fVetos->At(i-1);
1192 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1193 << " out of range." << endl;
1194 cout << " --- First signal (if any) returned." << endl;
1195 return (AliSignal*)fVetos->At(0);
1198 ///////////////////////////////////////////////////////////////////////////
1199 void AliCalorimeter::SetName(TString name)
1201 // Set the name of the calorimeter system.
1204 ///////////////////////////////////////////////////////////////////////////
1205 TString AliCalorimeter::GetName()
1207 // Provide the name of the calorimeter system.
1210 ///////////////////////////////////////////////////////////////////////////