]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzer.cxx
Effective c++, committed on behalf of �ystein Djuvsland
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzer.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: Øystein Djuvsland <oysteind@ift.uib.no>                        *
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 #include "AliHLTPHOSPhysicsAnalyzer.h"
18 #include "TVector3.h"
19 #include "TFile.h"
20 #include "TMath.h"
21 #include "TH1F.h"
22 #include "AliPHOSGeometry.h"
23 #include "Rtypes.h"
24 #include "AliHLTPHOSCommonDefs.h"
25 #include "AliHLTPHOSClusterDataStruct.h"
26  
27
28 ClassImp(AliHLTPHOSPhysicsAnalyzer);
29
30 AliHLTPHOSPhysicsAnalyzer::AliHLTPHOSPhysicsAnalyzer():fClustersPtr(0), fRootHistPtr(0), fPHOSRadius(0)
31                                                     
32                                                        
33 {
34   //Constructor
35
36   AliPHOSGeometry *geom=AliPHOSGeometry::GetInstance("noCPV");
37
38   fPHOSRadius = geom->GetIPtoCrystalSurface();
39   
40   for(Int_t i = 0; i < N_MODULES; i++)
41     {
42       fRotParametersCos[i] = cos((geom->GetPHOSAngle(i+1))*2*TMath::Pi()/360);
43
44       fRotParametersSin[i] = sin((geom->GetPHOSAngle(i+1))*2*TMath::Pi()/360);
45     }
46 }
47
48 AliHLTPHOSPhysicsAnalyzer::AliHLTPHOSPhysicsAnalyzer(const AliHLTPHOSPhysicsAnalyzer &):fClustersPtr(0), fRootHistPtr(0), fPHOSRadius(0)
49
50 {
51   //Cooy constructor
52
53   AliPHOSGeometry *geom=AliPHOSGeometry::GetInstance("noCPV");
54
55   fPHOSRadius = geom->GetIPtoCrystalSurface();
56   
57   for(Int_t i = 0; i < N_MODULES; i++)
58     {
59       fRotParametersCos[i] = cos((geom->GetPHOSAngle(i+1))*2*TMath::Pi()/360);
60       
61       fRotParametersSin[i] = sin((geom->GetPHOSAngle(i+1))*2*TMath::Pi()/360);
62     }
63
64 }
65
66
67 AliHLTPHOSPhysicsAnalyzer::~AliHLTPHOSPhysicsAnalyzer()
68 {
69   //Destructor
70
71   fClustersPtr = 0;
72   fRootHistPtr = 0;
73 }
74
75 void
76 AliHLTPHOSPhysicsAnalyzer::LocalPosition(AliHLTPHOSClusterDataStruct* clusterPtr, Float_t* locPositionPtr)
77 {
78   //Get local position for a cluster
79
80   locPositionPtr[0] = clusterPtr->fLocalPositionPtr[0];
81   locPositionPtr[1] = clusterPtr->fLocalPositionPtr[1];
82
83 }
84
85 void
86 AliHLTPHOSPhysicsAnalyzer::GlobalPosition(AliHLTPHOSClusterDataStruct* clusterPtr, Float_t* positionPtr)
87 {
88   //Get global position for a cluster
89   
90   Float_t tempPosX = 0;
91
92   Int_t module = clusterPtr->fPHOSModule;
93
94   tempPosX = kCRYSTAL_SIZE*(clusterPtr->fLocalPositionPtr[0]-N_COLUMNS_MOD/2) + kCRYSTAL_SIZE/2;
95
96   positionPtr[0] = tempPosX*fRotParametersSin[module] + fPHOSRadius*fRotParametersCos[module];
97
98   positionPtr[1] = tempPosX*fRotParametersCos[module] - fPHOSRadius*fRotParametersSin[module];
99
100   positionPtr[2] = kCRYSTAL_SIZE*(clusterPtr->fLocalPositionPtr[1]-N_ROWS_MOD/2) + kCRYSTAL_SIZE/2;
101
102 }
103
104 void
105 AliHLTPHOSPhysicsAnalyzer::GlobalPosition(Float_t* locPositionPtr, Float_t* positionPtr, Int_t module)
106
107   //Get global position from local postion and module number
108
109   positionPtr[0] = kCRYSTAL_SIZE*(locPositionPtr[0]-N_COLUMNS_MOD/2)*fRotParametersCos[module-1] + fPHOSRadius*fRotParametersSin[module-1];
110
111   positionPtr[1] = kCRYSTAL_SIZE*(locPositionPtr[0]-N_COLUMNS_MOD/2)*fRotParametersSin[module-1] - fPHOSRadius*fRotParametersCos[module-1];
112   
113   positionPtr[2] = kCRYSTAL_SIZE*(locPositionPtr[1]-N_ROWS_MOD);
114
115 }
116
117 void
118 AliHLTPHOSPhysicsAnalyzer::WriteHistogram(Char_t* fileName)
119 {
120   //Write the histogram
121
122   TFile *outfile = new TFile(fileName,"recreate");  
123   
124   fRootHistPtr->Write();
125   
126   outfile->Close();
127   
128   delete outfile;
129   outfile = 0;
130
131 }
132
133