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 matrix
109 if (fMatrix || fPositions)
111 for (Int_t i=0; i<fNrows; i++)
113 for (Int_t j=0; j<fNcolumns; j++)
116 if (fPositions[i][j]) delete fPositions[i][j];
126 delete [] fPositions;
141 ///////////////////////////////////////////////////////////////////////////
142 AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol)
144 // Create a calorimeter module matrix
151 fAttributes=new TMatrix(nrow,ncol);
152 fGains=new TMatrix(nrow,ncol);
153 fMatrix=new AliCalmodule**[nrow];
154 fPositions=new AliPosition**[nrow];
155 for (Int_t row=0; row<nrow; row++)
157 fMatrix[row]=new AliCalmodule*[ncol];
158 fPositions[row]=new AliPosition*[ncol];
159 // Initialise the various matrices
160 for (Int_t col=0; col<ncol; col++)
163 fPositions[row][col]=0;
164 (*fGains)(row,col)=1;
165 (*fAttributes)(row,col)=0;
169 // Mark the edge modules
170 for (Int_t j=0; j<ncol; j++)
172 (*fAttributes)(0,j)=10;
173 (*fAttributes)(nrow-1,j)=10;
175 for (Int_t i=0; i<nrow; i++)
177 (*fAttributes)(i,0)=10;
178 (*fAttributes)(i,ncol-1)=10;
189 ///////////////////////////////////////////////////////////////////////////
190 Int_t AliCalorimeter::GetNrows()
192 // Provide the number of rows for the calorimeter module matrix
195 ///////////////////////////////////////////////////////////////////////////
196 Int_t AliCalorimeter::GetNcolumns()
198 // Provide the number of columns for the calorimeter module matrix
201 ///////////////////////////////////////////////////////////////////////////
202 void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
204 // Set the signal for a certain calorimeter module
206 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
208 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
210 AliCalmodule* m=fMatrix[row-1][col-1];
211 if (!m) // only count new modules
215 fModules=new TObjArray(); // Default size, expanded automatically
216 fModules->SetOwner();
219 m=new AliCalmodule();
220 AliPosition* r=fPositions[row-1][col-1];
221 if (r) m->SetPosition(*r);
223 fMatrix[row-1][col-1]=m;
225 m->SetSignal(row,col,sig);
229 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
230 << " out of range." << endl;
231 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
234 ///////////////////////////////////////////////////////////////////////////
235 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
237 // Add the signal to a certain calorimeter module
239 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
241 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
243 AliCalmodule* m=fMatrix[row-1][col-1];
244 if (!m) // only count new modules
246 SetSignal(row,col,sig);
250 m->AddSignal(row,col,sig);
255 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
256 << " out of range." << endl;
257 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
260 ///////////////////////////////////////////////////////////////////////////
261 void AliCalorimeter::AddSignal(AliCalmodule* mod)
263 // Add the signal of module mod to the current calorimeter data.
264 // This enables mixing of calorimeter data of various events.
266 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
268 Int_t row=mod->GetRow();
269 Int_t col=mod->GetColumn();
270 Float_t sig=mod->GetSignal();
271 AliPosition r=mod->GetPosition();
273 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
275 AliCalmodule* m=fMatrix[row-1][col-1];
276 if (!m) // No module existed yet at this position
280 fModules=new TObjArray(); // Default size, expanded automatically
281 fModules->SetOwner();
286 fMatrix[row-1][col-1]=m;
289 m->AddSignal(row,col,sig);
290 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition(r);
294 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
295 << " out of range." << endl;
296 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
299 ///////////////////////////////////////////////////////////////////////////
300 void AliCalorimeter::Reset(Int_t row,Int_t col)
302 // Reset the signal for a certain calorimeter module
304 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
306 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
308 AliCalmodule* m=fMatrix[row-1][col-1];
313 fModules->Compress();
315 fMatrix[row-1][col-1]=0;
320 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
321 << " out of range." << endl;
322 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
325 ///////////////////////////////////////////////////////////////////////////
326 void AliCalorimeter::Reset()
328 // Reset the signals for the complete calorimeter
329 // Normally this is done to prepare for the data of the next event
330 // Note : Module gains, edge and dead flags remain unchanged
332 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
340 for (Int_t i=0; i<fNrows; i++)
342 for (Int_t j=0; j<fNcolumns; j++)
362 ///////////////////////////////////////////////////////////////////////////
363 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
365 // Provide the signal of a certain calorimeter module.
366 // In case the module was marked dead, 0 is returned.
368 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
370 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
373 AliCalmodule* m=fMatrix[row-1][col-1];
376 Int_t dead=m->GetDeadValue();
377 if (!dead) signal=m->GetSignal();
383 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
384 << " out of range." << endl;
385 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
389 ///////////////////////////////////////////////////////////////////////////
390 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
392 // Indicate a certain calorimeter module as 'edge module'
394 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
396 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
398 Float_t word=(*fAttributes)(row-1,col-1);
399 Int_t iword=int(word+0.1);
402 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
406 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
407 << " out of range." << endl;
408 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
411 ///////////////////////////////////////////////////////////////////////////
412 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
414 // Indicate a certain calorimeter module as 'non-edge module'
416 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
418 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
420 Float_t word=(*fAttributes)(row-1,col-1);
421 Int_t iword=int(word+0.1);
424 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
428 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
429 << " out of range." << endl;
430 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
433 ///////////////////////////////////////////////////////////////////////////
434 void AliCalorimeter::SetDead(Int_t row,Int_t col)
436 // Indicate a certain calorimeter module as 'dead module'
438 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
440 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
442 Float_t word=(*fAttributes)(row-1,col-1);
443 Int_t iword=int(word+0.1);
446 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
447 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
449 // Increase the 'edge value' of surrounding modules
455 if (rlow < 1) rlow=row;
456 if (rup > fNrows) rup=fNrows;
457 if (clow < 1) clow=col;
458 if (cup > fNcolumns) cup=fNcolumns;
460 for (Int_t i=rlow; i<=rup; i++)
462 for (Int_t j=clow; j<=cup; j++)
464 if (i!=row || j!=col) // No increase of edge value for the dead module itself
466 word=(*fAttributes)(i-1,j-1);
471 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
478 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
479 << " out of range." << endl;
480 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
483 ///////////////////////////////////////////////////////////////////////////
484 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
486 // Indicate a certain calorimeter module as 'active module'
488 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
490 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
492 Float_t word=(*fAttributes)(row-1,col-1);
493 Int_t iword=int(word+0.1);
496 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
497 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
499 // Decrease the 'edge value' of surrounding modules
505 if (rlow < 1) rlow=row;
506 if (rup > fNrows) rup=fNrows;
507 if (clow < 1) clow=col;
508 if (cup > fNcolumns) cup=fNcolumns;
510 for (Int_t i=rlow; i<=rup; i++)
512 for (Int_t j=clow; j<=cup; j++)
514 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
516 word=(*fAttributes)(i-1,j-1);
521 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
528 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
529 << " out of range." << endl;
530 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
533 ///////////////////////////////////////////////////////////////////////////
534 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
536 // Set the gain value for a certain calorimeter module
538 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
540 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
542 (*fGains)(row-1,col-1)=gain;
543 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
547 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
548 << " out of range." << endl;
549 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
552 ///////////////////////////////////////////////////////////////////////////
553 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
555 // Set the position in user coordinates for a certain calorimeter module
557 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
559 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
561 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
562 (fPositions[row-1][col-1])->SetVector(vec,f);
563 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
567 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
568 << " out of range." << endl;
569 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
572 ///////////////////////////////////////////////////////////////////////////
573 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
575 // Set the position for a certain calorimeter module
577 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
579 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
581 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
582 (fPositions[row-1][col-1])->SetPosition(r);
583 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
587 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
588 << " out of range." << endl;
589 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
592 ///////////////////////////////////////////////////////////////////////////
593 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
595 // Provide the value of the edge flag of a certain module
597 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
599 Float_t word=(*fAttributes)(row-1,col-1);
600 Int_t iword=int(word+0.1);
606 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
607 << " out of range." << endl;
608 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
612 ///////////////////////////////////////////////////////////////////////////
613 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
615 // Provide the value of the dead flag of a certain module
617 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
619 Float_t word=(*fAttributes)(row-1,col-1);
620 Int_t iword=int(word+0.1);
626 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
627 << " out of range." << endl;
628 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
632 ///////////////////////////////////////////////////////////////////////////
633 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
635 // Provide the gain value of a certain module
637 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
639 return (*fGains)(row-1,col-1);
643 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
644 << " out of range." << endl;
645 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
649 ///////////////////////////////////////////////////////////////////////////
650 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
652 // Return the position in user coordinates for a certain calorimeter module
654 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
656 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
658 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
659 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
663 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
664 << " out of range." << endl;
665 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
668 ///////////////////////////////////////////////////////////////////////////
669 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
671 // Access to the position of a certain calorimeter module
673 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
675 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
677 return fPositions[row-1][col-1];
681 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
682 << " out of range." << endl;
683 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
687 ///////////////////////////////////////////////////////////////////////////
688 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
690 // Provide the module signal after clustering
692 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
694 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
696 if (fMatrix[row-1][col-1])
698 return (fMatrix[row-1][col-1])->GetClusteredSignal();
707 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
708 << " out of range." << endl;
709 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
713 ///////////////////////////////////////////////////////////////////////////
714 Int_t AliCalorimeter::GetNsignals()
716 // Provide the number of modules that contain a signal
717 // Note : The number of modules marked 'dead' but which had a signal
721 ///////////////////////////////////////////////////////////////////////////
722 void AliCalorimeter::Group(Int_t n)
724 // Group the individual modules into clusters
725 // Module signals of n rings around the central module will be grouped
727 if (fNsignals > 0) // Directly return if no modules fired
729 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
731 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
733 // Order the modules with decreasing signal
734 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
738 // Clustering of modules. Start with the highest signal.
744 fClusters=new TObjArray();
745 fClusters->SetOwner();
751 for (Int_t i=0; i<nord; i++)
753 row=ordered[i]->GetRow(); // row number of cluster center
754 col=ordered[i]->GetColumn(); // column number of cluster center
755 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
757 m=fMatrix[row-1][col-1];
760 // only use modules not yet used in a cluster
761 if (m->GetClusteredSignal() > 0.)
763 Int_t edge=GetEdgeValue(row,col);
765 if (!edge) c->Start(*m); // module to start the cluster if not on edge
766 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
769 fNclusters++; // update cluster counter
770 AddRing(row,col,n); // add signals of n rings around the center
781 // Delete the temp. array
784 for (Int_t j=0; j<nord; j++)
792 ///////////////////////////////////////////////////////////////////////////
793 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
795 // Order the modules with decreasing signal
798 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
800 for (Int_t ii=0; ii<fNcolumns; ii++)
802 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
804 if (nord == 0) // store the first module with a signal at the first ordered position
807 ordered[nord-1]=fMatrix[i][ii];
811 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
813 if (j == nord) // module has smallest signal seen so far
816 ordered[j]=fMatrix[i][ii]; // add module at the end
817 break; // go for next matrix module
820 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
823 for (Int_t k=nord-1; k>j; k--) // create empty position
825 ordered[k]=ordered[k-1];
827 ordered[j]=fMatrix[i][ii]; // put module at empty position
828 break; // go for next matrix module
833 ///////////////////////////////////////////////////////////////////////////
834 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
836 // Add module signals of 1 ring around (row,col) to current cluster
837 // n denotes the maximum number of rings around cluster center
838 // Note : This function is used recursively
840 if (n >= 1) // Check if any rings left for recursive calls
842 Float_t signal=GetSignal(row,col); // signal of (row,col) module
844 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
845 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
846 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
847 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
849 for (Int_t i=lrow; i<=urow; i++)
851 for (Int_t j=lcol; j<=ucol; j++)
853 // add module(i,j) to cluster if the signal <= signal(row,col)
854 if (GetSignal(i,j) <= signal)
856 AliCalmodule* m=fMatrix[i-1][j-1];
857 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
859 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
864 ///////////////////////////////////////////////////////////////////////////
865 Int_t AliCalorimeter::GetNclusters()
867 // Provide the number of clusters
870 ///////////////////////////////////////////////////////////////////////////
871 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
873 // Provide cluster number j
874 // Note : j=1 denotes the first cluster
875 if ((j >= 1) && (j <= fNclusters))
877 return (AliCalcluster*)fClusters->At(j-1);
881 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
882 << " out of range." << endl;
883 cout << " -- Cluster number 1 (if any) returned " << endl;
884 return (AliCalcluster*)fClusters->At(0);
887 ///////////////////////////////////////////////////////////////////////////
888 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
890 // Provide 'fired' module number j
891 // Note : j=1 denotes the first 'fired' module
892 if ((j >= 1) && (j <= fNsignals))
894 return (AliCalmodule*)fModules->At(j-1);
898 cout << " *AliCalorimeter::GetModule* module number : " << j
899 << " out of range." << endl;
900 cout << " -- Fired module number 1 (if any) returned " << endl;
901 return (AliCalmodule*)fModules->At(0);
904 ///////////////////////////////////////////////////////////////////////////
905 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
907 // Provide access to module (row,col).
908 // Note : first module is at (1,1).
910 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
912 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
914 return fMatrix[row-1][col-1];
918 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
919 << " out of range." << endl;
923 ///////////////////////////////////////////////////////////////////////////
924 TH2F* AliCalorimeter::DrawModules()
926 // Provide a lego plot of the module signals
934 fHmodules=new TH2F("fHmodules","Module signals",
935 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
937 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
941 Float_t row,col,signal;
943 for (Int_t i=0; i<fNsignals; i++)
945 m=(AliCalmodule*)fModules->At(i);
948 row=float(m->GetRow());
949 col=float(m->GetColumn());
950 dead=m->GetDeadValue();
952 if (!dead) signal=m->GetSignal();
953 if (signal>0.) fHmodules->Fill(col,row,signal);
957 fHmodules->Draw("lego");
960 ///////////////////////////////////////////////////////////////////////////
961 TH2F* AliCalorimeter::DrawClusters()
963 // Provide a lego plot of the cluster signals
971 fHclusters=new TH2F("fHclusters","Cluster signals",
972 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
974 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
978 Float_t row,col,signal;
979 for (Int_t i=0; i<fNclusters; i++)
981 c=(AliCalcluster*)fClusters->At(i);
984 row=float(c->GetRow());
985 col=float(c->GetColumn());
986 signal=c->GetSignal();
987 if (signal>0.) fHclusters->Fill(col,row,signal);
991 fHclusters->Draw("lego");
994 ///////////////////////////////////////////////////////////////////////////
995 void AliCalorimeter::LoadMatrix()
997 // Load the Calorimeter module matrix data back from the TObjArray
999 // Initialise the module matrix
1002 fMatrix=new AliCalmodule**[fNrows];
1003 for (Int_t i=0; i<fNrows; i++)
1005 fMatrix[i]=new AliCalmodule*[fNcolumns];
1009 // Initialise the position matrix
1012 fPositions=new AliPosition**[fNrows];
1013 for (Int_t j=0; j<fNrows; j++)
1015 fPositions[j]=new AliPosition*[fNcolumns];
1019 for (Int_t jrow=0; jrow<fNrows; jrow++)
1021 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1023 fMatrix[jrow][jcol]=0;
1024 fPositions[jrow][jcol]=0;
1028 // Copy the module pointers back into the matrix
1033 if (fModules) nsig=fModules->GetEntries();
1034 for (Int_t j=0; j<nsig; j++)
1036 m=(AliCalmodule*)fModules->At(j);
1041 AliPosition r=m->GetPosition();
1042 fMatrix[row-1][col-1]=m;
1043 fPositions[row-1][col-1]=new AliPosition(r);
1047 ///////////////////////////////////////////////////////////////////////////
1048 void AliCalorimeter::Ungroup()
1050 // Set the module signals back to the non-clustered situation
1052 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1055 if (fModules) nsig=fModules->GetEntries();
1059 for (Int_t j=0; j<nsig; j++)
1061 m=(AliCalmodule*)fModules->At(j);
1064 signal=m->GetSignal();
1065 m->SetClusteredSignal(signal);
1069 ///////////////////////////////////////////////////////////////////////////
1070 void AliCalorimeter::AddVetoSignal(AliSignal& s)
1072 // Associate an (extrapolated) AliSignal as veto to the calorimeter.
1076 fVetos=new TObjArray();
1080 Int_t nvalues=s.GetNvalues();
1081 AliSignal* sx=new AliSignal(nvalues);
1082 sx->SetName(s.GetName());
1084 sx->SetPosition((Ali3Vector&)s);
1087 for (Int_t i=1; i<=nvalues; i++)
1090 err=s.GetSignalError(i);
1091 sx->SetSignal(sig,i);
1092 sx->SetSignalError(err,i);
1098 ///////////////////////////////////////////////////////////////////////////
1099 Int_t AliCalorimeter::GetNvetos()
1101 // Provide the number of veto signals associated to the calorimeter
1104 ///////////////////////////////////////////////////////////////////////////
1105 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1107 // Provide access to the i-th veto signal of this calorimeter
1108 // Note : The first hit corresponds to i=1
1110 if (i>0 && i<=fNvetos)
1112 return (AliSignal*)fVetos->At(i-1);
1116 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1117 << " out of range." << endl;
1118 cout << " --- First signal (if any) returned." << endl;
1119 return (AliSignal*)fVetos->At(0);
1122 ///////////////////////////////////////////////////////////////////////////
1123 void AliCalorimeter::SetName(TString name)
1125 // Set the name of the calorimeter system.
1128 ///////////////////////////////////////////////////////////////////////////
1129 TString AliCalorimeter::GetName()
1131 // Provide the name of the calorimeter system.
1134 ///////////////////////////////////////////////////////////////////////////