The decoder now handles correctly the case when
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzer.cxx
CommitLineData
2410262d 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"
91b95d47 21#include "TH1F.h"
d6e6cb01 22#include "AliPHOSGeometry.h"
91b95d47 23#include "Rtypes.h"
24#include "AliHLTPHOSCommonDefs.h"
25#include "AliHLTPHOSClusterDataStruct.h"
26
2410262d 27
28ClassImp(AliHLTPHOSPhysicsAnalyzer);
29
30AliHLTPHOSPhysicsAnalyzer::AliHLTPHOSPhysicsAnalyzer():fClustersPtr(NULL)
31
32
33{
91b95d47 34 //Constructor
2410262d 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
48AliHLTPHOSPhysicsAnalyzer::AliHLTPHOSPhysicsAnalyzer(const AliHLTPHOSPhysicsAnalyzer &):fClustersPtr(NULL)
49
50{
91b95d47 51 //Cooy constructor
52
2410262d 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 }
91b95d47 63
2410262d 64}
65
66
67AliHLTPHOSPhysicsAnalyzer::~AliHLTPHOSPhysicsAnalyzer()
68{
91b95d47 69 //Destructor
2410262d 70
91b95d47 71 fClustersPtr = 0;
72 fRootHistPtr = 0;
2410262d 73}
74
75void
76AliHLTPHOSPhysicsAnalyzer::LocalPosition(AliHLTPHOSClusterDataStruct* clusterPtr, Float_t* locPositionPtr)
77{
91b95d47 78 //Get local position for a cluster
2410262d 79
80 locPositionPtr[0] = clusterPtr->fLocalPositionPtr[0];
81 locPositionPtr[1] = clusterPtr->fLocalPositionPtr[1];
82
83}
84
85void
86AliHLTPHOSPhysicsAnalyzer::GlobalPosition(AliHLTPHOSClusterDataStruct* clusterPtr, Float_t* positionPtr)
87{
91b95d47 88 //Get global position for a cluster
2410262d 89
90 Float_t tempPosX = 0;
91
92 Int_t module = clusterPtr->fPHOSModule;
93
91b95d47 94 tempPosX = kCRYSTAL_SIZE*(clusterPtr->fLocalPositionPtr[0]-N_COLUMNS_MOD/2) + kCRYSTAL_SIZE/2;
2410262d 95
96 positionPtr[0] = tempPosX*fRotParametersSin[module] + fPHOSRadius*fRotParametersCos[module];
97
98 positionPtr[1] = tempPosX*fRotParametersCos[module] - fPHOSRadius*fRotParametersSin[module];
99
91b95d47 100 positionPtr[2] = kCRYSTAL_SIZE*(clusterPtr->fLocalPositionPtr[1]-N_ROWS_MOD/2) + kCRYSTAL_SIZE/2;
2410262d 101
102}
103
104void
105AliHLTPHOSPhysicsAnalyzer::GlobalPosition(Float_t* locPositionPtr, Float_t* positionPtr, Int_t module)
106{
91b95d47 107 //Get global position from local postion and module number
2410262d 108
91b95d47 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];
2410262d 112
91b95d47 113 positionPtr[2] = kCRYSTAL_SIZE*(locPositionPtr[1]-N_ROWS_MOD);
2410262d 114
115}
116
117void
118AliHLTPHOSPhysicsAnalyzer::WriteHistogram(Char_t* fileName)
119{
91b95d47 120 //Write the histogram
121
2410262d 122 TFile *outfile = new TFile(fileName,"recreate");
123
124 fRootHistPtr->Write();
125
126 outfile->Close();
91b95d47 127
128 delete outfile;
129 outfile = 0;
2410262d 130
131}
132
133