]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
Fixing comments
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.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 "AliHLTPHOSDigitMakerComponent.h"
19 #include "AliHLTPHOSDigitMaker.h"
20 #include "AliHLTPHOSDigitDataStruct.h"
21 #include "AliHLTPHOSChannelDataHeaderStruct.h"
22 #include "AliHLTPHOSChannelDataStruct.h"
23 #include "TFile.h"
24 #include <sys/stat.h>
25 #include <sys/types.h>
26
27
28 /** 
29  * @file   AliHLTPHOSDigitMakerComponent.cxx
30  * @author Oystein Djuvsland
31  * @date   
32  * @brief  A digit maker component for PHOS HLT
33 */
34
35 // see below for class documentation
36 // or
37 // refer to README to build package
38 // or
39 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40
41
42 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
43
44 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
45   AliHLTPHOSProcessor(),
46   fDigitMakerPtr(0),
47   fDigitContainerPtr(0)
48 {
49   //see header file for documentation
50 }
51
52
53 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
54 {
55   //see header file for documentation
56 }
57
58 int 
59 AliHLTPHOSDigitMakerComponent::Deinit()
60
61   //see header file for documentation
62   if(fDigitMakerPtr)
63     {
64       delete fDigitMakerPtr;
65       fDigitMakerPtr = 0;
66     }
67   return 0;
68 }
69
70 const char*
71 AliHLTPHOSDigitMakerComponent::GetComponentID()
72 {
73   //see header file for documentation
74   return "PhosDigitMaker";
75 }
76
77
78 void
79 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
80
81   //see header file for documentation
82   list.clear();
83   list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
84 }
85
86 AliHLTComponentDataType 
87 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
88 {
89   //see header file for documentation
90   return AliHLTPHOSDefinitions::fgkDigitDataType;
91 }
92
93
94 void 
95 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
96 {
97   //see header file for documentation
98   constBase = 0;
99   inputMultiplier = (float)sizeof(AliHLTPHOSDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
100 }
101
102 int 
103 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
104                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
105                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
106 {
107   //see header file for documentation
108   UInt_t offset           = 0; 
109   UInt_t mysize           = 0;
110   Int_t digitCount        = 0;
111   Int_t ret               = 0;
112
113   AliHLTUInt8_t* outBPtr;
114   outBPtr = outputPtr;
115   const AliHLTComponentBlockData* iter = 0; 
116   unsigned long ndx; 
117
118   UInt_t specification = 0;
119   AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
120   
121   fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(outputPtr));
122
123   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
124     {
125       iter = blocks+ndx;
126       
127       if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
128         {
129           HLTDebug("Data block is not of type fgkChannelDataType");
130           continue;
131         }
132
133       specification |= iter->fSpecification;
134       tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
135     
136       ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTPHOSDigitDataStruct)));
137       if(ret == -1) 
138         {
139           HLTError("Trying to write over buffer size");
140           return -ENOBUFS;
141         }
142       digitCount += ret; 
143     }
144   
145   mysize += digitCount*sizeof(AliHLTPHOSDigitDataStruct);
146
147   HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
148
149   if(mysize > 0) 
150     {
151       AliHLTComponentBlockData bd;
152       FillBlockData( bd );
153       bd.fOffset = offset;
154       bd.fSize = mysize;
155       bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
156       bd.fSpecification = specification;
157       outputBlocks.push_back(bd);
158     }
159
160   fDigitMakerPtr->Reset();
161
162   size = mysize; 
163
164   return 0;
165 }
166
167
168 int
169 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
170 {
171   //see header file for documentation
172
173   fDigitMakerPtr = new AliHLTPHOSDigitMaker();
174   
175   for(int i = 0; i < argc; i++)
176     {
177       if(!strcmp("-lowgainfactor", argv[i]))
178         {
179           fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
180         }
181       if(!strcmp("-highgainfactor", argv[i]))
182         {
183           fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
184         }
185       if(!strcmp("-reverseorder", argv[i]))
186         {
187           fDigitMakerPtr->SetOrdered(false);
188         }
189     }
190  
191   //fDigitMakerPtr->SetDigitThreshold(2);
192
193   return 0;
194 }
195
196 AliHLTComponent*
197 AliHLTPHOSDigitMakerComponent::Spawn()
198 {
199   //see header file for documentation
200   return new AliHLTPHOSDigitMakerComponent();
201 }