]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRcuDigitMakerComponent.cxx
Coding conventions and minor fixes
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuDigitMakerComponent.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 #include "AliHLTPHOSRcuDigitMakerComponent.h"
17 #include "AliHLTPHOSRcuDigitMaker.h"
18 #include "TTree.h"
19 #include "AliHLTPHOSRcuProcessor.h"
20 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
21 #include "AliHLTPHOSRcuDigitContainerDataStruct.h"
22 #include "TClonesArray.h"
23 #include "TFile.h"
24 #include <sys/stat.h>
25 #include <sys/types.h>
26
27 const AliHLTComponentDataType AliHLTPHOSRcuDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
28
29 AliHLTPHOSRcuDigitMakerComponent gAliHLTPHOSRcuDigitMakerComponent;
30
31 AliHLTPHOSRcuDigitMakerComponent::AliHLTPHOSRcuDigitMakerComponent() :
32   AliHLTPHOSRcuProcessor(),
33   fDigitMakerPtr(0),
34   fEvtCnt(0)
35 {
36   //comment
37 }
38
39 AliHLTPHOSRcuDigitMakerComponent::~AliHLTPHOSRcuDigitMakerComponent()
40 {
41   //comment
42 }
43
44 int 
45 AliHLTPHOSRcuDigitMakerComponent::Deinit()
46
47   //comment
48   if(fDigitMakerPtr)
49     {
50       delete fDigitMakerPtr;
51       fDigitMakerPtr = 0;
52     }
53   return 0;
54 }
55
56 const char*
57 AliHLTPHOSRcuDigitMakerComponent::GetComponentID()
58 {
59   //comment
60   return "PhosRcuDigitMaker";
61 }
62
63 void
64
65 AliHLTPHOSRcuDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
66
67  //Get datatypes for input
68   const AliHLTComponentDataType* pType=fgkInputDataTypes;
69   while (pType->fID!=0) {
70     list.push_back(*pType); 
71     pType++;
72   }
73 }
74
75 AliHLTComponentDataType 
76 AliHLTPHOSRcuDigitMakerComponent::GetOutputDataType()
77 {
78   //comment
79   return AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
80 }
81
82
83 void 
84 AliHLTPHOSRcuDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
85 {
86   //comment
87   constBase = 30;
88   inputMultiplier = 1;
89 }
90
91 int 
92 AliHLTPHOSRcuDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
93                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
94                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
95 {
96   cout << "AliHLTPHOSRcuDigitMakerComponent::DoEven TP1"  << endl;
97
98    //Do event
99      
100   UInt_t tSize            = 0;
101   UInt_t offset           = 0; 
102   UInt_t mysize           = 0;
103   //Int_t nRecPoints        = 0;
104   //Int_t index             = 0;
105   
106   //Int_t fileCount = 0;
107   Int_t digitCount = 0;
108   //char filename [50];
109
110
111   AliHLTUInt8_t* outBPtr;
112   outBPtr = outputPtr;
113   const AliHLTComponentBlockData* iter = 0; 
114   unsigned long ndx; 
115
116  cout << "AliHLTPHOSRcuDigitMakerComponent::DoEven TP2"  << endl;
117   fDigitContainerPtr = (AliHLTPHOSRcuDigitContainerDataStruct*)outBPtr;
118   //fDigitMakerPtr->SetDigitContainerStruct(fDigitContainerPtr);
119   fDigitMakerPtr->SetDigitContainerStruct((AliHLTPHOSRcuDigitContainerDataStruct*)outBPtr);
120  cout << "AliHLTPHOSRcuDigitMakerComponent::DoEven TP3"  << endl;
121   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
122     {
123       iter = blocks+ndx;
124       
125       if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
126         {
127           //      cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
128           continue;
129
130         }
131       
132       
133
134       digitCount = fDigitMakerPtr->MakeDigits(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
135     }
136   fEvtCnt++;
137   
138   mysize = 0;
139   offset = tSize;
140       
141   mysize += sizeof(AliHLTPHOSRcuDigitContainerDataStruct);
142   ((AliHLTPHOSRcuDigitContainerDataStruct*)outBPtr)->fNDigits = digitCount;
143   AliHLTComponentBlockData bd;
144   FillBlockData( bd );
145   bd.fOffset = offset;
146   bd.fSize = mysize;
147   bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTDigitDataType;
148   bd.fSpecification = 0xFFFFFFFF;
149   outputBlocks.push_back( bd );
150        
151   tSize += mysize;
152   outBPtr += mysize;
153       
154   if( tSize > size )
155     {
156       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuDigitMakerComponent::DoEvent", "Too much data",
157                "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
158                , tSize, size );
159       return EMSGSIZE;
160     }
161       
162   fDigitMakerPtr->Reset();
163   
164   if(fEvtCnt % 10 == 0)
165     {
166       cout << "Event #: " << fEvtCnt << endl;
167       cout << "  - Number of digits found: " << digitCount << endl;
168     }
169   
170   return 0;
171 }
172
173
174 int
175 AliHLTPHOSRcuDigitMakerComponent::DoInit(int argc, const char** argv )
176 {
177   //Do initialization
178
179   fDigitMakerPtr = new AliHLTPHOSRcuDigitMaker();
180   
181   for(int i = 0; i < argc; i++)
182     {
183       if(!strcmp("-threshold", argv[i]))
184         fDigitMakerPtr->SetDigitThreshold(atoi(argv[i+1]));
185       if(!strcmp("-presamples", argv[i]))
186         fDigitMakerPtr->SetNrPresamples(atoi(argv[i+1]));
187     }
188  
189   //fDigitMakerPtr->SetDigitThreshold(2);
190
191   return 0;
192 }
193
194 AliHLTComponent*
195 AliHLTPHOSRcuDigitMakerComponent::Spawn()
196 {
197   //comment
198   return new AliHLTPHOSRcuDigitMakerComponent();
199 }