]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMaker.cxx
Fixing memory leaks (Christian)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMaker.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  * @file   AliHLTPHOSClusterizer.cxx
17  * @author Oystein Djuvsland
18  * @date 
19  * @brief  Clusterizer for PHOS HLT  
20  */
21       
22
23 // see header file for class documentation
24 // or
25 // refer to README to build package
26 // or
27 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
28
29 #include "AliHLTPHOSDigitMaker.h"
30 #include "AliHLTPHOSDigit.h"
31 #include "AliHLTPHOSConstants.h"
32 #include "AliHLTPHOSBaseline.h"
33 #include "TTree.h"
34 #include "TBranch.h"
35 #include "TClonesArray.h"
36 #include "TFile.h"
37
38 #include "AliHLTPHOSValidCellDataStruct.h"
39 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
40 #include "AliHLTPHOSDigitDataStruct.h"
41 #include "AliHLTPHOSDigitContainerDataStruct.h"
42 #include "AliHLTPHOSSharedMemoryInterface.h" // added by PTH
43
44 ClassImp(AliHLTPHOSDigitMaker);
45
46 using namespace PhosHLTConst;
47
48 AliHLTPHOSDigitMaker::AliHLTPHOSDigitMaker() :
49   AliHLTPHOSBase(),
50   fCellDataPtr(0),
51   // fDigitContainerStructPtr(0),
52   fDigitArrayPtr(0),
53   fDigitPtr(0),
54   // fDigitStructPtr(0),
55   fDigitCount(0), 
56   fNrPresamples(10),
57   fDigitThreshold(0),
58   fShmPtr(0)
59 {
60   fShmPtr = new AliHLTPHOSSharedMemoryInterface();
61   // See header file for documentation
62 }
63   
64 AliHLTPHOSDigitMaker::~AliHLTPHOSDigitMaker() 
65 {
66   //See header file for documentation
67 }
68
69
70 /*
71  *modified by PTH to use new interface too shared memory
72  */
73 Int_t
74 AliHLTPHOSDigitMaker::MakeDigits(AliHLTPHOSRcuCellEnergyDataStruct* rcuData)
75 {
76   //See header file for documentation
77   Int_t i = 0;
78   Int_t j = 0;
79   Int_t x = -1;
80   Int_t z = -1;
81   Float_t amplitude = 0;
82
83   fShmPtr->SetMemory(rcuData);
84   // for ( i = 0; i < rcuData->fCnt; i++ )
85     //  {
86   fCellDataPtr = fShmPtr->NextChannel();
87
88   while(fCellDataPtr != 0)
89     {
90   
91       fCellDataPtr = & ( rcuData->fValidData[i] );
92       x = fCellDataPtr->fX + rcuData->fRcuX * N_XCOLUMNS_RCU;
93       z = fCellDataPtr->fZ + rcuData->fRcuZ * N_ZROWS_RCU;
94       amplitude = fCellDataPtr->fEnergy;
95   
96       if ( amplitude > fDigitThreshold )
97         {
98           fDigitStructPtr = & ( fDigitContainerStructPtr->fDigitDataStruct[j + fDigitCount] );
99           fDigitStructPtr->fX = ( fCellDataPtr->fX + rcuData->fRcuX * N_XCOLUMNS_RCU );
100           fDigitStructPtr->fZ = ( fCellDataPtr->fZ + rcuData->fRcuZ * N_ZROWS_RCU );
101           fDigitStructPtr->fAmplitude = ( amplitude );
102           fDigitStructPtr->fTime = ( fCellDataPtr->fTime );
103           fDigitStructPtr->fGain = ( fCellDataPtr->fGain );
104           fDigitStructPtr->SetRawData ( fCellDataPtr->fData );
105           fDigitStructPtr->fCrazyness = ( fCellDataPtr->fCrazyness );
106           fDigitStructPtr->fBaseline = -1;
107           j++;
108         }
109       
110       fCellDataPtr = fShmPtr->NextChannel();
111     }
112   //  }
113   fDigitCount += j;
114   return fDigitCount; 
115 }
116
117
118 /*
119 Int_t
120 AliHLTPHOSDigitMaker::MakeDigits(AliHLTPHOSRcuCellEnergyDataStruct* rcuData)
121 {
122
123   //See header file for documentation
124   Int_t i = 0;
125   Int_t j = 0;
126   Int_t x = -1;
127   Int_t z = -1;
128   Float_t amplitude = 0;
129   for ( i = 0; i < rcuData->fCnt; i++ )
130   {
131     fCellDataPtr = & ( rcuData->fValidData[i] );
132     x = fCellDataPtr->fX + rcuData->fRcuX * N_XCOLUMNS_RCU;
133     z = fCellDataPtr->fZ + rcuData->fRcuZ * N_ZROWS_RCU;
134     amplitude = fCellDataPtr->fEnergy;
135     if ( amplitude > fDigitThreshold )
136       {
137         fDigitStructPtr = & ( fDigitContainerStructPtr->fDigitDataStruct[j + fDigitCount] );
138         fDigitStructPtr->fX = ( fCellDataPtr->fX + rcuData->fRcuX * N_XCOLUMNS_RCU );
139         fDigitStructPtr->fZ = ( fCellDataPtr->fZ + rcuData->fRcuZ * N_ZROWS_RCU );
140         fDigitStructPtr->fAmplitude = ( amplitude );
141         fDigitStructPtr->fTime = ( fCellDataPtr->fTime );
142         fDigitStructPtr->fGain = ( fCellDataPtr->fGain );
143         fDigitStructPtr->SetRawData ( fCellDataPtr->fData );
144         fDigitStructPtr->fCrazyness = ( fCellDataPtr->fCrazyness );
145         fDigitStructPtr->fBaseline = -1;
146         j++;
147       }
148   }
149   fDigitCount += j;
150   return fDigitCount; 
151 }
152 */
153
154 /*
155 Int_t
156 AliHLTPHOSDigitMaker::SetDigitsTree(TTree *tree)
157 {
158   TBranch * digBranch = tree->Branch("digits","TClonesArray",fDebugDigitArrayPtr); 
159 }
160 */
161
162 void
163 AliHLTPHOSDigitMaker::Reset()
164
165   //fDigitArrayPtr->Clear();
166   fDigitCount = 0;
167 }
168
169   
170
171  
172