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