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");
41 // Float_t loc[3]={-1,12,3};
42 // cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto
44 // cal.Group(2); // Group 'fired' modules into clusters
45 // // Perform grouping over 2 rings around the center
46 // cal.Reset(); // Reset the complete calorimeter
47 // // Normally to prepare for the next event data
48 // // Note : Module gain, edge and dead flags remain
50 //--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht
51 //- Modified: NvE $Date$ UU-SAP Utrecht
52 ///////////////////////////////////////////////////////////////////////////
54 #include "AliCalorimeter.h"
56 ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
58 AliCalorimeter::AliCalorimeter()
60 // Default constructor, all parameters set to 0
76 ///////////////////////////////////////////////////////////////////////////
77 AliCalorimeter::~AliCalorimeter()
79 // Destructor to delete memory allocated to the various arrays and matrix
108 if (fMatrix || fPositions)
110 for (Int_t i=0; i<fNrows; i++)
112 for (Int_t j=0; j<fNcolumns; j++)
115 if (fPositions[i][j]) delete fPositions[i][j];
125 delete [] fPositions;
140 ///////////////////////////////////////////////////////////////////////////
141 AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol)
143 // Create a calorimeter module matrix
149 fAttributes=new TMatrix(nrow,ncol);
150 fGains=new TMatrix(nrow,ncol);
151 fMatrix=new AliCalmodule**[nrow];
152 fPositions=new AliPosition**[nrow];
153 for (Int_t row=0; row<nrow; row++)
155 fMatrix[row]=new AliCalmodule*[ncol];
156 fPositions[row]=new AliPosition*[ncol];
157 // Initialise the various matrices
158 for (Int_t col=0; col<ncol; col++)
161 fPositions[row][col]=0;
162 (*fGains)(row,col)=1;
163 (*fAttributes)(row,col)=0;
167 // Mark the edge modules
168 for (Int_t j=0; j<ncol; j++)
170 (*fAttributes)(0,j)=10;
171 (*fAttributes)(nrow-1,j)=10;
173 for (Int_t i=0; i<nrow; i++)
175 (*fAttributes)(i,0)=10;
176 (*fAttributes)(i,ncol-1)=10;
179 fModules=new TObjArray(); // Default size, expanded automatically
187 ///////////////////////////////////////////////////////////////////////////
188 Int_t AliCalorimeter::GetNrows()
190 // Provide the number of rows for the calorimeter module matrix
193 ///////////////////////////////////////////////////////////////////////////
194 Int_t AliCalorimeter::GetNcolumns()
196 // Provide the number of columns for the calorimeter module matrix
199 ///////////////////////////////////////////////////////////////////////////
200 void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
202 // Set the signal for a certain calorimeter module
204 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
206 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
208 AliCalmodule* m=fMatrix[row-1][col-1];
209 if (!m) // only count new modules
213 AliPosition* r=fPositions[row-1][col-1];
214 if (r) m->SetPosition(*r);
216 fMatrix[row-1][col-1]=m;
218 m->SetSignal(row,col,sig);
222 cout << " *AliCalorimeter::SetSignal* row,col : " << row << "," << col
223 << " out of range." << endl;
224 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
227 ///////////////////////////////////////////////////////////////////////////
228 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
230 // Add the signal to a certain calorimeter module
232 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
234 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
236 AliCalmodule* m=fMatrix[row-1][col-1];
237 if (!m) // only count new modules
239 SetSignal(row,col,sig);
243 m->AddSignal(row,col,sig);
248 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
249 << " out of range." << endl;
250 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
253 ///////////////////////////////////////////////////////////////////////////
254 void AliCalorimeter::AddSignal(AliCalmodule* mod)
256 // Add the signal of module mod to the current calorimeter data.
257 // This enables mixing of calorimeter data of various events.
259 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
261 Int_t row=mod->GetRow();
262 Int_t col=mod->GetColumn();
263 Float_t sig=mod->GetSignal();
264 AliPosition r=mod->GetPosition();
266 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
268 AliCalmodule* m=fMatrix[row-1][col-1];
269 if (!m) // No module existed yet at this position
274 fMatrix[row-1][col-1]=m;
277 m->AddSignal(row,col,sig);
278 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition(r);
282 cout << " *AliCalorimeter::AddSignal* row,col : " << row << "," << col
283 << " out of range." << endl;
284 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
287 ///////////////////////////////////////////////////////////////////////////
288 void AliCalorimeter::Reset(Int_t row,Int_t col)
290 // Reset the signal for a certain calorimeter module
292 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
294 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
296 AliCalmodule* m=fMatrix[row-1][col-1];
301 fModules->Compress();
303 fMatrix[row-1][col-1]=0;
308 cout << " *AliCalorimeter::Reset* row,col : " << row << "," << col
309 << " out of range." << endl;
310 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
313 ///////////////////////////////////////////////////////////////////////////
314 void AliCalorimeter::Reset()
316 // Reset the signals for the complete calorimeter
317 // Normally this is done to prepare for the data of the next event
318 // Note : Module gains, edge and dead flags remain unchanged
320 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
323 if (fModules) fModules->Delete();
324 for (Int_t i=0; i<fNrows; i++)
326 for (Int_t j=0; j<fNcolumns; j++)
348 ///////////////////////////////////////////////////////////////////////////
349 Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
351 // Provide the signal of a certain calorimeter module.
352 // In case the module was marked dead, 0 is returned.
354 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
356 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
359 AliCalmodule* m=fMatrix[row-1][col-1];
362 Int_t dead=m->GetDeadValue();
363 if (!dead) signal=m->GetSignal();
369 cout << " *AliCalorimeter::GetSignal* row,col : " << row << "," << col
370 << " out of range." << endl;
371 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
375 ///////////////////////////////////////////////////////////////////////////
376 void AliCalorimeter::SetEdgeOn(Int_t row,Int_t col)
378 // Indicate a certain calorimeter module as 'edge module'
380 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
382 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
384 Float_t word=(*fAttributes)(row-1,col-1);
385 Int_t iword=int(word+0.1);
388 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
392 cout << " *AliCalorimeter::SetEdgeOn* row,col : " << row << "," << col
393 << " out of range." << endl;
394 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
397 ///////////////////////////////////////////////////////////////////////////
398 void AliCalorimeter::SetEdgeOff(Int_t row,Int_t col)
400 // Indicate a certain calorimeter module as 'non-edge module'
402 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
404 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
406 Float_t word=(*fAttributes)(row-1,col-1);
407 Int_t iword=int(word+0.1);
410 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
414 cout << " *AliCalorimeter::SetEdgeOff* row,col : " << row << "," << col
415 << " out of range." << endl;
416 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
419 ///////////////////////////////////////////////////////////////////////////
420 void AliCalorimeter::SetDead(Int_t row,Int_t col)
422 // Indicate a certain calorimeter module as 'dead module'
424 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
426 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
428 Float_t word=(*fAttributes)(row-1,col-1);
429 Int_t iword=int(word+0.1);
432 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
433 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetDead();
435 // Increase the 'edge value' of surrounding modules
441 if (rlow < 1) rlow=row;
442 if (rup > fNrows) rup=fNrows;
443 if (clow < 1) clow=col;
444 if (cup > fNcolumns) cup=fNcolumns;
446 for (Int_t i=rlow; i<=rup; i++)
448 for (Int_t j=clow; j<=cup; j++)
450 if (i!=row || j!=col) // No increase of edge value for the dead module itself
452 word=(*fAttributes)(i-1,j-1);
457 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
464 cout << " *AliCalorimeter::SetDead* row,col : " << row << "," << col
465 << " out of range." << endl;
466 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
469 ///////////////////////////////////////////////////////////////////////////
470 void AliCalorimeter::SetAlive(Int_t row,Int_t col)
472 // Indicate a certain calorimeter module as 'active module'
474 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
476 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
478 Float_t word=(*fAttributes)(row-1,col-1);
479 Int_t iword=int(word+0.1);
482 (*fAttributes)(row-1,col-1)=float(dead+10*edge);
483 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetAlive();
485 // Decrease the 'edge value' of surrounding modules
491 if (rlow < 1) rlow=row;
492 if (rup > fNrows) rup=fNrows;
493 if (clow < 1) clow=col;
494 if (cup > fNcolumns) cup=fNcolumns;
496 for (Int_t i=rlow; i<=rup; i++)
498 for (Int_t j=clow; j<=cup; j++)
500 if (i!=row || j!=col) // No decrease of edge value for the dead module itself
502 word=(*fAttributes)(i-1,j-1);
507 (*fAttributes)(i-1,j-1)=float(dead+10*edge);
514 cout << " *AliCalorimeter::SetAlive* row,col : " << row << "," << col
515 << " out of range." << endl;
516 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
519 ///////////////////////////////////////////////////////////////////////////
520 void AliCalorimeter::SetGain(Int_t row,Int_t col,Float_t gain)
522 // Set the gain value for a certain calorimeter module
524 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
526 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
528 (*fGains)(row-1,col-1)=gain;
529 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetGain(gain);
533 cout << " *AliCalorimeter::SetGain* row,col : " << row << "," << col
534 << " out of range." << endl;
535 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
538 ///////////////////////////////////////////////////////////////////////////
539 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
541 // Set the position in user coordinates for a certain calorimeter module
543 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
545 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
547 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
548 (fPositions[row-1][col-1])->SetVector(vec,f);
549 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(vec,f);
553 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
554 << " out of range." << endl;
555 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
558 ///////////////////////////////////////////////////////////////////////////
559 void AliCalorimeter::SetPosition(Int_t row,Int_t col,Ali3Vector& r)
561 // Set the position for a certain calorimeter module
563 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
565 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
567 if (!fPositions[row-1][col-1]) fPositions[row-1][col-1]=new AliPosition;
568 (fPositions[row-1][col-1])->SetPosition(r);
569 if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->SetPosition(r);
573 cout << " *AliCalorimeter::SetPosition* row,col : " << row << "," << col
574 << " out of range." << endl;
575 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
578 ///////////////////////////////////////////////////////////////////////////
579 Int_t AliCalorimeter::GetEdgeValue(Int_t row,Int_t col)
581 // Provide the value of the edge flag of a certain module
583 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
585 Float_t word=(*fAttributes)(row-1,col-1);
586 Int_t iword=int(word+0.1);
592 cout << " *AliCalorimeter::GetEdgeValue* row,col : " << row << "," << col
593 << " out of range." << endl;
594 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
598 ///////////////////////////////////////////////////////////////////////////
599 Int_t AliCalorimeter::GetDeadValue(Int_t row,Int_t col)
601 // Provide the value of the dead flag of a certain module
603 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
605 Float_t word=(*fAttributes)(row-1,col-1);
606 Int_t iword=int(word+0.1);
612 cout << " *AliCalorimeter::GetDeadValue* row,col : " << row << "," << col
613 << " out of range." << endl;
614 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
618 ///////////////////////////////////////////////////////////////////////////
619 Float_t AliCalorimeter::GetGain(Int_t row,Int_t col)
621 // Provide the gain value of a certain module
623 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
625 return (*fGains)(row-1,col-1);
629 cout << " *AliCalorimeter::GetGain* row,col : " << row << "," << col
630 << " out of range." << endl;
631 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
635 ///////////////////////////////////////////////////////////////////////////
636 void AliCalorimeter::GetPosition(Int_t row,Int_t col,Float_t* vec,TString f)
638 // Return the position in user coordinates for a certain calorimeter module
640 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
642 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
644 // if (fMatrix[row-1][col-1]) (fMatrix[row-1][col-1])->GetPosition(vec,f);
645 if (fPositions[row-1][col-1]) (fPositions[row-1][col-1])->GetVector(vec,f);
649 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
650 << " out of range." << endl;
651 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
654 ///////////////////////////////////////////////////////////////////////////
655 AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
657 // Access to the position of a certain calorimeter module
659 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
661 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
663 return fPositions[row-1][col-1];
667 cout << " *AliCalorimeter::GetPosition* row,col : " << row << "," << col
668 << " out of range." << endl;
669 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
673 ///////////////////////////////////////////////////////////////////////////
674 Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
676 // Provide the module signal after clustering
678 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
680 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
682 if (fMatrix[row-1][col-1])
684 return (fMatrix[row-1][col-1])->GetClusteredSignal();
693 cout << " *AliCalorimeter::GetClusteredSignal* row,col : " << row << "," << col
694 << " out of range." << endl;
695 cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
699 ///////////////////////////////////////////////////////////////////////////
700 Int_t AliCalorimeter::GetNsignals()
702 // Provide the number of modules that contain a signal
703 // Note : The number of modules marked 'dead' but which had a signal
707 ///////////////////////////////////////////////////////////////////////////
708 void AliCalorimeter::Group(Int_t n)
710 // Group the individual modules into clusters
711 // Module signals of n rings around the central module will be grouped
713 if (fNsignals > 0) // Directly return if no modules fired
715 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
717 if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed
719 // Order the modules with decreasing signal
720 AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules
724 // Clustering of modules. Start with the highest signal.
731 fClusters=new TObjArray();
737 for (Int_t i=0; i<nord; i++)
739 row=ordered[i]->GetRow(); // row number of cluster center
740 col=ordered[i]->GetColumn(); // column number of cluster center
741 if (row>0 && row<=fNrows && col>0 && col<=fNcolumns)
743 m=fMatrix[row-1][col-1];
746 // only use modules not yet used in a cluster
747 if (m->GetClusteredSignal() > 0.)
749 Int_t edge=GetEdgeValue(row,col);
751 if (!edge) c->Start(*m); // module to start the cluster if not on edge
752 if (c->GetNmodules() > 0) // cluster started successfully (no edge)
755 fNclusters++; // update cluster counter
756 AddRing(row,col,n); // add signals of n rings around the center
767 // Delete the temp. array
770 for (Int_t j=0; j<nord; j++)
778 ///////////////////////////////////////////////////////////////////////////
779 void AliCalorimeter::Sortm(AliCalmodule** ordered,Int_t& nord)
781 // Order the modules with decreasing signal
784 for (Int_t i=0; i<fNrows; i++) // loop over all modules of the matrix
786 for (Int_t ii=0; ii<fNcolumns; ii++)
788 if (GetSignal(i+1,ii+1) <= 0.) continue; // only take alive modules with a signal
790 if (nord == 0) // store the first module with a signal at the first ordered position
793 ordered[nord-1]=fMatrix[i][ii];
797 for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
799 if (j == nord) // module has smallest signal seen so far
802 ordered[j]=fMatrix[i][ii]; // add module at the end
803 break; // go for next matrix module
806 if (GetSignal(i+1,ii+1) < ordered[j]->GetSignal()) continue;
809 for (Int_t k=nord-1; k>j; k--) // create empty position
811 ordered[k]=ordered[k-1];
813 ordered[j]=fMatrix[i][ii]; // put module at empty position
814 break; // go for next matrix module
819 ///////////////////////////////////////////////////////////////////////////
820 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
822 // Add module signals of 1 ring around (row,col) to current cluster
823 // n denotes the maximum number of rings around cluster center
824 // Note : This function is used recursively
826 if (n >= 1) // Check if any rings left for recursive calls
828 Float_t signal=GetSignal(row,col); // signal of (row,col) module
830 Int_t lrow=row-1; if (lrow < 1) lrow=1; // row lowerbound for ring
831 Int_t urow=row+1; if (urow > fNrows) urow=fNrows; // row upperbound for ring
832 Int_t lcol=col-1; if (lcol < 1) lcol=1; // col lowerbound for ring
833 Int_t ucol=col+1; if (ucol > fNcolumns) ucol=fNcolumns; // row upperbound for ring
835 for (Int_t i=lrow; i<=urow; i++)
837 for (Int_t j=lcol; j<=ucol; j++)
839 // add module(i,j) to cluster if the signal <= signal(row,col)
840 if (GetSignal(i,j) <= signal)
842 AliCalmodule* m=fMatrix[i-1][j-1];
843 if (m) ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(*m);
845 AddRing(i,j,n-1); // Go for ring of modules around this (i,j) one
850 ///////////////////////////////////////////////////////////////////////////
851 Int_t AliCalorimeter::GetNclusters()
853 // Provide the number of clusters
856 ///////////////////////////////////////////////////////////////////////////
857 AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
859 // Provide cluster number j
860 // Note : j=1 denotes the first cluster
861 if ((j >= 1) && (j <= fNclusters))
863 return (AliCalcluster*)fClusters->At(j-1);
867 cout << " *AliCalorimeter::GetCluster* cluster number : " << j
868 << " out of range." << endl;
869 cout << " -- Cluster number 1 (if any) returned " << endl;
870 return (AliCalcluster*)fClusters->At(0);
873 ///////////////////////////////////////////////////////////////////////////
874 AliCalmodule* AliCalorimeter::GetModule(Int_t j)
876 // Provide 'fired' module number j
877 // Note : j=1 denotes the first 'fired' module
878 if ((j >= 1) && (j <= fNsignals))
880 return (AliCalmodule*)fModules->At(j-1);
884 cout << " *AliCalorimeter::GetModule* module number : " << j
885 << " out of range." << endl;
886 cout << " -- Fired module number 1 (if any) returned " << endl;
887 return (AliCalmodule*)fModules->At(0);
890 ///////////////////////////////////////////////////////////////////////////
891 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
893 // Provide access to module (row,col).
894 // Note : first module is at (1,1).
896 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
898 if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns)
900 return fMatrix[row-1][col-1];
904 cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col
905 << " out of range." << endl;
909 ///////////////////////////////////////////////////////////////////////////
910 TH2F* AliCalorimeter::DrawModules()
912 // Provide a lego plot of the module signals
920 fHmodules=new TH2F("fHmodules","Module signals",
921 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
923 fHmodules->SetDirectory(0); // Suppress global character of histo pointer
927 Float_t row,col,signal;
929 for (Int_t i=0; i<fNsignals; i++)
931 m=(AliCalmodule*)fModules->At(i);
934 row=float(m->GetRow());
935 col=float(m->GetColumn());
936 dead=m->GetDeadValue();
938 if (!dead) signal=m->GetSignal();
939 if (signal>0.) fHmodules->Fill(col,row,signal);
943 fHmodules->Draw("lego");
946 ///////////////////////////////////////////////////////////////////////////
947 TH2F* AliCalorimeter::DrawClusters()
949 // Provide a lego plot of the cluster signals
957 fHclusters=new TH2F("fHclusters","Cluster signals",
958 fNcolumns,0.5,float(fNcolumns)+0.5,fNrows,0.5,float(fNrows)+0.5);
960 fHclusters->SetDirectory(0); // Suppress global character of histo pointer
964 Float_t row,col,signal;
965 for (Int_t i=0; i<fNclusters; i++)
967 c=(AliCalcluster*)fClusters->At(i);
970 row=float(c->GetRow());
971 col=float(c->GetColumn());
972 signal=c->GetSignal();
973 if (signal>0.) fHclusters->Fill(col,row,signal);
977 fHclusters->Draw("lego");
980 ///////////////////////////////////////////////////////////////////////////
981 void AliCalorimeter::LoadMatrix()
983 // Load the Calorimeter module matrix data back from the TObjArray
985 // Initialise the module matrix
988 fMatrix=new AliCalmodule**[fNrows];
989 for (Int_t i=0; i<fNrows; i++)
991 fMatrix[i]=new AliCalmodule*[fNcolumns];
995 // Initialise the position matrix
998 fPositions=new AliPosition**[fNrows];
999 for (Int_t j=0; j<fNrows; j++)
1001 fPositions[j]=new AliPosition*[fNcolumns];
1005 for (Int_t jrow=0; jrow<fNrows; jrow++)
1007 for (Int_t jcol=0; jcol<fNcolumns; jcol++)
1009 fMatrix[jrow][jcol]=0;
1010 fPositions[jrow][jcol]=0;
1014 // Copy the module pointers back into the matrix
1019 if (fModules) nsig=fModules->GetEntries();
1020 for (Int_t j=0; j<nsig; j++)
1022 m=(AliCalmodule*)fModules->At(j);
1027 AliPosition r=m->GetPosition();
1028 fMatrix[row-1][col-1]=m;
1029 fPositions[row-1][col-1]=new AliPosition(r);
1033 ///////////////////////////////////////////////////////////////////////////
1034 void AliCalorimeter::Ungroup()
1036 // Set the module signals back to the non-clustered situation
1038 if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
1041 if (fModules) nsig=fModules->GetEntries();
1045 for (Int_t j=0; j<nsig; j++)
1047 m=(AliCalmodule*)fModules->At(j);
1050 signal=m->GetSignal();
1051 m->SetClusteredSignal(signal);
1055 ///////////////////////////////////////////////////////////////////////////
1056 void AliCalorimeter::AddVetoSignal(Float_t* r,TString f,Float_t s)
1058 // Associate an (extrapolated) AliSignal at location r as veto to the cal.
1059 // Note : The default signal value (s) is 0
1063 fVetos=new TObjArray();
1066 fVetos->Add(new AliSignal);
1069 ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
1070 ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
1072 ///////////////////////////////////////////////////////////////////////////
1073 Int_t AliCalorimeter::GetNvetos()
1075 // Provide the number of veto signals associated to the calorimeter
1078 ///////////////////////////////////////////////////////////////////////////
1079 AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
1081 // Provide access to the i-th veto signal of this calorimeter
1082 // Note : The first hit corresponds to i=1
1084 if (i>0 && i<=fNvetos)
1086 return (AliSignal*)fVetos->At(i-1);
1090 cout << " *AliCalorimeter::GetVetoSignal* Signal number " << i
1091 << " out of range." << endl;
1092 cout << " --- First signal (if any) returned." << endl;
1093 return (AliSignal*)fVetos->At(0);
1096 ///////////////////////////////////////////////////////////////////////////