1 /**************************************************************************
2 * Copyright(c) 2002-2003, 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 **************************************************************************/
16 #include <Riostream.h>
17 #include "AliITSTableSSD.h"
22 ClassImp(AliITSTableSSD)
23 ////////////////////////////////////////////////////////////////////////
25 // Origin: Massimo Masera //
28 // AliITSTableSSD is used by AliITSsimulationSSD class to fill the AliITSpList
29 // object starting from the map with energy depositions
30 ////////////////////////////////////////////////////////////////////////
31 //----------------------------------------------------------------------
32 AliITSTableSSD::AliITSTableSSD() : TObject(),
35 // Default Constructor
36 for(Int_t i=0;i<2;i++){
41 //----------------------------------------------------------------------
42 AliITSTableSSD::AliITSTableSSD(const AliITSTableSSD & source):TObject(source),
44 fArray(source.fArray){
47 if(this == &source) return;
48 fArray = new Int_t [fDim];
49 fCurrUse[0]=(source.fCurrUse)[0];
50 fCurrUse[1]=(source.fCurrUse)[1];
51 fCurrFil[0]=(source.fCurrFil)[0];
52 fCurrFil[1]=(source.fCurrFil)[1];
53 for(Int_t i=0;i<fDim;i++)fArray[i]=(source.fArray)[i];
55 //----------------------------------------------------------------------
56 AliITSTableSSD& AliITSTableSSD::operator=(const AliITSTableSSD & source){
57 // = opporator constructor
59 if(this == &source) return *this;
61 if(fArray)delete [] fArray;
62 fArray = new Int_t [fDim];
63 fCurrUse[0]=(source.fCurrUse)[0];
64 fCurrUse[1]=(source.fCurrUse)[1];
65 fCurrFil[0]=(source.fCurrFil)[0];
66 fCurrFil[1]=(source.fCurrFil)[1];
67 for(Int_t i=0;i<fDim;i++)fArray[i]=(source.fArray)[i];
70 //----------------------------------------------------------------------
71 AliITSTableSSD::AliITSTableSSD(Int_t noelem) : TObject(),
74 // Standard constructor
76 fArray = new Int_t [fDim];
79 //----------------------------------------------------------------------
80 AliITSTableSSD::~AliITSTableSSD(){
85 //----------------------------------------------------------------------
86 void AliITSTableSSD::Add(Int_t side,Int_t strip){
87 // Add an element to the table
89 cerr<<" Error in AliITSTableSSD::Add. "<<strip<<" is out of range\n";
92 if((side!=0) && (side!=1)){
93 cerr<<" Error in AliITSTableSSD::Add. side="<<side<<endl;
94 cerr<<" side must be 0 or 1\n";
97 if(fCurrFil[side]>(fDim/2-1)){
98 cerr<<" Error in AliITSTableSSD::Add. Trying to fill an element out of range\n";
99 cerr<<" Element="<<fCurrFil[side]<<" while max limit is "<<(fDim/2-1)<<endl;
103 // P side = 0 and N side =1
104 Int_t index=(fDim/2)*side+fCurrFil[side];
105 Int_t * ptr= &fArray[(fDim/2)*side];
106 if(SearchValue(ptr,strip,fCurrFil[side])>=0)return;
110 //----------------------------------------------------------------------
111 void AliITSTableSSD::Clear(){
117 for(Int_t i=0;i<fDim;i++)fArray[i]=-1;
119 //----------------------------------------------------------------------
120 void AliITSTableSSD::DumpTable(){
121 // Dumps the contents of the table
122 cout<<"==============================================================\n";
123 cout<<" AliITSTableSSD::DumpTable \n";
124 cout<<" Dimension of the table "<<fDim<<" ("<<fDim/2<<" per side)\n";
125 cout<<" Current element to be filled for P side "<<fCurrFil[0]<<endl;
126 cout<<" Current element to be filled for N side "<<fCurrFil[1]<<endl;
127 cout<<" Current element in use for P side "<<fCurrUse[0]<<endl;
128 cout<<" Current element in use for N side "<<fCurrUse[1]<<endl;
129 cout<<"\n Elements for P side: \n";
130 for(Int_t i=0; i<fCurrFil[0];i++){
131 printf("%6d ",fArray[i]);
132 if(i%6==0 && i>0)printf("\n");
135 cout<<"\n Elements for N side: \n";
136 for(Int_t i=0; i<fCurrFil[1];i++){
137 printf("%6d ",fArray[fDim/2+i]);
138 if(i%6==0 && i>0)printf("\n");
143 //----------------------------------------------------------------------
144 Int_t AliITSTableSSD::Use(Int_t side){
145 // uses the current element. This means that the current element is returned
146 // and its content is replaced by -1. Hence each element can be used only
149 if((side!=0) && (side!=1)){
150 cerr<<" Error in AliITSTableSSD::Use. side="<<side<<endl;
151 cerr<<" side must be 0 or 1\n";
154 if(fCurrUse[side]>(fDim/2-1)){
155 cerr<<" Error in AliITSTableSSD::Use. Trying to use an element out of range\n";
156 cerr<<" Element="<<fCurrUse[side]<<" while max limit is "<<(fDim/2-1)<<endl;
160 Int_t index=(fDim/2)*side+fCurrUse[side];