]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerSpectrum.cxx
Coding conventions and minor changes
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerSpectrum.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        * 
3  * All rights reserved.                                                   *
4  *                                                                        *
5  * Primary Authors: Oystein Djuvsland                                     *
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  * @file   AliHLTPHOSPhysicsAnalyzerSpectrum.cxx
18  * @author Oystein Djuvsland
19  * @date 
20  * @brief  Invariant mass spectrum from 2 gammas  */
21
22 // see header file for class documentation
23 // or
24 // refer to README to build package
25 // or
26 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
27
28 #include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
29 #include "AliHLTPHOSRecPointContainerStruct.h"
30 #include "AliHLTPHOSRecPointDataStruct.h"
31 #include <cmath>
32 #include "math.h"
33 #include "TH1F.h"
34
35
36 ClassImp(AliHLTPHOSPhysicsAnalyzerSpectrum);
37
38
39
40 AliHLTPHOSPhysicsAnalyzerSpectrum::AliHLTPHOSPhysicsAnalyzerSpectrum():AliHLTPHOSPhysicsAnalyzer(), fPos0Ptr(0), fPos1Ptr(0), fThresholdPtr(0), fEnergyPtr(0)
41 {
42   //Constructor
43   //See header file for documentation
44   fEnergyPtr = new Float_t[2];
45   fPos0Ptr = new Float_t[3];
46   fPos1Ptr = new Float_t[3];
47   fThresholdPtr = new Float_t[2];
48   fThresholdPtr[0] = 0;
49   fThresholdPtr[1] = 0;
50   
51 }
52
53 AliHLTPHOSPhysicsAnalyzerSpectrum::AliHLTPHOSPhysicsAnalyzerSpectrum(const AliHLTPHOSPhysicsAnalyzerSpectrum &):AliHLTPHOSPhysicsAnalyzer(), fPos0Ptr(0), fPos1Ptr(0), fThresholdPtr(0), fEnergyPtr(0)
54 {
55   //Copy constructor not implemented
56   //See header file for documentation
57 }
58
59 AliHLTPHOSPhysicsAnalyzerSpectrum::~AliHLTPHOSPhysicsAnalyzerSpectrum()
60 {
61   //Destructor
62   //See header file for documentation
63   if(fRecPointsPtr) fRecPointsPtr = 0;
64
65   if(fRootHistPtr) fRootHistPtr = 0;
66
67   if(fThresholdPtr)
68     {
69       delete [] fThresholdPtr;
70       fThresholdPtr = 0;
71     }
72   if(fEnergyPtr)
73     {
74       delete [] fEnergyPtr;
75       fEnergyPtr = 0;
76     }
77   if(fPos0Ptr)
78     {
79       delete [] fPos0Ptr;
80       fPos0Ptr = 0;
81     }
82   if(fPos1Ptr)
83     {
84       delete [] fPos1Ptr;
85       fPos1Ptr = 0;
86     }
87
88 }
89 void
90 AliHLTPHOSPhysicsAnalyzerSpectrum::Analyze(AliHLTPHOSRecPointContainerStruct* recPointsArrayPtr, Int_t nRecPoints)
91 {
92   //Analyzing a set of recPoints
93   //See header file for documentation
94   Float_t cosOpeningAngle = 0;
95
96   AliHLTPHOSRecPointDataStruct* firstRecPointPtr;
97   AliHLTPHOSRecPointDataStruct* secondRecPointPtr;
98
99   if(nRecPoints > 1)
100     {
101       for(Int_t i = 0; i < nRecPoints-1; i++)
102         {
103           firstRecPointPtr = &(recPointsArrayPtr->fRecPointArray[i]);
104           fEnergyPtr[0] = firstRecPointPtr->fAmp;
105           if(fEnergyPtr[0] > fThresholdPtr[0])
106             {
107               
108               for(Int_t j = i+1; j < nRecPoints; j++)
109                 {
110                   secondRecPointPtr = &(recPointsArrayPtr->fRecPointArray[j]);
111                   fEnergyPtr[1] = secondRecPointPtr->fAmp;
112                   if(fEnergyPtr[1] > fThresholdPtr[1])
113                     {
114                       GlobalPosition(firstRecPointPtr, fPos0Ptr);
115                       GlobalPosition(secondRecPointPtr, fPos1Ptr);
116
117                       cosOpeningAngle = (fPos0Ptr[0]*fPos1Ptr[0] + fPos0Ptr[1]*fPos1Ptr[1] + fPos0Ptr[2]*fPos1Ptr[2])/
118                         (sqrt(fPos0Ptr[0]*fPos0Ptr[0] + fPos0Ptr[1]*fPos0Ptr[1] + fPos0Ptr[2]*fPos0Ptr[2])*
119                          sqrt(fPos1Ptr[0]*fPos1Ptr[0] + fPos1Ptr[1]*fPos1Ptr[1] + fPos1Ptr[2]*fPos1Ptr[2]));
120                       
121                       fRootHistPtr->Fill(sqrt(2*fEnergyPtr[0]*fEnergyPtr[1]*(1 - cosOpeningAngle)));
122                     }
123                   
124                 }                 
125               
126             }
127           
128         }
129       
130     }
131 }
132
133 Float_t 
134 AliHLTPHOSPhysicsAnalyzerSpectrum::EvalDistance()
135 {
136   //Evaluate the distance between the two recPoints
137   //See header file for documentation
138   if(fPos0Ptr && fPos1Ptr)
139     return sqrt(pow(fPos1Ptr[0]-fPos0Ptr[0],2) + pow(fPos1Ptr[1]-fPos0Ptr[1],2) + pow(fPos1Ptr[2]-fPos0Ptr[2],2));
140   return -1;
141
142 }
143
144 Int_t
145 AliHLTPHOSPhysicsAnalyzerSpectrum::SetThreshold(Float_t photonEnergy0, Float_t photonEnergy1)
146 {
147   //Setting the cut thresholds
148   //See header file for documentation
149   fThresholdPtr[0] = photonEnergy0;
150
151   fThresholdPtr[1] = photonEnergy1;
152
153   return 0;
154
155 }