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