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