speed up with binary search
[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 "AliPMDrecdata.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
61   Int_t   det = 0,smn = 0, trno = 0, trpid = 0, mstatus = 0;
62   Float_t clusdata[7] = {0.,0.,0.,0.,0.,0.,0.};
63
64   AliPMDrecdata  *pmdcl    = 0;
65   AliPMDclupid   *pmdclout = 0;
66
67   Int_t nentries1 = pmdcontin->GetEntries();
68
69   AliDebug(1,Form("Number of total clusters from CPV PRE = %d",nentries1));
70
71
72   for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
73     {
74       pmdcl = (AliPMDrecdata*)pmdcontin->UncheckedAt(ient1);
75       
76       det         = pmdcl->GetDetector();
77       smn         = pmdcl->GetSMNumber();
78       trno        = pmdcl->GetClusTrackNo();
79       trpid       = pmdcl->GetClusTrackPid();
80       clusdata[0] = pmdcl->GetClusX();
81       clusdata[1] = pmdcl->GetClusY();
82       clusdata[2] = pmdcl->GetClusADC();
83       clusdata[3] = pmdcl->GetClusCells();
84       clusdata[4] = pmdcl->GetClusSigmaX();
85       clusdata[5] = pmdcl->GetClusSigmaY();
86
87       if (det == 0 && clusdata[2] > 300.)
88         {
89           clusdata[6] = 1;     // photon
90         }
91       else
92         {
93           clusdata[6] = 8;     // hadron
94         }
95
96       mstatus = 0;             // at this moment matching is not done
97
98       pmdclout = new AliPMDclupid(det,smn,trno,trpid,mstatus,clusdata);
99       pmdcontout->Add(pmdclout);
100       
101     } // Entries of TObjArray loop
102
103 }
104 // -----------------------------------------------------------------------