]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSMapA2.cxx
Added protection on SSD module in Raw2SDigits
[u/mrichter/AliRoot.git] / ITS / AliITSMapA2.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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
16 #include <TH1.h>
17 #include <TObjArray.h>
18
19 #include "AliITSMapA2.h"
20 #include "AliITSsegmentation.h"
21 #include "AliITSdigit.h"
22
23 ////////////////////////////////////////////////////////////////////////
24 //  Map Class for ITS. Implementation A2. In this implementation, the //
25 // 2 dimensional (iz,ix) map is filled with Double precision floating //
26 // point values. Since this class is derived for AliITSMapA1 it also  //
27 // has all of the functionality of that class as well. For each       //
28 // cell a corresponding TObject, a hit, can also be stored.           //
29 //  The detector geometry is accessed via the that detectors          //
30 // segmentation class and stored here for conveniance.                //
31 ////////////////////////////////////////////////////////////////////////
32
33 ClassImp(AliITSMapA2)
34
35 //______________________________________________________________________
36 AliITSMapA2::AliITSMapA2():
37 fHitMapD(0),
38 fMapThresholdD(0),
39 fScaleSizeX(0),
40 fScaleSizeZ(0){
41     // default constructor
42
43     fSegmentation  = 0;
44     fNpz           = 0;
45     fNpx           = 0;
46     fMaxIndex      = 0;
47     fObjects       = 0;
48     fNobjects      = 0;
49 }
50 //______________________________________________________________________
51 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg):
52 fHitMapD(0),
53 fMapThresholdD(0),
54 fScaleSizeX(1),
55 fScaleSizeZ(1){
56     //constructor
57
58     fSegmentation  = seg;
59     fNpz           = fSegmentation->Npz();
60     fNpx           = fSegmentation->Npx();
61     fMaxIndex      = fNpz*fNpx+fNpx;       // 2 halves of detector
62     fHitMapD       = new Double_t[fMaxIndex+1];
63     fObjects       = 0;
64     fNobjects      = 0;
65     ClearMap();
66 }
67 //______________________________________________________________________
68 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
69                          Int_t scalesizeX, Int_t scalesizeZ):
70 fHitMapD(0),
71 fMapThresholdD(0),
72 fScaleSizeX(scalesizeX),
73 fScaleSizeZ(scalesizeZ){
74     //constructor
75
76     fSegmentation  = seg;
77     fNpz           = fScaleSizeZ*fSegmentation->Npz();
78     fNpx           = fScaleSizeX*fSegmentation->Npx();
79     fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector
80     fHitMapD       = new Double_t[fMaxIndex+1];
81     fObjects       = 0;
82     fNobjects      = 0;
83     ClearMap();
84 }
85 //______________________________________________________________________
86 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, 
87                          Double_t thresh):
88 fHitMapD(0),
89 fMapThresholdD(thresh),
90 fScaleSizeX(1),
91 fScaleSizeZ(1){
92     //constructor
93
94     fNobjects      = 0;
95     fSegmentation  = seg;
96     fNpz           = fSegmentation->Npz();
97     fNpx           = fSegmentation->Npx();
98     fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector  
99     fHitMapD       = new Double_t[fMaxIndex+1];
100     fObjects       =  obj;
101     if (fObjects) fNobjects = fObjects->GetEntriesFast();
102     ClearMap();
103 }
104 //______________________________________________________________________
105 AliITSMapA2::~AliITSMapA2(){
106     //destructor
107
108     if (fHitMapD) delete[] fHitMapD;
109 }
110 //______________________________________________________________________
111 AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source) : AliITSMapA1(source),
112 fHitMapD(source.fHitMapD),
113 fMapThresholdD(source.fMapThresholdD),
114 fScaleSizeX(source.fScaleSizeX),
115 fScaleSizeZ(source.fScaleSizeZ){
116     //     Copy Constructor 
117
118 }
119 //______________________________________________________________________
120 AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) {
121     //    Assignment operator
122   this->~AliITSMapA2();
123   new(this) AliITSMapA2(source);
124   return *this;
125
126 }
127
128 //______________________________________________________________________
129 void AliITSMapA2::ClearMap(){
130     //clear array
131
132     memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
133 }
134 //______________________________________________________________________
135 void  AliITSMapA2::FillMap(){
136     // fills signal map from digits - apply a threshold for signal
137   
138     if (!fObjects) return;
139
140     Int_t ndigits = fObjects->GetEntriesFast();
141     if (!ndigits) return;
142
143     AliITSdigit *dig;
144     for (Int_t ndig=0; ndig<ndigits; ndig++) {
145         dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
146         Double_t signal = (Double_t)(dig->GetSignal());
147         if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
148     } // end for ndig
149 }
150 //______________________________________________________________________
151 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
152   //flag an entry
153
154     fHitMapD[CheckedIndex(iz, ix)]=
155                 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
156 }
157 //______________________________________________________________________
158 TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy) const {
159   //return a pointer to the 1D histogram
160
161     dummy = 0; // added to remove unused variable warning.
162     if (fObjects) {
163         return fObjects->UncheckedAt(i);
164     } else return NULL;
165 }
166 //______________________________________________________________________
167 Double_t AliITSMapA2::GetSignal(Int_t index) const {
168     //get signal in a cell 
169
170     if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
171     else return 0.;
172 }
173 //______________________________________________________________________
174 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
175     // check if the entry has already been flagged
176
177     if (CheckedIndex(iz, ix) < 0) return kEmpty;
178     Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
179     
180     if (inf <= -1000) {
181         return kUsed;
182     } else if (inf == 0) {
183         return kEmpty;
184     } else {
185         return kUnused;
186     } // end if inf...
187 }
188 //______________________________________________________________________
189 void  AliITSMapA2::FillMapFromHist(){
190     // fills map from 1D histograms
191
192     if (!fObjects) return;
193
194     // an example
195     for( Int_t i=0; i<fNobjects; i++) {
196         TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
197         Int_t nsamples = hist->GetNbinsX();
198         for( Int_t j=0; j<nsamples; j++) {
199             Double_t signal = (Double_t)(hist->GetBinContent(j+1));
200             if (signal > fMapThresholdD) SetHit(i,j,signal);
201         } // end for j
202     } // end for i
203 }
204 //______________________________________________________________________
205 void  AliITSMapA2::FillHist(){
206     // fill 1D histograms from map
207
208     if (!fObjects || fScaleSizeX != 1) return;
209
210     // an example
211     for( Int_t i=0; i<fNobjects; i++) {
212         TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
213         for( Int_t j=0; j<fNpx; j++) {
214             Double_t signal=GetSignal(i,j);
215             if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
216         } // end for j
217     } // end for i
218 }
219 //______________________________________________________________________
220 void  AliITSMapA2::ResetHist(){
221     // Reset histograms
222
223     if (!fObjects) return;
224
225     for( Int_t i=0; i<fNobjects; i++) {
226         if ((*fObjects)[i])    ((TH1F*)(*fObjects)[i])->Reset();
227     } // end for i
228 }
229 //______________________________________________________________________
230 void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
231     // Addes sig to cell iz. equivalent to the very common
232     // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
233
234
235     Int_t index=GetHitIndex(iz,ix);
236     if(index<0) return;
237     fHitMapD[CheckedIndex(iz, ix)] += sig;    
238 }