0fb8234ce326ac4f194d662b65ccff58b2e13aee
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSESDMaker.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 /** 
18  * @file   AliHLTPHOSESDMaker.cxx
19  * @author Oystein Djuvsland
20  * @date 
21  * @brief  ESD maker for PHOS HLT 
22  */
23
24 // see header file for class documentation
25 // or
26 // refer to README to build package
27 // or 
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
30 #include "AliHLTPHOSESDMaker.h"
31 #include "AliHLTPHOSCaloClusterContainerStruct.h"
32 #include "AliHLTPHOSBase.h"
33 #include "AliHLTPHOSCaloClusterDataStruct.h"
34 #include "AliESDEvent.h"
35 #include "AliESDCaloCluster.h"
36 #include "TClonesArray.h"
37
38 ClassImp(AliHLTPHOSESDMaker);
39
40 AliHLTPHOSESDMaker::AliHLTPHOSESDMaker() : 
41   AliHLTPHOSBase(),
42   fNCaloClusters(0),
43   fCaloClustersPtr(0),
44   fESDEventPtr(0),
45   fCaloClusterContainerPtr(0)
46 {
47   //See header file for documentation
48   fCaloClustersPtr = new TClonesArray("AliESDCaloCluster", 0);
49 }
50
51 AliHLTPHOSESDMaker::~AliHLTPHOSESDMaker()
52 {
53   //See header file for documentation
54   if(fCaloClustersPtr)
55     {
56       //fCaloClustersPtr->Delete();
57       //fCaloClustersPtr = 0;
58     }
59 }
60
61 Int_t
62 AliHLTPHOSESDMaker::FillESDCaloClusters()
63 {
64   //See header file for documentation
65
66   AliESDCaloCluster *caloCluster = 0;
67   AliHLTPHOSCaloClusterDataStruct* caloClusterStruct = 0;
68
69   for(UInt_t i = 0; i < fCaloClusterContainerPtr->fNCaloClusters; i++)
70     {
71       caloCluster = (AliESDCaloCluster*)fCaloClustersPtr->At(i + fNCaloClusters);
72       caloClusterStruct = &(fCaloClusterContainerPtr->fCaloClusterArray[i]);
73       caloCluster->SetID(caloClusterStruct->fID);
74       caloCluster->SetClusterType(caloClusterStruct->fClusterType);
75       caloCluster->SetPosition((Float_t*)&caloClusterStruct->fGlobalPos[0]);
76       caloCluster->SetE(caloClusterStruct->fEnergy);
77       caloCluster->SetClusterDisp(caloClusterStruct->fDispersion);
78       caloCluster->SetClusterChi2(caloClusterStruct->fFitQuality);
79       caloCluster->SetPid((Float_t*)&caloClusterStruct->fPID[0]);
80       caloCluster->SetM20(caloClusterStruct->fM20);
81       caloCluster->SetM02(caloClusterStruct->fM02);
82       // PT   caloCluster->SetM11(caloClusterStruct->fM11);
83       caloCluster->SetNExMax(caloClusterStruct->fNExMax);
84       caloCluster->SetEmcCpvDistance(caloClusterStruct->fEmcCpvDistance);
85       caloCluster->SetDistanceToBadChannel(caloClusterStruct->fDistToBadChannel);
86       caloCluster->SetNCells(caloClusterStruct->fNCells);
87       caloCluster->SetCellsAbsId(caloClusterStruct->fCellsAbsId);
88       caloCluster->SetCellsAmplitudeFraction(caloClusterStruct->fCellsAmpFraction);
89       fNCaloClusters++;
90     }
91
92   return 0;
93 }
94
95 Int_t
96 AliHLTPHOSESDMaker::FillESDEvent()
97 {
98   //See header file for documentation
99   
100   AliESDCaloCluster *caloCluster = 0;
101   AliHLTPHOSCaloClusterDataStruct* caloClusterStruct = 0;
102   for(UInt_t i = 0; i < fCaloClusterContainerPtr->fNCaloClusters; i++)
103     {
104       //      caloCluster = (AliESDCaloCluster*)fCaloClustersPtr->New(i + fNCaloClusters);
105       caloCluster = (AliESDCaloCluster*)fCaloClustersPtr->New(i);
106       caloClusterStruct = &(fCaloClusterContainerPtr->fCaloClusterArray[i]);
107
108       caloCluster->SetID(caloClusterStruct->fID);
109       caloCluster->SetClusterType(caloClusterStruct->fClusterType);
110       caloCluster->SetPosition((Float_t*)&caloClusterStruct->fGlobalPos[0]);
111       caloCluster->SetE(caloClusterStruct->fEnergy);
112       caloCluster->SetClusterDisp(caloClusterStruct->fDispersion);
113       caloCluster->SetClusterChi2(caloClusterStruct->fFitQuality);
114       caloCluster->SetPid((Float_t*)&caloClusterStruct->fPID[0]);
115       caloCluster->SetM20(caloClusterStruct->fM20);
116       caloCluster->SetM02(caloClusterStruct->fM02);
117       //     caloCluster->SetM11(caloClusterStruct->fM11);
118       caloCluster->SetNExMax(caloClusterStruct->fNExMax);
119       caloCluster->SetEmcCpvDistance(caloClusterStruct->fEmcCpvDistance);
120       caloCluster->SetDistanceToBadChannel(caloClusterStruct->fDistToBadChannel);
121       caloCluster->SetNCells(caloClusterStruct->fNCells);
122       caloCluster->SetCellsAbsId(caloClusterStruct->fCellsAbsId);
123       caloCluster->SetCellsAmplitudeFraction(caloClusterStruct->fCellsAmpFraction);
124       fESDEventPtr->AddCaloCluster(caloCluster);
125       fNCaloClusters++;  
126     }
127   
128   return 0;
129 }
130 Int_t
131 AliHLTPHOSESDMaker::FillESDEvent(AliHLTPHOSCaloClusterContainerStruct* caloClusterContainerPtr)
132 {
133   //See header file for documentation
134
135   caloClusterContainerPtr--;
136   caloClusterContainerPtr++;
137   
138   //  AliESDCaloCluster *caloCluster = 0;
139   //  AliHLTPHOSCaloClusterDataStruct* caloClusterStruct = 0;
140   
141   for(UInt_t i = 0; i < 1/*caloClusterContainerPtr->fNCaloClusters*/; i++)
142     {
143       //      caloCluster = (AliESDCaloCluster*)fCaloClustersPtr->New(i + fNCaloClusters);
144       //caloCluster = (AliESDCaloCluster*)fCaloClustersPtr->New(i + fNCaloClusters);
145       /*      caloClusterStruct = &(caloClusterContainerPtr->fCaloClusterArray[i]);
146       caloCluster->SetID(caloClusterStruct->fID);
147       caloCluster->SetClusterType(caloClusterStruct->fClusterType);
148       caloCluster->SetPosition((Float_t*)&caloClusterStruct->fGlobalPos[0]);
149       caloCluster->SetE(caloClusterStruct->fEnergy);
150       caloCluster->SetClusterDisp(caloClusterStruct->fDispersion);
151       caloCluster->SetClusterChi2(caloClusterStruct->fFitQuality);
152       caloCluster->SetPid((Float_t*)&caloClusterStruct->fPID[0]);
153       caloCluster->SetM20(caloClusterStruct->fM20);
154       caloCluster->SetM02(caloClusterStruct->fM02);
155       caloCluster->SetM11(caloClusterStruct->fM11);
156       caloCluster->SetNExMax(caloClusterStruct->fNExMax);
157       caloCluster->SetEmcCpvDistance(caloClusterStruct->fEmcCpvDistance);
158       caloCluster->SetDistanceToBadChannel(caloClusterStruct->fDistToBadChannel);
159       caloCluster->SetNCells(caloClusterStruct->fNCells);
160       caloCluster->SetCellsAbsId(caloClusterStruct->fCellsAbsId);
161       caloCluster->SetCellsAmplitudeFraction(caloClusterStruct->fCellsAmpFraction);
162       fESDEventPtr->AddCaloCluster(caloCluster);
163        */
164       fNCaloClusters++;  
165     }
166   
167   return 0;
168 }
169
170 void 
171 AliHLTPHOSESDMaker::ResetESD()
172 {
173   fNCaloClusters = 0;
174   // fCaloClustersPtr->Delete();
175 }
176