]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerSpectrum.cxx
Effective c++, committed on behalf of �ystein Djuvsland
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerSpectrum.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Øystein Djuvsland <oysteind@ift.uib.no>                       *
5  *                                                                        *
6  * Permission to use, copy, modify and distribute this software and its   *
7  * documentation strictly for non-commercial purposes is hereby granted   *
8  * without fee, provided that the above copyright notice appears in all   *
9  * copies and that both the copyright notice and this permission notice   *
10  * appear in the supporting documentation. The authors make no claims     *
11  * about the suitability of this software for any purpose. It is          *
12  * provided "as is" without express or implied warranty.                  *
13  **************************************************************************/
14
15
16 #include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
17 #include "AliHLTPHOSClusterDataStruct.h"
18 #include <cmath>
19 #include "math.h"
20 #include "TH1F.h"
21
22
23 ClassImp(AliHLTPHOSPhysicsAnalyzerSpectrum);
24
25
26
27 AliHLTPHOSPhysicsAnalyzerSpectrum::AliHLTPHOSPhysicsAnalyzerSpectrum():AliHLTPHOSPhysicsAnalyzer(), fPos0Ptr(0), fPos1Ptr(0), fThresholdPtr(0), fEnergyPtr(0)
28 {
29   //Constructor
30
31   fEnergyPtr = new Float_t[2];
32   fPos0Ptr = new Float_t[3];
33   fPos1Ptr = new Float_t[3];
34   fThresholdPtr = new Float_t[2];
35   fThresholdPtr[0] = 0;
36   fThresholdPtr[1] = 0;
37   
38 }
39
40 AliHLTPHOSPhysicsAnalyzerSpectrum::AliHLTPHOSPhysicsAnalyzerSpectrum(const AliHLTPHOSPhysicsAnalyzerSpectrum &):AliHLTPHOSPhysicsAnalyzer(), fPos0Ptr(0), fPos1Ptr(0), fThresholdPtr(0), fEnergyPtr(0)
41 {
42   //Copy constructor not implemented
43 }
44
45 AliHLTPHOSPhysicsAnalyzerSpectrum::~AliHLTPHOSPhysicsAnalyzerSpectrum()
46 {
47   //Destructor
48
49   if(fClustersPtr) fClustersPtr = 0;
50
51   if(fRootHistPtr) fRootHistPtr = 0;
52
53   if(fThresholdPtr)
54     {
55       delete [] fThresholdPtr;
56       fThresholdPtr = 0;
57     }
58   if(fEnergyPtr)
59     {
60       delete [] fEnergyPtr;
61       fEnergyPtr = 0;
62     }
63   if(fPos0Ptr)
64     {
65       delete [] fPos0Ptr;
66       fPos0Ptr = 0;
67     }
68   if(fPos1Ptr)
69     {
70       delete [] fPos1Ptr;
71       fPos1Ptr = 0;
72     }
73
74 }
75
76 void
77 AliHLTPHOSPhysicsAnalyzerSpectrum::Analyze(AliHLTPHOSClusterDataStruct* clustersPtr[10000], Int_t nClusters)
78 {
79   //Analyzing a set of clusters
80
81   Float_t cosOpeningAngle = 0;
82
83   if(nClusters > 1)
84     {
85       for(Int_t i = 0; i < nClusters-1; i++)
86         {
87           
88           fEnergyPtr[0] = clustersPtr[i]->fClusterEnergy;
89
90           if(fEnergyPtr[0] > fThresholdPtr[0])
91             {
92               
93               for(Int_t j = i+1; j < nClusters; j++)
94                 {
95                   
96                   fEnergyPtr[1] = clustersPtr[j]->fClusterEnergy;
97
98                   if(fEnergyPtr[1] > fThresholdPtr[1])
99                     {
100                       GlobalPosition(clustersPtr[i], fPos0Ptr);
101
102                       GlobalPosition(clustersPtr[j], fPos1Ptr);
103                       
104                       cosOpeningAngle = (fPos0Ptr[0]*fPos1Ptr[0] + fPos0Ptr[1]*fPos1Ptr[1] + fPos0Ptr[2]*fPos1Ptr[2])/
105                         (sqrt(fPos0Ptr[0]*fPos0Ptr[0] + fPos0Ptr[1]*fPos0Ptr[1] + fPos0Ptr[2]*fPos0Ptr[2])*
106                          sqrt(fPos1Ptr[0]*fPos1Ptr[0] + fPos1Ptr[1]*fPos1Ptr[1] + fPos1Ptr[2]*fPos1Ptr[2]));
107                       
108                       fRootHistPtr->Fill(sqrt(2*fEnergyPtr[0]*fEnergyPtr[1]*(1 - cosOpeningAngle)));
109                       
110                       
111                     }
112                   
113                 }                 
114               
115             }
116           
117         }
118       
119     }
120   
121 }
122
123
124 Float_t 
125 AliHLTPHOSPhysicsAnalyzerSpectrum::EvalDistance()
126 {
127   //Evaluate the distance between the two clusters
128
129   if(fPos0Ptr && fPos1Ptr)
130     return sqrt(pow(fPos1Ptr[0]-fPos0Ptr[0],2) + pow(fPos1Ptr[1]-fPos0Ptr[1],2) + pow(fPos1Ptr[2]-fPos0Ptr[2],2));
131   return -1;
132
133 }
134
135 Int_t
136 AliHLTPHOSPhysicsAnalyzerSpectrum::SetThreshold(Float_t photonEnergy0, Float_t photonEnergy1)
137 {
138   //Setting the cut thresholds
139
140   fThresholdPtr[0] = photonEnergy0;
141
142   fThresholdPtr[1] = photonEnergy1;
143
144   return 0;
145
146 }