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