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