gain values initialised to -1
[u/mrichter/AliRoot.git] / PMD / AliPMDEmpDiscriminator.cxx
CommitLineData
077a4c66 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//-----------------------------------------------------//
17// //
18// Date : August 05 2003 //
19// This does photon hadron discrimination on the //
20// of matching a PMD cluster with a CPV cluster //
21// //
22//-----------------------------------------------------//
23
24#include <Riostream.h>
25#include <TMath.h>
26#include <TBRIK.h>
27#include <TNode.h>
28#include <TTree.h>
29#include <TGeometry.h>
30#include <TObjArray.h>
31#include <TClonesArray.h>
32#include <TFile.h>
33#include <TNtuple.h>
34#include <TParticle.h>
35
36#include "AliLog.h"
37//#include "AliPMDcluster.h"
38#include "AliPMDrecpoint1.h"
39#include "AliPMDclupid.h"
40#include "AliPMDDiscriminator.h"
41#include "AliPMDEmpDiscriminator.h"
42
43ClassImp(AliPMDEmpDiscriminator)
44
45AliPMDEmpDiscriminator::AliPMDEmpDiscriminator()
46{
47//
48// Default Constructor
49//
50}
51// -----------------------------------------------------------------------
52AliPMDEmpDiscriminator::~AliPMDEmpDiscriminator()
53{
54 // Destructor
55}
56
57// -----------------------------------------------------------------------
58
59void AliPMDEmpDiscriminator::Discrimination(TObjArray *pmdcontin, TObjArray *pmdcontout)
60{
61 // Does Photon/Hadron discrimination
62 // matching the clusters of CPV and PREshower plane
63 //
64 const Int_t kumperdet = 24;
65 static Int_t neibx[6]={1,0,-1,-1,0,1}, neiby[6]={0,1,1,0,-1,-1};
66 Int_t det,smn;
67 Int_t iprecount[24], icpvcount[24];
68 Float_t xpos,ypos;
69 Float_t adc, ncell, rad;
70 Float_t clusdata[6];
71
72 for(Int_t i = 0; i < kumperdet; i++)
73 {
74 iprecount[i] = 0;
75 icpvcount[i] = 0;
76 }
77 AliPMDrecpoint1 *pmdcl = 0;
78 AliPMDclupid *pmdclout = 0;
79
80 Int_t nentries1 = pmdcontin->GetEntries();
81
82 AliDebug(1,Form("Number of total clusters from CPV PRE = %d",nentries1));
83 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
84 {
85 pmdcl = (AliPMDrecpoint1*)pmdcontin->UncheckedAt(ient1);
86
87 det = pmdcl->GetDetector();
88 smn = pmdcl->GetSMNumber();
89 if(det == 0) iprecount[smn]++;
90 if(det == 1) icpvcount[smn]++;
91 } // Entries of TObjArray loop
92
93 Int_t idet, ismn;
94 Float_t edepcpv[48][96];
95 Int_t statuscpv[48][96];
96
97 for(Int_t i = 0; i < kumperdet; i++) // unit module
98 {
99 // Initialisation of the ADC of CPV (1UM)
100 for (Int_t ix = 0; ix < 48;ix++)
101 {
102 for (Int_t iy = 0; iy < 96;iy++)
103 {
104 edepcpv[ix][iy] = 0.;
105 statuscpv[ix][iy] = 0;
106 }
107 }
108 Int_t precounter = iprecount[i];
109 Int_t cpvcounter = icpvcount[i];
110
111 Float_t *xpadpre = new Float_t[precounter];
112 Float_t *ypadpre = new Float_t[precounter];
113 Float_t *adcpre = new Float_t[precounter];
114 Float_t *ncellpre = new Float_t[precounter];
115 Float_t *radpre = new Float_t[precounter];
116 Int_t *sortcoord = new Int_t[precounter];
117 Int_t *clupidpre = new Int_t[precounter];
118
119 Float_t *xpadcpv = new Float_t[cpvcounter];
120 Float_t *ypadcpv = new Float_t[cpvcounter];
121 Float_t *adccpv = new Float_t[cpvcounter];
122 Float_t *ncellcpv = new Float_t[cpvcounter];
123 Float_t *radcpv = new Float_t[cpvcounter];
124
125 Int_t ii = 0;
126 Int_t ij = 0;
127 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
128 {
129 pmdcl = (AliPMDrecpoint1*)pmdcontin->UncheckedAt(ient1);
130
131 det = pmdcl->GetDetector();
132 smn = pmdcl->GetSMNumber();
133 xpos = pmdcl->GetClusX();
134 ypos = pmdcl->GetClusY();
135 adc = pmdcl->GetClusADC();
136 ncell = pmdcl->GetClusCells();
137 rad = pmdcl->GetClusSigmaX();
138
139 if(det == 0 && smn == i)
140 {
141 xpadpre[ii] = xpos;
142 ypadpre[ii] = ypos;
143 adcpre[ii] = adc;
144 ncellpre[ii] = ncell;
145 radpre[ii] = rad;
146 ii++;
147 }
148 if(det == 1 && smn == i)
149 {
150 Int_t ix = (Int_t) (xpos+0.5);
151 Int_t iy = (Int_t) (ypos+0.5);
152 if(ix > 47) ix = 47;
153 if(iy > 95) iy = 95;
154 edepcpv[ix][iy] = adc;
155 xpadcpv[ij] = xpos;
156 ypadcpv[ij] = ypos;
157 adccpv[ij] = adc;
158 ncellcpv[ij] = ncell;
159 radcpv[ij] = rad;
160 ij++;
161 }
162 } // Entries of TObjArray loop
163 // sorts from lowest ADC to highest ADC
164 // and returns the coordinates
165 Bool_t jsort = false;
166 TMath::Sort(precounter,adcpre,sortcoord,jsort);
167
168 Int_t jjsort = 0;
169 for(Int_t jj=0; jj<precounter; jj++)
170 {
171 // PRE information
172 // PIDs for PRE clusters are 0(photon) and 1(hadron)
173
174 jjsort = sortcoord[jj];
175
176 Int_t ix = (Int_t) (xpadpre[jjsort]+0.5);
177 Int_t iy = (Int_t) (ypadpre[jjsort]+0.5);
178 if(ix > 47) ix = 47;
179 if(iy > 95) iy = 95;
180
181 for(Int_t jk=0; jk<6; jk++)
182 {
183 Int_t jd1 = ix + neibx[jk];
184 Int_t jd2 = iy + neiby[jk];
185 if(jd1 <0 ) jd1 = 0;
186 if(jd1 >47) jd1 = 47;
187 if(jd2 <0 ) jd2 = 0;
188 if(jd2 >47) jd2 = 47;
189 if(edepcpv[jd1][jd2] > 0.0 && statuscpv[jd1][jd2] == 0)
190 {
191 statuscpv[jd1][jd2] = 1;
192 clupidpre[jjsort] = 1;
193 break;
194 }
195 }
196
197 idet = 0;
198 ismn = i;
199 clusdata[0] = xpadpre[jjsort];
200 clusdata[1] = ypadpre[jjsort];
201 clusdata[2] = adcpre[jjsort];
202 clusdata[3] = ncellpre[jjsort];
203 clusdata[4] = radpre[jjsort];
204 //PH clusdata[5] = (Float_t) clupidpre[jjsort];
205
206 // Temporary the cluster PID is set to 1 if the
207 // adc > 3MIP units which will be changed later on.
208
209 if (adcpre[jjsort] > 300.)
210 {
211 clusdata[5] = 1.0;
212 }
213 else
214 {
215 clusdata[5] = 0.0;
216 }
217 pmdclout = new AliPMDclupid(idet,ismn,clusdata);
218 pmdcontout->Add(pmdclout);
219 } // jj loop
220
221 for(Int_t jj=0; jj<cpvcounter; jj++)
222 {
223 // CPV information
224 // PID for CPV clusters is 1
225
226 idet = 1;
227 ismn = i;
228 clusdata[0] = xpadcpv[jj];
229 clusdata[1] = ypadcpv[jj];
230 clusdata[2] = adccpv[jj];
231 clusdata[3] = ncellcpv[jj];
232 clusdata[4] = radcpv[jj];
233 clusdata[5] = 0.;
234
235 pmdclout = new AliPMDclupid(idet,ismn,clusdata);
236 pmdcontout->Add(pmdclout);
237 }
238
239 // delete all the pointers
240 delete [] xpadpre;
241 delete [] ypadpre;
242 delete [] adcpre;
243 delete [] ncellpre;
244 delete [] radpre;
316c6cd9 245 delete [] sortcoord;
077a4c66 246 delete [] clupidpre;
247 delete [] xpadcpv;
248 delete [] ypadcpv;
249 delete [] adccpv;
250 delete [] ncellcpv;
251 delete [] radcpv;
252 } // i loop
253
254}
255// -----------------------------------------------------------------------