]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSTableSSD.cxx
Now the full chain includes raw data.
[u/mrichter/AliRoot.git] / ITS / AliITSTableSSD.cxx
CommitLineData
d895ac37 1/**************************************************************************
2 * Copyright(c) 2002-2003, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
4ae5bbc4 16#include <Riostream.h>
d895ac37 17#include "AliITSTableSSD.h"
18
925e6570 19ClassImp(AliITSTableSSD)
d895ac37 20////////////////////////////////////////////////////////////////////////
21// Version: 0
22// Origin: Massimo Masera
23// March 2002
24//
25// AliITSTableSSD is used by AliITSsimulationSSD class to fill the AliITSpList
26// object starting from the map with energy depositions
27
28//----------------------------------------------------------------------
25393432 29AliITSTableSSD::AliITSTableSSD() : TObject(){
d895ac37 30 // Default Constructor
31 fDim=0;
32 fArray=0;
33 for(Int_t i=0;i<2;i++){
34 fCurrUse[i]=0;
35 fCurrFil[i]=0;
36 }
37}
38//----------------------------------------------------------------------
25393432 39AliITSTableSSD::AliITSTableSSD(const AliITSTableSSD & source):TObject(source){
d895ac37 40 // Copy constructor
25393432 41
42 if(this == &source) return;
43 fDim=source.fDim;
44 fArray = new Int_t [fDim];
45 fCurrUse[0]=(source.fCurrUse)[0];
46 fCurrUse[1]=(source.fCurrUse)[1];
47 fCurrFil[0]=(source.fCurrFil)[0];
48 fCurrFil[1]=(source.fCurrFil)[1];
49 for(Int_t i=0;i<fDim;i++)fArray[i]=(source.fArray)[i];
50}
51//----------------------------------------------------------------------
52AliITSTableSSD& AliITSTableSSD::operator=(const AliITSTableSSD & source){
53 // = opporator constructor
54
55 if(this == &source) return *this;
56 fDim=source.fDim;
57 fArray = new Int_t [fDim];
58 fCurrUse[0]=(source.fCurrUse)[0];
59 fCurrUse[1]=(source.fCurrUse)[1];
60 fCurrFil[0]=(source.fCurrFil)[0];
61 fCurrFil[1]=(source.fCurrFil)[1];
62 for(Int_t i=0;i<fDim;i++)fArray[i]=(source.fArray)[i];
63 return *this;
d895ac37 64}
65//----------------------------------------------------------------------
25393432 66AliITSTableSSD::AliITSTableSSD(Int_t noelem) : TObject(){
d895ac37 67 // Standard constructor
68 fDim=noelem*2;
69 fArray = new Int_t [fDim];
70 Clear();
71}
72//----------------------------------------------------------------------
73AliITSTableSSD::~AliITSTableSSD(){
74 // Destructor
75 delete [] fArray;
76 fArray=0;
77}
78//----------------------------------------------------------------------
79void AliITSTableSSD::Add(Int_t side,Int_t strip){
80 // Add an element to the table
81 if(strip>=fDim/2){
82 cerr<<" Error in AliITSTableSSD::Add. "<<strip<<" is out of range\n";
83 return;
84 }
85 if((side!=0) && (side!=1)){
86 cerr<<" Error in AliITSTableSSD::Add. side="<<side<<endl;
87 cerr<<" side must be 0 or 1\n";
88 return;
89 }
90 if(fCurrFil[side]>(fDim/2-1)){
91 cerr<<" Error in AliITSTableSSD::Add. Trying to fill an element out of range\n";
92 cerr<<" Element="<<fCurrFil[side]<<" while max limit is "<<(fDim/2-1)<<endl;
93 fCurrFil[side]++;
94 return;
95 }
96 // P side = 0 and N side =1
97 Int_t index=(fDim/2)*side+fCurrFil[side];
98 Int_t * ptr= &fArray[(fDim/2)*side];
99 if(SearchValue(ptr,strip,fCurrFil[side])>=0)return;
100 fArray[index]=strip;
101 fCurrFil[side]++;
102}
103//----------------------------------------------------------------------
104void AliITSTableSSD::Clear(){
105 fCurrUse[0]= 0;
106 fCurrUse[1] = 0;
107 fCurrFil[0]= 0;
108 fCurrFil[1] = 0;
109 for(Int_t i=0;i<fDim;i++)fArray[i]=-1;
110}
111//----------------------------------------------------------------------
112void AliITSTableSSD::DumpTable(){
113 // Dumps the contents of the table
114 cout<<"==============================================================\n";
115 cout<<" AliITSTableSSD::DumpTable \n";
116 cout<<" Dimension of the table "<<fDim<<" ("<<fDim/2<<" per side)\n";
117 cout<<" Current element to be filled for P side "<<fCurrFil[0]<<endl;
118 cout<<" Current element to be filled for N side "<<fCurrFil[1]<<endl;
119 cout<<" Current element in use for P side "<<fCurrUse[0]<<endl;
120 cout<<" Current element in use for N side "<<fCurrUse[1]<<endl;
121 cout<<"\n Elements for P side: \n";
122 for(Int_t i=0; i<fCurrFil[0];i++){
123 printf("%6d ",fArray[i]);
124 if(i%6==0 && i>0)printf("\n");
125 }
126 printf("\n");
127 cout<<"\n Elements for N side: \n";
128 for(Int_t i=0; i<fCurrFil[1];i++){
129 printf("%6d ",fArray[fDim/2+i]);
130 if(i%6==0 && i>0)printf("\n");
131 }
132 printf("\n");
133}
134
135//----------------------------------------------------------------------
136Int_t AliITSTableSSD::Use(Int_t side){
137 // uses the current element. This means that the current element is returned
138 // and its content is replaced by -1. Hence each element can be used only
139 // once.
140 Int_t elem=-1;
141 if((side!=0) && (side!=1)){
142 cerr<<" Error in AliITSTableSSD::Use. side="<<side<<endl;
143 cerr<<" side must be 0 or 1\n";
144 return elem;
145 }
146 if(fCurrUse[side]>(fDim/2-1)){
147 cerr<<" Error in AliITSTableSSD::Use. Trying to use an element out of range\n";
148 cerr<<" Element="<<fCurrUse[side]<<" while max limit is "<<(fDim/2-1)<<endl;
149 fCurrUse[side]++;
150 return elem;
151 }
152 Int_t index=(fDim/2)*side+fCurrUse[side];
153 elem=fArray[index];
154 fArray[index]=-1;
155 fCurrUse[side]++;
156 return elem;
157}