]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALDigitMakerComponent.cxx
Fixing rule violations: commented out everything
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALDigitMakerComponent.cxx
1  // $Id$
2
3  /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        *
5  * All rights reserved.                                                   *
6  *                                                                        *
7  * Primary Authors: Oystein Djuvsland                                     *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 #include "AliHLTEMCALDigitMakerComponent.h"
19 #include "AliHLTCaloDigitMaker.h"
20 #include "AliHLTCaloDigitDataStruct.h"
21 #include "AliHLTCaloChannelDataHeaderStruct.h"
22 #include "AliHLTCaloChannelDataStruct.h"
23 #include "AliHLTEMCALMapper.h"
24 #include "AliHLTEMCALDefinitions.h"
25 #include "TFile.h"
26 #include <sys/stat.h>
27 #include <sys/types.h>
28
29
30 /** 
31  * @file   AliHLTEMCALDigitMakerComponent.cxx
32  * @author Oystein Djuvsland
33  * @date   
34  * @brief  A digit maker component for EMCAL HLT
35 */
36
37 // see below for class documentation
38 // or
39 // refer to README to build package
40 // or
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
42
43
44 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
45
46 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
47   AliHLTCaloProcessor(),
48   fDigitMakerPtr(0),
49   fDigitContainerPtr(0)
50 {
51   //see header file for documentation
52 }
53
54
55 AliHLTEMCALDigitMakerComponent::~AliHLTEMCALDigitMakerComponent()
56 {
57   //see header file for documentation
58 }
59
60 int 
61 AliHLTEMCALDigitMakerComponent::Deinit()
62
63   //see header file for documentation
64   if(fDigitMakerPtr)
65     {
66       delete fDigitMakerPtr;
67       fDigitMakerPtr = 0;
68     }
69   return 0;
70 }
71
72 const char*
73 AliHLTEMCALDigitMakerComponent::GetComponentID()
74 {
75   //see header file for documentation
76   return "EmcalDigitMaker";
77 }
78
79
80 void
81 AliHLTEMCALDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
82
83   //see header file for documentation
84   list.clear();
85   list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
86 }
87
88 AliHLTComponentDataType 
89 AliHLTEMCALDigitMakerComponent::GetOutputDataType()
90 {
91   //see header file for documentation
92 //  return AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginEMCAL;
93   return AliHLTEMCALDefinitions::fgkDigitDataType;
94 }
95
96
97 void 
98 AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
99 {
100   //see header file for documentation
101   constBase = 0;
102   inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
103 }
104
105 int 
106 AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
107                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
108                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
109 {
110   //see header file for documentation
111   UInt_t offset           = 0; 
112   UInt_t mysize           = 0;
113   Int_t digitCount        = 0;
114   Int_t ret               = 0;
115
116   AliHLTUInt8_t* outBPtr;
117   outBPtr = outputPtr;
118   const AliHLTComponentBlockData* iter = 0; 
119   unsigned long ndx; 
120
121   UInt_t specification = 0;
122   AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
123   
124   //  fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
125
126   fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
127
128   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129     {
130       iter = blocks+ndx;
131       
132       if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
133         {
134           HLTError("Data block is not of type fgkChannelDataType");
135           continue;
136         }
137
138       specification |= iter->fSpecification;
139       tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
140     
141       ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
142       if(ret == -1) 
143         {
144           HLTError("Trying to write over buffer size");
145           return -ENOBUFS;
146         }
147       digitCount += ret; 
148     }
149   
150   mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
151
152   HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
153
154   if(mysize > 0) 
155     {
156       AliHLTComponentBlockData bd;
157       FillBlockData( bd );
158       bd.fOffset = offset;
159       bd.fSize = mysize;
160       bd.fDataType = AliHLTEMCALDefinitions::fgkDigitDataType;
161       bd.fSpecification = specification;
162       outputBlocks.push_back(bd);
163     }
164
165   fDigitMakerPtr->Reset();
166
167   size = mysize; 
168
169   return 0;
170 }
171
172
173 int
174 AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
175 {
176   //see header file for documentation
177
178   fDigitMakerPtr = new AliHLTCaloDigitMaker("EMCAL");
179
180   AliHLTCaloMapper *mapper = new AliHLTEMCALMapper(2);
181   fDigitMakerPtr->SetMapper(mapper);
182   
183   for(int i = 0; i < argc; i++)
184     {
185       if(!strcmp("-lowgainfactor", argv[i]))
186         {
187           fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
188         }
189       if(!strcmp("-highgainfactor", argv[i]))
190         {
191           fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
192         }
193     }
194  
195   //fDigitMakerPtr->SetDigitThreshold(2);
196
197   return 0;
198 }
199
200 AliHLTComponent*
201 AliHLTEMCALDigitMakerComponent::Spawn()
202 {
203   //see header file for documentation
204   return new AliHLTEMCALDigitMakerComponent();
205 }