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;
373 if (fMatrix || fPositions)
375 for (Int_t i=0; i<fNrows; i++)
377 for (Int_t j=0; j<fNcolumns; j++)
385 if (fPositions[i][j]) delete fPositions[i][j];
390 if (fPositions[i]) delete [] fPositions[i];
391 if (fMatrix[i]) delete [] fMatrix[i];
396 // Free memory allocated for various arrays and matrices.
406 delete [] fPositions;
431 ///////////////////////////////////////////////////////////////////////////
432 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
434 // Provide the signal of a certain calorimeter module.
435 // In case the module was marked dead, 0 is returned.
437 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
439 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
442 AliCalmodule* m=fMatrix[row-1][col-1];
445 Int_t dead=m->GetDeadValue();
446 if (!dead) signal=m->GetSignal();
452 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
453 << " out of range." << endl;
454 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
458 ///////////////////////////////////////////////////////////////////////////
459 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
461 // Indicate a certain calorimeter module as 'edge module'
463 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
465 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
467 Float_t word=(*fAttributes)(row-1,col-1);
468 Int_t iword=int(word+0.1);
471 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
475 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
476 << " out of range." << endl;
477 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
480 ///////////////////////////////////////////////////////////////////////////
481 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
483 // Indicate a certain calorimeter module as 'non-edge module'
485 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
487 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
489 Float_t word=(*fAttributes)(row-1,col-1);
490 Int_t iword=int(word+0.1);
493 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
497 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
498 << " out of range." << endl;
499 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
502 ///////////////////////////////////////////////////////////////////////////
503 void AliCalorimeter::SetDead(Int_t row,Int_t col)
505 // Indicate a certain calorimeter module as 'dead module'
507 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
509 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
511 Float_t word=(*fAttributes)(row-1,col-1);
512 Int_t iword=int(word+0.1);
515 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
516 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
518 // Increase the 'edge value' of surrounding modules
524 if (rlow < 1) rlow=row;
525 if (rup > fNrows) rup=fNrows;
526 if (clow < 1) clow=col;
527 if (cup > fNcolumns) cup=fNcolumns;
529 for (Int_t i=rlow; i<=rup; i++)
531 for (Int_t j=clow; j<=cup; j++)
533 if (i!=row || j!=col) // No increase of edge value for the dead module itself
535 word=(*fAttributes)(i-1,j-1);
540 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
547 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
548 << " out of range." << endl;
549 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
552 ///////////////////////////////////////////////////////////////////////////
553 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
555 // Indicate a certain calorimeter module as 'active 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);
566 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
568 // Decrease the 'edge value' of surrounding modules
574 if (rlow < 1) rlow=row;
575 if (rup > fNrows) rup=fNrows;
576 if (clow < 1) clow=col;
577 if (cup > fNcolumns) cup=fNcolumns;
579 for (Int_t i=rlow; i<=rup; i++)
581 for (Int_t j=clow; j<=cup; j++)
583 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
585 word=(*fAttributes)(i-1,j-1);
590 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
597 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
598 << " out of range." << endl;
599 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
602 ///////////////////////////////////////////////////////////////////////////
603 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
605 // Set the gain value for a certain calorimeter module
607 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
609 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
611 (*fGains)(row-1,col-1)=gain;
612 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
616 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
617 << " out of range." << endl;
618 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
621 ///////////////////////////////////////////////////////////////////////////
622 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
624 // Set the position in user coordinates for a certain calorimeter module
626 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
628 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
630 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
631 (fPositions[row-1][col-1])->SetVector(vec,f);
632 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
636 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
637 << " out of range." << endl;
638 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
641 ///////////////////////////////////////////////////////////////////////////
642 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
644 // Set the position for a certain calorimeter module
646 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
648 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
650 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
651 (fPositions[row-1][col-1])->SetPosition(r);
652 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
656 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
657 << " out of range." << endl;
658 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
661 ///////////////////////////////////////////////////////////////////////////
662 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
664 // Provide the value of the edge flag of a certain module
666 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
668 Float_t word=(*fAttributes)(row-1,col-1);
669 Int_t iword=int(word+0.1);
675 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
676 << " out of range." << endl;
677 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
681 ///////////////////////////////////////////////////////////////////////////
682 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
684 // Provide the value of the dead flag of a certain module
686 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
688 Float_t word=(*fAttributes)(row-1,col-1);
689 Int_t iword=int(word+0.1);
695 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
696 << " out of range." << endl;
697 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
701 ///////////////////////////////////////////////////////////////////////////
702 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
704 // Provide the gain value of a certain module
706 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
708 return (*fGains)(row-1,col-1);
712 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
713 << " out of range." << endl;
714 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
718 ///////////////////////////////////////////////////////////////////////////
719 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
721 // Return the position in user coordinates for a certain calorimeter module
723 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
725 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
727 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
728 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
732 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
733 << " out of range." << endl;
734 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
737 ///////////////////////////////////////////////////////////////////////////
738 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
740 // Access to the position of a certain calorimeter module
742 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
744 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
746 return fPositions[row-1][col-1];
750 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
751 << " out of range." << endl;
752 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
756 ///////////////////////////////////////////////////////////////////////////
757 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
759 // Provide the module signal after clustering
761 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
763 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
765 if (fMatrix[row-1][col-1])
767 return (fMatrix[row-1][col-1])->GetClusteredSignal();
776 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
777 << " out of range." << endl;
778 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
782 ///////////////////////////////////////////////////////////////////////////
783 Int_t AliCalorimeter::GetNsignals()
785 // Provide the number of modules that contain a signal
786 // Note : The number of modules marked 'dead' but which had a signal
790 ///////////////////////////////////////////////////////////////////////////
791 void AliCalorimeter::Group(Int_t n)
793 // Group the individual modules into clusters
794 // Module signals of n rings around the central module will be grouped
796 if (fNsignals > 0) // Directly return if no modules fired
798 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
800 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
802 // Order the modules with decreasing signal
803 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
807 // Clustering of modules. Start with the highest signal.
813 fClusters=new TObjArray();
814 fClusters->SetOwner();
820 for (Int_t i=0; i<nord; i++)
822 row=ordered[i]->GetRow(); // row number of cluster center
823 col=ordered[i]->GetColumn(); // column number of cluster center
824 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
826 m=fMatrix[row-1][col-1];
829 // only use modules not yet used in a cluster
830 if (m->GetClusteredSignal() > 0.)
832 Int_t edge=GetEdgeValue(row,col);
834 if (!edge) c->Start(*m); // module to start the cluster if not on edge
835 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
838 fNclusters++; // update cluster counter
839 AddRing(row,col,n); // add signals of n rings around the center
850 // Delete the temp. array
853 for (Int_t j=0; j<nord; j++)
861 ///////////////////////////////////////////////////////////////////////////
862 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
864 // Order the modules with decreasing signal
867 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
869 for (Int_t ii=0; ii<fNcolumns; ii++)
871 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
873 if (nord == 0) // store the first module with a signal at the first ordered position
876 ordered[nord-1]=fMatrix[i][ii];
880 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
882 if (j == nord) // module has smallest signal seen so far
885 ordered[j]=fMatrix[i][ii]; // add module at the end
886 break; // go for next matrix module
889 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
892 for (Int_t k=nord-1; k>j; k--) // create empty position
894 ordered[k]=ordered[k-1];
896 ordered[j]=fMatrix[i][ii]; // put module at empty position
897 break; // go for next matrix module
902 ///////////////////////////////////////////////////////////////////////////
903 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
905 // Add module signals of 1 ring around (row,col) to current cluster
906 // n denotes the maximum number of rings around cluster center
907 // Note : This function is used recursively
909 if (n >= 1) // Check if any rings left for recursive calls
911 Float_t signal=GetSignal(row,col); // signal of (row,col) module
913 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
914 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
915 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
916 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
918 for (Int_t i=lrow; i<=urow; i++)
920 for (Int_t j=lcol; j<=ucol; j++)
922 // add module(i,j) to cluster if the signal <= signal(row,col)
923 if (GetSignal(i,j) <= signal)
925 AliCalmodule* m=fMatrix[i-1][j-1];
926 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
928 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
933 ///////////////////////////////////////////////////////////////////////////
934 Int_t AliCalorimeter::GetNclusters()
936 // Provide the number of clusters
939 ///////////////////////////////////////////////////////////////////////////
940 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
942 // Provide cluster number j
943 // Note : j=1 denotes the first cluster
944 if ((j >= 1) && (j <= fNclusters))
946 return (AliCalcluster*)fClusters->At(j-1);
950 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
951 << " out of range." << endl;
952 cout << " -- Cluster number 1 (if any) returned " << endl;
953 return (AliCalcluster*)fClusters->At(0);
956 ///////////////////////////////////////////////////////////////////////////
957 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
959 // Provide 'fired' module number j
960 // Note : j=1 denotes the first 'fired' module
961 if ((j >= 1) && (j <= fNsignals))
963 return (AliCalmodule*)fModules->At(j-1);
967 cout << " *AliCalorimeter::GetModule* module number : " << j
968 << " out of range." << endl;
969 cout << " -- Fired module number 1 (if any) returned " << endl;
970 return (AliCalmodule*)fModules->At(0);
973 ///////////////////////////////////////////////////////////////////////////
974 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
976 // Provide access to module (row,col).
977 // Note : first module is at (1,1).
979 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
981 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
983 return fMatrix[row-1][col-1];
987 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
988 << " out of range." << endl;
992 ///////////////////////////////////////////////////////////////////////////
993 TH2F* AliCalorimeter::DrawModules()
995 // Provide a lego plot of the module signals
1003 fHmodules=new TH2F("fHmodules","Module signals",
1004 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1006 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
1010 Float_t row,col,signal;
1012 for (Int_t i=0; i<fNsignals; i++)
1014 m=(AliCalmodule*)fModules->At(i);
1017 row=float(m->GetRow());
1018 col=float(m->GetColumn());
1019 dead=m->GetDeadValue();
1021 if (!dead) signal=m->GetSignal();
1022 if (signal>0.) fHmodules->Fill(col,row,signal);
1026 fHmodules->Draw("lego");
1029 ///////////////////////////////////////////////////////////////////////////
1030 TH2F* AliCalorimeter::DrawClusters()
1032 // Provide a lego plot of the cluster signals
1036 fHclusters->Reset();
1040 fHclusters=new TH2F("fHclusters","Cluster signals",
1041 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
1043 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
1047 Float_t row,col,signal;
1048 for (Int_t i=0; i<fNclusters; i++)
1050 c=(AliCalcluster*)fClusters->At(i);
1053 row=float(c->GetRow());
1054 col=float(c->GetColumn());
1055 signal=c->GetSignal();
1056 if (signal>0.) fHclusters->Fill(col,row,signal);
1060 fHclusters->Draw("lego");
1063 ///////////////////////////////////////////////////////////////////////////
1064 void AliCalorimeter::LoadMatrix()
1066 // Load the Calorimeter module matrix data back from the TObjArray
1068 // Initialise the module matrix
1071 fMatrix=new AliCalmodule**[fNrows];
1072 for (Int_t i=0; i<fNrows; i++)
1074 fMatrix[i]=new AliCalmodule*[fNcolumns];
1078 // Initialise the position matrix
1081 fPositions=new AliPosition**[fNrows];
1082 for (Int_t j=0; j<fNrows; j++)
1084 fPositions[j]=new AliPosition*[fNcolumns];
1088 for (Int_t jrow=0; jrow<fNrows; jrow++)
1090 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1092 fMatrix[jrow][jcol]=0;
1093 fPositions[jrow][jcol]=0;
1097 // Copy the module pointers back into the matrix
1102 if (fModules) nsig=fModules->GetEntries();
1103 for (Int_t j=0; j<nsig; j++)
1105 m=(AliCalmodule*)fModules->At(j);
1110 AliPosition r=m->GetPosition();
1111 fMatrix[row-1][col-1]=m;
1112 fPositions[row-1][col-1]=new AliPosition(r);
1116 ///////////////////////////////////////////////////////////////////////////
1117 void AliCalorimeter::Ungroup()
1119 // Set the module signals back to the non-clustered situation
1121 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1124 if (fModules) nsig=fModules->GetEntries();
1128 for (Int_t j=0; j<nsig; j++)
1130 m=(AliCalmodule*)fModules->At(j);
1133 signal=m->GetSignal();
1134 m->SetClusteredSignal(signal);
1138 ///////////////////////////////////////////////////////////////////////////
1139 void AliCalorimeter::AddVetoSignal(AliSignal& s)
1141 // Associate an (extrapolated) AliSignal as veto to the calorimeter.
1145 fVetos=new TObjArray();
1149 Int_t nvalues=s.GetNvalues();
1150 AliSignal* sx=new AliSignal(nvalues);
1151 sx->SetName(s.GetName());
1153 sx->SetPosition((Ali3Vector&)s);
1156 for (Int_t i=1; i<=nvalues; i++)
1159 err=s.GetSignalError(i);
1160 sx->SetSignal(sig,i);
1161 sx->SetSignalError(err,i);
1167 ///////////////////////////////////////////////////////////////////////////
1168 Int_t AliCalorimeter::GetNvetos()
1170 // Provide the number of veto signals associated to the calorimeter
1173 ///////////////////////////////////////////////////////////////////////////
1174 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1176 // Provide access to the i-th veto signal of this calorimeter
1177 // Note : The first hit corresponds to i=1
1179 if (i>0 && i<=fNvetos)
1181 return (AliSignal*)fVetos->At(i-1);
1185 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1186 << " out of range." << endl;
1187 cout << " --- First signal (if any) returned." << endl;
1188 return (AliSignal*)fVetos->At(0);
1191 ///////////////////////////////////////////////////////////////////////////
1192 void AliCalorimeter::SetName(TString name)
1194 // Set the name of the calorimeter system.
1197 ///////////////////////////////////////////////////////////////////////////
1198 TString AliCalorimeter::GetName()
1200 // Provide the name of the calorimeter system.
1203 ///////////////////////////////////////////////////////////////////////////